Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4334443rwl; Mon, 10 Apr 2023 09:27:22 -0700 (PDT) X-Google-Smtp-Source: AKy350bIuj5F63ExdIo9q1D9InE+rejc7hXA9TrSPs74xcvmdozog2JyO14mSgQC3aKUT8Bx2znV X-Received: by 2002:aa7:d8d9:0:b0:501:c547:2135 with SMTP id k25-20020aa7d8d9000000b00501c5472135mr6268661eds.36.1681144041976; Mon, 10 Apr 2023 09:27:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681144041; cv=none; d=google.com; s=arc-20160816; b=TCHqBF5tuUG9+5qXRNrJqvNDTPTqAVoKUux8jniesfTwiu73agoq3P3rTppYRCILa0 YmaJKWjfgbYhUQ4CA9NHcSE+phOa8K2iQ5nrcQ8B4bb43E/ZpP6L8he2KWZ30EmggQmX 8xfehEMpGCsqdbxdC/ZQIuj8TV0iQ3r/Gj3PhBBpWVs/gBEP9nsF36It8zACHEnGK1pV SgGySAi8AHK23Po/I0DJ5KJK2DueO94tbJ+LrZH45/A4hRsjnES20RVuhGxAh/D30t+f 5BeOyapeGspJoCgP/TuBzzY5nyjWafDoJr1gPcR3BLWyQ/54W8xkoxMjqiyhVHuGW4wG U6fw== 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=rYoNI/GBnV/XFf9cldcCfKoCMP9onvoHik7LIhPrsRg=; b=i65lQH5DqE0/7owJwyPkgiRJzUtZp43PyOa53JiGSCFQc6n2fHr82ut9jSjpmVleIq C4y8+RG5dZvayRepb3H7fVuZTgxF7XEbpBn00ryKJCnvEjn4DijKMLqzBHBcxDDcmWCm t1ik/etspzIEIbtRmIBJxT8zPAH8gZ8xhC4IeOgnL5gl5cVoeet4NONu3WdAqNeM7GQY 482b0Sm//JzDG8HlRqOszmm2smJBfQHTtValTfneJpewVFBeNlombnsrASDyxsdApF5v Vvcx55AaRAlkqtZPKneskmTqNV9LU2pkjPpjU/Kld/teQyF3rI3PAGNa6Tw/n68LB3Nn wTog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="Un/CIKLU"; 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 d13-20020aa7d5cd000000b00502230e8b41si7639233eds.54.2023.04.10.09.26.57; Mon, 10 Apr 2023 09:27: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="Un/CIKLU"; 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 S230231AbjDJQSP (ORCPT + 99 others); Mon, 10 Apr 2023 12:18:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230236AbjDJQSM (ORCPT ); Mon, 10 Apr 2023 12:18:12 -0400 Received: from mail-qv1-xf30.google.com (mail-qv1-xf30.google.com [IPv6:2607:f8b0:4864:20::f30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E7791737 for ; Mon, 10 Apr 2023 09:17:46 -0700 (PDT) Received: by mail-qv1-xf30.google.com with SMTP id kj14so3618850qvb.12 for ; Mon, 10 Apr 2023 09:17:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1681143463; 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=rYoNI/GBnV/XFf9cldcCfKoCMP9onvoHik7LIhPrsRg=; b=Un/CIKLUsHod8NZC3q1oBYRRT1tcolo3z+esv0yEylxdbqYWgU14GIHALm5q20kE68 njxx99gSV2I4M7alAyutYPd7r5dSFa4sKQJu/6PU/5gWpqj7PJa8Sgd9dxI3BIQrw4Wa cCr3KCflB+L3OQcCamcqC2heJxQn16w3l4/Bc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681143463; 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=rYoNI/GBnV/XFf9cldcCfKoCMP9onvoHik7LIhPrsRg=; b=diuVHa9PplBbmE7EfVNyCQ7ss5AbxQl/RpCOx8gJIsZ1qSsHzydhvO7SHO1kVdG4RD QUvcE7g9bLOwScHwrEmjLmEiVhJWksZ0M4FIxOxn4O3c0gPb+hf0zOivITKUxILYNyCu 63h47eMpFshH4Vgb+agWzITWPO6SKALoSGxSu3Gt7VUB5ksYBAB8/PVYCSYWHrjqYxPk i7BzqsyBoDLRYdxjQxfczSY+krwlkL9l3lWpUzoHgJ8aR9VWHxp689FKv4K20huACljQ BLE+uPATtAID3ZFAn9l4wwhFikH1dM3Zx9mDU7EvK16e26q/6oI7v6ifFyNoa0FSnkQB AcgA== X-Gm-Message-State: AAQBX9cXYZinnHxeMNjvDNOfs2Zb56z2oH8wn/CwGW/qpORaszVXhTQu T8CvdOoAsgjEG/C5qCk5YfespRcynfitMfdhviy5sw== X-Received: by 2002:a05:6214:bd2:b0:56e:9f09:ee58 with SMTP id ff18-20020a0562140bd200b0056e9f09ee58mr2486153qvb.8.1681143463551; Mon, 10 Apr 2023 09:17:43 -0700 (PDT) MIME-Version: 1.0 References: <20230320093259.845178-1-korneld@chromium.org> In-Reply-To: From: =?UTF-8?Q?Kornel_Dul=C4=99ba?= Date: Mon, 10 Apr 2023 18:17:32 +0200 Message-ID: Subject: Re: [PATCH] pinctrl: amd: Disable and mask interrupts on resume To: "Gong, Richard" Cc: Mario Limonciello , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, regressions@leemhuis.info, Basavaraj Natikar , Shyam Sundar S K , Linus Walleij , upstream@semihalf.com, rad@semihalf.com, mattedavis@google.com, gregkh@linuxfoundation.org, stable@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 Mon, Apr 10, 2023 at 5:29=E2=80=AFPM 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 kernel. > >> Leverage it to re-initialize interrupt fields of a pin only if it's no= t > >> 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_ops > >> =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 pin) > >> { > >> - 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, p= in); > >> - > >> - 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 platform. > Reverting "pinctrl: amd: Disable and mask interrupts on resume" on the > top of 6.3-rc6 does fix the issue. Whoops, sorry for the breakage. Could you please share the output of "/sys/kernel/debug/gpio" before and after the first suspend/resume cycle. I've looked at the patch again and found a rather silly mistake. Please try the following. Note that I don't have access to hardware with this controller at the moment, so I've only compile tested it. diff --git a/drivers/pinctrl/pinctrl-amd.c b/drivers/pinctrl/pinctrl-amd.c index 609821b756c2..7e7770152ca8 100644 --- a/drivers/pinctrl/pinctrl-amd.c +++ b/drivers/pinctrl/pinctrl-amd.c @@ -899,7 +899,7 @@ static void amd_gpio_irq_init(struct amd_gpio *gpio_dev= ) int i; for (i =3D 0; i < desc->npins; i++) - amd_gpio_irq_init_pin(gpio_dev, i); + amd_gpio_irq_init_pin(gpio_dev, desc->pins[i].number); } > > > > 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 solution > > 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 resum= e > > > > > Thanks, > > > > > Regards, > > Richard >