drm/msm: fix unbind/rebind of the msm_dpu
Subsystems (5)
cover drm/msm: fix unbind/rebind of the msm_dpu
Unbinding the msm_dpu component master and binding it again fails in several places on X1E80100. With the GPU firmware installed:
echo ae01000.display-controller > /sys/bus/platform/drivers/msm_dpu/unbind echo ae01000.display-controller > /sys/bus/platform/drivers/msm_dpu/bind
By where the failure shows up:
- unbind: the self-refresh entry work runs on the freed DRM device (patch 1), and buffers are freed while still pinned or vmapped: the fbdev buffer (patch 3), the SQE and shadow BOs (patches 4-5)
- bind: the eDP panel was freed on unbind (patch 2), and the GPU fails to bind because leaked BOs keep its VM and SMMU context bank alive (patch 6) and the GMU rscc/PDC regions are never released (patch 7)
- first GPU power-up after bind: the GMU is warm booted without its firmware (patch 8), and the PDC left asleep by the previous GPU instance is never woken up (patch 9)
Each patch can be applied on its own, except patch 9 which needs patch 8.
Not covered here: removing the DP controller device (rmmod msm) still crashes, as the devm AUX bus teardown from commit e2969ee30252 runs after msm_dp_display_remove() has freed the AUX channel and cleared the drvdata. With patch 2 this happens whenever an eDP panel is present. This is independent of unbind/bind and will be fixed separately.
Tested on hamoa-iot-evk and hamoa-advantech-som-5830 (with [1])
[1] https://lore.kernel.org/r/[email protected]
---
Yuanjie Yang (9):
drm/msm/dpu: clean up the self-refresh helper on KMS teardown drm/msm/dp: don't depopulate the eDP AUX bus on component unbind drm/msm: unpin the fbdev buffer when the fbdev is destroyed drm/msm/a6xx: don't leak the SQE vmap in a6xx_ucode_check_version() drm/msm/a6xx: drop the shadow BO vmap on destroy drm/msm/a6xx: free the preemption and pwrup_reglist buffers on destroy drm/msm/a6xx: map the GMU rscc and PDC regions against the GPU device drm/msm/a6xx: cold boot the GMU on the first resume after bind drm/msm/a6xx: wake up a PDC left asleep by a previous GPU instance
drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 41 +++++++++++++++++++++++++------ drivers/gpu/drm/msm/adreno/a6xx_gmu.h | 1 + drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 16 +++++++----- drivers/gpu/drm/msm/adreno/a6xx_preempt.c | 9 ++++++- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 6 +++++ drivers/gpu/drm/msm/dp/dp_display.c | 2 -- drivers/gpu/drm/msm/msm_fbdev.c | 3 +++ 7 files changed, 61 insertions(+), 17 deletions(-)
---
base-commit: 9437046953b2fb3bf55b36582450ea0267df82a7
change-id: 20261126-dpu_unbind_rebind_display-db9931c173dc
Best regards,
Signature · 1 line
Yuanjie Yang <[email protected]>
PATCH 1/9 drm/msm/dpu: clean up the self-refresh helper on KMS teardown
dpu_crtc_init() sets up the self-refresh helper for each CRTC, but drm_self_refresh_helper_cleanup() is never called. The helper re-arms its entry_work on every commit, including the one done by drm_atomic_helper_shutdown() on unbind, so the work later runs on the freed DRM device and CRTCs:
Unable to handle kernel NULL pointer dereference at virtual address 0000000000000300 Workqueue: events drm_self_refresh_helper_entry_work pc : drm_atomic_commit_alloc+0x18/0xb0
--- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +6 -0
@@ -17,6 +17,7 @@#include <drm/drm_crtc.h> #include <drm/drm_file.h> #include <drm/drm_framebuffer.h> +#include <drm/drm_self_refresh_helper.h> #include <drm/drm_vblank.h> #include <drm/drm_writeback.h>
@@ -905,6 +906,7 @@ static void _dpu_kms_hw_destroy(struct dpu_kms *dpu_kms)static void dpu_kms_destroy (struct msm_kms *kms) {struct dpu_kms *dpu_kms; +struct drm_crtc *crtc;if (!kms) {DPU_ERROR ("invalid kms\n" );
@@ -913,6 +915,10 @@ static void dpu_kms_destroy(struct msm_kms *kms) dpu_kms =to_dpu_kms (kms); +if (dpu_kms->dev) +drm_for_each_crtc (crtc, dpu_kms->dev) +drm_self_refresh_helper_cleanup (crtc); +_dpu_kms_hw_destroy (dpu_kms);msm_kms_destroy (&dpu_kms->base);
Signature · 1 line
2.43.0
PATCH 2/9 drm/msm/dp: don't depopulate the eDP AUX bus on component unbind
In reply to Yuanjie YangSince commit e2969ee30252 ("drm/msm/dp: move of_dp_aux_populate_bus() to eDP probe()") the eDP AUX bus is populated at probe time with devm_of_dp_aux_populate_bus(), but msm_dp_display_unbind() still depopulates it. This frees the panel while dp->next_bridge keeps pointing at it, and the first connector probe after a rebind crashes:
Unable to handle kernel paging request at virtual address 0000000800000000 Workqueue: events output_poll_execute panel_edp_get_modes+0x1b8/0x480 [panel_edp]
Drop the depopulate and leave it to the devm action registered at probe time.
--- drivers/gpu/drm/msm/dp/dp_display.c | 2 -- 1 file changed, 2 deletions(-)
drivers/gpu/drm/msm/dp/dp_display.c +0 -2
@@ -239,8 +239,6 @@ static void msm_dp_display_unbind(struct device *dev, struct device *master,struct msm_dp_display_private *dp =dev_get_dp_display_private (dev);struct msm_drm_private *priv =dev_get_drvdata (master); -of_dp_aux_depopulate_bus (dp->aux); -msm_dp_aux_unregister (dp->aux); dp->drm_dev =NULL ; dp->aux->drm_dev =NULL ;
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH 2/9] drm/msm/dp: don't depopulate the eDP AUX bus on component unbind
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] drm/msm/dp: use-after-free of dp->aux after msm_dp_display_remove() --
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [High] drm/msm/dp: use-after-free of dp->aux after msm_dp_display_remove()
--
commit ffc44dc305e10f09be11226df97e5b2a91916044
Author: Yuanjie Yang <[email protected]>
drm/msm/dp: don't depopulate the eDP AUX bus on component unbind
This commit stops calling of_dp_aux_depopulate_bus() in msm_dp_display_unbind() so that eDP AUX bus teardown is left to the devm action registered at probe time.
drivers/gpu/drm/msm/dp/dp_display.c static void msm_dp_display_unbind(struct device *dev, struct device *master, · line 244
Quoted 13 lines
drivers/gpu/drm/msm/dp/dp_display.c +0
-2@@ -239,8 +239,6 @@ static void msm_dp_display_unbind(struct device *dev, struct device *master,struct msm_dp_display_private *dp =dev_get_dp_display_private (dev);struct msm_drm_private *priv =dev_get_drvdata (master); -of_dp_aux_depopulate_bus (dp->aux); -msm_dp_aux_unregister (dp->aux); dp->drm_dev =NULL ; dp->aux->drm_dev =NULL ;
[Severity: High]
Does deferring AUX bus depopulation to the devm action cause a use-after-free of dp->aux during msm_dp_display_remove()?
When the platform device is removed, msm_dp_display_remove() runs before devres_release_all():
drivers/gpu/drm/msm/dp/dp_display.c:msm_dp_display_remove() {
struct msm_dp_display_private *dp = dev_get_dp_display_private(&pdev->dev);
component_del(&pdev->dev, &msm_dp_display_comp_ops);
msm_dp_display_deinit_sub_modules(dp);
platform_set_drvdata(pdev, NULL);
}msm_dp_display_deinit_sub_modules() calls msm_dp_aux_put(dp->aux), which destroys aux->mutex and calls devm_kfree(aux->dev, aux). When devres_release_all() then runs the devm_of_dp_aux_populate_bus() cleanup action, of_dp_aux_depopulate_bus_void(dp->aux) dereferences aux->dev from the already-freed dp->aux and tears down the child AUX endpoint device after dp->aux and aux->mutex have been destroyed.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/20261130-dpu_unbind_rebind_display-v1-0-c335387de1bb@oss.qualcomm.com?part=2
Re: [PATCH 2/9] drm/msm/dp: don't depopulate the eDP AUX bus on component unbind
Quoted 44 lines · On Mon, Nov 30, 2026 at 07:09:11AM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [High] drm/msm/dp: use-after-free ofdp->auxaftermsm_dp_display_remove()
--commit
ffc44dc305e10f09be11226df97e5b2a91916044
Author: Yuanjie Yang <[email protected]>drm/msm/dp: don't depopulate the eDP AUX bus on component unbind
This commit stops calling
of_dp_aux_depopulate_bus()inmsm_dp_display_unbind()so that eDP AUX bus teardown is left to the devm action registered at probe time.drivers/gpu/drm/msm/dp/dp_display.c static void msm_dp_display_unbind(struct device *dev, struct device *master, · line 244
Quoted 13 lines
drivers/gpu/drm/msm/dp/dp_display.c +0
-2@@ -239,8 +239,6 @@ static void msm_dp_display_unbind(struct device *dev, struct device *master,struct msm_dp_display_private *dp =dev_get_dp_display_private (dev);struct msm_drm_private *priv =dev_get_drvdata (master); -of_dp_aux_depopulate_bus (dp->aux); -msm_dp_aux_unregister (dp->aux); dp->drm_dev =NULL ; dp->aux->drm_dev =NULL ;[Severity: High]
Does deferring AUX bus depopulation to the devm action cause a use-after-free ofdp->auxduringmsm_dp_display_remove()?When the platform device is removed,
msm_dp_display_remove()runs beforedevres_release_all():drivers/gpu/drm/msm/dp/dp_display.c:msm_dp_display_remove() { struct msm_dp_display_private *dp = dev_get_dp_display_private(&pdev->dev); component_del(&pdev->dev, &msm_dp_display_comp_ops); msm_dp_display_deinit_sub_modules(dp); platform_set_drvdata(pdev, NULL); }
Quoted 6 lines
msm_dp_display_deinit_sub_modules()callsmsm_dp_aux_put(dp->aux), which destroysaux->mutexand callsdevm_kfree(aux->dev, aux). Whendevres_release_all()then runs thedevm_of_dp_aux_populate_bus()cleanup action,of_dp_aux_depopulate_bus_void(dp->aux)dereferencesaux->devfrom the already-freeddp->auxand tears down the child AUX endpoint device afterdp->auxandaux->mutexhave been destroyed.
I mentioned this issue in the cover letter. this can be reproduce by rmmod msm. will fix in other patch.
Thanks,
Yuanjie
Quoted 2 lines
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/20261130-dpu_unbind_rebind_display-v1-0-c335387de1bb@oss.qualcomm.com?part=2
PATCH 3/9 drm/msm: unpin the fbdev buffer when the fbdev is destroyed
In reply to Yuanjie Yangmsm_fbdev_driver_fbdev_probe() pins the scanout buffer, but msm_fbdev_fb_destroy() never unpins it, so every unbind frees a pinned object:
WARNING: drivers/gpu/drm/msm/msm_gem.c:173 at update_lru_locked+0x98/0xa8 msm_gem_free_object+0x1d0/0x260 drm_client_buffer_delete+0xdc/0x108 msm_fbdev_fb_destroy+0x5c/0x80
Drop the pin before deleting the client buffer. For the KMS VM, msm_gem_unpin_iova() only drops the object pin, so do that directly with msm_gem_unpin_locked(), as msm_gem_put_vaddr() does for the vmap.
--- drivers/gpu/drm/msm/msm_fbdev.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/msm/msm_fbdev.c +3 -0
@@ -48,6 +48,9 @@ static void msm_fbdev_fb_destroy(struct fb_info *info)drm_fb_helper_fini (helper);msm_gem_put_vaddr (bo); +msm_gem_lock (bo); +msm_gem_unpin_locked (bo); +msm_gem_unlock (bo);drm_client_buffer_delete (helper->buffer);drm_client_release (&helper->client);
Signature · 1 line
2.43.0
PATCH 4/9 drm/msm/a6xx: don't leak the SQE vmap in a6xx_ucode_check_version()
In reply to Yuanjie Yanga6xx_ucode_check_version() maps the SQE firmware BO with msm_gem_get_vaddr(), but returns early for a7xx, a702 and a8xx without the matching msm_gem_put_vaddr(). The BO then reaches a6xx_destroy() still vmapped, and freeing it warns:
WARNING: drivers/gpu/drm/msm/msm_gem.c:912 at msm_gem_vunmap+0x78/0x88 WARNING: drivers/gpu/drm/msm/msm_gem.c:173 at update_lru_locked+0x98/0xa8
Go through the common exit path instead.
--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +5 -2
@@ -995,8 +995,11 @@ static bool a6xx_ucode_check_version(struct a6xx_gpu *a6xx_gpu,return false;/* A7xx is safe! */ -if (adreno_is_a7xx (adreno_gpu) ||adreno_is_a702 (adreno_gpu) ||adreno_is_a8xx (adreno_gpu)) -return true; +if (adreno_is_a7xx (adreno_gpu) ||adreno_is_a702 (adreno_gpu) || +adreno_is_a8xx (adreno_gpu)) { + ret = true; + goto out; + }/* * Targets up to a640 (a618, a630 and a640) need to check for a
Signature · 1 line
2.43.0
Re: [PATCH 4/9] drm/msm/a6xx: don't leak the SQE vmap in a6xx_ucode_check_version()
Quoted 8 lines · Yuanjie Yang
a6xx_ucode_check_version()maps the SQE firmware BO withmsm_gem_get_vaddr(), but returns early for a7xx, a702 and a8xx without the matchingmsm_gem_put_vaddr(). The BO then reachesa6xx_destroy()still vmapped, and freeing it warns:WARNING: drivers/gpu/drm/msm/msm_gem.c:912 at msm_gem_vunmap+0x78/0x88 WARNING: drivers/gpu/drm/msm/msm_gem.c:173 at update_lru_locked+0x98/0xa8
Quoted 6 lines
Go through the common exit path instead.
Fixes af66706accdf ("drm/msm/a6xx: Add skeleton A7xx support")Signed-off-by Yuanjie Yang <[email protected]>---
Konrad
PATCH 5/9 drm/msm/a6xx: drop the shadow BO vmap on destroy
In reply to Yuanjie YangThe RPTR shadow BO is allocated with msm_gem_kernel_new(), which keeps it vmapped, but a6xx_destroy() only unpins its iova before dropping the last reference. Unlike sqe_bo and aqe_bo, whose vmap is dropped right after the firmware is copied in, it is freed still vmapped:
WARNING: drivers/gpu/drm/msm/msm_gem.c:912 at msm_gem_vunmap+0x78/0x88 WARNING: drivers/gpu/drm/msm/msm_gem.c:173 at update_lru_locked+0x98/0xa8
Release it with msm_gem_kernel_put(), the counterpart of msm_gem_kernel_new().
--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +1 -4
@@ -2325,10 +2325,7 @@ static void a6xx_destroy(struct msm_gpu *gpu)drm_gem_object_put (a6xx_gpu->aqe_bo); } -if (a6xx_gpu->shadow_bo) { -msm_gem_unpin_iova (a6xx_gpu->shadow_bo, gpu->vm); -drm_gem_object_put (a6xx_gpu->shadow_bo); - } +msm_gem_kernel_put (a6xx_gpu->shadow_bo, gpu->vm);a6xx_llc_slices_destroy (a6xx_gpu);
Signature · 1 line
2.43.0
Re: [PATCH 5/9] drm/msm/a6xx: drop the shadow BO vmap on destroy
Quoted 8 lines · Yuanjie Yang
The RPTR shadow BO is allocated with
msm_gem_kernel_new(), which keeps it vmapped, buta6xx_destroy()only unpins its iova before dropping the last reference. Unlikesqe_boandaqe_bo, whose vmap is dropped right after the firmware is copied in, it is freed still vmapped:WARNING: drivers/gpu/drm/msm/msm_gem.c:912 at msm_gem_vunmap+0x78/0x88 WARNING: drivers/gpu/drm/msm/msm_gem.c:173 at update_lru_locked+0x98/0xa8
Quoted 7 lines
Release it with
msm_gem_kernel_put(), the counterpart ofmsm_gem_kernel_new().Fixes d3a569fccfa0 ("drm/msm: a6xx: Use WHERE_AM_I for eligible targets")Signed-off-by Yuanjie Yang <[email protected]>---
Konrad
PATCH 6/9 drm/msm/a6xx: free the preemption and pwrup_reglist buffers on destroy
In reply to Yuanjie Yanga6xx_destroy() never calls a6xx_preempt_fini(), which itself only frees preempt_bo[], and it never frees pwrup_reglist_bo either. Each leaked BO stays mapped in gpu->vm and holds references to it, so the GPU VM, its IOMMU domain and the SMMU context bank 0 reserved for the GPU are never released, and the next bind of the GPU fails:
msm_dpu ae01000.display-controller: failed to bind 3d00000.gpu (...): -28
On x1e80100 the final drm_gpuvm_put() in msm_gpu_cleanup() still sees 21 references: the VM's own one plus two for each of the 10 leaked BOs.
Free all the preemption buffers in a6xx_preempt_fini(), clearing the pointers since the a6xx_preempt_init() error path calls it as well, and call it from a6xx_destroy() together with freeing pwrup_reglist_bo.
--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 4 ++++ drivers/gpu/drm/msm/adreno/a6xx_preempt.c | 9 ++++++++- 2 files changed, 12 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +4 -0
@@ -2327,6 +2327,10 @@ static void a6xx_destroy(struct msm_gpu *gpu)msm_gem_kernel_put (a6xx_gpu->shadow_bo, gpu->vm); +msm_gem_kernel_put (a6xx_gpu->pwrup_reglist_bo, gpu->vm); + +a6xx_preempt_fini (gpu); +a6xx_llc_slices_destroy (a6xx_gpu);a6xx_gmu_remove (a6xx_gpu);
drivers/gpu/drm/msm/adreno/a6xx_preempt.c +8 -1
@@ -354,8 +354,15 @@ void a6xx_preempt_fini(struct msm_gpu *gpu)struct a6xx_gpu *a6xx_gpu =to_a6xx_gpu (adreno_gpu);int i; -for (i =0 ; i < gpu->nr_rings; i++) +for (i =0 ; i < gpu->nr_rings; i++) {msm_gem_kernel_put (a6xx_gpu->preempt_bo[i], gpu->vm); + a6xx_gpu->preempt_bo[i] =NULL ; +msm_gem_kernel_put (a6xx_gpu->preempt_smmu_bo[i], gpu->vm); + a6xx_gpu->preempt_smmu_bo[i] =NULL ; + } + +msm_gem_kernel_put (a6xx_gpu->preempt_postamble_bo, gpu->vm); + a6xx_gpu->preempt_postamble_bo =NULL ; }void a6xx_preempt_init (struct msm_gpu *gpu)
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH 6/9] drm/msm/a6xx: free the preemption and pwrup_reglist buffers on destroy
Thank you for your contribution! Sashiko AI review found no new issues in this patch, but noticed 1 related pre-existing issue it does not introduce: - [Critical] drm/msm: double free on…
Thank you for your contribution! Sashiko AI review found no new issues in this patch, but noticed 1 related pre-existing issue it does not introduce:
- [Critical] drm/msm: double free on gpu->memptrs_bo in msm_gpu_init()
[1]
--
commit f46993f14cc108abd1489c5015e179df0efd70e6
Author: Yuanjie Yang <[email protected]>
drm/msm/a6xx: free the preemption and pwrup_reglist buffers on destroy
This commit releases all preemption buffers in a6xx_preempt_fini() while clearing their pointers, and calls a6xx_preempt_fini() alongside freeing pwrup_reglist_bo in a6xx_destroy().
Quoted 11 lines
drivers/gpu/drm/msm/adreno/a6xx_preempt.c +1
-1@@ -354,8 +354,15 @@ void a6xx_preempt_fini(struct msm_gpu *gpu)struct a6xx_gpu *a6xx_gpu =to_a6xx_gpu (adreno_gpu);int i; -for (i =0 ; i < gpu->nr_rings; i++) +for (i =0 ; i < gpu->nr_rings; i++) {msm_gem_kernel_put (a6xx_gpu->preempt_bo[i], gpu->vm);
drivers/gpu/drm/msm/adreno/a6xx_preempt.c void a6xx_preempt_fini(struct msm_gpu *gpu) · line 368
Quoted 10 lines
drivers/gpu/drm/msm/adreno/a6xx_preempt.c +7
-0+ a6xx_gpu->preempt_bo[i] =NULL ; +msm_gem_kernel_put (a6xx_gpu->preempt_smmu_bo[i], gpu->vm); + a6xx_gpu->preempt_smmu_bo[i] =NULL ; + } + +msm_gem_kernel_put (a6xx_gpu->preempt_postamble_bo, gpu->vm); + a6xx_gpu->preempt_postamble_bo =NULL ; }void a6xx_preempt_init (struct msm_gpu *gpu)
[Severity: Critical]
This problem wasn't introduced by this patch, but can gpu->memptrs_bo be double freed [1] if msm_gpu_init() fails after allocating it?
drivers/gpu/drm/msm/msm_gpu.c:msm_gpu_init() {
...
fail:
for (i = 0; i < ARRAY_SIZE(gpu->rb); i++) {
msm_ringbuffer_destroy(gpu->rb[i]);
gpu->rb[i] = NULL;
}
msm_gem_kernel_put(gpu->memptrs_bo, gpu->vm);
platform_set_drvdata(pdev, NULL);
return ret;
}When a step such as msm_ringbuffer_new() fails, msm_gpu_init() releases gpu->memptrs_bo without clearing the pointer to NULL. The caller's error path (for example a6xx_gpu_init() -> a6xx_destroy() -> adreno_gpu_cleanup() -> msm_gpu_cleanup()) then calls msm_gem_kernel_put(gpu->memptrs_bo, gpu->vm) a second time on the already-freed GEM object.
[1] https://sashiko.dev/#/bug/linux-ee423138-c527-467c-b053-bdbec97b4f9c
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/20261130-dpu_unbind_rebind_display-v1-0-c335387de1bb@oss.qualcomm.com?part=6
PATCH 7/9 drm/msm/a6xx: map the GMU rscc and PDC regions against the GPU device
In reply to Yuanjie YangCommit 188db3d7fe66 ("drm/msm/a6xx: Rebase GMU register offsets") maps the rscc, gmu_pdc and gmu_pdc_seq regions with devm_platform_ioremap_resource_byname() on the GMU device. That device has no driver, so its devres are never released and the regions cannot be requested again on the next bind:
3d6a000.gmu: error -EBUSY: can't request region for resource [mem 0x03d50000-0x03d5ffff]
msm_dpu ae01000.display-controller: failed to bind 3d00000.gpu (...): -19
For gmu_pdc the failure is silent and the RSC/PDC setup is skipped.
Keep the managed mappings, but attach them to the GPU device. They are created from the GPU component bind, so component_unbind(), or a failed bind, releases them through the devres group opened by component_bind().
--- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +13 -4
@@ -684,11 +684,20 @@ static inline void pdc_write(void __iomem *ptr, u32 offset, u32 value)writel (value, ptr + (offset <<2 )); } +static void __iomem *a6xx_gmu_ioremap_byname (struct a6xx_gmu *gmu, +const char *name) +{ + struct a6xx_gpu *a6xx_gpu = container_of(gmu, struct a6xx_gpu, gmu); +struct platform_device *pdev =to_platform_device (gmu->dev); + +return devm_ioremap_resource (&a6xx_gpu->base.base.pdev->dev, +platform_get_resource_byname (pdev,IORESOURCE_MEM , name)); +} +static void a6xx_gmu_rpmh_init (struct a6xx_gmu *gmu) { struct a6xx_gpu *a6xx_gpu = container_of(gmu, struct a6xx_gpu, gmu);struct adreno_gpu *adreno_gpu = &a6xx_gpu->base; -struct platform_device *pdev =to_platform_device (gmu->dev);u32 seqmem0_drv0_reg =REG_A6XX_RSCC_SEQ_MEM_0_DRV0 ;void __iomem *seqptr =NULL ;uint32_t pdc_address_offset;
@@ -699,7 +708,7 @@ static void a6xx_gmu_rpmh_init(struct a6xx_gmu *gmu)if (adreno_is_a8xx (adreno_gpu))return ; - pdcptr =devm_platform_ioremap_resource_byname (pdev,"gmu_pdc" ); + pdcptr =a6xx_gmu_ioremap_byname (gmu,"gmu_pdc" );if (IS_ERR (pdcptr))return ;
@@ -714,7 +723,7 @@ static void a6xx_gmu_rpmh_init(struct a6xx_gmu *gmu) pdc_address_offset =0x30080 ;if (!pdc_in_aop) { - seqptr =devm_platform_ioremap_resource_byname (pdev,"gmu_pdc_seq" ); + seqptr =a6xx_gmu_ioremap_byname (gmu,"gmu_pdc_seq" );if (IS_ERR (seqptr))return ; }
@@ -2464,7 +2473,7 @@ int a6xx_gmu_init(struct a6xx_gpu *a6xx_gpu, struct device_node *node)if (adreno_is_a650_family (adreno_gpu) ||adreno_is_a7xx (adreno_gpu)) { - gmu->rscc =devm_platform_ioremap_resource_byname (pdev,"rscc" ); + gmu->rscc =a6xx_gmu_ioremap_byname (gmu,"rscc" );if (IS_ERR (gmu->rscc)) { ret = -ENODEV ; goto err_mmio;
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH 7/9] drm/msm/a6xx: map the GMU rscc and PDC regions against the GPU device
Thank you for your contribution! Sashiko AI review found no new issues in this patch, but noticed 1 related pre-existing issue it does not introduce: - [High] drm/msm/a6xx: ignored…
Thank you for your contribution! Sashiko AI review found no new issues in this patch, but noticed 1 related pre-existing issue it does not introduce:
- [High] drm/msm/a6xx: ignored a6xx_gmu_pwrlevels_probe() return in a6xx_gmu_init() [1]
--
commit 95ee2296d872dd08a9e4fb839630fa6c9e25a217
Author: Yuanjie Yang <[email protected]>
drm/msm/a6xx: map the GMU rscc and PDC regions against the GPU device
This commit attaches the devres-managed mappings for the GMU rscc, gmu_pdc, and gmu_pdc_seq regions to the GPU device rather than the driverless GMU device so that they are properly released on component unbind or bind failure.
Quoted 4 lines
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +0
-0
[ ... ]
drivers/gpu/drm/msm/adreno/a6xx_gmu.c int a6xx_gmu_init(struct a6xx_gpu *a6xx_gpu, struct device_node *node) · line 2479
Quoted 9 lines
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +1
-1@@ -2464,7 +2473,7 @@ int a6xx_gmu_init(struct a6xx_gpu *a6xx_gpu, struct device_node *node)if (adreno_is_a650_family (adreno_gpu) ||adreno_is_a7xx (adreno_gpu)) { - gmu->rscc =devm_platform_ioremap_resource_byname (pdev,"rscc" ); + gmu->rscc =a6xx_gmu_ioremap_byname (gmu,"rscc" );if (IS_ERR (gmu->rscc)) { ret = -ENODEV ; goto err_mmio;
[Severity: High]
This problem wasn't introduced by this patch, but should a6xx_gmu_init() check the return value of a6xx_gmu_pwrlevels_probe() [1]?
drivers/gpu/drm/msm/adreno/a6xx_gmu.c:a6xx_gmu_init() {
...
/* Get the power levels for the GMU and GPU */
a6xx_gmu_pwrlevels_probe(gmu);
ret = a6xx_gmu_acd_probe(gmu);
if (ret)
goto detach_gxpd;
...
}If a6xx_gmu_pwrlevels_probe() fails (for example, returning -EPROBE_DEFER when OPP tables are not yet ready), probe continues with unpopulated frequency tables (gmu->nr_gmu_freqs and gmu->nr_gpu_freqs remain 0), leading to invalid hardware initialization and a kernel panic when voting for frequencies.
[1] https://sashiko.dev/#/bug/linux-0cc3192b-3c52-4862-8d9b-9647c0282109
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/20261130-dpu_unbind_rebind_display-v1-0-c335387de1bb@oss.qualcomm.com?part=7
Re: [PATCH 7/9] drm/msm/a6xx: map the GMU rscc and PDC regions against the GPU device
In reply to Yuanjie YangQuoted 9 lines · Yuanjie Yang
Commit
188db3d7fe66("drm/msm/a6xx: Rebase GMU register offsets") maps the rscc,gmu_pdcandgmu_pdc_seqregions withdevm_platform_ioremap_resource_byname()on the GMU device. That device has no driver, so its devres are never released and the regions cannot be requested again on the next bind:3d6a000.gmu: error
-EBUSY: can't request region for resource [mem 0x03d50000-0x03d5ffff]
msm_dpuae01000.display-controller: failed to bind 3d00000.gpu (...): -19
msm-next currently carries a patch to bind a driver to the GMU
Konrad
Re: [PATCH 7/9] drm/msm/a6xx: map the GMU rscc and PDC regions against the GPU device
Quoted 7 lines · Konrad Dybcio
Quoted 6 lines · Yuanjie Yang
Commit
188db3d7fe66("drm/msm/a6xx: Rebase GMU register offsets") maps the rscc,gmu_pdcandgmu_pdc_seqregions withdevm_platform_ioremap_resource_byname()on the GMU device. That device has no driver, so its devres are never released and the regions cannot be requested again on the next bind:
Quoted 5 lines
Quoted 3 lines
3d6a000.gmu: error
-EBUSY: can't request region for resource [mem 0x03d50000-0x03d5ffff]
msm_dpuae01000.display-controller: failed to bind 3d00000.gpu (...): -19msm-next currently carries a patch to bind a driver to the GMU
will drop this patch in next series.
Thanks,
Yuanjie
Quoted 1 line
Konrad
PATCH 8/9 drm/msm/a6xx: cold boot the GMU on the first resume after bind
In reply to Yuanjie YangOn a7xx/a8xx a6xx_gmu_resume() warm boots the GMU when CX_MISC_TCM_RET_CNTL reads back 1. The flag survives a GPU unbind/bind as long as CX stays powered, but a warm boot skips a6xx_gmu_fw_load() while the icache/dcache/dummy buffers of the new instance are empty, so the first GPU open after a rebind fails:
*ERROR* GMU firmware initialization timed out
*ERROR* Couldn't power up the GPU: -110
Only allow a warm boot on a7xx/a8xx once this instance has loaded the firmware.
--- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 4 ++++ drivers/gpu/drm/msm/adreno/a6xx_gmu.h | 1 + 2 files changed, 5 insertions(+)
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +4 -0
@@ -992,6 +992,8 @@ static int a6xx_gmu_fw_start(struct a6xx_gmu *gmu, unsigned int state) ret =a6xx_gmu_fw_load (gmu);if (ret)return ret; + + gmu->fw_loaded = true; }/* Clear init result to make sure we are getting a fresh value */
@@ -1382,6 +1384,8 @@ int a6xx_gmu_resume(struct a6xx_gpu *a6xx_gpu)if (adreno_is_a7xx (adreno_gpu) ||adreno_is_a8xx (adreno_gpu)) { status =a6xx_cx_misc_read (a6xx_gpu,REG_A7XX_CX_MISC_TCM_RET_CNTL ) ==1 ?GMU_WARM_BOOT :GMU_COLD_BOOT ; +if (!gmu->fw_loaded) + status =GMU_COLD_BOOT ; }else if (gmu->legacy) { status =gmu_read (gmu,REG_A6XX_GMU_GENERAL_7 ) ==1 ?GMU_WARM_BOOT :GMU_COLD_BOOT ;
drivers/gpu/drm/msm/adreno/a6xx_gmu.h +1 -0
@@ -117,6 +117,7 @@ struct a6xx_gmu {bool initialized;bool hung;bool legacy;/* a618 or a630 */ +bool fw_loaded;/* For power domain callback */ struct notifier_block pd_nb;
Signature · 1 line
2.43.0
PATCH 9/9 drm/msm/a6xx: wake up a PDC left asleep by a previous GPU instance
In reply to Yuanjie YangSince commit f248d5d5159a ("drm/msm/a6xx: Fix PDC sleep sequence") the PDC is only woken up when GMU_STATUS_PDC_SLEEP is set, i.e. after this instance put it to sleep. The PDC lives outside the GPU and stays asleep across a GPU unbind/bind, while gmu->status of the new instance starts out clear. The wake sequence is then skipped, the GMU cannot reach RPMh and the first GPU open after a rebind fails:
*ERROR* Message HFI_H2F_MSG_GX_BW_PERF_VOTE id 8 timed out waiting for response
*ERROR* Timeout waiting for GMU OOB set GPU_SET: 0x0 *ERROR* gpu hw init failed: -110
On the first GMU boot of an instance, set GMU_STATUS_PDC_SLEEP if the RSC status reports the PDC asleep, using the same bit a6xx_rpmh_stop() waits for, so that the wake sequence still only follows a sleep. Move the bit selection into a helper shared with a6xx_rpmh_stop().
--- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +16 -4
@@ -623,6 +623,14 @@ static int a6xx_gmu_notify_slumber(struct a6xx_gmu *gmu)return ret; } +static u32 a6xx_rsc_sleep_mask (struct adreno_gpu *adreno_gpu) +{ +if (adreno_is_a840 (adreno_gpu) ||adreno_is_a850_family (adreno_gpu)) +return BIT (30 ); + +return BIT (16 ); +} +static int a6xx_rpmh_start (struct a6xx_gmu *gmu) {int ret;
@@ -657,16 +665,13 @@ static void a6xx_rpmh_stop(struct a6xx_gmu *gmu) { struct a6xx_gpu *a6xx_gpu = container_of(gmu, struct a6xx_gpu, gmu);struct adreno_gpu *adreno_gpu = &a6xx_gpu->base; -u32 bitmask =BIT (16 ); +u32 bitmask =a6xx_rsc_sleep_mask (adreno_gpu);int ret;u32 val;if (!test_and_clear_bit (GMU_STATUS_FW_START , &gmu->status))return ; -if (adreno_is_a840 (adreno_gpu) ||adreno_is_a850_family (adreno_gpu)) - bitmask =BIT (30 ); -gmu_write (gmu,REG_A6XX_GMU_RSCC_CONTROL_REQ ,1 ); ret = gmu_poll_timeout_rscc(gmu, REG_A6XX_GPU_RSCC_RSC_STATUS0_DRV0,
@@ -980,6 +985,13 @@ static int a6xx_gmu_fw_start(struct a6xx_gmu *gmu, unsigned int state)else if (!adreno_is_a8xx (adreno_gpu))gmu_write (gmu,REG_A6XX_GMU_GENERAL_7 ,1 ); +if (!gmu->fw_loaded && + (gmu_read_rscc (gmu,REG_A6XX_GPU_RSCC_RSC_STATUS0_DRV0 ) & +a6xx_rsc_sleep_mask (adreno_gpu))) { +DRM_DEV_DEBUG_DRIVER (gmu->dev,"GPU RSC left asleep, waking it up\n" ); +set_bit (GMU_STATUS_PDC_SLEEP , &gmu->status); + } + ret =a6xx_rpmh_start (gmu);if (ret)return ret;
Signature · 1 line
2.43.0