Fix no_console_suspend for PNP serial consoles
Subsystems (2)
v2 cover Fix no_console_suspend for PNP serial consoles
Hi Greg and Rafael,
This v2 of the earlier series submitted back in Nov addresses Rafael's comments, specifically:
* Adds PNP_CONSOLE flag, which disables the pnp protocol's suspend() and disable() methods.
This greatly simplifies the PNP serial driver patch since the existing pnp device capabilities does not need to be saved and restored now.
Note that it was necessary to continue to use macros, since struct pnp_protocol is anonymous.
Regards,
Peter Hurley (2):
PNP: Allow console to override ACPI device sleep
serial: 8250_pnp: Enable PNP_CONSOLE for console ports
drivers/pnp/driver.c | 2 +- drivers/tty/serial/8250/8250_pnp.c | 8 +++++++- include/linux/pnp.h | 12 ++++++++++-- 3 files changed, 18 insertions(+), 4 deletions(-)
Signature · 1 line
2.2.2
PATCH v2 1/2 PNP: Allow console to override ACPI device sleep
If the serial console is an ACPI PNP device, the PNP bus always powers down the device at system suspend, even though the no_console_suspend command line parameter is specified (eg., when debugging suspend/resume).
Add PNP_CONSOLE capability, which when set, prevents calling both the ->disable() and ->suspend() PNP protocol methods if console suspend is disabled.
--- drivers/pnp/driver.c | 2 +- include/linux/pnp.h | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-)
drivers/pnp/driver.c +1 -1
@@ -182,7 +182,7 @@ static int __pnp_bus_suspend(struct device *dev, pm_message_t state)return error; } -if (pnp_dev->protocol->suspend) +if (pnp_can_suspend (pnp_dev)) pnp_dev->protocol->suspend (pnp_dev, state);return 0 ; }
include/linux/pnp.h +10 -2
@@ -12,6 +12,7 @@#include <linux/list.h> #include <linux/errno.h> #include <linux/mod_devicetable.h> +#include <linux/console.h> #define PNP_NAME_LEN 50
@@ -309,15 +310,22 @@ struct pnp_fixup {#define PNP_DISABLE 0x0004#define PNP_CONFIGURABLE 0x0008#define PNP_REMOVABLE 0x0010 +#define PNP_CONSOLE 0x0020#define pnp_can_read (dev) (((dev)->protocol->get) && \ ((dev)->capabilities & PNP_READ))#define pnp_can_write (dev) (((dev)->protocol->set) && \ ((dev)->capabilities & PNP_WRITE)) -#define pnp_can_disable (dev) (((dev)->protocol->disable) && \ - ((dev)->capabilities & PNP_DISABLE)) +#define pnp_can_disable (dev) (((dev)->protocol->disable) && \ + ((dev)->capabilities & PNP_DISABLE) && \ + (!((dev)->capabilities & PNP_CONSOLE) || \ + console_suspend_enabled))#define pnp_can_configure (dev) ((!(dev)->active) && \ ((dev)->capabilities & PNP_CONFIGURABLE)) +#define pnp_can_suspend (dev) (((dev)->protocol->suspend) && \ + (!((dev)->capabilities & PNP_CONSOLE) || \ + console_suspend_enabled)) +#ifdef CONFIG_ISAPNP extern struct pnp_protocol isapnp_protocol;
Signature · 1 line
2.2.2
PATCH v2 2/2 serial: 8250_pnp: Enable PNP_CONSOLE for console ports
In reply to Peter HurleyWhen the kernel command line parameter, no_console_suspend, is used, the console should continue to output console messages during and after system suspend. For a serial console, the serial core ensures that the device is not shutdown when no_console_suspend is specified. However, the default operation of the pnp bus will disable and suspend the device and no further output occurs.
When registering the 8250 port, if the serial device is a console set the PNP_CONSOLE capability, which prevents device power-off if consoles are not suspending.
--- drivers/tty/serial/8250/8250_pnp.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/tty/serial/8250/8250_pnp.c +7 -1
@@ -426,7 +426,7 @@ static int serial_pnp_guess_board(struct pnp_dev *dev)static int serial_pnp_probe (struct pnp_dev *dev,const struct pnp_device_id *dev_id) { -struct uart_8250_port uart; +struct uart_8250_port uart, *port;int ret, line, flags = dev_id->driver_data;if (flags &UNKNOWN_DEV ) {
@@ -471,6 +471,10 @@ serial_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)if (line <0 || (flags &CIR_PORT ))return -ENODEV ; + port =serial8250_get_port (line); +if (uart_console (&port->port)) + dev->capabilities |=PNP_CONSOLE ; +pnp_set_drvdata (dev, (void *)((long )line +1 ));return 0 ; }
@@ -478,6 +482,8 @@ serial_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)static void serial_pnp_remove (struct pnp_dev *dev) {long line = (long )pnp_get_drvdata (dev); + + dev->capabilities &= ~PNP_CONSOLE ;if (line)serial8250_unregister_port (line -1 ); }
Signature · 1 line
2.2.2