Skip to contentSkip to conversation

drivers/target: Call page_address() on page acquired with GFP_KERNEL flag

PATCH In review Sumitra Sharma 2 participants 2 messages Jun 14, 2023 – Jun 26, 2023

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

PATCH 1/1 drivers/target: Call page_address() on page acquired with GFP_KERNEL flag

rd_allocate_sgl_table() acquires a page with alloc_pages(GFP_KERNEL, 0). Pages allocated with GFP_KERNEL cannot come from Highmem. This is why there is no need to call kmap() on them.

Therefore, use a plain page_address() on that page.

---
 drivers/target/target_core_rd.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/target/target_core_rd.c +1 -2
index 6648c1c90e19..d8ea6aff39a2 100644
@@ -159,9 +159,8 @@ static int rd_allocate_sgl_table(struct rd_dev *rd_dev, struct rd_dev_sg_table *
 			sg_assign_page(&sg[j], pg);
 			sg[j].length = PAGE_SIZE;
 
-			p = kmap(pg);
+			p = page_address(pg);
 			memset(p, init_payload, PAGE_SIZE);
-			kunmap(pg);
 		}
 
 		page_offset += sg_per_table;
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Sumitra Sharma

rd_allocate_sgl_table() acquires a page with alloc_pages(GFP_KERNEL, 0). Pages allocated with GFP_KERNEL cannot come from Highmem. This is why there is no need to call kmap() on them.

Therefore, use a plain page_address() on that page.

LGTM:

Quoted 22 lines
---
 drivers/target/target_core_rd.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/target/target_core_rd.c +1 -2
index 6648c1c90e19..d8ea6aff39a2 100644
@@ -159,9 +159,8 @@ static int rd_allocate_sgl_table(struct rd_dev *rd_dev, struct rd_dev_sg_table *
 			sg_assign_page(&sg[j], pg);
 			sg[j].length = PAGE_SIZE;
 
-			p = kmap(pg);
+			p = page_address(pg);
 			memset(p, init_payload, PAGE_SIZE);
-			kunmap(pg);
 		}
 
 		page_offset += sg_per_table;
Signature · 1 line
2.25.1