From: Mario Limonciello <mario.limonciello@amd.com>
To: <Shyam-sundar.S-k@amd.com>, <linus.walleij@linaro.org>,
<Basavaraj.Natikar@amd.com>
Cc: <linux-gpio@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
"Mario Limonciello" <mario.limonciello@amd.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Hans de Goede <hdegoede@redhat.com>,
Kieran Levin <ktl@frame.work>
Subject: [PATCH] pinctrl: amd: Set up affinity for GPIO lines when enabling interrupt
Date: Sun, 19 May 2024 07:41:09 -0500 [thread overview]
Message-ID: <20240519124109.1523-1-mario.limonciello@amd.com> (raw)
When a touchpad's attention interrupt is triggered on a different
CPU than the GPIO controller interrupt multiple CPUs wake up the system
and can cause higher power consumption than necessary for operating
the touchpad.
Waking up the additional CPUs is especially unnecessary as the
irq_ack() callback for pinctrl-amd doesn't do anything.
To solve this save the affinity of the GPIO controller interrupt when
it's set up and assign that affinity to the GPIO line IRQ.
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Hans de Goede <hdegoede@redhat.com>
Reported-by: Kieran Levin <ktl@frame.work>
Link: https://bugzilla.kernel.org/show_bug.cgi?id=218169
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
drivers/pinctrl/pinctrl-amd.c | 18 ++++++++++++++++++
drivers/pinctrl/pinctrl-amd.h | 1 +
2 files changed, 19 insertions(+)
diff --git a/drivers/pinctrl/pinctrl-amd.c b/drivers/pinctrl/pinctrl-amd.c
index 7f66ec73199a..0f126caa8dfc 100644
--- a/drivers/pinctrl/pinctrl-amd.c
+++ b/drivers/pinctrl/pinctrl-amd.c
@@ -561,6 +561,21 @@ static int amd_gpio_irq_set_type(struct irq_data *d, unsigned int type)
return ret;
}
+static int amd_gpio_set_affinity(struct irq_data *data, const struct cpumask *dest,
+ bool force)
+{
+ struct gpio_chip *gc = irq_data_get_irq_chip_data(data);
+ struct amd_gpio *gpio_dev = gpiochip_get_data(gc);
+
+ /*
+ * The affinity is explicitly set to the GPIO controller as amd_irq_ack()
+ * doesn't do anything and pinning to a different CPU is a needless wakeup.
+ */
+ irq_data_update_effective_affinity(data, gpio_dev->base_affinity);
+
+ return 0;
+}
+
static void amd_irq_ack(struct irq_data *d)
{
/*
@@ -580,6 +595,7 @@ static const struct irq_chip amd_gpio_irqchip = {
.irq_set_wake = amd_gpio_irq_set_wake,
.irq_eoi = amd_gpio_irq_eoi,
.irq_set_type = amd_gpio_irq_set_type,
+ .irq_set_affinity = amd_gpio_set_affinity,
/*
* We need to set IRQCHIP_ENABLE_WAKEUP_ON_SUSPEND so that a wake event
* also generates an IRQ. We need the IRQ so the irq_handler can clear
@@ -1163,6 +1179,8 @@ static int amd_gpio_probe(struct platform_device *pdev)
if (ret)
goto out2;
+ gpio_dev->base_affinity = irq_get_affinity_mask(gpio_dev->irq);
+
platform_set_drvdata(pdev, gpio_dev);
acpi_register_wakeup_handler(gpio_dev->irq, amd_gpio_check_wake, gpio_dev);
diff --git a/drivers/pinctrl/pinctrl-amd.h b/drivers/pinctrl/pinctrl-amd.h
index cf59089f2776..1a97c7570374 100644
--- a/drivers/pinctrl/pinctrl-amd.h
+++ b/drivers/pinctrl/pinctrl-amd.h
@@ -106,6 +106,7 @@ struct amd_gpio {
struct platform_device *pdev;
u32 *saved_regs;
int irq;
+ const struct cpumask *base_affinity;
};
/* KERNCZ configuration*/
--
2.43.0
next reply other threads:[~2024-05-19 12:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-19 12:41 Mario Limonciello [this message]
2024-05-20 9:38 ` Andy Shevchenko
2024-05-21 2:01 ` Mario Limonciello
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240519124109.1523-1-mario.limonciello@amd.com \
--to=mario.limonciello@amd.com \
--cc=Basavaraj.Natikar@amd.com \
--cc=Shyam-sundar.S-k@amd.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=hdegoede@redhat.com \
--cc=ktl@frame.work \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®