[PATCH v2 1/5] phy: cpcap-usb: Prevent line glitches from triggering sysrq
Ivaylo Dimitrov <[email protected]> Sun, 5 Jul 2026 10:58:05 +0300
| Newsgroups | org.kernel.vger.linux-omap,org.infradead.lists.linux-phy,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-gpio,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
We can get random sysrq events on switching from USB to debug serial port mode unless we temporarily disable sysrq on serial line for the mode changes. Suggested-by: Tony Lindgren <[email protected]> Signed-off-by: Ivaylo Dimitrov <[email protected]> --- drivers/phy/motorola/phy-cpcap-usb.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/phy/motorola/phy-cpcap-usb.c b/drivers/phy/motorola/phy-cpcap-usb.c index 7cb020dd3423..d1c70c715346 100644 --- a/drivers/phy/motorola/phy-cpcap-usb.c +++ b/drivers/phy/motorola/phy-cpcap-usb.c @@ -20,6 +20,7 @@ #include <linux/platform_device.h> #include <linux/regmap.h> #include <linux/slab.h> +#include <linux/sysrq.h> #include <linux/gpio/consumer.h> #include <linux/mfd/motorola-cpcap.h> @@ -413,7 +414,12 @@ static int cpcap_usb_gpio_set_mode(struct cpcap_phy_ddata *ddata, static int cpcap_usb_set_uart_mode(struct cpcap_phy_ddata *ddata) { - int error; + int old_sysrq_mask, error; + + /* Disable sysrq to prevent random sysrq events on line glitches */ + old_sysrq_mask = sysrq_mask(); + if (old_sysrq_mask & 1) + sysrq_toggle_support(old_sysrq_mask & ~1); /* Disable lines to prevent glitches from waking up mdm6600 */ error = cpcap_usb_gpio_set_mode(ddata, CPCAP_UNKNOWN_DISABLED); @@ -445,13 +451,13 @@ static int cpcap_usb_set_uart_mode(struct cpcap_phy_ddata *ddata) /* Enable UART mode */ error = cpcap_usb_gpio_set_mode(ddata, CPCAP_DM_DP); - if (error) - goto out_err; - - return 0; out_err: - dev_err(ddata->dev, "%s failed with %i\n", __func__, error); + if (old_sysrq_mask & 1) + sysrq_toggle_support(old_sysrq_mask); + + if (error) + dev_err(ddata->dev, "%s failed with %i\n", __func__, error); return error; } -- 2.39.5