drm/amd: fix debugfs access for discovery blob
Subsystems (2)
PATCH 1/1 drm/amd: fix debugfs access for discovery blob
Accessing the blob for amdgpu discovery from debugfs triggers:
[ 1924.487667] kernel BUG at mm/usercopy.c:102!
usercopy_abort() explains that it needs to be solved by creating a cache to store the data.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 7 +++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 17 ++++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 2 ++ 3 files changed, 23 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +5 -2
@@ -791,8 +791,11 @@ struct amdgpu_device {bool accel_working;struct notifier_block acpi_nb;struct amdgpu_i2c_chan *i2c_bus[AMDGPU_MAX_I2C_BUS ]; -struct debugfs_blob_wrapper debugfs_vbios_blob; -struct debugfs_blob_wrapper debugfs_discovery_blob; +#if defined(CONFIG_DEBUG_FS ) +struct debugfs_blob_wrapper debugfs_vbios_blob; +struct debugfs_blob_wrapper debugfs_discovery_blob; +struct kmem_cache *discovery_blob_cache; +#endif struct mutex srbm_mutex;/* GRBM index mutex. Protects concurrent access to GRBM index */ struct mutex grbm_idx_mutex;
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +16 -1
@@ -2180,7 +2180,15 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev)debugfs_create_blob ("amdgpu_vbios" ,0444 , root, &adev->debugfs_vbios_blob); - adev->debugfs_discovery_blob.data = adev->mman.discovery_bin; + + adev->discovery_blob_cache =kmem_cache_create_usercopy ("amdgpu_discovery" , + adev->mman.discovery_tmr_size, +0 ,0 ,0 , + adev->mman.discovery_tmr_size, +NULL ); + adev->debugfs_discovery_blob.data =kmem_cache_alloc (adev->discovery_blob_cache,GFP_KERNEL ); +memcpy (adev->debugfs_discovery_blob.data, adev->mman.discovery_bin, + adev->mman.discovery_tmr_size); adev->debugfs_discovery_blob.size = adev->mman.discovery_tmr_size;debugfs_create_blob ("amdgpu_discovery" ,0444 , root, &adev->debugfs_discovery_blob);
@@ -2188,6 +2196,12 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev) return 0; } +void amdgpu_debugfs_fini (struct amdgpu_device *adev) +{ +kmem_cache_free (adev->discovery_blob_cache, adev->debugfs_discovery_blob.data); +kmem_cache_destroy (adev->discovery_blob_cache); +} +#else int amdgpu_debugfs_init (struct amdgpu_device *adev) {
@@ -2197,4 +2211,5 @@ int amdgpu_debugfs_regs_init(struct amdgpu_device *adev) {return 0 ; } +inline void amdgpu_debugfs_fini (struct amdgpu_device *adev) {}#endif
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2 -0
@@ -2276,6 +2276,8 @@ amdgpu_pci_remove(struct pci_dev *pdev)struct drm_device *dev =pci_get_drvdata (pdev);struct amdgpu_device *adev =drm_to_adev (dev); +amdgpu_debugfs_fini (adev); +amdgpu_xcp_dev_unplug (adev);drm_dev_unplug (dev);
Signature · 1 line
2.34.1
Quoted 10 lines · Mario Limonciello
Accessing the blob for amdgpu discovery from debugfs triggers:
[ 1924.487667] kernel BUG at mm/usercopy.c:102!
usercopy_abort()explains that it needs to be solved by creating a cache to store the data.
Quoted 80 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 7 +++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 17 ++++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 2 ++ 3 files changed, 23 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +5
-2@@ -791,8 +791,11 @@ struct amdgpu_device {bool accel_working;struct notifier_block acpi_nb;struct amdgpu_i2c_chan *i2c_bus[AMDGPU_MAX_I2C_BUS ]; -struct debugfs_blob_wrapper debugfs_vbios_blob; -struct debugfs_blob_wrapper debugfs_discovery_blob; +#if defined(CONFIG_DEBUG_FS ) +struct debugfs_blob_wrapper debugfs_vbios_blob; +struct debugfs_blob_wrapper debugfs_discovery_blob; +struct kmem_cache *discovery_blob_cache; +#endif struct mutex srbm_mutex;/* GRBM index mutex. Protects concurrent access to GRBM index */ struct mutex grbm_idx_mutex;drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +16
-1@@ -2180,7 +2180,15 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev)debugfs_create_blob ("amdgpu_vbios" ,0444 , root, &adev->debugfs_vbios_blob); - adev->debugfs_discovery_blob.data = adev->mman.discovery_bin; + + adev->discovery_blob_cache =kmem_cache_create_usercopy ("amdgpu_discovery" , + adev->mman.discovery_tmr_size, +0 ,0 ,0 , + adev->mman.discovery_tmr_size, +NULL ); + adev->debugfs_discovery_blob.data =kmem_cache_alloc (adev->discovery_blob_cache,GFP_KERNEL ); +memcpy (adev->debugfs_discovery_blob.data, adev->mman.discovery_bin, + adev->mman.discovery_tmr_size); adev->debugfs_discovery_blob.size = adev->mman.discovery_tmr_size;debugfs_create_blob ("amdgpu_discovery" ,0444 , root, &adev->debugfs_discovery_blob);@@ -2188,6 +2196,12 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev) return 0; } +void amdgpu_debugfs_fini (struct amdgpu_device *adev) +{ +kmem_cache_free (adev->discovery_blob_cache, adev->debugfs_discovery_blob.data); +kmem_cache_destroy (adev->discovery_blob_cache); +} +#else int amdgpu_debugfs_init (struct amdgpu_device *adev) {@@ -2197,4 +2211,5 @@ int amdgpu_debugfs_regs_init(struct amdgpu_device *adev) {return 0 ; } +inline void amdgpu_debugfs_fini (struct amdgpu_device *adev) {}#endif drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2
-1@@ -2276,6 +2276,8 @@ amdgpu_pci_remove(struct pci_dev *pdev)struct drm_device *dev =pci_get_drvdata (pdev);struct amdgpu_device *adev =drm_to_adev (dev); +amdgpu_debugfs_fini (adev); +amdgpu_xcp_dev_unplug (adev);drm_dev_unplug (dev); --2.34.1
Quoted 7 lines · Alex Deucher
Quoted 5 lines · Mario Limonciello
Accessing the blob for amdgpu discovery from debugfs triggers:
[ 1924.487667] kernel BUG at mm/usercopy.c:102!
Quoted 8 lines
Quoted 5 lines
usercopy_abort()explains that it needs to be solved by creating a cache to store the data.Reviewed-by Alex Deucher <[email protected]>
Although this avoids the issue; I've concluded it's an inappropriate fix and will abandon it. It turns out to spit out 64k discovery blobs that should have been 8k.
6.5-rc and ASDN already picked up a better solution.
db3b5cb64a9c ("drm/amdgpu: Use apt name for FW reserved region")
Quoted 80 lines
Quoted 80 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 7 +++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 17 ++++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 2 ++ 3 files changed, 23 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +5
-2@@ -791,8 +791,11 @@ struct amdgpu_device {bool accel_working;struct notifier_block acpi_nb;struct amdgpu_i2c_chan *i2c_bus[AMDGPU_MAX_I2C_BUS ]; -struct debugfs_blob_wrapper debugfs_vbios_blob; -struct debugfs_blob_wrapper debugfs_discovery_blob; +#if defined(CONFIG_DEBUG_FS ) +struct debugfs_blob_wrapper debugfs_vbios_blob; +struct debugfs_blob_wrapper debugfs_discovery_blob; +struct kmem_cache *discovery_blob_cache; +#endif struct mutex srbm_mutex;/* GRBM index mutex. Protects concurrent access to GRBM index */ struct mutex grbm_idx_mutex;drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +16
-1@@ -2180,7 +2180,15 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev)debugfs_create_blob ("amdgpu_vbios" ,0444 , root, &adev->debugfs_vbios_blob); - adev->debugfs_discovery_blob.data = adev->mman.discovery_bin; + + adev->discovery_blob_cache =kmem_cache_create_usercopy ("amdgpu_discovery" , + adev->mman.discovery_tmr_size, +0 ,0 ,0 , + adev->mman.discovery_tmr_size, +NULL ); + adev->debugfs_discovery_blob.data =kmem_cache_alloc (adev->discovery_blob_cache,GFP_KERNEL ); +memcpy (adev->debugfs_discovery_blob.data, adev->mman.discovery_bin, + adev->mman.discovery_tmr_size); adev->debugfs_discovery_blob.size = adev->mman.discovery_tmr_size;debugfs_create_blob ("amdgpu_discovery" ,0444 , root, &adev->debugfs_discovery_blob);@@ -2188,6 +2196,12 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev) return 0; } +void amdgpu_debugfs_fini (struct amdgpu_device *adev) +{ +kmem_cache_free (adev->discovery_blob_cache, adev->debugfs_discovery_blob.data); +kmem_cache_destroy (adev->discovery_blob_cache); +} +#else int amdgpu_debugfs_init (struct amdgpu_device *adev) {@@ -2197,4 +2211,5 @@ int amdgpu_debugfs_regs_init(struct amdgpu_device *adev) {return 0 ; } +inline void amdgpu_debugfs_fini (struct amdgpu_device *adev) {}#endif drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2
-1@@ -2276,6 +2276,8 @@ amdgpu_pci_remove(struct pci_dev *pdev)struct drm_device *dev =pci_get_drvdata (pdev);struct amdgpu_device *adev =drm_to_adev (dev); +amdgpu_debugfs_fini (adev); +amdgpu_xcp_dev_unplug (adev);drm_dev_unplug (dev); --2.34.1