All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] drm/omap: fix reference leak in runtime get ops
@ 2020-11-10 12:51 Zhang Qilong
  2020-11-10 12:51 ` [PATCH 1/4] drm: omapdrm: dsi: fix-reference-leak-in dsi_runtime_get Zhang Qilong
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Zhang Qilong @ 2020-11-10 12:51 UTC (permalink / raw)
  To: tomi.valkeinen, airlied, daniel; +Cc: dri-devel

This series of patches fixed several usage counter leaks refer to
pm_runtime_get_sync. Many callers forget to call pm_runtime_put_noidle
when pm_runtime_get_sync failed, and we fixed it.

Zhang Qilong (4):
  drm: omapdrm: dsi: fix-reference-leak-in dsi_runtime_get.
  drm: omapdrm: dss: fix reference leak in dss_runtime_get
  drm/omap: hdmi4: fix reference leak in hdmi_runtime_get
  drm/omap: hdmi5: fix reference leak in hdmi_runtime_get

 drivers/gpu/drm/omapdrm/dss/dsi.c   | 8 ++++++--
 drivers/gpu/drm/omapdrm/dss/dss.c   | 8 ++++++--
 drivers/gpu/drm/omapdrm/dss/hdmi4.c | 4 +++-
 drivers/gpu/drm/omapdrm/dss/hdmi5.c | 4 +++-
 4 files changed, 18 insertions(+), 6 deletions(-)

-- 
2.25.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/4] drm: omapdrm: dsi: fix-reference-leak-in dsi_runtime_get.
  2020-11-10 12:51 [PATCH 0/4] drm/omap: fix reference leak in runtime get ops Zhang Qilong
@ 2020-11-10 12:51 ` Zhang Qilong
  2020-11-10 12:51 ` [PATCH 2/4] drm: omapdrm: dss: fix reference leak in dss_runtime_get Zhang Qilong
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Zhang Qilong @ 2020-11-10 12:51 UTC (permalink / raw)
  To: tomi.valkeinen, airlied, daniel; +Cc: dri-devel

pm_runtime_get_sync() will increment pm usage at first and it
will resume the device later. If runtime of the device has
error or device is in inaccessible state(or other error state),
resume operation will fail. If we do not call put operation to
decrease the reference, it will result in reference leak in
dsi_runtime_get. Moreover, this device cannot enter the idle
state and always stay busy or other non-idle state later. So we
should fix it through adding pm_runtime_put_noidle.

Fixes: 4600ea9c49cc4 ("drm: omapdrm: dsi: Store the struct device pointer in struct dsi_data")

Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index eeccf40bae41..f407d9c60ada 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -1112,8 +1112,12 @@ static int dsi_runtime_get(struct dsi_data *dsi)
 	DSSDBG("dsi_runtime_get\n");
 
 	r = pm_runtime_get_sync(dsi->dev);
-	WARN_ON(r < 0);
-	return r < 0 ? r : 0;
+	if (WARN_ON(r < 0)) {
+		pm_runtime_put_noidle(dsi->dev);
+		return r;
+	}
+
+	return 0;
 }
 
 static void dsi_runtime_put(struct dsi_data *dsi)
-- 
2.25.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/4] drm: omapdrm: dss: fix reference leak in dss_runtime_get
  2020-11-10 12:51 [PATCH 0/4] drm/omap: fix reference leak in runtime get ops Zhang Qilong
  2020-11-10 12:51 ` [PATCH 1/4] drm: omapdrm: dsi: fix-reference-leak-in dsi_runtime_get Zhang Qilong
@ 2020-11-10 12:51 ` Zhang Qilong
  2020-11-10 12:51 ` [PATCH 3/4] drm/omap: hdmi4: fix reference leak in hdmi_runtime_get Zhang Qilong
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Zhang Qilong @ 2020-11-10 12:51 UTC (permalink / raw)
  To: tomi.valkeinen, airlied, daniel; +Cc: dri-devel

pm_runtime_get_sync() will increment pm usage at first and it
will resume the device later. If runtime of the device has
error or device is in inaccessible state(or other error state),
resume operation will fail. If we do not call put operation to
decrease the reference, it will result in reference leak in
dss_runtime_get. Moreover, this device cannot enter the idle state
and always stay busy or other non-idle state later. So we should
fix it through adding pm_runtime_put_noidle.

Fixes: 7b295257a13d8 ("drm: omapdrm: dss: Pass DSS private structure to runtime PM functions")

Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
---
 drivers/gpu/drm/omapdrm/dss/dss.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
index 6ccbc29c4ce4..9571f3db6f71 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -858,8 +858,12 @@ int dss_runtime_get(struct dss_device *dss)
 	DSSDBG("dss_runtime_get\n");
 
 	r = pm_runtime_get_sync(&dss->pdev->dev);
-	WARN_ON(r < 0);
-	return r < 0 ? r : 0;
+	if (WARN_ON(r < 0)) {
+		pm_runtime_put_noidle(&dss->pdev->dev);
+		return r;
+	}
+
+	return 0;
 }
 
 void dss_runtime_put(struct dss_device *dss)
-- 
2.25.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/4] drm/omap: hdmi4: fix reference leak in hdmi_runtime_get
  2020-11-10 12:51 [PATCH 0/4] drm/omap: fix reference leak in runtime get ops Zhang Qilong
  2020-11-10 12:51 ` [PATCH 1/4] drm: omapdrm: dsi: fix-reference-leak-in dsi_runtime_get Zhang Qilong
  2020-11-10 12:51 ` [PATCH 2/4] drm: omapdrm: dss: fix reference leak in dss_runtime_get Zhang Qilong
@ 2020-11-10 12:51 ` Zhang Qilong
  2020-11-10 12:51 ` [PATCH 4/4] drm/omap: hdmi5: " Zhang Qilong
  2020-11-10 13:07 ` [PATCH 0/4] drm/omap: fix reference leak in runtime get ops Tomi Valkeinen
  4 siblings, 0 replies; 6+ messages in thread
From: Zhang Qilong @ 2020-11-10 12:51 UTC (permalink / raw)
  To: tomi.valkeinen, airlied, daniel; +Cc: dri-devel

pm_runtime_get_sync will increment pm usage counter even it
failed. Forgetting to pm_runtime_put_noidle will result in
reference leak in hdmi_runtime_get, so we should fix it.

Fixes: ac7674567c620 ("drm: omapdrm: hdmi4: Allocate the omap_hdmi data structure dynamically")
Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
---
 drivers/gpu/drm/omapdrm/dss/hdmi4.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
index a14fbf06cb30..33f12c351b08 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
@@ -44,8 +44,10 @@ static int hdmi_runtime_get(struct omap_hdmi *hdmi)
 
 	r = pm_runtime_get_sync(&hdmi->pdev->dev);
 	WARN_ON(r < 0);
-	if (r < 0)
+	if (r < 0) {
+		pm_runtime_put_noidle(&hdmi->pdev->dev);
 		return r;
+	}
 
 	return 0;
 }
-- 
2.25.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4/4] drm/omap: hdmi5: fix reference leak in hdmi_runtime_get
  2020-11-10 12:51 [PATCH 0/4] drm/omap: fix reference leak in runtime get ops Zhang Qilong
                   ` (2 preceding siblings ...)
  2020-11-10 12:51 ` [PATCH 3/4] drm/omap: hdmi4: fix reference leak in hdmi_runtime_get Zhang Qilong
@ 2020-11-10 12:51 ` Zhang Qilong
  2020-11-10 13:07 ` [PATCH 0/4] drm/omap: fix reference leak in runtime get ops Tomi Valkeinen
  4 siblings, 0 replies; 6+ messages in thread
From: Zhang Qilong @ 2020-11-10 12:51 UTC (permalink / raw)
  To: tomi.valkeinen, airlied, daniel; +Cc: dri-devel

pm_runtime_get_sync will increment pm usage counter even it
failed. Forgetting to pm_runtime_put_noidle will result in
reference leak in hdmi_runtime_get, so we should fix it.

Fixes: c44991ce21bef ("drm: omapdrm: hdmi5: Allocate the omap_hdmi data structure dynamically")
Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
---
 drivers/gpu/drm/omapdrm/dss/hdmi5.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
index b738d9750686..26ffbd1bd1cc 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
@@ -45,8 +45,10 @@ static int hdmi_runtime_get(struct omap_hdmi *hdmi)
 
 	r = pm_runtime_get_sync(&hdmi->pdev->dev);
 	WARN_ON(r < 0);
-	if (r < 0)
+	if (r < 0) {
+		pm_runtime_put_noidle(&hdmi->pdev->dev);
 		return r;
+	}
 
 	return 0;
 }
-- 
2.25.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/4] drm/omap: fix reference leak in runtime get ops
  2020-11-10 12:51 [PATCH 0/4] drm/omap: fix reference leak in runtime get ops Zhang Qilong
                   ` (3 preceding siblings ...)
  2020-11-10 12:51 ` [PATCH 4/4] drm/omap: hdmi5: " Zhang Qilong
@ 2020-11-10 13:07 ` Tomi Valkeinen
  4 siblings, 0 replies; 6+ messages in thread
From: Tomi Valkeinen @ 2020-11-10 13:07 UTC (permalink / raw)
  To: Zhang Qilong, airlied, daniel; +Cc: dri-devel

Hi,

On 10/11/2020 14:51, Zhang Qilong wrote:
> This series of patches fixed several usage counter leaks refer to
> pm_runtime_get_sync. Many callers forget to call pm_runtime_put_noidle
> when pm_runtime_get_sync failed, and we fixed it.
> 
> Zhang Qilong (4):
>   drm: omapdrm: dsi: fix-reference-leak-in dsi_runtime_get.
>   drm: omapdrm: dss: fix reference leak in dss_runtime_get
>   drm/omap: hdmi4: fix reference leak in hdmi_runtime_get
>   drm/omap: hdmi5: fix reference leak in hdmi_runtime_get
> 
>  drivers/gpu/drm/omapdrm/dss/dsi.c   | 8 ++++++--
>  drivers/gpu/drm/omapdrm/dss/dss.c   | 8 ++++++--
>  drivers/gpu/drm/omapdrm/dss/hdmi4.c | 4 +++-
>  drivers/gpu/drm/omapdrm/dss/hdmi5.c | 4 +++-
>  4 files changed, 18 insertions(+), 6 deletions(-)

I have applied an earlier series from Dinghao Liu which does the same thing.

 Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-11-11  7:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-10 12:51 [PATCH 0/4] drm/omap: fix reference leak in runtime get ops Zhang Qilong
2020-11-10 12:51 ` [PATCH 1/4] drm: omapdrm: dsi: fix-reference-leak-in dsi_runtime_get Zhang Qilong
2020-11-10 12:51 ` [PATCH 2/4] drm: omapdrm: dss: fix reference leak in dss_runtime_get Zhang Qilong
2020-11-10 12:51 ` [PATCH 3/4] drm/omap: hdmi4: fix reference leak in hdmi_runtime_get Zhang Qilong
2020-11-10 12:51 ` [PATCH 4/4] drm/omap: hdmi5: " Zhang Qilong
2020-11-10 13:07 ` [PATCH 0/4] drm/omap: fix reference leak in runtime get ops Tomi Valkeinen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.