Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp498183pxb; Wed, 22 Sep 2021 06:55:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz48KCdiUlNsQmwaUez2UR7k3Glzv9Srzumtu6xKB3tNf4xB+SaNDuKJhmKbCPugBJWp6sc X-Received: by 2002:a17:906:a3d9:: with SMTP id ca25mr41316066ejb.306.1632318949822; Wed, 22 Sep 2021 06:55:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632318949; cv=none; d=google.com; s=arc-20160816; b=zeGQ/2xyAQ5YrbE8NH6Y3rPb+UY7/Iq8fwwjh3+g0Fg3LGvc+d7wZbuqneDpqIu9uP MghpZ0Pm1RpQ5mBKJB5GHSN0NugY5GYNS7VbbDl5wChlZlaIVD/ORL+6nt/s5/GG/ihy ao0qjOijPEVc1oIClnCOdS2yBCttOT51C2Xna4AdGVwC+0d01fighokN5pQvglNnbi7C hLRJceWJcsNqWVm5WWHf4wB51pi1xuNm4Y0bIzjgXq79u74Q7Rh7jPaR77T7ZFinnSg/ XS/aeZ7OnJlOdg2zbTXi8mx46X71C23eLSpthWIslM79uz+RYsRpV6qmYS48rfV+rK1v gjtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=CH7tsAmJeh0xqRYIxsRQC+QLRbdM8LPzw0YzELw0bic=; b=tGJLs86j2wA7T28Gw5m5qIlVaTByTFvS9ULGK2o2Q4gNqN3xL2lbp8U8xv1d0X9N6O hbIEK/DWNIgYHvBm88+FuY5lB/NM4d3GUsZo7x27nycnJ4kd0LiJjtut9a8DYbiZp/wL ipRe+VEyDi+h45Aw+GTx46ctY5Q94Kn/4yE1DCrHr5kpfhiVHhkyiJhySrAIVgDNSVI1 QUYK0jypVuOJcTm/TA7qQHCZ1cUnbVzeEEqnuarnxKIuHnRMBnmreq7e+vN6RRPFaqs0 y2hQHfHYGmJGMw/KJ8PA0KjepyFf+tidMVH8c2XerxcVN/jOxAEfIo0Dykjsl4yPYjJI 1ftg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ebtJeBOM; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 12si2870767ejk.308.2021.09.22.06.55.12; Wed, 22 Sep 2021 06:55:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ebtJeBOM; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232678AbhIVNyx (ORCPT + 99 others); Wed, 22 Sep 2021 09:54:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232213AbhIVNyx (ORCPT ); Wed, 22 Sep 2021 09:54:53 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9125C061574 for ; Wed, 22 Sep 2021 06:53:22 -0700 (PDT) Date: Wed, 22 Sep 2021 13:53:20 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1632318801; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CH7tsAmJeh0xqRYIxsRQC+QLRbdM8LPzw0YzELw0bic=; b=ebtJeBOMVXXBMCePMUjG5Mci34PMoVJk+vki7qfiazYM52NTYyraWXKNWlISNjJkwtDXbk ElLqkk6RyOtOIGiyQMkUvNlAyk9uJWFfjQdYxrzc3GuF0FLnM1dwEF1/NSYarGyrDFZkvl 8gVpLIy7uJL9Ey0YCOADRcBivRmnBjm0ksk114IAgl8/Fbk7F/8S5gQqsTMCl9G8XcQDwV lzRgVvRSWIJ7khuqPDB/LArBBdL+GSUvvJ9vYLYjEgLlz3IeCnGcfbDbiOhHvbFVADY1Np eylnk6jUGMRn/7yqCR+/mV+Q4XwHf8BrjLgsiHEDAkH4gIR3kSJm/Eaorqpv1Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1632318801; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CH7tsAmJeh0xqRYIxsRQC+QLRbdM8LPzw0YzELw0bic=; b=W88mLVFc+05TBsVG/w0bAp+Q7YQYTPGR+SK5M9crJ2lbnakB6YSg5XjqimX9SbACi4pCjC NXryRoQetoJYZsDw== From: "irqchip-bot for Marc Zyngier" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-kernel@vger.kernel.org Subject: [irqchip: irq/irqchip-fixes] irqchip/gic: Work around broken Renesas integration Cc: Geert Uytterhoeven , Marc Zyngier , tglx@linutronix.de In-Reply-To: References: MIME-Version: 1.0 Message-ID: <163231880052.25758.17370626929263049968.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the irq/irqchip-fixes branch of irqchip: Commit-ID: b78f26926b17cc289e4f16b63363abe0aa2e8efc Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms/b78f26926b17cc289e4f16b63363abe0aa2e8efc Author: Marc Zyngier AuthorDate: Fri, 10 Sep 2021 18:29:25 +01:00 Committer: Marc Zyngier CommitterDate: Wed, 22 Sep 2021 14:44:25 +01:00 irqchip/gic: Work around broken Renesas integration Geert reported that the GIC driver locks up on a Renesas system since 005c34ae4b44f085 ("irqchip/gic: Atomically update affinity") fixed the driver to use writeb_relaxed() instead of writel_relaxed(). As it turns out, the interconnect used on this system mandates 32bit wide accesses for all MMIO transactions, even if the GIC architecture specifically mandates for some registers to be byte accessible. Gahhh... Work around the issue by crudly detecting the offending system, and falling back to an inefficient RMW+lock implementation. Reported-by: Geert Uytterhoeven Signed-off-by: Marc Zyngier Link: https://lore.kernel.org/r/CAMuHMdV+Ev47K5NO8XHsanSq5YRMCHn2gWAQyV-q2LpJVy9HiQ@mail.gmail.com --- drivers/irqchip/irq-gic.c | 52 +++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c index d329ec3..5f22c9d 100644 --- a/drivers/irqchip/irq-gic.c +++ b/drivers/irqchip/irq-gic.c @@ -107,6 +107,8 @@ static DEFINE_RAW_SPINLOCK(cpu_map_lock); #endif +static DEFINE_STATIC_KEY_FALSE(needs_rmw_access); + /* * The GIC mapping of CPU interfaces does not necessarily match * the logical CPU numbering. Let's use a mapping as returned @@ -774,6 +776,25 @@ static int gic_pm_init(struct gic_chip_data *gic) #endif #ifdef CONFIG_SMP +static void rmw_writeb(u8 bval, void __iomem *addr) +{ + static DEFINE_RAW_SPINLOCK(rmw_lock); + unsigned long offset = (unsigned long)addr & 3UL; + unsigned long shift = offset * 8; + unsigned long flags; + u32 val; + + raw_spin_lock_irqsave(&rmw_lock, flags); + + addr -= offset; + val = readl_relaxed(addr); + val &= ~GENMASK(shift + 7, shift); + val |= bval << shift; + writel_relaxed(val, addr); + + raw_spin_unlock_irqrestore(&rmw_lock, flags); +} + static int gic_set_affinity(struct irq_data *d, const struct cpumask *mask_val, bool force) { @@ -788,7 +809,10 @@ static int gic_set_affinity(struct irq_data *d, const struct cpumask *mask_val, if (cpu >= NR_GIC_CPU_IF || cpu >= nr_cpu_ids) return -EINVAL; - writeb_relaxed(gic_cpu_map[cpu], reg); + if (static_branch_unlikely(&needs_rmw_access)) + rmw_writeb(gic_cpu_map[cpu], reg); + else + writeb_relaxed(gic_cpu_map[cpu], reg); irq_data_update_effective_affinity(d, cpumask_of(cpu)); return IRQ_SET_MASK_OK_DONE; @@ -1375,6 +1399,30 @@ static bool gic_check_eoimode(struct device_node *node, void __iomem **base) return true; } +static bool gic_enable_rmw_access(void *data) +{ + /* + * The EMEV2 class of machines has a broken interconnect, and + * locks up on accesses that are less than 32bit. So far, only + * the affinity setting requires it. + */ + if (of_machine_is_compatible("renesas,emev2")) { + static_branch_enable(&needs_rmw_access); + return true; + } + + return false; +} + +static const struct gic_quirk gic_quirks[] = { + { + .desc = "broken byte access", + .compatible = "arm,pl390", + .init = gic_enable_rmw_access, + }, + { }, +}; + static int gic_of_setup(struct gic_chip_data *gic, struct device_node *node) { if (!gic || !node) @@ -1391,6 +1439,8 @@ static int gic_of_setup(struct gic_chip_data *gic, struct device_node *node) if (of_property_read_u32(node, "cpu-offset", &gic->percpu_offset)) gic->percpu_offset = 0; + gic_enable_of_quirks(node, gic_quirks, gic); + return 0; error: