Am 22.06.22 um 12:07 schrieb Pierre-Eric Pelloux-Prayer:
If amdgpu.vramlimit=XXXX is used, amdgpu_gmc_vram_location will update
real_vram_size based on this value.
mc_vram_size is the real amount of VRAM, initialized in gmc_..._mc_init.

Thinking more about it I came to the conclusion that this patch here is not correct.

Even when we restricted the driver to use only a fraction of the VRAM we can still read/write all of it through the debugging interfaces.

That could be useful if we try to track down things like random memory corruption etc..

Regards,
Christian.


Signed-off-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-pra...@amd.com>
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 10 +++++-----
  1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 952e99e6d07e..8f245e9f8f7c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -2252,10 +2252,10 @@ static ssize_t amdgpu_ttm_vram_read(struct file *f, 
char __user *buf,
        if (size & 0x3 || *pos & 0x3)
                return -EINVAL;
- if (*pos >= adev->gmc.mc_vram_size)
+       if (*pos >= adev->gmc.real_vram_size)
                return -ENXIO;
- size = min(size, (size_t)(adev->gmc.mc_vram_size - *pos));
+       size = min(size, (size_t)(adev->gmc.real_vram_size - *pos));
        while (size) {
                size_t bytes = min(size, AMDGPU_TTM_VRAM_MAX_DW_READ * 4);
                uint32_t value[AMDGPU_TTM_VRAM_MAX_DW_READ];
@@ -2288,13 +2288,13 @@ static ssize_t amdgpu_ttm_vram_write(struct file *f, 
const char __user *buf,
        if (size & 0x3 || *pos & 0x3)
                return -EINVAL;
- if (*pos >= adev->gmc.mc_vram_size)
+       if (*pos >= adev->gmc.real_vram_size)
                return -ENXIO;
while (size) {
                uint32_t value;
- if (*pos >= adev->gmc.mc_vram_size)
+               if (*pos >= adev->gmc.real_vram_size)
                        return result;
r = get_user(value, (uint32_t *)buf);
@@ -2442,7 +2442,7 @@ void amdgpu_ttm_debugfs_init(struct amdgpu_device *adev)
        struct dentry *root = minor->debugfs_root;
debugfs_create_file_size("amdgpu_vram", 0444, root, adev,
-                                &amdgpu_ttm_vram_fops, adev->gmc.mc_vram_size);
+                                &amdgpu_ttm_vram_fops, 
adev->gmc.real_vram_size);
        debugfs_create_file("amdgpu_iomem", 0444, root, adev,
                            &amdgpu_ttm_iomem_fops);
        debugfs_create_file("amdgpu_vram_mm", 0444, root, adev,

Reply via email to