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(-)
--
2.1.4
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.
Signed-off-by: Jeffy Chen <[email protected]>
---
Changes in v2: None
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
index ec47fc2..084ee8f 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
@@ -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))
--
2.1.4
We should not cleanup iommu before cleanup other resources.
Reorder unload sequence, follow exynos drm.
Signed-off-by: Jeffy Chen <[email protected]>
---
Changes in v2: None
drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
index b360e62..a5d83cb 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
@@ -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
The panel is attached when binding analogix dp.
Signed-off-by: Jeffy Chen <[email protected]>
---
Changes in v2:
Fix some commit messages.
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
index e7cd105..a3db290 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
@@ -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);
--
2.1.4
The dp aux is registered when binding analogix dp.
Signed-off-by: Jeffy Chen <[email protected]>
---
Changes in v2: None
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
index a3db290..ec47fc2 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
@@ -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);
--
2.1.4
Signed-off-by: Jeffy Chen <[email protected]>
---
Changes in v2: None
drivers/gpu/drm/rockchip/cdn-dp-core.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/rockchip/cdn-dp-core.c b/drivers/gpu/drm/rockchip/cdn-dp-core.c
index fd79a70..a97f3f4 100644
--- a/drivers/gpu/drm/rockchip/cdn-dp-core.c
+++ b/drivers/gpu/drm/rockchip/cdn-dp-core.c
@@ -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;
}
--
2.1.4
Signed-off-by: Jeffy Chen <[email protected]>
---
Changes in v2: None
drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
index df9e570..2bf8024 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
@@ -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
Signed-off-by: Jeffy Chen <[email protected]>
---
Changes in v2: None
drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
index a5d83cb..5dbf011 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
@@ -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);
--
2.1.4
Signed-off-by: Jeffy Chen <[email protected]>
---
Changes in v2: None
drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 31 +++++++++++++++++++----------
1 file changed, 21 insertions(+), 10 deletions(-)
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
index 76c79ac..1d85319 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
@@ -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;
}
--
2.1.4
In current sound framework, there's no way to unbind dai link after
unregister codec.
So move unregister codec to driver remove for now.
Signed-off-by: Jeffy Chen <[email protected]>
---
Changes in v2: None
drivers/gpu/drm/rockchip/cdn-dp-core.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/rockchip/cdn-dp-core.c b/drivers/gpu/drm/rockchip/cdn-dp-core.c
index a97f3f4..1deab9f 100644
--- a/drivers/gpu/drm/rockchip/cdn-dp-core.c
+++ b/drivers/gpu/drm/rockchip/cdn-dp-core.c
@@ -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);
--
2.1.4
On Sat, Apr 01, 2017 at 07:35:28PM +0800, Jeffy Chen wrote:
> Signed-off-by: Jeffy Chen <[email protected]>
> ---
>
> 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
>
> drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> index df9e570..2bf8024 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> @@ -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
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
On Sat, Apr 1, 2017 at 1:35 PM, Jeffy Chen <[email protected]> wrote:
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> index a5d83cb..5dbf011 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> @@ -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
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
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.
> Signed-off-by: Jeffy Chen <[email protected]>
> ---
>
> Changes in v2: None
>
> drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 31 +++++++++++++++++++----------
> 1 file changed, 21 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> index 76c79ac..1d85319 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> @@ -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
> + }
> +
> /* 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);
Should be above err_unprepare_dclk
> 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;
> + }
This function move would be a lot easier to understand with a commit message ;-)
> +
> 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()?
>
> 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
>
--
Sean Paul, Software Engineer, Google / Chromium OS
On Sat, Apr 01, 2017 at 07:35:26PM +0800, Jeffy Chen wrote:
> 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
>
> Signed-off-by: Jeffy Chen <[email protected]>
> ---
>
> Changes in v2: None
>
> drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> index b360e62..a5d83cb 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> @@ -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
>
--
Sean Paul, Software Engineer, Google / Chromium OS
Hi Daniel,
On 04/03/2017 03:41 PM, Daniel Vetter wrote:
> On Sat, Apr 01, 2017 at 07:35:28PM +0800, Jeffy Chen wrote:
>> Signed-off-by: Jeffy Chen <[email protected]>
>> ---
>>
>> 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.
>
> Thanks, Daniel
>
>>
>> drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 8 ++++++++
>> 1 file changed, 8 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
>> index df9e570..2bf8024 100644
>> --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
>> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
>> @@ -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
>
Hi Sean,
On 04/05/2017 03:44 AM, Sean Paul wrote:
> On Sat, Apr 01, 2017 at 07:35:26PM +0800, Jeffy Chen wrote:
>> 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.
>
> Sean
>
>>
>> Signed-off-by: Jeffy Chen <[email protected]>
>> ---
>>
>> Changes in v2: None
>>
>> drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 6 ++++--
>> 1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
>> index b360e62..a5d83cb 100644
>> --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
>> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
>> @@ -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
>>
>
Hi Sean,
On 04/05/2017 03:42 AM, Sean Paul wrote:
> 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.
>
>> Signed-off-by: Jeffy Chen <[email protected]>
>> ---
>>
>> Changes in v2: None
>>
>> drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 31 +++++++++++++++++++----------
>> 1 file changed, 21 insertions(+), 10 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
>> index 76c79ac..1d85319 100644
>> --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
>> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
>> @@ -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
hmm, that's true, i copied it from vop_enable without a double
check...will fix that too.
>
>> + }
>> +
>> /* 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);
>
> Should be above err_unprepare_dclk
>
oh, too careless, thanx for pointing that out.
>> 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;
>> + }
>
> This function move would be a lot easier to understand with a commit message ;-)
>
ok
>> +
>> 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 ;)
>>
>> 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
>>
>
Hi Daniel,
On 04/03/2017 03:58 PM, Daniel Vetter wrote:
> On Sat, Apr 1, 2017 at 1:35 PM, Jeffy Chen <[email protected]> wrote:
>> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
>> index a5d83cb..5dbf011 100644
>> --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
>> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
>> @@ -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
>
oops, thanx for the notice.