drm/amdgpu: Add new reset option and rework coredump
Subsystems (2)
v3 cover drm/amdgpu: Add new reset option and rework coredump
Hi,
The goal of this patchset is to improve debugging device resets on amdgpu.
The first patch creates a new module parameter to disable soft recoveries, ensuring every recovery go through the full device reset, making easier to generate resets from userspace tools like [0] and [1]. This is important to validate how the stack behaves on resets, from end-to-end.
The last patches are a rework to alloc devcoredump dynamically and to move it to a better source file.
I have dropped the patches that add more information to devcoredump for now, until I figure out a better way to do so, like storing the IB address in the fence.
Thanks,
André
[0] https://gitlab.freedesktop.org/andrealmeid/gpu-timeout
[1] https://github.com/andrealmeid/vulkan-triangle-v1
Changelog:
v2: https://lore.kernel.org/dri-devel/[email protected]/
- Drop the IB and ring patch
- Drop patch that limited information from kernel threads
- Add patch to move coredump to amdgpu_reset
v1: https://lore.kernel.org/dri-devel/[email protected]/
- Drop "Mark contexts guilty for causing soft recoveries" patch
- Use GFP_NOWAIT for devcoredump allocation
André Almeida (5):
drm/amdgpu: Create a module param to disable soft recovery drm/amdgpu: Allocate coredump memory in a nonblocking way drm/amdgpu: Rework coredump to use memory dynamically drm/amdgpu: Move coredump code to amdgpu_reset file drm/amdgpu: Create version number for coredumps
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 +- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 67 +----------------- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 9 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c | 79 ++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h | 14 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 6 +- 6 files changed, 111 insertions(+), 70 deletions(-)
Signature · 1 line
2.41.0
PATCH RESEND v3 1/5 drm/amdgpu: Create a module param to disable soft recovery
Create a module parameter to disable soft recoveries on amdgpu, making every recovery go through the device reset path. This option makes easier to force device resets for testing and debugging purposes.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 9 +++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 6 +++++- 3 files changed, 15 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
@@ -189,6 +189,7 @@ extern uint amdgpu_force_long_training;extern int amdgpu_lbpw;extern int amdgpu_compute_multipipe;extern int amdgpu_gpu_recovery; +extern bool amdgpu_soft_recovery;extern int amdgpu_emu_mode;extern uint amdgpu_smu_memory_pool_size;extern int amdgpu_smu_pptable_id;
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +9 -0
@@ -163,6 +163,7 @@ uint amdgpu_force_long_training;int amdgpu_lbpw =-1 ;int amdgpu_compute_multipipe =-1 ;int amdgpu_gpu_recovery =-1 ;/* auto */ +bool amdgpu_soft_recovery = true;int amdgpu_emu_mode;uint amdgpu_smu_memory_pool_size;int amdgpu_smu_pptable_id =-1 ;
@@ -538,6 +539,14 @@ module_param_named(compute_multipipe, amdgpu_compute_multipipe, int, 0444);MODULE_PARM_DESC (gpu_recovery,"Enable GPU recovery mechanism, (1 = enable, 0 = disable, -1 = auto)" );module_param_named (gpu_recovery, amdgpu_gpu_recovery, int,0444 ); +/** +* DOC: gpu_soft_recovery (bool) +* Set true to allow the driver to try soft recoveries if a job get stuck. Set +* to false to always force a GPU reset during recovery. +*/ +MODULE_PARM_DESC (gpu_soft_recovery,"Enable GPU soft recovery mechanism (default: true)" ); +module_param_named (gpu_soft_recovery, amdgpu_soft_recovery, bool,0644 ); +/** * DOC: emu_mode (int) * Set value 1 to enable emulation mode. This is only needed when running on an emulator. The default is 0 (disabled).
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +5 -1
@@ -434,8 +434,12 @@ bool amdgpu_ring_soft_recovery(struct amdgpu_ring *ring, unsigned int vmid, struct dma_fence *fence) {unsigned long flags; +ktime_t deadline; -ktime_t deadline =ktime_add_us (ktime_get (),10000 ); +if (!amdgpu_soft_recovery) +return false; + + deadline =ktime_add_us (ktime_get (),10000 );if (amdgpu_sriov_vf (ring->adev) || !ring->funcs->soft_recovery || !fence)return false;
Signature · 1 line
2.41.0
Christian König
maintainerRe: [RESEND v3 1/5] drm/amdgpu: Create a module param to disable soft recovery
Am 10.08.23 um 21:23 schrieb André Almeida:
Quoted 3 lines
Create a module parameter to disable soft recoveries on amdgpu, making every recovery go through the device reset path. This option makes easier to force device resets for testing and debugging purposes.
I'm still torn apart on this. On the one hand it's certainly useful for developers on the other hand module parameters are not meant to be used by developers, they are meant to be used by end users.
Now we have to ask what's the use case to disable soft recovery by an end user? I don't see any.
Maybe we can overload the amdgpu_gpu_recovery module option with this. Or even better merge all the developer module parameter into a amdgpu_debug option. This way it should be pretty obvious that this isn't meant to be used by someone who doesn't know how to use it.
Regards,
Christian.
Quoted 65 lines
Signed-off-by André Almeida <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 9 +++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 6 +++++- 3 files changed, 15 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +1
-0@@ -189,6 +189,7 @@ extern uint amdgpu_force_long_training;extern int amdgpu_lbpw;extern int amdgpu_compute_multipipe;extern int amdgpu_gpu_recovery; +extern bool amdgpu_soft_recovery;extern int amdgpu_emu_mode;extern uint amdgpu_smu_memory_pool_size;extern int amdgpu_smu_pptable_id;drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +9
-0@@ -163,6 +163,7 @@ uint amdgpu_force_long_training;int amdgpu_lbpw =-1 ;int amdgpu_compute_multipipe =-1 ;int amdgpu_gpu_recovery =-1 ;/* auto */ +bool amdgpu_soft_recovery = true;int amdgpu_emu_mode;uint amdgpu_smu_memory_pool_size;int amdgpu_smu_pptable_id =-1 ;@@ -538,6 +539,14 @@ module_param_named(compute_multipipe, amdgpu_compute_multipipe, int, 0444);MODULE_PARM_DESC (gpu_recovery,"Enable GPU recovery mechanism, (1 = enable, 0 = disable, -1 = auto)" );module_param_named (gpu_recovery, amdgpu_gpu_recovery, int,0444 ); +/** +* DOC: gpu_soft_recovery (bool) +* Set true to allow the driver to try soft recoveries if a job get stuck. Set +* to false to always force a GPU reset during recovery. +*/ +MODULE_PARM_DESC (gpu_soft_recovery,"Enable GPU soft recovery mechanism (default: true)" ); +module_param_named (gpu_soft_recovery, amdgpu_soft_recovery, bool,0644 ); +/** * DOC: emu_mode (int) * Set value 1 to enable emulation mode. This is only needed when running on an emulator. The default is 0 (disabled). drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +5
-1@@ -434,8 +434,12 @@ bool amdgpu_ring_soft_recovery(struct amdgpu_ring *ring, unsigned int vmid, struct dma_fence *fence) {unsigned long flags; +ktime_t deadline; -ktime_t deadline =ktime_add_us (ktime_get (),10000 ); +if (!amdgpu_soft_recovery) +return false; + + deadline =ktime_add_us (ktime_get (),10000 );if (amdgpu_sriov_vf (ring->adev) || !ring->funcs->soft_recovery || !fence)return false;
PATCH RESEND v3 2/5 drm/amdgpu: Allocate coredump memory in a nonblocking way
In reply to André AlmeidaDuring a GPU reset, a normal memory reclaim could block to reclaim memory. Giving that coredump is a best effort mechanism, it shouldn't disturb the reset path. Change its memory allocation flag to a nonblocking one.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
@@ -4847,7 +4847,7 @@ static void amdgpu_reset_capture_coredumpm(struct amdgpu_device *adev)struct drm_device *dev =adev_to_drm (adev);ktime_get_ts64 (&adev->reset_time); -dev_coredumpm (dev->dev,THIS_MODULE , adev,0 ,GFP_KERNEL , +dev_coredumpm (dev->dev,THIS_MODULE , adev,0 ,GFP_NOWAIT , amdgpu_devcoredump_read, amdgpu_devcoredump_free); }#endif
Signature · 1 line
2.41.0
PATCH RESEND v3 3/5 drm/amdgpu: Rework coredump to use memory dynamically
In reply to André AlmeidaInstead of storing coredump information inside amdgpu_device struct, move if to a proper separated struct and allocate it dynamically. This will make it easier to further expand the logged information.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 14 +++-- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 65 ++++++++++++++-------- 2 files changed, 51 insertions(+), 28 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +9 -5
@@ -1088,11 +1088,6 @@ struct amdgpu_device {uint32_t *reset_dump_reg_list;uint32_t *reset_dump_reg_value;int num_regs; -#ifdef CONFIG_DEV_COREDUMP -struct amdgpu_task_info reset_task_info; -bool reset_vram_lost; -struct timespec64 reset_time; -#endif bool scpm_enabled;uint32_t scpm_status;
@@ -1105,6 +1100,15 @@ struct amdgpu_device {uint32_t aid_mask; }; +#ifdef CONFIG_DEV_COREDUMP +struct amdgpu_coredump_info { +struct amdgpu_device *adev; +struct amdgpu_task_info reset_task_info; +struct timespec64 reset_time; +bool reset_vram_lost; +}; +#endif +static inline struct amdgpu_device *drm_to_adev (struct drm_device *ddev) { return container_of(ddev, struct amdgpu_device, ddev);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +42 -23
104 lines not on this page · raw message
Signature · 1 line
2.41.0
PATCH RESEND v3 4/5 drm/amdgpu: Move coredump code to amdgpu_reset file
In reply to André AlmeidaGiving that we use codedump just for device resets, move it's functions and structs to a more semantic file, the amdgpu_reset.{c, h}.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 9 --- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 80 ---------------------- drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c | 78 +++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h | 11 +++ 4 files changed, 89 insertions(+), 89 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -9
@@ -1100,15 +1100,6 @@ struct amdgpu_device {uint32_t aid_mask; }; -#ifdef CONFIG_DEV_COREDUMP -struct amdgpu_coredump_info { -struct amdgpu_device *adev; -struct amdgpu_task_info reset_task_info; -struct timespec64 reset_time; -bool reset_vram_lost; -}; -#endif -static inline struct amdgpu_device *drm_to_adev (struct drm_device *ddev) { return container_of(ddev, struct amdgpu_device, ddev);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -80
92 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c +78 -0
89 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h +11 -0
@@ -87,6 +87,15 @@ struct amdgpu_reset_domain {atomic_t reset_res; }; +#ifdef CONFIG_DEV_COREDUMP +struct amdgpu_coredump_info { +struct amdgpu_device *adev; +struct amdgpu_task_info reset_task_info; +struct timespec64 reset_time; +bool reset_vram_lost; +}; +#endif +int amdgpu_reset_init (struct amdgpu_device *adev);int amdgpu_reset_fini (struct amdgpu_device *adev);
@@ -126,4 +135,6 @@ void amdgpu_device_lock_reset_domain(struct amdgpu_reset_domain *reset_domain);void amdgpu_device_unlock_reset_domain (struct amdgpu_reset_domain *reset_domain); +void amdgpu_coredump (struct amdgpu_device *adev,bool vram_lost, +struct amdgpu_reset_context *reset_context);#endif
Signature · 1 line
2.41.0
kernel test robot
build botRe: [RESEND v3 4/5] drm/amdgpu: Move coredump code to amdgpu_reset file
kernel test robot noticed the following build warnings:
Hi André,
kernel test robot noticed the following build warnings:
[auto build test WARNING on drm-misc/drm-misc-next]
[also build test WARNING on drm/drm-next drm-exynos/exynos-drm-next drm-intel/for-linux-next drm-intel/for-linux-next-fixes drm-tip/drm-tip linus/master v6.5-rc5 next-20230809] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Andr-Almeida/drm-amdgpu-Create-a-module-param-to-disable-soft-recovery/20230811-032440 base: git://anongit.freedesktop.org/drm/drm-misc drm-misc-next patch link: https://lore.kernel.org/r/20230810192330.198326-5-andrealmeid%40igalia.com patch subject: [RESEND v3 4/5] drm/amdgpu: Move coredump code to amdgpu_reset file config: alpha-randconfig-r062-20230814 (https://download.01.org/0day-ci/archive/20230814/[email protected]/config) compiler: alpha-linux-gcc (GCC) 12.3.0 reproduce: (https://download.01.org/0day-ci/archive/20230814/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
cocci warnings: (new ones prefixed by >>)
>> drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c:228:12-19: WARNING: kzalloc should be used for
>> coredump , instead of kmalloc/memset
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
PATCH RESEND v3 5/5 drm/amdgpu: Create version number for coredumps
In reply to André AlmeidaEven if there's nothing currently parsing amdgpu's coredump files, if we eventually have such tools they will be glad to find a version field to properly read the file.
Create a version number to be displayed on top of coredump file, to be incremented when the file format or content get changed.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h | 3 +++ 2 files changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c +1 -0
@@ -192,6 +192,7 @@ static ssize_t amdgpu_devcoredump_read(char *buffer, loff_t offset, p =drm_coredump_printer (&iter);drm_printf (&p,"**** AMDGPU Device Coredump ****\n" ); +drm_printf (&p,"version: " AMDGPU_COREDUMP_VERSION "\n" );drm_printf (&p,"kernel: " UTS_RELEASE "\n" );drm_printf (&p,"module: " KBUILD_MODNAME "\n" );drm_printf (&p,"time: %lld.%09ld\n" , coredump->reset_time.tv_sec, coredump->reset_time.tv_nsec);
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h +3 -0
@@ -88,6 +88,9 @@ struct amdgpu_reset_domain { }; #ifdef CONFIG_DEV_COREDUMP + +#define AMDGPU_COREDUMP_VERSION "1" + struct amdgpu_coredump_info { struct amdgpu_device *adev; struct amdgpu_task_info reset_task_info;
Signature · 1 line
2.41.0