The hardware state readout is useful, but might need to be disabled in case of bugs, or its checks relaxed during development when not all hooks are implemented yet.
Add a module parameter to control the readout behavior: it can be disabled entirely, or the checks for missing compare or readout hooks can be skipped independently. Suggested-by: Simona Vetter <[email protected]> Reviewed-by: Simona Vetter <[email protected]> Reviewed-by: Maarten Lankhorst <[email protected]> Reviewed-by: Tomi Valkeinen <[email protected]> Signed-off-by: Maxime Ripard <[email protected]> --- Documentation/admin-guide/kernel-parameters.txt | 12 ++++++++++ drivers/gpu/drm/drm_atomic_state_readout.c | 31 +++++++++++++++++++++++++ include/drm/drm_atomic_state_readout.h | 13 +++++++++++ 3 files changed, 56 insertions(+) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 0b3c140babd9..59ff44c49f31 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -1375,10 +1375,22 @@ Kernel parameters the EDID name. Each connector may use a unique EDID data set by separating the files with a comma. An EDID data set with no connector name will be used for any connectors not explicitly specified. + drm.atomic_readout= [DRM] + Control the KMS atomic hardware state readout + (SRO), used to initialize the atomic state from + the state the firmware left the hardware in at + boot instead of programming a new one. + 0: disable the state readout entirely, + 1: enable it (default), + 2: ignore the objects missing a comparison + implementation, + 3: ignore the objects missing a readout or + comparison implementation. + dscc4.setup= [NET] dt_cpu_ftrs= [PPC,EARLY] Format: {"off" | "known"} Control how the dt_cpu_ftrs device-tree binding is diff --git a/drivers/gpu/drm/drm_atomic_state_readout.c b/drivers/gpu/drm/drm_atomic_state_readout.c index dc9e1cbfe0d8..dab47fef6672 100644 --- a/drivers/gpu/drm/drm_atomic_state_readout.c +++ b/drivers/gpu/drm/drm_atomic_state_readout.c @@ -12,10 +12,41 @@ #include <linux/sched/mm.h> #include "drm_internal.h" #include "drm_crtc_internal.h" +unsigned int drm_atomic_sro_status = DRM_ATOMIC_SRO_ENABLED; +EXPORT_SYMBOL(drm_atomic_sro_status); + +module_param_named_unsafe(atomic_readout, drm_atomic_sro_status, uint, 0400); +MODULE_PARM_DESC(atomic_readout, + "Enable Hardware State Readout (0 = disabled, 1 = enabled, 2 = ignore missing compares, 3 = ignore missing readouts and compares, default = 1)"); + +/** + * drm_atomic_sro_device_can_readout - check if a device supports hardware state readout + * @dev: DRM device to check + * + * Verifies that the device is an atomic driver, that readout is + * enabled, and that all KMS objects implement the relevant hooks. + * + * RETURNS: + * + * True if the device supports full hardware state readout, false + * otherwise. + */ +bool drm_atomic_sro_device_can_readout(struct drm_device *dev) +{ + if (!drm_drv_uses_atomic_modeset(dev)) + return false; + + if (drm_atomic_sro_status == DRM_ATOMIC_SRO_DISABLED) + return false; + + return true; +} +EXPORT_SYMBOL(drm_atomic_sro_device_can_readout); + static unsigned int max_connector_index(struct drm_device *dev) { struct drm_connector_list_iter conn_iter; struct drm_connector *connector; unsigned int max = 0; diff --git a/include/drm/drm_atomic_state_readout.h b/include/drm/drm_atomic_state_readout.h index 4b1a92291cc1..bbed8e8dccf0 100644 --- a/include/drm/drm_atomic_state_readout.h +++ b/include/drm/drm_atomic_state_readout.h @@ -1,10 +1,12 @@ /* SPDX-License-Identifier: GPL-2.0-or-later */ #ifndef DRM_ATOMIC_SRO_H_ #define DRM_ATOMIC_SRO_H_ +#include <linux/types.h> + struct drm_connector; struct drm_connector_state; struct drm_crtc; struct drm_crtc_state; struct drm_device; @@ -12,10 +14,21 @@ struct drm_plane; struct drm_plane_state; struct drm_printer; struct drm_private_obj; struct drm_private_state; +enum drm_atomic_sro_status_values { + DRM_ATOMIC_SRO_DISABLED = 0, + DRM_ATOMIC_SRO_ENABLED, + DRM_ATOMIC_SRO_SKIP_MISSING_COMPARE, + DRM_ATOMIC_SRO_SKIP_MISSING_READOUT, +}; + +extern unsigned int drm_atomic_sro_status; + +bool drm_atomic_sro_device_can_readout(struct drm_device *dev); + /** * struct __drm_atomic_sro_plane - plane entry of a &struct drm_atomic_sro_state */ struct __drm_atomic_sro_plane { /** -- 2.56.1
