[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: Mykola Kvach <xakep.amatop@xxxxxxxxx>
  • From: Luca Fancellu <Luca.Fancellu@xxxxxxx>
  • Date: Wed, 22 Apr 2026 15:55:46 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 4.158.2.129) smtp.rcpttodomain=gmail.com smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=arm.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com])
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3kl2PJjm4E4GfCJMlcRyVjQlDYOWo6koetR9ZTlZFnI=; b=VSwtjXLL2nlYKIAjj9FhDblVWOZGao3I8tJENBU1bHh5LeHFhiLjxqUXnqGUFvgMYA3Nf1HsQjcizPSfd168cnLP9YJwYTOYw49e0tOPEC35Yh7htPTIrgbxqEu8peMhjrFvv/GcEwuW3yN+lFCPya6kNDpQfcejOMqIHcQjdcDeCZXokPrzNkR+iZiujyxwosyUIp3PuV+la1rMtmENqpsSjQyAu5tncXZtFFE/vXYUm+61s607XWDtrp96a8ohNKYhjTagIOoT/1QjawgX+1SnIjv64IHFdIrwmjkgS3hssEJrgqdwp2r+WfEhByHvQ64jfzjNCn1rXW/Npo6/3g==
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3kl2PJjm4E4GfCJMlcRyVjQlDYOWo6koetR9ZTlZFnI=; b=hmnT/klqULNHQw/0vayJY6DTgou9SE+46qRfXwDLw0+OsGIFrm7vp79hJrMjGvTvoPjGQy0cl3qDvUozrcIbgmXEhqi7fNZLpifEb9vFXvTNxIZW1PZV6885l62JGYDhl6aKtPO+CvvjtnsymugtVY33FZYaLoOn0cBk+o8iW+QTNbQrZn8/DJMb6aePl3wr25E+/M8gDzt2Q4UBLOkxtQ2i/h8pSH/ZDxqqHWjsQvaTpHS86CpkR0x9CiQ+duNUOEsMd6Vg2VmQNStf0DC5EqRDtuHm1Hr4RWYI/qLXkRLccFPvVz9dnfiBD4rA4zfmK6wWQMBzKoLNtfcrVBOp1Q==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=R6Is/nUdAqUevF5TEn5Ga8mLBEXHh4nA+mciOS7fh9ZpzgWw+2YMId8rXbF0f73WILmGp3IGy7sJV+/kgTfUWalnqfi90YJYA/FRXTAFSwXM1hDBsqpsZTFEoRffjqKhhfjvljWQgnVBBcEMEMhEnlfbbIMZ6fBPKN2c5BgKdYim8Ot28En60XUtyqZJgvpwsjtxJMEpSoD5Mu9HjdJBjorXK/EgKBsWiVwqzE7265YsGMw7GpK7NOH+ajXB7L1l2zuDc6FFEQhYCTBd76ZgVLJT9vG0ITLBdneD18fMiJsXxzEOfEznidpM2hXPEd584QKm+ih18DY0H7XVt1WGsg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XK1cQ0DyGEREA2c5G6f8GkXHxZTpY9P2M/JsAgD/eGoLfpiWAZB3LzHlggpKcPEkQhtzkBVBDUTcPwQEEdqJaPPM5Z3W5lk41U1pMpEslwoU3MIJmaKf60jmf731gBBBR4r5sSlL1ELcNpEmGKmVbqmyEjbRU3yvmYCJyLrlGaK/a3tGafCbC8P+myT0tpQRFY9Yfnr7OKeXBITihSmxmJ6iAN4y1c8oSoL+4rM0MPiQV4ZwC5TzLEO6p39h8yHSW/2sERPOoi8V5Y8QRbidclpTUN6exrE3r9NnVgDu1cTNwzO+DaImRuI3pkCvdF1N0kekP2DtqUQqBuRWBAO/Yw==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=arm.com header.i="@arm.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"; dkim=pass header.s=selector1 header.d=arm.com header.i="@arm.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • 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: Wed, 22 Apr 2026 15:57:12 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Thread-index: AQHc0nB7rI/mApm2xEOwE7P+RDE1mQ==
  • Thread-topic: [PATCH v8 03/13] xen/arm: gic-v3: tolerate retained redistributor LPI state across CPU_OFF

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.

> +    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?

>                                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?

> @@ -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®.