Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp805285rwn; Thu, 8 Sep 2022 09:02:02 -0700 (PDT) X-Google-Smtp-Source: AA6agR6VsF/XQCj/YGWooEjWfNo1Qu9vjW/Q56WxhpNlRz5vu3cLFtfLXi8e1y5JVOhsOnynFWTj X-Received: by 2002:a17:90a:4fe3:b0:1fd:b6f7:f5e3 with SMTP id q90-20020a17090a4fe300b001fdb6f7f5e3mr4845349pjh.169.1662652922732; Thu, 08 Sep 2022 09:02:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662652922; cv=none; d=google.com; s=arc-20160816; b=ctLKkZwlt+gVfHQgCc66ly/fA+6jVLvskKjL3WHPSqW4+gSNaojtuP/hxK/zfZmWRj bP1UcC50Cm7RjJxZbbQlOrih7dWlefPtDC6397HswHO3tvKY5g2NHu15JY5HFpiZpFTq TaDyu9Rx1/WfrSznhcbgeiisr6gr30rHbHJ0ktEP2vcFj2we4xqWah2UZQiouEUbcnE7 cX/Vwi2i0mMTDyHh9w94ZtncSh+Be8xOwMcUsq+bMgRAKpYLOYefXla6I4NrO58MnuEM CyXnAtnInV7k42CqKPGUzFwMcltHUel+DF5AcRmd2a1GEVXAZB1dZVkGpoQnb73a+cCX nbHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=hy6RYfrm5HmnR/mLw7f4LGBQqKyWCny7YZKaMviwD+g=; b=boAS7+NxlgHzDHFQVgIwv2iQDDlSCFhJTngm+m/tf9FvFIoWBqTvUwaR9I4FzBVfmW SHh9uzUSEVYMbQ8BNlxbEMtGlE59PcgcrNtBS5m5fjbHX0Gh/PqEDq5Bz1/UShzVN0cz jre5uzpu37Oqsz/m4A6nsvLDkrlD9Mc3orHDLiwWHp8F8g2E/nCIWk4iXjgyxDLQl1JJ OQ4rsb5hTh1PO+PZ8f1KfK7rDj8nXrP2VGGOOR0aKobLcyZTcCgLML8K2uWmQSm90hSO lf2Bok40eB8ifUSWI7lcerWF2UNHESk5CIDKxC5MVB8Dy0c7fWT9eTK7L3K5e3b5CKr/ O5bw== ARC-Authentication-Results: i=1; mx.google.com; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pc3-20020a17090b3b8300b001fd73f8193csi3318190pjb.10.2022.09.08.09.01.48; Thu, 08 Sep 2022 09:02:02 -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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229445AbiIHPYE (ORCPT + 99 others); Thu, 8 Sep 2022 11:24:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232544AbiIHPXw (ORCPT ); Thu, 8 Sep 2022 11:23:52 -0400 Received: from mail-yw1-f171.google.com (mail-yw1-f171.google.com [209.85.128.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DCD21EB2EE; Thu, 8 Sep 2022 08:23:50 -0700 (PDT) Received: by mail-yw1-f171.google.com with SMTP id 00721157ae682-3487d84e477so46960687b3.6; Thu, 08 Sep 2022 08:23:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=hy6RYfrm5HmnR/mLw7f4LGBQqKyWCny7YZKaMviwD+g=; b=GN+prGANnKxenbDDawxnZwSe02nuS3w13Yp/PwykK91iUw3ID+LM4DVPcg/qjxUYiG vETZsHymfjp/V6cNrPR6BHzMREvrllk7sO8qpR1RB8AKXnAiD+0G8F48rYibNaSNivNQ itpV+0Xq2/N1fBpyp6ZZ7IYQKIRMElpiFZYhGicXCqUZxMNELX6l4fHGmj6zP1ZMa3CY 6VFRe1ajrhw/r1UuNZASqmfUZxRY2QtXII5JVO8/h4RDZLjaFjoEx1nOMrx+o46zTUEO HXA/OcWkLymJ9sZoQNS0dZDe5yEOZ1SWe9TjpFR9n0ggeWakDiv43QQCQKcSp2dAT73W 6afA== X-Gm-Message-State: ACgBeo0yavldGuCIwAhWisSv/I4lbeEvJap4TnntDjJeh6KtOAaN0YbH NzMgqa9DfPBxPUQurT7QzIiTkpKKZtItrgRdapI= X-Received: by 2002:a81:9407:0:b0:345:6683:d757 with SMTP id l7-20020a819407000000b003456683d757mr7948011ywg.326.1662650629499; Thu, 08 Sep 2022 08:23:49 -0700 (PDT) MIME-Version: 1.0 References: <20220830231541.1135813-1-rrangel@chromium.org> <20220830171332.4.I8af4282adc72eb9f247adcd03676a43893a020a6@changeid> <98559c23-cc22-3b85-2102-0cc760240804@redhat.com> In-Reply-To: From: "Rafael J. Wysocki" Date: Thu, 8 Sep 2022 17:23:37 +0200 Message-ID: Subject: Re: [PATCH 4/8] i2c: acpi: Use ACPI GPIO wake capability bit to set wake_irq To: Raul Rangel Cc: Hans de Goede , Dmitry Torokhov , Linux ACPI , linux-input , "Limonciello, Mario" , Tim Van Patten , "Rafael J. Wysocki" , Mika Westerberg , Wolfram Sang , "open list:I2C SUBSYSTEM HOST DRIVERS" , linux-kernel Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no 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 Thu, Sep 8, 2022 at 4:40 PM Raul Rangel wrote: > > On Wed, Sep 7, 2022 at 2:12 AM Hans de Goede wrote: > > > > Hi, > > > > On 9/7/22 04:00, Raul Rangel wrote: > > > On Tue, Sep 6, 2022 at 7:00 PM Dmitry Torokhov > > > wrote: > > >> > > >> On Tue, Aug 30, 2022 at 05:15:37PM -0600, Raul E Rangel wrote: > > >>> Device tree already has a mechanism to pass the wake_irq. It does this > > >>> by looking for the wakeup-source property and setting the > > >>> I2C_CLIENT_WAKE flag. This CL adds the ACPI equivalent. It uses at the > > >>> ACPI GpioInt wake flag to determine if the interrupt can be used to wake > > >>> the system. Previously the i2c drivers had to make assumptions and > > >>> blindly enable the wake IRQ. This can cause spurious wake events. e.g., > > >>> If there is a device with an Active Low interrupt and the device gets > > >>> powered off while suspending, the interrupt line will go low since it's > > >>> no longer powered and wake the system. For this reason we should respect > > >>> the board designers wishes and honor the wake bit defined on the > > >>> GpioInt. > > >>> > > >>> This change does not cover the ACPI Interrupt or IRQ resources. > > >>> > > >>> Signed-off-by: Raul E Rangel > > >>> --- > > >>> > > >>> drivers/i2c/i2c-core-acpi.c | 8 ++++++-- > > >>> drivers/i2c/i2c-core-base.c | 17 +++++++++++------ > > >>> drivers/i2c/i2c-core.h | 4 ++-- > > >>> 3 files changed, 19 insertions(+), 10 deletions(-) > > >>> > > >>> diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c > > >>> index c762a879c4cc6b..cfe82a6ba3ef28 100644 > > >>> --- a/drivers/i2c/i2c-core-acpi.c > > >>> +++ b/drivers/i2c/i2c-core-acpi.c > > >>> @@ -182,12 +182,13 @@ static int i2c_acpi_add_resource(struct acpi_resource *ares, void *data) > > >>> /** > > >>> * i2c_acpi_get_irq - get device IRQ number from ACPI > > >>> * @client: Pointer to the I2C client device > > >>> + * @wake_capable: Set to 1 if the IRQ is wake capable > > >>> * > > >>> * Find the IRQ number used by a specific client device. > > >>> * > > >>> * Return: The IRQ number or an error code. > > >>> */ > > >>> -int i2c_acpi_get_irq(struct i2c_client *client) > > >>> +int i2c_acpi_get_irq(struct i2c_client *client, int *wake_capable) > > >>> { > > >>> struct acpi_device *adev = ACPI_COMPANION(&client->dev); > > >>> struct list_head resource_list; > > >>> @@ -196,6 +197,9 @@ int i2c_acpi_get_irq(struct i2c_client *client) > > >>> > > >>> INIT_LIST_HEAD(&resource_list); > > >>> > > >>> + if (wake_capable) > > >>> + *wake_capable = 0; > > >>> + > > >>> ret = acpi_dev_get_resources(adev, &resource_list, > > >>> i2c_acpi_add_resource, &irq); > > >> > > > > > > > > >> You also need to handle "Interrupt(..., ...AndWake)" case here. I would > > >> look into maybe defining > > >> > > >> #define IORESOURCE_IRQ_WAKECAPABLE (1<<6) > > >> > > >> in include/linux/ioport.h and plumbing it through from ACPI layer. > > >> > > >> Thanks. > > > > > > AFAIK the Intel (Not 100% certain) and AMD IO-APIC's can't actually > > > wake a system from suspend/suspend-to-idle. > > > > That may be true for S3 suspend (it sounds about right) there > > certainly is no way to "arm for wakeup" on the APIC, but with > > s2idle all IRQs which are not explicitly disabled by the OS > > still function normally so there any IRQ can be a wakeup > > source (AFAIK). That's true. Moreover, even for S3 there are transitions into it and there may be wakeup interrupts taking place during those transitions. Those may be any IRQs too. > > And even with S3 suspend I think some IRQs can act as wakeup, > > but that is configured by the BIOS then and not something which > > linux can enable/disable. E.g IIRC the parent IRQ of the GPIO > > controllers on x86 is an APIC IRQ ... It's more about how the system is wired up AFAICS. Basically, in order to wake up the system from S3, the given IRQ needs to be physically attached to an input that will trigger the platform wakeup logic while in S3. > > > > SGTM. I wanted to make sure there was interest before I invested the > time in adding the functionality. Hopefully I can push up a new patch > set tomorrow. Sounds good. :-)