Skip to contentSkip to conversation

drm/amdgpu: Extend the bad page check to page range

PATCH New Xiang Liu 1 participant 1 message Aug 22, 2025

Subsystems (2)
lore
Share & tools
lore

Xiang Liu

author
#0 lore raw

PATCH 1/1 drm/amdgpu: Extend the bad page check to page range

The page range should be checked for the critical region.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +5 -2
index c9df026e53f7..db7fd21b2c04 100644
@@ -406,15 +406,18 @@ int amdgpu_vram_mgr_query_address_block_info(struct amdgpu_vram_mgr *mgr,
 {
 	struct amdgpu_vram_mgr_resource *vres;
 	struct drm_buddy_block *block;
-	u64 start, size;
+	u64 start, size, addr_begin, addr_end;
 	int ret = -ENOENT;
 
+	addr_begin = address & PAGE_MASK;
+	addr_end = address | (PAGE_SIZE - 1);
+
 	mutex_lock(&mgr->lock);
 	list_for_each_entry(vres, &mgr->allocated_vres_list, vres_node) {
 		list_for_each_entry(block, &vres->blocks, link) {
 			start = amdgpu_vram_mgr_block_start(block);
 			size = amdgpu_vram_mgr_block_size(block);
-			if ((start <= address) && (address < (start + size))) {
+			if ((start <= addr_begin) && (addr_end < (start + size))) {
 				info->start = start;
 				info->size = size;
 				memcpy(&info->task, &vres->task, sizeof(vres->task));
Signature · 1 line
2.34.1