Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5519329rwl; Tue, 11 Apr 2023 06:39:22 -0700 (PDT) X-Google-Smtp-Source: AKy350Zrs0E56mXEVuEY71bd/sIHQR97P0bjaG3oV73Lh/gaYvxmUecuHurdJexjmz1H4XA1qKcr X-Received: by 2002:a17:907:8e8a:b0:8f0:143d:ee34 with SMTP id tx10-20020a1709078e8a00b008f0143dee34mr10179228ejc.1.1681220361793; Tue, 11 Apr 2023 06:39:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681220361; cv=none; d=google.com; s=arc-20160816; b=IppN+AYWxYkcI6nqhQsS7y/6qrInS8TXXZD2mpv8hxZb9+Etn2URzUzBO7fjkFNwiJ Gv/DJPuQjX1IvKg37Epx3D7TcTuGhLF75FPOPw+5K2csX2H4GMNmvLk55ZLEPNSevc67 9T9St6KwX1/A4sdSe7xffx4IFF92oBWuU7OHIHnEc37qCnakmTN4QXGI24lGLmCIkQVP 65u/nFdS8rLrIkRhPG634sUMEopQgUmWILrGpXN0EPBVTpnQReXK3XBToNTC879UHwee SGChPxeBByhz8mIjq7NQj51YPlZ8x19i2Xe+JE86lvTM8Hs9K/745x3Mm0gvugwU2KU2 Dhag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=vrOYuqNiPd2bcPoAQiJstrA3DGctCaG7OtD7OxNRvsQ=; b=d0loC7Ru/BtF5lHUlXrswln9qk/5eyFSq+cNiz2dBGmSabRCRKAUFFAjjTGf29HYQA o7ompUV6j9OjGJa/0zxm92PE4h6nC6IvMBleKSSAw0Gph8mNdxcPK63LyVZq+Wh+aIls /qyZ6nW7pOo29iB8ud08Q/gJFH9y/0kOUxJ7f5TTm8ubEcp+fKqV3/K4dcAI5MPmRIqB zvFwvcgLgYQQyHElHv+4RXU29JQj/XHRggdFYC1W9f2To/us/upJXfiYh19YMUeEew4S LNzwiKZs6vn7l8r05iwpNN+NHEm2E1C3ati9GJ7wzfjUdjRcNWqC97qfG3doIu6yrt2A Lofw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=EkOKABoD; 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=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dd3-20020a1709069b8300b009333dc257b0si3030179ejc.350.2023.04.11.06.38.57; Tue, 11 Apr 2023 06:39:21 -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=@chromium.org header.s=google header.b=EkOKABoD; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229773AbjDKNft (ORCPT + 99 others); Tue, 11 Apr 2023 09:35:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229571AbjDKNfs (ORCPT ); Tue, 11 Apr 2023 09:35:48 -0400 Received: from mail-qk1-x730.google.com (mail-qk1-x730.google.com [IPv6:2607:f8b0:4864:20::730]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C20B730FE for ; Tue, 11 Apr 2023 06:35:46 -0700 (PDT) Received: by mail-qk1-x730.google.com with SMTP id b23so2522319qkn.10 for ; Tue, 11 Apr 2023 06:35:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1681220146; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=vrOYuqNiPd2bcPoAQiJstrA3DGctCaG7OtD7OxNRvsQ=; b=EkOKABoD6LTFdgA4R4fLK1/4nAaUARmB6B3iZr9hPnT7REDHE9t2nnZtxkvxBTTVN2 s+ZFCtnp/vrOkE+EE40L/xgqUyBBErS11CCpca2Y22znSx7JTHIG+WyNjau5uOAgMCqW Q8YkUyIvSSIW9F95JQ79r0tSsohuS+mulYQ2Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681220146; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vrOYuqNiPd2bcPoAQiJstrA3DGctCaG7OtD7OxNRvsQ=; b=pPtmb9lhmyt5BcYrn7rwQA4Dji9323Z9ZQevsIecAz6S6HiFqppwvuF5+6KbDW1H5U cvP0oiP/2igNBj91ZefThdvzSB1+eQKMsjOUlemmwojS02RnDznhRgwsbNUHvVyGC+34 63TFHrRL/tGOgPQMITBl6muGqhPafPJECkjWjC4ZLiyA4HrVtYBAWptItVTozBKF3T02 yWjEDRN/FLxFZ4lgOU6H8m0vqX6PUy5VgkHgbR0e77eCaP3VPFlcZjpdfvpK24QLwkN2 Xq6a/xgbiBqCrk0vEkunv+3N4OGrbXPb6mCDxrNEChAdrxUeDQsBojm24vxZXQP/AnwZ LrJQ== X-Gm-Message-State: AAQBX9eyskw36wc1/hHmO/iyXIEp0hG55bJGj68F8wfgLtZPIQgMC0HG A5m/33pBacJGdKwhwOwIquG0S9JY3CDtEfvmnNgc1g== X-Received: by 2002:a05:620a:4728:b0:745:ad92:8887 with SMTP id bs40-20020a05620a472800b00745ad928887mr3513462qkb.13.1681220145901; Tue, 11 Apr 2023 06:35:45 -0700 (PDT) MIME-Version: 1.0 References: <20230320093259.845178-1-korneld@chromium.org> <37178398-497c-900b-361a-34b1b77517aa@leemhuis.info> <36c7638f-964b-bee6-b44b-c8406e71dfec@leemhuis.info> In-Reply-To: <36c7638f-964b-bee6-b44b-c8406e71dfec@leemhuis.info> From: =?UTF-8?Q?Kornel_Dul=C4=99ba?= Date: Tue, 11 Apr 2023 15:35:35 +0200 Message-ID: Subject: Re: [PATCH] pinctrl: amd: Disable and mask interrupts on resume To: Linux regressions mailing list , Linus Walleij Cc: gregkh@linuxfoundation.org, Basavaraj Natikar , Shyam Sundar S K , upstream@semihalf.com, rad@semihalf.com, mattedavis@google.com, stable@vger.kernel.org, Sasha Levin , "Gong, Richard" , Mario Limonciello , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 Tue, Apr 11, 2023 at 3:29=E2=80=AFPM Linux regression tracking (Thorsten Leemhuis) wrote: > > On 11.04.23 15:09, Kornel Dul=C4=99ba wrote: > > On Tue, Apr 11, 2023 at 2:50=E2=80=AFPM Linux regression tracking (Thor= sten > > Leemhuis) wrote: > >> On 10.04.23 17:29, Gong, Richard wrote: > >>> On 4/10/2023 12:03 AM, Mario Limonciello wrote: > >>>> On 3/20/23 04:32, Kornel Dul=C4=99ba wrote: > >>>> > >>>>> This fixes a similar problem to the one observed in: > >>>>> commit 4e5a04be88fe ("pinctrl: amd: disable and mask interrupts on > >>>>> probe"). > >>>>> > >>>>> On some systems, during suspend/resume cycle firmware leaves > >>>>> an interrupt enabled on a pin that is not used by the kernel. > >>>>> This confuses the AMD pinctrl driver and causes spurious interrupts= . > >>>>> > >>>>> The driver already has logic to detect if a pin is used by the kern= el. > >>>>> Leverage it to re-initialize interrupt fields of a pin only if it's= not > >>>>> used by us. > >>>>> > >>>>> Signed-off-by: Kornel Dul=C4=99ba > >>>>> --- > >>>>> drivers/pinctrl/pinctrl-amd.c | 36 +++++++++++++++++++-----------= ----- > >>>>> 1 file changed, 20 insertions(+), 16 deletions(-) > >>>>> > >>>>> diff --git a/drivers/pinctrl/pinctrl-amd.c > >>>>> b/drivers/pinctrl/pinctrl-amd.c > >>>>> index 9236a132c7ba..609821b756c2 100644 > >>>>> --- a/drivers/pinctrl/pinctrl-amd.c > >>>>> +++ b/drivers/pinctrl/pinctrl-amd.c > >>>>> @@ -872,32 +872,34 @@ static const struct pinconf_ops amd_pinconf_o= ps > >>>>> =3D { > >>>>> .pin_config_group_set =3D amd_pinconf_group_set, > >>>>> }; > >>>>> -static void amd_gpio_irq_init(struct amd_gpio *gpio_dev) > >>>>> +static void amd_gpio_irq_init_pin(struct amd_gpio *gpio_dev, int p= in) > >>>>> { > >>>>> - struct pinctrl_desc *desc =3D gpio_dev->pctrl->desc; > >>>>> + const struct pin_desc *pd; > >>>>> unsigned long flags; > >>>>> u32 pin_reg, mask; > >>>>> - int i; > >>>>> mask =3D BIT(WAKE_CNTRL_OFF_S0I3) | BIT(WAKE_CNTRL_OFF_S3) = | > >>>>> BIT(INTERRUPT_MASK_OFF) | BIT(INTERRUPT_ENABLE_OFF) | > >>>>> BIT(WAKE_CNTRL_OFF_S4); > >>>>> - for (i =3D 0; i < desc->npins; i++) { > >>>>> - int pin =3D desc->pins[i].number; > >>>>> - const struct pin_desc *pd =3D pin_desc_get(gpio_dev->pctrl= , pin); > >>>>> - > >>>>> - if (!pd) > >>>>> - continue; > >>>>> + pd =3D pin_desc_get(gpio_dev->pctrl, pin); > >>>>> + if (!pd) > >>>>> + return; > >>>>> - raw_spin_lock_irqsave(&gpio_dev->lock, flags); > >>>>> + raw_spin_lock_irqsave(&gpio_dev->lock, flags); > >>>>> + pin_reg =3D readl(gpio_dev->base + pin * 4); > >>>>> + pin_reg &=3D ~mask; > >>>>> + writel(pin_reg, gpio_dev->base + pin * 4); > >>>>> + raw_spin_unlock_irqrestore(&gpio_dev->lock, flags); > >>>>> +} > >>>>> - pin_reg =3D readl(gpio_dev->base + i * 4); > >>>>> - pin_reg &=3D ~mask; > >>>>> - writel(pin_reg, gpio_dev->base + i * 4); > >>>>> +static void amd_gpio_irq_init(struct amd_gpio *gpio_dev) > >>>>> +{ > >>>>> + struct pinctrl_desc *desc =3D gpio_dev->pctrl->desc; > >>>>> + int i; > >>>>> - raw_spin_unlock_irqrestore(&gpio_dev->lock, flags); > >>>>> - } > >>>>> + for (i =3D 0; i < desc->npins; i++) > >>>>> + amd_gpio_irq_init_pin(gpio_dev, i); > >>>>> } > >>>>> #ifdef CONFIG_PM_SLEEP > >>>>> @@ -950,8 +952,10 @@ static int amd_gpio_resume(struct device *dev) > >>>>> for (i =3D 0; i < desc->npins; i++) { > >>>>> int pin =3D desc->pins[i].number; > >>>>> - if (!amd_gpio_should_save(gpio_dev, pin)) > >>>>> + if (!amd_gpio_should_save(gpio_dev, pin)) { > >>>>> + amd_gpio_irq_init_pin(gpio_dev, pin); > >>>>> continue; > >>>>> + } > >>>>> raw_spin_lock_irqsave(&gpio_dev->lock, flags); > >>>>> gpio_dev->saved_regs[i] |=3D readl(gpio_dev->base + pin *= 4) > >>>>> & PIN_IRQ_PENDING; > >>>> > >>>> Hello Kornel, > >>>> > >>>> I've found that this commit which was included in 6.3-rc5 is causing= a > >>>> regression waking up from lid on a Lenovo Z13. > >>> observed "unable to wake from power button" on AMD based Dell platfor= m. > >> > >> This sounds like something that we want to fix quickly. > >> > >>> Reverting "pinctrl: amd: Disable and mask interrupts on resume" on th= e > >>> top of 6.3-rc6 does fix the issue. > >>>> > >>>> Reverting it on top of 6.3-rc6 resolves the problem. > >>>> > >>>> I've collected what I can into this bug report: > >>>> > >>>> https://bugzilla.kernel.org/show_bug.cgi?id=3D217315 > >>>> > >>>> Linus Walleij, > >>>> > >>>> It looks like this was CC to stable. If we can't get a quick soluti= on > >>>> we might want to pull this from stable. > >>> > >>> this commit landed into 6.1.23 as well > >>> > >>> d9c63daa576b2 pinctrl: amd: Disable and mask interrupts on re= sume > >> > >> It made it back up to 5.10.y afaics. > >> > >> The culprit has no fixes tag, which makes me wonder: should we quickly > >> (e.g. today) revert this in mainline to get back to the previous state= , > >> so that Greg can pick up the revert for the next stable releases he > >> apparently currently prepares? > >> > >> Greg, is there another way to make you quickly fix this in the stable > >> trees? One option obviously would be "revert this now in stable, reapp= ly > >> it later together with a fix ". But I'm under the impression that this > >> is too much of a hassle and thus something you only do in dire situati= ons? > >> > >> I'm asking because I over time noticed that quite a few regressions ar= e > >> in a similar situation -- and quite a few of them take quite some time > >> to get fixed even when a developer provided a fix, because reviewing a= nd > >> mainlining the fix takes a week or two (sometimes more). And that is a > >> situation that is more and more hitting a nerve here. :-/ > > > > I've looked into this and at this moment I can't really find a quick fi= x. > > See https://bugzilla.kernel.org/show_bug.cgi?id=3D217315#c3. > > It seems that reverting this might be the best solution for now. > > Great, thx for the update (and BTW: Greg, thx for your answer, too). > > To speed things up a quick question: > > Linusw, what's your preferred course to realize this revert quickly? > > * someone (Kornel?) sends a revert with a commit msg for review, which > you then apply and pass on to the other Linus? > > * someone (Kornel?) sends a revert with a commit msg for review that > immediately asks the other Linus to pick this up directly? > > * we ask the other Linus directly to revert this (who then has to come > up with a commit msg on his own)? Would you like me to send a reverting change? I can do this right away. The commit message would contain something like: This patch introduces a regression on Lenovo Z13, which can't wake from the lid with it applied.