Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1789187ybb; Sun, 29 Mar 2020 13:28:21 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuatspAbg6Tuu3iPmFJ+fxL5WBmzfRx7stDq6rKcQNVXIXUsAfK1k9a/VpAt6LGCsQJcIYc X-Received: by 2002:aca:cd58:: with SMTP id d85mr5764359oig.173.1585513701491; Sun, 29 Mar 2020 13:28:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585513701; cv=none; d=google.com; s=arc-20160816; b=Yp9ojeKLak0gwAXU4BZyGPmR7eMlimpBCaI/XC73yDxxGw7dEIpwIIyywx+f145xNc iWkJKT83eohRz9N2ErH9PGFj4vl4Rt6PCJMMSb5Hf4otLNLuhfr9QSHhRaZz6eyrxhj6 x4HOtuyfZ5oxhlqCbFvA/UHSB0FypvR4rmz5zPpnAY71pZhHdL1elL9ZebUdv9WXki5Z 9xEZy0Wp1mPJgGaetegZIMMQNCA+8aL6jJ/ThjFN+ru561LKqcG3ORkg9lP4QdPVXfDw M+wQXIx843CqjEufH8d3BUO8NnHGiOXFUZuyNPly8vAWxQQAVXpxrjPA59flQOBIsBOk kNLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=/FFGmEpfZUPnayd83VnJsraJi6zdxUjii5Kt1zXwkMA=; b=072l6j5IVBZ677/cLePKCcj4bwv3MwK6FIqA0qkYiW90Nl9L4K4Eay2Ff1LAQL+fuh CKFkCjUVv9jjJwts0GOHP8gZ6A++I0TrxOG+Vezgi3KMOTrTtsYbXz+jIY5xWNuQ7/8v axnLEVPgfZYVlr1SSHKfNR7EtXw1F7D+4NXA3QMsjqgiKdqMGkUyyKr47GZ+RiZqy9yk rbDdpfwa/bZSRG/XEJouDXxEIQlqoMaiBL49BEc3RqDwIr790ztz6/8oi/Q3GrQvRr1s EL0q64nQtsKPjRTUgYIVYZSKLxBjBO3yVUKjZEVt8Ok34qAUiVtzVHt+KOAS3/FZ5kuh nj2Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e13si5789903oom.86.2020.03.29.13.28.08; Sun, 29 Mar 2020 13:28:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729088AbgC2U12 (ORCPT + 99 others); Sun, 29 Mar 2020 16:27:28 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:57007 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728871AbgC2U00 (ORCPT ); Sun, 29 Mar 2020 16:26:26 -0400 Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1jIeVh-0001Q0-2b; Sun, 29 Mar 2020 22:26:21 +0200 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id ACB6F1C070D; Sun, 29 Mar 2020 22:26:15 +0200 (CEST) Date: Sun, 29 Mar 2020 20:26:15 -0000 From: "tip-bot2 for Marc Zyngier" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: irq/core] irqchip/gic-v4.1: Ensure mutual exclusion betwen invalidations on the same RD Cc: Marc Zyngier , Zenghui Yu , Eric Auger , x86 , LKML In-Reply-To: <20200304203330.4967-6-maz@kernel.org> References: <20200304203330.4967-6-maz@kernel.org> MIME-Version: 1.0 Message-ID: <158551357529.28353.6897448857798291173.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the irq/core branch of tip: Commit-ID: 9058a4e980648e7d068a7f7726a8ea4c67d0e88a Gitweb: https://git.kernel.org/tip/9058a4e980648e7d068a7f7726a8ea4c67d0e88a Author: Marc Zyngier AuthorDate: Wed, 04 Mar 2020 20:33:12 Committer: Marc Zyngier CommitterDate: Fri, 20 Mar 2020 17:48:21 irqchip/gic-v4.1: Ensure mutual exclusion betwen invalidations on the same RD The GICv4.1 spec says that it is CONTRAINED UNPREDICTABLE to write to any of the GICR_INV{LPI,ALL}R registers if GICR_SYNCR.Busy == 1. To deal with it, we must ensure that only a single invalidation can happen at a time for a given redistributor. Add a per-RD lock to that effect and take it around the invalidation/syncr-read to deal with this. Signed-off-by: Marc Zyngier Reviewed-by: Zenghui Yu Reviewed-by: Eric Auger Link: https://lore.kernel.org/r/20200304203330.4967-6-maz@kernel.org --- drivers/irqchip/irq-gic-v3-its.c | 6 ++++++ drivers/irqchip/irq-gic-v3.c | 1 + include/linux/irqchip/arm-gic-v3.h | 1 + 3 files changed, 8 insertions(+) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index c843702..fc57885 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -1373,10 +1373,12 @@ static void direct_lpi_inv(struct irq_data *d) /* Target the redistributor this LPI is currently routed to */ cpu = irq_to_cpuid_lock(d, &flags); + raw_spin_lock(&gic_data_rdist_cpu(cpu)->rd_lock); rdbase = per_cpu_ptr(gic_rdists->rdist, cpu)->rd_base; gic_write_lpir(val, rdbase + GICR_INVLPIR); wait_for_syncr(rdbase); + raw_spin_unlock(&gic_data_rdist_cpu(cpu)->rd_lock); irq_to_cpuid_unlock(d, flags); } @@ -3662,9 +3664,11 @@ static void its_vpe_send_inv(struct irq_data *d) void __iomem *rdbase; /* 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; 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); } else { its_vpe_send_cmd(vpe, its_send_inv); } @@ -3825,10 +3829,12 @@ static void its_vpe_4_1_invall(struct its_vpe *vpe) val |= FIELD_PREP(GICR_INVALLR_VPEID, vpe->vpe_id); /* 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; gic_write_lpir(val, rdbase + GICR_INVALLR); wait_for_syncr(rdbase); + raw_spin_unlock(&gic_data_rdist_cpu(vpe->col_idx)->rd_lock); } static int its_vpe_4_1_set_vcpu_affinity(struct irq_data *d, void *vcpu_info) diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index b6b0f86..0f716c2 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -834,6 +834,7 @@ static int __gic_populate_rdist(struct redist_region *region, void __iomem *ptr) typer = gic_read_typer(ptr + GICR_TYPER); if ((typer >> 32) == aff) { u64 offset = ptr - region->redist_base; + raw_spin_lock_init(&gic_data_rdist()->rd_lock); gic_data_rdist_rd_base() = ptr; gic_data_rdist()->phys_base = region->phys_base + offset; diff --git a/include/linux/irqchip/arm-gic-v3.h b/include/linux/irqchip/arm-gic-v3.h index c29a026..b28acfa 100644 --- a/include/linux/irqchip/arm-gic-v3.h +++ b/include/linux/irqchip/arm-gic-v3.h @@ -652,6 +652,7 @@ struct rdists { struct { + raw_spinlock_t rd_lock; void __iomem *rd_base; struct page *pend_page; phys_addr_t phys_base;