Skip to contentSkip to conversation

drm: rockchip: Fix rockchip drm unbind crash error

PATCH Superseded Jeffy Chen 3 participants 18 messages Apr 1, 2017 – Apr 5, 2017

Subsystems (5)

v2 of 11 Superseded Latest is v11 →

lore
Share & tools
lore

Jeffy Chen

author
#0 lore raw

v2 cover drm: rockchip: Fix rockchip drm unbind crash error

Verified on rk3399 chromebook kevin:
1/ stop ui && pkill -9 frecon
2/ unbind/bind drm

Changes in v2:
Fix some commit messages.

Jeffy Chen (9):
drm: bridge: analogix: Detach panel when unbinding analogix dp
drm: bridge: analogix: Unregister dp aux when unbinding
drm: bridge: analogix: Destroy connector when unbinding drm/rockchip: cdn-dp: Don't try to release firmware when not loaded drm/rockchip: vop: Enable pm domain when resetting vop drm/rockchip: Reoder unload sequence
drm/rockchip: Force disable all crtc when unload drm/rockchip: gem: Don't alloc/free gem buf before drm dev registered drm/rockchip: cdn-dp: Don't unregister audio dev when unbinding

 drivers/gpu/drm/bridge/analogix/analogix_dp_core.c |  4 +++
 drivers/gpu/drm/rockchip/cdn-dp-core.c             | 10 ++++---
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c        |  7 +++--
 drivers/gpu/drm/rockchip/rockchip_drm_gem.c        |  8 ++++++
 drivers/gpu/drm/rockchip/rockchip_drm_vop.c        | 31 +++++++++++++++-------
 5 files changed, 44 insertions(+), 16 deletions(-)
Signature · 1 line
2.1.4
author
#1 lore raw

PATCH v2 1/9 drm: bridge: analogix: Detach panel when unbinding analogix dp

The panel is attached when binding analogix dp.

---

Changes in v2:
Fix some commit messages.

 drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +2 -0
index e7cd105..a3db290 100644
@@ -1443,6 +1443,8 @@ void analogix_dp_unbind(struct device *dev, struct device *master,
 	if (dp->plat_data->panel) {
 		if (drm_panel_unprepare(dp->plat_data->panel))
 			DRM_ERROR("failed to turnoff the panel\n");
+		if (drm_panel_detach(dp->plat_data->panel))
+			DRM_ERROR("failed to detach the panel\n");
 	}
 
 	pm_runtime_disable(dev);
Signature · 1 line
2.1.4
author
#2 lore raw

PATCH v2 2/9 drm: bridge: analogix: Unregister dp aux when unbinding

In reply to Jeffy Chen

The dp aux is registered when binding analogix dp.

---

Changes in v2: None

 drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +1 -0
index a3db290..ec47fc2 100644
@@ -1447,6 +1447,7 @@ void analogix_dp_unbind(struct device *dev, struct device *master,
 			DRM_ERROR("failed to detach the panel\n");
 	}
 
+	drm_dp_aux_unregister(&dp->aux);
 	pm_runtime_disable(dev);
 }
 EXPORT_SYMBOL_GPL(analogix_dp_unbind);
Signature · 1 line
2.1.4
author
#3 lore raw

PATCH v2 3/9 drm: bridge: analogix: Destroy connector when unbinding

In reply to Jeffy Chen

Normally we do this in drm_mode_config_cleanup. But analogix dp's connector is allocated in bind, and freed after unbind. So we need to destroy it in unbind to avoid further access.

---

Changes in v2: None

 drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +1 -0
index ec47fc2..084ee8f 100644
@@ -1439,6 +1439,7 @@ void analogix_dp_unbind(struct device *dev, struct device *master,
 	struct analogix_dp_device *dp = dev_get_drvdata(dev);
 
 	analogix_dp_bridge_disable(dp->bridge);
+	dp->connector.funcs->destroy(&dp->connector);
 
 	if (dp->plat_data->panel) {
 		if (drm_panel_unprepare(dp->plat_data->panel))
Signature · 1 line
2.1.4
author
#4 lore raw

PATCH v2 4/9 drm/rockchip: cdn-dp: Don't try to release firmware when not loaded

In reply to Jeffy Chen

---

Changes in v2: None

 drivers/gpu/drm/rockchip/cdn-dp-core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/rockchip/cdn-dp-core.c +3 -1
index fd79a70..a97f3f4 100644
@@ -1052,6 +1052,7 @@ static int cdn_dp_bind(struct device *dev, struct device *master, void *data)
 	dp->connected = false;
 	dp->active = false;
 	dp->active_port = -1;
+	dp->fw_loaded = false;
 
 	INIT_WORK(&dp->event_work, cdn_dp_pd_event_work);
 
@@ -1132,7 +1133,8 @@ static void cdn_dp_unbind(struct device *dev, struct device *master, void *data)
 	connector->funcs->destroy(connector);
 
 	pm_runtime_disable(dev);
-	release_firmware(dp->fw);
+	if (dp->fw_loaded)
+		release_firmware(dp->fw);
 	kfree(dp->edid);
 	dp->edid = NULL;
 }
Signature · 1 line
2.1.4
author
#5 lore raw

PATCH v2 5/9 drm/rockchip: vop: Enable pm domain when resetting vop

In reply to Jeffy Chen

---

Changes in v2: None

 drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 31 +++++++++++++++++++----------
 1 file changed, 21 insertions(+), 10 deletions(-)
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +21 -10
index 76c79ac..1d85319 100644
@@ -1365,6 +1365,12 @@ static int vop_initial(struct vop *vop)
 		return ret;
 	}
 
+	ret = pm_runtime_get_sync(vop->dev);
+	if (ret < 0) {
+		dev_err(vop->dev, "failed to get pm runtime: %d\n", ret);
+		goto err_put_pm_runtime;
+	}
+
 	/* Enable both the hclk and aclk to setup the vop */
 	ret = clk_prepare_enable(vop->hclk);
 	if (ret < 0) {
@@ -1422,6 +1428,8 @@ static int vop_initial(struct vop *vop)
 
 	vop->is_enabled = false;
 
+	pm_runtime_put_sync(vop->dev);
+
 	return 0;
 
 err_disable_aclk:
@@ -1430,6 +1438,8 @@ static int vop_initial(struct vop *vop)
 	clk_disable_unprepare(vop->hclk);
 err_unprepare_dclk:
 	clk_unprepare(vop->dclk);
+err_put_pm_runtime:
+	pm_runtime_put_sync(vop->dev);
 	return ret;
 }
 
@@ -1530,12 +1540,6 @@ static int vop_bind(struct device *dev, struct device *master, void *data)
 	if (!vop->regsbak)
 		return -ENOMEM;
 
-	ret = vop_initial(vop);
-	if (ret < 0) {
-		dev_err(&pdev->dev, "cannot initial vop dev - err %d\n", ret);
-		return ret;
-	}
-
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0) {
 		dev_err(dev, "cannot find irq for vop\n");
@@ -1556,15 +1560,22 @@ static int vop_bind(struct device *dev, struct device *master, void *data)
 	/* IRQ is initially disabled; it gets enabled in power_on */
 	disable_irq(vop->irq);
 
+	pm_runtime_enable(&pdev->dev);
+
+	ret = vop_initial(vop);
+	if (ret < 0) {
+		dev_err(&pdev->dev, "cannot initial vop dev - err %d\n", ret);
+		goto err_disable_pm_runtime;
+	}
+
 	ret = vop_create_crtc(vop);
 	if (ret)
-		goto err_enable_irq;
-
-	pm_runtime_enable(&pdev->dev);
+		goto err_disable_pm_runtime;
 
 	return 0;
 
-err_enable_irq:
+err_disable_pm_runtime:
+	pm_runtime_disable(&pdev->dev);
 	enable_irq(vop->irq); /* To balance out the disable_irq above */
 	return ret;
 }
Signature · 1 line
2.1.4
#6 lore raw

Re: [PATCH v2 5/9] drm/rockchip: vop: Enable pm domain when resetting vop

On Sat, Apr 01, 2017 at 07:35:25PM +0800, Jeffy Chen wrote:

Hi Jeffy,
Could you please add commit messages describing *why* you're making the change? It might be obvious to you (and maybe me), but others will benefit from better descriptions.

Quoted 13 lines

---

Changes in v2: None

 drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 31 +++++++++++++++++++----------
 1 file changed, 21 insertions(+), 10 deletions(-)
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +0 -0
index 76c79ac..1d85319 100644

drivers/gpu/drm/rockchip/rockchip_drm_vop.c static int vop_initial(struct vop *vop) · line 1371

Quoted 7 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +4 -0
@@ -1365,6 +1365,12 @@ static int vop_initial(struct vop *vop)
 		return ret;
 	}
 
+	ret = pm_runtime_get_sync(vop->dev);
+	if (ret < 0) {
+		dev_err(vop->dev, "failed to get pm runtime: %d\n", ret);
+		goto err_put_pm_runtime;

This should go to err_unprepare_dclk, the next error condition should go to err_put_pm_runtime

Quoted 15 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +4 -0
+	}
+
 	/* Enable both the hclk and aclk to setup the vop */
 	ret = clk_prepare_enable(vop->hclk);
 	if (ret < 0) {
@@ -1422,6 +1428,8 @@ static int vop_initial(struct vop *vop)
 
 	vop->is_enabled = false;
 
+	pm_runtime_put_sync(vop->dev);
+
 	return 0;
 
 err_disable_aclk:

drivers/gpu/drm/rockchip/rockchip_drm_vop.c static int vop_initial(struct vop *vop) · line 1442

Quoted 5 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +2 -0
@@ -1430,6 +1438,8 @@ static int vop_initial(struct vop *vop)
 	clk_disable_unprepare(vop->hclk);
 err_unprepare_dclk:
 	clk_unprepare(vop->dclk);
+err_put_pm_runtime:
+	pm_runtime_put_sync(vop->dev);

Should be above err_unprepare_dclk

Quoted 17 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +0 -6
 	return ret;
 }
 
@@ -1530,12 +1540,6 @@ static int vop_bind(struct device *dev, struct device *master, void *data)
 	if (!vop->regsbak)
 		return -ENOMEM;
 
-	ret = vop_initial(vop);
-	if (ret < 0) {
-		dev_err(&pdev->dev, "cannot initial vop dev - err %d\n", ret);
-		return ret;
-	}
-
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0) {
 		dev_err(dev, "cannot find irq for vop\n");

drivers/gpu/drm/rockchip/rockchip_drm_vop.c static int vop_bind(struct device *dev, struct device *master, void *data) · line 1569

Quoted 10 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +7 -0
@@ -1556,15 +1560,22 @@ static int vop_bind(struct device *dev, struct device *master, void *data)
 	/* IRQ is initially disabled; it gets enabled in power_on */
 	disable_irq(vop->irq);
 
+	pm_runtime_enable(&pdev->dev);
+
+	ret = vop_initial(vop);
+	if (ret < 0) {
+		dev_err(&pdev->dev, "cannot initial vop dev - err %d\n", ret);
+		goto err_disable_pm_runtime;
+	}

This function move would be a lot easier to understand with a commit message ;-)

drivers/gpu/drm/rockchip/rockchip_drm_vop.c static int vop_bind(struct device *dev, struct device *master, void *data) · line 1573

Quoted 7 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +2 -3
+
 	ret = vop_create_crtc(vop);
 	if (ret)
-		goto err_enable_irq;
-
-	pm_runtime_enable(&pdev->dev);
+		goto err_disable_pm_runtime;

Do you have anything to clean up from vop_initial()?

Quoted 12 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +2 -1
 	return 0;
 
-err_enable_irq:
+err_disable_pm_runtime:
+	pm_runtime_disable(&pdev->dev);
 	enable_irq(vop->irq); /* To balance out the disable_irq above */
 	return ret;
 }
Signature · 1 line
2.1.4
Signature · 1 line
Sean Paul, Software Engineer, Google / Chromium OS
author
#7 lore raw

Re: [PATCH v2 5/9] drm/rockchip: vop: Enable pm domain when resetting vop

Hi Sean,

Quoted 6 lines · Sean Paul

On Sat, Apr 01, 2017 at 07:35:25PM +0800, Jeffy Chen wrote:

Hi Jeffy,
Could you please add commit messages describing *why* you're making the change? It might be obvious to you (and maybe me), but others will benefit from better descriptions.

ok, will do.

Quoted 17 lines
Quoted 17 lines

---

Changes in v2: None

  drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 31 +++++++++++++++++++----------
  1 file changed, 21 insertions(+), 10 deletions(-)
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +0 -0
index 76c79ac..1d85319 100644
@@ -1365,6 +1365,12 @@ static int vop_initial(struct vop *vop)
  		return ret;
  	}
 
Quoted 7 lines

drivers/gpu/drm/rockchip/rockchip_drm_vop.c static int vop_initial(struct vop *vop) · line 1371

Quoted 4 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +4 -0
+	ret = pm_runtime_get_sync(vop->dev);
+	if (ret < 0) {
+		dev_err(vop->dev, "failed to get pm runtime: %d\n", ret);
+		goto err_put_pm_runtime;

This should go to err_unprepare_dclk, the next error condition should go to err_put_pm_runtime

hmm, that's true, i copied it from vop_enable without a double check...will fix that too.

Quoted 14 lines
Quoted 14 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +4 -0
+	}
+
  	/* Enable both the hclk and aclk to setup the vop */
  	ret = clk_prepare_enable(vop->hclk);
  	if (ret < 0) {
@@ -1422,6 +1428,8 @@ static int vop_initial(struct vop *vop)
 
  	vop->is_enabled = false;
 
+	pm_runtime_put_sync(vop->dev);
+
  	return 0;
 
Quoted 10 lines

drivers/gpu/drm/rockchip/rockchip_drm_vop.c static int vop_initial(struct vop *vop) · line 1442

Quoted 7 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +2 -0
  err_disable_aclk:
@@ -1430,6 +1438,8 @@ static int vop_initial(struct vop *vop)
  	clk_disable_unprepare(vop->hclk);
  err_unprepare_dclk:
  	clk_unprepare(vop->dclk);
+err_put_pm_runtime:
+	pm_runtime_put_sync(vop->dev);

Should be above err_unprepare_dclk

oh, too careless, thanx for pointing that out.

Quoted 20 lines
Quoted 20 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +0 -6
  	return ret;
  }
 
@@ -1530,12 +1540,6 @@ static int vop_bind(struct device *dev, struct device *master, void *data)
  	if (!vop->regsbak)
  		return -ENOMEM;
 
-	ret = vop_initial(vop);
-	if (ret < 0) {
-		dev_err(&pdev->dev, "cannot initial vop dev - err %d\n", ret);
-		return ret;
-	}
-
  	irq = platform_get_irq(pdev, 0);
  	if (irq < 0) {
  		dev_err(dev, "cannot find irq for vop\n");
@@ -1556,15 +1560,22 @@ static int vop_bind(struct device *dev, struct device *master, void *data)
  	/* IRQ is initially disabled; it gets enabled in power_on */
  	disable_irq(vop->irq);
 
Quoted 10 lines

drivers/gpu/drm/rockchip/rockchip_drm_vop.c static int vop_bind(struct device *dev, struct device *master, void *data) · line 1569

Quoted 7 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +7 -0
+	pm_runtime_enable(&pdev->dev);
+
+	ret = vop_initial(vop);
+	if (ret < 0) {
+		dev_err(&pdev->dev, "cannot initial vop dev - err %d\n", ret);
+		goto err_disable_pm_runtime;
+	}

This function move would be a lot easier to understand with a commit message ;-)

ok

Quoted 10 lines

drivers/gpu/drm/rockchip/rockchip_drm_vop.c static int vop_bind(struct device *dev, struct device *master, void *data) · line 1573

Quoted 7 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +2 -3
+
  	ret = vop_create_crtc(vop);
  	if (ret)
-		goto err_enable_irq;
-
-	pm_runtime_enable(&pdev->dev);
+		goto err_disable_pm_runtime;

Do you have anything to clean up from vop_initial()?

i'll put it to the end of bind ;)

Quoted 13 lines
Quoted 12 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +2 -2
  	return 0;
 
-err_enable_irq:
+err_disable_pm_runtime:
+	pm_runtime_disable(&pdev->dev);
  	enable_irq(vop->irq); /* To balance out the disable_irq above */
  	return ret;
  }
--

2.1.4

author
#8 lore raw

PATCH v2 6/9 drm/rockchip: Reoder unload sequence

In reply to Jeffy Chen

We should not cleanup iommu before cleanup other resources.

Reorder unload sequence, follow exynos drm.

---

Changes in v2: None

 drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/rockchip/rockchip_drm_drv.c +4 -2
index b360e62..a5d83cb 100644
@@ -244,11 +244,13 @@ static void rockchip_drm_unbind(struct device *dev)
 	struct drm_device *drm_dev = dev_get_drvdata(dev);
 
 	rockchip_drm_fbdev_fini(drm_dev);
-	drm_vblank_cleanup(drm_dev);
 	drm_kms_helper_poll_fini(drm_dev);
+
+	drm_vblank_cleanup(drm_dev);
 	component_unbind_all(dev, drm_dev);
-	rockchip_iommu_cleanup(drm_dev);
 	drm_mode_config_cleanup(drm_dev);
+	rockchip_iommu_cleanup(drm_dev);
+
 	drm_dev->dev_private = NULL;
 	drm_dev_unregister(drm_dev);
 	drm_dev_unref(drm_dev);
Signature · 1 line
2.1.4
#9 lore raw

Re: [PATCH v2 6/9] drm/rockchip: Reoder unload sequence

Quoted 3 lines · Jeffy Chen

We should not cleanup iommu before cleanup other resources.

Reorder unload sequence, follow exynos drm.

This doesn't match the cleanup sequence in rockchip_drm_bind. Also make sure that you're unwinding the setup sequence when you cleanup (ie: take a close look at how you set things up and reverse it for cleanup).

Sean

Quoted 32 lines

---

Changes in v2: None

 drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/rockchip/rockchip_drm_drv.c +4 -2
index b360e62..a5d83cb 100644
@@ -244,11 +244,13 @@ static void rockchip_drm_unbind(struct device *dev)
 	struct drm_device *drm_dev = dev_get_drvdata(dev);
 
 	rockchip_drm_fbdev_fini(drm_dev);
-	drm_vblank_cleanup(drm_dev);
 	drm_kms_helper_poll_fini(drm_dev);
+
+	drm_vblank_cleanup(drm_dev);
 	component_unbind_all(dev, drm_dev);
-	rockchip_iommu_cleanup(drm_dev);
 	drm_mode_config_cleanup(drm_dev);
+	rockchip_iommu_cleanup(drm_dev);
+
 	drm_dev->dev_private = NULL;
 	drm_dev_unregister(drm_dev);
 	drm_dev_unref(drm_dev);
Signature · 1 line
2.1.4
Signature · 1 line
Sean Paul, Software Engineer, Google / Chromium OS
author
#10 lore raw

Re: [PATCH v2 6/9] drm/rockchip: Reoder unload sequence

Hi Sean,

Quoted 8 lines · Sean Paul
Quoted 3 lines · Jeffy Chen

We should not cleanup iommu before cleanup other resources.

Reorder unload sequence, follow exynos drm.

This doesn't match the cleanup sequence in rockchip_drm_bind. Also make sure that you're unwinding the setup sequence when you cleanup (ie: take a close look at how you set things up and reverse it for cleanup).

ok, will reoder the bind sequence too, thanx.

Quoted 36 lines

Sean

Quoted 32 lines

---

Changes in v2: None

  drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/rockchip/rockchip_drm_drv.c +4 -3
index b360e62..a5d83cb 100644
@@ -244,11 +244,13 @@ static void rockchip_drm_unbind(struct device *dev)
  	struct drm_device *drm_dev = dev_get_drvdata(dev);
 
  	rockchip_drm_fbdev_fini(drm_dev);
-	drm_vblank_cleanup(drm_dev);
  	drm_kms_helper_poll_fini(drm_dev);
+
+	drm_vblank_cleanup(drm_dev);
  	component_unbind_all(dev, drm_dev);
-	rockchip_iommu_cleanup(drm_dev);
  	drm_mode_config_cleanup(drm_dev);
+	rockchip_iommu_cleanup(drm_dev);
+
  	drm_dev->dev_private = NULL;
  	drm_dev_unregister(drm_dev);
  	drm_dev_unref(drm_dev);
--

2.1.4

author
#11 lore raw

PATCH v2 7/9 drm/rockchip: Force disable all crtc when unload

In reply to Jeffy Chen

---

Changes in v2: None

 drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/rockchip/rockchip_drm_drv.c +1 -0
index a5d83cb..5dbf011 100644
@@ -246,6 +246,7 @@ static void rockchip_drm_unbind(struct device *dev)
 	rockchip_drm_fbdev_fini(drm_dev);
 	drm_kms_helper_poll_fini(drm_dev);
 
+	drm_crtc_force_disable_all(drm_dev);
 	drm_vblank_cleanup(drm_dev);
 	component_unbind_all(dev, drm_dev);
 	drm_mode_config_cleanup(drm_dev);
Signature · 1 line
2.1.4
#12 lore raw

Re: [PATCH v2 7/9] drm/rockchip: Force disable all crtc when unload

drivers/gpu/drm/rockchip/rockchip_drm_drv.c static void rockchip_drm_unbind(struct device *dev) · line 249

Quoted 9 lines · Jeffy Chen
drivers/gpu/drm/rockchip/rockchip_drm_drv.c +1 -0
index a5d83cb..5dbf011 100644
@@ -246,6 +246,7 @@ static void rockchip_drm_unbind(struct device *dev)
        rockchip_drm_fbdev_fini(drm_dev);
        drm_kms_helper_poll_fini(drm_dev);
 
+       drm_crtc_force_disable_all(drm_dev);

This will result in a WARN_ON in latest drm-next because rockchip is atomic, and this helper is for legacy kms drivers. You want to use drm_atomic_helper_shutdown here.
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
author
#13 lore raw

Re: [PATCH v2 7/9] drm/rockchip: Force disable all crtc when unload

Hi Daniel,

Quoted 9 lines · Daniel Vetter
Quoted 8 lines · Jeffy Chen
drivers/gpu/drm/rockchip/rockchip_drm_drv.c +0 -0
index a5d83cb..5dbf011 100644
@@ -246,6 +246,7 @@ static void rockchip_drm_unbind(struct device *dev)
         rockchip_drm_fbdev_fini(drm_dev);
         drm_kms_helper_poll_fini(drm_dev);
 
Quoted 7 lines

drivers/gpu/drm/rockchip/rockchip_drm_drv.c static void rockchip_drm_unbind(struct device *dev) · line 249

Quoted 1 line
drivers/gpu/drm/rockchip/rockchip_drm_drv.c +1 -0
+       drm_crtc_force_disable_all(drm_dev);

This will result in a WARN_ON in latest drm-next because rockchip is atomic, and this helper is for legacy kms drivers. You want to use drm_atomic_helper_shutdown here.
-Daniel

oops, thanx for the notice.

author
#14 lore raw

PATCH v2 8/9 drm/rockchip: gem: Don't alloc/free gem buf before drm dev registered

In reply to Jeffy Chen

---

Changes in v2: None

 drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/gpu/drm/rockchip/rockchip_drm_gem.c +8 -0
index df9e570..2bf8024 100644
@@ -184,6 +184,9 @@ static int rockchip_gem_alloc_buf(struct rockchip_gem_object *rk_obj,
 	struct drm_device *drm = obj->dev;
 	struct rockchip_drm_private *private = drm->dev_private;
 
+	if (!drm->registered)
+		return -ENODEV;
+
 	if (private->domain)
 		return rockchip_gem_alloc_iommu(rk_obj, alloc_kmap);
 	else
@@ -208,6 +211,11 @@ static void rockchip_gem_free_dma(struct rockchip_gem_object *rk_obj)
 
 static void rockchip_gem_free_buf(struct rockchip_gem_object *rk_obj)
 {
+	struct drm_device *drm = rk_obj->base.dev;
+
+	if (!drm->registered)
+		return;
+
 	if (rk_obj->pages)
 		rockchip_gem_free_iommu(rk_obj);
 	else
Signature · 1 line
2.1.4
#15 lore raw

Re: [PATCH v2 8/9] drm/rockchip: gem: Don't alloc/free gem buf before drm dev registered

Quoted 4 lines · Jeffy Chen

---

Changes in v2: None

Wut? How is this even possible? If you haven't registered the driver yet, there's no way for userspace to call allocation functions. Anything else is a driver bug that should be handled by fixing the driver load sequence. The only thing I can imagine is that you init the fbdev stuff too early, in that case pls fix that. Not apply this duct-tape here.

Thanks, Daniel

Quoted 38 lines
 drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/gpu/drm/rockchip/rockchip_drm_gem.c +8 -0
index df9e570..2bf8024 100644
@@ -184,6 +184,9 @@ static int rockchip_gem_alloc_buf(struct rockchip_gem_object *rk_obj,
 	struct drm_device *drm = obj->dev;
 	struct rockchip_drm_private *private = drm->dev_private;
 
+	if (!drm->registered)
+		return -ENODEV;
+
 	if (private->domain)
 		return rockchip_gem_alloc_iommu(rk_obj, alloc_kmap);
 	else
@@ -208,6 +211,11 @@ static void rockchip_gem_free_dma(struct rockchip_gem_object *rk_obj)
 
 static void rockchip_gem_free_buf(struct rockchip_gem_object *rk_obj)
 {
+	struct drm_device *drm = rk_obj->base.dev;
+
+	if (!drm->registered)
+		return;
+
 	if (rk_obj->pages)
 		rockchip_gem_free_iommu(rk_obj);
 	else
Signature · 7 lines
2.1.4


_______________________________________________
dri-devel mailing list
dri-devel at lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
author
#16 lore raw

Re: [PATCH v2 8/9] drm/rockchip: gem: Don't alloc/free gem buf before drm dev registered

Hi Daniel,

Quoted 11 lines · Daniel Vetter
Quoted 4 lines · Jeffy Chen

---

Changes in v2: None

Wut? How is this even possible? If you haven't registered the driver yet, there's no way for userspace to call allocation functions. Anything else is a driver bug that should be handled by fixing the driver load sequence. The only thing I can imagine is that you init the fbdev stuff too early, in that case pls fix that. Not apply this duct-tape here.

after unbind drm drivers, userspace may still have the chance to call gem ioctls before we call drm_dev_register again. and we can add a sanity check here to avoid invalid access.

i'll try to make a better commit message in next version soon, thanx for reply.

Quoted 42 lines

Thanks, Daniel

Quoted 38 lines
  drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 8 ++++++++
  1 file changed, 8 insertions(+)
drivers/gpu/drm/rockchip/rockchip_drm_gem.c +8 -1
index df9e570..2bf8024 100644
@@ -184,6 +184,9 @@ static int rockchip_gem_alloc_buf(struct rockchip_gem_object *rk_obj,
  	struct drm_device *drm = obj->dev;
  	struct rockchip_drm_private *private = drm->dev_private;
 
+	if (!drm->registered)
+		return -ENODEV;
+
  	if (private->domain)
  		return rockchip_gem_alloc_iommu(rk_obj, alloc_kmap);
  	else
@@ -208,6 +211,11 @@ static void rockchip_gem_free_dma(struct rockchip_gem_object *rk_obj)
 
  static void rockchip_gem_free_buf(struct rockchip_gem_object *rk_obj)
  {
+	struct drm_device *drm = rk_obj->base.dev;
+
+	if (!drm->registered)
+		return;
+
  	if (rk_obj->pages)
  		rockchip_gem_free_iommu(rk_obj);
  	else
--

2.1.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

author
#17 lore raw

PATCH v2 9/9 drm/rockchip: cdn-dp: Don't unregister audio dev when unbinding

In reply to Jeffy Chen

In current sound framework, there's no way to unbind dai link after unregister codec.

So move unregister codec to driver remove for now.

---

Changes in v2: None

 drivers/gpu/drm/rockchip/cdn-dp-core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/rockchip/cdn-dp-core.c +3 -3
index a97f3f4..1deab9f 100644
@@ -1091,8 +1091,6 @@ static int cdn_dp_bind(struct device *dev, struct device *master, void *data)
 		goto err_free_connector;
 	}
 
-	cdn_dp_audio_codec_init(dp, dev);
-
 	for (i = 0; i < dp->ports; i++) {
 		port = dp->port[i];
 
@@ -1127,7 +1125,6 @@ static void cdn_dp_unbind(struct device *dev, struct device *master, void *data)
 	struct drm_connector *connector = &dp->connector;
 
 	cancel_work_sync(&dp->event_work);
-	platform_device_unregister(dp->audio_pdev);
 	cdn_dp_encoder_disable(encoder);
 	encoder->funcs->destroy(encoder);
 	connector->funcs->destroy(connector);
@@ -1220,6 +1217,8 @@ static int cdn_dp_probe(struct platform_device *pdev)
 	mutex_init(&dp->lock);
 	dev_set_drvdata(dev, dp);
 
+	cdn_dp_audio_codec_init(dp, dev);
+
 	return component_add(dev, &cdn_dp_component_ops);
 }
 
@@ -1227,6 +1226,7 @@ static int cdn_dp_remove(struct platform_device *pdev)
 {
 	struct cdn_dp_device *dp = platform_get_drvdata(pdev);
 
+	platform_device_unregister(dp->audio_pdev);
 	cdn_dp_suspend(dp->dev);
 	component_del(&pdev->dev, &cdn_dp_component_ops);
 
Signature · 1 line
2.1.4