From patchwork Wed Dec 8 21:14:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 1565497 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=OJXAnOVN; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4J8VwH3099z9sXS for ; Thu, 9 Dec 2021 08:41:02 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1mv4HK-0000Wk-Fy; Wed, 08 Dec 2021 21:15:06 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1mv4HJ-0000WV-CT for kernel-team@lists.ubuntu.com; Wed, 08 Dec 2021 21:15:05 +0000 Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 373F33F1BD for ; Wed, 8 Dec 2021 21:15:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1638998105; bh=RFt/QWLRPmEvy6nR+7Lk7nkAd3qgENBp9+sEPy5Y9Jo=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OJXAnOVN1vidEnkGuEbLOoLlr3raYl5ozhlz8MLwCPbQpKuogUgLrMmim5+HM21ya qKsfGLMrsGjlsAPjdLBUnrFINMERdYzC2klq1K9Y67OXPFq27djksmEJJ5jD32EGmT nuM2JVKvXdA0B0w/qgjbUn1CN0uTvPFJAAJF+tmSnbfDMO8JckI/6Qntiu0+Je9m1K KP7Rh92JQBQBMvND4kJf7652+peKOxFUXIjOmPVZZwa1sxFqyuUzsiT20tuIibXndV WsGaNY/+0MH3g/9fXDwTjZHpzYo1kZQd5+OzOBHZY4MBoJBdyC4m87fOnQU6ZE4TlV jNqWD/WH51h+Q== Received: by mail-pg1-f199.google.com with SMTP id 66-20020a630545000000b0032e4e898d24so1965362pgf.10 for ; Wed, 08 Dec 2021 13:15:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RFt/QWLRPmEvy6nR+7Lk7nkAd3qgENBp9+sEPy5Y9Jo=; b=xrSXknkqU+hEvlmzi1vR6+MDvR+2AoaY28kJeE2i1yZQYa6+mVEASjiMGmt7sXuZ+n zoDfoE+f1HBTmFa0yT1WFzOIJ8+OaIMGDT5vA4IR4zyQo2DzXpqIStZQRuWUwoVRD8Ll fNDD3AK62bUQ6CurxHXyGQK0SWeJDfYIJnjcr5DuWx97J1B2pRQWr79Sw4uEfUgDtg7v 9kz3TltLbgPXVywJ8BXzlaOpLyl/hblfaotCyQfeWSMCEhXoNOuHSmcScOKl4ztK0tj6 YC7DASzRML/vK3CXIVObRPtyFJMyAxloxwA8M7/X6Zwh+r5GPi7l0EFm6OAq/wCZGvkz cG7A== X-Gm-Message-State: AOAM531XStLD8r0eYilH5eCYSlLkyZ4t5rYj6lwJHeZhf0wpXSvk9Ohf /q/YHWiO979//1qntpg0QxypHmfiEOWNao3YHUP1rCXx49QiuhJ6lFG22R8l02HAQQ/VcgQrmrH GYan0a3dk0wXHD7abjatEZYu4sbXOF7FQE06AxuqPCA== X-Received: by 2002:a62:878a:0:b0:4ae:d7d4:ecb1 with SMTP id i132-20020a62878a000000b004aed7d4ecb1mr8018145pfe.52.1638998103486; Wed, 08 Dec 2021 13:15:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJyNMq+4Zp0i63/hLeMLQQOc6KbZESimZZmPXlY+7CL2FoJmDrL6zAn6hbdLBDxD5Y6/TR+xzg== X-Received: by 2002:a62:878a:0:b0:4ae:d7d4:ecb1 with SMTP id i132-20020a62878a000000b004aed7d4ecb1mr8018114pfe.52.1638998103144; Wed, 08 Dec 2021 13:15:03 -0800 (PST) Received: from canonical.com (node-1w7jr9yebujeq5th4a1ypmdy2.ipv6.telus.net. [2001:56a:78ed:fb00::11a]) by smtp.gmail.com with ESMTPSA id s31sm4928048pfg.22.2021.12.08.13.15.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Dec 2021 13:15:02 -0800 (PST) From: Alex Hung To: kernel-team@lists.ubuntu.com Subject: [PATCH 2/2][SRU][OEM-5.14][U] pinctrl: amd: Fix wakeups when IRQ is shared with SCI Date: Wed, 8 Dec 2021 14:14:59 -0700 Message-Id: <20211208211459.1358692-3-alex.hung@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211208211459.1358692-1-alex.hung@canonical.com> References: <20211208211459.1358692-1-alex.hung@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Mario Limonciello BugLink: https://bugs.launchpad.net/bugs/1953540 On some Lenovo AMD Gen2 platforms the IRQ for the SCI and pinctrl drivers are shared. Due to how the s2idle loop handling works, this case needs an extra explicit check whether the interrupt was caused by SCI or by the GPIO controller. To fix this rework the existing IRQ handler function to function as a checker and an IRQ handler depending on the calling arguments. BugLink: https://gitlab.freedesktop.org/drm/amd/-/issues/1738 Reported-by: Joerie de Gram Signed-off-by: Mario Limonciello Acked-by: Basavaraj Natikar Link: https://lore.kernel.org/r/20211101014853.6177-2-mario.limonciello@amd.com Signed-off-by: Linus Walleij (cherry picked from commit 2d54067fcd23aae61e23508425ae5b29e973573d) Signed-off-by: Alex Hung --- drivers/pinctrl/pinctrl-amd.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/drivers/pinctrl/pinctrl-amd.c b/drivers/pinctrl/pinctrl-amd.c index bae9d42..ecab906 100644 --- a/drivers/pinctrl/pinctrl-amd.c +++ b/drivers/pinctrl/pinctrl-amd.c @@ -598,14 +598,14 @@ static struct irq_chip amd_gpio_irqchip = { #define PIN_IRQ_PENDING (BIT(INTERRUPT_STS_OFF) | BIT(WAKE_STS_OFF)) -static irqreturn_t amd_gpio_irq_handler(int irq, void *dev_id) +static bool do_amd_gpio_irq_handler(int irq, void *dev_id) { struct amd_gpio *gpio_dev = dev_id; struct gpio_chip *gc = &gpio_dev->gc; - irqreturn_t ret = IRQ_NONE; unsigned int i, irqnr; unsigned long flags; u32 __iomem *regs; + bool ret = false; u32 regval; u64 status, mask; @@ -627,6 +627,14 @@ static irqreturn_t amd_gpio_irq_handler(int irq, void *dev_id) /* Each status bit covers four pins */ for (i = 0; i < 4; i++) { regval = readl(regs + i); + /* caused wake on resume context for shared IRQ */ + if (irq < 0 && (regval & BIT(WAKE_STS_OFF))) { + dev_dbg(&gpio_dev->pdev->dev, + "Waking due to GPIO %d: 0x%x", + irqnr + i, regval); + return true; + } + if (!(regval & PIN_IRQ_PENDING) || !(regval & BIT(INTERRUPT_MASK_OFF))) continue; @@ -650,9 +658,12 @@ static irqreturn_t amd_gpio_irq_handler(int irq, void *dev_id) } writel(regval, regs + i); raw_spin_unlock_irqrestore(&gpio_dev->lock, flags); - ret = IRQ_HANDLED; + ret = true; } } + /* did not cause wake on resume context for shared IRQ */ + if (irq < 0) + return false; /* Signal EOI to the GPIO unit */ raw_spin_lock_irqsave(&gpio_dev->lock, flags); @@ -664,6 +675,16 @@ static irqreturn_t amd_gpio_irq_handler(int irq, void *dev_id) return ret; } +static irqreturn_t amd_gpio_irq_handler(int irq, void *dev_id) +{ + return IRQ_RETVAL(do_amd_gpio_irq_handler(irq, dev_id)); +} + +static bool __maybe_unused amd_gpio_check_wake(void *dev_id) +{ + return do_amd_gpio_irq_handler(-1, dev_id); +} + static int amd_get_groups_count(struct pinctrl_dev *pctldev) { struct amd_gpio *gpio_dev = pinctrl_dev_get_drvdata(pctldev); @@ -1033,6 +1054,7 @@ static int amd_gpio_probe(struct platform_device *pdev) goto out2; platform_set_drvdata(pdev, gpio_dev); + acpi_register_wakeup_handler(gpio_dev->irq, amd_gpio_check_wake, gpio_dev); dev_dbg(&pdev->dev, "amd gpio driver loaded\n"); return ret; @@ -1050,6 +1072,7 @@ static int amd_gpio_remove(struct platform_device *pdev) gpio_dev = platform_get_drvdata(pdev); gpiochip_remove(&gpio_dev->gc); + acpi_unregister_wakeup_handler(amd_gpio_check_wake, gpio_dev); return 0; }