Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3219277ybi; Mon, 10 Jun 2019 06:37:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqzZqLcMDQ0ssyalZ4d45CgglH7QkIHI2eLrscUt6tSSKHOfeIhU5iaJTGzvlDOHwuoWT6Gm X-Received: by 2002:a17:90a:a596:: with SMTP id b22mr21484171pjq.20.1560173825714; Mon, 10 Jun 2019 06:37:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560173825; cv=none; d=google.com; s=arc-20160816; b=gLSv6UT3L5+HvzGJ1sS3uj3Jpni7gH19sUCyxM6MpA8xGOcmXpNibof2S56yxN1hEt cjdV3CTDjLuQ0ILgLWZrBWXMaPJf+yY3vd9g4IJEAjNDXoSgk6NA8I04DS5iBt2hfFZt SN0EXeJn6whNpj/ZvUNXbif10gQOBiEKjJ7b+axar0GJjVrxd3NqQ+vX2+zHyS2rBp9D pSjka3K8iuGw1BQhGQhMo5Z9mWCr3H70BeT++oarEuYB7le2W5GuSGlH63QsUNb8s/+n RcCIjQwFKArisHkVb0zaxlxYYL1k24u7OQmpL3oolPAyn/LmCKSTDRvzh+2iOFJY7A9D se+w== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:autocrypt:openpgp:from:references:cc:to :subject; bh=OLShCOcUVRgtxhwL7OMmtWqFhni59aVaTfv6SvLP5Qw=; b=AEj1DTTcUdAPR8T//5JBwgLz2yKCoKtS7710cbommW790FJ5lVTXLQd5w0uX09mQhU L40tzrjDh5sk8xBDlTjI8NsBokSOkTMM/U0nPgqo1dKfKKx0i95Tnv1pefZWRS6QAl5Z Jp8cG/X5Se6ZmTNcSmsUaNPTqEH0uR1mjipyzgY+r5URKag4Y1cTZHWwzYcnnF+K5tLm DBDBTMipxy161UsHijpB2rikEJF/nbPAqP4c5SUuoXRPQWWc9vmHpMlzDqqNK7ScZRt0 3HXheA3WtRJ2Jgb2s4WpE9MTNf6r7qKK9tKm8NVNBDi/s+eusyZhfaFMPnMo13n/lCB8 MLdg== 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 p1si10294770pld.91.2019.06.10.06.36.50; Mon, 10 Jun 2019 06:37:05 -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 S2390310AbfFJNYR (ORCPT + 99 others); Mon, 10 Jun 2019 09:24:17 -0400 Received: from foss.arm.com ([217.140.110.172]:42880 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389171AbfFJNYR (ORCPT ); Mon, 10 Jun 2019 09:24:17 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0CBFB344; Mon, 10 Jun 2019 06:24:16 -0700 (PDT) Received: from [10.1.197.61] (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1A9243F557; Mon, 10 Jun 2019 06:24:12 -0700 (PDT) Subject: Re: [RFC 1/2] irqchip: irq-imx-gpcv2: Add workaround for i.MX8MQ ERR11171 To: Abel Vesa , Rob Herring , Mark Rutland , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Thomas Gleixner , Lucas Stach , Bai Ping , Lorenzo Pieralisi , Leonard Crestez Cc: NXP Linux Team , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Carlo Caione References: <20190610121346.15779-1-abel.vesa@nxp.com> <20190610121346.15779-2-abel.vesa@nxp.com> From: Marc Zyngier Openpgp: preference=signencrypt Autocrypt: addr=marc.zyngier@arm.com; prefer-encrypt=mutual; keydata= mQINBE6Jf0UBEADLCxpix34Ch3kQKA9SNlVQroj9aHAEzzl0+V8jrvT9a9GkK+FjBOIQz4KE g+3p+lqgJH4NfwPm9H5I5e3wa+Scz9wAqWLTT772Rqb6hf6kx0kKd0P2jGv79qXSmwru28vJ t9NNsmIhEYwS5eTfCbsZZDCnR31J6qxozsDHpCGLHlYym/VbC199Uq/pN5gH+5JHZyhyZiNW ozUCjMqC4eNW42nYVKZQfbj/k4W9xFfudFaFEhAf/Vb1r6F05eBP1uopuzNkAN7vqS8XcgQH qXI357YC4ToCbmqLue4HK9+2mtf7MTdHZYGZ939OfTlOGuxFW+bhtPQzsHiW7eNe0ew0+LaL 3wdNzT5abPBscqXWVGsZWCAzBmrZato+Pd2bSCDPLInZV0j+rjt7MWiSxEAEowue3IcZA++7 ifTDIscQdpeKT8hcL+9eHLgoSDH62SlubO/y8bB1hV8JjLW/jQpLnae0oz25h39ij4ijcp8N t5slf5DNRi1NLz5+iaaLg4gaM3ywVK2VEKdBTg+JTg3dfrb3DH7ctTQquyKun9IVY8AsxMc6 lxl4HxrpLX7HgF10685GG5fFla7R1RUnW5svgQhz6YVU33yJjk5lIIrrxKI/wLlhn066mtu1 DoD9TEAjwOmpa6ofV6rHeBPehUwMZEsLqlKfLsl0PpsJwov8TQARAQABtCNNYXJjIFp5bmdp ZXIgPG1hcmMuenluZ2llckBhcm0uY29tPokCTwQTAQIAOQIbAwYLCQgHAwIGFQgCCQoLBBYC AwECHgECF4AWIQSf1RxT4LVjGP2VnD0j0NC60T16QwUCXO+WxgAKCRAj0N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883-196a-bcb3-7ee36117074a@arm.com> Date: Mon, 10 Jun 2019 14:24:11 +0100 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <20190610121346.15779-2-abel.vesa@nxp.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Abel, On 10/06/2019 13:13, Abel Vesa wrote: > i.MX8MQ is missing the wake_request signals from GIC to GPCv2. This indirectly > breaks cpuidle support due to inability to wake target cores on IPIs. > > Here is the link to the errata (see e11171): > > https://www.nxp.com/docs/en/errata/IMX8MDQLQ_0N14W.pdf > > Now, in order to fix this, we can trigger IRQ 32 (hwirq 0) to all the cores by > setting 12th bit in IOMUX_GPR1 register. In order to control the target cores > only, that is, not waking up all the cores every time, we can unmask/mask the > IRQ 32 in the first GPC IMR register. So basically we can leave the IOMUX_GPR1 > 12th bit always set and just play with the masking and unmasking the IRO 32 for > each independent core. > > Since EL3 is the one that deals with powering down/up the cores, and since the > cores wake up in EL3, EL3 should be the one to control the IMRs in this case. > This implies we need to get into EL3 on every IPI to do the unmasking, leaving > the masking to be done on the power-up sequence by the core itself. > > In order to be able to get into EL3 on each IPI, we 'hijack' the registered smp > cross call handler, in this case the gic_raise_softirq which is registered by > the irq-gic-v3 driver and register our own handler instead. This new handler is > basically a wrapper over the hijacked handler plus the call into EL3. > > To get into EL3, we use a custom vendor SIP id added just for this purpose. > > All of this is conditional for i.MX8MQ only. > > Signed-off-by: Abel Vesa > --- > drivers/irqchip/irq-imx-gpcv2.c | 42 +++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 42 insertions(+) > > diff --git a/drivers/irqchip/irq-imx-gpcv2.c b/drivers/irqchip/irq-imx-gpcv2.c > index 66501ea..b921105 100644 > --- a/drivers/irqchip/irq-imx-gpcv2.c > +++ b/drivers/irqchip/irq-imx-gpcv2.c > @@ -6,11 +6,19 @@ > * published by the Free Software Foundation. > */ > > +#include > +#include > +#include > #include > #include > +#include > #include > #include > #include > +#include > + > +#define IMX_SIP_GPC 0xC2000004 > +#define IMX_SIP_GPC_CORE_WAKE 0x00 > > #define IMR_NUM 4 > #define GPC_MAX_IRQS (IMR_NUM * 32) > @@ -73,6 +81,37 @@ static struct syscore_ops imx_gpcv2_syscore_ops = { > .resume = gpcv2_wakeup_source_restore, > }; > > +static void (*__gic_v3_smp_cross_call)(const struct cpumask *, unsigned int); > + > +static void imx_gpcv2_raise_softirq(const struct cpumask *mask, > + unsigned int irq) > +{ > + struct arm_smccc_res res; > + > + /* call the hijacked smp cross call handler */ > + __gic_v3_smp_cross_call(mask, irq); I'm feeling a bit sick... :-( > + > + /* now call into EL3 and take care of the wakeup */ > + arm_smccc_smc(IMX_SIP_GPC, IMX_SIP_GPC_CORE_WAKE, > + *cpumask_bits(mask), 0, 0, 0, 0, 0, &res); There is a number of things that look wrong here: - What guarantees that this SMC call actually exists? The DT itself just says that this is broken, and not much about EL3. - What guarantees that the cpumask matches the physical layout? I could have booted via kexec, and logical CPU0 is now physical CPU3. - What if you have more than 64 CPUs? Probably not a big deal for this particular instance, but I fully expect people to get it wrong again on the next iteration if we "fix" it for them. - How does it work on a 32bit kernel, when firmware advertises a SMC64 call? And also: - IMX_SIP_GMC doesn't strike me as a very distinctive name. It certainly doesn't say *which* SiP is responsible for this wonderful thing. I understand that they would like to stay anonymous, but still... - It isn't clear what you gain from relying on the kernel to send the SGI, while you could do the whole thing at EL3. > +} > + > +static void imx_gpcv2_wake_request_fixup(void) > +{ > + struct regmap *iomux_gpr; > + > + /* hijack the already registered smp cross call handler */ > + __gic_v3_smp_cross_call = __smp_cross_call; > + > + /* register our workaround handler for smp cross call */ > + set_smp_cross_call(imx_gpcv2_raise_softirq); > + > + iomux_gpr = syscon_regmap_lookup_by_compatible("fsl,imx6q-iomuxc-gpr"); > + if (!IS_ERR(iomux_gpr)) > + regmap_update_bits(iomux_gpr, IOMUXC_GPR1, IMX6Q_GPR1_GINT, > + IMX6Q_GPR1_GINT); > +} > + > static int imx_gpcv2_irq_set_wake(struct irq_data *d, unsigned int on) > { > struct gpcv2_irqchip_data *cd = d->chip_data; > @@ -269,6 +308,9 @@ static int __init imx_gpcv2_irqchip_init(struct device_node *node, > cd->wakeup_sources[i] = ~0; > } > > + if (of_property_read_bool(node, "broken-wake-request-signals")) > + imx_gpcv2_wake_request_fixup(); > + > /* Let CORE0 as the default CPU to wake up by GPC */ > cd->cpu2wakeup = GPC_IMR1_CORE0; > > Overall, I find this horrible, and pretty pointless: - Supporting this in mainline is likely to be a loosing battle (let's get real here, nobody will get the updated firmware) - It doesn't solve some other problems such as the lack of LPI and PPI wakeup, as it was outlined in the previous iteration of such workaround. Given this, I'm drawing the same conclusion as last time: this isn't fit for mainline. The real mainline fix is to prevent the use of cpuidle. This workaround is best kept in a vendor-specific tree. Thanks, M. -- Jazz is not dead. It just smells funny...