Devicetree
 help / color / mirror / Atom feed
From: Mikko Perttunen <mperttunen@nvidia.com>
To: devicetree@vger.kernel.org
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Thierry Reding <thierry.reding@kernel.org>,
	Jonathan Hunter <jonathanh@nvidia.com>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Jessica Zhang <jesszhan0024@gmail.com>,
	devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org,
	linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org,
	Svyatoslav Ryhel <clamor95@gmail.com>
Subject: Re: [PATCH v8 09/12] drm/tegra: Convert to use atomic versions of drm_encoder_helper_funcs
Date: Mon, 30 Nov 2026 12:00:26 +0900	[thread overview]
Message-ID: <7MvGXNT0TAGXvBavVSuwWQ@nvidia.com> (raw)
In-Reply-To: <CAPVz0n1Q85nGx3Aa1Vc8sxsX7cVdMqzk_G5R+5XMaMrLotQC-w@mail.gmail.com>

On Friday, November 27, 2026 10:47 PM Svyatoslav Ryhel wrote:
> пт, 27 лист. 2026 р. о 11:17 Svyatoslav Ryhel <clamor95@gmail.com> пише:
> >
> > пт, 27 лист. 2026 р. о 07:24 Mikko Perttunen <mperttunen@nvidia.com> пише:
> > >
> > > On Sunday, November 22, 2026 5:18 PM Svyatoslav Ryhel wrote:
> > > > Switch to using the atomic versions of the enable() and disable()
> > > > operations.
> > > >
> > > > This is required for acquiring the next bridge state without causing
> > > > crashes, in order to properly set up the encoder.
> > >
> > > This is a bit vague. I'd make an explicit reference to RGB needing
> > > access to the bridge state, which is not possible with the non-atomic
> > > functions, and then explaining that DSI / HDMI / SOR are converted for
> > > consistency.
> > >
> >
> > Noted
> >
> > > >
> > > > Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> > > > ---
> > > >  drivers/gpu/drm/tegra/dsi.c  | 20 +++++++++++++++-----
> > > >  drivers/gpu/drm/tegra/hdmi.c | 20 +++++++++++++++-----
> > > >  drivers/gpu/drm/tegra/rgb.c  | 23 +++++++++++++++++------
> > > >  drivers/gpu/drm/tegra/sor.c  | 18 +++++++++++++-----
> > > >  4 files changed, 60 insertions(+), 21 deletions(-)
> > > >
> > > > diff --git a/drivers/gpu/drm/tegra/dsi.c b/drivers/gpu/drm/tegra/dsi.c
> > > > index 6d6adc485e51e..cd61070072beb 100644
> > > > --- a/drivers/gpu/drm/tegra/dsi.c
> > > > +++ b/drivers/gpu/drm/tegra/dsi.c
> > > > @@ -855,7 +855,8 @@ static void tegra_dsi_unprepare(struct tegra_dsi *dsi)
> > > >               dev_err(dsi->dev, "failed to suspend: %d\n", err);
> > > >  }
> > > >
> > > > -static void tegra_dsi_encoder_disable(struct drm_encoder *encoder)
> > > > +static void tegra_dsi_encoder_disable(struct drm_encoder *encoder,
> > > > +                                   struct drm_atomic_commit *comm_state)
> > > >  {
> > > >       struct tegra_output *output = encoder_to_output(encoder);
> > > >       struct tegra_dc *dc = to_tegra_dc(encoder->crtc);
> > > > @@ -919,16 +920,25 @@ static int tegra_dsi_prepare(struct tegra_dsi *dsi)
> > > >       return 0;
> > > >  }
> > > >
> > > > -static void tegra_dsi_encoder_enable(struct drm_encoder *encoder)
> > > > +static void tegra_dsi_encoder_enable(struct drm_encoder *encoder,
> > > > +                                  struct drm_atomic_commit *comm_state)
> > > >  {
> > > > -     struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode;
> > > >       struct tegra_output *output = encoder_to_output(encoder);
> > > >       struct tegra_dc *dc = to_tegra_dc(encoder->crtc);
> > > > +     struct drm_connector_state *conn_state;
> > > >       struct tegra_dsi *dsi = to_dsi(output);
> > > > +     struct drm_crtc_state *crtc_state;
> > > > +     struct drm_connector *connector;
> > > >       struct tegra_dsi_state *state;
> > > > +     struct drm_display_mode *mode;
> > > >       u32 value;
> > > >       int err;
> > > >
> > > > +     connector = drm_atomic_get_new_connector_for_encoder(comm_state, encoder);
> > > > +     conn_state = drm_atomic_get_new_connector_state(comm_state, connector);
> > > > +     crtc_state = drm_atomic_get_new_crtc_state(comm_state, conn_state->crtc);
> > > > +     mode = &crtc_state->adjusted_mode;
> > > > +
> > > >       err = tegra_dsi_prepare(dsi);
> > > >       if (err < 0) {
> > > >               dev_err(dsi->dev, "failed to prepare: %d\n", err);
> > >
> > > The function also uses encoder->crtc and tegra_dsi_get_state. Should
> > > these be changed to conn_state->crtc and to_dsi_state(conn_state)?
> > >
> > > Similarly for HDMI / SOR.
> > >
> >
> > I must have missed that. Good catch
> >
> 
> encoder->crtc into conn_state->crtc is pretty straight forward, but
> tegra_dsi_get_state() is more obscure to me, how should I approach it?

tegra_dsi_get_state() just calls to_dsi_state() which converts a struct 
drm_connector_state * into a struct tegra_dsi_state *; we have a struct 
drm_connector_state * from calling drm_atomic_get_new_connector_state(), 
so I think we can just call to_dsi_state() on that.

We should also pass the struct tegra_dsi_state * into dsi_configure() so 
it doesn't need to call tegra_dsi_get_state() either.

> 
> > > > @@ -1059,8 +1069,8 @@ static const struct drm_encoder_funcs tegra_dsi_encoder_funcs = {
> > > >  };
> > > >
> > > >  static const struct drm_encoder_helper_funcs tegra_dsi_encoder_helper_funcs = {
> > > > -     .disable = tegra_dsi_encoder_disable,
> > > > -     .enable = tegra_dsi_encoder_enable,
> > > > +     .atomic_disable = tegra_dsi_encoder_disable,
> > > > +     .atomic_enable = tegra_dsi_encoder_enable,
> > > >       .atomic_check = tegra_dsi_encoder_atomic_check,
> > > >  };
> > > >
> > > > diff --git a/drivers/gpu/drm/tegra/hdmi.c b/drivers/gpu/drm/tegra/hdmi.c
> > > > index e8c4347f09e69..a78279810dd82 100644
> > > > --- a/drivers/gpu/drm/tegra/hdmi.c
> > > > +++ b/drivers/gpu/drm/tegra/hdmi.c
> > > > @@ -1166,7 +1166,8 @@ tegra_hdmi_connector_helper_funcs = {
> > > >       .mode_valid = tegra_hdmi_connector_mode_valid,
> > > >  };
> > > >
> > > > -static void tegra_hdmi_encoder_disable(struct drm_encoder *encoder)
> > > > +static void tegra_hdmi_encoder_disable(struct drm_encoder *encoder,
> > > > +                                    struct drm_atomic_commit *comm_state)
> > > >  {
> > > >       struct tegra_output *output = encoder_to_output(encoder);
> > > >       struct tegra_dc *dc = to_tegra_dc(encoder->crtc);
> > > > @@ -1209,18 +1210,27 @@ static void tegra_hdmi_encoder_disable(struct drm_encoder *encoder)
> > > >               dev_err(hdmi->dev, "failed to suspend: %d\n", err);
> > > >  }
> > > >
> > > > -static void tegra_hdmi_encoder_enable(struct drm_encoder *encoder)
> > > > +static void tegra_hdmi_encoder_enable(struct drm_encoder *encoder,
> > > > +                                   struct drm_atomic_commit *comm_state)
> > > >  {
> > > > -     struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode;
> > > >       unsigned int h_sync_width, h_front_porch, h_back_porch, i, rekey;
> > > >       struct tegra_output *output = encoder_to_output(encoder);
> > > >       struct tegra_dc *dc = to_tegra_dc(encoder->crtc);
> > > >       struct tegra_hdmi *hdmi = to_hdmi(output);
> > > > +     struct drm_connector_state *conn_state;
> > > > +     struct drm_crtc_state *crtc_state;
> > > >       unsigned int pulse_start, div82;
> > > > +     struct drm_connector *connector;
> > > > +     struct drm_display_mode *mode;
> > > >       int retries = 1000;
> > > >       u32 value;
> > > >       int err;
> > > >
> > > > +     connector = drm_atomic_get_new_connector_for_encoder(comm_state, encoder);
> > > > +     conn_state = drm_atomic_get_new_connector_state(comm_state, connector);
> > > > +     crtc_state = drm_atomic_get_new_crtc_state(comm_state, conn_state->crtc);
> > > > +     mode = &crtc_state->adjusted_mode;
> > > > +
> > > >       err = host1x_client_resume(&hdmi->client);
> > > >       if (err < 0) {
> > > >               dev_err(hdmi->dev, "failed to resume: %d\n", err);
> > > > @@ -1460,8 +1470,8 @@ tegra_hdmi_encoder_atomic_check(struct drm_encoder *encoder,
> > > >  }
> > > >
> > > >  static const struct drm_encoder_helper_funcs tegra_hdmi_encoder_helper_funcs = {
> > > > -     .disable = tegra_hdmi_encoder_disable,
> > > > -     .enable = tegra_hdmi_encoder_enable,
> > > > +     .atomic_disable = tegra_hdmi_encoder_disable,
> > > > +     .atomic_enable = tegra_hdmi_encoder_enable,
> > > >       .atomic_check = tegra_hdmi_encoder_atomic_check,
> > > >  };
> > > >
> > > > diff --git a/drivers/gpu/drm/tegra/rgb.c b/drivers/gpu/drm/tegra/rgb.c
> > > > index 227a178f761bd..d48d498068ac8 100644
> > > > --- a/drivers/gpu/drm/tegra/rgb.c
> > > > +++ b/drivers/gpu/drm/tegra/rgb.c
> > > > @@ -90,7 +90,8 @@ static void tegra_dc_write_regs(struct tegra_dc *dc,
> > > >               tegra_dc_writel(dc, table[i].value, table[i].offset);
> > > >  }
> > > >
> > > > -static void tegra_rgb_encoder_disable(struct drm_encoder *encoder)
> > > > +static void tegra_rgb_encoder_disable(struct drm_encoder *encoder,
> > > > +                                   struct drm_atomic_commit *state)
> > > >  {
> > > >       struct tegra_output *output = encoder_to_output(encoder);
> > > >       struct tegra_rgb *rgb = to_rgb(output);
> > > > @@ -99,12 +100,22 @@ static void tegra_rgb_encoder_disable(struct drm_encoder *encoder)
> > > >       tegra_dc_commit(rgb->dc);
> > > >  }
> > > >
> > > > -static void tegra_rgb_encoder_enable(struct drm_encoder *encoder)
> > > > +static void tegra_rgb_encoder_enable(struct drm_encoder *encoder,
> > > > +                                  struct drm_atomic_commit *state)
> > > >  {
> > > > -     struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode;
> > > >       struct tegra_output *output = encoder_to_output(encoder);
> > > >       struct tegra_rgb *rgb = to_rgb(output);
> > > > -     u32 value;
> > > > +     struct drm_connector_state *conn_state;
> > > > +     struct drm_crtc_state *crtc_state;
> > > > +     struct drm_connector *connector;
> > > > +     struct drm_display_mode *mode;
> > > > +     u32 bus_flags, value;
> > > > +
> > > > +     /* Get mode flags */
> > > > +     connector = drm_atomic_get_new_connector_for_encoder(state, encoder);
> > > > +     conn_state = drm_atomic_get_new_connector_state(state, connector);
> > > > +     crtc_state = drm_atomic_get_new_crtc_state(state, conn_state->crtc);
> > > > +     mode = &crtc_state->adjusted_mode;
> > > >
> > > >       tegra_dc_write_regs(rgb->dc, rgb_enable, ARRAY_SIZE(rgb_enable));
> > > >
> > > > @@ -201,8 +212,8 @@ static const struct drm_encoder_funcs tegra_rgb_encoder_funcs = {
> > > >  };
> > > >
> > > >  static const struct drm_encoder_helper_funcs tegra_rgb_encoder_helper_funcs = {
> > > > -     .disable = tegra_rgb_encoder_disable,
> > > > -     .enable = tegra_rgb_encoder_enable,
> > > > +     .atomic_disable = tegra_rgb_encoder_disable,
> > > > +     .atomic_enable = tegra_rgb_encoder_enable,
> > > >       .atomic_check = tegra_rgb_encoder_atomic_check,
> > > >  };
> > > >
> > > > diff --git a/drivers/gpu/drm/tegra/sor.c b/drivers/gpu/drm/tegra/sor.c
> > > > index ebac9068b670f..45a9ea94c4355 100644
> > > > --- a/drivers/gpu/drm/tegra/sor.c
> > > > +++ b/drivers/gpu/drm/tegra/sor.c
> > > > @@ -2203,7 +2203,8 @@ static void tegra_sor_hdmi_scdc_start(struct tegra_sor *sor)
> > > >       }
> > > >  }
> > > >
> > > > -static void tegra_sor_hdmi_disable(struct drm_encoder *encoder)
> > > > +static void tegra_sor_hdmi_disable(struct drm_encoder *encoder,
> > > > +                                struct drm_atomic_commit *comm_state)
> > > >  {
> > > >       struct tegra_output *output = encoder_to_output(encoder);
> > > >       struct tegra_dc *dc = to_tegra_dc(encoder->crtc);
> > > > @@ -2244,13 +2245,17 @@ static void tegra_sor_hdmi_disable(struct drm_encoder *encoder)
> > > >       host1x_client_suspend(&sor->client);
> > > >  }
> > > >
> > > > -static void tegra_sor_hdmi_enable(struct drm_encoder *encoder)
> > > > +static void tegra_sor_hdmi_enable(struct drm_encoder *encoder,
> > > > +                               struct drm_atomic_commit *comm_state)
> > > >  {
> > > >       struct tegra_output *output = encoder_to_output(encoder);
> > > >       unsigned int h_ref_to_sync = 1, pulse_start, max_ac;
> > > >       struct tegra_dc *dc = to_tegra_dc(encoder->crtc);
> > > >       struct tegra_sor_hdmi_settings *settings;
> > > > +     struct drm_connector_state *conn_state;
> > > >       struct tegra_sor *sor = to_sor(output);
> > > > +     struct drm_crtc_state *crtc_state;
> > > > +     struct drm_connector *connector;
> > > >       struct tegra_sor_state *state;
> > > >       struct drm_display_mode *mode;
> > > >       unsigned long rate, pclk;
> > > > @@ -2259,7 +2264,10 @@ static void tegra_sor_hdmi_enable(struct drm_encoder *encoder)
> > > >       int err;
> > > >
> > > >       state = to_sor_state(output->connector.state);
> > > > -     mode = &encoder->crtc->state->adjusted_mode;
> > > > +     connector = drm_atomic_get_new_connector_for_encoder(comm_state, encoder);
> > > > +     conn_state = drm_atomic_get_new_connector_state(comm_state, connector);
> > > > +     crtc_state = drm_atomic_get_new_crtc_state(comm_state, conn_state->crtc);
> > > > +     mode = &crtc_state->adjusted_mode;
> > > >       pclk = mode->clock * 1000;
> > > >
> > > >       err = host1x_client_resume(&sor->client);
> > > > @@ -2657,8 +2665,8 @@ static void tegra_sor_hdmi_enable(struct drm_encoder *encoder)
> > > >  }
> > > >
> > > >  static const struct drm_encoder_helper_funcs tegra_sor_hdmi_helpers = {
> > > > -     .disable = tegra_sor_hdmi_disable,
> > > > -     .enable = tegra_sor_hdmi_enable,
> > > > +     .atomic_disable = tegra_sor_hdmi_disable,
> > > > +     .atomic_enable = tegra_sor_hdmi_enable,
> > > >       .atomic_check = tegra_sor_encoder_atomic_check,
> > > >  };
> > > >
> > > > --
> > > > 2.53.0
> > > >
> > > >
> > >
> > >
> > >
> > >





  reply	other threads:[~2026-11-30  3:00 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-22  8:18 [PATCH v8 00/12] drm/tegra: Add support for Tegra20/Tegra30 8-bit CPU interface Svyatoslav Ryhel
2026-11-22  8:18 ` [PATCH v8 01/12] drm: Add MIPI DBI bus support for MIPI DBI Type A and B Svyatoslav Ryhel
2026-11-27  4:16   ` Mikko Perttunen
2026-11-27  9:06     ` Svyatoslav Ryhel
2026-11-27 12:14       ` Mikko Perttunen
2026-11-27 13:05         ` Svyatoslav Ryhel
2026-11-22  8:18 ` [PATCH v8 02/12] drm/panel: panel-hitachi-tx10d07vm0baa: Convert to use MIPI DBI bus Svyatoslav Ryhel
2026-11-27  4:23   ` Mikko Perttunen
2026-11-27  9:10     ` Svyatoslav Ryhel
2026-11-27 12:16       ` Mikko Perttunen
2026-11-27 13:08         ` Svyatoslav Ryhel
2026-11-22  8:18 ` [PATCH v8 03/12] drm/panel: panel-hitachi-tx10d07vm0baa: Convert to mipi_dbi_write_seq_multi() Svyatoslav Ryhel
2026-11-27  4:40   ` Mikko Perttunen
2026-11-22  8:18 ` [PATCH v8 04/12] drm/panel: panel-lg-lh400wv3: Convert to use MIPI DBI bus Svyatoslav Ryhel
2026-11-22  8:18 ` [PATCH v8 05/12] drm/panel: panel-lg-lh400wv3: Convert to mipi_dbi_write_seq_multi() Svyatoslav Ryhel
2026-11-27  4:40   ` Mikko Perttunen
2026-11-22  8:18 ` [PATCH v8 06/12] drm/tegra: dc: Add elements required by Tegra MIPI DBI Svyatoslav Ryhel
2026-11-27  4:56   ` Mikko Perttunen
2026-11-27  9:16     ` Svyatoslav Ryhel
2026-11-22  8:18 ` [PATCH v8 07/12] dt-bindings: display: tegra: Document Tegra20 DSI port Svyatoslav Ryhel
2026-11-22  8:18 ` [PATCH v8 08/12] drm/tegra: output: Make panel parsing configurable Svyatoslav Ryhel
2026-11-27  5:01   ` Mikko Perttunen
2026-11-22  8:18 ` [PATCH v8 09/12] drm/tegra: Convert to use atomic versions of drm_encoder_helper_funcs Svyatoslav Ryhel
2026-11-27  5:24   ` Mikko Perttunen
2026-11-27  9:17     ` Svyatoslav Ryhel
2026-11-27 13:47       ` Svyatoslav Ryhel
2026-11-30  3:00         ` Mikko Perttunen [this message]
2026-11-22  8:18 ` [PATCH v8 10/12] drm/tegra: rgb: Parameterize configuration based on bus flags Svyatoslav Ryhel
2026-11-27  6:22   ` Mikko Perttunen
2026-11-27  9:21     ` Svyatoslav Ryhel
2026-11-27  9:41       ` Svyatoslav Ryhel
2026-11-27 12:26         ` Mikko Perttunen
2026-11-28  7:55           ` Svyatoslav Ryhel
2026-11-30  2:49             ` Mikko Perttunen
2026-11-27 12:35       ` Mikko Perttunen
2026-11-27 13:21         ` Svyatoslav Ryhel
2026-11-28  1:28           ` Mikko Perttunen
2026-11-28  7:53             ` Svyatoslav Ryhel
2026-11-30  2:37               ` Mikko Perttunen
2026-11-22  8:18 ` [PATCH v8 11/12] dt-bindings: display: tegra: Document 8-bit CPU parallel interface Svyatoslav Ryhel
2026-11-22  8:18 ` [PATCH v8 12/12] drm/tegra: Add support for 8-bit CPU interface Svyatoslav Ryhel
2026-11-22  8:43   ` sashiko-bot

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=7MvGXNT0TAGXvBavVSuwWQ@nvidia.com \
    --to=mperttunen@nvidia.com \
    --cc=airlied@gmail.com \
    --cc=clamor95@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jesszhan0024@gmail.com \
    --cc=jonathanh@nvidia.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=robh@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=thierry.reding@kernel.org \
    --cc=tzimmermann@suse.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox