: PCI Error Recovery: Symbios SCSI device driver
PATCH 1/1 : PCI Error Recovery: Symbios SCSI device driver
Matthew,
I hope this looks like a good patch. Please review, apply and forward upstream.
--linas
Various PCI bus errors can be signaled by newer PCI controllers. This patch adds the PCI error recovery callbacks to the Symbios SCSI device driver. The patch has been tested, and appears to work well.
----
drivers/scsi/sym53c8xx_2/sym_glue.c | 97 ++++++++++++++++++++++++++++++++++++ drivers/scsi/sym53c8xx_2/sym_glue.h | 4 + drivers/scsi/sym53c8xx_2/sym_hipd.c | 10 +++ 3 files changed, 111 insertions(+)
drivers/scsi/sym53c8xx_2/sym_glue.c +97 -0
@@ -659,6 +659,11 @@ static irqreturn_t sym53c8xx_intr(int irif (DEBUG_FLAGS &DEBUG_TINY )printf_debug ("[" ); +/* Avoid spinloop trying to handle interrupts on frozen device */ +if ((np->s.device->error_state != pci_channel_io_normal) && + (np->s.device->error_state !=0 )) +return IRQ_HANDLED ; +spin_lock_irqsave (np->s.host->host_lock, flags);sym_interrupt (np);spin_unlock_irqrestore (np->s.host->host_lock, flags);
@@ -726,6 +731,19 @@ static int sym_eh_handler(int op, char *dev_warn (&cmd->device->sdev_gendev,"%s operation started.\n" , opname); +/* We may be in an error condition because the PCI bus +* went down. In this case, we need to wait until the +* PCI bus is reset, the card is reset, and only then +* proceed with the scsi error recovery. There's no +* point in hurrying; take a leisurely wait. +*/ +#define WAIT_FOR_PCI_RECOVERY 35 +if ((np->s.device->error_state != pci_channel_io_normal) && + (np->s.device->error_state !=0 ) && + (0 ==wait_for_completion_timeout (&np->s.io_reset_wait, +WAIT_FOR_PCI_RECOVERY *HZ ))) +return SCSI_FAILED ; +spin_lock_irq (host->host_lock);/* This one is queued in some place -> to wait for completion */ FOR_EACH_QUEUED_ELEMENT(&np->busy_ccbq, qp) {
@@ -1510,6 +1528,7 @@ static struct Scsi_Host * __devinit sym_ np->maxoffs = dev->chip.offset_max; np->maxburst = dev->chip.burst_max; np->myaddr = dev->host_id; +init_completion (&np->s.io_reset_wait);/* * Edit its name.
@@ -1948,6 +1967,77 @@ static void __devexit sym2_remove(struct attach_count--; } +/** +* sym2_io_error_detected() -- called when PCI error is detected +* @pdev: pointer to PCI device +* @state: current state of the PCI slot +*/ +static pci_ers_result_t sym2_io_error_detected (struct pci_dev *pdev, +enum pci_channel_state state) +{ +struct sym_hcb *np =pci_get_drvdata (pdev); + +/* If slot is permanently frozen, turn everything off */ +if (state == pci_channel_io_perm_failure) { +sym2_remove (pdev); +return PCI_ERS_RESULT_DISCONNECT ; + } + +init_completion (&np->s.io_reset_wait); +disable_irq (pdev->irq); +pci_disable_device (pdev); + +/* Request a slot slot reset. */ +return PCI_ERS_RESULT_NEED_RESET ; +} + +/** +* sym2_io_slot_reset() -- called when the pci bus has been reset. +* @pdev: pointer to PCI device +* +* Restart the card from scratch. +*/ +static pci_ers_result_t sym2_io_slot_reset (struct pci_dev *pdev) +{ +struct sym_hcb *np =pci_get_drvdata (pdev); + +printk (KERN_INFO "%s: recovering from a PCI slot reset\n" , +sym_name (np)); + +if (pci_enable_device (pdev)) +printk (KERN_ERR "%s: device setup failed most egregiously\n" , +sym_name (np)); + +pci_set_master (pdev); +enable_irq (pdev->irq); + +/* Perform host reset only on one instance of the card */ +if (0 ==PCI_FUNC (pdev->devfn)) { +if (sym_reset_scsi_bus (np,0 )) { +printk (KERN_ERR "%s: Unable to reset scsi host controller\n" , +sym_name (np)); +return PCI_ERS_RESULT_DISCONNECT ; + } +sym_start_up (np,1 ); + } + +return PCI_ERS_RESULT_RECOVERED ; +} + +/** +* sym2_io_resume() -- resume normal ops after PCI reset +* @pdev: pointer to PCI device +* +* Called when the error recovery driver tells us that its +* OK to resume normal operation. Use completion to allow +* halted scsi ops to resume. +*/ +static void sym2_io_resume (struct pci_dev *pdev) +{ +struct sym_hcb *np =pci_get_drvdata (pdev); +complete_all (&np->s.io_reset_wait); +} +static void sym2_get_signalling (struct Scsi_Host *shost) {struct sym_hcb *np =sym_get_hcb (shost);
@@ -2110,11 +2200,18 @@ static struct pci_device_id sym2_id_tablMODULE_DEVICE_TABLE (pci, sym2_id_table); +static struct pci_error_handlers sym2_err_handler = { + .error_detected = sym2_io_error_detected, + .slot_reset = sym2_io_slot_reset, + .resume = sym2_io_resume, +}; +static struct pci_driver sym2_driver = { .name =NAME53C8XX , .id_table = sym2_id_table, .probe = sym2_probe, .remove =__devexit_p (sym2_remove), + .err_handler = &sym2_err_handler, };static int __init sym2_init (void )
drivers/scsi/sym53c8xx_2/sym_glue.h +4 -0
@@ -40,6 +40,7 @@#ifndef SYM_GLUE_H #define SYM_GLUE_H +#include <linux/completion.h> #include <linux/delay.h> #include <linux/ioport.h> #include <linux/pci.h>
@@ -179,6 +180,9 @@ struct sym_shcb {char chip_name[8 ];struct pci_dev *device; +/* Waiter for clearing of frozen PCI bus */ +struct completion io_reset_wait; +struct Scsi_Host *host;void __iomem * ioaddr;/* MMIO kernel io address */
drivers/scsi/sym53c8xx_2/sym_hipd.c +10 -0
@@ -2761,6 +2761,7 @@ void sym_interrupt (struct sym_hcb *np)u_char istat, istatc;u_char dstat;u_short sist; +u_int icnt;/* * interrupt on the fly ?
@@ -2802,6 +2803,7 @@ void sym_interrupt (struct sym_hcb *np) sist =0 ; dstat =0 ; istatc = istat; + icnt =0 ; do { if (istatc & SIP) sist |= INW(np, nc_sist);
@@ -2809,6 +2811,14 @@ void sym_interrupt (struct sym_hcb *np) dstat |=INB (np, nc_dstat); istatc =INB (np, nc_istat); istat |= istatc; + +/* Prevent deadlock waiting on a condition that may never clear. */ + icnt ++; +if (100 < icnt) { +if ((np->s.device->error_state != pci_channel_io_normal) + && (np->s.device->error_state !=0 )) +return ; + } }while (istatc & (SIP |DIP ));if (DEBUG_FLAGS &DEBUG_TINY )
Hi Linas,
Linas Vepstas <[email protected]> ha scritto:
Quoted 5 lines
Index:
linux-2.6.18-rc7-git1/drivers/scsi/sym53c8xx_2/sym_glue.c
===================================================================drivers/scsi/sym53c8xx_2/sym_glue.c 2006-09-21 17:35:37.000000000 -0500 renamed from drivers/scsi/sym53c8xx_2/sym_glue.c 2006-09-21 17:32:54.000000000 -0500 +1
-0+/**
drivers/scsi/sym53c8xx_2/sym_glue.c 2006-09-21 17:35:37.000000000 -0500
Quoted 10 lines
drivers/scsi/sym53c8xx_2/sym_glue.c 2006-09-21 17:35:37.000000000 -0500 renamed from drivers/scsi/sym53c8xx_2/sym_glue.c 2006-09-21 17:32:54.000000000 -0500 +10
-0+ * sym2_io_slot_reset() -- called when the pci bus has been reset. + * @pdev: pointer to PCI device + * + * Restart the card from scratch. + */ +static pci_ers_result_t sym2_io_slot_reset (struct pci_dev *pdev) +{ + struct sym_hcb *np = pci_get_drvdata(pdev); + + printk (KERN_INFO "%s: recovering from a PCI slot reset\n",
Space after function name? You put in other places too, it's not consistent with the rest of the patch.
drivers/scsi/sym53c8xx_2/sym_glue.c 2006-09-21 17:35:37.000000000 -0500
Quoted 5 lines
drivers/scsi/sym53c8xx_2/sym_glue.c 2006-09-21 17:35:37.000000000 -0500 renamed from drivers/scsi/sym53c8xx_2/sym_glue.c 2006-09-21 17:32:54.000000000 -0500 +5
-0+ sym_name(np)); + + if (pci_enable_device(pdev)) + printk (KERN_ERR "%s: device setup failed most egregiously\n", + sym_name(np));
Is the failure of pci_enable_device ignored on purpose? (plus extra space)
drivers/scsi/sym53c8xx_2/sym_glue.c 2006-09-21 17:35:37.000000000 -0500
Quoted 3 lines
drivers/scsi/sym53c8xx_2/sym_glue.c 2006-09-21 17:35:37.000000000 -0500 renamed from drivers/scsi/sym53c8xx_2/sym_glue.c 2006-09-21 17:32:54.000000000 -0500 +3
-0+ + pci_set_master(pdev); + enable_irq (pdev->irq);
Spurious space.
drivers/scsi/sym53c8xx_2/sym_glue.c 2006-09-21 17:35:37.000000000 -0500
Quoted 3 lines
drivers/scsi/sym53c8xx_2/sym_glue.c 2006-09-21 17:35:37.000000000 -0500 renamed from drivers/scsi/sym53c8xx_2/sym_glue.c 2006-09-21 17:32:54.000000000 -0500 +3
-0+ + /* Perform host reset only on one instance of the card */ + if (0 == PCI_FUNC (pdev->devfn)) {
Ditto.
drivers/scsi/sym53c8xx_2/sym_glue.c 2006-09-21 17:35:37.000000000 -0500
Quoted 6 lines
drivers/scsi/sym53c8xx_2/sym_glue.c 2006-09-21 17:35:37.000000000 -0500 renamed from drivers/scsi/sym53c8xx_2/sym_glue.c 2006-09-21 17:32:54.000000000 -0500 +6
-0+ if (sym_reset_scsi_bus(np, 0)) { + printk(KERN_ERR "%s: Unable to reset scsi host controller\n", + sym_name(np)); + return PCI_ERS_RESULT_DISCONNECT; + } + sym_start_up (np, 1);
Ditto.
drivers/scsi/sym53c8xx_2/sym_glue.c 2006-09-21 17:35:37.000000000 -0500
Quoted 4 lines
drivers/scsi/sym53c8xx_2/sym_glue.c 2006-09-21 17:35:37.000000000 -0500 renamed from drivers/scsi/sym53c8xx_2/sym_glue.c 2006-09-21 17:32:54.000000000 -0500 +4
-0+ } + + return PCI_ERS_RESULT_RECOVERED; +}
Luca
Signature · 4 lines
"L'abilita` politica e` l'abilita` di prevedere quello che accadra` domani, la prossima settimana, il prossimo mese e l'anno prossimo. E di essere cosi` abili, piu` tardi, da spiegare perche' non e` accaduto."
Quoted 3 lines · Luca
Space after function name? You put in other places too, it's not consistent with the rest of the patch.
Oops. I was also coding on a different project recently, with a different style. I'll send a revised patch in a moment.
Quoted 5 lines
drivers/scsi/sym53c8xx_2/sym_glue.c static void __devexit sym2_remove(struct · line 2009
Quoted 3 lines
drivers/scsi/sym53c8xx_2/sym_glue.c +3
-0+if (pci_enable_device (pdev)) +printk (KERN_ERR "%s: device setup failed most egregiously\n" , +sym_name (np));Is the failure of
pci_enable_deviceignored on purpose?
No. :-( Thanks for the catch. I think I got cross-eyed staring at the code.
--linas
Quoted 7 lines · On Fri, 22 Sep 2006 18:32:35 -0500 Linas Vepstas wrote:
Quoted 3 lines · Luca
Space after function name? You put in other places too, it's not consistent with the rest of the patch.
Oops. I was also coding on a different project recently, with a different style. I'll send a revised patch in a moment.
Please change if()'s to use
if (var == constant) instead of if (constant == var)
also. (or whatever condition is being used) Thanks.
Quoted 7 lines
Quoted 5 lines
drivers/scsi/sym53c8xx_2/sym_glue.c static void __devexit sym2_remove(struct · line 2009
Quoted 3 lines
drivers/scsi/sym53c8xx_2/sym_glue.c +3
-0+if (pci_enable_device (pdev)) +printk (KERN_ERR "%s: device setup failed most egregiously\n" , +sym_name (np));Is the failure of
pci_enable_deviceignored on purpose?No. :-( Thanks for the catch. I think I got cross-eyed staring at the code.
---
~Randy
Quoted 7 lines · Randy.Dunlap
Quoted 5 lines · On Fri, 22 Sep 2006 18:32:35 -0500 Linas Vepstas wrote:
Quoted 3 lines · Luca
Space after function name? You put in other places too, it's not consistent with the rest of the patch.
Quoted 8 lines
Quoted 2 lines
Oops. I was also coding on a different project recently, with a different style. I'll send a revised patch in a moment.
Please change if()'s to use
if (var == constant) instead of if (constant == var)
Yuck! Horrid coding style! No rational excuse for coding like that. Advice taken under protest; new patch shortly.
--linas
Quoted 11 lines · On Fri, 22 Sep 2006 18:50:17 -0500 Linas Vepstas wrote:
Quoted 10 lines · Randy.Dunlap
Quoted 7 lines · On Fri, 22 Sep 2006 18:32:35 -0500 Linas Vepstas wrote:
Quoted 3 lines · Luca
Space after function name? You put in other places too, it's not consistent with the rest of the patch.
Oops. I was also coding on a different project recently, with a different style. I'll send a revised patch in a moment.
Quoted 8 lines
Quoted 5 lines
Please change if()'s to use
if (var == constant) instead of if (constant == var)Yuck! Horrid coding style! No rational excuse for coding like that. Advice taken under protest; new patch shortly.
Just after my email, I saw this :)
http://marc.theaimsgroup.com/?l=linux-mm-commits&m=115896769322020&w=2
---
~Randy
PATCH 1/1 : (revised 2) PCI Error Recovery: Symbios SCSI device driver
In reply to Randy.DunlapMatthew,
Second revised patch, based on comments from Luca and Randy.Dunlap Please review, apply and forward upstream.
--linas
Various PCI bus errors can be signaled by newer PCI controllers. This patch adds the PCI error recovery callbacks to the Symbios SCSI device driver. The patch has been tested, and appears to work well.
--
drivers/scsi/sym53c8xx_2/sym_glue.c | 99 ++++++++++++++++++++++++++++++++++++ drivers/scsi/sym53c8xx_2/sym_glue.h | 4 + drivers/scsi/sym53c8xx_2/sym_hipd.c | 10 +++ 3 files changed, 113 insertions(+)
drivers/scsi/sym53c8xx_2/sym_glue.c +99 -0
@@ -659,6 +659,11 @@ static irqreturn_t sym53c8xx_intr(int irif (DEBUG_FLAGS &DEBUG_TINY )printf_debug ("[" ); +/* Avoid spinloop trying to handle interrupts on frozen device */ +if ((np->s.device->error_state != pci_channel_io_normal) && + (np->s.device->error_state !=0 )) +return IRQ_HANDLED ; +spin_lock_irqsave (np->s.host->host_lock, flags);sym_interrupt (np);spin_unlock_irqrestore (np->s.host->host_lock, flags);
@@ -726,6 +731,19 @@ static int sym_eh_handler(int op, char *dev_warn (&cmd->device->sdev_gendev,"%s operation started.\n" , opname); +/* We may be in an error condition because the PCI bus +* went down. In this case, we need to wait until the +* PCI bus is reset, the card is reset, and only then +* proceed with the scsi error recovery. There's no +* point in hurrying; take a leisurely wait. +*/ +#define WAIT_FOR_PCI_RECOVERY 35 +if ((np->s.device->error_state != pci_channel_io_normal) && + (np->s.device->error_state !=0 ) && + (wait_for_completion_timeout (&np->s.io_reset_wait, +WAIT_FOR_PCI_RECOVERY *HZ ) ==0 )) +return SCSI_FAILED ; +spin_lock_irq (host->host_lock);/* This one is queued in some place -> to wait for completion */ FOR_EACH_QUEUED_ELEMENT(&np->busy_ccbq, qp) {
@@ -1510,6 +1528,7 @@ static struct Scsi_Host * __devinit sym_ np->maxoffs = dev->chip.offset_max; np->maxburst = dev->chip.burst_max; np->myaddr = dev->host_id; +init_completion (&np->s.io_reset_wait);/* * Edit its name.
@@ -1948,6 +1967,79 @@ static void __devexit sym2_remove(struct attach_count--; } +/** +* sym2_io_error_detected() -- called when PCI error is detected +* @pdev: pointer to PCI device +* @state: current state of the PCI slot +*/ +static pci_ers_result_t sym2_io_error_detected (struct pci_dev *pdev, +enum pci_channel_state state) +{ +struct sym_hcb *np =pci_get_drvdata (pdev); + +/* If slot is permanently frozen, turn everything off */ +if (state == pci_channel_io_perm_failure) { +sym2_remove (pdev); +return PCI_ERS_RESULT_DISCONNECT ; + } + +init_completion (&np->s.io_reset_wait); +disable_irq (pdev->irq); +pci_disable_device (pdev); + +/* Request a slot reset. */ +return PCI_ERS_RESULT_NEED_RESET ; +} + +/** +* sym2_io_slot_reset() -- called when the pci bus has been reset. +* @pdev: pointer to PCI device +* +* Restart the card from scratch. +*/ +static pci_ers_result_t sym2_io_slot_reset (struct pci_dev *pdev) +{ +struct sym_hcb *np =pci_get_drvdata (pdev); + +printk (KERN_INFO "%s: recovering from a PCI slot reset\n" , +sym_name (np)); + +if (pci_enable_device (pdev)) { +printk (KERN_ERR "%s: device setup failed most egregiously\n" , +sym_name (np)); +return PCI_ERS_RESULT_DISCONNECT ; + } + +pci_set_master (pdev); +enable_irq (pdev->irq); + +/* Perform host reset only on one instance of the card */ +if (PCI_FUNC (pdev->devfn) ==0 ) { +if (sym_reset_scsi_bus (np,0 )) { +printk (KERN_ERR "%s: Unable to reset scsi host controller\n" , +sym_name (np)); +return PCI_ERS_RESULT_DISCONNECT ; + } +sym_start_up (np,1 ); + } + +return PCI_ERS_RESULT_RECOVERED ; +} + +/** +* sym2_io_resume() -- resume normal ops after PCI reset +* @pdev: pointer to PCI device +* +* Called when the error recovery driver tells us that its +* OK to resume normal operation. Use completion to allow +* halted scsi ops to resume. +*/ +static void sym2_io_resume (struct pci_dev *pdev) +{ +struct sym_hcb *np =pci_get_drvdata (pdev); +complete_all (&np->s.io_reset_wait); +} +static void sym2_get_signalling (struct Scsi_Host *shost) {struct sym_hcb *np =sym_get_hcb (shost);
@@ -2110,11 +2202,18 @@ static struct pci_device_id sym2_id_tablMODULE_DEVICE_TABLE (pci, sym2_id_table); +static struct pci_error_handlers sym2_err_handler = { + .error_detected = sym2_io_error_detected, + .slot_reset = sym2_io_slot_reset, + .resume = sym2_io_resume, +}; +static struct pci_driver sym2_driver = { .name =NAME53C8XX , .id_table = sym2_id_table, .probe = sym2_probe, .remove =__devexit_p (sym2_remove), + .err_handler = &sym2_err_handler, };static int __init sym2_init (void )
drivers/scsi/sym53c8xx_2/sym_glue.h +4 -0
@@ -40,6 +40,7 @@#ifndef SYM_GLUE_H #define SYM_GLUE_H +#include <linux/completion.h> #include <linux/delay.h> #include <linux/ioport.h> #include <linux/pci.h>
@@ -179,6 +180,9 @@ struct sym_shcb {char chip_name[8 ];struct pci_dev *device; +/* Waiter for clearing of frozen PCI bus */ +struct completion io_reset_wait; +struct Scsi_Host *host;void __iomem * ioaddr;/* MMIO kernel io address */
drivers/scsi/sym53c8xx_2/sym_hipd.c +10 -0
@@ -2761,6 +2761,7 @@ void sym_interrupt (struct sym_hcb *np)u_char istat, istatc;u_char dstat;u_short sist; +u_int icnt;/* * interrupt on the fly ?
@@ -2802,6 +2803,7 @@ void sym_interrupt (struct sym_hcb *np) sist =0 ; dstat =0 ; istatc = istat; + icnt =0 ; do { if (istatc & SIP) sist |= INW(np, nc_sist);
@@ -2809,6 +2811,14 @@ void sym_interrupt (struct sym_hcb *np) dstat |=INB (np, nc_dstat); istatc =INB (np, nc_istat); istat |= istatc; + +/* Prevent deadlock waiting on a condition that may never clear. */ + icnt ++; +if (icnt >100 ) { +if ((np->s.device->error_state != pci_channel_io_normal) + && (np->s.device->error_state !=0 )) +return ; + } }while (istatc & (SIP |DIP ));if (DEBUG_FLAGS &DEBUG_TINY )
PATCH 1/1 : (revised) PCI Error Recovery: Symbios SCSI device driver
In reply to LucaMatthew,
Revised patch per comments from Luca,
Please review, apply and forward upstream.
--linas
Various PCI bus errors can be signaled by newer PCI controllers. This patch adds the PCI error recovery callbacks to the Symbios SCSI device driver. The patch has been tested, and appears to work well.
--
drivers/scsi/sym53c8xx_2/sym_glue.c | 99 ++++++++++++++++++++++++++++++++++++ drivers/scsi/sym53c8xx_2/sym_glue.h | 4 + drivers/scsi/sym53c8xx_2/sym_hipd.c | 10 +++ 3 files changed, 113 insertions(+)
drivers/scsi/sym53c8xx_2/sym_glue.c +99 -0
@@ -659,6 +659,11 @@ static irqreturn_t sym53c8xx_intr(int irif (DEBUG_FLAGS &DEBUG_TINY )printf_debug ("[" ); +/* Avoid spinloop trying to handle interrupts on frozen device */ +if ((np->s.device->error_state != pci_channel_io_normal) && + (np->s.device->error_state !=0 )) +return IRQ_HANDLED ; +spin_lock_irqsave (np->s.host->host_lock, flags);sym_interrupt (np);spin_unlock_irqrestore (np->s.host->host_lock, flags);
@@ -726,6 +731,19 @@ static int sym_eh_handler(int op, char *dev_warn (&cmd->device->sdev_gendev,"%s operation started.\n" , opname); +/* We may be in an error condition because the PCI bus +* went down. In this case, we need to wait until the +* PCI bus is reset, the card is reset, and only then +* proceed with the scsi error recovery. There's no +* point in hurrying; take a leisurely wait. +*/ +#define WAIT_FOR_PCI_RECOVERY 35 +if ((np->s.device->error_state != pci_channel_io_normal) && + (np->s.device->error_state !=0 ) && + (0 ==wait_for_completion_timeout (&np->s.io_reset_wait, +WAIT_FOR_PCI_RECOVERY *HZ ))) +return SCSI_FAILED ; +spin_lock_irq (host->host_lock);/* This one is queued in some place -> to wait for completion */ FOR_EACH_QUEUED_ELEMENT(&np->busy_ccbq, qp) {
@@ -1510,6 +1528,7 @@ static struct Scsi_Host * __devinit sym_ np->maxoffs = dev->chip.offset_max; np->maxburst = dev->chip.burst_max; np->myaddr = dev->host_id; +init_completion (&np->s.io_reset_wait);/* * Edit its name.
@@ -1948,6 +1967,79 @@ static void __devexit sym2_remove(struct attach_count--; } +/** +* sym2_io_error_detected() -- called when PCI error is detected +* @pdev: pointer to PCI device +* @state: current state of the PCI slot +*/ +static pci_ers_result_t sym2_io_error_detected (struct pci_dev *pdev, +enum pci_channel_state state) +{ +struct sym_hcb *np =pci_get_drvdata (pdev); + +/* If slot is permanently frozen, turn everything off */ +if (state == pci_channel_io_perm_failure) { +sym2_remove (pdev); +return PCI_ERS_RESULT_DISCONNECT ; + } + +init_completion (&np->s.io_reset_wait); +disable_irq (pdev->irq); +pci_disable_device (pdev); + +/* Request a slot reset. */ +return PCI_ERS_RESULT_NEED_RESET ; +} + +/** +* sym2_io_slot_reset() -- called when the pci bus has been reset. +* @pdev: pointer to PCI device +* +* Restart the card from scratch. +*/ +static pci_ers_result_t sym2_io_slot_reset (struct pci_dev *pdev) +{ +struct sym_hcb *np =pci_get_drvdata (pdev); + +printk (KERN_INFO "%s: recovering from a PCI slot reset\n" , +sym_name (np)); + +if (pci_enable_device (pdev)) { +printk (KERN_ERR "%s: device setup failed most egregiously\n" , +sym_name (np)); +return PCI_ERS_RESULT_DISCONNECT ; + } + +pci_set_master (pdev); +enable_irq (pdev->irq); + +/* Perform host reset only on one instance of the card */ +if (0 ==PCI_FUNC (pdev->devfn)) { +if (sym_reset_scsi_bus (np,0 )) { +printk (KERN_ERR "%s: Unable to reset scsi host controller\n" , +sym_name (np)); +return PCI_ERS_RESULT_DISCONNECT ; + } +sym_start_up (np,1 ); + } + +return PCI_ERS_RESULT_RECOVERED ; +} + +/** +* sym2_io_resume() -- resume normal ops after PCI reset +* @pdev: pointer to PCI device +* +* Called when the error recovery driver tells us that its +* OK to resume normal operation. Use completion to allow +* halted scsi ops to resume. +*/ +static void sym2_io_resume (struct pci_dev *pdev) +{ +struct sym_hcb *np =pci_get_drvdata (pdev); +complete_all (&np->s.io_reset_wait); +} +static void sym2_get_signalling (struct Scsi_Host *shost) {struct sym_hcb *np =sym_get_hcb (shost);
@@ -2110,11 +2202,18 @@ static struct pci_device_id sym2_id_tablMODULE_DEVICE_TABLE (pci, sym2_id_table); +static struct pci_error_handlers sym2_err_handler = { + .error_detected = sym2_io_error_detected, + .slot_reset = sym2_io_slot_reset, + .resume = sym2_io_resume, +}; +static struct pci_driver sym2_driver = { .name =NAME53C8XX , .id_table = sym2_id_table, .probe = sym2_probe, .remove =__devexit_p (sym2_remove), + .err_handler = &sym2_err_handler, };static int __init sym2_init (void )
drivers/scsi/sym53c8xx_2/sym_glue.h +4 -0
@@ -40,6 +40,7 @@#ifndef SYM_GLUE_H #define SYM_GLUE_H +#include <linux/completion.h> #include <linux/delay.h> #include <linux/ioport.h> #include <linux/pci.h>
@@ -179,6 +180,9 @@ struct sym_shcb {char chip_name[8 ];struct pci_dev *device; +/* Waiter for clearing of frozen PCI bus */ +struct completion io_reset_wait; +struct Scsi_Host *host;void __iomem * ioaddr;/* MMIO kernel io address */
drivers/scsi/sym53c8xx_2/sym_hipd.c +10 -0
@@ -2761,6 +2761,7 @@ void sym_interrupt (struct sym_hcb *np)u_char istat, istatc;u_char dstat;u_short sist; +u_int icnt;/* * interrupt on the fly ?
@@ -2802,6 +2803,7 @@ void sym_interrupt (struct sym_hcb *np) sist =0 ; dstat =0 ; istatc = istat; + icnt =0 ; do { if (istatc & SIP) sist |= INW(np, nc_sist);
@@ -2809,6 +2811,14 @@ void sym_interrupt (struct sym_hcb *np) dstat |=INB (np, nc_dstat); istatc =INB (np, nc_istat); istat |= istatc; + +/* Prevent deadlock waiting on a condition that may never clear. */ + icnt ++; +if (100 < icnt) { +if ((np->s.device->error_state != pci_channel_io_normal) + && (np->s.device->error_state !=0 )) +return ; + } }while (istatc & (SIP |DIP ));if (DEBUG_FLAGS &DEBUG_TINY )