drm/connector: demote connector force-probes for non-master clients

Force-probing a connector can be slow and cause flickering. As this
affects the global KMS state, let's make it so only the DRM master
can force-probe a connector.

Non-master DRM clients won't be able to force-probe a connector
anymore. Instead, KMS will perform a regular read-only connector
query.

Signed-off-by: Simon Ser <contact@emersion.fr>
Acked-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20210402112212.5625-1-contact@emersion.fr
This commit is contained in:
Simon Ser 2021-04-02 13:22:12 +02:00
parent 4aae79f77e
commit 8f86c82aba
2 changed files with 12 additions and 6 deletions

View File

@ -20,6 +20,7 @@
* OF THIS SOFTWARE. * OF THIS SOFTWARE.
*/ */
#include <drm/drm_auth.h>
#include <drm/drm_connector.h> #include <drm/drm_connector.h>
#include <drm/drm_edid.h> #include <drm/drm_edid.h>
#include <drm/drm_encoder.h> #include <drm/drm_encoder.h>
@ -2376,9 +2377,13 @@ int drm_mode_getconnector(struct drm_device *dev, void *data,
mutex_lock(&dev->mode_config.mutex); mutex_lock(&dev->mode_config.mutex);
if (out_resp->count_modes == 0) { if (out_resp->count_modes == 0) {
connector->funcs->fill_modes(connector, if (drm_is_current_master(file_priv))
dev->mode_config.max_width, connector->funcs->fill_modes(connector,
dev->mode_config.max_height); dev->mode_config.max_width,
dev->mode_config.max_height);
else
drm_dbg_kms(dev, "User-space requested a forced probe on [CONNECTOR:%d:%s] but is not the DRM master, demoting to read-only probe",
connector->base.id, connector->name);
} }
out_resp->mm_width = connector->display_info.width_mm; out_resp->mm_width = connector->display_info.width_mm;

View File

@ -413,9 +413,10 @@ enum drm_mode_subconnector {
* *
* **Force-probing a connector** * **Force-probing a connector**
* *
* If the @count_modes field is set to zero, the kernel will perform a forced * If the @count_modes field is set to zero and the DRM client is the current
* probe on the connector to refresh the connector status, modes and EDID. * DRM master, the kernel will perform a forced probe on the connector to
* A forced-probe can be slow, might cause flickering and the ioctl will block. * refresh the connector status, modes and EDID. A forced-probe can be slow,
* might cause flickering and the ioctl will block.
* *
* User-space needs to force-probe connectors to ensure their metadata is * User-space needs to force-probe connectors to ensure their metadata is
* up-to-date at startup and after receiving a hot-plug event. User-space * up-to-date at startup and after receiving a hot-plug event. User-space