From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Imre Deak <imre.deak@intel.com>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH v2 11/12] drm/i915: Factor out a helper for handling atomic modeset locks/state
Date: Thu, 4 May 2023 18:00:06 +0300 [thread overview]
Message-ID: <ZFPIdiJxRLyteyud@intel.com> (raw)
In-Reply-To: <20230503231048.432368-12-imre.deak@intel.com>
On Thu, May 04, 2023 at 02:10:47AM +0300, Imre Deak wrote:
> This patch simplifying the handling of modeset locks and atomic state
> for an atomic commit is based on
>
> https://lore.kernel.org/all/20210715184954.7794-2-ville.syrjala@linux.intel.com/
>
> adding the helper to i915. I find this approach preferrable than
> open-coding the corresponding steps (fixed for me an atomic
> state reset during a DEADLK retry, which I missed in the open-coded
> version) and also better than the existing
> DRM_MODESET_LOCK_ALL_BEGIN/END macros for the reasons described in the
> above original patchset.
>
> This change takes the helper into use only for atomic commits during DDI
> hotplug handling, as a preparation for a follow-up patch adding a
> similar commit started from the same spot. Other places doing a
> driver-internal atomic commit is to be converted by a follow-up
> patchset.
>
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Signed-off-by: Imre Deak <imre.deak@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
> drivers/gpu/drm/i915/Makefile | 1 +
> drivers/gpu/drm/i915/display/intel_ddi.c | 17 ++-----
> .../gpu/drm/i915/display/intel_modeset_lock.c | 50 +++++++++++++++++++
> .../gpu/drm/i915/display/intel_modeset_lock.h | 33 ++++++++++++
> 4 files changed, 87 insertions(+), 14 deletions(-)
> create mode 100644 drivers/gpu/drm/i915/display/intel_modeset_lock.c
> create mode 100644 drivers/gpu/drm/i915/display/intel_modeset_lock.h
>
> diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
> index 9af76e376ca91..ef6feb2aad2ad 100644
> --- a/drivers/gpu/drm/i915/Makefile
> +++ b/drivers/gpu/drm/i915/Makefile
> @@ -263,6 +263,7 @@ i915-y += \
> display/intel_hti.o \
> display/intel_load_detect.o \
> display/intel_lpe_audio.o \
> + display/intel_modeset_lock.o \
> display/intel_modeset_verify.o \
> display/intel_modeset_setup.o \
> display/intel_overlay.o \
> diff --git a/drivers/gpu/drm/i915/display/intel_ddi.c b/drivers/gpu/drm/i915/display/intel_ddi.c
> index 55f36d9d509c6..eb391fff0f1be 100644
> --- a/drivers/gpu/drm/i915/display/intel_ddi.c
> +++ b/drivers/gpu/drm/i915/display/intel_ddi.c
> @@ -63,6 +63,7 @@
> #include "intel_hti.h"
> #include "intel_lspcon.h"
> #include "intel_mg_phy_regs.h"
> +#include "intel_modeset_lock.h"
> #include "intel_pps.h"
> #include "intel_psr.h"
> #include "intel_quirks.h"
> @@ -4400,26 +4401,14 @@ intel_ddi_hotplug(struct intel_encoder *encoder,
>
> state = intel_encoder_hotplug(encoder, connector);
>
> - drm_modeset_acquire_init(&ctx, 0);
> -
> - for (;;) {
> + intel_modeset_lock_ctx_retry(&ctx, NULL, 0, ret) {
> if (connector->base.connector_type == DRM_MODE_CONNECTOR_HDMIA)
> ret = intel_hdmi_reset_link(encoder, &ctx);
> else
> ret = intel_dp_retrain_link(encoder, &ctx);
> -
> - if (ret == -EDEADLK) {
> - drm_modeset_backoff(&ctx);
> - continue;
> - }
> -
> - break;
> }
>
> - drm_modeset_drop_locks(&ctx);
> - drm_modeset_acquire_fini(&ctx);
> - drm_WARN(encoder->base.dev, ret,
> - "Acquiring modeset locks failed with %i\n", ret);
> + drm_WARN_ON(encoder->base.dev, ret);
>
> /*
> * Unpowered type-c dongles can take some time to boot and be
> diff --git a/drivers/gpu/drm/i915/display/intel_modeset_lock.c b/drivers/gpu/drm/i915/display/intel_modeset_lock.c
> new file mode 100644
> index 0000000000000..8fb6fd849a75d
> --- /dev/null
> +++ b/drivers/gpu/drm/i915/display/intel_modeset_lock.c
> @@ -0,0 +1,50 @@
> +// SPDX-License-Identifier: MIT
> +/*
> + * Copyright © 2023 Intel Corporation
> + */
> +
> +#include <drm/drm_modeset_lock.h>
> +
> +#include "intel_display_types.h"
> +#include "intel_modeset_lock.h"
> +
> +void _intel_modeset_lock_begin(struct drm_modeset_acquire_ctx *ctx,
> + struct intel_atomic_state *state,
> + unsigned int flags, int *ret)
> +{
> + drm_modeset_acquire_init(ctx, flags);
> +
> + if (state)
> + state->base.acquire_ctx = ctx;
> +
> + *ret = -EDEADLK;
> +}
> +
> +bool _intel_modeset_lock_loop(int *ret)
> +{
> + if (*ret == -EDEADLK) {
> + *ret = 0;
> + return true;
> + }
> +
> + return false;
> +}
> +
> +void _intel_modeset_lock_end(struct drm_modeset_acquire_ctx *ctx,
> + struct intel_atomic_state *state,
> + int *ret)
> +{
> + if (*ret == -EDEADLK) {
> + if (state)
> + drm_atomic_state_clear(&state->base);
> +
> + *ret = drm_modeset_backoff(ctx);
> + if (*ret == 0) {
> + *ret = -EDEADLK;
> + return;
> + }
> + }
> +
> + drm_modeset_drop_locks(ctx);
> + drm_modeset_acquire_fini(ctx);
> +}
> diff --git a/drivers/gpu/drm/i915/display/intel_modeset_lock.h b/drivers/gpu/drm/i915/display/intel_modeset_lock.h
> new file mode 100644
> index 0000000000000..edb5099bcd99c
> --- /dev/null
> +++ b/drivers/gpu/drm/i915/display/intel_modeset_lock.h
> @@ -0,0 +1,33 @@
> +/* SPDX-License-Identifier: MIT */
> +/*
> + * Copyright © 2023 Intel Corporation
> + */
> +
> +#ifndef __INTEL_MODESET_LOCK_H__
> +#define __INTEL_MODESET_LOCK_H__
> +
> +#include <linux/types.h>
> +
> +struct drm_modeset_acquire_ctx;
> +struct intel_atomic_state;
> +
> +void _intel_modeset_lock_begin(struct drm_modeset_acquire_ctx *ctx,
> + struct intel_atomic_state *state,
> + unsigned int flags,
> + int *ret);
> +bool _intel_modeset_lock_loop(int *ret);
> +void _intel_modeset_lock_end(struct drm_modeset_acquire_ctx *ctx,
> + struct intel_atomic_state *state,
> + int *ret);
> +
> +/*
> + * Note that one must always use "continue" rather than
> + * "break" or "return" to handle errors within the
> + * intel_modeset_lock_ctx_retry() block.
> + */
> +#define intel_modeset_lock_ctx_retry(ctx, state, flags, ret) \
> + for (_intel_modeset_lock_begin((ctx), (state), (flags), &(ret)); \
> + _intel_modeset_lock_loop(&(ret)); \
> + _intel_modeset_lock_end((ctx), (state), &(ret)))
> +
> +#endif /* __INTEL_MODESET_LOCK_H__ */
> --
> 2.37.2
--
Ville Syrjälä
Intel
next prev parent reply other threads:[~2023-05-04 15:02 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-03 23:10 [Intel-gfx] [PATCH v2 00/12] drm/i915/tc: Add a workaround for an IOM/TCSS firmware hang issue Imre Deak
2023-05-03 23:10 ` [Intel-gfx] [PATCH v2 01/12] drm/i915: Fix PIPEDMC disabling for a bigjoiner configuration Imre Deak
2023-05-04 14:39 ` Ville Syrjälä
2023-05-03 23:10 ` [Intel-gfx] [PATCH v2 02/12] drm/i915: Make the CRTC state consistent during sanitize-disabling Imre Deak
2023-05-04 14:38 ` Ville Syrjälä
2023-05-04 17:08 ` Imre Deak
2023-05-05 20:46 ` [Intel-gfx] [PATCH v3 " Imre Deak
2023-05-09 14:45 ` Ville Syrjälä
2023-05-09 18:28 ` Imre Deak
2023-05-03 23:10 ` [Intel-gfx] [PATCH v2 03/12] drm/i915: Update connector atomic state before crtc sanitize-disabling Imre Deak
2023-05-04 14:42 ` Ville Syrjälä
2023-05-03 23:10 ` [Intel-gfx] [PATCH v2 04/12] drm/i915: Separate intel_crtc_disable_noatomic_begin/complete() Imre Deak
2023-05-04 17:15 ` Ville Syrjälä
2023-05-05 20:46 ` [Intel-gfx] [PATCH v3 " Imre Deak
2023-05-03 23:10 ` [Intel-gfx] [PATCH v2 05/12] drm/i915: Factor out set_encoder_for_connector() Imre Deak
2023-05-04 14:48 ` Ville Syrjälä
2023-05-05 20:46 ` [Intel-gfx] [PATCH v3 " Imre Deak
2023-05-03 23:10 ` [Intel-gfx] [PATCH v2 06/12] drm/i915: Add support for disabling any CRTCs during HW readout/sanitization Imre Deak
2023-05-04 17:15 ` Ville Syrjälä
2023-05-04 20:29 ` Imre Deak
2023-05-05 20:46 ` [Intel-gfx] [PATCH v3 " Imre Deak
2023-05-03 23:10 ` [Intel-gfx] [PATCH v2 07/12] drm/i915/dp: Add link training debug and error printing helpers Imre Deak
2023-05-04 14:53 ` Ville Syrjälä
2023-05-05 8:51 ` Jani Nikula
2023-05-05 12:07 ` Imre Deak
2023-05-05 20:46 ` [Intel-gfx] [PATCH v3 " Imre Deak
2023-05-03 23:10 ` [Intel-gfx] [PATCH v2 08/12] drm/i915/dp: Convert link training error to debug message on disconnected sink Imre Deak
2023-05-04 14:54 ` Ville Syrjälä
2023-05-05 8:22 ` Govindapillai, Vinod
2023-05-05 12:12 ` Imre Deak
2023-05-05 20:46 ` [Intel-gfx] [PATCH v3 " Imre Deak
2023-05-09 12:26 ` Govindapillai, Vinod
2023-05-03 23:10 ` [Intel-gfx] [PATCH v2 09/12] drm/i915/dp: Prevent link training fallback on disconnected port Imre Deak
2023-05-04 14:54 ` Ville Syrjälä
2023-05-05 20:46 ` [Intel-gfx] [PATCH v3 " Imre Deak
2023-05-09 12:26 ` Govindapillai, Vinod
2023-05-03 23:10 ` [Intel-gfx] [PATCH v2 10/12] drm/i915/dp: Factor out intel_dp_get_active_pipes() Imre Deak
2023-05-04 14:55 ` Ville Syrjälä
2023-05-03 23:10 ` [Intel-gfx] [PATCH v2 11/12] drm/i915: Factor out a helper for handling atomic modeset locks/state Imre Deak
2023-05-04 15:00 ` Ville Syrjälä [this message]
2023-05-03 23:10 ` [Intel-gfx] [PATCH v2 12/12] drm/i915/tc: Reset TypeC PHYs left enabled in DP-alt mode after the sink disconnects Imre Deak
2023-05-04 17:41 ` Ville Syrjälä
2023-05-04 20:12 ` Imre Deak
2023-05-05 20:46 ` [Intel-gfx] [PATCH v3 " Imre Deak
2023-05-05 22:12 ` Imre Deak
2023-05-04 0:21 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915/tc: Add a workaround for an IOM/TCSS firmware hang issue (rev2) Patchwork
2023-05-04 0:21 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2023-05-04 0:32 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2023-05-04 2:54 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork
2023-05-05 21:59 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915/tc: Add a workaround for an IOM/TCSS firmware hang issue (rev10) Patchwork
2023-05-05 21:59 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2023-05-05 22:13 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2023-05-06 16:34 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZFPIdiJxRLyteyud@intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=imre.deak@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.