mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kunkun Jiang <jiangkunkun@huawei.com>
To: Thomas Gleixner <tglx@linutronix.de>,
	Marc Zyngier <maz@kernel.org>, Zenghui Yu <yuzenghui@huawei.com>,
	"open list:IRQCHIP DRIVERS" <linux-kernel@vger.kernel.org>
Cc: <wanghaibin.wang@huawei.com>,
	Kunkun Jiang <jiangkunkun@huawei.com>,
	<chenxiang66@hisilicon.com>, <tangnianyao@huawei.com>
Subject: [PATCH] irqchipi/gic-v4: Ensure accessing the correct RD when and writing INVLPIR
Date: Wed, 12 Apr 2023 12:15:10 +0800	[thread overview]
Message-ID: <20230412041510.497-1-jiangkunkun@huawei.com> (raw)

commit f3a059219bc7 ("irqchip/gic-v4.1: Ensure mutual exclusion between
vPE affinity change and RD access") tried to address the race
between the RD accesses and the vPE affinity change, but somehow
forgot to take GICR_INVLPIR into account. Let's take the vpe_lock
before evaluating vpe->col_idx to fix it.

Fixes: f3a059219bc7 ("irqchip/gic-v4.1: Ensure mutual exclusion between vPE affinity change and RD access")
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: Nianyao Tang <tangnianyao@huawei.com>
---
 drivers/irqchip/irq-gic-v3-its.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
index 586271b8aa39..041f06922587 100644
--- a/drivers/irqchip/irq-gic-v3-its.c
+++ b/drivers/irqchip/irq-gic-v3-its.c
@@ -3943,13 +3943,17 @@ static void its_vpe_send_inv(struct irq_data *d)
 
 	if (gic_rdists->has_direct_lpi) {
 		void __iomem *rdbase;
+		unsigned long flags;
+		int cpu;
 
 		/* Target the redistributor this VPE is currently known on */
-		raw_spin_lock(&gic_data_rdist_cpu(vpe->col_idx)->rd_lock);
-		rdbase = per_cpu_ptr(gic_rdists->rdist, vpe->col_idx)->rd_base;
+		cpu = vpe_to_cpuid_lock(vpe, &flags);
+		raw_spin_lock(&gic_data_rdist_cpu(cpu)->rd_lock);
+		rdbase = per_cpu_ptr(gic_rdists->rdist, cpu)->rd_base;
 		gic_write_lpir(d->parent_data->hwirq, rdbase + GICR_INVLPIR);
 		wait_for_syncr(rdbase);
-		raw_spin_unlock(&gic_data_rdist_cpu(vpe->col_idx)->rd_lock);
+		raw_spin_unlock(&gic_data_rdist_cpu(cpu)->rd_lock);
+		vpe_to_cpuid_unlock(vpe, flags);
 	} else {
 		its_vpe_send_cmd(vpe, its_send_inv);
 	}
-- 
2.27.0


             reply	other threads:[~2023-04-12  4:15 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-12  4:15 Kunkun Jiang [this message]
2023-04-12  9:42 ` Marc Zyngier
     [not found]   ` <f618c540-879c-ca5b-31af-e55472d8208c@huawei.com>
2023-04-13  7:35     ` Marc Zyngier
2023-05-16 10:15     ` Marc Zyngier
2023-05-16 12:01       ` Kunkun Jiang
2023-06-17  7:02         ` Marc Zyngier
2023-06-17  7:35         ` Marc Zyngier
2023-06-21 12:30           ` Kunkun Jiang
2023-06-30 10:37             ` Kunkun Jiang

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=20230412041510.497-1-jiangkunkun@huawei.com \
    --to=jiangkunkun@huawei.com \
    --cc=chenxiang66@hisilicon.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=tangnianyao@huawei.com \
    --cc=tglx@linutronix.de \
    --cc=wanghaibin.wang@huawei.com \
    --cc=yuzenghui@huawei.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

all inboxes | Powered by JetHome®