* [PATCH v8 1/8] drm/bridge: analogix: Do not use device's drvdata
2018-01-10 16:23 [PATCH v8 0/8] rockchip: kevin: Enable edp display Thierry Escande
@ 2018-01-10 16:23 ` Thierry Escande
2018-01-10 16:23 ` [PATCH v8 7/8] drm/bridge/synopsys: dw-hdmi: Do not use device's drvdata Thierry Escande
2018-01-10 16:23 ` [PATCH v8 8/8] drm/rockchip: dw_hdmi: Fix error handling path Thierry Escande
2 siblings, 0 replies; 31+ messages in thread
From: Thierry Escande @ 2018-01-10 16:23 UTC (permalink / raw)
To: Rob Herring, Archit Taneja, Daniel Vetter, Neil Armstrong,
Laurent Pinchart, Sandy Huang
Cc: linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Jeffy Chen,
Sean Paul, linux-kernel-u79uwXL29TY76Z2rM5mHXA,
dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
From: Jeffy Chen <jeffy.chen-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
The driver that instantiates the bridge should own the drvdata, as all
driver model callbacks (probe, remove, shutdown, PM ops, etc.) are also
owned by its driver struct. Moreover, storing two different pointer
types in driver data depending on driver initialization status is barely
a good practice and in fact has led to many bugs in this driver.
Let's clean up this mess and change Analogix entry points to simply
accept some opaque struct pointer, adjusting their users at the same
time to avoid breaking the compilation.
Signed-off-by: Tomasz Figa <tfiga-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
Signed-off-by: Jeffy Chen <jeffy.chen-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
Signed-off-by: Thierry Escande <thierry.escande-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
Reviewed-by: Andrzej Hajda <a.hajda-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
Reviewed-by: Sean Paul <seanpaul-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
Acked-by: Jingoo Han <jingoohan1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Acked-by: Archit Taneja <architt-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
---
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 50 +++++++++-------------
drivers/gpu/drm/exynos/exynos_dp.c | 26 ++++++-----
drivers/gpu/drm/rockchip/analogix_dp-rockchip.c | 48 ++++++++++++---------
include/drm/bridge/analogix_dp.h | 19 ++++----
4 files changed, 74 insertions(+), 69 deletions(-)
diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
index a8905049b9da..878f61b65cb2 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
@@ -98,17 +98,15 @@ static int analogix_dp_detect_hpd(struct analogix_dp_device *dp)
return 0;
}
-int analogix_dp_psr_supported(struct device *dev)
+int analogix_dp_psr_supported(struct analogix_dp_device *dp)
{
- struct analogix_dp_device *dp = dev_get_drvdata(dev);
return dp->psr_support;
}
EXPORT_SYMBOL_GPL(analogix_dp_psr_supported);
-int analogix_dp_enable_psr(struct device *dev)
+int analogix_dp_enable_psr(struct analogix_dp_device *dp)
{
- struct analogix_dp_device *dp = dev_get_drvdata(dev);
struct edp_vsc_psr psr_vsc;
if (!dp->psr_support)
@@ -129,9 +127,8 @@ int analogix_dp_enable_psr(struct device *dev)
}
EXPORT_SYMBOL_GPL(analogix_dp_enable_psr);
-int analogix_dp_disable_psr(struct device *dev)
+int analogix_dp_disable_psr(struct analogix_dp_device *dp)
{
- struct analogix_dp_device *dp = dev_get_drvdata(dev);
struct edp_vsc_psr psr_vsc;
int ret;
@@ -1283,8 +1280,9 @@ static ssize_t analogix_dpaux_transfer(struct drm_dp_aux *aux,
return analogix_dp_transfer(dp, msg);
}
-int analogix_dp_bind(struct device *dev, struct drm_device *drm_dev,
- struct analogix_dp_plat_data *plat_data)
+struct analogix_dp_device *
+analogix_dp_bind(struct device *dev, struct drm_device *drm_dev,
+ struct analogix_dp_plat_data *plat_data)
{
struct platform_device *pdev = to_platform_device(dev);
struct analogix_dp_device *dp;
@@ -1294,14 +1292,12 @@ int analogix_dp_bind(struct device *dev, struct drm_device *drm_dev,
if (!plat_data) {
dev_err(dev, "Invalided input plat_data\n");
- return -EINVAL;
+ return ERR_PTR(-EINVAL);
}
dp = devm_kzalloc(dev, sizeof(struct analogix_dp_device), GFP_KERNEL);
if (!dp)
- return -ENOMEM;
-
- dev_set_drvdata(dev, dp);
+ return ERR_PTR(-ENOMEM);
dp->dev = &pdev->dev;
dp->dpms_mode = DRM_MODE_DPMS_OFF;
@@ -1318,7 +1314,7 @@ int analogix_dp_bind(struct device *dev, struct drm_device *drm_dev,
ret = analogix_dp_dt_parse_pdata(dp);
if (ret)
- return ret;
+ return ERR_PTR(ret);
dp->phy = devm_phy_get(dp->dev, "dp");
if (IS_ERR(dp->phy)) {
@@ -1332,14 +1328,14 @@ int analogix_dp_bind(struct device *dev, struct drm_device *drm_dev,
if (ret == -ENOSYS || ret == -ENODEV)
dp->phy = NULL;
else
- return ret;
+ return ERR_PTR(ret);
}
}
dp->clock = devm_clk_get(&pdev->dev, "dp");
if (IS_ERR(dp->clock)) {
dev_err(&pdev->dev, "failed to get clock\n");
- return PTR_ERR(dp->clock);
+ return ERR_CAST(dp->clock);
}
clk_prepare_enable(dp->clock);
@@ -1348,7 +1344,7 @@ int analogix_dp_bind(struct device *dev, struct drm_device *drm_dev,
dp->reg_base = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(dp->reg_base))
- return PTR_ERR(dp->reg_base);
+ return ERR_CAST(dp->reg_base);
dp->force_hpd = of_property_read_bool(dev->of_node, "force-hpd");
@@ -1369,7 +1365,7 @@ int analogix_dp_bind(struct device *dev, struct drm_device *drm_dev,
"hpd_gpio");
if (ret) {
dev_err(&pdev->dev, "failed to get hpd gpio\n");
- return ret;
+ return ERR_PTR(ret);
}
dp->irq = gpio_to_irq(dp->hpd_gpio);
irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING;
@@ -1381,7 +1377,7 @@ int analogix_dp_bind(struct device *dev, struct drm_device *drm_dev,
if (dp->irq == -ENXIO) {
dev_err(&pdev->dev, "failed to get irq\n");
- return -ENODEV;
+ return ERR_PTR(-ENODEV);
}
pm_runtime_enable(dev);
@@ -1422,7 +1418,7 @@ int analogix_dp_bind(struct device *dev, struct drm_device *drm_dev,
phy_power_off(dp->phy);
pm_runtime_put(dev);
- return 0;
+ return dp;
err_disable_pm_runtime:
@@ -1430,15 +1426,12 @@ int analogix_dp_bind(struct device *dev, struct drm_device *drm_dev,
pm_runtime_put(dev);
pm_runtime_disable(dev);
- return ret;
+ return ERR_PTR(ret);
}
EXPORT_SYMBOL_GPL(analogix_dp_bind);
-void analogix_dp_unbind(struct device *dev, struct device *master,
- void *data)
+void analogix_dp_unbind(struct analogix_dp_device *dp)
{
- struct analogix_dp_device *dp = dev_get_drvdata(dev);
-
analogix_dp_bridge_disable(dp->bridge);
dp->connector.funcs->destroy(&dp->connector);
dp->encoder->funcs->destroy(dp->encoder);
@@ -1451,16 +1444,14 @@ void analogix_dp_unbind(struct device *dev, struct device *master,
}
drm_dp_aux_unregister(&dp->aux);
- pm_runtime_disable(dev);
+ pm_runtime_disable(dp->dev);
clk_disable_unprepare(dp->clock);
}
EXPORT_SYMBOL_GPL(analogix_dp_unbind);
#ifdef CONFIG_PM
-int analogix_dp_suspend(struct device *dev)
+int analogix_dp_suspend(struct analogix_dp_device *dp)
{
- struct analogix_dp_device *dp = dev_get_drvdata(dev);
-
clk_disable_unprepare(dp->clock);
if (dp->plat_data->panel) {
@@ -1472,9 +1463,8 @@ int analogix_dp_suspend(struct device *dev)
}
EXPORT_SYMBOL_GPL(analogix_dp_suspend);
-int analogix_dp_resume(struct device *dev)
+int analogix_dp_resume(struct analogix_dp_device *dp)
{
- struct analogix_dp_device *dp = dev_get_drvdata(dev);
int ret;
ret = clk_prepare_enable(dp->clock);
diff --git a/drivers/gpu/drm/exynos/exynos_dp.c b/drivers/gpu/drm/exynos/exynos_dp.c
index 39629e7a80b9..f7e5b2c405ed 100644
--- a/drivers/gpu/drm/exynos/exynos_dp.c
+++ b/drivers/gpu/drm/exynos/exynos_dp.c
@@ -41,6 +41,7 @@ struct exynos_dp_device {
struct device *dev;
struct videomode vm;
+ struct analogix_dp_device *adp;
struct analogix_dp_plat_data plat_data;
};
@@ -157,13 +158,6 @@ static int exynos_dp_bind(struct device *dev, struct device *master, void *data)
struct drm_device *drm_dev = data;
int ret;
- /*
- * Just like the probe function said, we don't need the
- * device drvrate anymore, we should leave the charge to
- * analogix dp driver, set the device drvdata to NULL.
- */
- dev_set_drvdata(dev, NULL);
-
dp->dev = dev;
dp->drm_dev = drm_dev;
@@ -190,13 +184,19 @@ static int exynos_dp_bind(struct device *dev, struct device *master, void *data)
dp->plat_data.encoder = encoder;
- return analogix_dp_bind(dev, dp->drm_dev, &dp->plat_data);
+ dp->adp = analogix_dp_bind(dev, dp->drm_dev, &dp->plat_data);
+ if (IS_ERR(dp->adp))
+ return PTR_ERR(dp->adp);
+
+ return 0;
}
static void exynos_dp_unbind(struct device *dev, struct device *master,
void *data)
{
- return analogix_dp_unbind(dev, master, data);
+ struct exynos_dp_device *dp = dev_get_drvdata(dev);
+
+ return analogix_dp_unbind(dp->adp);
}
static const struct component_ops exynos_dp_ops = {
@@ -257,12 +257,16 @@ static int exynos_dp_remove(struct platform_device *pdev)
#ifdef CONFIG_PM
static int exynos_dp_suspend(struct device *dev)
{
- return analogix_dp_suspend(dev);
+ struct exynos_dp_device *dp = dev_get_drvdata(dev);
+
+ return analogix_dp_suspend(dp->adp);
}
static int exynos_dp_resume(struct device *dev)
{
- return analogix_dp_resume(dev);
+ struct exynos_dp_device *dp = dev_get_drvdata(dev);
+
+ return analogix_dp_resume(dp->adp);
}
#endif
diff --git a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
index 1262120a3834..8a58ad80f509 100644
--- a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
+++ b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
@@ -77,6 +77,7 @@ struct rockchip_dp_device {
const struct rockchip_dp_chip_data *data;
+ struct analogix_dp_device *adp;
struct analogix_dp_plat_data plat_data;
};
@@ -84,7 +85,7 @@ static void analogix_dp_psr_set(struct drm_encoder *encoder, bool enabled)
{
struct rockchip_dp_device *dp = to_dp(encoder);
- if (!analogix_dp_psr_supported(dp->dev))
+ if (!analogix_dp_psr_supported(dp->adp))
return;
DRM_DEV_DEBUG(dp->dev, "%s PSR...\n", enabled ? "Entry" : "Exit");
@@ -114,9 +115,9 @@ static void analogix_dp_psr_work(struct work_struct *work)
mutex_lock(&dp->psr_lock);
if (dp->psr_state == EDP_VSC_PSR_STATE_ACTIVE)
- analogix_dp_enable_psr(dp->dev);
+ analogix_dp_enable_psr(dp->adp);
else
- analogix_dp_disable_psr(dp->dev);
+ analogix_dp_disable_psr(dp->adp);
mutex_unlock(&dp->psr_lock);
}
@@ -334,13 +335,6 @@ static int rockchip_dp_bind(struct device *dev, struct device *master,
struct drm_device *drm_dev = data;
int ret;
- /*
- * Just like the probe function said, we don't need the
- * device drvrate anymore, we should leave the charge to
- * analogix dp driver, set the device drvdata to NULL.
- */
- dev_set_drvdata(dev, NULL);
-
dp_data = of_device_get_match_data(dev);
if (!dp_data)
return -ENODEV;
@@ -367,7 +361,11 @@ static int rockchip_dp_bind(struct device *dev, struct device *master,
rockchip_drm_psr_register(&dp->encoder, analogix_dp_psr_set);
- return analogix_dp_bind(dev, dp->drm_dev, &dp->plat_data);
+ dp->adp = analogix_dp_bind(dev, dp->drm_dev, &dp->plat_data);
+ if (IS_ERR(dp->adp))
+ return PTR_ERR(dp->adp);
+
+ return 0;
}
static void rockchip_dp_unbind(struct device *dev, struct device *master,
@@ -376,8 +374,7 @@ static void rockchip_dp_unbind(struct device *dev, struct device *master,
struct rockchip_dp_device *dp = dev_get_drvdata(dev);
rockchip_drm_psr_unregister(&dp->encoder);
-
- analogix_dp_unbind(dev, master, data);
+ analogix_dp_unbind(dp->adp);
}
static const struct component_ops rockchip_dp_component_ops = {
@@ -407,11 +404,6 @@ static int rockchip_dp_probe(struct platform_device *pdev)
if (ret < 0)
return ret;
- /*
- * We just use the drvdata until driver run into component
- * add function, and then we would set drvdata to null, so
- * that analogix dp driver could take charge of the drvdata.
- */
platform_set_drvdata(pdev, dp);
return component_add(dev, &rockchip_dp_component_ops);
@@ -424,10 +416,26 @@ static int rockchip_dp_remove(struct platform_device *pdev)
return 0;
}
+#ifdef CONFIG_PM_SLEEP
+static int rockchip_dp_suspend(struct device *dev)
+{
+ struct rockchip_dp_device *dp = dev_get_drvdata(dev);
+
+ return analogix_dp_suspend(dp->adp);
+}
+
+static int rockchip_dp_resume(struct device *dev)
+{
+ struct rockchip_dp_device *dp = dev_get_drvdata(dev);
+
+ return analogix_dp_resume(dp->adp);
+}
+#endif
+
static const struct dev_pm_ops rockchip_dp_pm_ops = {
#ifdef CONFIG_PM_SLEEP
- .suspend = analogix_dp_suspend,
- .resume_early = analogix_dp_resume,
+ .suspend = rockchip_dp_suspend,
+ .resume_early = rockchip_dp_resume,
#endif
};
diff --git a/include/drm/bridge/analogix_dp.h b/include/drm/bridge/analogix_dp.h
index c99d6eaef1ac..5518fc75dd6e 100644
--- a/include/drm/bridge/analogix_dp.h
+++ b/include/drm/bridge/analogix_dp.h
@@ -13,6 +13,8 @@
#include <drm/drm_crtc.h>
+struct analogix_dp_device;
+
enum analogix_dp_devtype {
EXYNOS_DP,
RK3288_DP,
@@ -38,16 +40,17 @@ struct analogix_dp_plat_data {
struct drm_connector *);
};
-int analogix_dp_psr_supported(struct device *dev);
-int analogix_dp_enable_psr(struct device *dev);
-int analogix_dp_disable_psr(struct device *dev);
+int analogix_dp_psr_supported(struct analogix_dp_device *dp);
+int analogix_dp_enable_psr(struct analogix_dp_device *dp);
+int analogix_dp_disable_psr(struct analogix_dp_device *dp);
-int analogix_dp_resume(struct device *dev);
-int analogix_dp_suspend(struct device *dev);
+int analogix_dp_resume(struct analogix_dp_device *dp);
+int analogix_dp_suspend(struct analogix_dp_device *dp);
-int analogix_dp_bind(struct device *dev, struct drm_device *drm_dev,
- struct analogix_dp_plat_data *plat_data);
-void analogix_dp_unbind(struct device *dev, struct device *master, void *data);
+struct analogix_dp_device *
+analogix_dp_bind(struct device *dev, struct drm_device *drm_dev,
+ struct analogix_dp_plat_data *plat_data);
+void analogix_dp_unbind(struct analogix_dp_device *dp);
int analogix_dp_start_crc(struct drm_connector *connector);
int analogix_dp_stop_crc(struct drm_connector *connector);
--
2.14.1
^ permalink raw reply related [flat|nested] 31+ messages in thread* [PATCH v8 1/8] drm/bridge: analogix: Do not use device's drvdata
@ 2018-01-10 16:23 ` Thierry Escande
0 siblings, 0 replies; 31+ messages in thread
From: Thierry Escande @ 2018-01-10 16:23 UTC (permalink / raw)
To: Rob Herring, Archit Taneja, Daniel Vetter, Neil Armstrong,
Laurent Pinchart, Sandy Huang
Cc: Jeffy Chen, Sean Paul, dri-devel, linux-rockchip, linux-kernel
From: Jeffy Chen <jeffy.chen@rock-chips.com>
The driver that instantiates the bridge should own the drvdata, as all
driver model callbacks (probe, remove, shutdown, PM ops, etc.) are also
owned by its driver struct. Moreover, storing two different pointer
types in driver data depending on driver initialization status is barely
a good practice and in fact has led to many bugs in this driver.
Let's clean up this mess and change Analogix entry points to simply
accept some opaque struct pointer, adjusting their users at the same
time to avoid breaking the compilation.
Signed-off-by: Tomasz Figa <tfiga@chromium.org>
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
Signed-off-by: Thierry Escande <thierry.escande@collabora.com>
Reviewed-by: Andrzej Hajda <a.hajda@samsung.com>
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Acked-by: Jingoo Han <jingoohan1@gmail.com>
Acked-by: Archit Taneja <architt@codeaurora.org>
---
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 50 +++++++++-------------
drivers/gpu/drm/exynos/exynos_dp.c | 26 ++++++-----
drivers/gpu/drm/rockchip/analogix_dp-rockchip.c | 48 ++++++++++++---------
include/drm/bridge/analogix_dp.h | 19 ++++----
4 files changed, 74 insertions(+), 69 deletions(-)
diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
index a8905049b9da..878f61b65cb2 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
@@ -98,17 +98,15 @@ static int analogix_dp_detect_hpd(struct analogix_dp_device *dp)
return 0;
}
-int analogix_dp_psr_supported(struct device *dev)
+int analogix_dp_psr_supported(struct analogix_dp_device *dp)
{
- struct analogix_dp_device *dp = dev_get_drvdata(dev);
return dp->psr_support;
}
EXPORT_SYMBOL_GPL(analogix_dp_psr_supported);
-int analogix_dp_enable_psr(struct device *dev)
+int analogix_dp_enable_psr(struct analogix_dp_device *dp)
{
- struct analogix_dp_device *dp = dev_get_drvdata(dev);
struct edp_vsc_psr psr_vsc;
if (!dp->psr_support)
@@ -129,9 +127,8 @@ int analogix_dp_enable_psr(struct device *dev)
}
EXPORT_SYMBOL_GPL(analogix_dp_enable_psr);
-int analogix_dp_disable_psr(struct device *dev)
+int analogix_dp_disable_psr(struct analogix_dp_device *dp)
{
- struct analogix_dp_device *dp = dev_get_drvdata(dev);
struct edp_vsc_psr psr_vsc;
int ret;
@@ -1283,8 +1280,9 @@ static ssize_t analogix_dpaux_transfer(struct drm_dp_aux *aux,
return analogix_dp_transfer(dp, msg);
}
-int analogix_dp_bind(struct device *dev, struct drm_device *drm_dev,
- struct analogix_dp_plat_data *plat_data)
+struct analogix_dp_device *
+analogix_dp_bind(struct device *dev, struct drm_device *drm_dev,
+ struct analogix_dp_plat_data *plat_data)
{
struct platform_device *pdev = to_platform_device(dev);
struct analogix_dp_device *dp;
@@ -1294,14 +1292,12 @@ int analogix_dp_bind(struct device *dev, struct drm_device *drm_dev,
if (!plat_data) {
dev_err(dev, "Invalided input plat_data\n");
- return -EINVAL;
+ return ERR_PTR(-EINVAL);
}
dp = devm_kzalloc(dev, sizeof(struct analogix_dp_device), GFP_KERNEL);
if (!dp)
- return -ENOMEM;
-
- dev_set_drvdata(dev, dp);
+ return ERR_PTR(-ENOMEM);
dp->dev = &pdev->dev;
dp->dpms_mode = DRM_MODE_DPMS_OFF;
@@ -1318,7 +1314,7 @@ int analogix_dp_bind(struct device *dev, struct drm_device *drm_dev,
ret = analogix_dp_dt_parse_pdata(dp);
if (ret)
- return ret;
+ return ERR_PTR(ret);
dp->phy = devm_phy_get(dp->dev, "dp");
if (IS_ERR(dp->phy)) {
@@ -1332,14 +1328,14 @@ int analogix_dp_bind(struct device *dev, struct drm_device *drm_dev,
if (ret == -ENOSYS || ret == -ENODEV)
dp->phy = NULL;
else
- return ret;
+ return ERR_PTR(ret);
}
}
dp->clock = devm_clk_get(&pdev->dev, "dp");
if (IS_ERR(dp->clock)) {
dev_err(&pdev->dev, "failed to get clock\n");
- return PTR_ERR(dp->clock);
+ return ERR_CAST(dp->clock);
}
clk_prepare_enable(dp->clock);
@@ -1348,7 +1344,7 @@ int analogix_dp_bind(struct device *dev, struct drm_device *drm_dev,
dp->reg_base = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(dp->reg_base))
- return PTR_ERR(dp->reg_base);
+ return ERR_CAST(dp->reg_base);
dp->force_hpd = of_property_read_bool(dev->of_node, "force-hpd");
@@ -1369,7 +1365,7 @@ int analogix_dp_bind(struct device *dev, struct drm_device *drm_dev,
"hpd_gpio");
if (ret) {
dev_err(&pdev->dev, "failed to get hpd gpio\n");
- return ret;
+ return ERR_PTR(ret);
}
dp->irq = gpio_to_irq(dp->hpd_gpio);
irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING;
@@ -1381,7 +1377,7 @@ int analogix_dp_bind(struct device *dev, struct drm_device *drm_dev,
if (dp->irq == -ENXIO) {
dev_err(&pdev->dev, "failed to get irq\n");
- return -ENODEV;
+ return ERR_PTR(-ENODEV);
}
pm_runtime_enable(dev);
@@ -1422,7 +1418,7 @@ int analogix_dp_bind(struct device *dev, struct drm_device *drm_dev,
phy_power_off(dp->phy);
pm_runtime_put(dev);
- return 0;
+ return dp;
err_disable_pm_runtime:
@@ -1430,15 +1426,12 @@ int analogix_dp_bind(struct device *dev, struct drm_device *drm_dev,
pm_runtime_put(dev);
pm_runtime_disable(dev);
- return ret;
+ return ERR_PTR(ret);
}
EXPORT_SYMBOL_GPL(analogix_dp_bind);
-void analogix_dp_unbind(struct device *dev, struct device *master,
- void *data)
+void analogix_dp_unbind(struct analogix_dp_device *dp)
{
- struct analogix_dp_device *dp = dev_get_drvdata(dev);
-
analogix_dp_bridge_disable(dp->bridge);
dp->connector.funcs->destroy(&dp->connector);
dp->encoder->funcs->destroy(dp->encoder);
@@ -1451,16 +1444,14 @@ void analogix_dp_unbind(struct device *dev, struct device *master,
}
drm_dp_aux_unregister(&dp->aux);
- pm_runtime_disable(dev);
+ pm_runtime_disable(dp->dev);
clk_disable_unprepare(dp->clock);
}
EXPORT_SYMBOL_GPL(analogix_dp_unbind);
#ifdef CONFIG_PM
-int analogix_dp_suspend(struct device *dev)
+int analogix_dp_suspend(struct analogix_dp_device *dp)
{
- struct analogix_dp_device *dp = dev_get_drvdata(dev);
-
clk_disable_unprepare(dp->clock);
if (dp->plat_data->panel) {
@@ -1472,9 +1463,8 @@ int analogix_dp_suspend(struct device *dev)
}
EXPORT_SYMBOL_GPL(analogix_dp_suspend);
-int analogix_dp_resume(struct device *dev)
+int analogix_dp_resume(struct analogix_dp_device *dp)
{
- struct analogix_dp_device *dp = dev_get_drvdata(dev);
int ret;
ret = clk_prepare_enable(dp->clock);
diff --git a/drivers/gpu/drm/exynos/exynos_dp.c b/drivers/gpu/drm/exynos/exynos_dp.c
index 39629e7a80b9..f7e5b2c405ed 100644
--- a/drivers/gpu/drm/exynos/exynos_dp.c
+++ b/drivers/gpu/drm/exynos/exynos_dp.c
@@ -41,6 +41,7 @@ struct exynos_dp_device {
struct device *dev;
struct videomode vm;
+ struct analogix_dp_device *adp;
struct analogix_dp_plat_data plat_data;
};
@@ -157,13 +158,6 @@ static int exynos_dp_bind(struct device *dev, struct device *master, void *data)
struct drm_device *drm_dev = data;
int ret;
- /*
- * Just like the probe function said, we don't need the
- * device drvrate anymore, we should leave the charge to
- * analogix dp driver, set the device drvdata to NULL.
- */
- dev_set_drvdata(dev, NULL);
-
dp->dev = dev;
dp->drm_dev = drm_dev;
@@ -190,13 +184,19 @@ static int exynos_dp_bind(struct device *dev, struct device *master, void *data)
dp->plat_data.encoder = encoder;
- return analogix_dp_bind(dev, dp->drm_dev, &dp->plat_data);
+ dp->adp = analogix_dp_bind(dev, dp->drm_dev, &dp->plat_data);
+ if (IS_ERR(dp->adp))
+ return PTR_ERR(dp->adp);
+
+ return 0;
}
static void exynos_dp_unbind(struct device *dev, struct device *master,
void *data)
{
- return analogix_dp_unbind(dev, master, data);
+ struct exynos_dp_device *dp = dev_get_drvdata(dev);
+
+ return analogix_dp_unbind(dp->adp);
}
static const struct component_ops exynos_dp_ops = {
@@ -257,12 +257,16 @@ static int exynos_dp_remove(struct platform_device *pdev)
#ifdef CONFIG_PM
static int exynos_dp_suspend(struct device *dev)
{
- return analogix_dp_suspend(dev);
+ struct exynos_dp_device *dp = dev_get_drvdata(dev);
+
+ return analogix_dp_suspend(dp->adp);
}
static int exynos_dp_resume(struct device *dev)
{
- return analogix_dp_resume(dev);
+ struct exynos_dp_device *dp = dev_get_drvdata(dev);
+
+ return analogix_dp_resume(dp->adp);
}
#endif
diff --git a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
index 1262120a3834..8a58ad80f509 100644
--- a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
+++ b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
@@ -77,6 +77,7 @@ struct rockchip_dp_device {
const struct rockchip_dp_chip_data *data;
+ struct analogix_dp_device *adp;
struct analogix_dp_plat_data plat_data;
};
@@ -84,7 +85,7 @@ static void analogix_dp_psr_set(struct drm_encoder *encoder, bool enabled)
{
struct rockchip_dp_device *dp = to_dp(encoder);
- if (!analogix_dp_psr_supported(dp->dev))
+ if (!analogix_dp_psr_supported(dp->adp))
return;
DRM_DEV_DEBUG(dp->dev, "%s PSR...\n", enabled ? "Entry" : "Exit");
@@ -114,9 +115,9 @@ static void analogix_dp_psr_work(struct work_struct *work)
mutex_lock(&dp->psr_lock);
if (dp->psr_state == EDP_VSC_PSR_STATE_ACTIVE)
- analogix_dp_enable_psr(dp->dev);
+ analogix_dp_enable_psr(dp->adp);
else
- analogix_dp_disable_psr(dp->dev);
+ analogix_dp_disable_psr(dp->adp);
mutex_unlock(&dp->psr_lock);
}
@@ -334,13 +335,6 @@ static int rockchip_dp_bind(struct device *dev, struct device *master,
struct drm_device *drm_dev = data;
int ret;
- /*
- * Just like the probe function said, we don't need the
- * device drvrate anymore, we should leave the charge to
- * analogix dp driver, set the device drvdata to NULL.
- */
- dev_set_drvdata(dev, NULL);
-
dp_data = of_device_get_match_data(dev);
if (!dp_data)
return -ENODEV;
@@ -367,7 +361,11 @@ static int rockchip_dp_bind(struct device *dev, struct device *master,
rockchip_drm_psr_register(&dp->encoder, analogix_dp_psr_set);
- return analogix_dp_bind(dev, dp->drm_dev, &dp->plat_data);
+ dp->adp = analogix_dp_bind(dev, dp->drm_dev, &dp->plat_data);
+ if (IS_ERR(dp->adp))
+ return PTR_ERR(dp->adp);
+
+ return 0;
}
static void rockchip_dp_unbind(struct device *dev, struct device *master,
@@ -376,8 +374,7 @@ static void rockchip_dp_unbind(struct device *dev, struct device *master,
struct rockchip_dp_device *dp = dev_get_drvdata(dev);
rockchip_drm_psr_unregister(&dp->encoder);
-
- analogix_dp_unbind(dev, master, data);
+ analogix_dp_unbind(dp->adp);
}
static const struct component_ops rockchip_dp_component_ops = {
@@ -407,11 +404,6 @@ static int rockchip_dp_probe(struct platform_device *pdev)
if (ret < 0)
return ret;
- /*
- * We just use the drvdata until driver run into component
- * add function, and then we would set drvdata to null, so
- * that analogix dp driver could take charge of the drvdata.
- */
platform_set_drvdata(pdev, dp);
return component_add(dev, &rockchip_dp_component_ops);
@@ -424,10 +416,26 @@ static int rockchip_dp_remove(struct platform_device *pdev)
return 0;
}
+#ifdef CONFIG_PM_SLEEP
+static int rockchip_dp_suspend(struct device *dev)
+{
+ struct rockchip_dp_device *dp = dev_get_drvdata(dev);
+
+ return analogix_dp_suspend(dp->adp);
+}
+
+static int rockchip_dp_resume(struct device *dev)
+{
+ struct rockchip_dp_device *dp = dev_get_drvdata(dev);
+
+ return analogix_dp_resume(dp->adp);
+}
+#endif
+
static const struct dev_pm_ops rockchip_dp_pm_ops = {
#ifdef CONFIG_PM_SLEEP
- .suspend = analogix_dp_suspend,
- .resume_early = analogix_dp_resume,
+ .suspend = rockchip_dp_suspend,
+ .resume_early = rockchip_dp_resume,
#endif
};
diff --git a/include/drm/bridge/analogix_dp.h b/include/drm/bridge/analogix_dp.h
index c99d6eaef1ac..5518fc75dd6e 100644
--- a/include/drm/bridge/analogix_dp.h
+++ b/include/drm/bridge/analogix_dp.h
@@ -13,6 +13,8 @@
#include <drm/drm_crtc.h>
+struct analogix_dp_device;
+
enum analogix_dp_devtype {
EXYNOS_DP,
RK3288_DP,
@@ -38,16 +40,17 @@ struct analogix_dp_plat_data {
struct drm_connector *);
};
-int analogix_dp_psr_supported(struct device *dev);
-int analogix_dp_enable_psr(struct device *dev);
-int analogix_dp_disable_psr(struct device *dev);
+int analogix_dp_psr_supported(struct analogix_dp_device *dp);
+int analogix_dp_enable_psr(struct analogix_dp_device *dp);
+int analogix_dp_disable_psr(struct analogix_dp_device *dp);
-int analogix_dp_resume(struct device *dev);
-int analogix_dp_suspend(struct device *dev);
+int analogix_dp_resume(struct analogix_dp_device *dp);
+int analogix_dp_suspend(struct analogix_dp_device *dp);
-int analogix_dp_bind(struct device *dev, struct drm_device *drm_dev,
- struct analogix_dp_plat_data *plat_data);
-void analogix_dp_unbind(struct device *dev, struct device *master, void *data);
+struct analogix_dp_device *
+analogix_dp_bind(struct device *dev, struct drm_device *drm_dev,
+ struct analogix_dp_plat_data *plat_data);
+void analogix_dp_unbind(struct analogix_dp_device *dp);
int analogix_dp_start_crc(struct drm_connector *connector);
int analogix_dp_stop_crc(struct drm_connector *connector);
--
2.14.1
^ permalink raw reply related [flat|nested] 31+ messages in thread* Re: [PATCH v8 1/8] drm/bridge: analogix: Do not use device's drvdata
2018-01-10 16:23 ` Thierry Escande
@ 2018-03-01 15:39 ` Heiko Stübner
-1 siblings, 0 replies; 31+ messages in thread
From: Heiko Stübner @ 2018-03-01 15:39 UTC (permalink / raw)
To: dri-devel
Cc: Thierry Escande, Neil Armstrong, Jeffy Chen, linux-kernel,
linux-rockchip, Rob Herring, Laurent Pinchart, Daniel Vetter
Am Mittwoch, 10. Januar 2018, 17:23:41 CET schrieb Thierry Escande:
> From: Jeffy Chen <jeffy.chen@rock-chips.com>
>
> The driver that instantiates the bridge should own the drvdata, as all
> driver model callbacks (probe, remove, shutdown, PM ops, etc.) are also
> owned by its driver struct. Moreover, storing two different pointer
> types in driver data depending on driver initialization status is barely
> a good practice and in fact has led to many bugs in this driver.
>
> Let's clean up this mess and change Analogix entry points to simply
> accept some opaque struct pointer, adjusting their users at the same
> time to avoid breaking the compilation.
>
> Signed-off-by: Tomasz Figa <tfiga@chromium.org>
> Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
> Signed-off-by: Thierry Escande <thierry.escande@collabora.com>
> Reviewed-by: Andrzej Hajda <a.hajda@samsung.com>
> Reviewed-by: Sean Paul <seanpaul@chromium.org>
> Acked-by: Jingoo Han <jingoohan1@gmail.com>
> Acked-by: Archit Taneja <architt@codeaurora.org>
applied to drm-misc-next as it had Reviews/Acks from drm-bridge people
Thanks
Heiko
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v8 1/8] drm/bridge: analogix: Do not use device's drvdata
@ 2018-03-01 15:39 ` Heiko Stübner
0 siblings, 0 replies; 31+ messages in thread
From: Heiko Stübner @ 2018-03-01 15:39 UTC (permalink / raw)
To: dri-devel
Cc: Thierry Escande, Rob Herring, Archit Taneja, Daniel Vetter,
Neil Armstrong, Laurent Pinchart, Sandy Huang, linux-rockchip,
Jeffy Chen, linux-kernel
Am Mittwoch, 10. Januar 2018, 17:23:41 CET schrieb Thierry Escande:
> From: Jeffy Chen <jeffy.chen@rock-chips.com>
>
> The driver that instantiates the bridge should own the drvdata, as all
> driver model callbacks (probe, remove, shutdown, PM ops, etc.) are also
> owned by its driver struct. Moreover, storing two different pointer
> types in driver data depending on driver initialization status is barely
> a good practice and in fact has led to many bugs in this driver.
>
> Let's clean up this mess and change Analogix entry points to simply
> accept some opaque struct pointer, adjusting their users at the same
> time to avoid breaking the compilation.
>
> Signed-off-by: Tomasz Figa <tfiga@chromium.org>
> Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
> Signed-off-by: Thierry Escande <thierry.escande@collabora.com>
> Reviewed-by: Andrzej Hajda <a.hajda@samsung.com>
> Reviewed-by: Sean Paul <seanpaul@chromium.org>
> Acked-by: Jingoo Han <jingoohan1@gmail.com>
> Acked-by: Archit Taneja <architt@codeaurora.org>
applied to drm-misc-next as it had Reviews/Acks from drm-bridge people
Thanks
Heiko
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v8 2/8] drm/bridge: analogix_dp: Fix connector and encoder cleanup
2018-01-10 16:23 [PATCH v8 0/8] rockchip: kevin: Enable edp display Thierry Escande
@ 2018-01-10 16:23 ` Thierry Escande
2018-01-10 16:23 ` [PATCH v8 7/8] drm/bridge/synopsys: dw-hdmi: Do not use device's drvdata Thierry Escande
2018-01-10 16:23 ` [PATCH v8 8/8] drm/rockchip: dw_hdmi: Fix error handling path Thierry Escande
2 siblings, 0 replies; 31+ messages in thread
From: Thierry Escande @ 2018-01-10 16:23 UTC (permalink / raw)
To: Rob Herring, Archit Taneja, Daniel Vetter, Neil Armstrong,
Laurent Pinchart, Sandy Huang
Cc: linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Jeffy Chen,
Sean Paul, linux-kernel-u79uwXL29TY76Z2rM5mHXA,
dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
From: Jeffy Chen <jeffy.chen-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
Since we are initing connector in the core driver and encoder in the
plat driver, let's clean them up in the right places.
Signed-off-by: Jeffy Chen <jeffy.chen-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
Signed-off-by: Thierry Escande <thierry.escande-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
Reviewed-by: Andrzej Hajda <a.hajda-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
---
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 2 --
drivers/gpu/drm/exynos/exynos_dp.c | 7 +++++--
drivers/gpu/drm/rockchip/analogix_dp-rockchip.c | 12 +++++-------
3 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
index 878f61b65cb2..cb5e18d6ba04 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
@@ -1411,7 +1411,6 @@ analogix_dp_bind(struct device *dev, struct drm_device *drm_dev,
ret = analogix_dp_create_bridge(drm_dev, dp);
if (ret) {
DRM_ERROR("failed to create bridge (%d)\n", ret);
- drm_encoder_cleanup(dp->encoder);
goto err_disable_pm_runtime;
}
@@ -1434,7 +1433,6 @@ void analogix_dp_unbind(struct analogix_dp_device *dp)
{
analogix_dp_bridge_disable(dp->bridge);
dp->connector.funcs->destroy(&dp->connector);
- dp->encoder->funcs->destroy(dp->encoder);
if (dp->plat_data->panel) {
if (drm_panel_unprepare(dp->plat_data->panel))
diff --git a/drivers/gpu/drm/exynos/exynos_dp.c b/drivers/gpu/drm/exynos/exynos_dp.c
index f7e5b2c405ed..33319a858f3a 100644
--- a/drivers/gpu/drm/exynos/exynos_dp.c
+++ b/drivers/gpu/drm/exynos/exynos_dp.c
@@ -185,8 +185,10 @@ static int exynos_dp_bind(struct device *dev, struct device *master, void *data)
dp->plat_data.encoder = encoder;
dp->adp = analogix_dp_bind(dev, dp->drm_dev, &dp->plat_data);
- if (IS_ERR(dp->adp))
+ if (IS_ERR(dp->adp)) {
+ dp->encoder.funcs->destroy(&dp->encoder);
return PTR_ERR(dp->adp);
+ }
return 0;
}
@@ -196,7 +198,8 @@ static void exynos_dp_unbind(struct device *dev, struct device *master,
{
struct exynos_dp_device *dp = dev_get_drvdata(dev);
- return analogix_dp_unbind(dp->adp);
+ analogix_dp_unbind(dp->adp);
+ dp->encoder.funcs->destroy(&dp->encoder);
}
static const struct component_ops exynos_dp_ops = {
diff --git a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
index 8a58ad80f509..37250ab63bd7 100644
--- a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
+++ b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
@@ -259,13 +259,8 @@ static struct drm_encoder_helper_funcs rockchip_dp_encoder_helper_funcs = {
.atomic_check = rockchip_dp_drm_encoder_atomic_check,
};
-static void rockchip_dp_drm_encoder_destroy(struct drm_encoder *encoder)
-{
- drm_encoder_cleanup(encoder);
-}
-
static struct drm_encoder_funcs rockchip_dp_encoder_funcs = {
- .destroy = rockchip_dp_drm_encoder_destroy,
+ .destroy = drm_encoder_cleanup,
};
static int rockchip_dp_of_probe(struct rockchip_dp_device *dp)
@@ -362,8 +357,10 @@ static int rockchip_dp_bind(struct device *dev, struct device *master,
rockchip_drm_psr_register(&dp->encoder, analogix_dp_psr_set);
dp->adp = analogix_dp_bind(dev, dp->drm_dev, &dp->plat_data);
- if (IS_ERR(dp->adp))
+ if (IS_ERR(dp->adp)) {
+ dp->encoder.funcs->destroy(&dp->encoder);
return PTR_ERR(dp->adp);
+ }
return 0;
}
@@ -375,6 +372,7 @@ static void rockchip_dp_unbind(struct device *dev, struct device *master,
rockchip_drm_psr_unregister(&dp->encoder);
analogix_dp_unbind(dp->adp);
+ dp->encoder.funcs->destroy(&dp->encoder);
}
static const struct component_ops rockchip_dp_component_ops = {
--
2.14.1
^ permalink raw reply related [flat|nested] 31+ messages in thread* [PATCH v8 2/8] drm/bridge: analogix_dp: Fix connector and encoder cleanup
@ 2018-01-10 16:23 ` Thierry Escande
0 siblings, 0 replies; 31+ messages in thread
From: Thierry Escande @ 2018-01-10 16:23 UTC (permalink / raw)
To: Rob Herring, Archit Taneja, Daniel Vetter, Neil Armstrong,
Laurent Pinchart, Sandy Huang
Cc: Jeffy Chen, Sean Paul, dri-devel, linux-rockchip, linux-kernel
From: Jeffy Chen <jeffy.chen@rock-chips.com>
Since we are initing connector in the core driver and encoder in the
plat driver, let's clean them up in the right places.
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
Signed-off-by: Thierry Escande <thierry.escande@collabora.com>
Reviewed-by: Andrzej Hajda <a.hajda@samsung.com>
---
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 2 --
drivers/gpu/drm/exynos/exynos_dp.c | 7 +++++--
drivers/gpu/drm/rockchip/analogix_dp-rockchip.c | 12 +++++-------
3 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
index 878f61b65cb2..cb5e18d6ba04 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
@@ -1411,7 +1411,6 @@ analogix_dp_bind(struct device *dev, struct drm_device *drm_dev,
ret = analogix_dp_create_bridge(drm_dev, dp);
if (ret) {
DRM_ERROR("failed to create bridge (%d)\n", ret);
- drm_encoder_cleanup(dp->encoder);
goto err_disable_pm_runtime;
}
@@ -1434,7 +1433,6 @@ void analogix_dp_unbind(struct analogix_dp_device *dp)
{
analogix_dp_bridge_disable(dp->bridge);
dp->connector.funcs->destroy(&dp->connector);
- dp->encoder->funcs->destroy(dp->encoder);
if (dp->plat_data->panel) {
if (drm_panel_unprepare(dp->plat_data->panel))
diff --git a/drivers/gpu/drm/exynos/exynos_dp.c b/drivers/gpu/drm/exynos/exynos_dp.c
index f7e5b2c405ed..33319a858f3a 100644
--- a/drivers/gpu/drm/exynos/exynos_dp.c
+++ b/drivers/gpu/drm/exynos/exynos_dp.c
@@ -185,8 +185,10 @@ static int exynos_dp_bind(struct device *dev, struct device *master, void *data)
dp->plat_data.encoder = encoder;
dp->adp = analogix_dp_bind(dev, dp->drm_dev, &dp->plat_data);
- if (IS_ERR(dp->adp))
+ if (IS_ERR(dp->adp)) {
+ dp->encoder.funcs->destroy(&dp->encoder);
return PTR_ERR(dp->adp);
+ }
return 0;
}
@@ -196,7 +198,8 @@ static void exynos_dp_unbind(struct device *dev, struct device *master,
{
struct exynos_dp_device *dp = dev_get_drvdata(dev);
- return analogix_dp_unbind(dp->adp);
+ analogix_dp_unbind(dp->adp);
+ dp->encoder.funcs->destroy(&dp->encoder);
}
static const struct component_ops exynos_dp_ops = {
diff --git a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
index 8a58ad80f509..37250ab63bd7 100644
--- a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
+++ b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
@@ -259,13 +259,8 @@ static struct drm_encoder_helper_funcs rockchip_dp_encoder_helper_funcs = {
.atomic_check = rockchip_dp_drm_encoder_atomic_check,
};
-static void rockchip_dp_drm_encoder_destroy(struct drm_encoder *encoder)
-{
- drm_encoder_cleanup(encoder);
-}
-
static struct drm_encoder_funcs rockchip_dp_encoder_funcs = {
- .destroy = rockchip_dp_drm_encoder_destroy,
+ .destroy = drm_encoder_cleanup,
};
static int rockchip_dp_of_probe(struct rockchip_dp_device *dp)
@@ -362,8 +357,10 @@ static int rockchip_dp_bind(struct device *dev, struct device *master,
rockchip_drm_psr_register(&dp->encoder, analogix_dp_psr_set);
dp->adp = analogix_dp_bind(dev, dp->drm_dev, &dp->plat_data);
- if (IS_ERR(dp->adp))
+ if (IS_ERR(dp->adp)) {
+ dp->encoder.funcs->destroy(&dp->encoder);
return PTR_ERR(dp->adp);
+ }
return 0;
}
@@ -375,6 +372,7 @@ static void rockchip_dp_unbind(struct device *dev, struct device *master,
rockchip_drm_psr_unregister(&dp->encoder);
analogix_dp_unbind(dp->adp);
+ dp->encoder.funcs->destroy(&dp->encoder);
}
static const struct component_ops rockchip_dp_component_ops = {
--
2.14.1
^ permalink raw reply related [flat|nested] 31+ messages in thread* Re: [PATCH v8 2/8] drm/bridge: analogix_dp: Fix connector and encoder cleanup
2018-01-10 16:23 ` Thierry Escande
@ 2018-03-01 15:39 ` Heiko Stübner
-1 siblings, 0 replies; 31+ messages in thread
From: Heiko Stübner @ 2018-03-01 15:39 UTC (permalink / raw)
To: dri-devel
Cc: Thierry Escande, Neil Armstrong, Jeffy Chen, linux-kernel,
linux-rockchip, Rob Herring, Laurent Pinchart, Daniel Vetter
Am Mittwoch, 10. Januar 2018, 17:23:42 CET schrieb Thierry Escande:
> From: Jeffy Chen <jeffy.chen@rock-chips.com>
>
> Since we are initing connector in the core driver and encoder in the
> plat driver, let's clean them up in the right places.
>
> Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
> Signed-off-by: Thierry Escande <thierry.escande@collabora.com>
> Reviewed-by: Andrzej Hajda <a.hajda@samsung.com>
applied to drm-misc-next as it had also a Review from drm-bridge people
Thanks
Heiko
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v8 2/8] drm/bridge: analogix_dp: Fix connector and encoder cleanup
@ 2018-03-01 15:39 ` Heiko Stübner
0 siblings, 0 replies; 31+ messages in thread
From: Heiko Stübner @ 2018-03-01 15:39 UTC (permalink / raw)
To: dri-devel
Cc: Thierry Escande, Rob Herring, Archit Taneja, Daniel Vetter,
Neil Armstrong, Laurent Pinchart, Sandy Huang, linux-rockchip,
Jeffy Chen, linux-kernel
Am Mittwoch, 10. Januar 2018, 17:23:42 CET schrieb Thierry Escande:
> From: Jeffy Chen <jeffy.chen@rock-chips.com>
>
> Since we are initing connector in the core driver and encoder in the
> plat driver, let's clean them up in the right places.
>
> Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
> Signed-off-by: Thierry Escande <thierry.escande@collabora.com>
> Reviewed-by: Andrzej Hajda <a.hajda@samsung.com>
applied to drm-misc-next as it had also a Review from drm-bridge people
Thanks
Heiko
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v8 3/8] drm/rockchip: analogix_dp: Add a sanity check for rockchip_drm_psr_register()
2018-01-10 16:23 [PATCH v8 0/8] rockchip: kevin: Enable edp display Thierry Escande
@ 2018-01-10 16:23 ` Thierry Escande
2018-01-10 16:23 ` [PATCH v8 7/8] drm/bridge/synopsys: dw-hdmi: Do not use device's drvdata Thierry Escande
2018-01-10 16:23 ` [PATCH v8 8/8] drm/rockchip: dw_hdmi: Fix error handling path Thierry Escande
2 siblings, 0 replies; 31+ messages in thread
From: Thierry Escande @ 2018-01-10 16:23 UTC (permalink / raw)
To: Rob Herring, Archit Taneja, Daniel Vetter, Neil Armstrong,
Laurent Pinchart, Sandy Huang
Cc: linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Jeffy Chen,
Sean Paul, linux-kernel-u79uwXL29TY76Z2rM5mHXA,
dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
From: Jeffy Chen <jeffy.chen-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
The rockchip_drm_psr_register() can fail, so add a sanity check for that.
Also reorder the calls in unbind() to match bind().
Signed-off-by: Jeffy Chen <jeffy.chen-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
Signed-off-by: Thierry Escande <thierry.escande-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
---
drivers/gpu/drm/rockchip/analogix_dp-rockchip.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
index 37250ab63bd7..eb88c52336a7 100644
--- a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
+++ b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
@@ -354,15 +354,22 @@ static int rockchip_dp_bind(struct device *dev, struct device *master,
dp->psr_state = ~EDP_VSC_PSR_STATE_ACTIVE;
INIT_WORK(&dp->psr_work, analogix_dp_psr_work);
- rockchip_drm_psr_register(&dp->encoder, analogix_dp_psr_set);
+ ret = rockchip_drm_psr_register(&dp->encoder, analogix_dp_psr_set);
+ if (ret < 0)
+ goto err_cleanup_encoder;
dp->adp = analogix_dp_bind(dev, dp->drm_dev, &dp->plat_data);
if (IS_ERR(dp->adp)) {
- dp->encoder.funcs->destroy(&dp->encoder);
- return PTR_ERR(dp->adp);
+ ret = PTR_ERR(dp->adp);
+ goto err_unreg_psr;
}
return 0;
+err_unreg_psr:
+ rockchip_drm_psr_unregister(&dp->encoder);
+err_cleanup_encoder:
+ dp->encoder.funcs->destroy(&dp->encoder);
+ return ret;
}
static void rockchip_dp_unbind(struct device *dev, struct device *master,
@@ -370,8 +377,8 @@ static void rockchip_dp_unbind(struct device *dev, struct device *master,
{
struct rockchip_dp_device *dp = dev_get_drvdata(dev);
- rockchip_drm_psr_unregister(&dp->encoder);
analogix_dp_unbind(dp->adp);
+ rockchip_drm_psr_unregister(&dp->encoder);
dp->encoder.funcs->destroy(&dp->encoder);
}
--
2.14.1
^ permalink raw reply related [flat|nested] 31+ messages in thread* [PATCH v8 3/8] drm/rockchip: analogix_dp: Add a sanity check for rockchip_drm_psr_register()
@ 2018-01-10 16:23 ` Thierry Escande
0 siblings, 0 replies; 31+ messages in thread
From: Thierry Escande @ 2018-01-10 16:23 UTC (permalink / raw)
To: Rob Herring, Archit Taneja, Daniel Vetter, Neil Armstrong,
Laurent Pinchart, Sandy Huang
Cc: Jeffy Chen, Sean Paul, dri-devel, linux-rockchip, linux-kernel
From: Jeffy Chen <jeffy.chen@rock-chips.com>
The rockchip_drm_psr_register() can fail, so add a sanity check for that.
Also reorder the calls in unbind() to match bind().
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
Signed-off-by: Thierry Escande <thierry.escande@collabora.com>
---
drivers/gpu/drm/rockchip/analogix_dp-rockchip.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
index 37250ab63bd7..eb88c52336a7 100644
--- a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
+++ b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
@@ -354,15 +354,22 @@ static int rockchip_dp_bind(struct device *dev, struct device *master,
dp->psr_state = ~EDP_VSC_PSR_STATE_ACTIVE;
INIT_WORK(&dp->psr_work, analogix_dp_psr_work);
- rockchip_drm_psr_register(&dp->encoder, analogix_dp_psr_set);
+ ret = rockchip_drm_psr_register(&dp->encoder, analogix_dp_psr_set);
+ if (ret < 0)
+ goto err_cleanup_encoder;
dp->adp = analogix_dp_bind(dev, dp->drm_dev, &dp->plat_data);
if (IS_ERR(dp->adp)) {
- dp->encoder.funcs->destroy(&dp->encoder);
- return PTR_ERR(dp->adp);
+ ret = PTR_ERR(dp->adp);
+ goto err_unreg_psr;
}
return 0;
+err_unreg_psr:
+ rockchip_drm_psr_unregister(&dp->encoder);
+err_cleanup_encoder:
+ dp->encoder.funcs->destroy(&dp->encoder);
+ return ret;
}
static void rockchip_dp_unbind(struct device *dev, struct device *master,
@@ -370,8 +377,8 @@ static void rockchip_dp_unbind(struct device *dev, struct device *master,
{
struct rockchip_dp_device *dp = dev_get_drvdata(dev);
- rockchip_drm_psr_unregister(&dp->encoder);
analogix_dp_unbind(dp->adp);
+ rockchip_drm_psr_unregister(&dp->encoder);
dp->encoder.funcs->destroy(&dp->encoder);
}
--
2.14.1
^ permalink raw reply related [flat|nested] 31+ messages in thread* [PATCH] drm/rockchip: analogix_dp: reorder psr_unregister call in unbind
2018-01-10 16:23 ` Thierry Escande
@ 2018-03-01 15:25 ` Heiko Stuebner
-1 siblings, 0 replies; 31+ messages in thread
From: Heiko Stuebner @ 2018-03-01 15:25 UTC (permalink / raw)
To: dri-devel
Cc: Thierry Escande, Neil Armstrong, Jeffy Chen, linux-kernel,
linux-rockchip, Rob Herring, Laurent Pinchart, Daniel Vetter
In bind the psr handler gets registered first before the core
analogix_dp_bind() gets called. So it should be the other way
around in unbind, first unbind the analogix_dp and then
unregister the psr.
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
Signed-off-by: Thierry Escande <thierry.escande@collabora.com>
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
drivers/gpu/drm/rockchip/analogix_dp-rockchip.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
index 37250ab63bd7..eb88c52336a7 100644
--- a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
+++ b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
@@ -370,8 +377,8 @@ static void rockchip_dp_unbind(struct device *dev, struct device *master,
{
struct rockchip_dp_device *dp = dev_get_drvdata(dev);
- rockchip_drm_psr_unregister(&dp->encoder);
analogix_dp_unbind(dp->adp);
+ rockchip_drm_psr_unregister(&dp->encoder);
dp->encoder.funcs->destroy(&dp->encoder);
}
--
2.15.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 31+ messages in thread* [PATCH] drm/rockchip: analogix_dp: reorder psr_unregister call in unbind
@ 2018-03-01 15:25 ` Heiko Stuebner
0 siblings, 0 replies; 31+ messages in thread
From: Heiko Stuebner @ 2018-03-01 15:25 UTC (permalink / raw)
To: dri-devel
Cc: Thierry Escande, Rob Herring, Archit Taneja, Daniel Vetter,
Neil Armstrong, Laurent Pinchart, Sandy Huang, linux-rockchip,
Jeffy Chen, linux-kernel
In bind the psr handler gets registered first before the core
analogix_dp_bind() gets called. So it should be the other way
around in unbind, first unbind the analogix_dp and then
unregister the psr.
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
Signed-off-by: Thierry Escande <thierry.escande@collabora.com>
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
drivers/gpu/drm/rockchip/analogix_dp-rockchip.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
index 37250ab63bd7..eb88c52336a7 100644
--- a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
+++ b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
@@ -370,8 +377,8 @@ static void rockchip_dp_unbind(struct device *dev, struct device *master,
{
struct rockchip_dp_device *dp = dev_get_drvdata(dev);
- rockchip_drm_psr_unregister(&dp->encoder);
analogix_dp_unbind(dp->adp);
+ rockchip_drm_psr_unregister(&dp->encoder);
dp->encoder.funcs->destroy(&dp->encoder);
}
--
2.15.1
^ permalink raw reply related [flat|nested] 31+ messages in thread
* Re: [PATCH v8 3/8] drm/rockchip: analogix_dp: Add a sanity check for rockchip_drm_psr_register()
2018-01-10 16:23 ` Thierry Escande
@ 2018-03-01 15:41 ` Heiko Stübner
-1 siblings, 0 replies; 31+ messages in thread
From: Heiko Stübner @ 2018-03-01 15:41 UTC (permalink / raw)
To: dri-devel
Cc: Thierry Escande, Neil Armstrong, Jeffy Chen, linux-kernel,
linux-rockchip, Rob Herring, Laurent Pinchart, Daniel Vetter
Am Mittwoch, 10. Januar 2018, 17:23:43 CET schrieb Thierry Escande:
> From: Jeffy Chen <jeffy.chen@rock-chips.com>
>
> The rockchip_drm_psr_register() can fail, so add a sanity check for that.
>
> Also reorder the calls in unbind() to match bind().
>
> Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
> Signed-off-by: Thierry Escande <thierry.escande@collabora.com>
applied to drm-misc, after splitting out the reordering into a
separate patch. Having these surprise changes hidden behind
an "also" feels not ideal.
Heiko
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v8 3/8] drm/rockchip: analogix_dp: Add a sanity check for rockchip_drm_psr_register()
@ 2018-03-01 15:41 ` Heiko Stübner
0 siblings, 0 replies; 31+ messages in thread
From: Heiko Stübner @ 2018-03-01 15:41 UTC (permalink / raw)
To: dri-devel
Cc: Thierry Escande, Rob Herring, Archit Taneja, Daniel Vetter,
Neil Armstrong, Laurent Pinchart, Sandy Huang, linux-rockchip,
Jeffy Chen, linux-kernel
Am Mittwoch, 10. Januar 2018, 17:23:43 CET schrieb Thierry Escande:
> From: Jeffy Chen <jeffy.chen@rock-chips.com>
>
> The rockchip_drm_psr_register() can fail, so add a sanity check for that.
>
> Also reorder the calls in unbind() to match bind().
>
> Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
> Signed-off-by: Thierry Escande <thierry.escande@collabora.com>
applied to drm-misc, after splitting out the reordering into a
separate patch. Having these surprise changes hidden behind
an "also" feels not ideal.
Heiko
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v8 4/8] drm/rockchip: dw-mipi-dsi: Fix error handling path
2018-01-10 16:23 [PATCH v8 0/8] rockchip: kevin: Enable edp display Thierry Escande
@ 2018-01-10 16:23 ` Thierry Escande
2018-01-10 16:23 ` [PATCH v8 7/8] drm/bridge/synopsys: dw-hdmi: Do not use device's drvdata Thierry Escande
2018-01-10 16:23 ` [PATCH v8 8/8] drm/rockchip: dw_hdmi: Fix error handling path Thierry Escande
2 siblings, 0 replies; 31+ messages in thread
From: Thierry Escande @ 2018-01-10 16:23 UTC (permalink / raw)
To: Rob Herring, Archit Taneja, Daniel Vetter, Neil Armstrong,
Laurent Pinchart, Sandy Huang
Cc: linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Jeffy Chen,
Sean Paul, linux-kernel-u79uwXL29TY76Z2rM5mHXA,
dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
From: Jeffy Chen <jeffy.chen-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
Add missing pm_runtime_disable() in bind()'s error handling path.
Also cleanup encoder & connector in unbind().
Fixes: 80a9a059d4e4 ("drm/rockchip/dsi: add dw-mipi power domain support")
Signed-off-by: Jeffy Chen <jeffy.chen-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
Signed-off-by: Thierry Escande <thierry.escande-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
---
drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
index b1fe0639227e..78e6b7919bf7 100644
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
+++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
@@ -1282,7 +1282,7 @@ static int dw_mipi_dsi_bind(struct device *dev, struct device *master,
ret = dw_mipi_dsi_register(drm, dsi);
if (ret) {
DRM_DEV_ERROR(dev, "Failed to register mipi_dsi: %d\n", ret);
- goto err_pllref;
+ goto err_disable_pllref;
}
dsi->dsi_host.ops = &dw_mipi_dsi_host_ops;
@@ -1290,24 +1290,25 @@ static int dw_mipi_dsi_bind(struct device *dev, struct device *master,
ret = mipi_dsi_host_register(&dsi->dsi_host);
if (ret) {
DRM_DEV_ERROR(dev, "Failed to register MIPI host: %d\n", ret);
- goto err_cleanup;
+ goto err_disable_pm_runtime;
}
if (!dsi->panel) {
ret = -EPROBE_DEFER;
- goto err_mipi_dsi_host;
+ goto err_unreg_mipi_dsi_host;
}
dev_set_drvdata(dev, dsi);
pm_runtime_enable(dev);
return 0;
-err_mipi_dsi_host:
+err_unreg_mipi_dsi_host:
mipi_dsi_host_unregister(&dsi->dsi_host);
-err_cleanup:
- drm_encoder_cleanup(&dsi->encoder);
- drm_connector_cleanup(&dsi->connector);
-err_pllref:
+err_disable_pm_runtime:
+ pm_runtime_disable(dev);
+ dsi->connector.funcs->destroy(&dsi->connector);
+ dsi->encoder.funcs->destroy(&dsi->encoder);
+err_disable_pllref:
clk_disable_unprepare(dsi->pllref_clk);
return ret;
}
@@ -1319,6 +1320,10 @@ static void dw_mipi_dsi_unbind(struct device *dev, struct device *master,
mipi_dsi_host_unregister(&dsi->dsi_host);
pm_runtime_disable(dev);
+
+ dsi->connector.funcs->destroy(&dsi->connector);
+ dsi->encoder.funcs->destroy(&dsi->encoder);
+
clk_disable_unprepare(dsi->pllref_clk);
}
--
2.14.1
^ permalink raw reply related [flat|nested] 31+ messages in thread* [PATCH v8 4/8] drm/rockchip: dw-mipi-dsi: Fix error handling path
@ 2018-01-10 16:23 ` Thierry Escande
0 siblings, 0 replies; 31+ messages in thread
From: Thierry Escande @ 2018-01-10 16:23 UTC (permalink / raw)
To: Rob Herring, Archit Taneja, Daniel Vetter, Neil Armstrong,
Laurent Pinchart, Sandy Huang
Cc: Jeffy Chen, Sean Paul, dri-devel, linux-rockchip, linux-kernel
From: Jeffy Chen <jeffy.chen@rock-chips.com>
Add missing pm_runtime_disable() in bind()'s error handling path.
Also cleanup encoder & connector in unbind().
Fixes: 80a9a059d4e4 ("drm/rockchip/dsi: add dw-mipi power domain support")
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
Signed-off-by: Thierry Escande <thierry.escande@collabora.com>
---
drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
index b1fe0639227e..78e6b7919bf7 100644
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
+++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
@@ -1282,7 +1282,7 @@ static int dw_mipi_dsi_bind(struct device *dev, struct device *master,
ret = dw_mipi_dsi_register(drm, dsi);
if (ret) {
DRM_DEV_ERROR(dev, "Failed to register mipi_dsi: %d\n", ret);
- goto err_pllref;
+ goto err_disable_pllref;
}
dsi->dsi_host.ops = &dw_mipi_dsi_host_ops;
@@ -1290,24 +1290,25 @@ static int dw_mipi_dsi_bind(struct device *dev, struct device *master,
ret = mipi_dsi_host_register(&dsi->dsi_host);
if (ret) {
DRM_DEV_ERROR(dev, "Failed to register MIPI host: %d\n", ret);
- goto err_cleanup;
+ goto err_disable_pm_runtime;
}
if (!dsi->panel) {
ret = -EPROBE_DEFER;
- goto err_mipi_dsi_host;
+ goto err_unreg_mipi_dsi_host;
}
dev_set_drvdata(dev, dsi);
pm_runtime_enable(dev);
return 0;
-err_mipi_dsi_host:
+err_unreg_mipi_dsi_host:
mipi_dsi_host_unregister(&dsi->dsi_host);
-err_cleanup:
- drm_encoder_cleanup(&dsi->encoder);
- drm_connector_cleanup(&dsi->connector);
-err_pllref:
+err_disable_pm_runtime:
+ pm_runtime_disable(dev);
+ dsi->connector.funcs->destroy(&dsi->connector);
+ dsi->encoder.funcs->destroy(&dsi->encoder);
+err_disable_pllref:
clk_disable_unprepare(dsi->pllref_clk);
return ret;
}
@@ -1319,6 +1320,10 @@ static void dw_mipi_dsi_unbind(struct device *dev, struct device *master,
mipi_dsi_host_unregister(&dsi->dsi_host);
pm_runtime_disable(dev);
+
+ dsi->connector.funcs->destroy(&dsi->connector);
+ dsi->encoder.funcs->destroy(&dsi->encoder);
+
clk_disable_unprepare(dsi->pllref_clk);
}
--
2.14.1
^ permalink raw reply related [flat|nested] 31+ messages in thread* Re: [PATCH v8 4/8] drm/rockchip: dw-mipi-dsi: Fix error handling path
2018-01-10 16:23 ` Thierry Escande
@ 2018-03-01 15:50 ` Heiko Stübner
-1 siblings, 0 replies; 31+ messages in thread
From: Heiko Stübner @ 2018-03-01 15:50 UTC (permalink / raw)
To: dri-devel
Cc: Thierry Escande, Neil Armstrong, Jeffy Chen, linux-kernel,
linux-rockchip, Rob Herring, Laurent Pinchart, enric.balletbo,
Daniel Vetter
Hi Jeffy, Thierry, Enric,
Am Mittwoch, 10. Januar 2018, 17:23:44 CET schrieb Thierry Escande:
> From: Jeffy Chen <jeffy.chen@rock-chips.com>
>
> Add missing pm_runtime_disable() in bind()'s error handling path.
>
> Also cleanup encoder & connector in unbind().
Can you please split all these surprise "Also" sections into separate
patches?
It looks like this is true for all following patch to some degree and
the inno-hdmi patch even has a unbind reordering-change without
mentioning it in the commit message.
Thanks
Heiko
> Fixes: 80a9a059d4e4 ("drm/rockchip/dsi: add dw-mipi power domain support")
> Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
> Signed-off-by: Thierry Escande <thierry.escande@collabora.com>
> ---
> drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 21 +++++++++++++--------
> 1 file changed, 13 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
> b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c index b1fe0639227e..78e6b7919bf7
> 100644
> --- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
> +++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
> @@ -1282,7 +1282,7 @@ static int dw_mipi_dsi_bind(struct device *dev, struct
> device *master, ret = dw_mipi_dsi_register(drm, dsi);
> if (ret) {
> DRM_DEV_ERROR(dev, "Failed to register mipi_dsi: %d\n", ret);
> - goto err_pllref;
> + goto err_disable_pllref;
> }
>
> dsi->dsi_host.ops = &dw_mipi_dsi_host_ops;
> @@ -1290,24 +1290,25 @@ static int dw_mipi_dsi_bind(struct device *dev,
> struct device *master, ret = mipi_dsi_host_register(&dsi->dsi_host);
> if (ret) {
> DRM_DEV_ERROR(dev, "Failed to register MIPI host: %d\n", ret);
> - goto err_cleanup;
> + goto err_disable_pm_runtime;
> }
>
> if (!dsi->panel) {
> ret = -EPROBE_DEFER;
> - goto err_mipi_dsi_host;
> + goto err_unreg_mipi_dsi_host;
> }
>
> dev_set_drvdata(dev, dsi);
> pm_runtime_enable(dev);
> return 0;
>
> -err_mipi_dsi_host:
> +err_unreg_mipi_dsi_host:
> mipi_dsi_host_unregister(&dsi->dsi_host);
> -err_cleanup:
> - drm_encoder_cleanup(&dsi->encoder);
> - drm_connector_cleanup(&dsi->connector);
> -err_pllref:
> +err_disable_pm_runtime:
> + pm_runtime_disable(dev);
> + dsi->connector.funcs->destroy(&dsi->connector);
> + dsi->encoder.funcs->destroy(&dsi->encoder);
> +err_disable_pllref:
> clk_disable_unprepare(dsi->pllref_clk);
> return ret;
> }
> @@ -1319,6 +1320,10 @@ static void dw_mipi_dsi_unbind(struct device *dev,
> struct device *master,
>
> mipi_dsi_host_unregister(&dsi->dsi_host);
> pm_runtime_disable(dev);
> +
> + dsi->connector.funcs->destroy(&dsi->connector);
> + dsi->encoder.funcs->destroy(&dsi->encoder);
> +
> clk_disable_unprepare(dsi->pllref_clk);
> }
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 31+ messages in thread* Re: [PATCH v8 4/8] drm/rockchip: dw-mipi-dsi: Fix error handling path
@ 2018-03-01 15:50 ` Heiko Stübner
0 siblings, 0 replies; 31+ messages in thread
From: Heiko Stübner @ 2018-03-01 15:50 UTC (permalink / raw)
To: dri-devel
Cc: Thierry Escande, Rob Herring, Archit Taneja, Daniel Vetter,
Neil Armstrong, Laurent Pinchart, Sandy Huang, linux-rockchip,
Jeffy Chen, linux-kernel, enric.balletbo
Hi Jeffy, Thierry, Enric,
Am Mittwoch, 10. Januar 2018, 17:23:44 CET schrieb Thierry Escande:
> From: Jeffy Chen <jeffy.chen@rock-chips.com>
>
> Add missing pm_runtime_disable() in bind()'s error handling path.
>
> Also cleanup encoder & connector in unbind().
Can you please split all these surprise "Also" sections into separate
patches?
It looks like this is true for all following patch to some degree and
the inno-hdmi patch even has a unbind reordering-change without
mentioning it in the commit message.
Thanks
Heiko
> Fixes: 80a9a059d4e4 ("drm/rockchip/dsi: add dw-mipi power domain support")
> Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
> Signed-off-by: Thierry Escande <thierry.escande@collabora.com>
> ---
> drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 21 +++++++++++++--------
> 1 file changed, 13 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
> b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c index b1fe0639227e..78e6b7919bf7
> 100644
> --- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
> +++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
> @@ -1282,7 +1282,7 @@ static int dw_mipi_dsi_bind(struct device *dev, struct
> device *master, ret = dw_mipi_dsi_register(drm, dsi);
> if (ret) {
> DRM_DEV_ERROR(dev, "Failed to register mipi_dsi: %d\n", ret);
> - goto err_pllref;
> + goto err_disable_pllref;
> }
>
> dsi->dsi_host.ops = &dw_mipi_dsi_host_ops;
> @@ -1290,24 +1290,25 @@ static int dw_mipi_dsi_bind(struct device *dev,
> struct device *master, ret = mipi_dsi_host_register(&dsi->dsi_host);
> if (ret) {
> DRM_DEV_ERROR(dev, "Failed to register MIPI host: %d\n", ret);
> - goto err_cleanup;
> + goto err_disable_pm_runtime;
> }
>
> if (!dsi->panel) {
> ret = -EPROBE_DEFER;
> - goto err_mipi_dsi_host;
> + goto err_unreg_mipi_dsi_host;
> }
>
> dev_set_drvdata(dev, dsi);
> pm_runtime_enable(dev);
> return 0;
>
> -err_mipi_dsi_host:
> +err_unreg_mipi_dsi_host:
> mipi_dsi_host_unregister(&dsi->dsi_host);
> -err_cleanup:
> - drm_encoder_cleanup(&dsi->encoder);
> - drm_connector_cleanup(&dsi->connector);
> -err_pllref:
> +err_disable_pm_runtime:
> + pm_runtime_disable(dev);
> + dsi->connector.funcs->destroy(&dsi->connector);
> + dsi->encoder.funcs->destroy(&dsi->encoder);
> +err_disable_pllref:
> clk_disable_unprepare(dsi->pllref_clk);
> return ret;
> }
> @@ -1319,6 +1320,10 @@ static void dw_mipi_dsi_unbind(struct device *dev,
> struct device *master,
>
> mipi_dsi_host_unregister(&dsi->dsi_host);
> pm_runtime_disable(dev);
> +
> + dsi->connector.funcs->destroy(&dsi->connector);
> + dsi->encoder.funcs->destroy(&dsi->encoder);
> +
> clk_disable_unprepare(dsi->pllref_clk);
> }
^ permalink raw reply [flat|nested] 31+ messages in thread* Re: [PATCH v8 4/8] drm/rockchip: dw-mipi-dsi: Fix error handling path
2018-03-01 15:50 ` Heiko Stübner
(?)
@ 2018-03-02 12:09 ` Enric Balletbo i Serra
2018-03-02 12:17 ` Heiko Stuebner
-1 siblings, 1 reply; 31+ messages in thread
From: Enric Balletbo i Serra @ 2018-03-02 12:09 UTC (permalink / raw)
To: Heiko Stübner, dri-devel
Cc: Rob Herring, Archit Taneja, Daniel Vetter, Neil Armstrong,
Laurent Pinchart, Sandy Huang, linux-rockchip, Jeffy Chen,
linux-kernel
Hi Heiko,
On 01/03/18 16:50, Heiko Stübner wrote:
> Hi Jeffy, Thierry, Enric,
>
> Am Mittwoch, 10. Januar 2018, 17:23:44 CET schrieb Thierry Escande:
>> From: Jeffy Chen <jeffy.chen@rock-chips.com>
>>
>> Add missing pm_runtime_disable() in bind()'s error handling path.
>>
>> Also cleanup encoder & connector in unbind().
>
> Can you please split all these surprise "Also" sections into separate
> patches?
>
I'll take a look.
> It looks like this is true for all following patch to some degree and
> the inno-hdmi patch even has a unbind reordering-change without
> mentioning it in the commit message.
>
Actually, I think this patch is not correct against current mainline, see below.
>
> Thanks
> Heiko
>
>> Fixes: 80a9a059d4e4 ("drm/rockchip/dsi: add dw-mipi power domain support")
>> Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
>> Signed-off-by: Thierry Escande <thierry.escande@collabora.com>
>> ---
>> drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 21 +++++++++++++--------
>> 1 file changed, 13 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
>> b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c index b1fe0639227e..78e6b7919bf7
>> 100644
>> --- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
>> +++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
>> @@ -1282,7 +1282,7 @@ static int dw_mipi_dsi_bind(struct device *dev, struct
>> device *master, ret = dw_mipi_dsi_register(drm, dsi);
>> if (ret) {
>> DRM_DEV_ERROR(dev, "Failed to register mipi_dsi: %d\n", ret);
>> - goto err_pllref;
>> + goto err_disable_pllref;
>> }
>>
>> dsi->dsi_host.ops = &dw_mipi_dsi_host_ops;
>> @@ -1290,24 +1290,25 @@ static int dw_mipi_dsi_bind(struct device *dev,
>> struct device *master, ret = mipi_dsi_host_register(&dsi->dsi_host);
>> if (ret) {
>> DRM_DEV_ERROR(dev, "Failed to register MIPI host: %d\n", ret);
>> - goto err_cleanup;
>> + goto err_disable_pm_runtime;
>> }
>>
>> if (!dsi->panel) {
>> ret = -EPROBE_DEFER;
>> - goto err_mipi_dsi_host;
>> + goto err_unreg_mipi_dsi_host;
>> }
>>
>> dev_set_drvdata(dev, dsi);
>> pm_runtime_enable(dev);
>> return 0;
>>
>> -err_mipi_dsi_host:
>> +err_unreg_mipi_dsi_host:
>> mipi_dsi_host_unregister(&dsi->dsi_host);
>> -err_cleanup:
>> - drm_encoder_cleanup(&dsi->encoder);
>> - drm_connector_cleanup(&dsi->connector);
>> -err_pllref:
>> +err_disable_pm_runtime:
>> + pm_runtime_disable(dev);
I think that this is not required, 'pm_runtime_enable' is called just before the
'return 0' (see above). Commit 517f56839f58 'drm/rockchip: dw-mipi-dsi: fix
possible un-balanced runtime PM enable' moved the call to that place. So, now
the call to pm_runtime_disable is not needed.
>> + dsi->connector.funcs->destroy(&dsi->connector);
>> + dsi->encoder.funcs->destroy(&dsi->encoder);
Here, there is a reordering and also a function replacement. The reorder makes
sense to me, first cleanup the connector and then the encoder, but I'm not sure
about the function change and if is needed, anyway, in the case is needed,
shouldn't be
+ drm_connector_cleanup(&dsi->connector);
+ drm_encoder_cleanup(&dsi->encoder);
instead?
>> +err_disable_pllref:
>> clk_disable_unprepare(dsi->pllref_clk);
>> return ret;
>> }
>> @@ -1319,6 +1320,10 @@ static void dw_mipi_dsi_unbind(struct device *dev,
>> struct device *master,
>>
>> mipi_dsi_host_unregister(&dsi->dsi_host);
>> pm_runtime_disable(dev);
>> +
>> + dsi->connector.funcs->destroy(&dsi->connector);
>> + dsi->encoder.funcs->destroy(&dsi->encoder);
>> +
Same here.
>> clk_disable_unprepare(dsi->pllref_clk);
>> }
>
>
Best regards,
Enric
^ permalink raw reply [flat|nested] 31+ messages in thread* Re: [PATCH v8 4/8] drm/rockchip: dw-mipi-dsi: Fix error handling path
2018-03-02 12:09 ` Enric Balletbo i Serra
@ 2018-03-02 12:17 ` Heiko Stuebner
0 siblings, 0 replies; 31+ messages in thread
From: Heiko Stuebner @ 2018-03-02 12:17 UTC (permalink / raw)
To: Enric Balletbo i Serra
Cc: Neil Armstrong, Jeffy Chen, dri-devel, linux-kernel,
linux-rockchip, Rob Herring, Laurent Pinchart, Daniel Vetter
Hi Enric,
Am Freitag, 2. März 2018, 13:09:02 CET schrieb Enric Balletbo i Serra:
> Hi Heiko,
>
> On 01/03/18 16:50, Heiko Stübner wrote:
> > Hi Jeffy, Thierry, Enric,
> >
> > Am Mittwoch, 10. Januar 2018, 17:23:44 CET schrieb Thierry Escande:
> >> From: Jeffy Chen <jeffy.chen@rock-chips.com>
> >>
> >> Add missing pm_runtime_disable() in bind()'s error handling path.
> >>
> >> Also cleanup encoder & connector in unbind().
> >
> > Can you please split all these surprise "Also" sections into separate
> > patches?
> >
>
> I'll take a look.
>
> > It looks like this is true for all following patch to some degree and
> > the inno-hdmi patch even has a unbind reordering-change without
> > mentioning it in the commit message.
> >
>
> Actually, I think this patch is not correct against current mainline, see below.
>
> >
> > Thanks
> > Heiko
> >
> >> Fixes: 80a9a059d4e4 ("drm/rockchip/dsi: add dw-mipi power domain support")
> >> Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
> >> Signed-off-by: Thierry Escande <thierry.escande@collabora.com>
> >> ---
> >> drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 21 +++++++++++++--------
> >> 1 file changed, 13 insertions(+), 8 deletions(-)
> >>
> >> diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
> >> b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c index b1fe0639227e..78e6b7919bf7
> >> 100644
> >> --- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
> >> +++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
> >> @@ -1282,7 +1282,7 @@ static int dw_mipi_dsi_bind(struct device *dev, struct
> >> device *master, ret = dw_mipi_dsi_register(drm, dsi);
> >> if (ret) {
> >> DRM_DEV_ERROR(dev, "Failed to register mipi_dsi: %d\n", ret);
> >> - goto err_pllref;
> >> + goto err_disable_pllref;
> >> }
> >>
> >> dsi->dsi_host.ops = &dw_mipi_dsi_host_ops;
> >> @@ -1290,24 +1290,25 @@ static int dw_mipi_dsi_bind(struct device *dev,
> >> struct device *master, ret = mipi_dsi_host_register(&dsi->dsi_host);
> >> if (ret) {
> >> DRM_DEV_ERROR(dev, "Failed to register MIPI host: %d\n", ret);
> >> - goto err_cleanup;
> >> + goto err_disable_pm_runtime;
> >> }
> >>
> >> if (!dsi->panel) {
> >> ret = -EPROBE_DEFER;
> >> - goto err_mipi_dsi_host;
> >> + goto err_unreg_mipi_dsi_host;
> >> }
> >>
> >> dev_set_drvdata(dev, dsi);
> >> pm_runtime_enable(dev);
> >> return 0;
> >>
> >> -err_mipi_dsi_host:
> >> +err_unreg_mipi_dsi_host:
> >> mipi_dsi_host_unregister(&dsi->dsi_host);
> >> -err_cleanup:
> >> - drm_encoder_cleanup(&dsi->encoder);
> >> - drm_connector_cleanup(&dsi->connector);
> >> -err_pllref:
> >> +err_disable_pm_runtime:
> >> + pm_runtime_disable(dev);
>
> I think that this is not required, 'pm_runtime_enable' is called just before the
> 'return 0' (see above). Commit 517f56839f58 'drm/rockchip: dw-mipi-dsi: fix
> possible un-balanced runtime PM enable' moved the call to that place. So, now
> the call to pm_runtime_disable is not needed.
>
> >> + dsi->connector.funcs->destroy(&dsi->connector);
> >> + dsi->encoder.funcs->destroy(&dsi->encoder);
>
> Here, there is a reordering and also a function replacement. The reorder makes
> sense to me, first cleanup the connector and then the encoder, but I'm not sure
> about the function change and if is needed, anyway, in the case is needed,
> shouldn't be
>
> + drm_connector_cleanup(&dsi->connector);
> + drm_encoder_cleanup(&dsi->encoder);
>
> instead?
If you look at drm/rockchip/dw-mipi-dsi.c you'll see that
dw_mipi_dsi_drm_connector_destroy() does both connector_unregister()
and drm_connector_cleanup().
And looking at other drivers it really seems that calling that destroy
callback is really the way to go.
Heiko
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 31+ messages in thread* Re: [PATCH v8 4/8] drm/rockchip: dw-mipi-dsi: Fix error handling path
@ 2018-03-02 12:17 ` Heiko Stuebner
0 siblings, 0 replies; 31+ messages in thread
From: Heiko Stuebner @ 2018-03-02 12:17 UTC (permalink / raw)
To: Enric Balletbo i Serra
Cc: dri-devel, Rob Herring, Archit Taneja, Daniel Vetter,
Neil Armstrong, Laurent Pinchart, Sandy Huang, linux-rockchip,
Jeffy Chen, linux-kernel
Hi Enric,
Am Freitag, 2. März 2018, 13:09:02 CET schrieb Enric Balletbo i Serra:
> Hi Heiko,
>
> On 01/03/18 16:50, Heiko Stübner wrote:
> > Hi Jeffy, Thierry, Enric,
> >
> > Am Mittwoch, 10. Januar 2018, 17:23:44 CET schrieb Thierry Escande:
> >> From: Jeffy Chen <jeffy.chen@rock-chips.com>
> >>
> >> Add missing pm_runtime_disable() in bind()'s error handling path.
> >>
> >> Also cleanup encoder & connector in unbind().
> >
> > Can you please split all these surprise "Also" sections into separate
> > patches?
> >
>
> I'll take a look.
>
> > It looks like this is true for all following patch to some degree and
> > the inno-hdmi patch even has a unbind reordering-change without
> > mentioning it in the commit message.
> >
>
> Actually, I think this patch is not correct against current mainline, see below.
>
> >
> > Thanks
> > Heiko
> >
> >> Fixes: 80a9a059d4e4 ("drm/rockchip/dsi: add dw-mipi power domain support")
> >> Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
> >> Signed-off-by: Thierry Escande <thierry.escande@collabora.com>
> >> ---
> >> drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 21 +++++++++++++--------
> >> 1 file changed, 13 insertions(+), 8 deletions(-)
> >>
> >> diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
> >> b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c index b1fe0639227e..78e6b7919bf7
> >> 100644
> >> --- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
> >> +++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
> >> @@ -1282,7 +1282,7 @@ static int dw_mipi_dsi_bind(struct device *dev, struct
> >> device *master, ret = dw_mipi_dsi_register(drm, dsi);
> >> if (ret) {
> >> DRM_DEV_ERROR(dev, "Failed to register mipi_dsi: %d\n", ret);
> >> - goto err_pllref;
> >> + goto err_disable_pllref;
> >> }
> >>
> >> dsi->dsi_host.ops = &dw_mipi_dsi_host_ops;
> >> @@ -1290,24 +1290,25 @@ static int dw_mipi_dsi_bind(struct device *dev,
> >> struct device *master, ret = mipi_dsi_host_register(&dsi->dsi_host);
> >> if (ret) {
> >> DRM_DEV_ERROR(dev, "Failed to register MIPI host: %d\n", ret);
> >> - goto err_cleanup;
> >> + goto err_disable_pm_runtime;
> >> }
> >>
> >> if (!dsi->panel) {
> >> ret = -EPROBE_DEFER;
> >> - goto err_mipi_dsi_host;
> >> + goto err_unreg_mipi_dsi_host;
> >> }
> >>
> >> dev_set_drvdata(dev, dsi);
> >> pm_runtime_enable(dev);
> >> return 0;
> >>
> >> -err_mipi_dsi_host:
> >> +err_unreg_mipi_dsi_host:
> >> mipi_dsi_host_unregister(&dsi->dsi_host);
> >> -err_cleanup:
> >> - drm_encoder_cleanup(&dsi->encoder);
> >> - drm_connector_cleanup(&dsi->connector);
> >> -err_pllref:
> >> +err_disable_pm_runtime:
> >> + pm_runtime_disable(dev);
>
> I think that this is not required, 'pm_runtime_enable' is called just before the
> 'return 0' (see above). Commit 517f56839f58 'drm/rockchip: dw-mipi-dsi: fix
> possible un-balanced runtime PM enable' moved the call to that place. So, now
> the call to pm_runtime_disable is not needed.
>
> >> + dsi->connector.funcs->destroy(&dsi->connector);
> >> + dsi->encoder.funcs->destroy(&dsi->encoder);
>
> Here, there is a reordering and also a function replacement. The reorder makes
> sense to me, first cleanup the connector and then the encoder, but I'm not sure
> about the function change and if is needed, anyway, in the case is needed,
> shouldn't be
>
> + drm_connector_cleanup(&dsi->connector);
> + drm_encoder_cleanup(&dsi->encoder);
>
> instead?
If you look at drm/rockchip/dw-mipi-dsi.c you'll see that
dw_mipi_dsi_drm_connector_destroy() does both connector_unregister()
and drm_connector_cleanup().
And looking at other drivers it really seems that calling that destroy
callback is really the way to go.
Heiko
^ permalink raw reply [flat|nested] 31+ messages in thread* Re: [PATCH v8 4/8] drm/rockchip: dw-mipi-dsi: Fix error handling path
2018-03-02 12:17 ` Heiko Stuebner
(?)
@ 2018-03-02 12:22 ` Enric Balletbo i Serra
-1 siblings, 0 replies; 31+ messages in thread
From: Enric Balletbo i Serra @ 2018-03-02 12:22 UTC (permalink / raw)
To: Heiko Stuebner
Cc: dri-devel, Rob Herring, Archit Taneja, Daniel Vetter,
Neil Armstrong, Laurent Pinchart, Sandy Huang, linux-rockchip,
Jeffy Chen, linux-kernel
Hi Heiko,
On 02/03/18 13:17, Heiko Stuebner wrote:
> Hi Enric,
>
> Am Freitag, 2. März 2018, 13:09:02 CET schrieb Enric Balletbo i Serra:
>> Hi Heiko,
>>
>> On 01/03/18 16:50, Heiko Stübner wrote:
>>> Hi Jeffy, Thierry, Enric,
>>>
>>> Am Mittwoch, 10. Januar 2018, 17:23:44 CET schrieb Thierry Escande:
>>>> From: Jeffy Chen <jeffy.chen@rock-chips.com>
>>>>
>>>> Add missing pm_runtime_disable() in bind()'s error handling path.
>>>>
>>>> Also cleanup encoder & connector in unbind().
>>>
>>> Can you please split all these surprise "Also" sections into separate
>>> patches?
>>>
>>
>> I'll take a look.
>>
>>> It looks like this is true for all following patch to some degree and
>>> the inno-hdmi patch even has a unbind reordering-change without
>>> mentioning it in the commit message.
>>>
>>
>> Actually, I think this patch is not correct against current mainline, see below.
>>
>>>
>>> Thanks
>>> Heiko
>>>
>>>> Fixes: 80a9a059d4e4 ("drm/rockchip/dsi: add dw-mipi power domain support")
>>>> Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
>>>> Signed-off-by: Thierry Escande <thierry.escande@collabora.com>
>>>> ---
>>>> drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 21 +++++++++++++--------
>>>> 1 file changed, 13 insertions(+), 8 deletions(-)
>>>>
>>>> diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
>>>> b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c index b1fe0639227e..78e6b7919bf7
>>>> 100644
>>>> --- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
>>>> +++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
>>>> @@ -1282,7 +1282,7 @@ static int dw_mipi_dsi_bind(struct device *dev, struct
>>>> device *master, ret = dw_mipi_dsi_register(drm, dsi);
>>>> if (ret) {
>>>> DRM_DEV_ERROR(dev, "Failed to register mipi_dsi: %d\n", ret);
>>>> - goto err_pllref;
>>>> + goto err_disable_pllref;
>>>> }
>>>>
>>>> dsi->dsi_host.ops = &dw_mipi_dsi_host_ops;
>>>> @@ -1290,24 +1290,25 @@ static int dw_mipi_dsi_bind(struct device *dev,
>>>> struct device *master, ret = mipi_dsi_host_register(&dsi->dsi_host);
>>>> if (ret) {
>>>> DRM_DEV_ERROR(dev, "Failed to register MIPI host: %d\n", ret);
>>>> - goto err_cleanup;
>>>> + goto err_disable_pm_runtime;
>>>> }
>>>>
>>>> if (!dsi->panel) {
>>>> ret = -EPROBE_DEFER;
>>>> - goto err_mipi_dsi_host;
>>>> + goto err_unreg_mipi_dsi_host;
>>>> }
>>>>
>>>> dev_set_drvdata(dev, dsi);
>>>> pm_runtime_enable(dev);
>>>> return 0;
>>>>
>>>> -err_mipi_dsi_host:
>>>> +err_unreg_mipi_dsi_host:
>>>> mipi_dsi_host_unregister(&dsi->dsi_host);
>>>> -err_cleanup:
>>>> - drm_encoder_cleanup(&dsi->encoder);
>>>> - drm_connector_cleanup(&dsi->connector);
>>>> -err_pllref:
>>>> +err_disable_pm_runtime:
>>>> + pm_runtime_disable(dev);
>>
>> I think that this is not required, 'pm_runtime_enable' is called just before the
>> 'return 0' (see above). Commit 517f56839f58 'drm/rockchip: dw-mipi-dsi: fix
>> possible un-balanced runtime PM enable' moved the call to that place. So, now
>> the call to pm_runtime_disable is not needed.
>>
>>>> + dsi->connector.funcs->destroy(&dsi->connector);
>>>> + dsi->encoder.funcs->destroy(&dsi->encoder);
>>
>> Here, there is a reordering and also a function replacement. The reorder makes
>> sense to me, first cleanup the connector and then the encoder, but I'm not sure
>> about the function change and if is needed, anyway, in the case is needed,
>> shouldn't be
>>
>> + drm_connector_cleanup(&dsi->connector);
>> + drm_encoder_cleanup(&dsi->encoder);
>>
>> instead?
>
> If you look at drm/rockchip/dw-mipi-dsi.c you'll see that
> dw_mipi_dsi_drm_connector_destroy() does both connector_unregister()
> and drm_connector_cleanup().
>
> And looking at other drivers it really seems that calling that destroy
> callback is really the way to go.
>
Right, thanks for pointing me in the right direction. Learning about this
graphics stuff ;)
Regards,
Enric
>
> Heiko
>
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v8 5/8] drm/rockchip: inno_hdmi: Fix error handling path
2018-01-10 16:23 [PATCH v8 0/8] rockchip: kevin: Enable edp display Thierry Escande
@ 2018-01-10 16:23 ` Thierry Escande
2018-01-10 16:23 ` [PATCH v8 7/8] drm/bridge/synopsys: dw-hdmi: Do not use device's drvdata Thierry Escande
2018-01-10 16:23 ` [PATCH v8 8/8] drm/rockchip: dw_hdmi: Fix error handling path Thierry Escande
2 siblings, 0 replies; 31+ messages in thread
From: Thierry Escande @ 2018-01-10 16:23 UTC (permalink / raw)
To: Rob Herring, Archit Taneja, Daniel Vetter, Neil Armstrong,
Laurent Pinchart, Sandy Huang
Cc: linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Jeffy Chen,
Sean Paul, linux-kernel-u79uwXL29TY76Z2rM5mHXA,
dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
From: Jeffy Chen <jeffy.chen-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
Add missing error handling in bind().
Fixes: 412d4ae6b7a5 ("drm/rockchip: hdmi: add Innosilicon HDMI support")
Signed-off-by: Jeffy Chen <jeffy.chen-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
Signed-off-by: Thierry Escande <thierry.escande-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
---
drivers/gpu/drm/rockchip/inno_hdmi.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/rockchip/inno_hdmi.c b/drivers/gpu/drm/rockchip/inno_hdmi.c
index fab30927a889..b775283d7363 100644
--- a/drivers/gpu/drm/rockchip/inno_hdmi.c
+++ b/drivers/gpu/drm/rockchip/inno_hdmi.c
@@ -852,8 +852,10 @@ static int inno_hdmi_bind(struct device *dev, struct device *master,
}
irq = platform_get_irq(pdev, 0);
- if (irq < 0)
- return irq;
+ if (irq < 0) {
+ ret = irq;
+ goto err_disable_clk;
+ }
inno_hdmi_reset(hdmi);
@@ -861,7 +863,7 @@ static int inno_hdmi_bind(struct device *dev, struct device *master,
if (IS_ERR(hdmi->ddc)) {
ret = PTR_ERR(hdmi->ddc);
hdmi->ddc = NULL;
- return ret;
+ goto err_disable_clk;
}
/*
@@ -875,7 +877,7 @@ static int inno_hdmi_bind(struct device *dev, struct device *master,
ret = inno_hdmi_register(drm, hdmi);
if (ret)
- return ret;
+ goto err_put_adapter;
dev_set_drvdata(dev, hdmi);
@@ -885,7 +887,17 @@ static int inno_hdmi_bind(struct device *dev, struct device *master,
ret = devm_request_threaded_irq(dev, irq, inno_hdmi_hardirq,
inno_hdmi_irq, IRQF_SHARED,
dev_name(dev), hdmi);
+ if (ret < 0)
+ goto err_cleanup_hdmi;
+ return 0;
+err_cleanup_hdmi:
+ hdmi->connector.funcs->destroy(&hdmi->connector);
+ hdmi->encoder.funcs->destroy(&hdmi->encoder);
+err_put_adapter:
+ i2c_put_adapter(hdmi->ddc);
+err_disable_clk:
+ clk_disable_unprepare(hdmi->pclk);
return ret;
}
@@ -897,8 +909,8 @@ static void inno_hdmi_unbind(struct device *dev, struct device *master,
hdmi->connector.funcs->destroy(&hdmi->connector);
hdmi->encoder.funcs->destroy(&hdmi->encoder);
- clk_disable_unprepare(hdmi->pclk);
i2c_put_adapter(hdmi->ddc);
+ clk_disable_unprepare(hdmi->pclk);
}
static const struct component_ops inno_hdmi_ops = {
--
2.14.1
^ permalink raw reply related [flat|nested] 31+ messages in thread* [PATCH v8 5/8] drm/rockchip: inno_hdmi: Fix error handling path
@ 2018-01-10 16:23 ` Thierry Escande
0 siblings, 0 replies; 31+ messages in thread
From: Thierry Escande @ 2018-01-10 16:23 UTC (permalink / raw)
To: Rob Herring, Archit Taneja, Daniel Vetter, Neil Armstrong,
Laurent Pinchart, Sandy Huang
Cc: Jeffy Chen, Sean Paul, dri-devel, linux-rockchip, linux-kernel
From: Jeffy Chen <jeffy.chen@rock-chips.com>
Add missing error handling in bind().
Fixes: 412d4ae6b7a5 ("drm/rockchip: hdmi: add Innosilicon HDMI support")
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
Signed-off-by: Thierry Escande <thierry.escande@collabora.com>
---
drivers/gpu/drm/rockchip/inno_hdmi.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/rockchip/inno_hdmi.c b/drivers/gpu/drm/rockchip/inno_hdmi.c
index fab30927a889..b775283d7363 100644
--- a/drivers/gpu/drm/rockchip/inno_hdmi.c
+++ b/drivers/gpu/drm/rockchip/inno_hdmi.c
@@ -852,8 +852,10 @@ static int inno_hdmi_bind(struct device *dev, struct device *master,
}
irq = platform_get_irq(pdev, 0);
- if (irq < 0)
- return irq;
+ if (irq < 0) {
+ ret = irq;
+ goto err_disable_clk;
+ }
inno_hdmi_reset(hdmi);
@@ -861,7 +863,7 @@ static int inno_hdmi_bind(struct device *dev, struct device *master,
if (IS_ERR(hdmi->ddc)) {
ret = PTR_ERR(hdmi->ddc);
hdmi->ddc = NULL;
- return ret;
+ goto err_disable_clk;
}
/*
@@ -875,7 +877,7 @@ static int inno_hdmi_bind(struct device *dev, struct device *master,
ret = inno_hdmi_register(drm, hdmi);
if (ret)
- return ret;
+ goto err_put_adapter;
dev_set_drvdata(dev, hdmi);
@@ -885,7 +887,17 @@ static int inno_hdmi_bind(struct device *dev, struct device *master,
ret = devm_request_threaded_irq(dev, irq, inno_hdmi_hardirq,
inno_hdmi_irq, IRQF_SHARED,
dev_name(dev), hdmi);
+ if (ret < 0)
+ goto err_cleanup_hdmi;
+ return 0;
+err_cleanup_hdmi:
+ hdmi->connector.funcs->destroy(&hdmi->connector);
+ hdmi->encoder.funcs->destroy(&hdmi->encoder);
+err_put_adapter:
+ i2c_put_adapter(hdmi->ddc);
+err_disable_clk:
+ clk_disable_unprepare(hdmi->pclk);
return ret;
}
@@ -897,8 +909,8 @@ static void inno_hdmi_unbind(struct device *dev, struct device *master,
hdmi->connector.funcs->destroy(&hdmi->connector);
hdmi->encoder.funcs->destroy(&hdmi->encoder);
- clk_disable_unprepare(hdmi->pclk);
i2c_put_adapter(hdmi->ddc);
+ clk_disable_unprepare(hdmi->pclk);
}
static const struct component_ops inno_hdmi_ops = {
--
2.14.1
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH v8 6/8] drm/bridge/synopsys: dw-hdmi: Add missing bridge detach
2018-01-10 16:23 [PATCH v8 0/8] rockchip: kevin: Enable edp display Thierry Escande
@ 2018-01-10 16:23 ` Thierry Escande
2018-01-10 16:23 ` [PATCH v8 7/8] drm/bridge/synopsys: dw-hdmi: Do not use device's drvdata Thierry Escande
2018-01-10 16:23 ` [PATCH v8 8/8] drm/rockchip: dw_hdmi: Fix error handling path Thierry Escande
2 siblings, 0 replies; 31+ messages in thread
From: Thierry Escande @ 2018-01-10 16:23 UTC (permalink / raw)
To: Rob Herring, Archit Taneja, Daniel Vetter, Neil Armstrong,
Laurent Pinchart, Sandy Huang
Cc: linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Jeffy Chen,
Sean Paul, linux-kernel-u79uwXL29TY76Z2rM5mHXA,
dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
From: Jeffy Chen <jeffy.chen-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
We inited connector in attach(), so need a detach() to cleanup.
Also fix wrong use of dw_hdmi_remove() in bind().
Signed-off-by: Jeffy Chen <jeffy.chen-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
Signed-off-by: Thierry Escande <thierry.escande-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
---
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
index a38db40ce990..1cc63a18b7d5 100644
--- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
+++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
@@ -1967,6 +1967,13 @@ static int dw_hdmi_bridge_attach(struct drm_bridge *bridge)
return 0;
}
+static void dw_hdmi_bridge_detach(struct drm_bridge *bridge)
+{
+ struct dw_hdmi *hdmi = bridge->driver_private;
+
+ drm_connector_cleanup(&hdmi->connector);
+}
+
static enum drm_mode_status
dw_hdmi_bridge_mode_valid(struct drm_bridge *bridge,
const struct drm_display_mode *mode)
@@ -2023,6 +2030,7 @@ static void dw_hdmi_bridge_enable(struct drm_bridge *bridge)
static const struct drm_bridge_funcs dw_hdmi_bridge_funcs = {
.attach = dw_hdmi_bridge_attach,
+ .detach = dw_hdmi_bridge_detach,
.enable = dw_hdmi_bridge_enable,
.disable = dw_hdmi_bridge_disable,
.mode_set = dw_hdmi_bridge_mode_set,
@@ -2616,7 +2624,7 @@ int dw_hdmi_bind(struct platform_device *pdev, struct drm_encoder *encoder,
ret = drm_bridge_attach(encoder, &hdmi->bridge, NULL);
if (ret) {
- dw_hdmi_remove(pdev);
+ __dw_hdmi_remove(hdmi);
DRM_ERROR("Failed to initialize bridge with drm\n");
return ret;
}
--
2.14.1
^ permalink raw reply related [flat|nested] 31+ messages in thread* [PATCH v8 6/8] drm/bridge/synopsys: dw-hdmi: Add missing bridge detach
@ 2018-01-10 16:23 ` Thierry Escande
0 siblings, 0 replies; 31+ messages in thread
From: Thierry Escande @ 2018-01-10 16:23 UTC (permalink / raw)
To: Rob Herring, Archit Taneja, Daniel Vetter, Neil Armstrong,
Laurent Pinchart, Sandy Huang
Cc: Jeffy Chen, Sean Paul, dri-devel, linux-rockchip, linux-kernel
From: Jeffy Chen <jeffy.chen@rock-chips.com>
We inited connector in attach(), so need a detach() to cleanup.
Also fix wrong use of dw_hdmi_remove() in bind().
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
Signed-off-by: Thierry Escande <thierry.escande@collabora.com>
---
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
index a38db40ce990..1cc63a18b7d5 100644
--- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
+++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
@@ -1967,6 +1967,13 @@ static int dw_hdmi_bridge_attach(struct drm_bridge *bridge)
return 0;
}
+static void dw_hdmi_bridge_detach(struct drm_bridge *bridge)
+{
+ struct dw_hdmi *hdmi = bridge->driver_private;
+
+ drm_connector_cleanup(&hdmi->connector);
+}
+
static enum drm_mode_status
dw_hdmi_bridge_mode_valid(struct drm_bridge *bridge,
const struct drm_display_mode *mode)
@@ -2023,6 +2030,7 @@ static void dw_hdmi_bridge_enable(struct drm_bridge *bridge)
static const struct drm_bridge_funcs dw_hdmi_bridge_funcs = {
.attach = dw_hdmi_bridge_attach,
+ .detach = dw_hdmi_bridge_detach,
.enable = dw_hdmi_bridge_enable,
.disable = dw_hdmi_bridge_disable,
.mode_set = dw_hdmi_bridge_mode_set,
@@ -2616,7 +2624,7 @@ int dw_hdmi_bind(struct platform_device *pdev, struct drm_encoder *encoder,
ret = drm_bridge_attach(encoder, &hdmi->bridge, NULL);
if (ret) {
- dw_hdmi_remove(pdev);
+ __dw_hdmi_remove(hdmi);
DRM_ERROR("Failed to initialize bridge with drm\n");
return ret;
}
--
2.14.1
^ permalink raw reply related [flat|nested] 31+ messages in thread