Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp5697000imd; Wed, 31 Oct 2018 00:07:19 -0700 (PDT) X-Google-Smtp-Source: AJdET5e4c9aWosOZl5+9bdTv/nz9jpsMAI26PT9EX26oNW4F2KDaXpq5JuXe92G7eTLLE4p9Qcb7 X-Received: by 2002:a62:5bc4:: with SMTP id p187-v6mr2149247pfb.94.1540969639579; Wed, 31 Oct 2018 00:07:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540969639; cv=none; d=google.com; s=arc-20160816; b=EesRDWdxaK+kDPwj6k46PyXgvUbo3SIHHUv0UpRdE81F6VEM+hPOkLK7r9Uam3A11h /sFddeLpgIUEXcYgQ1yU7RDCao2mHeS2bvSsKZjhe3SVg1i2L+l/g/+utxt9SJT6Uk5h hfk54bab65fRJsVj9c49S+VZY8yq9NBSmc47Las/obf0lM28qubuOmzFysA3xNNshkXj zcEknuGBnbsaiq2QEOQebx6W7DHScI5QFKrNyd4rjMrsFZY3Ei8reU3QEmAust5wmxGK 6p9aFYCK2GklhaRfpsteqmO/kSctExpOoBEHI/7ycjyigKYBioeBh7wOxHqal4UaOgzV JMcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:subject:user-agent:message-id :references:cc:in-reply-to:from:to:content-transfer-encoding :mime-version:dkim-signature; bh=3jyZ13izQhVAKF5quP9WYMttRkn6iZPgb27lAx7LTpA=; b=Gp0w/S/KVn2soKONYPTTr5LKWpyXI/V1cP6DwWz067VqnWxI4aGskoyFWLP85nOX4B O1c6DfNfk+C6aRDaHiY0KCcdi9xFXIDVWSUP0Fidi4Wb/5VWWTYPbyyW6He/1RgxhrXN t+0TdAJTycz0bU4MCtOsiOXHwv6HubeQS68GbxbOkRO/YkUickWD37X/eQwmq037kMNr MuWwWD+Qj8UNhMeJ8fxUISWG859vGehF5W3UlGEcqH+DUe+cGQv50mE4/ezG+kMdKxPO dWz3bUGBV8/uBSjOv+JUaWEYwVDInvsG4q20DpY1vqSoUkXbSk7QG3cWGFhe/+qKBUIs Dh0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ae9Rv438; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o14-v6si26308820pgc.238.2018.10.31.00.07.04; Wed, 31 Oct 2018 00:07:19 -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; dkim=pass header.i=@chromium.org header.s=google header.b=ae9Rv438; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726969AbeJaQCh (ORCPT + 99 others); Wed, 31 Oct 2018 12:02:37 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:41393 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725961AbeJaQCh (ORCPT ); Wed, 31 Oct 2018 12:02:37 -0400 Received: by mail-pg1-f193.google.com with SMTP id 23-v6so6917909pgc.8 for ; Wed, 31 Oct 2018 00:05:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:content-transfer-encoding:to:from:in-reply-to:cc :references:message-id:user-agent:subject:date; bh=3jyZ13izQhVAKF5quP9WYMttRkn6iZPgb27lAx7LTpA=; b=ae9Rv438eSwYpoAyeZFpXyOG3u812yjKnMqnj4FuYxmbUxZlngDSFxSCB5kGMV6jho Auo4omYyEEYBDSNMsTP3Hkja3WPpilGNlXDoys1o7TEy7il0yNTUZwnyy3a7Eur6II4F 4KLOTW1HopvQH2XkxUU3fKlzZ3SUmc5JfqEa4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:content-transfer-encoding:to:from :in-reply-to:cc:references:message-id:user-agent:subject:date; bh=3jyZ13izQhVAKF5quP9WYMttRkn6iZPgb27lAx7LTpA=; b=Oril9FDGCWsPvE9pgC40Rgwc35o3mbeDzQ12YC8zOvD3GdqTi9mVBPTTCQf13TgBOS uvn8n93OW9ZxXrG5Z+CGmbNud1C24ogDwqGtBIzfwTt/Sv8d30y7tKy5d7EtlPyuUune oBHlnWgQdsSFmzugEGdMtp+wgHx7K4ihw06hxzryf6mSwuUh03xHxaF3BS9HJUWBrx7y 1COqVgOqrGPbf1uwJhfyZj8x4IA9paIhd6EGv1yK/V+kA0sUmSp+egkymFp69Ji3+kY5 Fpd/eDocwZ5qdnGTaygBEaCZtPGCmf7YfoWeuYOXlZUyS5yS5E0xBhmqByWuxfNIR9lC AFHA== X-Gm-Message-State: AGRZ1gJegn9Ya2qR0+iTf4MKP+QnROhPKS5vQGTShgoWyVEESx5Kb8tW NiLb31yQH0FWDeItJQ9S45Id3g== X-Received: by 2002:a63:2ad4:: with SMTP id q203-v6mr1939050pgq.356.1540969544877; Wed, 31 Oct 2018 00:05:44 -0700 (PDT) Received: from localhost ([2620:15c:202:1:fed3:9637:a13a:6c15]) by smtp.gmail.com with ESMTPSA id p62-v6sm42143192pfp.111.2018.10.31.00.05.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 31 Oct 2018 00:05:44 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: Lina Iyer From: Stephen Boyd In-Reply-To: <20181011002958.2597-2-ilina@codeaurora.org> Cc: linux-kernel@vger.kernel.org, evgreen@chromium.org, marc.zyngier@arm.com References: <20181011002958.2597-1-ilina@codeaurora.org> <20181011002958.2597-2-ilina@codeaurora.org> Message-ID: <154096954339.98144.12348474096990107321@swboyd.mtv.corp.google.com> User-Agent: alot/0.7 Subject: Re: [PATCH RFC 1/1] drivers: pinctrl: qcom: add wakeup capability to GPIO Date: Wed, 31 Oct 2018 00:05:43 -0700 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Lina, Quoting Lina Iyer (2018-10-10 17:29:58) > QCOM SoC's that have Power Domain Controller (PDC) chip in the always-on > domain can wakeup the SoC, when interrupts and GPIOs are routed to its > interrupt controller. Only select GPIOs that are deemed wakeup capable > are routed to specific PDC pins. During low power state, the pinmux > interrupt controller may be non-functional but the PDC would be. The PDC > can detect the wakeup GPIO is triggered and bring the TLMM to an > operational state. > = > Interrupts that are level triggered will be detected at the TLMM when > the controller becomes operational. Edge interrupts however need to be > replayed again. > = > Request the corresponding PDC IRQ, when the GPIO is requested as an IRQ, > but keep it disabled. During suspend, we can enable the PDC IRQ instead > of the GPIO IRQ, which may or not be detected. > = > Signed-off-by: Lina Iyer > --- I spoke with Marc about this at ELCE last week and I think we came up with a plan for how to make this all work while keeping the TLMM driver largely unaware of what's happening. One important point that we need to keep in mind is that we don't want the interrupt to appear twice at the GIC for the same TLMM irq, once in TLMM and once in PDC. That situation would be quite bad and confuse things. So the plan is as follows: 1) Split PDC irqdomain into two domains. One for GIC interrupts and one for TLMM interrupts 2) Support hierarchical irq domains in the TLMM driver and/or gpiolib 3) Stack the irq controllers into a hierarchy so that GIC is the parent of PDC and PDC is the parent of TLMM while also leaving the TLMM summary IRQ chained directly from the GIC irqdomain 4) Mask a TLMM irq in the TLMM driver and unmask the PDC irq in the PDC driver when an irq_set_wake() call is made on a TLMM gpio irq that PDC can monitor (and vice versa) 5) Have the PDC driver be the only driver that knows if a TLMM pin is wakeup capable or not expressed in some DT table Implementing #4 will require changing TLMM irqchip to call irq_chip_set_wake_parent() for the .irq_set_wake op and then checking the return value to figure out if PDC is monitoring the pin or not and doing the mask/unmask dance. Furthermore, implementing #2 will be a bit of work that Thierry has already started for Nvidia Tegra pinctrl drivers. The important part of #4 is that the irq can only happen in TLMM or in PDC, and not in both places because of how we mask and unmask in different drivers. The TLMM summary irq line can't be triggered when the PDC is monitoring the line. This also limits the usage of PDC to pins that are really waking up the system from some sort of sleep mode. Either the device driver is trying to wakeup from suspend so it's setting irq wake in the driver suspend path, or it's runtime suspending a device and wanting to wakeup from that device suspend state so it's again setting irq wake in runtime suspend. Either way, in "normal" active modes the irq path will be through the TLMM summary irq line and not through PDC. I don't know if a similar design would work for pre-PDC qcom hardware where the MPM is handled by RPM software. And finally, thinking about this after writing this mail I'm a little concerned that doing any sort of mask/unmask or irq movement from TLMM to PDC at runtime will miss edges for edge triggered interrupts. Is that also your concern? How is this handled with MPM? We would leave the TLMM interrupt enabled in that case and then have to replay the edge in software when resuming from suspend or idle paths but otherwise ignore the level type interrupts that MPM sees? I suppose MPM never gets an edge if TLMM gets the edge so this just works. I'm worried that when we're moving the gpio irq line from the summary GIC SPI line to the PDC's GIC SPI line we'll get an edge and then miss it in TLMM and be too late unmasking it in PDC or worse see it in PDC and TLMM because we unmask in PDC before masking in TLMM. So we may need to change #4 up above to always allocate the irq from PDC and somehow communicate that the irq is wakeup capable in PDC back to the TLMM driver so TLMM knows to keep the irq masked in the hardware forever. That way it can't cause the summary irq line to trigger in addition to the PDC one. Given that we have allocation hooks with domain hierarchy it may be easy enough to remove TLMM irqs from the summary irq domain when they can be allocated from the parent PDC domain.