aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/tty/serial/8250_pci.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/drivers/tty/serial/8250_pci.c b/drivers/tty/serial/8250_pci.c
index e1d4668f86ae..ae2188ce0670 100644
--- a/drivers/tty/serial/8250_pci.c
+++ b/drivers/tty/serial/8250_pci.c
@@ -2708,6 +2708,7 @@ pciserial_init_one(struct pci_dev *dev, const struct pci_device_id *ent)
2708 board = &pci_boards[ent->driver_data]; 2708 board = &pci_boards[ent->driver_data];
2709 2709
2710 rc = pci_enable_device(dev); 2710 rc = pci_enable_device(dev);
2711 pci_save_state(dev);
2711 if (rc) 2712 if (rc)
2712 return rc; 2713 return rc;
2713 2714
@@ -4002,6 +4003,51 @@ static struct pci_device_id serial_pci_tbl[] = {
4002 { 0, } 4003 { 0, }
4003}; 4004};
4004 4005
4006static pci_ers_result_t serial8250_io_error_detected(struct pci_dev *dev,
4007 pci_channel_state_t state)
4008{
4009 struct serial_private *priv = pci_get_drvdata(dev);
4010
4011 if (state == pci_channel_io_perm_failure)
4012 return PCI_ERS_RESULT_DISCONNECT;
4013
4014 if (priv)
4015 pciserial_suspend_ports(priv);
4016
4017 pci_disable_device(dev);
4018
4019 return PCI_ERS_RESULT_NEED_RESET;
4020}
4021
4022static pci_ers_result_t serial8250_io_slot_reset(struct pci_dev *dev)
4023{
4024 int rc;
4025
4026 rc = pci_enable_device(dev);
4027
4028 if (rc)
4029 return PCI_ERS_RESULT_DISCONNECT;
4030
4031 pci_restore_state(dev);
4032 pci_save_state(dev);
4033
4034 return PCI_ERS_RESULT_RECOVERED;
4035}
4036
4037static void serial8250_io_resume(struct pci_dev *dev)
4038{
4039 struct serial_private *priv = pci_get_drvdata(dev);
4040
4041 if (priv)
4042 pciserial_resume_ports(priv);
4043}
4044
4045static struct pci_error_handlers serial8250_err_handler = {
4046 .error_detected = serial8250_io_error_detected,
4047 .slot_reset = serial8250_io_slot_reset,
4048 .resume = serial8250_io_resume,
4049};
4050
4005static struct pci_driver serial_pci_driver = { 4051static struct pci_driver serial_pci_driver = {
4006 .name = "serial", 4052 .name = "serial",
4007 .probe = pciserial_init_one, 4053 .probe = pciserial_init_one,
@@ -4011,6 +4057,7 @@ static struct pci_driver serial_pci_driver = {
4011 .resume = pciserial_resume_one, 4057 .resume = pciserial_resume_one,
4012#endif 4058#endif
4013 .id_table = serial_pci_tbl, 4059 .id_table = serial_pci_tbl,
4060 .err_handler = &serial8250_err_handler,
4014}; 4061};
4015 4062
4016static int __init serial8250_pci_init(void) 4063static int __init serial8250_pci_init(void)