Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp2007928ima; Mon, 22 Oct 2018 02:33:22 -0700 (PDT) X-Google-Smtp-Source: ACcGV613h+/N1HG7ho7MSZnD2fZSTPYVfX+hoae8G5kpr+LKaZBwcABHsL211GJv+gwUTUoypnMK X-Received: by 2002:a62:d8c6:: with SMTP id e189-v6mr13110424pfg.23.1540200802226; Mon, 22 Oct 2018 02:33:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540200802; cv=none; d=google.com; s=arc-20160816; b=g0QuWFPfyqpViehC0hX9NCYU9s6923MtZmZp0SbAEopVcFgJjLY/NbbN9YenKDG629 QdirZR0LVo5dcsWM2JztlKtdjIB4OHPMSFEY5Um4KZdNxx3QdeadXjknGPkXsRN0Vxrs TcxFwNaBs5RaKnjYho/RAWbF3Vg34xfgp5/BgOO3eeFJbvjyxIAJOQkfrdivnbeb7OnZ YZ3MGKkjmiazWVoqS7lPOu/B5aen82cEsTRvSpYjjGRS0PP72RfhmqudPpVGNWPDWDAu 0LU9gXPG8TdVZ9dKT46H68b9zB4G2R0sJhpr+yUyiAkVMR1kDaLLwAlPiP68oroacCsA uLcQ== 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=nyhe7EruQZfLWj17NLOMIZ5ZFAuRSB5mIdgVjxuZD90=; b=a5zN3wbHDGOiee6GBe4VRMKWvkljsFH5Ht4KYwK8eSCOQqq1RL7RLSuuMWrWrHU5wr UwMNYXBdk4rnbzBsR0WlUfwaHyN6sTdt5DL/V0GSfW/pXzNo4uNSBrPudpzRwHfKvvkv pRYu3K2VkJ1AvCqvCQ4bXXccZD/W8wwU92xe2Eck3nar2FL1uRbjrRnpJPyXeMIr/SuT P809yGWRkatIHLUeAGzEmyk4UZwtCyi6Q0rrc9+Gr3TwrKm7QzUO0EUdtxLN3V/4xsDw ZqKK/zR0qXtS3ASJTcIvrbYqhTxGyrjbT3V7QrO5BHvymFballYJtbA13CdfYkp4PSfR x3/w== 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 y6-v6si6761155pgv.174.2018.10.22.02.33.07; Mon, 22 Oct 2018 02:33:22 -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 S1728271AbeJVRon (ORCPT + 99 others); Mon, 22 Oct 2018 13:44:43 -0400 Received: from foss.arm.com ([217.140.101.70]:43830 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727509AbeJVRon (ORCPT ); Mon, 22 Oct 2018 13:44:43 -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 758D9EBD; Mon, 22 Oct 2018 02:27:01 -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 EC29B3F6A8; Mon, 22 Oct 2018 02:26:58 -0700 (PDT) Date: Mon, 22 Oct 2018 10:26:53 +0100 Message-ID: <86a7n6tjqa.wl-marc.zyngier@arm.com> From: Marc Zyngier To: Lina Iyer Cc: sboyd@kernel.org, evgreen@chromium.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH RFC 1/1] drivers: pinctrl: qcom: add wakeup capability to GPIO In-Reply-To: <20181019194712.GB17444@codeaurora.org> References: <20181011002958.2597-1-ilina@codeaurora.org> <20181011002958.2597-2-ilina@codeaurora.org> <20181019153222.GA17444@codeaurora.org> <20181019194712.GB17444@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 Fri, 19 Oct 2018 20:47:12 +0100, Lina Iyer wrote: > > On Fri, Oct 19 2018 at 09:53 -0600, Marc Zyngier wrote: > > Hi Lina, > > > > On 19/10/18 16:32, Lina Iyer wrote: > >> Hi folks, > >> > >> On Wed, Oct 10 2018 at 18:30 -0600, Lina Iyer wrote: > > [...] > > >>> +static irqreturn_t wake_irq_gpio_handler(int irq, void *data) > >>> +{ > >>> + struct irq_data *irqd = data; > >>> + struct irq_desc *desc = irq_to_desc(irqd->irq); > >>> + > >>> + desc->handle_irq(desc); > >> Do we see any problem calling handle_irq()? > > > > Good timing, I was just looking at this. > > > :) Thanks for your time. > > > One thing I can see is that you will end-up calling the EOI callback on > > the root interrupt controller (the GIC), thus writing to ICC_EOIR1_EL1. > > > > But you've never acked this interrupt the first place by reading > > ICC_IAR1_EL1, and that puts you violently out of spec, according to the > > GICv3 spec (8.2.10), which reads: > > > > "A write to this register must correspond to the most recent valid read > > by this PE from an Interrupt Acknowledge Register, and must correspond > > to the INTID that was read from ICC_IAR1_EL1, otherwise the system > > behavior is UNPREDICTABLE." > > > > Here, you definitely risk the sanity of the CPU interface state machine. > > > Oh, thanks Marc. Will look into it. The problem is because I call > handle_irq() directly for the GPIO IRQ which is not triggered but we end > up mask, eoi etc. > > How about calling handle_simple_irq(), which doesn't seem to the IRQ > registers? The problem is that you cannot decide to use another flow handler, as this handler is a constraint imposed by the root interrupt controller. You can overload it, but you then need to make sure that the interrupt will *never* fire at the GIC level, ever. Can you actually enforce this? Assuming you can, this could work. But then the subsequent question is: Why do you have the interrupt at the TLMM level at all? Overall, I'm a bit worried of this "now you see me, now you don't" kind of game behind the kernel back. Is there a way we can stop playing that game and stick to one single path for interrupt delivery? > > So stepping back a bit: At some point, you had a version that just > > relied on regenerating edge interrupts by writing to some register > > (knowing that level interrupts are safe by definition). Why isn't that > > the right solution? It'd avoid the above minefield by just letting the > > HW do its thing... > > > There are some unnecessary complexity with the approach that we are > trying to avoid. > > The TLMM may or not may not be powered off (depending on the SoC state) > and Linux has no control on it. The PDC will remain powered on but we > don't want the PDC interrupt enabled always, since we will receive to > interrupts (one from TLMM and one from PDC) for every event. So we have > to keep the PDC interrupt configured as wakeup interrupt but operate on > the fact that when we go into suspend or cpuidle we will have to switch > to enabling the PDC interrupt and disabling the GPIO IRQ and swap back > when we resume. This dance is harder with cpuidle (notifying the TLMM > driver, when all the CPUs are in idle) than suspend/resume which has > nice callbacks and is what we are trying to avoid but using the PDC > interrupt always. It looks to me that the way this logic is split across two drivers is a major cause of headache. My advise is that either you have one single point of interrupt handling for such interrupt, or you force a TLMM wake-up on such an event, forcing it to handle the interrupt the "normal way"... Thanks, M. -- Jazz is not dead, it just smell funny.