hw_fini passes NULL as device_for_each_child() data, but the callback
derived adev from that pointer for logging and oopsed on unbind. Drop
the unused genpd lookup, log against the child device, keep walking
on remove failure, and only clear syscore after a successful detach.

Fixes: fd1478607102 ("drm/amd/amdgpu: Add ISP Generic PM Domain (genpd) 
support")
Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/5746
Signed-off-by: Bin Du <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.c | 28 ++++++-------------------
 1 file changed, 6 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.c 
b/drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.c
index 485ecdec9618..26dbfe2d2739 100644
--- a/drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.c
+++ b/drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.c
@@ -156,35 +156,19 @@ static int isp_genpd_add_device(struct device *dev, void 
*data)
 
 static int isp_genpd_remove_device(struct device *dev, void *data)
 {
-       struct generic_pm_domain *gpd = data;
-       struct platform_device *pdev = container_of(dev, struct 
platform_device, dev);
-       struct amdgpu_isp *isp = container_of(gpd, struct amdgpu_isp, ispgpd);
-       struct amdgpu_device *adev = isp->adev;
        int ret;
 
-       if (!pdev)
-               return -EINVAL;
-
-       if (!dev->type || !dev->type->name) {
-               drm_dbg(&adev->ddev, "Invalid device type to remove\n");
-               goto exit;
-       }
-
-       if (strcmp(dev->type->name, "mfd_device")) {
-               drm_dbg(&adev->ddev, "Invalid isp mfd device %s to remove\n",
-                       pdev->mfd_cell->name);
-               goto exit;
-       }
+       if (!dev->type || !dev->type->name ||
+           strcmp(dev->type->name, "mfd_device"))
+               return 0;
 
        ret = pm_genpd_remove_device(dev);
        if (ret) {
-               drm_err(&adev->ddev, "Failed to remove dev from genpd %d\n", 
ret);
-               return -ENODEV;
+               dev_err(dev, "Failed to remove dev from genpd %d\n", ret);
+               return 0;
        }
-       dev_pm_syscore_device(dev, false);
 
-exit:
-       /* Continue to remove */
+       dev_pm_syscore_device(dev, false);
        return 0;
 }
 
-- 
2.53.0

Reply via email to