Commit 3a0c56d8 authored by Michael Reed's avatar Michael Reed Committed by James Bottomley

[SCSI] mptfc: correct out of order event processing

This patch corrects a problem in mptfc which can result in targets
being removed after executing an "lsiutil 99" reset of the fibre
channel ports.

The last rescan event was being processed before the setup reset work
due to an inappropriate optimization in the event processing logic.
Every rescan event is now queued for execution and the setup reset
work now executes in the proper sequence.
Signed-off-by: default avatarMichael Reed <mdr@sgi.com>
Acked-by: default avatarMoore, Eric <Eric.Moore@lsil.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent 77d88ee2
...@@ -640,7 +640,6 @@ typedef struct _MPT_ADAPTER ...@@ -640,7 +640,6 @@ typedef struct _MPT_ADAPTER
struct work_struct fc_setup_reset_work; struct work_struct fc_setup_reset_work;
struct list_head fc_rports; struct list_head fc_rports;
spinlock_t fc_rescan_work_lock; spinlock_t fc_rescan_work_lock;
int fc_rescan_work_count;
struct work_struct fc_rescan_work; struct work_struct fc_rescan_work;
char fc_rescan_work_q_name[KOBJ_NAME_LEN]; char fc_rescan_work_q_name[KOBJ_NAME_LEN];
struct workqueue_struct *fc_rescan_work_q; struct workqueue_struct *fc_rescan_work_q;
......
...@@ -898,12 +898,9 @@ mptfc_rescan_devices(void *arg) ...@@ -898,12 +898,9 @@ mptfc_rescan_devices(void *arg)
{ {
MPT_ADAPTER *ioc = (MPT_ADAPTER *)arg; MPT_ADAPTER *ioc = (MPT_ADAPTER *)arg;
int ii; int ii;
int work_to_do;
u64 pn; u64 pn;
unsigned long flags;
struct mptfc_rport_info *ri; struct mptfc_rport_info *ri;
do {
/* start by tagging all ports as missing */ /* start by tagging all ports as missing */
list_for_each_entry(ri, &ioc->fc_rports, list) { list_for_each_entry(ri, &ioc->fc_rports, list) {
if (ri->flags & MPT_RPORT_INFO_FLAGS_REGISTERED) { if (ri->flags & MPT_RPORT_INFO_FLAGS_REGISTERED) {
...@@ -917,8 +914,8 @@ mptfc_rescan_devices(void *arg) ...@@ -917,8 +914,8 @@ mptfc_rescan_devices(void *arg)
*/ */
for (ii=0; ii < ioc->facts.NumberOfPorts; ii++) { for (ii=0; ii < ioc->facts.NumberOfPorts; ii++) {
(void) mptfc_GetFcPortPage0(ioc, ii); (void) mptfc_GetFcPortPage0(ioc, ii);
mptfc_init_host_attr(ioc,ii); /* refresh */ mptfc_init_host_attr(ioc, ii); /* refresh */
mptfc_GetFcDevPage0(ioc,ii,mptfc_register_dev); mptfc_GetFcDevPage0(ioc, ii, mptfc_register_dev);
} }
/* delete devices still missing */ /* delete devices still missing */
...@@ -940,17 +937,6 @@ mptfc_rescan_devices(void *arg) ...@@ -940,17 +937,6 @@ mptfc_rescan_devices(void *arg)
(unsigned long long)pn)); (unsigned long long)pn));
} }
} }
/*
* allow multiple passes as target state
* might have changed during scan
*/
spin_lock_irqsave(&ioc->fc_rescan_work_lock, flags);
if (ioc->fc_rescan_work_count > 2) /* only need one more */
ioc->fc_rescan_work_count = 2;
work_to_do = --ioc->fc_rescan_work_count;
spin_unlock_irqrestore(&ioc->fc_rescan_work_lock, flags);
} while (work_to_do);
} }
static int static int
...@@ -1162,7 +1148,6 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -1162,7 +1148,6 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id)
* by doing it via the workqueue, some locking is eliminated * by doing it via the workqueue, some locking is eliminated
*/ */
ioc->fc_rescan_work_count = 1;
queue_work(ioc->fc_rescan_work_q, &ioc->fc_rescan_work); queue_work(ioc->fc_rescan_work_q, &ioc->fc_rescan_work);
flush_workqueue(ioc->fc_rescan_work_q); flush_workqueue(ioc->fc_rescan_work_q);
...@@ -1205,11 +1190,9 @@ mptfc_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply) ...@@ -1205,11 +1190,9 @@ mptfc_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply)
case MPI_EVENT_RESCAN: case MPI_EVENT_RESCAN:
spin_lock_irqsave(&ioc->fc_rescan_work_lock, flags); spin_lock_irqsave(&ioc->fc_rescan_work_lock, flags);
if (ioc->fc_rescan_work_q) { if (ioc->fc_rescan_work_q) {
if (ioc->fc_rescan_work_count++ == 0) {
queue_work(ioc->fc_rescan_work_q, queue_work(ioc->fc_rescan_work_q,
&ioc->fc_rescan_work); &ioc->fc_rescan_work);
} }
}
spin_unlock_irqrestore(&ioc->fc_rescan_work_lock, flags); spin_unlock_irqrestore(&ioc->fc_rescan_work_lock, flags);
break; break;
default: default:
...@@ -1251,11 +1234,9 @@ mptfc_ioc_reset(MPT_ADAPTER *ioc, int reset_phase) ...@@ -1251,11 +1234,9 @@ mptfc_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
mptfc_SetFcPortPage1_defaults(ioc); mptfc_SetFcPortPage1_defaults(ioc);
spin_lock_irqsave(&ioc->fc_rescan_work_lock, flags); spin_lock_irqsave(&ioc->fc_rescan_work_lock, flags);
if (ioc->fc_rescan_work_q) { if (ioc->fc_rescan_work_q) {
if (ioc->fc_rescan_work_count++ == 0) {
queue_work(ioc->fc_rescan_work_q, queue_work(ioc->fc_rescan_work_q,
&ioc->fc_rescan_work); &ioc->fc_rescan_work);
} }
}
spin_unlock_irqrestore(&ioc->fc_rescan_work_lock, flags); spin_unlock_irqrestore(&ioc->fc_rescan_work_lock, flags);
} }
return 1; return 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment