All of lore.kernel.org
 help / color / mirror / Atom feed
From: Maxime Ripard <maxime@cerno.tech>
To: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Cc: dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org,
	linux-renesas-soc@vger.kernel.org,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>,
	Ulrich Hecht <uli+renesas@fpond.eu>
Subject: Re: [PATCH v5 09/10] drm: rcar-du: Perform group setup from the atomic tail handler
Date: Fri, 26 Mar 2021 15:37:15 +0100	[thread overview]
Message-ID: <20210326143715.tpk4o62xgjvigefe@gilmour> (raw)
In-Reply-To: <20210322163535.1090570-10-kieran.bingham+renesas@ideasonboard.com>

[-- Attachment #1: Type: text/plain, Size: 2026 bytes --]

Hi Kieran,

On Mon, Mar 22, 2021 at 04:35:34PM +0000, Kieran Bingham wrote:
> Create rcar_du_group_atomic_check() and rcar_du_group_atomic_setup()
> functions to track and apply group state through the DRM atomic state.
> The use_count field is moved from the rcar_du_group structure to an
> enabled field in the rcar_du_group_state structure.
> 
> This allows separating group setup from the configuration of the CRTCs
> that are part of the group, simplifying the CRTC code and improving
> overall readability. The existing rcar_du_group_{get,put}() functions
> are now redundant and removed.
> 
> The groups share clocking with the CRTCs within the group, and so are
> accessible only when one of its CRTCs has been powered through
> rcar_du_crtc_atomic_exit_standby().
> 
> Reviewed-by: Ulrich Hecht <uli+renesas@fpond.eu>
> Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

It's a bit weird to have both your and Laurent's SoB without a
Co-Developped-By or an authorship from him.

However, using a drm_private_obj shared between CRTC has a gotcha: you
don't have any ordering guarantee between commits if they affect
different CRTCs (and they are non-blocking).

Let's assume we have two subsequent commits, commit1 and commit2, both
non-blocking, and affecting different CRTC, plane and connectors. In
this case, commit1 old private state will be commit0 new private state,
and commit 2 old private state will be commit1 new private state.

If commit2 is executed before commit1, then it will free its old state
when done with it (so commit1 new private state), and will thus result
in an use-after-free when commit1 is ran.

In order to fix this, you should store (and get a reference to) the
drm_crtc_commit in your private state in atomic_commit_setup, and call
drm_crtc_commit_wait on that commit as the first part of your
commit_tail to serialize those commits.

Maxime

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Maxime Ripard <maxime@cerno.tech>
To: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Cc: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>,
	dri-devel@lists.freedesktop.org,
	linux-renesas-soc@vger.kernel.org,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Ulrich Hecht <uli+renesas@fpond.eu>,
	linux-media@vger.kernel.org
Subject: Re: [PATCH v5 09/10] drm: rcar-du: Perform group setup from the atomic tail handler
Date: Fri, 26 Mar 2021 15:37:15 +0100	[thread overview]
Message-ID: <20210326143715.tpk4o62xgjvigefe@gilmour> (raw)
In-Reply-To: <20210322163535.1090570-10-kieran.bingham+renesas@ideasonboard.com>


[-- Attachment #1.1: Type: text/plain, Size: 2026 bytes --]

Hi Kieran,

On Mon, Mar 22, 2021 at 04:35:34PM +0000, Kieran Bingham wrote:
> Create rcar_du_group_atomic_check() and rcar_du_group_atomic_setup()
> functions to track and apply group state through the DRM atomic state.
> The use_count field is moved from the rcar_du_group structure to an
> enabled field in the rcar_du_group_state structure.
> 
> This allows separating group setup from the configuration of the CRTCs
> that are part of the group, simplifying the CRTC code and improving
> overall readability. The existing rcar_du_group_{get,put}() functions
> are now redundant and removed.
> 
> The groups share clocking with the CRTCs within the group, and so are
> accessible only when one of its CRTCs has been powered through
> rcar_du_crtc_atomic_exit_standby().
> 
> Reviewed-by: Ulrich Hecht <uli+renesas@fpond.eu>
> Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

It's a bit weird to have both your and Laurent's SoB without a
Co-Developped-By or an authorship from him.

However, using a drm_private_obj shared between CRTC has a gotcha: you
don't have any ordering guarantee between commits if they affect
different CRTCs (and they are non-blocking).

Let's assume we have two subsequent commits, commit1 and commit2, both
non-blocking, and affecting different CRTC, plane and connectors. In
this case, commit1 old private state will be commit0 new private state,
and commit 2 old private state will be commit1 new private state.

If commit2 is executed before commit1, then it will free its old state
when done with it (so commit1 new private state), and will thus result
in an use-after-free when commit1 is ran.

In order to fix this, you should store (and get a reference to) the
drm_crtc_commit in your private state in atomic_commit_setup, and call
drm_crtc_commit_wait on that commit as the first part of your
commit_tail to serialize those commits.

Maxime

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2021-03-26 14:38 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-22 16:35 [PATCH v5 00/10] drm: rcar-du: Rework CRTC and groups for atomic commits Kieran Bingham
2021-03-22 16:35 ` Kieran Bingham
2021-03-22 16:35 ` [PATCH v5 01/10] media: vsp1: drm: Split vsp1_du_setup_lif() Kieran Bingham
2021-03-22 16:35   ` Kieran Bingham
2021-03-22 16:35 ` [PATCH v5 02/10] media: vsp1: drm: Don't configure hardware when the pipeline is disabled Kieran Bingham
2021-03-22 16:35   ` Kieran Bingham
2021-03-22 16:35 ` [PATCH v5 03/10] drm: rcar-du: Convert to the new VSP atomic API Kieran Bingham
2021-03-22 16:35   ` Kieran Bingham
2021-03-22 16:35 ` [PATCH v5 04/10] media: vsp1: drm: Remove vsp1_du_setup_lif() Kieran Bingham
2021-03-22 16:35   ` Kieran Bingham
2021-03-22 16:35 ` [PATCH v5 05/10] drm: rcar-du: Handle CRTC standby from commit tail handler Kieran Bingham
2021-03-22 16:35   ` Kieran Bingham
2021-03-22 16:35 ` [PATCH v5 06/10] drm: rcar-du: Handle CRTC configuration " Kieran Bingham
2021-03-22 16:35   ` Kieran Bingham
2021-03-22 16:35 ` [PATCH v5 07/10] drm: rcar-du: Provide for_each_group helper Kieran Bingham
2021-03-22 16:35   ` Kieran Bingham
2021-03-22 16:35 ` [PATCH v5 08/10] drm: rcar-du: Create a group state object Kieran Bingham
2021-03-22 16:35   ` Kieran Bingham
2021-03-22 16:35 ` [PATCH v5 09/10] drm: rcar-du: Perform group setup from the atomic tail handler Kieran Bingham
2021-03-22 16:35   ` Kieran Bingham
2021-03-26 14:37   ` Maxime Ripard [this message]
2021-03-26 14:37     ` Maxime Ripard
2021-03-22 16:35 ` [PATCH v5 10/10] drm: rcar-du: Centralise routing configuration in commit " Kieran Bingham
2021-03-22 16:35   ` Kieran Bingham

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=20210326143715.tpk4o62xgjvigefe@gilmour \
    --to=maxime@cerno.tech \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kieran.bingham+renesas@ideasonboard.com \
    --cc=laurent.pinchart+renesas@ideasonboard.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=uli+renesas@fpond.eu \
    /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.