[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <44610c2a-9fd1-8d15-a792-a96900e89424@redhat.com>
Date: Wed, 13 Jul 2022 13:59:17 +0800
From: Jason Wang <jasowang@...hat.com>
To: Xie Yongji <xieyongji@...edance.com>, mst@...hat.com,
xiaodong.liu@...el.com, maxime.coquelin@...hat.com,
stefanha@...hat.com
Cc: songmuchun@...edance.com,
virtualization@...ts.linux-foundation.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 2/5] vduse: Use memcpy_{to,from}_page() in do_bounce()
在 2022/7/6 13:05, Xie Yongji 写道:
> kmap_atomic() is being deprecated in favor of kmap_local_page().
>
> The use of kmap_atomic() in do_bounce() is all thread local therefore
> kmap_local_page() is a sufficient replacement.
>
> Convert to kmap_local_page() but, instead of open coding it,
> use the helpers memcpy_to_page() and memcpy_from_page().
>
> Signed-off-by: Xie Yongji <xieyongji@...edance.com>
Acked-by: Jason Wang <jasowang@...hat.com>
> ---
> drivers/vdpa/vdpa_user/iova_domain.c | 9 ++++-----
> 1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/vdpa/vdpa_user/iova_domain.c b/drivers/vdpa/vdpa_user/iova_domain.c
> index bca1f0b8850c..50d7c08d5450 100644
> --- a/drivers/vdpa/vdpa_user/iova_domain.c
> +++ b/drivers/vdpa/vdpa_user/iova_domain.c
> @@ -138,18 +138,17 @@ static void do_bounce(phys_addr_t orig, void *addr, size_t size,
> {
> unsigned long pfn = PFN_DOWN(orig);
> unsigned int offset = offset_in_page(orig);
> - char *buffer;
> + struct page *page;
> unsigned int sz = 0;
>
> while (size) {
> sz = min_t(size_t, PAGE_SIZE - offset, size);
>
> - buffer = kmap_atomic(pfn_to_page(pfn));
> + page = pfn_to_page(pfn);
> if (dir == DMA_TO_DEVICE)
> - memcpy(addr, buffer + offset, sz);
> + memcpy_from_page(addr, page, offset, sz);
> else
> - memcpy(buffer + offset, addr, sz);
> - kunmap_atomic(buffer);
> + memcpy_to_page(page, offset, addr, sz);
>
> size -= sz;
> pfn++;
Powered by blists - more mailing lists