DRM: small improvements
Subsystems (2)
v3 cover DRM: small improvements
This series brings small improvements to the DRM documentation, logging and a warning on an incorrect code path.
---
Changes in v3:
- patch 3: various fixes suggested by Jani Nikula and kernel test robot
- Updated reviewed-by tags
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- Added patches 3 and 4
- Updated reviewed-by tags
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Luca Ceresoli (4):
drm/drm_mode_object: fix typo in kerneldoc
drm/atomic-helper: improve CRTC enabled/connectors mismatch logging message drm/mode_object: add drm_mode_object_read_refcount() drm/connector: warn when cleaning up a refcounted connector
drivers/gpu/drm/drm_atomic_helper.c | 5 +++-- drivers/gpu/drm/drm_connector.c | 6 ++++++ drivers/gpu/drm/drm_mode_object.c | 17 +++++++++++++++++ include/drm/drm_mode_object.h | 3 ++- 4 files changed, 28 insertions(+), 3 deletions(-)
---
base-commit: 42f7652d3eb527d03665b09edac47f85fb600924
change-id: 20241018-drm-small-improvements-1d104cc10280
Best regards,
Signature · 1 line
Luca Ceresoli <[email protected]>
PATCH v3 1/4 drm/drm_mode_object: fix typo in kerneldoc
Remove unintended extra word.
--- include/drm/drm_mode_object.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/drm/drm_mode_object.h +1 -1
@@ -35,7 +35,7 @@ struct drm_file;* @id: userspace visible identifier * @type: type of the object, one of DRM_MODE_OBJECT\_\* * @properties: properties attached to this object, including values -* @refcount: reference count for objects which with dynamic lifetime +* @refcount: reference count for objects with dynamic lifetime * @free_cb: free function callback, only set for objects with dynamic lifetime * * Base structure for modeset objects visible to userspace. Objects can be
Signature · 1 line
2.34.1
PATCH v3 2/4 drm/atomic-helper: improve CRTC enabled/connectors mismatch logging message
In reply to Luca CeresoliThis message reports a mismatch between new_crtc_state->enable and has_connectors, which should be either both true or both false. However it does not mention which one is true and which is false, which can be useful for debugging. Add the value of both avriables to the log message.
--- drivers/gpu/drm/drm_atomic_helper.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +3 -2
@@ -666,8 +666,9 @@ drm_atomic_helper_check_modeset(struct drm_device *dev, }if (new_crtc_state->enable != has_connectors) { -drm_dbg_atomic (dev,"[CRTC:%d:%s] enabled/connectors mismatch\n" , - crtc->base.id, crtc->name); +drm_dbg_atomic (dev,"[CRTC:%d:%s] enabled/connectors mismatch (%d/%d)\n" , + crtc->base.id, crtc->name, + new_crtc_state->enable, has_connectors);return -EINVAL ; }
Signature · 1 line
2.34.1
PATCH v3 3/4 drm/mode_object: add drm_mode_object_read_refcount()
In reply to Luca CeresoliAdd a wrapper to kref_read() just like the ones already in place for kref_get() and kref_put(). This will be used for sanity checks on object lifetime.
---
Changed in v3:
* use conventions for 'Returns' doc syntax
* ditch DRM_DEBUG() and as a consequence rework and simplify the entire function
* fix function name in kerneldoc
--- drivers/gpu/drm/drm_mode_object.c | 17 +++++++++++++++++ include/drm/drm_mode_object.h | 1 + 2 files changed, 18 insertions(+)
drivers/gpu/drm/drm_mode_object.c +17 -0
@@ -217,6 +217,23 @@ void drm_mode_object_get(struct drm_mode_object *obj) }EXPORT_SYMBOL (drm_mode_object_get); +/** +* drm_mode_object_read_refcount - read the refcount for a mode object +* @obj: DRM mode object +* +* Returns: +* The current object refcount if it is a refcounted modeset object, or 0 +* for any other object. +*/ +unsigned int drm_mode_object_read_refcount (struct drm_mode_object *obj) +{ +if (obj->free_cb) +return kref_read (&obj->refcount); + +return 0 ; +} +EXPORT_SYMBOL (drm_mode_object_read_refcount); +/** * drm_object_attach_property - attach a property to a modeset object * @obj: drm modeset object
include/drm/drm_mode_object.h +1 -0
@@ -123,6 +123,7 @@ struct drm_mode_object *drm_mode_object_find(struct drm_device *dev, uint32_t id, uint32_t type);void drm_mode_object_get (struct drm_mode_object *obj);void drm_mode_object_put (struct drm_mode_object *obj); +unsigned int drm_mode_object_read_refcount (struct drm_mode_object *obj); int drm_object_property_set_value(struct drm_mode_object *obj, struct drm_property *property,
Signature · 1 line
2.34.1
PATCH v3 4/4 drm/connector: warn when cleaning up a refcounted connector
In reply to Luca CeresoliCalling drm_connector_cleanup() should only be done via the free_cb => .destroy path, which cleans up the struct drm_connector only when the refcount drops to zero.
A cleanup done with a refcount higher than 0 can result from buggy code, e.g. by doing cleanup directly in the drivers teardown code. Serious trouble can happen if this happens, so warn about it.
--- drivers/gpu/drm/drm_connector.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpu/drm/drm_connector.c +6 -0
@@ -624,6 +624,12 @@ void drm_connector_cleanup(struct drm_connector *connector)struct drm_device *dev = connector->dev;struct drm_display_mode *mode, *t; +/* +* Cleanup must happen when the last ref is put, via the +* drm_connector_free() callback. +*/ +WARN_ON (drm_mode_object_read_refcount (&connector->base) !=0 ); +/* The connector should have been removed from userspace long before * it is finally destroyed. */
Signature · 1 line
2.34.1