Skip to contentSkip to conversation

drm/etnaviv: Use drm_dev_unref, not drm_put_dev

PATCH In review Daniel Vetter 5 participants 14 messages Dec 8, 2016 – Dec 13, 2016

Subsystems (7)
lore
Share & tools
lore
#0 lore raw

PATCH 1/4 drm/etnaviv: Use drm_dev_unref, not drm_put_dev

drm_put_dev is the old midlayer-broken device cleanup function, but etnaviv has a proper unbind function which first unregisters and then drops the final reference. No functional change since drm_dev_unregister happens to be idempotent.

Cc Lucas Stach <[email protected]>
Cc Russell King <[email protected]>
Cc Christian Gmeiner <[email protected]>
---
 drivers/gpu/drm/etnaviv/etnaviv_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/etnaviv/etnaviv_drv.c +1 -1
index 00368b14d08d..30d70ed143f7 100644
@@ -592,7 +592,7 @@ static void etnaviv_unbind(struct device *dev)
 	drm->dev_private = NULL;
 	kfree(priv);
 
-	drm_put_dev(drm);
+	drm_dev_unref(drm);
 }
 
 static const struct component_master_ops etnaviv_master_ops = {
Signature · 6 lines
2.10.2

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

PATCH 2/4 drm/fsl: don't use drm_put_dev

fsl is already fully demidlayered in the probe function, but for convenience stuck with drm_put_dev. Call the unregister/unref parts separately, to make sure this driver works correct.

---
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c +2 -1
index 320e4728c9b9..d36bf4f8b3de 100644
@@ -426,7 +426,8 @@ static int fsl_dcu_drm_remove(struct platform_device *pdev)
 
 	clk_disable_unprepare(fsl_dev->clk);
 	clk_unregister(fsl_dev->pix_clk);
-	drm_put_dev(fsl_dev->drm);
+	drm_dev_unregister(fsl_dev->drm);
+	drm_dev_unref(fsl_dev->drm);
 
 	return 0;
 }
Signature · 6 lines
2.10.2

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
maintainer
#2 lore raw

Re: [PATCH 2/4] drm/fsl: don't use drm_put_dev

Am Donnerstag, den 08.12.2016, 12:07 +0100 schrieb Daniel Vetter:

Quoted 15 lines

fsl is already fully demidlayered in the probe function, but for convenience stuck with drm_put_dev. Call the unregister/unref parts separately, to make sure this driver works correct.

---
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c +0 -0
index 320e4728c9b9..d36bf4f8b3de 100644

drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c static int fsl_dcu_drm_remove(struct platform_device *pdev) · line 430

Quoted 6 lines
drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c +2 -1
@@ -426,7 +426,8 @@ static int fsl_dcu_drm_remove(struct platform_device *pdev)
 
 	clk_disable_unprepare(fsl_dev->clk);
 	clk_unregister(fsl_dev->pix_clk);
-	drm_put_dev(fsl_dev->drm);
+	drm_dev_unregister(fsl_dev->drm);
+	drm_dev_unref(fsl_dev->drm);

Why not make it work correctly instead of the mechanical change? I.e. move the drm_dev_unregister() up 2 lines.

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

#3 lore raw

Re: [PATCH 2/4] drm/fsl: don't use drm_put_dev

Quoted 17 lines · Lucas Stach

Am Donnerstag, den 08.12.2016, 12:07 +0100 schrieb Daniel Vetter:

Quoted 16 lines

fsl is already fully demidlayered in the probe function, but for convenience stuck with drm_put_dev. Call the unregister/unref parts separately, to make sure this driver works correct.

---
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c +0 -0
index 320e4728c9b9..d36bf4f8b3de 100644
@@ -426,7 +426,8 @@ static int fsl_dcu_drm_remove(struct platform_device *pdev)
 
Quoted 8 lines

drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c static int fsl_dcu_drm_remove(struct platform_device *pdev) · line 430

Quoted 5 lines
drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c +2 -1
 	clk_disable_unprepare(fsl_dev->clk);
 	clk_unregister(fsl_dev->pix_clk);
-	drm_put_dev(fsl_dev->drm);
+	drm_dev_unregister(fsl_dev->drm);
+	drm_dev_unref(fsl_dev->drm);

Why not make it work correctly instead of the mechanical change? I.e. move the drm_dev_unregister() up 2 lines.

I have a rebased v2 here which does that, because upstream fsl changed that. Will resend.
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#4 lore raw

PATCH 1/1 drm/fsl: don't use drm_put_dev

In reply to Daniel Vetter

fsl is already fully demidlayered in the probe function, but for convenience stuck with drm_put_dev. Call the unregister/unref parts separately, to make sure this driver works correct.

v2: Rebase.

Cc Lucas Stach <[email protected]>
Cc Stefan Agner <[email protected]>
---
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c +2 -1
index 537ca159ffe5..0b35da73c2b0 100644
@@ -434,7 +434,8 @@ static int fsl_dcu_drm_remove(struct platform_device *pdev)
 {
 	struct fsl_dcu_drm_device *fsl_dev = platform_get_drvdata(pdev);
 
-	drm_put_dev(fsl_dev->drm);
+	drm_dev_unregister(fsl_dev->drm);
+	drm_dev_unref(fsl_dev->drm);
 	clk_disable_unprepare(fsl_dev->clk);
 	clk_unregister(fsl_dev->pix_clk);
 
Signature · 6 lines
2.11.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
maintainer Reviewed-by on v1 1/1
#5 lore raw

Re: [PATCH] drm/fsl: don't use drm_put_dev

Am Dienstag, den 13.12.2016, 18:54 +0100 schrieb Daniel Vetter:

Quoted 9 lines

fsl is already fully demidlayered in the probe function, but for convenience stuck with drm_put_dev. Call the unregister/unref parts separately, to make sure this driver works correct.

v2: Rebase.

Cc Lucas Stach <[email protected]>
Cc Stefan Agner <[email protected]>
Quoted 9 lines
---
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c +0 -0
index 537ca159ffe5..0b35da73c2b0 100644

drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c static int fsl_dcu_drm_remove(struct platform_device *pdev) · line 441

Quoted 9 lines
drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c +2 -1
@@ -434,7 +434,8 @@ static int fsl_dcu_drm_remove(struct platform_device *pdev)
 {
 	struct fsl_dcu_drm_device *fsl_dev = platform_get_drvdata(pdev);
 
-	drm_put_dev(fsl_dev->drm);
+	drm_dev_unregister(fsl_dev->drm);
+	drm_dev_unref(fsl_dev->drm);
 	clk_disable_unprepare(fsl_dev->clk);
 	clk_unregister(fsl_dev->pix_clk);
 

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

#6 lore raw

Re: [PATCH] drm/fsl: don't use drm_put_dev

Quoted 5 lines · Lucas Stach

Am Dienstag, den 13.12.2016, 18:54 +0100 schrieb Daniel Vetter:

Quoted 4 lines

fsl is already fully demidlayered in the probe function, but for convenience stuck with drm_put_dev. Call the unregister/unref parts separately, to make sure this driver works correct.

Quoted 7 lines
Quoted 5 lines

v2: Rebase.

Cc Lucas Stach <[email protected]>
Cc Stefan Agner <[email protected]>

Ok, applied this one now too, thanks for your review. -Daniel

Quoted 21 lines
Quoted 19 lines
---
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c +2 -1
index 537ca159ffe5..0b35da73c2b0 100644
@@ -434,7 +434,8 @@ static int fsl_dcu_drm_remove(struct platform_device *pdev)
 {
 	struct fsl_dcu_drm_device *fsl_dev = platform_get_drvdata(pdev);
 
-	drm_put_dev(fsl_dev->drm);
+	drm_dev_unregister(fsl_dev->drm);
+	drm_dev_unref(fsl_dev->drm);
 	clk_disable_unprepare(fsl_dev->clk);
 	clk_unregister(fsl_dev->pix_clk);
 
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
maintainer Acked-by
#7 lore raw

Re: [PATCH] drm/fsl: don't use drm_put_dev

Quoted 6 lines · Daniel Vetter
Quoted 5 lines · Lucas Stach

Am Dienstag, den 13.12.2016, 18:54 +0100 schrieb Daniel Vetter:

Quoted 4 lines

fsl is already fully demidlayered in the probe function, but for convenience stuck with drm_put_dev. Call the unregister/unref parts separately, to make sure this driver works correct.

Quoted 8 lines
Quoted 7 lines
Quoted 5 lines

v2: Rebase.

Cc Lucas Stach <[email protected]>
Cc Stefan Agner <[email protected]>

Sorry for the delay.

Quoted 2 lines

Ok, applied this one now too, thanks for your review. -Daniel

FWIW, just tested it now and looks good to me

--
Stefan

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines

---
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c +0 -0
index 537ca159ffe5..0b35da73c2b0 100644
@@ -434,7 +434,8 @@ static int fsl_dcu_drm_remove(struct platform_device *pdev)
 {
 	struct fsl_dcu_drm_device *fsl_dev = platform_get_drvdata(pdev);
 
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c static int fsl_dcu_drm_remove(struct platform_device *pdev) · line 441

Quoted 6 lines
drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c +2 -1
-	drm_put_dev(fsl_dev->drm);
+	drm_dev_unregister(fsl_dev->drm);
+	drm_dev_unref(fsl_dev->drm);
 	clk_disable_unprepare(fsl_dev->clk);
 	clk_unregister(fsl_dev->pix_clk);
 

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

#8 lore raw

PATCH 3/4 drm/mediatek: don't use drm_put_dev

In reply to Daniel Vetter

fsl is already fully demidlayered in the probe function, but for convenience stuck with drm_put_dev. Call the unregister/unref parts separately, to make sure this driver works correct.

---
 drivers/gpu/drm/mediatek/mtk_drm_drv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/mediatek/mtk_drm_drv.c +2 -1
index 4b7fe7eaec01..b5f88e6d078e 100644
@@ -321,7 +321,8 @@ static void mtk_drm_unbind(struct device *dev)
 {
 	struct mtk_drm_private *private = dev_get_drvdata(dev);
 
-	drm_put_dev(private->drm);
+	drm_dev_unregister(private->drm);
+	drm_dev_unref(private->drm);
 	private->drm = NULL;
 }
 
Signature · 6 lines
2.10.2

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
maintainer Reviewed-by on v1 3/4
#9 lore raw

Re: [PATCH 3/4] drm/mediatek: don't use drm_put_dev

Am Donnerstag, den 08.12.2016, 12:07 +0100 schrieb Daniel Vetter:

Quoted 1 line

fsl is already fully demidlayered in the probe function, but for

^ mediatek not fsl-dcu

Quoted 3 lines

convenience stuck with drm_put_dev. Call the unregister/unref parts separately, to make sure this driver works correct.

I don't really see the benefit here, except you want to get rid of drm_dev_put() completely from the core. But whatever:

Quoted 12 lines
---
 drivers/gpu/drm/mediatek/mtk_drm_drv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/mediatek/mtk_drm_drv.c +0 -0
index 4b7fe7eaec01..b5f88e6d078e 100644

drivers/gpu/drm/mediatek/mtk_drm_drv.c static void mtk_drm_unbind(struct device *dev) · line 328

Quoted 9 lines
drivers/gpu/drm/mediatek/mtk_drm_drv.c +2 -1
@@ -321,7 +321,8 @@ static void mtk_drm_unbind(struct device *dev)
 {
 	struct mtk_drm_private *private = dev_get_drvdata(dev);
 
-	drm_put_dev(private->drm);
+	drm_dev_unregister(private->drm);
+	drm_dev_unref(private->drm);
 	private->drm = NULL;
 }
 

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

#10 lore raw

Re: [PATCH 3/4] drm/mediatek: don't use drm_put_dev

Quoted 9 lines · Lucas Stach

Am Donnerstag, den 08.12.2016, 12:07 +0100 schrieb Daniel Vetter:

Quoted 1 line

fsl is already fully demidlayered in the probe function, but for

^ mediatek not fsl-dcu

Quoted 3 lines

convenience stuck with drm_put_dev. Call the unregister/unref parts separately, to make sure this driver works correct.

I don't really see the benefit here, except you want to get rid of drm_dev_put() completely from the core. But whatever:

Yeah, that's the idea. Also I like probe/remove paths to be symmetric, this achieves this.

Quoted 1 line

Merged this and the etnaviv patch to drm-misc, thanks for your review. -Daniel

Quoted 24 lines
Quoted 22 lines
---
 drivers/gpu/drm/mediatek/mtk_drm_drv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/mediatek/mtk_drm_drv.c +2 -1
index 4b7fe7eaec01..b5f88e6d078e 100644
@@ -321,7 +321,8 @@ static void mtk_drm_unbind(struct device *dev)
 {
 	struct mtk_drm_private *private = dev_get_drvdata(dev);
 
-	drm_put_dev(private->drm);
+	drm_dev_unregister(private->drm);
+	drm_dev_unref(private->drm);
 	private->drm = NULL;
 }
 
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#11 lore raw

PATCH 4/4 drm/vc4: Don't use drm_put_dev

In reply to Daniel Vetter

vc4 already has a proper load sequence, but the unload one needed some
fixups: First unregister, and last drop the final ref.

---
 drivers/gpu/drm/vc4/vc4_drv.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/vc4/vc4_drv.c +3 -1
index 1dab9e5b3689..bfaf4e36f7ae 100644
@@ -277,12 +277,14 @@ static void vc4_drm_unbind(struct device *dev)
 	struct drm_device *drm = platform_get_drvdata(pdev);
 	struct vc4_dev *vc4 = to_vc4_dev(drm);
 
+	drm_dev_unregister(drm);
+
 	if (vc4->fbdev)
 		drm_fbdev_cma_fini(vc4->fbdev);
 
 	drm_mode_config_cleanup(drm);
 
-	drm_put_dev(drm);
+	drm_dev_unref(drm);
 }
 
 static const struct component_master_ops vc4_drm_ops = {
Signature · 6 lines
2.10.2

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

Re: [PATCH 4/4] drm/vc4: Don't use drm_put_dev

Quoted 5 lines · Daniel Vetter

vc4 already has a proper load sequence, but the unload one needed some
fixups: First unregister, and last drop the final ref.

Pulled this one. Thanks!

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

maintainer Reviewed-by on v1 1/4
#13 lore raw
In reply to Daniel Vetter

Am Donnerstag, den 08.12.2016, 12:07 +0100 schrieb Daniel Vetter:

Quoted 9 lines

drm_put_dev is the old midlayer-broken device cleanup function, but etnaviv has a proper unbind function which first unregisters and then drops the final reference. No functional change since drm_dev_unregister happens to be idempotent.

Cc Lucas Stach <[email protected]>
Cc Russell King <[email protected]>
Cc Christian Gmeiner <[email protected]>
Quoted 9 lines
---
 drivers/gpu/drm/etnaviv/etnaviv_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/etnaviv/etnaviv_drv.c +0 -0
index 00368b14d08d..30d70ed143f7 100644

drivers/gpu/drm/etnaviv/etnaviv_drv.c static void etnaviv_unbind(struct device *dev) · line 598

Quoted 8 lines
drivers/gpu/drm/etnaviv/etnaviv_drv.c +1 -1
@@ -592,7 +592,7 @@ static void etnaviv_unbind(struct device *dev)
 	drm->dev_private = NULL;
 	kfree(priv);
 
-	drm_put_dev(drm);
+	drm_dev_unref(drm);
 }
 
 static const struct component_master_ops etnaviv_master_ops = {

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