Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2315298rwb; Mon, 19 Sep 2022 03:18:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4svUrQtxB6hcbqXSI78NgGx55PLD30PHGC4IrtontvTZOAOiGcQf3e/fII6C6/DhRatN3F X-Received: by 2002:a17:902:f650:b0:172:8ee1:7f40 with SMTP id m16-20020a170902f65000b001728ee17f40mr12622128plg.101.1663582713663; Mon, 19 Sep 2022 03:18:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663582713; cv=none; d=google.com; s=arc-20160816; b=fIZUfoFaAv0ueOXAqTHjVN/XA9fDmvEmQn9n/sQS5gRfFJIPbOv1opSoo8Py+q1iYm BjAGHwero8+Qu/MhTTfwLiQSq3xKp2xmfKdDwr6IHlQSoQYNzcV6m6Ji+LPIxCQO2TTV Gh2kD0iCNG65IN81pY+eS6fMtTHAT5dD0tu3CYymXsPifDcuRvyVV9kvrTOx9DFj2TfN sv4szIeQmkAkiZLHBsrYLNZrWzTyfPKFP5UpBYWby9+olivDb6LToqE2DMvDxFuIrMSL nCCsCOEpzqwOCPY69EdKSTOhRH9Em7R7Or2zYWQgT/7ogxBKKfXNwZacJ5FN9x/4+RgG yxpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=SsCkL81jIfSLc6Jg33Tni2bbbS0oy+bbCGS3aW20JK4=; b=gVKKX4Jq4j9gX401joKfV/tGwmCT3S+yxce8Wa98fptknOx9tDHnWF7HYMLVQgR7wy aVrKg5sjn0luzFIUbzTOxwGuFwWziXyHB0HpeRCKKa/Ij9swerN/B+m0NzW9+klzYV+C ui8lDp1/42JRvkIU2ySdL34KE0his31+OMD41j62GYKd9q90la2mTxwZzQ5i9xa5VwLT A2c2clHJA2Z/0NBMLHWRViaNnfTuwUAkv2UExG/T5HXJBaipTcVAgyrjEwLJOODj0Qze GofF5+B0TsXBqXatABcAnPAvfPqgaC6eDOMgdK7mNUEGemlokbfdheukr+gwyFBNyPUH NIow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=bsKaM9zD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p129-20020a625b87000000b0052d45b66299si30081990pfb.312.2022.09.19.03.18.22; Mon, 19 Sep 2022 03:18:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=bsKaM9zD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229660AbiISJyX (ORCPT + 99 others); Mon, 19 Sep 2022 05:54:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229682AbiISJyV (ORCPT ); Mon, 19 Sep 2022 05:54:21 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A8D412AD1; Mon, 19 Sep 2022 02:54:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1663581260; x=1695117260; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=J84tZUNo70mPEn5i619JIcO867QIpVxzMSvGnO/5+I8=; b=bsKaM9zDaIbwkwleTrglfuDwMot7CaoLbHG9DnScRE3TePWPrxjw9SWl zFD+CVTPQNm7qODXYw5wnZzt5QkMWRmVvbIUscTkud5+7Iz2AZWBJWS57 0GFHR/pdcQk1WRILBOCK7QgUe3zbEPcB3Z6ZK9GknTtIeQACQZQjL0Kmt FN2EXLqR1LEbhUmLPRkQmOwxa5Fgo8itoLg2OEEGA9xdTl6y4YluMSiD5 OuSTSt8Q3kmeBDBlSh9jJvkYrncW9fr0p+qW/h9OxcTPnGs/XqEbwcRY8 FTMIwH4zPfm+/hEZ/GXIKsvbxsqsb6exOKxzDYluJkaqWLU6JwHyAmGOD A==; X-IronPort-AV: E=McAfee;i="6500,9779,10474"; a="363314046" X-IronPort-AV: E=Sophos;i="5.93,327,1654585200"; d="scan'208";a="363314046" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Sep 2022 02:54:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,327,1654585200"; d="scan'208";a="793795409" Received: from smile.fi.intel.com ([10.237.72.54]) by orsmga005.jf.intel.com with ESMTP; 19 Sep 2022 02:54:16 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1oaDTh-004VMM-2h; Mon, 19 Sep 2022 12:54:13 +0300 Date: Mon, 19 Sep 2022 12:54:13 +0300 From: Andy Shevchenko To: Raul E Rangel Cc: linux-acpi@vger.kernel.org, linux-input@vger.kernel.org, jingle.wu@emc.com.tw, rafael@kernel.org, mario.limonciello@amd.com, hdegoede@redhat.com, linus.walleij@linaro.org, timvp@google.com, dmitry.torokhov@gmail.com, Bartosz Golaszewski , Len Brown , Mika Westerberg , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 05/13] gpiolib: acpi: Add wake_capable variants of acpi_dev_gpio_irq_get Message-ID: References: <20220914235801.1731478-1-rrangel@chromium.org> <20220914155914.v3.5.I4ff95ba7e884a486d7814ee888bf864be2ebdef4@changeid> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220914155914.v3.5.I4ff95ba7e884a486d7814ee888bf864be2ebdef4@changeid> X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 14, 2022 at 05:57:53PM -0600, Raul E Rangel wrote: > The ACPI spec defines the SharedAndWake and ExclusiveAndWake share type > keywords. This is an indication that the GPIO IRQ can also be used as a > wake source. This change exposes the wake_capable bit so drivers can > correctly enable wake functionality instead of making an assumption. With two nit-picks below Reviewed-by: Andy Shevchenko > Signed-off-by: Raul E Rangel > --- > > Changes in v3: > - Kept `acpi_dev_gpio_irq_get_by` unchanged to avoid having to touch > unrelated drivers. > - Converted wake_capable parameter to bool. > > Changes in v2: > - Fixed call site in mlxbf_gige_probe > > drivers/gpio/gpiolib-acpi.c | 17 ++++++++++++++--- > drivers/gpio/gpiolib-acpi.h | 2 ++ > include/linux/acpi.h | 22 ++++++++++++++++++---- > 3 files changed, 34 insertions(+), 7 deletions(-) > > diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c > index 9be1376f9a627f..c703f095993a2c 100644 > --- a/drivers/gpio/gpiolib-acpi.c > +++ b/drivers/gpio/gpiolib-acpi.c > @@ -741,6 +741,8 @@ static int acpi_populate_gpio_lookup(struct acpi_resource *ares, void *data) > lookup->info.pin_config = agpio->pin_config; > lookup->info.debounce = agpio->debounce_timeout; > lookup->info.gpioint = gpioint; > + lookup->info.wake_capable = agpio->wake_capable == > + ACPI_WAKE_CAPABLE; Can be still on one line. > /* > * Polarity and triggering are only specified for GpioInt > @@ -987,10 +989,12 @@ struct gpio_desc *acpi_node_get_gpiod(struct fwnode_handle *fwnode, > } > > /** > - * acpi_dev_gpio_irq_get_by() - Find GpioInt and translate it to Linux IRQ number > + * acpi_dev_gpio_irq_wake_get_by() - Find GpioInt and translate it to Linux IRQ > + * number > * @adev: pointer to a ACPI device to get IRQ from > * @name: optional name of GpioInt resource > * @index: index of GpioInt resource (starting from %0) > + * @wake_capable: Set to true if the IRQ is wake capable > * > * If the device has one or more GpioInt resources, this function can be > * used to translate from the GPIO offset in the resource to the Linux IRQ > @@ -1002,9 +1006,13 @@ struct gpio_desc *acpi_node_get_gpiod(struct fwnode_handle *fwnode, > * The function takes optional @name parameter. If the resource has a property > * name, then only those will be taken into account. > * > + * The GPIO is considered wake capable if the GpioInt resource specifies > + * SharedAndWake or ExclusiveAndWake. > + * > * Return: Linux IRQ number (> %0) on success, negative errno on failure. > */ > -int acpi_dev_gpio_irq_get_by(struct acpi_device *adev, const char *name, int index) > +int acpi_dev_gpio_irq_wake_get_by(struct acpi_device *adev, const char *name, > + int index, bool *wake_capable) > { > int idx, i; > unsigned int irq_flags; > @@ -1061,13 +1069,16 @@ int acpi_dev_gpio_irq_get_by(struct acpi_device *adev, const char *name, int ind > dev_dbg(&adev->dev, "IRQ %d already in use\n", irq); > } > > + if (wake_capable) > + *wake_capable = info.wake_capable; > + > return irq; > } > > } > return -ENOENT; > } > -EXPORT_SYMBOL_GPL(acpi_dev_gpio_irq_get_by); > +EXPORT_SYMBOL_GPL(acpi_dev_gpio_irq_wake_get_by); > > static acpi_status > acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address, > diff --git a/drivers/gpio/gpiolib-acpi.h b/drivers/gpio/gpiolib-acpi.h > index e476558d947136..1ac6816839dbce 100644 > --- a/drivers/gpio/gpiolib-acpi.h > +++ b/drivers/gpio/gpiolib-acpi.h > @@ -18,6 +18,7 @@ struct acpi_device; > * @pin_config: pin bias as provided by ACPI > * @polarity: interrupt polarity as provided by ACPI > * @triggering: triggering type as provided by ACPI > + * @wake_capable: wake capability as provided by ACPI > * @debounce: debounce timeout as provided by ACPI > * @quirks: Linux specific quirks as provided by struct acpi_gpio_mapping > */ > @@ -28,6 +29,7 @@ struct acpi_gpio_info { > int pin_config; > int polarity; > int triggering; > + bool wake_capable; > unsigned int debounce; > unsigned int quirks; > }; > diff --git a/include/linux/acpi.h b/include/linux/acpi.h > index 6f64b2f3dc5479..d3121cef6cc3bc 100644 > --- a/include/linux/acpi.h > +++ b/include/linux/acpi.h > @@ -1202,7 +1202,8 @@ bool acpi_gpio_get_irq_resource(struct acpi_resource *ares, > struct acpi_resource_gpio **agpio); > bool acpi_gpio_get_io_resource(struct acpi_resource *ares, > struct acpi_resource_gpio **agpio); > -int acpi_dev_gpio_irq_get_by(struct acpi_device *adev, const char *name, int index); > +int acpi_dev_gpio_irq_wake_get_by(struct acpi_device *adev, const char *name, > + int index, bool *wake_capable); > #else > static inline bool acpi_gpio_get_irq_resource(struct acpi_resource *ares, > struct acpi_resource_gpio **agpio) > @@ -1214,16 +1215,29 @@ static inline bool acpi_gpio_get_io_resource(struct acpi_resource *ares, > { > return false; > } > -static inline int acpi_dev_gpio_irq_get_by(struct acpi_device *adev, > - const char *name, int index) > +static inline int acpi_dev_gpio_irq_wake_get_by(struct acpi_device *adev, > + const char *name, int index, > + bool *wake_capable) > { > return -ENXIO; > } > #endif > > +static inline int acpi_dev_gpio_irq_get_by(struct acpi_device *adev, > + const char *name, int index) > +{ > + return acpi_dev_gpio_irq_wake_get_by(adev, name, index, NULL); > +} > + > static inline int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index) > { > - return acpi_dev_gpio_irq_get_by(adev, NULL, index); > + return acpi_dev_gpio_irq_wake_get_by(adev, NULL, index, NULL); > +} > +static inline int acpi_dev_gpio_irq_wake_get(struct acpi_device *adev, > + int index, bool *wake_capable) > +{ > + return acpi_dev_gpio_irq_wake_get_by(adev, NULL, index, wake_capable); > } I would put this first in the group of these three helpers, so irq_get_by and irq_get will be the last (from more parameters to less parameters). > /* Device properties */ > -- > 2.37.3.968.ga6b4b080e4-goog > -- With Best Regards, Andy Shevchenko