Skip to contentSkip to conversation

drm: Add frame CRC debugfs files only for drivers that have CRTC

PATCH Applied Dhinakaran Pandiyan 6 participants 6 messages Sep 29, 2016

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

PATCH 1/1 drm: Add frame CRC debugfs files only for drivers that have CRTC

vgem does not do modeset, looping through non-existent CRTC's while registering drm_minor in

	'commit 48c787899882 ("drm: Add API for capturing frame CRCs")'

caused kernel oops. So, let's add CRC debugfs files only for those drivers that do modeset.

Cc Tomeu Vizoso <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Emil Velikov <[email protected]>
---
 drivers/gpu/drm/drm_drv.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_drv.c +6 -2
index 70d2543..294404f 100644
@@ -208,6 +208,7 @@ static int drm_minor_register(struct drm_device *dev, unsigned int type)
 	struct drm_crtc *crtc;
 	unsigned long flags;
 	int ret;
+	bool is_modeset;
 
 	DRM_DEBUG("\n");
 
@@ -221,7 +222,8 @@ static int drm_minor_register(struct drm_device *dev, unsigned int type)
 		return ret;
 	}
 
-	if (type == DRM_MINOR_PRIMARY) {
+	is_modeset = drm_core_check_feature(dev, DRIVER_MODESET);
+	if (type == DRM_MINOR_PRIMARY && is_modeset) {
 		drm_for_each_crtc(crtc, dev) {
 			ret = drm_debugfs_crtc_add(crtc);
 			if (ret)
@@ -255,12 +257,14 @@ static void drm_minor_unregister(struct drm_device *dev, unsigned int type)
 	struct drm_minor *minor;
 	struct drm_crtc *crtc;
 	unsigned long flags;
+	bool is_modeset;
 
 	minor = *drm_minor_get_slot(dev, type);
 	if (!minor || !device_is_registered(minor->kdev))
 		return;
 
-	if (type == DRM_MINOR_PRIMARY) {
+	is_modeset = drm_core_check_feature(dev, DRIVER_MODESET);
+	if (type == DRM_MINOR_PRIMARY && is_modeset) {
 		drm_for_each_crtc(crtc, dev)
 			drm_debugfs_crtc_remove(crtc);
 	}
Signature · 6 lines
2.7.4

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

✓ Fi.CI.BAT: success for drm: Add frame CRC debugfs files only for drivers that have CRTC

== Series Details ==

== Series Details ==

Series: drm: Add frame CRC debugfs files only for drivers that have CRTC
URL : https://patchwork.freedesktop.org/series/13053/
State : success

== Summary ==

Series 13053v1 drm: Add frame CRC debugfs files only for drivers that have CRTC
https://patchwork.freedesktop.org/api/1.0/series/13053/revisions/1/mbox/

Test drv_getparams_basic:

        Subgroup basic-subslice-total:
                incomplete -> PASS       (fi-byt-j1900)
                incomplete -> PASS       (fi-skl-6700k)
                incomplete -> PASS       (fi-byt-n2820)
                incomplete -> PASS       (fi-snb-2520m)
                incomplete -> PASS       (fi-ivb-3520m)
                incomplete -> PASS       (fi-skl-6260u)
                incomplete -> PASS       (fi-bsw-n3050)
                incomplete -> PASS       (fi-snb-2600)
                incomplete -> PASS       (fi-skl-6770hq)
                incomplete -> PASS       (fi-ilk-650)
                incomplete -> PASS       (fi-bxt-t5700)
                incomplete -> PASS       (fi-skl-6700hq)
                incomplete -> PASS       (fi-hsw-4770)
                incomplete -> PASS       (fi-hsw-4770r)
                incomplete -> PASS       (fi-bdw-5557u)
Test vgem_reload_basic:
                dmesg-fail -> PASS       (fi-byt-j1900)
                dmesg-fail -> PASS       (fi-skl-6700k)
                dmesg-fail -> PASS       (fi-byt-n2820)
                dmesg-fail -> PASS       (fi-snb-2520m)
                dmesg-fail -> PASS       (fi-ivb-3520m)
                dmesg-fail -> PASS       (fi-skl-6260u)
                dmesg-fail -> PASS       (fi-bsw-n3050)
                dmesg-fail -> PASS       (fi-snb-2600)
                dmesg-fail -> PASS       (fi-skl-6770hq)
                dmesg-fail -> PASS       (fi-ilk-650)
                dmesg-fail -> PASS       (fi-bxt-t5700)
                dmesg-fail -> PASS       (fi-skl-6700hq)
                dmesg-fail -> PASS       (fi-hsw-4770)
                dmesg-fail -> PASS       (fi-hsw-4770r)
                dmesg-fail -> PASS       (fi-bdw-5557u)
fi-bdw-5557u     total:244  pass:229  dwarn:0   dfail:0   fail:0   skip:15 
fi-bsw-n3050     total:244  pass:202  dwarn:0   dfail:0   fail:0   skip:42 
fi-bxt-t5700     total:244  pass:214  dwarn:0   dfail:0   fail:0   skip:30 
fi-byt-j1900     total:244  pass:212  dwarn:0   dfail:0   fail:1   skip:31 
fi-byt-n2820     total:244  pass:208  dwarn:0   dfail:0   fail:1   skip:35 
fi-hsw-4770      total:244  pass:222  dwarn:0   dfail:0   fail:0   skip:22 
fi-hsw-4770r     total:244  pass:221  dwarn:0   dfail:0   fail:1   skip:22 
fi-ilk-650       total:244  pass:182  dwarn:0   dfail:0   fail:2   skip:60 
fi-ivb-3520m     total:244  pass:219  dwarn:0   dfail:0   fail:0   skip:25 
fi-ivb-3770      total:244  pass:207  dwarn:0   dfail:0   fail:0   skip:37 
fi-skl-6260u     total:244  pass:230  dwarn:0   dfail:0   fail:0   skip:14 
fi-skl-6700hq    total:244  pass:221  dwarn:1   dfail:0   fail:0   skip:22 
fi-skl-6700k     total:244  pass:219  dwarn:1   dfail:0   fail:0   skip:24 
fi-skl-6770hq    total:244  pass:228  dwarn:1   dfail:0   fail:1   skip:14 
fi-snb-2520m     total:244  pass:208  dwarn:0   dfail:0   fail:0   skip:36 
fi-snb-2600      total:244  pass:207  dwarn:0   dfail:0   fail:0   skip:37 

Results at /archive/results/CI_IGT_test/Patchwork_2590/

edf68a3aacccc2ad1ff8915fcc8011ad43d53be9 drm-intel-nightly: 2016y-09m-28d-15h-13m-34s UTC integration manifest 7b1057e drm: Add frame CRC debugfs files only for drivers that have CRTC

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#2 lore raw
In reply to Dhinakaran Pandiyan
Quoted 5 lines · Dhinakaran Pandiyan

vgem does not do modeset, looping through non-existent CRTC's while registering drm_minor in

	'commit 48c787899882 ("drm: Add API for capturing frame CRCs")'
Quoted 7 lines

caused kernel oops. So, let's add CRC debugfs files only for those drivers that do modeset.

Cc Tomeu Vizoso <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Emil Velikov <[email protected]>
Fixes 48c787899882 ("drm: Add API for capturing frame CRCs")

Dhinakaran, for future reference, please add the kernel oops to the commit messages. It'll help reviewing the patch and matching other bug reports to the fix.

Tomeu, Emil, please review ASAP. This started oopsing all over the place in our CI... we'll need to start running pre-merge testing on patches on dri-devel too, like we do on intel-gfx. (Hint, for now, Cc'ing intel-gfx on drm patches will run our CI on it.)

Thanks,
Jani.

Quoted 42 lines
---
 drivers/gpu/drm/drm_drv.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_drv.c +6 -2
index 70d2543..294404f 100644
@@ -208,6 +208,7 @@ static int drm_minor_register(struct drm_device *dev, unsigned int type)
 	struct drm_crtc *crtc;
 	unsigned long flags;
 	int ret;
+	bool is_modeset;
 
 	DRM_DEBUG("\n");
 
@@ -221,7 +222,8 @@ static int drm_minor_register(struct drm_device *dev, unsigned int type)
 		return ret;
 	}
 
-	if (type == DRM_MINOR_PRIMARY) {
+	is_modeset = drm_core_check_feature(dev, DRIVER_MODESET);
+	if (type == DRM_MINOR_PRIMARY && is_modeset) {
 		drm_for_each_crtc(crtc, dev) {
 			ret = drm_debugfs_crtc_add(crtc);
 			if (ret)
@@ -255,12 +257,14 @@ static void drm_minor_unregister(struct drm_device *dev, unsigned int type)
 	struct drm_minor *minor;
 	struct drm_crtc *crtc;
 	unsigned long flags;
+	bool is_modeset;
 
 	minor = *drm_minor_get_slot(dev, type);
 	if (!minor || !device_is_registered(minor->kdev))
 		return;
 
-	if (type == DRM_MINOR_PRIMARY) {
+	is_modeset = drm_core_check_feature(dev, DRIVER_MODESET);
+	if (type == DRM_MINOR_PRIMARY && is_modeset) {
 		drm_for_each_crtc(crtc, dev)
 			drm_debugfs_crtc_remove(crtc);
 	}
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 1/1
#3 lore raw
In reply to Dhinakaran Pandiyan
Quoted 5 lines · Dhinakaran Pandiyan

vgem does not do modeset, looping through non-existent CRTC's while registering drm_minor in

        'commit 48c787899882 ("drm: Add API for capturing frame CRCs")'
Quoted 7 lines

caused kernel oops. So, let's add CRC debugfs files only for those drivers that do modeset.

Cc Tomeu Vizoso <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Emil Velikov <[email protected]>

But I would prefer if drm_for_each_crtc was safe to call in any device regardless of the features that its driver supports.

Regards,

Tomeu

Quoted 45 lines
---
 drivers/gpu/drm/drm_drv.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_drv.c +6 -3
index 70d2543..294404f 100644
@@ -208,6 +208,7 @@ static int drm_minor_register(struct drm_device *dev, unsigned int type)
        struct drm_crtc *crtc;
        unsigned long flags;
        int ret;
+       bool is_modeset;
 
        DRM_DEBUG("\n");
 
@@ -221,7 +222,8 @@ static int drm_minor_register(struct drm_device *dev, unsigned int type)
                return ret;
        }
 
-       if (type == DRM_MINOR_PRIMARY) {
+       is_modeset = drm_core_check_feature(dev, DRIVER_MODESET);
+       if (type == DRM_MINOR_PRIMARY && is_modeset) {
                drm_for_each_crtc(crtc, dev) {
                        ret = drm_debugfs_crtc_add(crtc);
                        if (ret)
@@ -255,12 +257,14 @@ static void drm_minor_unregister(struct drm_device *dev, unsigned int type)
        struct drm_minor *minor;
        struct drm_crtc *crtc;
        unsigned long flags;
+       bool is_modeset;
 
        minor = *drm_minor_get_slot(dev, type);
        if (!minor || !device_is_registered(minor->kdev))
                return;
 
-       if (type == DRM_MINOR_PRIMARY) {
+       is_modeset = drm_core_check_feature(dev, DRIVER_MODESET);
+       if (type == DRM_MINOR_PRIMARY && is_modeset) {
                drm_for_each_crtc(crtc, dev)
                        drm_debugfs_crtc_remove(crtc);
        }
--

2.7.4

Quoted 4 lines

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#4 lore raw
Quoted 10 lines · Tomeu Vizoso
Quoted 8 lines · Dhinakaran Pandiyan

vgem does not do modeset, looping through non-existent CRTC's while registering drm_minor in

        'commit 48c787899882 ("drm: Add API for capturing frame CRCs")'

caused kernel oops. So, let's add CRC debugfs files only for those drivers that do modeset.

Quoted 6 lines
Quoted 4 lines
Cc Tomeu Vizoso <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Emil Velikov <[email protected]>

Applied to drm-misc, thanks.

Quoted 2 lines

But I would prefer if drm_for_each_crtc was safe to call in any device regardless of the features that its driver supports.

Imo explicit checks are much better, especially in userspace-facing code like this (well it's debugfs and not an ioctl, but still). Unrelated rant:
I think we should throw away the concept of having per-minor debugfs (with a symlink for backwards compat). Then we could have put the crc code into drm_modeset_register_all, and there would not have been any bug. -Daniel

Quoted 54 lines

Regards,

Tomeu

Quoted 49 lines
---
 drivers/gpu/drm/drm_drv.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_drv.c +6 -3
index 70d2543..294404f 100644
@@ -208,6 +208,7 @@ static int drm_minor_register(struct drm_device *dev, unsigned int type)
        struct drm_crtc *crtc;
        unsigned long flags;
        int ret;
+       bool is_modeset;
 
        DRM_DEBUG("\n");
 
@@ -221,7 +222,8 @@ static int drm_minor_register(struct drm_device *dev, unsigned int type)
                return ret;
        }
 
-       if (type == DRM_MINOR_PRIMARY) {
+       is_modeset = drm_core_check_feature(dev, DRIVER_MODESET);
+       if (type == DRM_MINOR_PRIMARY && is_modeset) {
                drm_for_each_crtc(crtc, dev) {
                        ret = drm_debugfs_crtc_add(crtc);
                        if (ret)
@@ -255,12 +257,14 @@ static void drm_minor_unregister(struct drm_device *dev, unsigned int type)
        struct drm_minor *minor;
        struct drm_crtc *crtc;
        unsigned long flags;
+       bool is_modeset;
 
        minor = *drm_minor_get_slot(dev, type);
        if (!minor || !device_is_registered(minor->kdev))
                return;
 
-       if (type == DRM_MINOR_PRIMARY) {
+       is_modeset = drm_core_check_feature(dev, DRIVER_MODESET);
+       if (type == DRM_MINOR_PRIMARY && is_modeset) {
                drm_for_each_crtc(crtc, dev)
                        drm_debugfs_crtc_remove(crtc);
        }
--

2.7.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

PATCH 1/1 drm: Add frame CRC debugfs files only for drivers that have CRTC

Quoted 20 lines · Daniel Vetter
Quoted 10 lines · Tomeu Vizoso
Quoted 8 lines · Dhinakaran Pandiyan

vgem does not do modeset, looping through non-existent CRTC's while registering drm_minor in

        'commit 48c787899882 ("drm: Add API for capturing frame CRCs")'

caused kernel oops. So, let's add CRC debugfs files only for those drivers that do modeset.

Quoted 6 lines
Quoted 4 lines
Cc Tomeu Vizoso <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Emil Velikov <[email protected]>

Applied to drm-misc, thanks.

Quoted 8 lines
Quoted 2 lines

But I would prefer if drm_for_each_crtc was safe to call in any device regardless of the features that its driver supports.

Imo explicit checks are much better, especially in userspace-facing code like this (well it's debugfs and not an ioctl, but still). Unrelated rant:
I think we should throw away the concept of having per-minor debugfs (with a symlink for backwards compat). Then we could have put the crc code into drm_modeset_register_all, and there would not have been any bug.

Fwiw I agree that explicit checks are better.

I keep forgetting that we create a card# node even if the device does not feature DRIVER_MODESET. IMHO if we drop that assumption, we can simplify core DRM and/or some drivers. If userspace is not new enough to know about render nodes it's simply not capable of using new drivers/devices properly and there will be no regressions afaict. Not to mention it the dubious auth requirement even if the device is render only. Alternatively if we can have add a comment why the card# is required that'll be greatly appreciated.

That said, the patch is a good fix and is

Regards,
Emil

P.S. Some of the links on your blog have gone crazy [2]

[1] https://dri.freedesktop.org/docs/drm/gpu/drm-uapi.html#render-nodes
[2] http://blog.ffwll.ch/2016/01/better-markup-for-kernel-gpu-docbook.html

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