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]> Signed-off-by: Maxime Ripard <[email protected]> --- Documentation/admin-guide/kernel-parameters.txt | 12 ++++++++++ drivers/gpu/drm/drm_atomic_state_readout.c | 29 +++++++++++++++++++++++++ include/drm/drm_atomic_state_readout.h | 11 ++++++++++ 3 files changed, 52 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 c00631800234..b8ca4cbbc5b2 100644 --- a/drivers/gpu/drm/drm_atomic_state_readout.c +++ b/drivers/gpu/drm/drm_atomic_state_readout.c @@ -12,10 +12,39 @@ #include <linux/sched/mm.h> #include "drm_internal.h" #include "drm_crtc_internal.h" +static unsigned int atomic_readout = DRM_ATOMIC_READOUT_ENABLED; +module_param_unsafe(atomic_readout, 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 (atomic_readout == DRM_ATOMIC_READOUT_DISABLED) + return false; + + return true; +} +EXPORT_SYMBOL(drm_atomic_sro_device_can_readout); + struct __drm_atomic_sro_plane { struct drm_plane *ptr; struct drm_plane_state *state; }; diff --git a/include/drm/drm_atomic_state_readout.h b/include/drm/drm_atomic_state_readout.h index 5a9333a05796..65d45ca4be76 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_atomic_sro_state; struct drm_connector; struct drm_connector_state; struct drm_crtc; struct drm_crtc_state; @@ -13,10 +15,19 @@ struct drm_plane; struct drm_plane_state; struct drm_printer; struct drm_private_obj; struct drm_private_state; +enum drm_atomic_readout_status { + DRM_ATOMIC_READOUT_DISABLED = 0, + DRM_ATOMIC_READOUT_ENABLED, + DRM_ATOMIC_READOUT_SKIP_MISSING_COMPARE, + DRM_ATOMIC_READOUT_SKIP_MISSING_READOUT, +}; + +bool drm_atomic_sro_device_can_readout(struct drm_device *dev); + struct drm_atomic_sro_state *drm_atomic_sro_state_alloc(struct drm_device *dev); void drm_atomic_sro_state_free(struct drm_atomic_sro_state *state); void drm_atomic_sro_state_print(const struct drm_atomic_sro_state *state, struct drm_printer *p); -- 2.56.1
