linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/2] Add LPS0 check() for pinctrl-amd
@ 2025-02-27 20:50 Mario Limonciello
  2025-02-27 20:50 ` [PATCH v3 2/2] pinctrl: amd: Add an LPS0 check() callback Mario Limonciello
  0 siblings, 1 reply; 5+ messages in thread
From: Mario Limonciello @ 2025-02-27 20:50 UTC (permalink / raw)
  To: mario.limonciello, Basavaraj.Natikar, linus.walleij, rafael,
	Shyam-sundar.S-k
  Cc: linux-acpi, linux-gpio

From: Mario Limonciello <mario.limonciello@amd.com>

During suspend the pinctrl_amd driver disables the interrupts for
any GPIOs that are not marked as wake sources.

This however does not prevent them from changing the wake status
bit during suspend, it just stops the system from waking.

If the system wakes from hardware sleep for another reason (such
as plugging in the AC adapter) this wake bits might be active.

This could potentially cause problems with going back to hardware
sleep.  Add an extra debugging message when PM debugging is enabled
to help identify if this is happening.

Mario Limonciello (2):
  ACPI: Add missing prototype for non CONFIG_SUSPEND/CONFIG_X86 case
  pinctrl: amd: Add an LPS0 check() callback

 drivers/pinctrl/pinctrl-amd.c | 28 ++++++++++++++++++++++++++++
 include/linux/acpi.h          |  9 ++++++++-
 2 files changed, 36 insertions(+), 1 deletion(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v3 2/2] pinctrl: amd: Add an LPS0 check() callback
  2025-02-27 20:50 [PATCH v3 0/2] Add LPS0 check() for pinctrl-amd Mario Limonciello
@ 2025-02-27 20:50 ` Mario Limonciello
  2025-03-01 22:39   ` kernel test robot
                     ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Mario Limonciello @ 2025-02-27 20:50 UTC (permalink / raw)
  To: mario.limonciello, Basavaraj.Natikar, Shyam-sundar.S-k,
	linus.walleij
  Cc: linux-gpio

From: Mario Limonciello <mario.limonciello@amd.com>

During suspend the pinctrl_amd driver disables the interrupts for
any GPIOs that are not marked as wake sources.

This however does not prevent them from changing the wake status
bit during suspend, it just stops the system from waking.

If the system wakes from hardware sleep for another reason (such
as plugging in the AC adapter) this wake bits might be active.

This could potentially cause problems with going back to hardware
sleep.  Add an extra debugging message when PM debugging is enabled
to help identify if this is happening.

Acked-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://gitlab.freedesktop.org/drm/amd/-/issues/3929
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
v3:
 * Add tag
---
 drivers/pinctrl/pinctrl-amd.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/drivers/pinctrl/pinctrl-amd.c b/drivers/pinctrl/pinctrl-amd.c
index 1d7fdcdec4c85..fdda8d1c4f344 100644
--- a/drivers/pinctrl/pinctrl-amd.c
+++ b/drivers/pinctrl/pinctrl-amd.c
@@ -37,6 +37,8 @@
 #include "pinctrl-utils.h"
 #include "pinctrl-amd.h"
 
+static struct amd_gpio *pinctrl_dev;
+
 static int amd_gpio_get_direction(struct gpio_chip *gc, unsigned offset)
 {
 	unsigned long flags;
@@ -909,6 +911,29 @@ static bool amd_gpio_should_save(struct amd_gpio *gpio_dev, unsigned int pin)
 	return false;
 }
 
+static void amd_gpio_check_pending(void)
+{
+	struct amd_gpio *gpio_dev = pinctrl_dev;
+	struct pinctrl_desc *desc = gpio_dev->pctrl->desc;
+	int i;
+
+	if (!pm_debug_messages_on)
+		return;
+
+	for (i = 0; i < desc->npins; i++) {
+		int pin = desc->pins[i].number;
+		u32 tmp;
+
+		tmp = readl(gpio_dev->base + pin * 4);
+		if (tmp & PIN_IRQ_PENDING)
+			pm_pr_dbg("%s: GPIO %d is active: 0x%x.\n", __func__, pin, tmp);
+	}
+}
+
+static struct acpi_s2idle_dev_ops pinctrl_amd_s2idle_dev_ops = {
+	.check = amd_gpio_check_pending,
+};
+
 static int amd_gpio_suspend_hibernate_common(struct device *dev, bool is_suspend)
 {
 	struct amd_gpio *gpio_dev = dev_get_drvdata(dev);
@@ -942,6 +967,7 @@ static int amd_gpio_suspend_hibernate_common(struct device *dev, bool is_suspend
 
 static int amd_gpio_suspend(struct device *dev)
 {
+	pinctrl_dev = dev_get_drvdata(dev);
 	return amd_gpio_suspend_hibernate_common(dev, true);
 }
 
@@ -1181,6 +1207,7 @@ static int amd_gpio_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, gpio_dev);
 	acpi_register_wakeup_handler(gpio_dev->irq, amd_gpio_check_wake, gpio_dev);
+	acpi_register_lps0_dev(&pinctrl_amd_s2idle_dev_ops);
 
 	dev_dbg(&pdev->dev, "amd gpio driver loaded\n");
 	return ret;
@@ -1199,6 +1226,7 @@ static void amd_gpio_remove(struct platform_device *pdev)
 
 	gpiochip_remove(&gpio_dev->gc);
 	acpi_unregister_wakeup_handler(amd_gpio_check_wake, gpio_dev);
+	acpi_unregister_lps0_dev(&pinctrl_amd_s2idle_dev_ops);
 }
 
 #ifdef CONFIG_ACPI
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v3 2/2] pinctrl: amd: Add an LPS0 check() callback
  2025-02-27 20:50 ` [PATCH v3 2/2] pinctrl: amd: Add an LPS0 check() callback Mario Limonciello
@ 2025-03-01 22:39   ` kernel test robot
  2025-03-02  0:28   ` kernel test robot
  2025-03-02  7:17   ` kernel test robot
  2 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2025-03-01 22:39 UTC (permalink / raw)
  To: Mario Limonciello, mario.limonciello, Basavaraj.Natikar,
	Shyam-sundar.S-k, linus.walleij
  Cc: oe-kbuild-all, linux-gpio

Hi Mario,

kernel test robot noticed the following build warnings:

[auto build test WARNING on linusw-pinctrl/devel]
[also build test WARNING on linusw-pinctrl/for-next rafael-pm/linux-next rafael-pm/bleeding-edge linus/master v6.14-rc4 next-20250228]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Mario-Limonciello/ACPI-Add-missing-prototype-for-non-CONFIG_SUSPEND-CONFIG_X86-case/20250228-045242
base:   https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git devel
patch link:    https://lore.kernel.org/r/20250227205049.765309-3-superm1%40kernel.org
patch subject: [PATCH v3 2/2] pinctrl: amd: Add an LPS0 check() callback
config: mips-allyesconfig (https://download.01.org/0day-ci/archive/20250302/202503020616.j6juZTqH-lkp@intel.com/config)
compiler: mips-linux-gcc (GCC) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250302/202503020616.j6juZTqH-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/202503020616.j6juZTqH-lkp@intel.com/

All warnings (new ones prefixed by >>):

   drivers/pinctrl/pinctrl-amd.c:933:15: error: variable 'pinctrl_amd_s2idle_dev_ops' has initializer but incomplete type
     933 | static struct acpi_s2idle_dev_ops pinctrl_amd_s2idle_dev_ops = {
         |               ^~~~~~~~~~~~~~~~~~~
   drivers/pinctrl/pinctrl-amd.c:934:10: error: 'struct acpi_s2idle_dev_ops' has no member named 'check'
     934 |         .check = amd_gpio_check_pending,
         |          ^~~~~
>> drivers/pinctrl/pinctrl-amd.c:934:18: warning: excess elements in struct initializer
     934 |         .check = amd_gpio_check_pending,
         |                  ^~~~~~~~~~~~~~~~~~~~~~
   drivers/pinctrl/pinctrl-amd.c:934:18: note: (near initialization for 'pinctrl_amd_s2idle_dev_ops')
   drivers/pinctrl/pinctrl-amd.c: In function 'amd_gpio_probe':
   drivers/pinctrl/pinctrl-amd.c:1210:9: error: implicit declaration of function 'acpi_register_lps0_dev' [-Wimplicit-function-declaration]
    1210 |         acpi_register_lps0_dev(&pinctrl_amd_s2idle_dev_ops);
         |         ^~~~~~~~~~~~~~~~~~~~~~
   drivers/pinctrl/pinctrl-amd.c: In function 'amd_gpio_remove':
   drivers/pinctrl/pinctrl-amd.c:1229:9: error: implicit declaration of function 'acpi_unregister_lps0_dev' [-Wimplicit-function-declaration]
    1229 |         acpi_unregister_lps0_dev(&pinctrl_amd_s2idle_dev_ops);
         |         ^~~~~~~~~~~~~~~~~~~~~~~~
   drivers/pinctrl/pinctrl-amd.c: At top level:
   drivers/pinctrl/pinctrl-amd.c:933:35: error: storage size of 'pinctrl_amd_s2idle_dev_ops' isn't known
     933 | static struct acpi_s2idle_dev_ops pinctrl_amd_s2idle_dev_ops = {
         |                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~


vim +934 drivers/pinctrl/pinctrl-amd.c

   932	
   933	static struct acpi_s2idle_dev_ops pinctrl_amd_s2idle_dev_ops = {
 > 934		.check = amd_gpio_check_pending,
   935	};
   936	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v3 2/2] pinctrl: amd: Add an LPS0 check() callback
  2025-02-27 20:50 ` [PATCH v3 2/2] pinctrl: amd: Add an LPS0 check() callback Mario Limonciello
  2025-03-01 22:39   ` kernel test robot
@ 2025-03-02  0:28   ` kernel test robot
  2025-03-02  7:17   ` kernel test robot
  2 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2025-03-02  0:28 UTC (permalink / raw)
  To: Mario Limonciello, mario.limonciello, Basavaraj.Natikar,
	Shyam-sundar.S-k, linus.walleij
  Cc: oe-kbuild-all, linux-gpio

Hi Mario,

kernel test robot noticed the following build errors:

[auto build test ERROR on linusw-pinctrl/devel]
[also build test ERROR on linusw-pinctrl/for-next rafael-pm/linux-next rafael-pm/bleeding-edge linus/master v6.14-rc4 next-20250228]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Mario-Limonciello/ACPI-Add-missing-prototype-for-non-CONFIG_SUSPEND-CONFIG_X86-case/20250228-045242
base:   https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git devel
patch link:    https://lore.kernel.org/r/20250227205049.765309-3-superm1%40kernel.org
patch subject: [PATCH v3 2/2] pinctrl: amd: Add an LPS0 check() callback
config: hexagon-randconfig-r062-20250302 (https://download.01.org/0day-ci/archive/20250302/202503020849.ZhLZ4W63-lkp@intel.com/config)
compiler: clang version 21.0.0git (https://github.com/llvm/llvm-project 14170b16028c087ca154878f5ed93d3089a965c6)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250302/202503020849.ZhLZ4W63-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/202503020849.ZhLZ4W63-lkp@intel.com/

All errors (new ones prefixed by >>):

   drivers/pinctrl/pinctrl-amd.c:1210:2: error: call to undeclared function 'acpi_register_lps0_dev'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    1210 |         acpi_register_lps0_dev(&pinctrl_amd_s2idle_dev_ops);
         |         ^
>> drivers/pinctrl/pinctrl-amd.c:1210:26: error: use of undeclared identifier 'pinctrl_amd_s2idle_dev_ops'
    1210 |         acpi_register_lps0_dev(&pinctrl_amd_s2idle_dev_ops);
         |                                 ^
   drivers/pinctrl/pinctrl-amd.c:1229:2: error: call to undeclared function 'acpi_unregister_lps0_dev'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    1229 |         acpi_unregister_lps0_dev(&pinctrl_amd_s2idle_dev_ops);
         |         ^
   drivers/pinctrl/pinctrl-amd.c:1229:28: error: use of undeclared identifier 'pinctrl_amd_s2idle_dev_ops'
    1229 |         acpi_unregister_lps0_dev(&pinctrl_amd_s2idle_dev_ops);
         |                                   ^
   4 errors generated.


vim +/pinctrl_amd_s2idle_dev_ops +1210 drivers/pinctrl/pinctrl-amd.c

  1151	
  1152		gpio_dev->pdev = pdev;
  1153		gpio_dev->gc.get_direction	= amd_gpio_get_direction;
  1154		gpio_dev->gc.direction_input	= amd_gpio_direction_input;
  1155		gpio_dev->gc.direction_output	= amd_gpio_direction_output;
  1156		gpio_dev->gc.get			= amd_gpio_get_value;
  1157		gpio_dev->gc.set			= amd_gpio_set_value;
  1158		gpio_dev->gc.set_config		= amd_gpio_set_config;
  1159		gpio_dev->gc.dbg_show		= amd_gpio_dbg_show;
  1160	
  1161		gpio_dev->gc.base		= -1;
  1162		gpio_dev->gc.label			= pdev->name;
  1163		gpio_dev->gc.owner			= THIS_MODULE;
  1164		gpio_dev->gc.parent			= &pdev->dev;
  1165		gpio_dev->gc.ngpio			= resource_size(res) / 4;
  1166	
  1167		gpio_dev->hwbank_num = gpio_dev->gc.ngpio / 64;
  1168		gpio_dev->groups = kerncz_groups;
  1169		gpio_dev->ngroups = ARRAY_SIZE(kerncz_groups);
  1170	
  1171		amd_pinctrl_desc.name = dev_name(&pdev->dev);
  1172		amd_get_iomux_res(gpio_dev);
  1173		gpio_dev->pctrl = devm_pinctrl_register(&pdev->dev, &amd_pinctrl_desc,
  1174							gpio_dev);
  1175		if (IS_ERR(gpio_dev->pctrl)) {
  1176			dev_err(&pdev->dev, "Couldn't register pinctrl driver\n");
  1177			return PTR_ERR(gpio_dev->pctrl);
  1178		}
  1179	
  1180		/* Disable and mask interrupts */
  1181		amd_gpio_irq_init(gpio_dev);
  1182	
  1183		girq = &gpio_dev->gc.irq;
  1184		gpio_irq_chip_set_chip(girq, &amd_gpio_irqchip);
  1185		/* This will let us handle the parent IRQ in the driver */
  1186		girq->parent_handler = NULL;
  1187		girq->num_parents = 0;
  1188		girq->parents = NULL;
  1189		girq->default_type = IRQ_TYPE_NONE;
  1190		girq->handler = handle_simple_irq;
  1191	
  1192		ret = gpiochip_add_data(&gpio_dev->gc, gpio_dev);
  1193		if (ret)
  1194			return ret;
  1195	
  1196		ret = gpiochip_add_pin_range(&gpio_dev->gc, dev_name(&pdev->dev),
  1197					0, 0, gpio_dev->gc.ngpio);
  1198		if (ret) {
  1199			dev_err(&pdev->dev, "Failed to add pin range\n");
  1200			goto out2;
  1201		}
  1202	
  1203		ret = devm_request_irq(&pdev->dev, gpio_dev->irq, amd_gpio_irq_handler,
  1204				       IRQF_SHARED | IRQF_COND_ONESHOT, KBUILD_MODNAME, gpio_dev);
  1205		if (ret)
  1206			goto out2;
  1207	
  1208		platform_set_drvdata(pdev, gpio_dev);
  1209		acpi_register_wakeup_handler(gpio_dev->irq, amd_gpio_check_wake, gpio_dev);
> 1210		acpi_register_lps0_dev(&pinctrl_amd_s2idle_dev_ops);
  1211	
  1212		dev_dbg(&pdev->dev, "amd gpio driver loaded\n");
  1213		return ret;
  1214	
  1215	out2:
  1216		gpiochip_remove(&gpio_dev->gc);
  1217	
  1218		return ret;
  1219	}
  1220	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v3 2/2] pinctrl: amd: Add an LPS0 check() callback
  2025-02-27 20:50 ` [PATCH v3 2/2] pinctrl: amd: Add an LPS0 check() callback Mario Limonciello
  2025-03-01 22:39   ` kernel test robot
  2025-03-02  0:28   ` kernel test robot
@ 2025-03-02  7:17   ` kernel test robot
  2 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2025-03-02  7:17 UTC (permalink / raw)
  To: Mario Limonciello, mario.limonciello, Basavaraj.Natikar,
	Shyam-sundar.S-k, linus.walleij
  Cc: oe-kbuild-all, linux-gpio

Hi Mario,

kernel test robot noticed the following build errors:

[auto build test ERROR on linusw-pinctrl/devel]
[also build test ERROR on linusw-pinctrl/for-next rafael-pm/linux-next rafael-pm/bleeding-edge linus/master v6.14-rc4 next-20250228]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Mario-Limonciello/ACPI-Add-missing-prototype-for-non-CONFIG_SUSPEND-CONFIG_X86-case/20250228-045242
base:   https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git devel
patch link:    https://lore.kernel.org/r/20250227205049.765309-3-superm1%40kernel.org
patch subject: [PATCH v3 2/2] pinctrl: amd: Add an LPS0 check() callback
config: mips-allyesconfig (https://download.01.org/0day-ci/archive/20250302/202503021444.b3oW30XQ-lkp@intel.com/config)
compiler: mips-linux-gcc (GCC) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250302/202503021444.b3oW30XQ-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/202503021444.b3oW30XQ-lkp@intel.com/

All errors (new ones prefixed by >>):

>> drivers/pinctrl/pinctrl-amd.c:933:15: error: variable 'pinctrl_amd_s2idle_dev_ops' has initializer but incomplete type
     933 | static struct acpi_s2idle_dev_ops pinctrl_amd_s2idle_dev_ops = {
         |               ^~~~~~~~~~~~~~~~~~~
>> drivers/pinctrl/pinctrl-amd.c:934:10: error: 'struct acpi_s2idle_dev_ops' has no member named 'check'
     934 |         .check = amd_gpio_check_pending,
         |          ^~~~~
   drivers/pinctrl/pinctrl-amd.c:934:18: warning: excess elements in struct initializer
     934 |         .check = amd_gpio_check_pending,
         |                  ^~~~~~~~~~~~~~~~~~~~~~
   drivers/pinctrl/pinctrl-amd.c:934:18: note: (near initialization for 'pinctrl_amd_s2idle_dev_ops')
   drivers/pinctrl/pinctrl-amd.c: In function 'amd_gpio_probe':
   drivers/pinctrl/pinctrl-amd.c:1210:9: error: implicit declaration of function 'acpi_register_lps0_dev' [-Wimplicit-function-declaration]
    1210 |         acpi_register_lps0_dev(&pinctrl_amd_s2idle_dev_ops);
         |         ^~~~~~~~~~~~~~~~~~~~~~
   drivers/pinctrl/pinctrl-amd.c: In function 'amd_gpio_remove':
   drivers/pinctrl/pinctrl-amd.c:1229:9: error: implicit declaration of function 'acpi_unregister_lps0_dev' [-Wimplicit-function-declaration]
    1229 |         acpi_unregister_lps0_dev(&pinctrl_amd_s2idle_dev_ops);
         |         ^~~~~~~~~~~~~~~~~~~~~~~~
   drivers/pinctrl/pinctrl-amd.c: At top level:
>> drivers/pinctrl/pinctrl-amd.c:933:35: error: storage size of 'pinctrl_amd_s2idle_dev_ops' isn't known
     933 | static struct acpi_s2idle_dev_ops pinctrl_amd_s2idle_dev_ops = {
         |                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~


vim +/pinctrl_amd_s2idle_dev_ops +933 drivers/pinctrl/pinctrl-amd.c

   932	
 > 933	static struct acpi_s2idle_dev_ops pinctrl_amd_s2idle_dev_ops = {
 > 934		.check = amd_gpio_check_pending,
   935	};
   936	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-03-02  7:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-27 20:50 [PATCH v3 0/2] Add LPS0 check() for pinctrl-amd Mario Limonciello
2025-02-27 20:50 ` [PATCH v3 2/2] pinctrl: amd: Add an LPS0 check() callback Mario Limonciello
2025-03-01 22:39   ` kernel test robot
2025-03-02  0:28   ` kernel test robot
2025-03-02  7:17   ` 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;
as well as URLs for NNTP newsgroup(s).