From patchwork Thu Nov 20 11:42:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Thompson X-Patchwork-Id: 41230 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9A1A623C27 for ; Thu, 20 Nov 2014 11:42:47 +0000 (UTC) Received: by mail-wi0-f197.google.com with SMTP id l15sf1936669wiw.0 for ; Thu, 20 Nov 2014 03:42:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=FdeCrSD4AZc/cMTMELh+KqN+coubyfsE2UbNJNiBq0A=; b=Q21593Hm9KQo0mhR+L3VHZnTOsSECKEn7ZjR+ANMua3WDiYWH4YzpjYeeA/A3kXK8Q C3m1PASK9kBALRFg4xE5gMhbWwQ6uV/Aqi99kKUIyCwfbCCZ2t1W03sHhk6cH7LwfSwt MxuwOB8vY8YtA/fPf63jT45xsvDREQkGAtgb0IZrr/uiohVjTeOyW0G2W5Y1WVAPVmB6 7lRjw39sMaRlCgfjKU19VC+8RT89EAxUP0NDi3E/qW/civAxtjeQzJ+3js0EzoPuFzJ2 jLTLE2kXLhoY4S8wJxjWJsOF7pvSSmzSLtR1aQPaYUUoIjmWK/o3j54wb+38D4XZIVLy rrWA== X-Gm-Message-State: ALoCoQlMps8IUvdg+sjX4h6fw3R/2zYmSHgVIlYOs4zLg/E57g7EXKm+ekO7M5MtMloLoAD8Qyil X-Received: by 10.180.82.34 with SMTP id f2mr2657114wiy.1.1416483766836; Thu, 20 Nov 2014 03:42:46 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.44.194 with SMTP id g2ls57690lam.3.gmail; Thu, 20 Nov 2014 03:42:46 -0800 (PST) X-Received: by 10.152.22.194 with SMTP id g2mr10808788laf.33.1416483766582; Thu, 20 Nov 2014 03:42:46 -0800 (PST) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com. [209.85.217.175]) by mx.google.com with ESMTPS id bn10si1894256lbc.108.2014.11.20.03.42.46 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 20 Nov 2014 03:42:46 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) client-ip=209.85.217.175; Received: by mail-lb0-f175.google.com with SMTP id n15so2123294lbi.34 for ; Thu, 20 Nov 2014 03:42:46 -0800 (PST) X-Received: by 10.112.14.69 with SMTP id n5mr10893045lbc.34.1416483766476; Thu, 20 Nov 2014 03:42:46 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp245519lbc; Thu, 20 Nov 2014 03:42:45 -0800 (PST) X-Received: by 10.194.250.105 with SMTP id zb9mr23699499wjc.123.1416483765190; Thu, 20 Nov 2014 03:42:45 -0800 (PST) Received: from mail-wg0-f50.google.com (mail-wg0-f50.google.com. [74.125.82.50]) by mx.google.com with ESMTPS id y7si3114539wjy.65.2014.11.20.03.42.45 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 20 Nov 2014 03:42:45 -0800 (PST) Received-SPF: pass (google.com: domain of daniel.thompson@linaro.org designates 74.125.82.50 as permitted sender) client-ip=74.125.82.50; Received: by mail-wg0-f50.google.com with SMTP id k14so3412211wgh.23 for ; Thu, 20 Nov 2014 03:42:44 -0800 (PST) X-Received: by 10.180.103.225 with SMTP id fz1mr14995130wib.38.1416483764879; Thu, 20 Nov 2014 03:42:44 -0800 (PST) Received: from sundance.lan (cpc4-aztw19-0-0-cust157.18-1.cable.virginm.net. [82.33.25.158]) by mx.google.com with ESMTPSA id vm8sm3025563wjc.6.2014.11.20.03.42.42 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Nov 2014 03:42:43 -0800 (PST) From: Daniel Thompson To: Shawn Guo , Sascha Hauer Cc: Daniel Thompson , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Russell King , Will Deacon , Peter Zijlstra , Paul Mackerras , Ingo Molnar , Arnaldo Carvalho de Melo , patches@linaro.org, linaro-kernel@lists.linaro.org, John Stultz , Sumit Semwal Subject: [RFC PATCH] arm: imx: Workaround i.MX6 PMU interrupts muxed to one SPI Date: Thu, 20 Nov 2014 11:42:37 +0000 Message-Id: <1416483757-24165-1-git-send-email-daniel.thompson@linaro.org> X-Mailer: git-send-email 1.9.3 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: daniel.thompson@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , All PMU interrupts on multi-core i.MX6 devices are muxed onto a single SPI. Should the PMU of any core except 0 (the default affinity for the interrupt) trigger the interrupt then it cannot be serviced and, eventually, the spurious irq detection will forcefully disable the interrupt. This can be worked around by getting the interrupt handler to change its own affinity if it cannot figure out why it has been triggered. This patch adds logic to rotate the affinity to i.MX6. Signed-off-by: Daniel Thompson --- Notes: This patch adopts the approach used on the u8500 (db8500_pmu_handler) but the logic has been generalized for any number of CPUs, mostly because the i.MX6 has a both dual and quad core variants. However it might be better to include the generalized logic in the main armpmu code. I think the logic could be deployed automatically on SMP systems with only a single not-percpu IRQ, replacing the plat->handle_irq dance we currently do to hook up this code. Thoughts? (or is there already shared logic to do this that I overlooked) arch/arm/mach-imx/mach-imx6q.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) -- 1.9.3 diff --git a/arch/arm/mach-imx/mach-imx6q.c b/arch/arm/mach-imx/mach-imx6q.c index d51c6e99a2e9..c056b7b97eaa 100644 --- a/arch/arm/mach-imx/mach-imx6q.c +++ b/arch/arm/mach-imx/mach-imx6q.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -33,6 +34,7 @@ #include #include #include +#include #include #include "common.h" @@ -261,6 +263,40 @@ static void __init imx6q_axi_init(void) } } +/* + * The PMU IRQ lines of all cores are muxed onto a single interrupt. + * Rotate the interrupt around the cores if the current CPU cannot + * figure out why the interrupt has been triggered. + */ +static irqreturn_t imx6q_pmu_handler(int irq, void *dev, irq_handler_t handler) +{ + irqreturn_t ret = handler(irq, dev); + int next; + + if (ret == IRQ_NONE && num_online_cpus() > 1) { + next = cpumask_next(smp_processor_id(), cpu_online_mask); + if (next > nr_cpu_ids) + next = cpumask_next(-1, cpu_online_mask); + irq_set_affinity(irq, cpumask_of(next)); + } + + /* + * We should be able to get away with the amount of IRQ_NONEs we give, + * while still having the spurious IRQ detection code kick in if the + * interrupt really starts hitting spuriously. + */ + return ret; +} + +static struct arm_pmu_platdata imx6q_pmu_platdata = { + .handle_irq = imx6q_pmu_handler, +}; + +static struct of_dev_auxdata imx6q_auxdata_lookup[] __initdata = { + OF_DEV_AUXDATA("arm,cortex-a9-pmu", 0, "arm-pmu", &imx6q_pmu_platdata), + {}, +}; + static void __init imx6q_init_machine(void) { struct device *parent; @@ -276,7 +312,8 @@ static void __init imx6q_init_machine(void) imx6q_enet_phy_init(); - of_platform_populate(NULL, of_default_bus_match_table, NULL, parent); + of_platform_populate(NULL, of_default_bus_match_table, + imx6q_auxdata_lookup, parent); imx_anatop_init(); cpu_is_imx6q() ? imx6q_pm_init() : imx6dl_pm_init();