Skip to contentSkip to conversation

drm/hisilicon: Use drm_connector_register_all

PATCH In review Daniel Vetter 5 participants 6 messages May 6, 2016 – May 10, 2016

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

PATCH 1/1 drm/hisilicon: Use drm_connector_register_all

Also, the unbind function is totally not sufficient, and it's calling the deprecated drm_put_dev. Please look at what other drivers are doing and fix things up.

Cc Xinliang Liu <[email protected]>
Cc Xinwei Kong <[email protected]>
---
 drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 31 +------------------------
 1 file changed, 1 insertion(+), 30 deletions(-)
drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c +1 -30
index e6b9e40ced7d..cd3bcb048081 100644
@@ -201,35 +201,6 @@ static int compare_of(struct device *dev, void *data)
 	return dev->of_node == data;
 }
 
-static int kirin_drm_connectors_register(struct drm_device *dev)
-{
-	struct drm_connector *connector;
-	struct drm_connector *failed_connector;
-	int ret;
-
-	mutex_lock(&dev->mode_config.mutex);
-	drm_for_each_connector(connector, dev) {
-		ret = drm_connector_register(connector);
-		if (ret) {
-			failed_connector = connector;
-			goto err;
-		}
-	}
-	mutex_unlock(&dev->mode_config.mutex);
-
-	return 0;
-
-err:
-	drm_for_each_connector(connector, dev) {
-		if (failed_connector == connector)
-			break;
-		drm_connector_unregister(connector);
-	}
-	mutex_unlock(&dev->mode_config.mutex);
-
-	return ret;
-}
-
 static int kirin_drm_bind(struct device *dev)
 {
 	struct drm_driver *driver = &kirin_drm_driver;
@@ -251,7 +222,7 @@ static int kirin_drm_bind(struct device *dev)
 		goto err_kms_cleanup;
 
 	/* connectors should be registered after drm device register */
-	ret = kirin_drm_connectors_register(drm_dev);
+	ret = drm_connector_register_all(drm_dev);
 	if (ret)
 		goto err_drm_dev_unregister;
 
Signature · 6 lines
2.8.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw
Quoted 2 lines · Daniel Vetter

Also, the unbind function is totally not sufficient, and it's calling the deprecated drm_put_dev.

include/drm/drmP.h +1 -1
index 360b2a74e1ef..7efc0b477e38 100644
@@ -1032,7 +1032,7 @@ extern void drm_vblank_post_modeset(struct drm_device *dev, unsigned int pipe);
 extern struct drm_master *drm_master_get(struct drm_master *master);
 extern void drm_master_put(struct drm_master **master);
 
-extern void drm_put_dev(struct drm_device *dev);
+__deprecated extern void drm_put_dev(struct drm_device *dev);
 extern void drm_unplug_dev(struct drm_device *dev);
 extern unsigned int drm_debug;
 extern bool drm_atomic;

And you probably should markup all the others that are now deprecated and being phased out.

Maybe behind drm_deprecated so that the spam is hidden behind another kconfig option rather than enabled-by-buildbots?
-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw
Quoted 18 lines · Chris Wilson
Quoted 2 lines · Daniel Vetter

Also, the unbind function is totally not sufficient, and it's calling the deprecated drm_put_dev.

include/drm/drmP.h +1 -1
index 360b2a74e1ef..7efc0b477e38 100644
@@ -1032,7 +1032,7 @@ extern void drm_vblank_post_modeset(struct drm_device *dev, unsigned int pipe);
 extern struct drm_master *drm_master_get(struct drm_master *master);
 extern void drm_master_put(struct drm_master **master);
 
-extern void drm_put_dev(struct drm_device *dev);
+__deprecated extern void drm_put_dev(struct drm_device *dev);
 extern void drm_unplug_dev(struct drm_device *dev);
 extern unsigned int drm_debug;
 extern bool drm_atomic;
Quoted 5 lines

And you probably should markup all the others that are now deprecated and being phased out.

Maybe behind drm_deprecated so that the spam is hidden behind another kconfig option rather than enabled-by-buildbots?

I thought about this, but the problem is that we still have plenty drivers using them. And hiding behind a build option is a bit meh, or at least we'd need me and Dave to enable that option to make sure nothing slips through.

Dave, do you think such an option would be useful? You'd need to integrate it into your build testing when pulling drivers to make sure we catch it all?

Cheers, 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
#3 lore raw
Quoted 5 lines · Daniel Vetter
Quoted 4 lines · Chris Wilson
Quoted 2 lines · Daniel Vetter

Also, the unbind function is totally not sufficient, and it's calling the deprecated drm_put_dev.

Pretty much the example that I was thinking about when I said "use check-in cocci scripts". The driver was done ~2 weeks before the drm_connect_{un,}register_all helpers.

Quoted 25 lines
Quoted 14 lines
include/drm/drmP.h +1 -1
index 360b2a74e1ef..7efc0b477e38 100644
@@ -1032,7 +1032,7 @@ extern void drm_vblank_post_modeset(struct drm_device *dev, unsigned int pipe);
 extern struct drm_master *drm_master_get(struct drm_master *master);
 extern void drm_master_put(struct drm_master **master);
 
-extern void drm_put_dev(struct drm_device *dev);
+__deprecated extern void drm_put_dev(struct drm_device *dev);
 extern void drm_unplug_dev(struct drm_device *dev);
 extern unsigned int drm_debug;
 extern bool drm_atomic;
Quoted 5 lines

And you probably should markup all the others that are now deprecated and being phased out.

Maybe behind drm_deprecated so that the spam is hidden behind another kconfig option rather than enabled-by-buildbots?

I thought about this, but the problem is that we still have plenty drivers using them. And hiding behind a build option is a bit meh, or at least we'd need me and Dave to enable that option to make sure nothing slips through.

Quoted 4 lines

Dave, do you think such an option would be useful? You'd need to integrate it into your build testing when pulling drivers to make sure we catch it all?

Another interesting topic that I might have mentioned ;-)

About the defaults on such a toggle:
- enabled, shouldn't cause too much spam as the __deprecated
warnings, are off by default.
Pros: Inspire people (maintainers, others) to cleanup the low hanging fruit.
Cons: Might annoy Dave/Daniel and people looking at buildbot logs, when they set the latter.

- disabled, temporary enabled on pull req.
Pros: 'Status check' and a list of things to poke driver maintainers.
Cons: Maintainers might not have both toggles enabled, thus will likely miss things.

Whichever it is it's up-to you guys. Personally I think that we do want to annotate symbols as __deprecated with or without the extra configure (drm toggle).

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

maintainer
#4 lore raw
In reply to Daniel Vetter

Hi Daniel,

Quoted 3 lines · Daniel Vetter

Also, the unbind function is totally not sufficient, and it's calling the deprecated drm_put_dev. Please look at what other drivers are doing and fix things up.

will fix these things and send patch for review soon.

Thanks,
-xinliang

Quoted 58 lines
Cc Xinliang Liu <[email protected]>
Cc Xinwei Kong <[email protected]>
---
 drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 31 +------------------------
 1 file changed, 1 insertion(+), 30 deletions(-)
drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c +1 -31
index e6b9e40ced7d..cd3bcb048081 100644
@@ -201,35 +201,6 @@ static int compare_of(struct device *dev, void *data)
        return dev->of_node == data;
 }
 
-static int kirin_drm_connectors_register(struct drm_device *dev)
-{
-       struct drm_connector *connector;
-       struct drm_connector *failed_connector;
-       int ret;
-
-       mutex_lock(&dev->mode_config.mutex);
-       drm_for_each_connector(connector, dev) {
-               ret = drm_connector_register(connector);
-               if (ret) {
-                       failed_connector = connector;
-                       goto err;
-               }
-       }
-       mutex_unlock(&dev->mode_config.mutex);
-
-       return 0;
-
-err:
-       drm_for_each_connector(connector, dev) {
-               if (failed_connector == connector)
-                       break;
-               drm_connector_unregister(connector);
-       }
-       mutex_unlock(&dev->mode_config.mutex);
-
-       return ret;
-}
-
 static int kirin_drm_bind(struct device *dev)
 {
        struct drm_driver *driver = &kirin_drm_driver;
@@ -251,7 +222,7 @@ static int kirin_drm_bind(struct device *dev)
                goto err_kms_cleanup;
 
        /* connectors should be registered after drm device register */
-       ret = kirin_drm_connectors_register(drm_dev);
+       ret = drm_connector_register_all(drm_dev);
        if (ret)
                goto err_drm_dev_unregister;
 
--
Quoted 2 lines

2.8.1

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

maintainer Tested-by on v1 1/1
#5 lore raw
In reply to Daniel Vetter

Hi Daniel, Thank you for your patch.

Quoted 61 lines · Daniel Vetter

Also, the unbind function is totally not sufficient, and it's calling the deprecated drm_put_dev. Please look at what other drivers are doing and fix things up.

Cc Xinliang Liu <[email protected]>
Cc Xinwei Kong <[email protected]>
---
 drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 31 +------------------------
 1 file changed, 1 insertion(+), 30 deletions(-)
drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c +1 -31
index e6b9e40ced7d..cd3bcb048081 100644
@@ -201,35 +201,6 @@ static int compare_of(struct device *dev, void *data)
        return dev->of_node == data;
 }
 
-static int kirin_drm_connectors_register(struct drm_device *dev)
-{
-       struct drm_connector *connector;
-       struct drm_connector *failed_connector;
-       int ret;
-
-       mutex_lock(&dev->mode_config.mutex);
-       drm_for_each_connector(connector, dev) {
-               ret = drm_connector_register(connector);
-               if (ret) {
-                       failed_connector = connector;
-                       goto err;
-               }
-       }
-       mutex_unlock(&dev->mode_config.mutex);
-
-       return 0;
-
-err:
-       drm_for_each_connector(connector, dev) {
-               if (failed_connector == connector)
-                       break;
-               drm_connector_unregister(connector);
-       }
-       mutex_unlock(&dev->mode_config.mutex);
-
-       return ret;
-}
-
 static int kirin_drm_bind(struct device *dev)
 {
        struct drm_driver *driver = &kirin_drm_driver;
@@ -251,7 +222,7 @@ static int kirin_drm_bind(struct device *dev)
                goto err_kms_cleanup;
 
        /* connectors should be registered after drm device register */
-       ret = kirin_drm_connectors_register(drm_dev);
+       ret = drm_connector_register_all(drm_dev);
        if (ret)
                goto err_drm_dev_unregister;
 
--
Quoted 2 lines

2.8.1

This patch looks good to me. It will be Applied to drm-hisilicon-next for 4.7. As the unbind function is fixed in another patch[1]. Do you mind me to reword the git log msg?

[1]: http://www.spinics.net/lists/dri-devel/msg106836.html

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