public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andre Przywara <andre.przywara@arm.com>
To: Marc Zyngier <maz@kernel.org>
Cc: linux-kernel@vger.kernel.org,
	Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Eric Auger <eric.auger@redhat.com>
Subject: Re: [PATCH 3/3] irqchip/gic-v3: Relax polling of GIC{R,D}_CTLR.RWP
Date: Wed, 16 Mar 2022 14:54:03 +0000	[thread overview]
Message-ID: <20220316145403.51475e25@slackpad.lan> (raw)
In-Reply-To: <20220315165034.794482-4-maz@kernel.org>

On Tue, 15 Mar 2022 16:50:34 +0000
Marc Zyngier <maz@kernel.org> wrote:

Hi,

> Recent work on the KVM GIC emulation has revealed that the GICv3
> driver is a bit RWP-happy, as it polls this bit for each and
> every write MMIO access involving a single interrupt.
>
> As it turns out, polling RWP is only required when:
> - Disabling an SGI, PPI or SPI
> - Disabling LPIs at the redistributor level
> - Disabling groups
> - Enabling ARE
> - Dealing with DPG*
>
> Simplify the driver by removing all the other instances of RWP
> polling, and add the one that was missing when enabling the distributor
> (as that's where we set ARE).

Don't we need an explicit call to wait_for_rwp() now for:
gic_irq_set_irqchip_state(IRQCHIP_STATE_MASKED, true) ?

The rest looks fine to me.

Thanks,
Andre

>
> Signed-off-by: Marc Zyngier <maz@kernel.org>
> ---
>  drivers/irqchip/irq-gic-v3.c | 28 +++++++++++-----------------
>  1 file changed, 11 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c
> index 363bfe172033..05ff7fef64cb 100644
> --- a/drivers/irqchip/irq-gic-v3.c
> +++ b/drivers/irqchip/irq-gic-v3.c
> @@ -352,28 +352,27 @@ static int gic_peek_irq(struct irq_data *d, u32 offset)
>
>  static void gic_poke_irq(struct irq_data *d, u32 offset)
>  {
> -     void (*rwp_wait)(void);
>       void __iomem *base;
>       u32 index, mask;
>
>       offset = convert_offset_index(d, offset, &index);
>       mask = 1 << (index % 32);
>
> -     if (gic_irq_in_rdist(d)) {
> +     if (gic_irq_in_rdist(d))
>               base = gic_data_rdist_sgi_base();
> -             rwp_wait = gic_redist_wait_for_rwp;
> -     } else {
> +     else
>               base = gic_data.dist_base;
> -             rwp_wait = gic_dist_wait_for_rwp;
> -     }
>
>       writel_relaxed(mask, base + offset + (index / 32) * 4);
> -     rwp_wait();
>  }
>
>  static void gic_mask_irq(struct irq_data *d)
>  {
>       gic_poke_irq(d, GICD_ICENABLER);
> +     if (gic_irq_in_rdist(d))
> +             gic_redist_wait_for_rwp();
> +     else
> +             gic_dist_wait_for_rwp();
>  }
>
>  static void gic_eoimode1_mask_irq(struct irq_data *d)
> @@ -574,7 +573,6 @@ static int gic_set_type(struct irq_data *d, unsigned int type)
>  {
>       enum gic_intid_range range;
>       unsigned int irq = gic_irq(d);
> -     void (*rwp_wait)(void);
>       void __iomem *base;
>       u32 offset, index;
>       int ret;
> @@ -590,17 +588,14 @@ static int gic_set_type(struct irq_data *d, unsigned int type)
>           type != IRQ_TYPE_LEVEL_HIGH && type != IRQ_TYPE_EDGE_RISING)
>               return -EINVAL;
>
> -     if (gic_irq_in_rdist(d)) {
> +     if (gic_irq_in_rdist(d))
>               base = gic_data_rdist_sgi_base();
> -             rwp_wait = gic_redist_wait_for_rwp;
> -     } else {
> +     else
>               base = gic_data.dist_base;
> -             rwp_wait = gic_dist_wait_for_rwp;
> -     }
>
>       offset = convert_offset_index(d, GICD_ICFGR, &index);
>
> -     ret = gic_configure_irq(index, type, base + offset, rwp_wait);
> +     ret = gic_configure_irq(index, type, base + offset, NULL);
>       if (ret && (range == PPI_RANGE || range == EPPI_RANGE)) {
>               /* Misconfigured PPIs are usually not fatal */
>               pr_warn("GIC: PPI INTID%d is secure or misconfigured\n", irq);
> @@ -808,7 +803,7 @@ static void __init gic_dist_init(void)
>               writel_relaxed(GICD_INT_DEF_PRI_X4, base + GICD_IPRIORITYRnE + i);
>
>       /* Now do the common stuff, and wait for the distributor to drain */
> -     gic_dist_config(base, GIC_LINE_NR, gic_dist_wait_for_rwp);
> +     gic_dist_config(base, GIC_LINE_NR, NULL);
>
>       val = GICD_CTLR_ARE_NS | GICD_CTLR_ENABLE_G1A | GICD_CTLR_ENABLE_G1;
>       if (gic_data.rdists.gicd_typer2 & GICD_TYPER2_nASSGIcap) {
> @@ -818,6 +813,7 @@ static void __init gic_dist_init(void)
>
>       /* Enable distributor with ARE, Group1 */
>       writel_relaxed(val, base + GICD_CTLR);
> +     gic_dist_wait_for_rwp();
>
>       /*
>        * Set all global interrupts to the boot CPU only. ARE must be
> @@ -1293,8 +1289,6 @@ static int gic_set_affinity(struct irq_data *d, const struct cpumask *mask_val,
>        */
>       if (enabled)
>               gic_unmask_irq(d);
> -     else
> -             gic_dist_wait_for_rwp();
>
>       irq_data_update_effective_affinity(d, cpumask_of(cpu));
>

IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

  reply	other threads:[~2022-03-16 14:54 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-15 16:50 [PATCH 0/3] irqchip/gic-v3: Assorted fixes and improvements Marc Zyngier
2022-03-15 16:50 ` [PATCH 1/3] irqchip/gic-v3: Fix GICR_CTLR.RWP polling Marc Zyngier
2022-03-16 14:51   ` Andre Przywara
2022-03-16 15:19     ` Marc Zyngier
2022-03-17 17:03   ` Lorenzo Pieralisi
2022-03-21  9:19   ` [irqchip: irq/irqchip-next] " irqchip-bot for Marc Zyngier
2022-03-21 14:07   ` irqchip-bot for Marc Zyngier
2022-04-05 15:39   ` [irqchip: irq/irqchip-fixes] " irqchip-bot for Marc Zyngier
2022-03-15 16:50 ` [PATCH 2/3] irqchip/gic-v3: Detect LPI invalidation MMIO registers Marc Zyngier
2022-03-16 11:21   ` Marc Zyngier
2022-03-16 14:51   ` Andre Przywara
2022-03-16 15:36     ` Marc Zyngier
2022-03-16 15:52       ` Andre Przywara
2022-03-17 17:35   ` Lorenzo Pieralisi
2022-03-21  9:31     ` Marc Zyngier
2022-03-15 16:50 ` [PATCH 3/3] irqchip/gic-v3: Relax polling of GIC{R,D}_CTLR.RWP Marc Zyngier
2022-03-16 14:54   ` Andre Przywara [this message]
2022-03-16 15:42     ` Marc Zyngier

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=20220316145403.51475e25@slackpad.lan \
    --to=andre.przywara@arm.com \
    --cc=eric.auger@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=maz@kernel.org \
    --cc=tglx@linutronix.de \
    /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