Skip to contentSkip to conversation

staging: media: atomisp: Use kmap_local_page() in hmm_set()

PATCH In review Fabio M. De Francesco 3 participants 3 messages Apr 13, 2022 – Apr 20, 2022

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

PATCH 1/1 staging: media: atomisp: Use kmap_local_page() in hmm_set()

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.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · 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.

Quoted 8 lines

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().

Quoted 29 lines
---
 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.34.1
Tested-by on v1 1/1
#2 lore raw
In reply to Fabio M. De Francesco

Hi,

Quoted 4 lines · 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.

Quoted 8 lines

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().

I've successfully tested this on both the front and back cams of a chuwi hi8 tablet:

Regards,

Hans

Quoted 26 lines
---
 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;