From: "Hogander, Jouni" <jouni.hogander@intel.com>
To: "intel-gfx@lists.freedesktop.org"
<intel-gfx@lists.freedesktop.org>,
"Coelho, Luciano" <luciano.coelho@intel.com>
Cc: "intel-xe@lists.freedesktop.org" <intel-xe@lists.freedesktop.org>,
"Vivi, Rodrigo" <rodrigo.vivi@intel.com>
Subject: Re: [Intel-xe] [Intel-gfx] [PATCH v7] drm/i915: handle uncore spinlock when not available
Date: Thu, 7 Dec 2023 10:15:47 +0000 [thread overview]
Message-ID: <453db3046eb434d8860479e1c35c8548b578870a.camel@intel.com> (raw)
In-Reply-To: <1f378d699c11cbc577d7843fc4277681b3aa8c49.camel@intel.com>
On Thu, 2023-12-07 at 09:30 +0000, Coelho, Luciano wrote:
> On Thu, 2023-12-07 at 08:24 +0000, Hogander, Jouni wrote:
> > On Fri, 2023-12-01 at 12:00 +0200, Luca Coelho wrote:
> > > The uncore code may not always be available (e.g. when we build
> > > the
> > > display code with Xe), so we can't always rely on having the
> > > uncore's
> > > spinlock.
> > >
> > > To handle this, split the spin_lock/unlock_irqsave/restore() into
> > > spin_lock/unlock() followed by a call to local_irq_save/restore()
> > > and
> > > create wrapper functions for locking and unlocking the uncore's
> > > spinlock. In these functions, we have a condition check and only
> > > actually try to lock/unlock the spinlock when I915 is defined,
> > > and
> > > thus uncore is available.
> > >
> > > This keeps the ifdefs contained in these new functions and all
> > > such
> > > logic inside the display code.
> > >
> > > Cc: Tvrtko Ursulin <tvrto.ursulin@intel.com>
> > > Cc: Jani Nikula <jani.nikula@intel.com>
> > > Cc: Ville Syrjala <ville.syrjala@linux.intel.com>
> > > Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> > > Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
> > > ---
> > >
> > >
> > > In v2:
> > >
> > > * Renamed uncore_spin_*() to intel_spin_*()
> > > * Corrected the order: save, lock, unlock, restore
> > >
> > > In v3:
> > >
> > > * Undid the change to pass drm_i915_private instead of the
> > > lock
> > > itself, since we would have to include i915_drv.h and that
> > > pulls
> > > in a truckload of other includes.
> > >
> > > In v4:
> > >
> > > * After a brief attempt to replace this with a different
> > > patch,
> > > we're back to this one;
> > > * Pass drm_i195_private again, and move the functions to
> > > intel_vblank.c, so we don't need to include i915_drv.h in a
> > > header file and it's already included in intel_vblank.c;
> > >
> > > In v5:
> > >
> > > * Remove stray include in intel_display.h;
> > > * Remove unnecessary inline modifiers in the new functions.
> > >
> > > In v6:
> > >
> > > * Just removed the umlauts from Ville's name, because
> > > patchwork
> > > didn't catch my patch and I suspect it was some UTF-8
> > > confusion.
> > >
> > > In v7:
> > >
> > > * Add __acquires()/__releases() annotation to resolve sparse
> > > warnings.
> > >
> > > drivers/gpu/drm/i915/display/intel_vblank.c | 51
> > > +++++++++++++++++--
> > > --
> > > 1 file changed, 41 insertions(+), 10 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/i915/display/intel_vblank.c
> > > b/drivers/gpu/drm/i915/display/intel_vblank.c
> > > index 2cec2abf9746..fe256bf7b485 100644
> > > --- a/drivers/gpu/drm/i915/display/intel_vblank.c
> > > +++ b/drivers/gpu/drm/i915/display/intel_vblank.c
> > > @@ -265,6 +265,32 @@ int intel_crtc_scanline_to_hw(struct
> > > intel_crtc
> > > *crtc, int scanline)
> > > return (scanline + vtotal - crtc->scanline_offset) %
> > > vtotal;
> > > }
> > >
> > > +/*
> > > + * The uncore version of the spin lock functions is used to
> > > decide
> > > + * whether we need to lock the uncore lock or not. This is only
> > > + * needed in i915, not in Xe.
> > > + *
> > > + * This lock in i915 is needed because some old platforms (at
> > > least
> > > + * IVB and possibly HSW as well), which are not supported in Xe,
> > > need
> > > + * all register accesses to the same cacheline to be serialized,
> > > + * otherwise they may hang.
> > > + */
> > > +static void intel_vblank_section_enter(struct drm_i915_private
> > > *i915)
> > > + __acquires(i915->uncore.lock)
> > > +{
> > > +#ifdef I915
> > > + spin_lock(&i915->uncore.lock);
> > > +#endif
> > > +}
> > > +
> > > +static void intel_vblank_section_exit(struct drm_i915_private
> > > *i915)
> > > + __releases(i915->uncore.lock)
> > > +{
> > > +#ifdef I915
> > > + spin_unlock(&i915->uncore.lock);
> > > +#endif
> > > +}
> > > +
> >
> > Why don't you move these into gpu/drm/i915/intel_uncore.c/h? Then
> > you
> > could have empty defines/functions for these in gpu/drm/xe/compat-
> > i915-
> > headers/intel_uncore.h. That way you don't need these ifdefs. If
> > you
> > move them as I proposed you should rename them as well.
>
> We already went forth and back with this for some time. In the end
> we
> agreed that this is not related to uncore directly, so we decided to
> keep it here.
>
> We also agreed that I'll make a follow-up patch where it won't be
> only
> the lock that will be handled by this, but also enabling/disabling
> interrupts, which doesn't have anything to do with uncore, thus the
> name of the function.
Thank you Luca for the patch. This is now pushed to drm-intel-next.
BR,
Jouni Högander
>
>
> --
> Cheers,
> Luca.
next prev parent reply other threads:[~2023-12-07 10:15 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-01 10:00 [Intel-xe] [PATCH v7] drm/i915: handle uncore spinlock when not available Luca Coelho
2023-12-01 10:19 ` [Intel-xe] ✗ CI.Patch_applied: failure for drm/i915: handle uncore spinlock when not available (rev5) Patchwork
2023-12-07 8:24 ` [Intel-xe] [Intel-gfx] [PATCH v7] drm/i915: handle uncore spinlock when not available Hogander, Jouni
2023-12-07 9:30 ` Coelho, Luciano
2023-12-07 10:02 ` Hogander, Jouni
2023-12-07 10:15 ` Hogander, Jouni [this message]
2024-01-24 8:34 ` Sebastian Andrzej Siewior
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=453db3046eb434d8860479e1c35c8548b578870a.camel@intel.com \
--to=jouni.hogander@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=luciano.coelho@intel.com \
--cc=rodrigo.vivi@intel.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