Message ID | 20231213110009.v1.3.I29b26a7f3b80fac0a618707446a10b6cc974fdaf@changeid |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp7960917dys; Wed, 13 Dec 2023 10:01:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IEars0bE6cAB6aWPztijp6UyxaTwat3ed1mH10lx4y3zlnb0YVw76jaJfEoOdrM4pwI/2As X-Received: by 2002:a05:6a00:2da1:b0:6ce:2731:47b7 with SMTP id fb33-20020a056a002da100b006ce273147b7mr10181707pfb.23.1702490517225; Wed, 13 Dec 2023 10:01:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702490517; cv=none; d=google.com; s=arc-20160816; b=OeWLnwLCAT3HVigkJz2k6ai92R1DxjNZdQ4RS3Nxnc7+Wl1IIHJBEdMHB2rlVLUtQH FMnA8kJ1PR2asmgN065Oa5XRXGaJnzvBjEqO3T21DSSFYxyiFYfEKlRsqNfvHYivCAUH o189Olaol4wy+OzrwG252XQUyk3TKscGoJBSmLgSB0v6OQX7CNJcac5r4CZCb+rUdoSz vvA4cBs062Wb0YNlQqoDtLqQm4fRwJVuurcZjtEMFALaH3xV3oxKkUkOajbhlAYVStRq 2R7wzYqWtfv0hov2H2qut4fi5Cfco2e1QR84WgFWGH7PLmt4sC3ivsi6XK8trURDfUyt cRKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=IE6mE6pjbGov9LkkEhCEwGDUbXlSJbMapTwV75Z3EGc=; fh=zxG5iud9xF1D6IY8H/gUMSGI5vQPvUvLe4axMqsZymY=; b=CSn7IpnZBSeEPdRx7yvD9xZkXMpCPzj4VixkEqN4uef6L99JhZtrDOGU8h3Ut73uJ2 gDStmKkWc20iicwjdEek8QEyH1x5pzZVRZMwy5nri3/ik8mKHQS+76lNvsB9cdG7KfkK l7VRRUbxDpiUE6GVbey79vVwfS46o6PpkHG/RqGKWTJ+k9AsD9eLvUDeCA+8K6BD6O04 7mfiM1410E8ehvkDTWL2r2VH27Qbdg8JxyHkutHcbxp+iaKL1cMZlMWFQLG5wQDp1T2A Y7oWiS+ZEsJKTn9JRdrZLsAAIUdzgweJbbXbCMCiVcySHGXqcxKUjFMX+vwx+SmvUBxa DZxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=eSF3iGXX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id r15-20020a6560cf000000b005c67e7f7917si9801959pgv.409.2023.12.13.10.01.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 10:01:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=eSF3iGXX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 8C080826E8F6; Wed, 13 Dec 2023 10:01:53 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378894AbjLMSBg (ORCPT <rfc822;dexuan.linux@gmail.com> + 99 others); Wed, 13 Dec 2023 13:01:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233692AbjLMSBb (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 13 Dec 2023 13:01:31 -0500 Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D3E783 for <linux-kernel@vger.kernel.org>; Wed, 13 Dec 2023 10:01:37 -0800 (PST) Received: by mail-il1-x136.google.com with SMTP id e9e14a558f8ab-35d67aa6951so20728525ab.0 for <linux-kernel@vger.kernel.org>; Wed, 13 Dec 2023 10:01:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1702490497; x=1703095297; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IE6mE6pjbGov9LkkEhCEwGDUbXlSJbMapTwV75Z3EGc=; b=eSF3iGXXOC2kQ3n5Nvjxs6TXImtBZ+93Z/bZSIAOBmGzEVcfVUtzn/EVhDmjEsflaq MZmH+PNqez1eEtLBjr+QZtLdrvyS19dkt6p8/fahgjp3jxHcDCYZUNQo9zxtMR7vDHe5 Bncbrq6uoJ/qVNICvi3OH76+02VUHERHM3VFg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702490497; x=1703095297; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IE6mE6pjbGov9LkkEhCEwGDUbXlSJbMapTwV75Z3EGc=; b=aaD6mzys0O/aqEXtnIbECOwKbdTr0LjdpKdhmg+7WodoLIzWSm8PmXTKajWhhLgb+j z6FilWaSUCC7+SGBwQMycWb4KRaXhxbVJ0JVMx1zFxun2DT4+owQYVsrzvRQdCb8OxKG 2MTc3L0z7GM+MP3/oUh2aTSs11KMdmp1ZQvpEOdTim7IrGntq1fALcnHdJgGpsjpGqZe 8kKx1bFMafmKMEFJJyEk/yI8E2nhoHFo5S6dO6KSHkuqxL8nuta5lKfGUYHIUVRX6KJZ 96JhrBeY75S4tH62aV6d/cm75B6xQkp9BoST1gn6brdOCVXwMF2Np2BN2CgClVUksuol vfGg== X-Gm-Message-State: AOJu0Yz2CZFBTE5UmP5ppiXeCITMKEy17lgmjFEwjgHdIAmya2cmJO62 y2xPFjgv5SesesiNSO9/1ntu4639zJrfux3YTcI= X-Received: by 2002:a05:6e02:b45:b0:35d:59b3:2f86 with SMTP id f5-20020a056e020b4500b0035d59b32f86mr7479369ilu.27.1702490496668; Wed, 13 Dec 2023 10:01:36 -0800 (PST) Received: from markhas1.corp.google.com ([100.107.108.224]) by smtp.gmail.com with ESMTPSA id o28-20020a02cc3c000000b0046671f9717csm3161206jap.109.2023.12.13.10.01.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 10:01:36 -0800 (PST) From: Mark Hasemeyer <markhas@chromium.org> To: LKML <linux-kernel@vger.kernel.org> Cc: Raul Rangel <rrangel@chromium.org>, Mark Hasemeyer <markhas@chromium.org>, Frank Rowand <frowand.list@gmail.com>, Rob Herring <robh+dt@kernel.org>, devicetree@vger.kernel.org Subject: [PATCH v1 3/6] of: irq: add wake capable bit to of_irq_resource() Date: Wed, 13 Dec 2023 11:00:21 -0700 Message-ID: <20231213110009.v1.3.I29b26a7f3b80fac0a618707446a10b6cc974fdaf@changeid> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog In-Reply-To: <20231213110009.v1.1.Ifd0903f1c351e84376d71dbdadbd43931197f5ea@changeid> References: <20231213110009.v1.1.Ifd0903f1c351e84376d71dbdadbd43931197f5ea@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Wed, 13 Dec 2023 10:01:53 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785190696525095104 X-GMAIL-MSGID: 1785190696525095104 |
Series |
[v1,1/6] gpiolib: acpi: Modify acpi_dev_irq_wake_get_by to use resource
|
|
Commit Message
Mark Hasemeyer
Dec. 13, 2023, 6 p.m. UTC
Add wake capability information to the irq resource. Wake capability is
assumed based on conventions provided in the devicetree wakeup-source
binding documentation. An interrupt is considered wake capable if the
following are true:
1. a wakeup-source property exits in the same device node as the
interrupt.
2. No dedicated irq is defined, or the irq is marked as dedicated by
setting its interrupt-name to "wakeup".
The wakeup-source documentation states that dedicated interrupts can use
device specific interrupt names and device drivers are still welcome to
use their own naming schemes. This api is provided as a helper if one is
willing to conform to the above conventions.
The ACPI subsystems already provides similar apis that allow one to
query the wake capability of an irq. This brings feature parity to the
devicetree.
Signed-off-by: Mark Hasemeyer <markhas@chromium.org>
---
drivers/of/irq.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
Comments
On Wed, Dec 13, 2023 at 11:00:21AM -0700, Mark Hasemeyer wrote: > Add wake capability information to the irq resource. Wake capability is IRQ > assumed based on conventions provided in the devicetree wakeup-source > binding documentation. An interrupt is considered wake capable if the > following are true: > 1. a wakeup-source property exits in the same device node as the > interrupt. > 2. No dedicated irq is defined, or the irq is marked as dedicated by IRQ > setting its interrupt-name to "wakeup". > > The wakeup-source documentation states that dedicated interrupts can use > device specific interrupt names and device drivers are still welcome to > use their own naming schemes. This api is provided as a helper if one is API > willing to conform to the above conventions. > > The ACPI subsystems already provides similar apis that allow one to APIs > query the wake capability of an irq. This brings feature parity to the > devicetree. ... > +/** > + * __of_irq_wake_capable - Determine whether a given irq index is wake capable IRQ > + * The irq is considered wake capable if the following are true: IRQ > + * 1. wakeup-source property exists > + * 2. no dedicated wakeirq exists OR provided irq index is a dedicated wakeirq IRQ > + * This logic assumes the provided irq index is valid. IRQ > + * @dev: pointer to device tree node > + * @index: zero-based index of the irq IRQ > + * Return: True if provided irq index for #dev is wake capable. False otherwise. IRQ @dev > + */ ... > /** > * of_irq_to_resource - Decode a node's IRQ and return it as a resource > * @dev: pointer to device tree node > * @index: zero-based index of the irq > * @r: pointer to resource structure to return result into. > + * > + * Return: Linux IRQ number on success, or 0 on the IRQ mapping failure, or > + * -EPROBE_DEFER if the IRQ domain is not yet created, or error code in case > + * of any other failure. > */ You see, your new text is even inconsistent with the existing one...
On Wed, Dec 13, 2023 at 11:00:21AM -0700, Mark Hasemeyer wrote: > Add wake capability information to the irq resource. Wake capability is > assumed based on conventions provided in the devicetree wakeup-source > binding documentation. An interrupt is considered wake capable if the > following are true: > 1. a wakeup-source property exits in the same device node as the > interrupt. > 2. No dedicated irq is defined, or the irq is marked as dedicated by > setting its interrupt-name to "wakeup". > > The wakeup-source documentation states that dedicated interrupts can use > device specific interrupt names and device drivers are still welcome to > use their own naming schemes. This api is provided as a helper if one is > willing to conform to the above conventions. > > The ACPI subsystems already provides similar apis that allow one to > query the wake capability of an irq. This brings feature parity to the > devicetree. > > Signed-off-by: Mark Hasemeyer <markhas@chromium.org> > --- > > drivers/of/irq.c | 30 ++++++++++++++++++++++++++++++ > 1 file changed, 30 insertions(+) > > diff --git a/drivers/of/irq.c b/drivers/of/irq.c > index 174900072c18c..633711bc32953 100644 > --- a/drivers/of/irq.c > +++ b/drivers/of/irq.c > @@ -383,11 +383,39 @@ int of_irq_parse_one(struct device_node *device, int index, struct of_phandle_ar > } > EXPORT_SYMBOL_GPL(of_irq_parse_one); > > +/** > + * __of_irq_wake_capable - Determine whether a given irq index is wake capable > + * > + * The irq is considered wake capable if the following are true: > + * 1. wakeup-source property exists > + * 2. no dedicated wakeirq exists OR provided irq index is a dedicated wakeirq > + * > + * This logic assumes the provided irq index is valid. > + * > + * @dev: pointer to device tree node > + * @index: zero-based index of the irq > + * Return: True if provided irq index for #dev is wake capable. False otherwise. > + */ > +static bool __of_irq_wake_capable(const struct device_node *dev, int index) > +{ > + int wakeindex; > + > + if (!of_property_read_bool(dev, "wakeup-source")) > + return false; > + > + wakeindex = of_property_match_string(dev, "interrupt-names", "wakeup"); > + return wakeindex < 0 || wakeindex == index; If a device has multiple interrupts, but none named "wakeup" you are saying all the interrupts are wakeup capable. That's not right though. Only the device knows which interrupts are wakeup capable. You need: return wakeindex >= 0 && wakeindex == index; Rob
> If a device has multiple interrupts, but none named "wakeup" you are > saying all the interrupts are wakeup capable. That's not right though. > Only the device knows which interrupts are wakeup capable. You need: > > return wakeindex >= 0 && wakeindex == index; I was assuming logic described in the DT bindings: https://www.kernel.org/doc/Documentation/devicetree/bindings/power/wakeup-source.txt "Also, if device is marked as a wakeup source, then all the primary interrupt(s) can be used as wakeup interrupt(s)."
On Thu, Dec 14, 2023 at 02:05:16PM -0700, Mark Hasemeyer wrote: > > If a device has multiple interrupts, but none named "wakeup" you are > > saying all the interrupts are wakeup capable. That's not right though. > > Only the device knows which interrupts are wakeup capable. You need: > > > > return wakeindex >= 0 && wakeindex == index; > > I was assuming logic described in the DT bindings: > https://www.kernel.org/doc/Documentation/devicetree/bindings/power/wakeup-source.txt > "Also, if device is marked as a wakeup source, then all the primary > interrupt(s) can be used as wakeup interrupt(s)." Also not the best wording I think. Which interrupts are primary interrupts? If we can't determine which interrupt, then we should just leave it up to the device. Rob
On Fri, Dec 15, 2023 at 8:30 AM Rob Herring <robh@kernel.org> wrote: > > On Thu, Dec 14, 2023 at 02:05:16PM -0700, Mark Hasemeyer wrote: > > > If a device has multiple interrupts, but none named "wakeup" you are > > > saying all the interrupts are wakeup capable. That's not right though. > > > Only the device knows which interrupts are wakeup capable. You need: > > > > > > return wakeindex >= 0 && wakeindex == index; > > > > I was assuming logic described in the DT bindings: > > https://www.kernel.org/doc/Documentation/devicetree/bindings/power/wakeup-source.txt > > "Also, if device is marked as a wakeup source, then all the primary > > interrupt(s) can be used as wakeup interrupt(s)." > > Also not the best wording I think. > > Which interrupts are primary interrupts? > > If we can't determine which interrupt, then we should just leave it up > to the device. > > Rob +Sudeep who authored the documentation and Rob Ack'd: a68eee4c748c ("Documentation: devicetree: standardize/consolidate on "wakeup-source" property") I think what Rob is suggesting more closely matches what ACPI supports: where interrupt resources are individually marked as wake capable. The binding documentation should be updated though. Something like: ``` If the device is marked as a wakeup-source, interrupt wake capability depends on the device specific "interrupt-names" property. If no interrupts are labeled as wake capable, then it is up to the device to determine which interrupts can wake the system. However if a device has a dedicated interrupt as the wakeup source, then it needs to specify/identify it using a device specific interrupt name. In such cases only that interrupt can be used as a wakeup interrupt. While various legacy interrupt names exist, new devices should use "wakeup" as the canonical interrupt name. ``` Parts of the kernel (I2C, bluetooth, MMC) assume "wakeup" as the interrupt-name. I added some wording to clarify the assumption. Thoughts?
On Fri, Dec 15, 2023 at 01:56:47PM -0700, Mark Hasemeyer wrote: > On Fri, Dec 15, 2023 at 8:30 AM Rob Herring <robh@kernel.org> wrote: > > > > On Thu, Dec 14, 2023 at 02:05:16PM -0700, Mark Hasemeyer wrote: > > > > If a device has multiple interrupts, but none named "wakeup" you are > > > > saying all the interrupts are wakeup capable. That's not right though. > > > > Only the device knows which interrupts are wakeup capable. You need: > > > > Agreed. > > > > return wakeindex >= 0 && wakeindex == index; > > > > > > I was assuming logic described in the DT bindings: > > > https://www.kernel.org/doc/Documentation/devicetree/bindings/power/wakeup-source.txt > > > "Also, if device is marked as a wakeup source, then all the primary > > > interrupt(s) can be used as wakeup interrupt(s)." At the time it was written, the intention was not to fix any particular interrupt as wakeup but leave those details to the device. Also this was just to consolidate various variation of similar bindings/support for the same wake feature. It didn't enforce any rules as what can be or can't be wakeup interrupt. > > > > Also not the best wording I think. > > > > Which interrupts are primary interrupts? > > > > If we can't determine which interrupt, then we should just leave it up > > to the device. > > Again I agree with this. > +Sudeep who authored the documentation and Rob Ack'd: a68eee4c748c > ("Documentation: devicetree: standardize/consolidate on "wakeup-source" > property") > > I think what Rob is suggesting more closely matches what ACPI supports: where > interrupt resources are individually marked as wake capable. The binding > documentation should be updated though. > > Something like: > ``` > If the device is marked as a wakeup-source, interrupt wake capability depends > on the device specific "interrupt-names" property. If no interrupts are labeled > as wake capable, then it is up to the device to determine which interrupts can > wake the system. > > However if a device has a dedicated interrupt as the wakeup source, then it > needs to specify/identify it using a device specific interrupt name. In such > cases only that interrupt can be used as a wakeup interrupt. > > While various legacy interrupt names exist, new devices should use "wakeup" as > the canonical interrupt name. > ``` > > Parts of the kernel (I2C, bluetooth, MMC) assume "wakeup" as the > interrupt-name. I added some wording to clarify the assumption. > > Thoughts? Above wordings sounds good to me. -- Regards, Sudeep
diff --git a/drivers/of/irq.c b/drivers/of/irq.c index 174900072c18c..633711bc32953 100644 --- a/drivers/of/irq.c +++ b/drivers/of/irq.c @@ -383,11 +383,39 @@ int of_irq_parse_one(struct device_node *device, int index, struct of_phandle_ar } EXPORT_SYMBOL_GPL(of_irq_parse_one); +/** + * __of_irq_wake_capable - Determine whether a given irq index is wake capable + * + * The irq is considered wake capable if the following are true: + * 1. wakeup-source property exists + * 2. no dedicated wakeirq exists OR provided irq index is a dedicated wakeirq + * + * This logic assumes the provided irq index is valid. + * + * @dev: pointer to device tree node + * @index: zero-based index of the irq + * Return: True if provided irq index for #dev is wake capable. False otherwise. + */ +static bool __of_irq_wake_capable(const struct device_node *dev, int index) +{ + int wakeindex; + + if (!of_property_read_bool(dev, "wakeup-source")) + return false; + + wakeindex = of_property_match_string(dev, "interrupt-names", "wakeup"); + return wakeindex < 0 || wakeindex == index; +} + /** * of_irq_to_resource - Decode a node's IRQ and return it as a resource * @dev: pointer to device tree node * @index: zero-based index of the irq * @r: pointer to resource structure to return result into. + * + * Return: Linux IRQ number on success, or 0 on the IRQ mapping failure, or + * -EPROBE_DEFER if the IRQ domain is not yet created, or error code in case + * of any other failure. */ int of_irq_to_resource(struct device_node *dev, int index, struct resource *r) { @@ -411,6 +439,8 @@ int of_irq_to_resource(struct device_node *dev, int index, struct resource *r) r->start = r->end = irq; r->flags = IORESOURCE_IRQ | irqd_get_trigger_type(irq_get_irq_data(irq)); + if (__of_irq_wake_capable(dev, index)) + r->flags |= IORESOURCE_IRQ_WAKECAPABLE; r->name = name ? name : of_node_full_name(dev); }