From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org,
"Liviu Dudau" <liviu.dudau@arm.com>,
"Russell King" <linux@armlinux.org.uk>,
"Inki Dae" <inki.dae@samsung.com>,
"Patrik Jakobsson" <patrik.r.jakobsson@gmail.com>,
"Alain Volmat" <alain.volmat@foss.st.com>,
"Sandy Huang" <hjc@rock-chips.com>,
"Jyri Sarha" <jyri.sarha@iki.fi>,
"Alexey Brodkin" <abrodkin@synopsys.com>,
"Hans de Goede" <hdegoede@redhat.com>,
"Maíra Canal" <mairacanal@riseup.net>,
"Zack Rusin" <zack.rusin@broadcom.com>,
amd-gfx@lists.freedesktop.org,
linux-mediatek@lists.infradead.org,
linux-amlogic@lists.infradead.org, linux-arm-msm@vger.kernel.org,
freedreno@lists.freedesktop.org, nouveau@lists.freedesktop.org,
virtualization@lists.linux.dev,
spice-devel@lists.freedesktop.org,
linux-renesas-soc@vger.kernel.org,
xen-devel@lists.xenproject.org
Subject: Re: [PATCH 2/2] drm: Move crtc->{x, y, mode, enabled} to legacy sub-structure
Date: Thu, 3 Oct 2024 18:29:10 +0300 [thread overview]
Message-ID: <Zv64RktMPv2rpCZf@intel.com> (raw)
In-Reply-To: <Zv6zN7Go_XG44P2-@louis-chauvet-laptop>
On Thu, Oct 03, 2024 at 05:07:35PM +0200, Louis Chauvet wrote:
>
> > > > diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c
> > > > index a40295c18b48..780681ea77e4 100644
> > > > --- a/drivers/gpu/drm/vkms/vkms_crtc.c
> > > > +++ b/drivers/gpu/drm/vkms/vkms_crtc.c
> > > > @@ -64,7 +64,7 @@ static int vkms_enable_vblank(struct drm_crtc *crtc)
> > > > struct drm_vblank_crtc *vblank = drm_crtc_vblank_crtc(crtc);
> > > > struct vkms_output *out = drm_crtc_to_vkms_output(crtc);
> > > >
> > > > - drm_calc_timestamping_constants(crtc, &crtc->mode);
> > > > + drm_calc_timestamping_constants(crtc, &crtc->legacy.mode);
> > >
> > > drm_calc_timestamping_constants(crtc, &crtc->state->mode);
> >
> > This one doesn't look safe. You want to call that during your atomic
> > commit already.
> >
>
> This was already not safe with the previous implementation? Or it is only
> unsafe because now I use state->mode instead of legacy.mode?
Yeah, if you want to look at obj->state then you need the corresponding
lock.
obj->state is also not necessarily the correct state you want because
a parallel commit could have already swapped in a new state but the
hardware is still on the old state.
Basically 99.9% of code should never even look at obj->state, and
instead should always use the for_each_new_<obj>_in_state()
and drm_atomic_get_new_<obj>_state() stuff. Currently that is a
pipe dream though because a lot of drivers haven't been fixed to
do things properly. If we ever manage to fix everything then we
could remove the stall hacks from drm_atomic_helper_swap_state()
and allow a commit pipeline of arbitrary length.
>
> After inspecting the code, I think I don't need to call it as:
>
> In `vkms_atomic_commit_tail` (used in
> `@vkms_mode_config_helpers.atomic_commit_tail`), we call
> `drm_atomic_helper_commit_modeset_disables`, which call
> `drm_atomic_helper_calc_timestamping_constants` which call
> `drm_calc_timestamping_constants` for every CRTC.
Slightly odd place for it, but I think that's just because it was
originally part of drm_atomic_helper_update_legacy_modeset_state()
and I didn't bother looking for a better home for it when I split
it out. But seems like it should work fine as is.
>
> I tested kms_vblank, all of them are SUCCESS/SKIP, do you know other tests
> that can trigger bugs?
You would explicitly have to race commits against vblank_enable.
Could of course sprinkle sleep()s around to widen the race window
if you're really keen to hit it.
--
Ville Syrjälä
Intel
next prev parent reply other threads:[~2024-10-03 15:29 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-02 18:21 [PATCH 0/2] drm: Treewide plane/crtc legacy state sweeping Ville Syrjala
2024-10-02 18:22 ` [PATCH 2/2] drm: Move crtc->{x,y,mode,enabled} to legacy sub-structure Ville Syrjala
2024-10-03 12:38 ` [PATCH 2/2] drm: Move crtc->{x, y, mode, enabled} " Louis Chauvet
2024-10-03 13:46 ` Ville Syrjälä
2024-10-03 15:07 ` Louis Chauvet
2024-10-03 15:29 ` Ville Syrjälä [this message]
2024-10-03 15:45 ` Louis Chauvet
2024-10-25 7:46 ` [PATCH 0/2] drm: Treewide plane/crtc legacy state sweeping Ville Syrjälä
2024-10-25 9:54 ` Dmitry Baryshkov
2024-10-25 9:59 ` Jani Nikula
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=Zv64RktMPv2rpCZf@intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=abrodkin@synopsys.com \
--cc=alain.volmat@foss.st.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=freedreno@lists.freedesktop.org \
--cc=hdegoede@redhat.com \
--cc=hjc@rock-chips.com \
--cc=inki.dae@samsung.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jyri.sarha@iki.fi \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=liviu.dudau@arm.com \
--cc=mairacanal@riseup.net \
--cc=nouveau@lists.freedesktop.org \
--cc=patrik.r.jakobsson@gmail.com \
--cc=spice-devel@lists.freedesktop.org \
--cc=virtualization@lists.linux.dev \
--cc=xen-devel@lists.xenproject.org \
--cc=zack.rusin@broadcom.com \
/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;
as well as URLs for NNTP newsgroup(s).