[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v8 03/13] xen/arm: gic-v3: tolerate retained redistributor LPI state across CPU_OFF


  • To: Luca Fancellu <Luca.Fancellu@xxxxxxx>
  • From: Mykola Kvach <xakep.amatop@xxxxxxxxx>
  • Date: Tue, 5 May 2026 09:06:15 +0300
  • Arc-authentication-results: i=1; mx.google.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=DFFOXtk38hAz46vOIiuiR5vJQlqZM0Bfd9SfSoYLs4g=; fh=uAzoxIkY79cy0zES8IqO07ArU7DBG3jlr2bg4XRVkR0=; b=SWHTs1g4sIDS5pKb7SCGPOc7UoiFxjCN2rRK33qML9eKZOVCUZliFm0asuQm/oy7/I uQsOzrKG2pjPsRpJI6pv0N1eq6lCA/Ijn+1+jGBz02R7JoieEVaD4iSaYMk+F0hb6djo X9Qrvv/cj41hJDFFbGEY4pJ3SXxmhPrm2AuEeJt3YXKWcrorz1HzqQ8dA8gtXvHlAF62 WcnZnnk29PC8+ALBbSTcogogafufq9LsKjx61RdnjtuNz+P9cmQo11s26LhMeJgR5Mpz qMP8Dfd+dGSEv++rPZp8fA8nF4HijzOHnI3jwIL+x566fmHj3hCe0GCvA+K+DfAO3J02 bN0w==; darn=lists.xenproject.org
  • Arc-seal: i=1; a=rsa-sha256; t=1777961187; cv=none; d=google.com; s=arc-20240605; b=XpTyLF2KJKHRVwWxqw3smaGi6u0N0Spf4zgXOySrm08f9qhxNXx4grSwHIifoqGyx/ fnhPPJmKJ4Yyb/ixEp6svNb/HYidR9T1G4TMu0pzONgvyHD3+fDI/PpRvcYNIWLf6aNm wyA7A5BRWTOQQaBUA+0jq0AuJuWAT1/V5/5s9qNQucL2ApvWWFEBz97d3Zf6sdmlZGn7 v36zAqCfz8Iza6RMOvY76jIkgUXMFp5Tl6VzmtzCYI2rQHX5+4Gk5U1BNYo1lGi1N04+ aAkFEOusjNhCjpQ+uL2NESvGt8qWZWxP7WYLSnH+UB4nWtXR4VmQnWuJj+QgXJRELbGv alaw==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References:MIME-Version"
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Mykola Kvach <mykola_kvach@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Tue, 05 May 2026 06:06:38 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hi Luca,

Thank you for the review.

On Wed, Apr 22, 2026 at 6:57 PM Luca Fancellu <Luca.Fancellu@xxxxxxx> wrote:
>
> Hi Mykola,
>
> > +
> > +static int gicv3_lpi_disable_lpis(void __iomem *rdist_base)
> > +{
> > +    uint32_t reg = readl_relaxed(rdist_base + GICR_CTLR);
> > +    int ret;
> > +
> > +    if ( !(reg & GICR_CTLR_ENABLE_LPIS) )
> > +        return 0;
> > +
> > +    writel_relaxed(reg & ~GICR_CTLR_ENABLE_LPIS, rdist_base + GICR_CTLR);
> > +
> > +    /*
> > +     * The spec only guarantees programmability when we have observed the 
> > bit
> > +     * cleared. Where clearing is supported, RWP must reach 0 before 
> > touching
> > +     * PROPBASER/PENDBASER again.
> > +     */
> > +    wmb();
> > +
> > +    ret = gicv3_do_wait_for_rwp(rdist_base);
>
> I’m looking into the implementation of gicv3_do_wait_for_rwp() and I see
> it’s polling on bit 31 (UWP) instead of bit 3 (RWP)?
>
> Not related to this patch but I feel we need to raise this.

Good catch, thanks.

UWP does have SGI-related semantics, but it is not the same as redistributor
RWP. The existing helper is used as an RWP wait helper after redistributor
register writes, so the redistributor path should poll GICR_CTLR.RWP rather
than GICR_CTLR.UWP.

I will send a separate prerequisite patch to make the redistributor
path use GICR_CTLR_RWP.

>
> > +    if ( ret )
> > +        return ret;
> > +
> > +    reg = readl_relaxed(rdist_base + GICR_CTLR);
> > +    if ( reg & GICR_CTLR_ENABLE_LPIS )
> > +        return -EBUSY;
> > +
> > +    return 0;
> > +}
> > +
> > /*
> >  * Tell a redistributor about the (shared) property table, allocating one
> >  * if not already done.
> > @@ -373,7 +434,21 @@ int gicv3_lpi_init_rdist(void __iomem * rdist_base)
> >     /* Make sure LPIs are disabled before setting up the tables. */
> >     reg = readl_relaxed(rdist_base + GICR_CTLR);
> >     if ( reg & GICR_CTLR_ENABLE_LPIS )
> > -        return -EBUSY;
> > +    {
> > +        if ( gicv3_lpi_tables_match(rdist_base) )
> > +            return -EBUSY;
> > +
> > +        ret = gicv3_lpi_disable_lpis(rdist_base);
> > +        if ( ret == -EBUSY )
> > +        {
> > +            printk(XENLOG_ERR
> > +                   "GICv3: CPU%d: LPIs still enabled with unexpected 
> > redistributor tables\n",
> > +                   smp_processor_id());
> > +            return -EINVAL;
> > +        }
> > +        if ( ret )
> > +            return ret;
> > +    }
> >
> >     ret = gicv3_lpi_set_pendtable(rdist_base);
> >     if ( ret )
> > diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c
> > index bc07f97c16..34fb065afc 100644
> > --- a/xen/arch/arm/gic-v3.c
> > +++ b/xen/arch/arm/gic-v3.c
> > @@ -274,8 +274,8 @@ static void gicv3_enable_sre(void)
> >     isb();
> > }
> >
> > -/* Wait for completion of a distributor change */
> > -static void gicv3_do_wait_for_rwp(void __iomem *base)
> > +/* Wait for completion of a distributor/redistributor write-pending 
> > change. */
> > +int gicv3_do_wait_for_rwp(void __iomem *base)
> > {
> >     uint32_t val;
> >     bool timeout = false;
> > @@ -295,17 +295,22 @@ static void gicv3_do_wait_for_rwp(void __iomem *base)
> >     } while ( 1 );
> >
> >     if ( timeout )
> > +    {
> >         dprintk(XENLOG_ERR, "RWP timeout\n");
> > +        return -ETIMEDOUT;
> > +    }
> > +
> > +    return 0;
> > }
> >
> > static void gicv3_dist_wait_for_rwp(void)
> > {
> > -    gicv3_do_wait_for_rwp(GICD);
> > +    (void)gicv3_do_wait_for_rwp(GICD);
> > }
> >
> > static void gicv3_redist_wait_for_rwp(void)
> > {
> > -    gicv3_do_wait_for_rwp(GICD_RDIST_BASE);
> > +    (void)gicv3_do_wait_for_rwp(GICD_RDIST_BASE);
> > }
> >
> > static void gicv3_wait_for_rwp(int irq)
> > @@ -925,7 +930,7 @@ static int __init gicv3_populate_rdist(void)
> >                     gicv3_set_redist_address(rdist_addr, procnum);
> >
> >                     ret = gicv3_lpi_init_rdist(ptr);
> > -                    if ( ret && ret != -ENODEV )
> > +                    if ( ret && ret != -ENODEV && ret != -EBUSY )
> >                     {
> >                         printk("GICv3: CPU%d: Cannot initialize LPIs: %u\n”,
>
> This should be the other way around? %u for smp_processor_id() and %d for ret?

You're right, thanks. I will fix the format string.

>
> >                                smp_processor_id(), ret);
> > diff --git a/xen/arch/arm/include/asm/gic_v3_its.h 
> > b/xen/arch/arm/include/asm/gic_v3_its.h
> > index fc5a84892c..081bd19180 100644
> > --- a/xen/arch/arm/include/asm/gic_v3_its.h
> > +++ b/xen/arch/arm/include/asm/gic_v3_its.h
>
> Why this header and not gic.h?

You're right, this prototype is not ITS-specific. I will move it to gic.h.

Best regards,
Mykola

>
> > @@ -133,6 +133,7 @@ struct host_its {
> >
> > /* Map a collection for this host CPU to each host ITS. */
> > int gicv3_its_setup_collection(unsigned int cpu);
> > +int gicv3_do_wait_for_rwp(void __iomem *base);
> >
> > #ifdef CONFIG_HAS_ITS
> >
> >
>
> The rest looks ok to me!
>
> Cheers,
> Luca
>
>
>



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.