lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 29 Aug 2023 11:56:26 -0500
From:   Mario Limonciello <mario.limonciello@....com>
To:     <linus.walleij@...aro.org>
CC:     <Shyam-sundar.S-k@....com>, <Basavaraj.Natikar@....com>,
        <linux-gpio@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
        <regressions@...ts.linux.dev>, <lucapgl2001@...il.com>,
        Mario Limonciello <mario.limonciello@....com>
Subject: [PATCH 2/3] pinctrl: amd: Add a module parameter to configure power button behavior

On pinctrl-amd supported systems there is a bit in the GPIO controller
register that controls the debounce behavior. The traditional debounce
behavior is configured by software, whereas the 'WinBlue' debounce behavior
is handled internally in the GPIO controller and conforms to Microsoft
requirements.

For any users that find this behavior not desirable, add a module parameter
to force the traditional debounce behavior.

Signed-off-by: Mario Limonciello <mario.limonciello@....com>
---
 drivers/pinctrl/pinctrl-amd.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/drivers/pinctrl/pinctrl-amd.c b/drivers/pinctrl/pinctrl-amd.c
index 37d64fa55b66..a2468a988be3 100644
--- a/drivers/pinctrl/pinctrl-amd.c
+++ b/drivers/pinctrl/pinctrl-amd.c
@@ -36,6 +36,11 @@
 #include "pinctrl-utils.h"
 #include "pinctrl-amd.h"
 
+static int powerbtn = -1;
+module_param(powerbtn, int, 0444);
+MODULE_PARM_DESC(powerbtn,
+		 "Power button debouncing: 0=traditional, 1=windows, -1=auto");
+
 static int amd_gpio_get_direction(struct gpio_chip *gc, unsigned offset)
 {
 	unsigned long flags;
@@ -1075,6 +1080,30 @@ static void amd_get_iomux_res(struct amd_gpio *gpio_dev)
 	desc->pmxops = NULL;
 }
 
+static void handle_powerbtn(struct amd_gpio *gpio_dev)
+{
+	u32 pin_reg;
+
+	if (powerbtn == -1)
+		return;
+
+	pin_reg = readl(gpio_dev->base + WAKE_INT_MASTER_REG);
+	switch (powerbtn) {
+	case 0:
+		pin_reg &= ~INTERNAL_GPIO0_DEBOUNCE;
+		break;
+	case 1:
+		pin_reg |= INTERNAL_GPIO0_DEBOUNCE;
+		break;
+	default:
+		dev_err(&gpio_dev->pdev->dev, "Invalid module parameter %d\n",
+			powerbtn);
+		return;
+	}
+
+	writel(pin_reg, gpio_dev->base + WAKE_INT_MASTER_REG);
+}
+
 static int amd_gpio_probe(struct platform_device *pdev)
 {
 	int ret = 0;
@@ -1095,6 +1124,8 @@ static int amd_gpio_probe(struct platform_device *pdev)
 		return PTR_ERR(gpio_dev->base);
 	}
 
+	handle_powerbtn(gpio_dev);
+
 	gpio_dev->irq = platform_get_irq(pdev, 0);
 	if (gpio_dev->irq < 0)
 		return gpio_dev->irq;
-- 
2.34.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ