* [PATCH] pinctrl: amd: Steer GPIO interrupt to low power/efficiency cores
@ 2026-11-11 16:07 Mario Limonciello
2026-11-11 16:48 ` sashiko-bot
2026-11-12 1:04 ` kernel test robot
0 siblings, 2 replies; 3+ messages in thread
From: Mario Limonciello @ 2026-11-11 16:07 UTC (permalink / raw)
To: Basavaraj Natikar, Shyam Sundar S K, Linus Walleij,
Bartosz Golaszewski
Cc: linux-gpio, linux-kernel, Mario Limonciello
On hybrid x86 systems the GPIO controller interrupt can be a frequent
wake and handler source. Servicing it on a performance core can wake that
core unnecessarily.
Prefer routing it to low power cores, then to efficiency (dense) cores,
using the CPU type from the x86 topology information. If the system has
neither core type (non-hybrid), leave the affinity untouched.
The placement is applied with irq_set_affinity(), so userspace is still
free to override it.
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
drivers/pinctrl/pinctrl-amd.c | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/drivers/pinctrl/pinctrl-amd.c b/drivers/pinctrl/pinctrl-amd.c
index 30da75bb93b9a..3ae199cc93435 100644
--- a/drivers/pinctrl/pinctrl-amd.c
+++ b/drivers/pinctrl/pinctrl-amd.c
@@ -31,6 +31,8 @@
#include <linux/pinctrl/pinmux.h>
#include <linux/string_choices.h>
#include <linux/suspend.h>
+#include <linux/cpumask.h>
+#include <linux/processor.h>
#include "core.h"
#include "pinctrl-utils.h"
@@ -1272,6 +1274,41 @@ static void __iomem *amd_get_named_res(struct device *dev, struct platform_devic
return base;
}
+#ifdef CONFIG_X86_64
+/*
+ * On hybrid systems prefer to service the GPIO interrupt on low power cores,
+ * then on efficiency (dense) cores to save power. Userspace can still
+ * override the placement. Do nothing if neither core type exists.
+ */
+static void amd_gpio_set_irq_affinity(struct amd_gpio *gpio_dev)
+{
+ static const enum x86_topology_cpu_type types[] = {
+ TOPO_CPU_TYPE_LOW_POWER,
+ TOPO_CPU_TYPE_EFFICIENCY,
+ };
+ cpumask_var_t mask;
+ int cpu, i;
+
+ if (!zalloc_cpumask_var(&mask, GFP_KERNEL))
+ return;
+
+ for (i = 0; i < ARRAY_SIZE(types); i++) {
+ for_each_possible_cpu(cpu) {
+ if (cpu_data(cpu).topo.cpu_type == types[i])
+ cpumask_set_cpu(cpu, mask);
+ }
+ if (!cpumask_empty(mask)) {
+ irq_set_affinity(gpio_dev->irq, mask);
+ break;
+ }
+ }
+
+ free_cpumask_var(mask);
+}
+#else
+static void amd_gpio_set_irq_affinity(struct amd_gpio *gpio_dev) {}
+#endif
+
static int amd_gpio_probe(struct platform_device *pdev)
{
int ret = 0;
@@ -1377,6 +1414,8 @@ static int amd_gpio_probe(struct platform_device *pdev)
if (ret)
goto out2;
+ amd_gpio_set_irq_affinity(gpio_dev);
+
platform_set_drvdata(pdev, gpio_dev);
acpi_register_wakeup_handler(gpio_dev->irq, amd_gpio_check_wake, gpio_dev);
amd_gpio_register_s2idle_ops();
---
base-commit: 7475ea8b58616b33c04afb976cf0fbaad9dd63fb
change-id: 20261111-superm1-pinctrl-power-improvement-93440daeb293
Best regards,
--
Mario Limonciello <mario.limonciello@amd.com>
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] pinctrl: amd: Steer GPIO interrupt to low power/efficiency cores
2026-11-11 16:07 [PATCH] pinctrl: amd: Steer GPIO interrupt to low power/efficiency cores Mario Limonciello
@ 2026-11-11 16:48 ` sashiko-bot
2026-11-12 1:04 ` kernel test robot
1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-11-11 16:48 UTC (permalink / raw)
To: Mario Limonciello; +Cc: linux-gpio
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Low] pinctrl: amd: offline low-power CPUs prevent fallback in
amd_gpio_set_irq_affinity()
- [Low] pinctrl: amd: UML build failure in amd_gpio_set_irq_affinity()
under CONFIG_X86_64
--
commit 9979566a45b6fdd26d48ee240bec752ee33586ba
Author: Mario Limonciello <mario.limonciello@amd.com>
pinctrl: amd: Steer GPIO interrupt to low power/efficiency cores
This commit steers the AMD GPIO controller interrupt to low power or
efficiency cores on hybrid x86 systems during probe using
irq_set_affinity().
> diff --git a/drivers/pinctrl/pinctrl-amd.c b/drivers/pinctrl/pinctrl-amd.c
> index 30da75bb93b9a..3ae199cc93435 100644
> --- a/drivers/pinctrl/pinctrl-amd.c
> +++ b/drivers/pinctrl/pinctrl-amd.c
[ ... ]
> @@ -1272,6 +1274,41 @@ static void __iomem *amd_get_named_res(struct device *dev, struct platform_devic
> return base;
> }
>
> +#ifdef CONFIG_X86_64
> +/*
> + * On hybrid systems prefer to service the GPIO interrupt on low power cores,
> + * then on efficiency (dense) cores to save power. Userspace can still
> + * override the placement. Do nothing if neither core type exists.
> + */
> +static void amd_gpio_set_irq_affinity(struct amd_gpio *gpio_dev)
> +{
> + static const enum x86_topology_cpu_type types[] = {
> + TOPO_CPU_TYPE_LOW_POWER,
> + TOPO_CPU_TYPE_EFFICIENCY,
> + };
[Severity: Low]
Does guarding amd_gpio_set_irq_affinity() with CONFIG_X86_64 break 64-bit
ARCH=um builds when CONFIG_COMPILE_TEST is enabled?
On 64-bit User Mode Linux, arch/x86/um/Kconfig defines CONFIG_X86_64=y
without CONFIG_X86, and the UML processor headers define struct cpuinfo_um
rather than enum x86_topology_cpu_type or per-CPU cpu_data(cpu). Guarding
this with CONFIG_X86 (or excluding CONFIG_UML) would avoid the build
failure.
> + cpumask_var_t mask;
> + int cpu, i;
> +
> + if (!zalloc_cpumask_var(&mask, GFP_KERNEL))
> + return;
> +
> + for (i = 0; i < ARRAY_SIZE(types); i++) {
> + for_each_possible_cpu(cpu) {
> + if (cpu_data(cpu).topo.cpu_type == types[i])
> + cpumask_set_cpu(cpu, mask);
> + }
> + if (!cpumask_empty(mask)) {
> + irq_set_affinity(gpio_dev->irq, mask);
> + break;
> + }
> + }
[Severity: Low]
Can offline low-power CPUs prevent amd_gpio_set_irq_affinity() from falling
back to efficiency cores?
When a CPU is offlined via hotplug on x86, remove_siblinginfo() leaves
cpu_data(cpu).topo.cpu_type intact. Because the loop iterates over
for_each_possible_cpu(cpu) and breaks unconditionally whenever mask is
non-empty, if all TOPO_CPU_TYPE_LOW_POWER CPUs are offline when
amd_gpio_probe() runs, irq_do_set_affinity() rejects the offline-only mask
with -EINVAL and TOPO_CPU_TYPE_EFFICIENCY is never tried. Iterating over
for_each_online_cpu(cpu) (or checking the return value of
irq_set_affinity()) would allow the fallback to proceed.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261111-superm1-pinctrl-power-improvement-v1-1-4bbe6cdbd2e8@amd.com?part=1
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] pinctrl: amd: Steer GPIO interrupt to low power/efficiency cores
2026-11-11 16:07 [PATCH] pinctrl: amd: Steer GPIO interrupt to low power/efficiency cores Mario Limonciello
2026-11-11 16:48 ` sashiko-bot
@ 2026-11-12 1:04 ` kernel test robot
1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2026-11-12 1:04 UTC (permalink / raw)
To: Mario Limonciello, Basavaraj Natikar, Shyam Sundar S K,
Linus Walleij, Bartosz Golaszewski
Cc: llvm, oe-kbuild-all, linux-gpio, linux-kernel, Mario Limonciello
Hi Mario,
kernel test robot noticed the following build errors:
[auto build test ERROR on 7475ea8b58616b33c04afb976cf0fbaad9dd63fb]
url: https://github.com/intel-lab-lkp/linux/commits/Mario-Limonciello/pinctrl-amd-Steer-GPIO-interrupt-to-low-power-efficiency-cores/20261111-100708
base: 7475ea8b58616b33c04afb976cf0fbaad9dd63fb
patch link: https://lore.kernel.org/r/20261111-superm1-pinctrl-power-improvement-v1-1-4bbe6cdbd2e8%40amd.com
patch subject: [PATCH] pinctrl: amd: Steer GPIO interrupt to low power/efficiency cores
config: um-randconfig-1000-20261112 (https://download.01.org/0day-ci/archive/20261112/202611120840.VN9Z8N3s-lkp@intel.com/config)
compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261112/202611120840.VN9Z8N3s-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202611120840.VN9Z8N3s-lkp@intel.com/
All errors (new ones prefixed by >>):
In file included from drivers/pinctrl/pinctrl-amd.c:20:
In file included from include/linux/io.h:12:
In file included from arch/um/include/asm/io.h:24:
include/asm-generic/io.h:1209:55: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
1209 | return (port > MMIO_UPPER_LIMIT) ? NULL : PCI_IOBASE + port;
| ~~~~~~~~~~ ^
>> drivers/pinctrl/pinctrl-amd.c:1285:47: error: array has incomplete element type 'const enum x86_topology_cpu_type'
1285 | static const enum x86_topology_cpu_type types[] = {
| ^
drivers/pinctrl/pinctrl-amd.c:1285:20: note: forward declaration of 'enum x86_topology_cpu_type'
1285 | static const enum x86_topology_cpu_type types[] = {
| ^
>> drivers/pinctrl/pinctrl-amd.c:1286:3: error: use of undeclared identifier 'TOPO_CPU_TYPE_LOW_POWER'
1286 | TOPO_CPU_TYPE_LOW_POWER,
| ^
>> drivers/pinctrl/pinctrl-amd.c:1287:3: error: use of undeclared identifier 'TOPO_CPU_TYPE_EFFICIENCY'
1287 | TOPO_CPU_TYPE_EFFICIENCY,
| ^
>> drivers/pinctrl/pinctrl-amd.c:1297:8: error: call to undeclared function 'cpu_data'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
1297 | if (cpu_data(cpu).topo.cpu_type == types[i])
| ^
>> drivers/pinctrl/pinctrl-amd.c:1297:21: error: member reference base type 'int' is not a structure or union
1297 | if (cpu_data(cpu).topo.cpu_type == types[i])
| ~~~~~~~~~~~~~^~~~~
1 warning and 5 errors generated.
vim +1285 drivers/pinctrl/pinctrl-amd.c
1276
1277 #ifdef CONFIG_X86_64
1278 /*
1279 * On hybrid systems prefer to service the GPIO interrupt on low power cores,
1280 * then on efficiency (dense) cores to save power. Userspace can still
1281 * override the placement. Do nothing if neither core type exists.
1282 */
1283 static void amd_gpio_set_irq_affinity(struct amd_gpio *gpio_dev)
1284 {
> 1285 static const enum x86_topology_cpu_type types[] = {
> 1286 TOPO_CPU_TYPE_LOW_POWER,
> 1287 TOPO_CPU_TYPE_EFFICIENCY,
1288 };
1289 cpumask_var_t mask;
1290 int cpu, i;
1291
1292 if (!zalloc_cpumask_var(&mask, GFP_KERNEL))
1293 return;
1294
1295 for (i = 0; i < ARRAY_SIZE(types); i++) {
1296 for_each_possible_cpu(cpu) {
> 1297 if (cpu_data(cpu).topo.cpu_type == types[i])
1298 cpumask_set_cpu(cpu, mask);
1299 }
1300 if (!cpumask_empty(mask)) {
1301 irq_set_affinity(gpio_dev->irq, mask);
1302 break;
1303 }
1304 }
1305
1306 free_cpumask_var(mask);
1307 }
1308 #else
1309 static void amd_gpio_set_irq_affinity(struct amd_gpio *gpio_dev) {}
1310 #endif
1311
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-12 1:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-11 16:07 [PATCH] pinctrl: amd: Steer GPIO interrupt to low power/efficiency cores Mario Limonciello
2026-11-11 16:48 ` sashiko-bot
2026-11-12 1:04 ` kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox