Skip to content

Commit

Permalink
drm/kms: Duct-tape for mode object lifetime checks
Browse files Browse the repository at this point in the history
commit 4f5368b
Author: Daniel Vetter <[email protected]>
Date:   Fri Jun 14 08:17:23 2019 +0200

    drm/kms: Catch mode_object lifetime errors

uncovered a bit a mess in dp drivers. Most drivers (from a quick look,
all except i915) register all the dp stuff in their init code, which
is too early. With CONFIG_DRM_DP_AUX_CHARDEV this will blow up,
because drm_dp_aux_register tries to add a child to a device in sysfs
(the connector) which doesn't even exist yet.

No one seems to have cared thus far. But with the above change I also
moved the setting of dev->registered after the ->load callback, in an
attempt to keep old drivers from hitting any WARN_ON backtraces. But
that moved radeon.ko from the "working, by accident" to "now also
broken" category.

Since this is a huge mess I figured a revert would be simplest. But
this check has already caught issues in i915:

commit 1b9bd09
Author: Ville Syrjälä <[email protected]>
Date:   Tue Aug 20 19:16:57 2019 +0300

    drm/i915: Do not create a new max_bpc prop for MST connectors

Hence I'd like to retain it. Fix the radeon regression by moving the
setting of dev->registered back to were it was, and stop the
backtraces with an explicit check for dev->driver->load.

Everyone else will stay as broken with CONFIG_DRM_DP_AUX_CHARDEV. The
next patch will improve the kerneldoc and add a todo entry for this.

Fixes: 4f5368b ("drm/kms: Catch mode_object lifetime errors")
Cc: Sean Paul <[email protected]>
Cc: Maarten Lankhorst <[email protected]>
Reported-by: Michel Dänzer <[email protected]>
Reviewed-by: Michel Dänzer <[email protected]>
Tested-by: Michel Dänzer <[email protected]>
Cc: Michel Dänzer <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
  • Loading branch information
danvet committed Sep 18, 2019
1 parent 2472518 commit e0f32f7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions drivers/gpu/drm/drm_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -976,14 +976,14 @@ int drm_dev_register(struct drm_device *dev, unsigned long flags)
if (ret)
goto err_minors;

dev->registered = true;

if (dev->driver->load) {
ret = dev->driver->load(dev, flags);
if (ret)
goto err_minors;
}

dev->registered = true;

if (drm_core_check_feature(dev, DRIVER_MODESET))
drm_modeset_register_all(dev);

Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/drm_mode_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ int __drm_mode_object_add(struct drm_device *dev, struct drm_mode_object *obj,
{
int ret;

WARN_ON(dev->registered && !obj_free_cb);
WARN_ON(!dev->driver->load && dev->registered && !obj_free_cb);

mutex_lock(&dev->mode_config.idr_mutex);
ret = idr_alloc(&dev->mode_config.object_idr, register_obj ? obj : NULL,
Expand Down Expand Up @@ -104,7 +104,7 @@ void drm_mode_object_register(struct drm_device *dev,
void drm_mode_object_unregister(struct drm_device *dev,
struct drm_mode_object *object)
{
WARN_ON(dev->registered && !object->free_cb);
WARN_ON(!dev->driver->load && dev->registered && !object->free_cb);

mutex_lock(&dev->mode_config.idr_mutex);
if (object->id) {
Expand Down

0 comments on commit e0f32f7

Please sign in to comment.