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

Re: [PATCH v9 02/13] xen/arm: gic-v2: Implement GIC suspend/resume functions


  • To: Luca Fancellu <Luca.Fancellu@xxxxxxx>
  • From: Mykola Kvach <xakep.amatop@xxxxxxxxx>
  • Date: Sun, 17 May 2026 21:19:25 +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=YyolJmAcUVh+sm7ixV7LFL/JAxTKpQ9xmGSvTegaVz8=; fh=uAzoxIkY79cy0zES8IqO07ArU7DBG3jlr2bg4XRVkR0=; b=Cy08y5H35zL4BtABNhj6F8FXBtkQseEIg4RU5sy+Y139vlgMzeV+KbilHo1n7mIAe7 nHq8mVCQKubetdCig3grC+jpJhEdkJL10q6HSz7c5uGtzLk5OEPG5Z5HoWWWCpQMCWas I2bsFkedG/igGpT5zuDPJyJQQLWXAW1zSYKEyBv239tYW0o05BjRAsXxxRX3muof23R1 N7prdhUlISvD/dmbSPAWeg18LdmUx/LHo/0t+s5ZkdmvOpificLyQxJgjMLt/t597fKM 1Xl7Xn0Wr21vWK3+vHc8IMFxOfhtbJMo5xkpBm/TFKTYCly4mn+pIVsS/eMWEXBHA/WM 7pVw==; darn=lists.xenproject.org
  • Arc-seal: i=1; a=rsa-sha256; t=1779041977; cv=none; d=google.com; s=arc-20240605; b=flU2q9PuQnkn5+UWUKxmspMkp6OJWVeTccKkcAsMcBkHaxZdjCqvXzHQ5fDxXJ6QtV jr/vnFgxsEXBeD12Y6POEdeDO52wcBIvmSotAJ0WriKtXECL92T75unb74DxiRcolJtT 6uINj49Yp01sr7Vt5OwH6wOmu2S2Xr2vIv99cmEZv1MDPy/BJ0ZOk2RhDICOv+7ZssSg sThTN1o9Gw8rzb324nfJKb0tQKKvGoAwTIt6IHeFu5ILLMAmvEIWFzmZ9fvKXOawJUIu hGmw4+CKfYudCric1EcaOWp8q3Ce9IC65Bpp+OYjPxtFJsURg8+R9pZKWHJ6bvdsdpEm v09A==
  • 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: Sun, 17 May 2026 18:19:46 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Fri, May 15, 2026 at 12:53 PM Luca Fancellu <Luca.Fancellu@xxxxxxx> wrote:
>
> Hi Mykola,
>
> > On 15 May 2026, at 08:59, Mykola Kvach <xakep.amatop@xxxxxxxxx> wrote:
> >
> > Hi Luca,
> >
> > Thank you for the detailed review.
> >
> > On Wed, May 13, 2026 at 5:09 PM Luca Fancellu <Luca.Fancellu@xxxxxxx> wrote:
> >>
> >> Hi Mykola,
> >>
> >>> +
> >>> +static void gicv2_resume(void)
> >>> +{
> >>> +    unsigned int i, blocks = DIV_ROUND_UP(gicv2_info.nr_lines, 32);
> >>> +
> >>> +    gicv2_cpu_disable();
> >>> +    /* Disable distributor */
> >>> +    writel_gicd(0, GICD_CTLR);
> >>> +
> >>> +    for ( i = 0; i < blocks; i++ )
> >>> +    {
> >>> +        struct irq_block *irqs = gic_ctx.dist.irqs + i;
> >>> +        size_t j, off = i * sizeof(irqs->isenabler);
> >>> +
> >>> +        writel_gicd(GENMASK(31, 0), GICD_ICENABLER + off);
> >>> +        writel_gicd(irqs->isenabler, GICD_ISENABLER + off);
> >>> +
> >>> +        writel_gicd(GENMASK(31, 0), GICD_ICACTIVER + off);
> >>> +        writel_gicd(irqs->isactiver, GICD_ISACTIVER + off);
> >>> +
> >>> +        off = i * sizeof(irqs->ipriorityr);
> >>> +        for ( j = 0; j < ARRAY_SIZE(irqs->ipriorityr); j++ )
> >>> +            writel_gicd(irqs->ipriorityr[j], GICD_IPRIORITYR + off + j * 
> >>> 4);
> >>
> >> apologies for spotting these only now, in case gicv2_info.nr_lines is 1020,
> >> here and below for GICD_ITARGETSR we are going to save also IDs 1020-1023
> >> which are reserved.
> >>
> >> Could we assume irqs->ipriorityr and irqs->itargetsr have the same size 
> >> and implement
> >> some cap logic which might cap the last loop (eventually):
> >>
> >>    for ( i = 0; i < blocks; i++ )
> >>    {
> >>        struct irq_block *irqs = gic_ctx.dist.irqs + i;
> >>        size_t j, off = i * sizeof(irqs->isenabler);
> >>        size_t nr_regs = ARRAY_SIZE(irqs->ipriorityr);
> >>
> >>        if ( i == blocks - 1 )
> >>            nr_regs = DIV_ROUND_UP(gicv2_info.nr_lines - i * 32, 4);
> >>
> >>        […]
> >>
> >>        off = i * sizeof(irqs->ipriorityr);
> >>        for ( j = 0; j < nr_regs; j++ )
> >>            writel_gicd(irqs->ipriorityr[j], GICD_IPRIORITYR + off + j * 4);
> >>
> >>        /*
> >>         * GICD_ITARGETSR0..7 cover SGIs/PPIs and hold no state to save:
> >>         * they are read-only on multiprocessor implementations and RAZ/WI
> >>         * on uniprocessor implementations.
> >>         */
> >>        if ( i )
> >>        {
> >>            off = i * sizeof(irqs->itargetsr);
> >>            for ( j = 0; j < nr_regs; j++ )
> >>                writel_gicd(irqs->itargetsr[j], GICD_ITARGETSR + off + j * 
> >> 4);
> >>        }
> >>
> >>        […]
> >>    }
> >
> > This was intentional to keep the logic simpler.
> >
> > For the 1020-interrupt case, the extra word would correspond to
> > interrupt IDs 1020-1023. My reading of ARM IHI 0048B.b is that this
> > is architecturally harmless: section 4.1.2 says that reserved
> > Distributor register addresses are RAZ/WI, and Table 4-1 marks
> > GICD_IPRIORITYR offset 0x7fc and GICD_ITARGETSR offset 0xbfc as
> > Reserved.
> >
> > Would you be OK with keeping this as-is, or would you prefer me to add
> > the cap logic anyway?
>
> I think this would be the only part in the driver that does that, also Linux 
> is avoiding
> to touch these reserved parts
> (https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/irqchip/irq-gic.c?h=v7.1-rc3#n582)
> My preference would be to be consistent.

Ack. I'll add the cap logic.

>
> >
> >>
> >>> +
> >>> +        /*
> >>> +         * GICD_ITARGETSR0..7 cover SGIs/PPIs and hold no state to save:
> >>> +         * they are read-only on multiprocessor implementations and 
> >>> RAZ/WI
> >>> +         * on uniprocessor implementations.
> >>> +         */
> >>> +        if ( i )
> >>> +        {
> >>> +            off = i * sizeof(irqs->itargetsr);
> >>> +            for ( j = 0; j < ARRAY_SIZE(irqs->itargetsr); j++ )
> >>> +                writel_gicd(irqs->itargetsr[j], GICD_ITARGETSR + off + j 
> >>> * 4);
> >>> +        }
> >>> +
> >>> +        off = i * sizeof(irqs->icfgr);
> >>> +        for ( j = 0; j < ARRAY_SIZE(irqs->icfgr); j++ )
> >>> +            writel_gicd(irqs->icfgr[j], GICD_ICFGR + off + j * 4);
> >>
> >> in the GICv2 specs the usage constraints
> >> of GICD_ICFGR says: “Before changing the value of a programmable 
> >> Int_config field,
> >> software must disable the corresponding interrupt, otherwise GIC behavior 
> >> is
> >> UNPREDICTABLE"
> >>
> >> ARM IHI 0048B.b, 4.3.13.
> >>
> >> I think we should move this restore just after GICD_ICENABLER write, 
> >> before writing
> >> GICD_ISENABLER.
> >
> > Good catch, I agree.
> >
> > I will move the GICD_ICFGR restore after the GICD_ICENABLER writes
> > and before restoring GICD_ISENABLER, so that programmable Int_config
> > fields are restored while the corresponding interrupts are disabled.
> >
> > I will also check whether it makes sense to move the other
> > configuration restores before GICD_ISENABLER as well. The spec does
> > not seem to impose the same strict requirement there, but keeping all
> > configuration restores before re-enabling the interrupts might make
> > the ordering clearer.
> >
> >>
> >> And also the section says that the GICD_ICFGR0 is read-only.
> >
> > For GICD_ICFGR0, my intention was to keep the restore loop uniform.
> > There should be no useful SGI state to restore here: section 4.3.13
> > says that SGI Int_config[1] is not programmable and RAO/WI, while
> > Int_config[0] is reserved. Also, the value written is the value
> > previously read from the same register.
> >
> > So I do not expect this write to affect the architected SGI
> > configuration. However, if you prefer avoiding the write to
> > GICD_ICFGR0 explicitly, I will skip it in the next version of
> > this series.
>
> I think also Linux “restores” it, so I’m ok to keep the code as it is, in 
> fact it’s read-only
> and not marked as reserved, my bad!

Ack. I'll keep this part as-is here.

Best regards,
Mykola

>
> Cheers,
> Luca
>



 


Rackspace

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