Skip to content

Commit e7a8594

Browse files
Tom St Denisalexdeucher
authored andcommitted
drm/amd/amdgpu: Assign GART pages to AMD device mapping
This allows kernel mapped pages like the PDB and PTB to be read via the iomem debugfs when there is no vram in the system. Signed-off-by: Tom St Denis <tom.stdenis@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Cc: stable@vger.kernel.org # 6.7.x
1 parent f180768 commit e7a8594

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ int amdgpu_gart_table_ram_alloc(struct amdgpu_device *adev)
121121
struct amdgpu_bo_param bp;
122122
dma_addr_t dma_addr;
123123
struct page *p;
124+
unsigned long x;
124125
int ret;
125126

126127
if (adev->gart.bo != NULL)
@@ -130,6 +131,10 @@ int amdgpu_gart_table_ram_alloc(struct amdgpu_device *adev)
130131
if (!p)
131132
return -ENOMEM;
132133

134+
/* assign pages to this device */
135+
for (x = 0; x < (1UL << order); x++)
136+
p[x].mapping = adev->mman.bdev.dev_mapping;
137+
133138
/* If the hardware does not support UTCL2 snooping of the CPU caches
134139
* then set_memory_wc() could be used as a workaround to mark the pages
135140
* as write combine memory.
@@ -223,6 +228,7 @@ void amdgpu_gart_table_ram_free(struct amdgpu_device *adev)
223228
unsigned int order = get_order(adev->gart.table_size);
224229
struct sg_table *sg = adev->gart.bo->tbo.sg;
225230
struct page *p;
231+
unsigned long x;
226232
int ret;
227233

228234
ret = amdgpu_bo_reserve(adev->gart.bo, false);
@@ -234,6 +240,8 @@ void amdgpu_gart_table_ram_free(struct amdgpu_device *adev)
234240
sg_free_table(sg);
235241
kfree(sg);
236242
p = virt_to_page(adev->gart.ptr);
243+
for (x = 0; x < (1UL << order); x++)
244+
p[x].mapping = NULL;
237245
__free_pages(p, order);
238246

239247
adev->gart.ptr = NULL;

0 commit comments

Comments
 (0)