Skip to contentSkip to conversation

PNP: Do not disable devices on suspend when they cannot be re-enabled on resume

PATCH Applied Hans de Goede 2 participants 2 messages Nov 24, 2022 – Nov 25, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PNP: Do not disable devices on suspend when they cannot be re-enabled on resume

On an Advantech MICA-071 tablet, with a builtin barcode scanner connected to ttyS0, the following message is shown on suspend:

serial 00:02: disabled

And after suspend/resume trying to use the barcode scanner / ttyS0 shows:

serial 00:02: LSR safety check engaged!

Indicating that the UARTs io-ports are no longer reachable.

This is caused by __pnp_bus_suspend() calling pnp_stop_dev() on the "00:02" pnp device on suspend (this outputs the disabled message).

The problem is that pnp_can_write() returns false for the "00:02" pnp device, so after disabling it (disabling its decoding of IO addresses) during suspend, it cannot be re-enabled.

Add a pnp_can_write() check to the suspend path and only disable devices which can actually be re-enabled on resume.

This fixes the Advantech MICA-071's ttyS0 no longer working after a suspend/resume.

---
 drivers/pnp/driver.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pnp/driver.c +2 -1
index c02e7bf643a6..46c534f6b1c9 100644
@@ -182,7 +182,8 @@ static int __pnp_bus_suspend(struct device *dev, pm_message_t state)
 			return error;
 	}
 
-	if (pnp_can_disable(pnp_dev)) {
+	/* can_write is necessary to be able to re-start the device on resume */
+	if (pnp_can_disable(pnp_dev) && pnp_can_write(pnp_dev)) {
 		error = pnp_stop_dev(pnp_dev);
 		if (error)
 			return error;
Signature · 1 line
2.38.1
maintainer Applied
#1 lore raw
Quoted 35 lines · Hans de Goede

On an Advantech MICA-071 tablet, with a builtin barcode scanner connected to ttyS0, the following message is shown on suspend:

serial 00:02: disabled

And after suspend/resume trying to use the barcode scanner / ttyS0 shows:

serial 00:02: LSR safety check engaged!

Indicating that the UARTs io-ports are no longer reachable.

This is caused by __pnp_bus_suspend() calling pnp_stop_dev() on the "00:02" pnp device on suspend (this outputs the disabled message).

The problem is that pnp_can_write() returns false for the "00:02" pnp device, so after disabling it (disabling its decoding of IO addresses) during suspend, it cannot be re-enabled.

Add a pnp_can_write() check to the suspend path and only disable devices which can actually be re-enabled on resume.

This fixes the Advantech MICA-071's ttyS0 no longer working after a suspend/resume.

---
 drivers/pnp/driver.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pnp/driver.c +0 -0
index c02e7bf643a6..46c534f6b1c9 100644

drivers/pnp/driver.c static int __pnp_bus_suspend(struct device *dev, pm_message_t state)

Quoted 10 lines
drivers/pnp/driver.c +2 -2
@@ -182,7 +182,8 @@ static int __pnp_bus_suspend(struct device *dev, pm_message_t state)
                        return error;
        }
 
-       if (pnp_can_disable(pnp_dev)) {
+       /* can_write is necessary to be able to re-start the device on resume */
+       if (pnp_can_disable(pnp_dev) && pnp_can_write(pnp_dev)) {
                error = pnp_stop_dev(pnp_dev);
                if (error)
                        return error;
--

Applied as 6.2 material, thanks!