Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1377459imm; Sun, 23 Sep 2018 02:48:23 -0700 (PDT) X-Google-Smtp-Source: ACcGV614MzJ0SbBaPV+F2lWLs6b7+iRH4kR3z5n9fVEX11Y91JIqQdT8sZIsyv76GSeiJsbxDRYS X-Received: by 2002:a17:902:b945:: with SMTP id h5-v6mr5848429pls.248.1537696103447; Sun, 23 Sep 2018 02:48:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537696103; cv=none; d=google.com; s=arc-20160816; b=xii/DFJUzvIK+3dyEzXouVY9W5RXtqKA36MH34JL9mUWjULc9z1pNnKamHO5nHvRhF 3/VB8sg/GMD6w8mb3LHPQZpy9a6dHFOac5uY46rqVtaOrbh934/o0vhUtxeE3iyzAEEd 0wFEzE6YyZ7wtEq2Qc58ts72dlhspWIxp1gLZWUbHwNzP7XYNVXDlmlwmDmDOI3DRDFp gM4HwCxsGrBH65X3x0QoIamQA2etMF4LXCRgYZ0LN7IDhffgNEcFEiKo8A9fEMpqMunr uBMsMka0NQNRgmceUZq65jTfzdWBY5TRQVkSO5wnPLcdDSqchklUuQCg900i4fhzJX2H ufuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:organization:user-agent :references:in-reply-to:subject:cc:to:from:message-id:date; bh=T7Kcsexh9aArnrHevQcqpMyeCHuCDMjrSj8FFyzhUrQ=; b=HEbZalVx/8xFIaDkGVZc0+k55ufrVPYKqNQaKC9DvlvqOI4isQIhQI8uv7M5vq0ZX6 7UiWxNFtjDasLkhD3dBIK1MHDzbvOMpKE3HBTW7SOWk+H/TWsjl4pYZtQqyJoovydVne e9TwdGWikdKJENFh7TW7sdIuA9mvzD6WpbhwMSlnF/cjhANlNb8jhr43tfHt/U1LALzX jr7oLcpk924O4ntMogUqo8nz/t6Bz4zYpTkghtvBFUl1Iauq3y9UYlzxdU3a2/ZsD2og 8oN/sKtsT3hbISKmnviMS81FiqBbADa5y1VhQnyEYC4tnCton60wcj7mwSQEm0qCoj4V QWIQ== 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 gn24si33623527plb.43.2018.09.23.02.48.07; Sun, 23 Sep 2018 02:48:23 -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 S1726183AbeIWPo4 (ORCPT + 99 others); Sun, 23 Sep 2018 11:44:56 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:51196 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726071AbeIWPo4 (ORCPT ); Sun, 23 Sep 2018 11:44:56 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3CC7B80D; Sun, 23 Sep 2018 02:48:02 -0700 (PDT) Received: from big-swifty.misterjones.org (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1CED03F557; Sun, 23 Sep 2018 02:47:58 -0700 (PDT) Date: Sun, 23 Sep 2018 10:47:56 +0100 Message-ID: <867ejcwnn7.wl-marc.zyngier@arm.com> From: Marc Zyngier To: Lina Iyer Cc: bjorn.andersson@linaro.org, sboyd@kernel.org, evgreen@chromium.org, linus.walleij@linaro.org, rplsssn@codeaurora.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, rnayak@codeaurora.org, devicetree@vger.kernel.org, andy.gross@linaro.org, dianders@chromium.org Subject: Re: [PATCH v3 3/5] drivers: pinctrl: msm: enable PDC interrupt only during suspend In-Reply-To: <20180922170909.GI17420@codeaurora.org> References: <20180904211810.5506-1-ilina@codeaurora.org> <20180904211810.5506-4-ilina@codeaurora.org> <868t3twl64.wl-marc.zyngier@arm.com> <20180922170909.GI17420@codeaurora.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 EasyPG/1.0.0 Emacs/25.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) Organization: ARM Ltd MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 22 Sep 2018 18:09:09 +0100, Lina Iyer wrote: > > On Sat, Sep 22 2018 at 10:29 -0600, Marc Zyngier wrote: > > Hi Lina, > > > > On Tue, 04 Sep 2018 22:18:08 +0100, > > Lina Iyer wrote: > >> > >> During suspend the system may power down some of the system rails. As a > >> result, the TLMM hw block may not be operational anymore and wakeup > >> capable GPIOs will not be detected. The PDC however will be operational > >> and the GPIOs that are routed to the PDC as IRQs can wake the system up. > >> > >> To avoid being interrupted twice (for TLMM and once for PDC IRQ) when a > >> GPIO trips, use TLMM for active and switch to PDC for suspend. When > >> entering suspend, disable the TLMM wakeup interrupt and instead enable > >> the PDC IRQ and revert upon resume. > >> > >> Signed-off-by: Lina Iyer > >> --- > >> Changes in v3: > >> - Enable PDC-IRQ swap only for edge interrupts > >> Changes in v2: > >> - Fix PDC IRQ max port, 126 is the max supported in h/w > >> - Use PDC hwirq in bitmap, linux numbers could be large > >> - Setup DISABLE_UNLAZY for both TLMM and PDC IRQs > >> --- > [...] > > >> +int __maybe_unused msm_pinctrl_suspend_late(struct device *dev) > >> +{ > >> + struct msm_pinctrl *pctrl = dev_get_drvdata(dev); > >> + struct irq_data *irqd; > >> + unsigned int irq; > >> + int i; > >> + > >> + in_suspend = true; > >> + for_each_set_bit(i, pctrl->pdc_hwirqs, MAX_PDC_HWIRQ) { > >> + irq = irq_find_mapping(pctrl->pdc_irq_domain, i); > >> + irqd = irq_get_handler_data(irq); > >> + /* > >> + * We don't know if the TLMM will be functional > >> + * or not, during the suspend. If its functional, > >> + * we do not want duplicate interrupts from PDC. > >> + * Hence disable the GPIO IRQ and enable PDC IRQ > >> + * for edge interrupt only. > >> + */ > >> + if (irqd_is_wakeup_set(irqd) && !irqd_is_level_type(irqd)) { > >> + disable_irq_wake(irqd->irq); > > > > There is something I don't quite get here. If the PDC is used to wake > > up the platform, why is the TLMM interrupt configured as a wakeup > > source the first place? Or is it just to keep things simple and not > > have to track it in the TLMM driver itself? > > > True, it need not be. I could just avoid setting the wakeup on the TLMM > and just use the PDC interrupt as wakeup. > > Also, I am exploring an option that was suggested by Stephen [1] to just > use the PDC interrupt as a parent of the GPIO IRQ and use a different > irqchip for the PDC interrupt. I ran into some issue with accessing > irqchip and irqdata of the PDC interrupt, since the irqchip was not in > hierarchy with the GPIO's irqchip. I haven't been able to find time to > resolve the issue that the set_parent_ functions, because of the > hierarchy. > > Essentially, we have two different mechanisms for GPIO IRQs based on > whether they can be woken up by the PDC interrupt. > > GPIO-IRQ --> PDC --> GIC > > GPIO-IRQ --> TLMM SUMMARY --> GIC > > Do you think the idea is feasible? It would avoid doing all this > enable/disable at every suspend and even during idle, when the TLMM > could be powered off. [me tries to page it all in again] You could have the PDC as part of the GPIO hierarchy: GPIO -> PDC -> TLMM -> GIC and always configure the PDC as a wake-up source. I just wonder if you can do that without setting up a parallel hierarchy between the PDC and the GIC. We already have similar things in the tree (see OMAP's wakeupgen), and it may be worth having a look. The lack of interrupt replaying on the PDC is quite annoying (I have much stronger words in mind though), and I'm not sure we can easily fix that one without this parallel interrupt hack (you need something to inject edge interrupts in the TLMM). > > > >> + disable_irq(irqd->irq); > >> + enable_irq(irq); > >> + } > >> + } > > > > Given that you're changing in_suspend and parsing the bitmap, > > shouldn't take the pdc spinlock? > > > Since we are the the only CPU running and suspend/resume (and even idle) > would be serialized I didn't see a reason for needing a lock. In that case, what is the purpose of 'in_suspend' if msm_gpio_irq_set_wake cannot happen during the suspend/resume phases? It all seems a bit inconsistent. Thanks, N, -- Jazz is not dead, it just smell funny.