diff mbox series

[2/3] dma-buf/heaps: replace kmap_atomic with kmap_local_page

Message ID 20241001175057.27172-1-quic_pintu@quicinc.com (mailing list archive)
State New, archived
Headers show
Series [1/3] dma-buf: replace symbolic permission S_IRUGO with octal 0444 | expand

Commit Message

Pintu Kumar Oct. 1, 2024, 5:50 p.m. UTC
Use of kmap_atomic/kunmap_atomic is deprecated, use
kmap_local_page/kunmap_local instead.

This is reported by checkpatch.
Also fix repeated word issue.

WARNING: Deprecated use of 'kmap_atomic', prefer 'kmap_local_page' instead
+                       void *vaddr = kmap_atomic(page);

WARNING: Deprecated use of 'kunmap_atomic', prefer 'kunmap_local' instead
+                       kunmap_atomic(vaddr);

WARNING: Possible repeated word: 'by'
+                        * has been killed by by SIGKILL

total: 0 errors, 3 warnings, 405 lines checked

Signed-off-by: Pintu Kumar <quic_pintu@quicinc.com>
---
 drivers/dma-buf/heaps/cma_heap.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Pintu Agarwal Oct. 10, 2024, 5:26 a.m. UTC | #1
On Wed, 2 Oct 2024 at 02:54, T.J. Mercier <tjmercier@google.com> wrote:
>
> On Tue, Oct 1, 2024 at 7:51 PM Pintu Kumar <quic_pintu@quicinc.com> wrote:
> >
> > Use of kmap_atomic/kunmap_atomic is deprecated, use
> > kmap_local_page/kunmap_local instead.
> >
> > This is reported by checkpatch.
> > Also fix repeated word issue.
> >
> > WARNING: Deprecated use of 'kmap_atomic', prefer 'kmap_local_page' instead
> > +                       void *vaddr = kmap_atomic(page);
> >
> > WARNING: Deprecated use of 'kunmap_atomic', prefer 'kunmap_local' instead
> > +                       kunmap_atomic(vaddr);
> >
> > WARNING: Possible repeated word: 'by'
> > +                        * has been killed by by SIGKILL
> >
> > total: 0 errors, 3 warnings, 405 lines checked
> >
> > Signed-off-by: Pintu Kumar <quic_pintu@quicinc.com>
>
> Reviewed-by: T.J. Mercier <tjmercier@google.com>
>
> The Android kernels have been doing this for over a year, so should be
> pretty well tested at this point:
> https://r.android.com/c/kernel/common/+/2500840
>
Thank you TJ for the review.
Hope this will be picked soon.

> > ---
> >  drivers/dma-buf/heaps/cma_heap.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/dma-buf/heaps/cma_heap.c b/drivers/dma-buf/heaps/cma_heap.c
> > index 93be88b805fe..8c55431cc16c 100644
> > --- a/drivers/dma-buf/heaps/cma_heap.c
> > +++ b/drivers/dma-buf/heaps/cma_heap.c
> > @@ -309,13 +309,13 @@ static struct dma_buf *cma_heap_allocate(struct dma_heap *heap,
> >                 struct page *page = cma_pages;
> >
> >                 while (nr_clear_pages > 0) {
> > -                       void *vaddr = kmap_atomic(page);
> > +                       void *vaddr = kmap_local_page(page);
> >
> >                         memset(vaddr, 0, PAGE_SIZE);
> > -                       kunmap_atomic(vaddr);
> > +                       kunmap_local(vaddr);

However, I realized one more thing.
This can be easily replaced by:
memset_page(page, 0, 0, PAGE_SIZE);

I will push this in new patchset once this is available in linux-next.

Thanks,
Pintu
diff mbox series

Patch

diff --git a/drivers/dma-buf/heaps/cma_heap.c b/drivers/dma-buf/heaps/cma_heap.c
index 93be88b805fe..8c55431cc16c 100644
--- a/drivers/dma-buf/heaps/cma_heap.c
+++ b/drivers/dma-buf/heaps/cma_heap.c
@@ -309,13 +309,13 @@  static struct dma_buf *cma_heap_allocate(struct dma_heap *heap,
 		struct page *page = cma_pages;
 
 		while (nr_clear_pages > 0) {
-			void *vaddr = kmap_atomic(page);
+			void *vaddr = kmap_local_page(page);
 
 			memset(vaddr, 0, PAGE_SIZE);
-			kunmap_atomic(vaddr);
+			kunmap_local(vaddr);
 			/*
 			 * Avoid wasting time zeroing memory if the process
-			 * has been killed by by SIGKILL
+			 * has been killed by SIGKILL.
 			 */
 			if (fatal_signal_pending(current))
 				goto free_cma;