From patchwork Mon Jun 10 12:13:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abel Vesa X-Patchwork-Id: 10984735 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6C1C1924 for ; Mon, 10 Jun 2019 12:16:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C587286E3 for ; Mon, 10 Jun 2019 12:16:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 504C22887A; Mon, 10 Jun 2019 12:16:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C9086286E3 for ; Mon, 10 Jun 2019 12:16:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=YZld8MDeb0qpF6isj6L9KjhUcEnH+100HJUgnDmBIqY=; b=WVPW2ZIelnx1kER5gywszbn05p ybrjq0hrxIv4byD+yeM36Dnw7aC+5CVBi96g3gPGd2eW6dSMmyzREtvh9uakYvB6LifUxBnyfAodF SULk41g2v17dOk+WyHoGDzFzvYAVEi4H6xk1hhFHzhFBvczS0e1p402FkZPfGa31olUqsH0W1dE47 zbrcmQ0tzerlnZ4AX0gkGJev0W7HOZshWuC14vlICJ/0Ckiar2PX0IdKDPUM62BTlfE1Pg6X3hveQ ElfrHVlA43K51ZWJaoU5NjnsjAHdJdjjfzMUttz5brdH+hwRWwUPHEYgXNZjunHytNOdeRguE5TQZ N6mljuRw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1haJDl-0004c2-As; Mon, 10 Jun 2019 12:16:17 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1haJDM-0004JV-Lu for linux-arm-kernel@lists.infradead.org; Mon, 10 Jun 2019 12:15:55 +0000 Received: by mail-wr1-x443.google.com with SMTP id r18so8927357wrm.10 for ; Mon, 10 Jun 2019 05:15:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=FlvwpC6m0v53KavCocJ+2csqLAYMxCnpT0Lw1VCqit4=; b=T3Th9y2P8mFhAGe5f2GRszLTwWxc6rRrQtrzWo2OCdsGyBknRfs4DoV1f9pNEJ7DnD bhynNiQHLGjvAX5Hj8Gme1I8jBPVbYX1fkNs98qmi8n4pWCLUXs3ul43FCLWUm/Uaguw IiJw6WZbo0kaLkzs97FkomBsEFzD3WV+rCVK39RjXiq6huqwSEiPLNdsOlaJLhzOzvZZ QeXE+Vz0VGLAf3yDhDhLjrcGiOZM0mcig0NXAEcKGoyniF6m1N0qBnUS4UPLW1RRmGqf knIcqtaZeEdF9ffKj4E16lrrgkipRKQx0tau1XjbQcjhF+XCGHye1SROp0h6UTOg2lGA a6qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=FlvwpC6m0v53KavCocJ+2csqLAYMxCnpT0Lw1VCqit4=; b=r7K63goFO2aT79kI2Ob45urhEF4Vf0e1KwiQgnILMAnm/j3TyRIeUgz/Fg58fTVSye EmDTn57yuGfdVhyBbUGE2fBTt5KxD1ufKKMFQF4kQmuAcWkxSp01D48v2a/cSdkzXbxj Z7IyxWOTegWMbjCXoUKpn2XFHPUGlbe25rQ1iBxsjf0Uw0qRIXitNd5qnbVFwbg5/jzf Pyg108IpY6uivBVoIEemv34mgleUebPQI8Xeg8iLeUY/ZJ8qwgDdk3q/DMDAb2BxAH5Q PgNUcydMPdLRpHwshLQ5SfBsPoZmnhScgVBI879t+/yUAraZTDNb2QzvalqjPm1thwq9 0XWA== X-Gm-Message-State: APjAAAVcgw0e188Hy7v/gquYSKwaiR/eyo3UDl5VyvEmA+fnr2Mgsz3E UpCbN7eZqbPRBwHgjSeqWGg= X-Google-Smtp-Source: APXvYqzsoAkn97R3560OJNeo/y83djbhV8nq+nIziMx4Zq7RVWl4008WIAc8fw11dPOCmAdmrJM83w== X-Received: by 2002:adf:b689:: with SMTP id j9mr24269221wre.76.1560168950907; Mon, 10 Jun 2019 05:15:50 -0700 (PDT) Received: from ryzen.lan (5-12-114-167.residential.rdsnet.ro. [5.12.114.167]) by smtp.gmail.com with ESMTPSA id f21sm10385574wmb.2.2019.06.10.05.15.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jun 2019 05:15:50 -0700 (PDT) From: Abel Vesa X-Google-Original-From: Abel Vesa To: Rob Herring , Mark Rutland , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Thomas Gleixner , Marc Zyngier , Lucas Stach , Bai Ping , Lorenzo Pieralisi , Leonard Crestez Subject: [RFC 1/2] irqchip: irq-imx-gpcv2: Add workaround for i.MX8MQ ERR11171 Date: Mon, 10 Jun 2019 15:13:45 +0300 Message-Id: <20190610121346.15779-2-abel.vesa@nxp.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190610121346.15779-1-abel.vesa@nxp.com> References: <20190610121346.15779-1-abel.vesa@nxp.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190610_051552_716779_1262D8B0 X-CRM114-Status: GOOD ( 19.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Carlo Caione , NXP Linux Team , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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); + + /* 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); +} + +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;