Skip to contentSkip to conversation

staging: media: atomisp: Convert to kmap_local_page()

PATCH RESEND In review Fabio M. De Francesco 3 participants 8 messages Jul 7, 2022 – Jul 15, 2022

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover staging: media: atomisp: Convert to kmap_local_page()

After waiting months, I'm resending three conversions to kmap_local_page(). I'd like to ask if there is anything which prevents these patches from being accepted.

Please note that these patches were submitted on April 2022.

For you convenience here are the links to the patches, the "Reviewed-by:" and "Tested-by:" tags:

[PATCH] staging: media: atomisp: Use kmap_local_page() in hmm_store()
https://lore.kernel.org/lkml/[email protected]/
https://lore.kernel.org/lkml/Yli+R7iLZKqO8kVP@iweiny-desk3/
https://lore.kernel.org/lkml/[email protected]/

[PATCH] staging: media: atomisp: Use kmap_local_page() in hmm_set()
https://lore.kernel.org/lkml/[email protected]/
https://lore.kernel.org/lkml/YldNhErgt53RqYp7@iweiny-desk3/
https://lore.kernel.org/lkml/[email protected]/

[PATCH] staging: media: atomisp: Convert kmap() to kmap_local_page()
https://lore.kernel.org/lkml/[email protected]/
https://lore.kernel.org/lkml/[email protected]/

Fabio M. De Francesco (3):
staging: media: atomisp: Convert kmap() to kmap_local_page()
staging: media: atomisp: Use kmap_local_page() in hmm_set()
staging: media: atomisp: Use kmap_local_page() in hmm_store()

 drivers/staging/media/atomisp/pci/hmm/hmm.c | 22 ++++++---------------
 1 file changed, 6 insertions(+), 16 deletions(-)
Signature · 1 line
2.36.1
#1 lore raw

PATCH RESEND 1/3 staging: media: atomisp: Convert kmap() to kmap_local_page()

The use of kmap() is being deprecated in favor of kmap_local_page() where it is feasible. With kmap_local_page(), the mapping is per thread, CPU local and not globally visible.

load_and_flush_by_kmap() is a function where the use of kmap_local_page() in place of kmap() is correctly suited.

Convert load_and_flush_by_kmap() from kmap() to kmap_local_page().

---
 drivers/staging/media/atomisp/pci/hmm/hmm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/media/atomisp/pci/hmm/hmm.c +2 -2
index c1cda16f2dc0..6394385b6637 100644
@@ -350,7 +350,7 @@ static int load_and_flush_by_kmap(ia_css_ptr virt, void *data,
 		idx = (virt - bo->start) >> PAGE_SHIFT;
 		offset = (virt - bo->start) - (idx << PAGE_SHIFT);
 
-		src = (char *)kmap(bo->page_obj[idx].page) + offset;
+		src = (char *)kmap_local_page(bo->page_obj[idx].page) + offset;
 
 		if ((bytes + offset) >= PAGE_SIZE) {
 			len = PAGE_SIZE - offset;
@@ -369,7 +369,7 @@ static int load_and_flush_by_kmap(ia_css_ptr virt, void *data,
 
 		clflush_cache_range(src, len);
 
-		kunmap(bo->page_obj[idx].page);
+		kunmap_local(src);
 	}
 
 	return 0;
Signature · 1 line
2.36.1
#2 lore raw

PATCH RESEND 2/3 staging: media: atomisp: Use kmap_local_page() in hmm_set()

In reply to Fabio M. De Francesco

The use of kmap() is being deprecated in favor of kmap_local_page() where it is feasible. In file pci/hmm/hmm.c, function hmm_set() calls kmap() / kunmap() where kmap_local_page() can instead do the mapping.

With kmap_local_page(), the mapping is per thread, CPU local and not globally visible. Therefore, hmm_set()() is a function where the use of kmap_local_page() in place of kmap() is correctly suited.

Convert the calls of kmap() / kunmap() to kmap_local_page() / kunmap_local().

---
 drivers/staging/media/atomisp/pci/hmm/hmm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/media/atomisp/pci/hmm/hmm.c +2 -2
index 6394385b6637..46ac082cd3f1 100644
@@ -563,7 +563,7 @@ int hmm_set(ia_css_ptr virt, int c, unsigned int bytes)
 		idx = (virt - bo->start) >> PAGE_SHIFT;
 		offset = (virt - bo->start) - (idx << PAGE_SHIFT);
 
-		des = (char *)kmap(bo->page_obj[idx].page) + offset;
+		des = (char *)kmap_local_page(bo->page_obj[idx].page) + offset;
 
 		if ((bytes + offset) >= PAGE_SIZE) {
 			len = PAGE_SIZE - offset;
@@ -579,7 +579,7 @@ int hmm_set(ia_css_ptr virt, int c, unsigned int bytes)
 
 		clflush_cache_range(des, len);
 
-		kunmap(bo->page_obj[idx].page);
+		kunmap_local(des);
 	}
 
 	return 0;
Signature · 1 line
2.36.1
#3 lore raw

PATCH RESEND 3/3 staging: media: atomisp: Use kmap_local_page() in hmm_store()

In reply to Fabio M. De Francesco

The use of kmap() is being deprecated in favor of kmap_local_page() where it is feasible. The same is true for kmap_atomic().

In file pci/hmm/hmm.c, function hmm_store() test if we are in atomic context and, if so, it calls kmap_atomic(), if not, it calls kmap().

First of all, in_atomic() shouldn't be used in drivers. This macro cannot always detect atomic context; in particular, it cannot know about held spinlocks in non-preemptible kernels.

Notwithstanding what it is said above, this code doesn't need to care whether or not it is executing in atomic context. It can simply use kmap_local_page() / kunmap_local() that can instead do the mapping / unmapping regardless of the context.

With kmap_local_page(), the mapping is per thread, CPU local and not globally visible. Therefore, hmm_store()() is a function where the use of kmap_local_page() in place of both kmap() and kmap_atomic() is correctly suited.

Convert the calls of kmap() / kunmap() and kmap_atomic() / kunmap_atomic() to kmap_local_page() / kunmap_local() and drop the unnecessary tests which test if the code is in atomic context.

---
 drivers/staging/media/atomisp/pci/hmm/hmm.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)
drivers/staging/media/atomisp/pci/hmm/hmm.c +2 -12
index 46ac082cd3f1..54188197c3dc 100644
@@ -482,10 +482,7 @@ int hmm_store(ia_css_ptr virt, const void *data, unsigned int bytes)
 		idx = (virt - bo->start) >> PAGE_SHIFT;
 		offset = (virt - bo->start) - (idx << PAGE_SHIFT);
 
-		if (in_atomic())
-			des = (char *)kmap_atomic(bo->page_obj[idx].page);
-		else
-			des = (char *)kmap(bo->page_obj[idx].page);
+		des = (char *)kmap_local_page(bo->page_obj[idx].page);
 
 		if (!des) {
 			dev_err(atomisp_dev,
@@ -512,14 +509,7 @@ int hmm_store(ia_css_ptr virt, const void *data, unsigned int bytes)
 
 		clflush_cache_range(des, len);
 
-		if (in_atomic())
-			/*
-			 * Note: kunmap_atomic requires return addr from
-			 * kmap_atomic, not the page. See linux/highmem.h
-			 */
-			kunmap_atomic(des - offset);
-		else
-			kunmap(bo->page_obj[idx].page);
+		kunmap_local(des);
 	}
 
 	return 0;
Signature · 1 line
2.36.1
Reviewed-by on the v1 series
#4 lore raw
In reply to Fabio M. De Francesco

Hi,

Quoted 19 lines · Fabio M. De Francesco

After waiting months, I'm resending three conversions to kmap_local_page(). I'd like to ask if there is anything which prevents these patches from being accepted.

Please note that these patches were submitted on April 2022.

For you convenience here are the links to the patches, the "Reviewed-by:" and "Tested-by:" tags:

[PATCH] staging: media: atomisp: Use kmap_local_page() in hmm_store()
https://lore.kernel.org/lkml/[email protected]/
https://lore.kernel.org/lkml/Yli+R7iLZKqO8kVP@iweiny-desk3/
https://lore.kernel.org/lkml/[email protected]/

[PATCH] staging: media: atomisp: Use kmap_local_page() in hmm_set()
https://lore.kernel.org/lkml/[email protected]/
https://lore.kernel.org/lkml/YldNhErgt53RqYp7@iweiny-desk3/
https://lore.kernel.org/lkml/[email protected]/

Quoted 8 lines

[PATCH] staging: media: atomisp: Convert kmap() to kmap_local_page()
https://lore.kernel.org/lkml/[email protected]/
https://lore.kernel.org/lkml/[email protected]/

Fabio M. De Francesco (3):
staging: media: atomisp: Convert kmap() to kmap_local_page()
staging: media: atomisp: Use kmap_local_page() in hmm_set()
staging: media: atomisp: Use kmap_local_page() in hmm_store()

Thanks, the entire series looks good to me:

Regards,

Hans

#5 lore raw

Em Fri, 8 Jul 2022 17:55:26 +0200
Hans de Goede <[email protected]> escreveu:

Quoted 26 lines

Hi,

Quoted 23 lines · Fabio M. De Francesco

After waiting months, I'm resending three conversions to kmap_local_page(). I'd like to ask if there is anything which prevents these patches from being accepted.

Please note that these patches were submitted on April 2022.

For you convenience here are the links to the patches, the "Reviewed-by:" and "Tested-by:" tags:

[PATCH] staging: media: atomisp: Use kmap_local_page() in hmm_store()
https://lore.kernel.org/lkml/[email protected]/
https://lore.kernel.org/lkml/Yli+R7iLZKqO8kVP@iweiny-desk3/
https://lore.kernel.org/lkml/[email protected]/

[PATCH] staging: media: atomisp: Use kmap_local_page() in hmm_set()
https://lore.kernel.org/lkml/[email protected]/
https://lore.kernel.org/lkml/YldNhErgt53RqYp7@iweiny-desk3/
https://lore.kernel.org/lkml/[email protected]/

[PATCH] staging: media: atomisp: Convert kmap() to kmap_local_page()
https://lore.kernel.org/lkml/[email protected]/
https://lore.kernel.org/lkml/[email protected]/

Quoted 8 lines
Quoted 4 lines

Fabio M. De Francesco (3):
staging: media: atomisp: Convert kmap() to kmap_local_page()
staging: media: atomisp: Use kmap_local_page() in hmm_set()
staging: media: atomisp: Use kmap_local_page() in hmm_store()

Thanks, the entire series looks good to me:

Yesterday, I applied all pending patches at media-stage, including those. Please check if everything is ok, as I had to solve some trivial conflicts.

Regards,
Mauro

#6 lore raw
Quoted 8 lines · On sabato 9 luglio 2022 18:46:45 CEST Mauro Carvalho Chehab wrote:

Em Fri, 8 Jul 2022 17:55:26 +0200
Hans de Goede <[email protected]> escreveu:

Quoted 5 lines

Hi,

Quoted 2 lines · Fabio M. De Francesco

After waiting months, I'm resending three conversions to kmap_local_page(). I'd like to ask if there is anything which

prevents

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

these patches from being accepted.

Please note that these patches were submitted on April 2022.

For you convenience here are the links to the patches, the "Reviewed-

by:"

Quoted 23 lines
Quoted 23 lines
Quoted 12 lines

and "Tested-by:" tags:

[PATCH] staging: media: atomisp: Use kmap_local_page() in hmm_store()
https://lore.kernel.org/lkml/[email protected]/
https://lore.kernel.org/lkml/Yli+R7iLZKqO8kVP@iweiny-desk3/
https://lore.kernel.org/lkml/[email protected]/

[PATCH] staging: media: atomisp: Use kmap_local_page() in hmm_set()
https://lore.kernel.org/lkml/[email protected]/
https://lore.kernel.org/lkml/YldNhErgt53RqYp7@iweiny-desk3/
https://lore.kernel.org/lkml/[email protected]/

Quoted 8 lines

[PATCH] staging: media: atomisp: Convert kmap() to kmap_local_page()
https://lore.kernel.org/lkml/[email protected]/
https://lore.kernel.org/lkml/[email protected]/

Fabio M. De Francesco (3):
staging: media: atomisp: Convert kmap() to kmap_local_page()
staging: media: atomisp: Use kmap_local_page() in hmm_set()
staging: media: atomisp: Use kmap_local_page() in hmm_store()

Thanks, the entire series looks good to me:

Quoted 9 lines
Quoted 1 line

Yesterday, I applied all pending patches at media-stage, including those. Please check if everything is ok, as I had to solve some trivial conflicts.

Regards,
Mauro

I just checked those patches at media-stage and everything seems fine. Thanks for applying them.

Regards,

Fabio

#7 lore raw

Hi,

Quoted 45 lines · Fabio M. De Francesco
Quoted 8 lines · On sabato 9 luglio 2022 18:46:45 CEST Mauro Carvalho Chehab wrote:

Em Fri, 8 Jul 2022 17:55:26 +0200
Hans de Goede <[email protected]> escreveu:

Quoted 5 lines

Hi,

Quoted 2 lines · Fabio M. De Francesco

After waiting months, I'm resending three conversions to kmap_local_page(). I'd like to ask if there is anything which

prevents

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

these patches from being accepted.

Please note that these patches were submitted on April 2022.

For you convenience here are the links to the patches, the "Reviewed-

by:"

Quoted 29 lines
Quoted 16 lines
Quoted 16 lines

and "Tested-by:" tags:

[PATCH] staging: media: atomisp: Use kmap_local_page() in hmm_store()
https://lore.kernel.org/lkml/[email protected]/
https://lore.kernel.org/lkml/Yli+R7iLZKqO8kVP@iweiny-desk3/
https://lore.kernel.org/lkml/[email protected]/

[PATCH] staging: media: atomisp: Use kmap_local_page() in hmm_set()
https://lore.kernel.org/lkml/[email protected]/
https://lore.kernel.org/lkml/YldNhErgt53RqYp7@iweiny-desk3/
https://lore.kernel.org/lkml/[email protected]/

[PATCH] staging: media: atomisp: Convert kmap() to kmap_local_page()
https://lore.kernel.org/lkml/[email protected]/
https://lore.kernel.org/lkml/[email protected]/

Quoted 8 lines
Quoted 4 lines

Fabio M. De Francesco (3):
staging: media: atomisp: Convert kmap() to kmap_local_page()
staging: media: atomisp: Use kmap_local_page() in hmm_set()
staging: media: atomisp: Use kmap_local_page() in hmm_store()

Thanks, the entire series looks good to me:

Yesterday, I applied all pending patches at media-stage, including those. Please check if everything is ok, as I had to solve some trivial conflicts.

Quoted 5 lines
Quoted 3 lines

Regards,
Mauro

I just checked those patches at media-stage and everything seems fine. Thanks for applying them.

The landing of my series in media-stage looks good too,

Thanks.

Regards,

Hans