[SRU][F:linux-bluefield][PATCH v1 3/3] UBUNTU: SAUCE: pwr-mlxbf: support graceful reboot instead of soft reset
Asmaa Mnebhi
asmaa at nvidia.com
Mon Oct 30 20:05:47 UTC 2023
BugLink: https://bugs.launchpad.net/bugs/2041996
There is a new feature request to replace the soft reset with a
graceful reboot.
We will use acpi events triggered by the irq in the pwr-mlxbf file
to trigger the graceful reboot.
Signed-off-by: Asmaa Mnebhi <asmaa at nvidia.com>
---
drivers/power/reset/pwr-mlxbf.c | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/drivers/power/reset/pwr-mlxbf.c b/drivers/power/reset/pwr-mlxbf.c
index 683bf38ba582..813eb98a2b74 100644
--- a/drivers/power/reset/pwr-mlxbf.c
+++ b/drivers/power/reset/pwr-mlxbf.c
@@ -15,14 +15,20 @@
#include <linux/reboot.h>
#include <linux/types.h>
-#define DRV_VERSION "1.1"
+#define DRV_VERSION "1.2"
struct pwr_mlxbf {
- struct work_struct send_work;
+ struct work_struct reboot_work;
+ struct work_struct shutdown_work;
const char *hid;
};
-static void pwr_mlxbf_send_work(struct work_struct *work)
+static void pwr_mlxbf_reboot_work(struct work_struct *work)
+{
+ acpi_bus_generate_netlink_event("button/reboot.*", "Reboot Button", 0x80, 1);
+}
+
+static void pwr_mlxbf_shutdown_work(struct work_struct *work)
{
acpi_bus_generate_netlink_event("button/power.*", "Power Button", 0x80, 1);
}
@@ -34,16 +40,15 @@ static irqreturn_t pwr_mlxbf_irq(int irq, void *ptr)
struct pwr_mlxbf *priv = ptr;
if (!strncmp(priv->hid, rst_pwr_hid, 8))
- emergency_restart();
+ schedule_work(&priv->reboot_work);
if (!strncmp(priv->hid, low_pwr_hid, 8))
- schedule_work(&priv->send_work);
+ schedule_work(&priv->shutdown_work);
return IRQ_HANDLED;
}
-static int
-pwr_mlxbf_probe(struct platform_device *pdev)
+static int pwr_mlxbf_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct acpi_device *adev;
@@ -70,7 +75,8 @@ pwr_mlxbf_probe(struct platform_device *pdev)
return -EPROBE_DEFER;
}
- INIT_WORK(&priv->send_work, pwr_mlxbf_send_work);
+ INIT_WORK(&priv->shutdown_work, pwr_mlxbf_shutdown_work);
+ INIT_WORK(&priv->reboot_work, pwr_mlxbf_reboot_work);
platform_set_drvdata(pdev, priv);
@@ -86,7 +92,8 @@ pwr_mlxbf_remove(struct platform_device *pdev)
{
struct pwr_mlxbf *priv = platform_get_drvdata(pdev);
- flush_work(&priv->send_work);
+ flush_work(&priv->shutdown_work);
+ flush_work(&priv->reboot_work);
return 0;
}
--
2.30.1
More information about the kernel-team
mailing list