From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7645AC5DF62 for ; Wed, 6 Nov 2019 11:59:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2EBD32075C for ; Wed, 6 Nov 2019 11:59:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=posteo.de header.i=@posteo.de header.b="P0mDZxdI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727652AbfKFL7Y (ORCPT ); Wed, 6 Nov 2019 06:59:24 -0500 Received: from mout01.posteo.de ([185.67.36.65]:43880 "EHLO mout01.posteo.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727391AbfKFL7Y (ORCPT ); Wed, 6 Nov 2019 06:59:24 -0500 Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id DB1C116005E for ; Wed, 6 Nov 2019 12:59:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1573041557; bh=GYzri181iZ/WOeNlLcMdCvqWqEhUamYlx/vBeuGli+Y=; h=Subject:To:Cc:From:Openpgp:Autocrypt:Date:From; b=P0mDZxdIYFZfxJr8r2zz0cA2PuRndQwmNQS32UDvKmiMCcB/0zpgK52W2rc8nhgN/ LrOoBHfa7H/kbdCA9l2USz14n+0OD7ywBcrggYJ+bpnZyT0RsedufL6q5+eh4O6osc KzrgDtGNyZJILdMoK/DZZGY9BNsoZaL3YhUK+TEsS4v/taVvcAA67gcBjZC3FD3pZe OmRoljc6igtLI5PmAygNWEwGgqy2iHEFKi1/Swir+EfW5KB2L1uqzdqy2pJhl3SIM2 NgKDdzhOfQc2YDELKycmBwKaz1SeViyZbqe4IoRakYqAUGw399duGQKQ3946/2ZwiD 4mdp/8Y+uEJXQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 477Q6w2YTnz6tmG; Wed, 6 Nov 2019 12:59:04 +0100 (CET) Subject: Re: [RFC 0/2] Add workaround for core wake-up on IPI for i.MX8MQ To: Abel Vesa Cc: Abel Vesa , Rob Herring , Mark Rutland , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Thomas Gleixner , Marc Zyngier , Lucas Stach , Jacky Bai , Lorenzo Pieralisi , Leonard Crestez , "devicetree@vger.kernel.org" , Carlo Caione , dl-linux-imx , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" References: <20190610121346.15779-1-abel.vesa@nxp.com> <7d3a868a-768c-3cb1-c6d8-bf5fcd1ddd1c@posteo.de> <20191030080727.7pcvhd4466dproy4@fsr-ub1664-175> <523f92bd-7e89-b48a-afd0-0a9a8bca8344@posteo.de> <20191104103525.qjkxh2zhhgaaectk@fsr-ub1664-175> From: Martin Kepplinger Openpgp: preference=signencrypt Autocrypt: addr=martink@posteo.de; keydata= mQINBFULfZABEADRxJqDOYAHfrp1w8Egcv88qoru37k1x0Ugy8S6qYtKLAAt7boZW+q5gPv3 Sj2KjfkWA7gotXpASN21OIfE/puKGwhDLAySY1DGNMQ0gIVakUO0ji5GJPjeB9JlmN5hbA87 Si9k3yKQQfv7Cf9Lr1iZaV4A4yjLP/JQMImaCVdC5KyqJ98Luwci1GbsLIGX3EEjfg1+MceO dnJTKZpBAKd1J7S2Ib3dRwv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YZqQkFaNcQrGcCi24jYUItZlX9 mzy1+GRt6pgU7xWXPejSyP6vrexYWRVNc5tfuMJBTBbsdcR0xoJoN8Lo1SSQpPU8kgEL6Slx U9Kri/82yf7KD4r44ZRseN6aGO9LvsHJms38gFk6b3gNJiBlAlFOZNVh33ob77Z0w85pS1aO qYLO7fE5+mW4vV1HX2oJmMPX6YDHl6WouLsGtmAk5SOZRv9cj+sMsGmgVD/rE0m4MDhROLV3 54Rl5w4S7uZjXEFCS8o1cvp6yrHuV2J5os0B/jBSSwD5MRSXZc+7zimMsxRubQUD6xSca8yS EKfxh1C0RtyA1irh4iU6Mdb6HvNTYbn+mb4WbE0AnHuKJdpRj0pDeyegTPevftHEQNy9Nj0o pqHDETOTYx/nw49VpXg8SxGJqeuYStJR+amX3dqBu1krWvktrF4i0U6P47aFYUs0N6clGUFj BfCUkKIfEz87bveFlk+g/wvmnni5eFpLkQm5XZfOBuLdURvDcZmv4ScMLtc0TbBSueUP/DZb pHNViNVPohfhJqY2VX4xZfT/V9gK61+pmXzoFIqYmOVal+Q8rPLOOEZBVmtNlicoC7jvWFG/ z/oPHkm5kmAMKdhqc3HcMOt5Ey7+erpN9o56Qy3GA1hv/ygOvLT1QUdsYcuxafqgGg== Message-ID: <433f3f03-f780-c327-f1e8-fbf046a8374c@posteo.de> Date: Wed, 6 Nov 2019 12:59:03 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <20191104103525.qjkxh2zhhgaaectk@fsr-ub1664-175> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org On 04.11.19 11:35, Abel Vesa wrote: > On 19-11-04 09:49:18, Martin Kepplinger wrote: >> On 30.10.19 09:08, Abel Vesa wrote: >>> On 19-10-30 07:11:37, Martin Kepplinger wrote: >>>> On 23.06.19 13:47, Martin Kepplinger wrote: >>>>> On 10.06.19 14:13, Abel Vesa wrote: >>>>>> This is another alternative for the RFC: >>>>>> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flkml.org%2Flkml%2F2019%2F3%2F27%2F545&data=02%7C01%7Cabel.vesa%40nxp.com%7C50f2d9cf92ae4c41db1308d76103e468%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C637084541652623937&sdata=eY8TR3bpvYBWGZ7Xd58%2BK8Ig0qJ3ZqTWO8fNS5X0tj8%3D&reserved=0 >>>>>> >>>>>> This new workaround proposal is a little bit more hacky but more contained >>>>>> since everything is done within the irq-imx-gpcv2 driver. >>>>>> >>>>>> Basically, it 'hijacks' the registered gic_raise_softirq __smp_cross_call >>>>>> handler and registers instead a wrapper which calls in the 'hijacked' >>>>>> handler, after that calling into EL3 which will take care of the actual >>>>>> wake up. This time, instead of expanding the PSCI ABI, we use a new vendor SIP. >>>>>> >>>>>> I also have the patches ready for TF-A but I'll hold on to them until I see if >>>>>> this has a chance of getting in. >>>>> >>>> >>>> Hi Abel, >>>> >>>> Running this workaround doesn't seem to work anymore on 5.4-rcX. Linux >>>> doesn't boot, with ATF unchanged (includes your workaround changes). I >>>> can try to add more details to this... >>>> >>> >>> This is happening because the system counter is now enabled on 8mq. >>> And since the irq-imx-gpcv2 is using as irq_set_affinity the >>> irq_chip_set_affinity_parent. This is because the actual implementation >>> of the driver relies on GIC to set the right affinity. On a SoC >>> that has the wake_request signales linked to the power controller this >>> works fine. Since the system counter is actually the tick broadcast >>> device and the set affinity relies only on GIC, the cores can't be >>> woken up by the broadcast interrupt. >>> >>>> Have you tested this for 5.4? Could you update this workaround? Please >>>> let me know if I missed any earlier update on this (having a cpu-sleep >>>> idle state). >>>> >>> >>> The solution is to implement the set affinity in the irq-imx-gpcv2 driver >>> which would allow the gpc to wake up the target core when the broadcast >>> irq arrives. >>> >>> I have a patch for this. I just need to clean it up a little bit. >>> Unfortunately, it won't go upstream since everuone thinks the gic >>> should be the one to control the affinity. This obviously doesn't work >>> on 8mq. >>> >>> Currently, I'm at ELCE in Lyon. Will get back at the office tomorrow >>> and sned you what I have. >>> >> >> Hi Abel, >> >> Do you have any news on said patch for testing? That'd be great for my >> plannings. >> > > Sorry for the late answer. > > I'm dropping here the diff. > > Please keep in mind that this is _not_ an official solution. > > --- > drivers/irqchip/irq-imx-gpcv2.c | 42 ++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 41 insertions(+), 1 deletion(-) > > diff --git a/drivers/irqchip/irq-imx-gpcv2.c b/drivers/irqchip/irq-imx-gpcv2.c > index 01ce6f4..3150588 100644 > --- a/drivers/irqchip/irq-imx-gpcv2.c > +++ b/drivers/irqchip/irq-imx-gpcv2.c > @@ -41,6 +41,24 @@ static void __iomem *gpcv2_idx_to_reg(struct gpcv2_irqchip_data *cd, int i) > return cd->gpc_base + cd->cpu2wakeup + i * 4; > } > > +static void __iomem *gpcv2_idx_to_reg_cpu(struct gpcv2_irqchip_data *cd, > + int i, int cpu) > +{ > + u32 offset = GPC_IMR1_CORE0; > + switch(cpu) { > + case 1: > + offset = GPC_IMR1_CORE1; > + break; > + case 2: > + offset = GPC_IMR1_CORE2; > + break; > + case 3: > + offset = GPC_IMR1_CORE3; > + break; > + } > + return cd->gpc_base + offset + i * 4; > +} > + > static int gpcv2_wakeup_source_save(void) > { > struct gpcv2_irqchip_data *cd; > @@ -163,6 +181,28 @@ static void imx_gpcv2_irq_mask(struct irq_data *d) > irq_chip_mask_parent(d); > } > > +static int imx_gpcv2_irq_set_affinity(struct irq_data *d, > + const struct cpumask *dest, bool force) > +{ > + struct gpcv2_irqchip_data *cd = d->chip_data; > + void __iomem *reg; > + u32 val; > + int cpu; > + > + for_each_possible_cpu(cpu) { > + raw_spin_lock(&cd->rlock); > + reg = gpcv2_idx_to_reg_cpu(cd, d->hwirq / 32, cpu); > + val = readl_relaxed(reg); > + val |= BIT(d->hwirq % 32); > + if (cpumask_test_cpu(cpu, dest)) > + val &= ~BIT(d->hwirq % 32); > + writel_relaxed(val, reg); > + raw_spin_unlock(&cd->rlock); > + } > + > + return irq_chip_set_affinity_parent(d, dest, force); > +} > + > static struct irq_chip gpcv2_irqchip_data_chip = { > .name = "GPCv2", > .irq_eoi = irq_chip_eoi_parent, > @@ -172,7 +212,7 @@ static struct irq_chip gpcv2_irqchip_data_chip = { > .irq_retrigger = irq_chip_retrigger_hierarchy, > .irq_set_type = irq_chip_set_type_parent, > #ifdef CONFIG_SMP > - .irq_set_affinity = irq_chip_set_affinity_parent, > + .irq_set_affinity = imx_gpcv2_irq_set_affinity, > #endif > }; > > hi Abel, I guess this diff does not apply when using this reworked change: https://source.puri.sm/Librem5/linux-next/commit/e59807ae0e236512761b751abc84a9b129d7fcda which has worked for me when running 5.3. At least on 5.4-rc5, using your change, I still get cat /sys/devices/system/cpu/cpuidle/current_driver none But also when trying to rewrite your patch against irq-gic-v3.c at least nothing changes for me (I might have done that wrong as well though). What needs to change (in order to have the cpu-sleep state / idle driver) based on the above "reworked" workaround? Could the config have changed? CONFIG_ARM_CPUIDLE should be the only needed path, or did things change there in 5.4? I know all this is no real solution, but currently the only way to have said sleep state on top of mainline. so be it for now. thanks for your help! martin