drm/amdgpu: return an error for hw access in INFO ioctl when in reset
Subsystems (2)
PATCH 1/1 drm/amdgpu: return an error for hw access in INFO ioctl when in reset
When the GPU is in reset, accessing the hw is unreliable and could interfere with the reset. Return an error in those cases.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +6 -0
@@ -684,6 +684,9 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_fileif (info->read_mmr_reg.count >128 )return -EINVAL ; +if (adev->in_gpu_reset) +return -EPERM ; + regs =kmalloc_array (info->read_mmr_reg.count,sizeof (*regs),GFP_KERNEL );if (!regs)return -ENOMEM ;
@@ -854,6 +857,9 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_fileif (!adev->pm.dpm_enabled)return -ENOENT ; +if (adev->in_gpu_reset) +return -EPERM ; +switch (info->sensor_info.type) {case AMDGPU_INFO_SENSOR_GFX_SCLK :/* get sclk in Mhz */
Signature · 6 lines
2.25.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
ping?
Quoted 34 lines · Alex Deucher
When the GPU is in reset, accessing the hw is unreliable and could interfere with the reset. Return an error in those cases.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +6
-1@@ -684,6 +684,9 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_fileif (info->read_mmr_reg.count >128 )return -EINVAL ; +if (adev->in_gpu_reset) +return -EPERM ; + regs =kmalloc_array (info->read_mmr_reg.count,sizeof (*regs),GFP_KERNEL );if (!regs)return -ENOMEM ;@@ -854,6 +857,9 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_fileif (!adev->pm.dpm_enabled)return -ENOENT ; +if (adev->in_gpu_reset) +return -EPERM ; +switch (info->sensor_info.type) {case AMDGPU_INFO_SENSOR_GFX_SCLK :/* get sclk in Mhz */ --
Quoted 2 lines
2.25.4
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
I don't think this is a good idea, we should probably rather wait for the GPU reset to finish by taking the appropriate lock.
Christian.
Am 01.07.20 um 07:33 schrieb Alex Deucher:
Quoted 29 lines
ping?
Quoted 26 lines · Alex Deucher
When the GPU is in reset, accessing the hw is unreliable and could interfere with the reset. Return an error in those cases.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +3
-0@@ -684,6 +684,9 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_fileif (info->read_mmr_reg.count >128 )return -EINVAL ; +if (adev->in_gpu_reset) +return -EPERM ; + regs =kmalloc_array (info->read_mmr_reg.count,sizeof (*regs),GFP_KERNEL );if (!regs)return -ENOMEM ;@@ -854,6 +857,9 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_fileif (!adev->pm.dpm_enabled)return -ENOENT ;
Quoted 13 lines
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +3
-1+if (adev->in_gpu_reset) +return -EPERM ; +switch (info->sensor_info.type) {case AMDGPU_INFO_SENSOR_GFX_SCLK :/* get sclk in Mhz */ --2.25.4
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
[AMD Official Use Only - Internal Distribution Only]
Hi, Christian and Alex
Not only amdgpu ioctls, but amdkfd ioctls also have the same issue.
Best Regards
Dennis Li
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Christian König
Sent: Wednesday, July 1, 2020 4:20 PM
To: Alex Deucher <[email protected]>; amd-gfx list <[email protected]>
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: return an error for hw access in INFO ioctl when in reset
I don't think this is a good idea, we should probably rather wait for the GPU reset to finish by taking the appropriate lock.
Christian.
Am 01.07.20 um 07:33 schrieb Alex Deucher:
Quoted 39 lines
ping?
Quoted 34 lines · Alex Deucher
When the GPU is in reset, accessing the hw is unreliable and could interfere with the reset. Return an error in those cases.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +3
-0@@ -684,6 +684,9 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_fileif (info->read_mmr_reg.count >128 )return -EINVAL ; +if (adev->in_gpu_reset) +return -EPERM ; + regs =kmalloc_array (info->read_mmr_reg.count,sizeof (*regs),GFP_KERNEL );if (!regs) return -ENOMEM; @@ -854,6 +857,9 @@ staticint amdgpu_info_ioctl(struct
drm_device*dev, void *data, structdrm_fileif (!adev->pm.dpm_enabled) return -ENOENT;drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +3
-1+if (adev->in_gpu_reset) +return -EPERM ; +switch (info->sensor_info.type) {case AMDGPU_INFO_SENSOR_GFX_SCLK :/* get sclk in Mhz */ --Quoted 2 lines
2.25.4
Quoted 8 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flist
s.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=02%7C01%7CDe nnis.Li%40amd.com%7Cefeeda4b6d194660fbc508d81d9791a3%7C3dd8961fe4884e6 08e11a82d994e183d%7C0%7C0%7C637291884123360340&sdata=GNPWQNndUJKx7 70fDTuRGBnJzfmRUQjD4B1HBie3xUQ%3D&reserved=0
_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=02%7C01%7CDennis.Li%40amd.com%7Cefeeda4b6d194660fbc508d81d9791a3%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637291884123360340&sdata=GNPWQNndUJKx770fDTuRGBnJzfmRUQjD4B1HBie3xUQ%3D&reserved=0
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Am 2020-07-01 um 10:34 a.m. schrieb Li, Dennis:
Quoted 4 lines
[AMD Official Use Only - Internal Distribution Only]
Hi, Christian and Alex
Not only amdgpu ioctls, but amdkfd ioctls also have the same issue.
Most KFD ioctls don't access HW directly. The only place that interacts with HW in KFD is the device queues manager (DQM) and beneath it the packet manager. In DQM we already have protections to avoid HW access while a reset is in progress.
For other HW access, KFD goes through helper functions in amdgpu.
Memory management ioctls indirectly access HW for page table updates. However, that requires validating the page table BOs first. Are VRAM BOs considered "valid" during a GPU reset? When using SDMA for page table updates, the DRM GPU scheduler is also involved. Is that suspended during a GPU reset?
The only other KFD ioctl that looks like it might access HW during a GPU reset is kfd_ioctl_get_clock_counters by calling amdgpu_amdkfd_get_gpu_clock_counter.
Regards,
Felix
Quoted 62 lines
Best Regards
Dennis Li
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Christian König
Sent: Wednesday, July 1, 2020 4:20 PM
To: Alex Deucher <[email protected]>; amd-gfx list <[email protected]>
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: return an error for hw access in INFO ioctl when in resetI don't think this is a good idea, we should probably rather wait for the GPU reset to finish by taking the appropriate lock.
Christian.
Am 01.07.20 um 07:33 schrieb Alex Deucher:
Quoted 39 lines
ping?
Quoted 34 lines · Alex Deucher
When the GPU is in reset, accessing the hw is unreliable and could interfere with the reset. Return an error in those cases.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +3
-0@@ -684,6 +684,9 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_fileif (info->read_mmr_reg.count >128 )return -EINVAL ; +if (adev->in_gpu_reset) +return -EPERM ; + regs =kmalloc_array (info->read_mmr_reg.count,sizeof (*regs),GFP_KERNEL );if (!regs) return -ENOMEM; @@ -854,6 +857,9 @@ staticint amdgpu_info_ioctl(struct
drm_device*dev, void *data, structdrm_fileif (!adev->pm.dpm_enabled) return -ENOENT;drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +3
-1+if (adev->in_gpu_reset) +return -EPERM ; +switch (info->sensor_info.type) {case AMDGPU_INFO_SENSOR_GFX_SCLK :/* get sclk in Mhz */ --Quoted 2 lines
2.25.4
Quoted 8 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://list
s.freedesktop.org/mailman/listinfo/amd-gfx nnis.Li%40amd.com%7Cefeeda4b6d194660fbc508d81d9791a3%7C3dd8961fe4884e6 08e11a82d994e183d%7C0%7C0%7C637291884123360340&sdata=GNPWQNndUJKx7 70fDTuRGBnJzfmRUQjD4B1HBie3xUQ%3D&reserved=0
Quoted 8 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Christian König
maintainerAm 03.07.20 um 08:05 schrieb Felix Kuehling:
Quoted 10 lines
Am 2020-07-01 um 10:34 a.m. schrieb Li, Dennis:
Quoted 4 lines
[AMD Official Use Only - Internal Distribution Only]
Hi, Christian and Alex
Not only amdgpu ioctls, but amdkfd ioctls also have the same issue.Most KFD ioctls don't access HW directly. The only place that interacts with HW in KFD is the device queues manager (DQM) and beneath it the packet manager. In DQM we already have protections to avoid HW access while a reset is in progress.
Quoted 7 lines
For other HW access, KFD goes through helper functions in amdgpu.
Memory management ioctls indirectly access HW for page table updates. However, that requires validating the page table BOs first. Are VRAM BOs considered "valid" during a GPU reset? When using SDMA for page table updates, the DRM GPU scheduler is also involved. Is that suspended during a GPU reset?
That stuff should work concurrently. The scheduler is stopped during a reset, but we can still push new jobs to the queues.
Stuff like TLB flushes are also harmless since after a reset we can safely assume that the TLB is completely empty.
Quoted 3 lines
The only other KFD ioctl that looks like it might access HW during a GPU reset is
kfd_ioctl_get_clock_countersby callingamdgpu_amdkfd_get_gpu_clock_counter.
Yeah, that is indeed a problem which needs handling.
Christian.
Quoted 75 lines
Regards,
FelixQuoted 69 lines
Best Regards
Dennis Li
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Christian König
Sent: Wednesday, July 1, 2020 4:20 PM
To: Alex Deucher <[email protected]>; amd-gfx list <[email protected]>
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: return an error for hw access in INFO ioctl when in resetI don't think this is a good idea, we should probably rather wait for the GPU reset to finish by taking the appropriate lock.
Christian.
Am 01.07.20 um 07:33 schrieb Alex Deucher:
Quoted 39 lines
ping?
Quoted 34 lines · Alex Deucher
When the GPU is in reset, accessing the hw is unreliable and could interfere with the reset. Return an error in those cases.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +3
-0@@ -684,6 +684,9 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_fileif (info->read_mmr_reg.count >128 )return -EINVAL ; +if (adev->in_gpu_reset) +return -EPERM ; + regs =kmalloc_array (info->read_mmr_reg.count,sizeof (*regs),GFP_KERNEL );if (!regs) return -ENOMEM; @@ -854,6 +857,9 @@ staticint amdgpu_info_ioctl(struct
drm_device*dev, void *data, structdrm_fileif (!adev->pm.dpm_enabled) return -ENOENT;drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +3
-1+if (adev->in_gpu_reset) +return -EPERM ; +switch (info->sensor_info.type) {case AMDGPU_INFO_SENSOR_GFX_SCLK :/* get sclk in Mhz */ --Quoted 2 lines
2.25.4
Quoted 8 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://list
s.freedesktop.org/mailman/listinfo/amd-gfx nnis.Li%40amd.com%7Cefeeda4b6d194660fbc508d81d9791a3%7C3dd8961fe4884e6 08e11a82d994e183d%7C0%7C0%7C637291884123360340&sdata=GNPWQNndUJKx7 70fDTuRGBnJzfmRUQjD4B1HBie3xUQ%3D&reserved=0_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx