Commit bd23e94c authored by Moore, Eric's avatar Moore, Eric Committed by James Bottomley

[SCSI] mptfusion: bug fix's for raid components adding/deleting

This patch handles case where raid hidden components
are not being removed when power turned off to device
attached to expander, as well as the case of
exposing raid components when power is turned back on
to devices attached to an expander.  (This is a repost
of this patch, with  mptsas_is_end_device declared
further up in the code.)

This patch contains some other miscellaneous bug fix's.
Signed-off-by: default avatarEric Moore <Eric.Moore@lsil.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent c42bcefb
...@@ -5741,6 +5741,7 @@ static void ...@@ -5741,6 +5741,7 @@ static void
EventDescriptionStr(u8 event, u32 evData0, char *evStr) EventDescriptionStr(u8 event, u32 evData0, char *evStr)
{ {
char *ds; char *ds;
char buf[50];
switch(event) { switch(event) {
case MPI_EVENT_NONE: case MPI_EVENT_NONE:
...@@ -5841,7 +5842,6 @@ EventDescriptionStr(u8 event, u32 evData0, char *evStr) ...@@ -5841,7 +5842,6 @@ EventDescriptionStr(u8 event, u32 evData0, char *evStr)
break; break;
case MPI_EVENT_SAS_DEVICE_STATUS_CHANGE: case MPI_EVENT_SAS_DEVICE_STATUS_CHANGE:
{ {
char buf[50];
u8 id = (u8)(evData0); u8 id = (u8)(evData0);
u8 ReasonCode = (u8)(evData0 >> 16); u8 ReasonCode = (u8)(evData0 >> 16);
switch (ReasonCode) { switch (ReasonCode) {
...@@ -5878,7 +5878,6 @@ EventDescriptionStr(u8 event, u32 evData0, char *evStr) ...@@ -5878,7 +5878,6 @@ EventDescriptionStr(u8 event, u32 evData0, char *evStr)
break; break;
case MPI_EVENT_SAS_PHY_LINK_STATUS: case MPI_EVENT_SAS_PHY_LINK_STATUS:
{ {
char buf[50];
u8 LinkRates = (u8)(evData0 >> 8); u8 LinkRates = (u8)(evData0 >> 8);
u8 PhyNumber = (u8)(evData0); u8 PhyNumber = (u8)(evData0);
LinkRates = (LinkRates & MPI_EVENT_SAS_PLS_LR_CURRENT_MASK) >> LinkRates = (LinkRates & MPI_EVENT_SAS_PLS_LR_CURRENT_MASK) >>
...@@ -5921,7 +5920,6 @@ EventDescriptionStr(u8 event, u32 evData0, char *evStr) ...@@ -5921,7 +5920,6 @@ EventDescriptionStr(u8 event, u32 evData0, char *evStr)
case MPI_EVENT_IR_RESYNC_UPDATE: case MPI_EVENT_IR_RESYNC_UPDATE:
{ {
u8 resync_complete = (u8)(evData0 >> 16); u8 resync_complete = (u8)(evData0 >> 16);
char buf[40];
sprintf(buf,"IR Resync Update: Complete = %d:",resync_complete); sprintf(buf,"IR Resync Update: Complete = %d:",resync_complete);
ds = buf; ds = buf;
break; break;
......
...@@ -91,6 +91,7 @@ enum mptsas_hotplug_action { ...@@ -91,6 +91,7 @@ enum mptsas_hotplug_action {
MPTSAS_DEL_DEVICE, MPTSAS_DEL_DEVICE,
MPTSAS_ADD_RAID, MPTSAS_ADD_RAID,
MPTSAS_DEL_RAID, MPTSAS_DEL_RAID,
MPTSAS_IGNORE_EVENT,
}; };
struct mptsas_hotplug_event { struct mptsas_hotplug_event {
...@@ -298,6 +299,26 @@ mptsas_find_portinfo_by_handle(MPT_ADAPTER *ioc, u16 handle) ...@@ -298,6 +299,26 @@ mptsas_find_portinfo_by_handle(MPT_ADAPTER *ioc, u16 handle)
return rc; return rc;
} }
/*
* Returns true if there is a scsi end device
*/
static inline int
mptsas_is_end_device(struct mptsas_devinfo * attached)
{
if ((attached->handle) &&
(attached->device_info &
MPI_SAS_DEVICE_INFO_END_DEVICE) &&
((attached->device_info &
MPI_SAS_DEVICE_INFO_SSP_TARGET) |
(attached->device_info &
MPI_SAS_DEVICE_INFO_STP_TARGET) |
(attached->device_info &
MPI_SAS_DEVICE_INFO_SATA_DEVICE)))
return 1;
else
return 0;
}
static int static int
mptsas_sas_enclosure_pg0(MPT_ADAPTER *ioc, struct mptsas_enclosure *enclosure, mptsas_sas_enclosure_pg0(MPT_ADAPTER *ioc, struct mptsas_enclosure *enclosure,
u32 form, u32 form_specific) u32 form, u32 form_specific)
...@@ -872,7 +893,11 @@ mptsas_sas_device_pg0(MPT_ADAPTER *ioc, struct mptsas_devinfo *device_info, ...@@ -872,7 +893,11 @@ mptsas_sas_device_pg0(MPT_ADAPTER *ioc, struct mptsas_devinfo *device_info,
SasDevicePage0_t *buffer; SasDevicePage0_t *buffer;
dma_addr_t dma_handle; dma_addr_t dma_handle;
__le64 sas_address; __le64 sas_address;
int error; int error=0;
if (ioc->sas_discovery_runtime &&
mptsas_is_end_device(device_info))
goto out;
hdr.PageVersion = MPI_SASDEVICE0_PAGEVERSION; hdr.PageVersion = MPI_SASDEVICE0_PAGEVERSION;
hdr.ExtPageLength = 0; hdr.ExtPageLength = 0;
...@@ -1009,7 +1034,11 @@ mptsas_sas_expander_pg1(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, ...@@ -1009,7 +1034,11 @@ mptsas_sas_expander_pg1(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info,
CONFIGPARMS cfg; CONFIGPARMS cfg;
SasExpanderPage1_t *buffer; SasExpanderPage1_t *buffer;
dma_addr_t dma_handle; dma_addr_t dma_handle;
int error; int error=0;
if (ioc->sas_discovery_runtime &&
mptsas_is_end_device(&phy_info->attached))
goto out;
hdr.PageVersion = MPI_SASEXPANDER0_PAGEVERSION; hdr.PageVersion = MPI_SASEXPANDER0_PAGEVERSION;
hdr.ExtPageLength = 0; hdr.ExtPageLength = 0;
...@@ -1068,26 +1097,6 @@ mptsas_sas_expander_pg1(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, ...@@ -1068,26 +1097,6 @@ mptsas_sas_expander_pg1(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info,
return error; return error;
} }
/*
* Returns true if there is a scsi end device
*/
static inline int
mptsas_is_end_device(struct mptsas_devinfo * attached)
{
if ((attached->handle) &&
(attached->device_info &
MPI_SAS_DEVICE_INFO_END_DEVICE) &&
((attached->device_info &
MPI_SAS_DEVICE_INFO_SSP_TARGET) |
(attached->device_info &
MPI_SAS_DEVICE_INFO_STP_TARGET) |
(attached->device_info &
MPI_SAS_DEVICE_INFO_SATA_DEVICE)))
return 1;
else
return 0;
}
static void static void
mptsas_parse_device_info(struct sas_identify *identify, mptsas_parse_device_info(struct sas_identify *identify,
struct mptsas_devinfo *device_info) struct mptsas_devinfo *device_info)
...@@ -1737,6 +1746,9 @@ mptsas_hotplug_work(void *arg) ...@@ -1737,6 +1746,9 @@ mptsas_hotplug_work(void *arg)
break; break;
case MPTSAS_ADD_DEVICE: case MPTSAS_ADD_DEVICE:
if (ev->phys_disk_num_valid)
mpt_findImVolumes(ioc);
/* /*
* Refresh sas device pg0 data * Refresh sas device pg0 data
*/ */
...@@ -1868,6 +1880,9 @@ mptsas_hotplug_work(void *arg) ...@@ -1868,6 +1880,9 @@ mptsas_hotplug_work(void *arg)
scsi_device_put(sdev); scsi_device_put(sdev);
mpt_findImVolumes(ioc); mpt_findImVolumes(ioc);
break; break;
case MPTSAS_IGNORE_EVENT:
default:
break;
} }
kfree(ev); kfree(ev);
...@@ -1940,7 +1955,8 @@ mptscsih_send_raid_event(MPT_ADAPTER *ioc, ...@@ -1940,7 +1955,8 @@ mptscsih_send_raid_event(MPT_ADAPTER *ioc,
EVENT_DATA_RAID *raid_event_data) EVENT_DATA_RAID *raid_event_data)
{ {
struct mptsas_hotplug_event *ev; struct mptsas_hotplug_event *ev;
RAID_VOL0_STATUS * volumeStatus; int status = le32_to_cpu(raid_event_data->SettingsStatus);
int state = (status >> 8) & 0xff;
if (ioc->bus_type != SAS) if (ioc->bus_type != SAS)
return; return;
...@@ -1955,6 +1971,7 @@ mptscsih_send_raid_event(MPT_ADAPTER *ioc, ...@@ -1955,6 +1971,7 @@ mptscsih_send_raid_event(MPT_ADAPTER *ioc,
INIT_WORK(&ev->work, mptsas_hotplug_work, ev); INIT_WORK(&ev->work, mptsas_hotplug_work, ev);
ev->ioc = ioc; ev->ioc = ioc;
ev->id = raid_event_data->VolumeID; ev->id = raid_event_data->VolumeID;
ev->event_type = MPTSAS_IGNORE_EVENT;
switch (raid_event_data->ReasonCode) { switch (raid_event_data->ReasonCode) {
case MPI_EVENT_RAID_RC_PHYSDISK_DELETED: case MPI_EVENT_RAID_RC_PHYSDISK_DELETED:
...@@ -1966,6 +1983,25 @@ mptscsih_send_raid_event(MPT_ADAPTER *ioc, ...@@ -1966,6 +1983,25 @@ mptscsih_send_raid_event(MPT_ADAPTER *ioc,
ev->phys_disk_num = raid_event_data->PhysDiskNum; ev->phys_disk_num = raid_event_data->PhysDiskNum;
ev->event_type = MPTSAS_DEL_DEVICE; ev->event_type = MPTSAS_DEL_DEVICE;
break; break;
case MPI_EVENT_RAID_RC_PHYSDISK_STATUS_CHANGED:
switch (state) {
case MPI_PD_STATE_ONLINE:
ioc->raid_data.isRaid = 1;
ev->phys_disk_num_valid = 1;
ev->phys_disk_num = raid_event_data->PhysDiskNum;
ev->event_type = MPTSAS_ADD_DEVICE;
break;
case MPI_PD_STATE_MISSING:
case MPI_PD_STATE_NOT_COMPATIBLE:
case MPI_PD_STATE_OFFLINE_AT_HOST_REQUEST:
case MPI_PD_STATE_FAILED_AT_HOST_REQUEST:
case MPI_PD_STATE_OFFLINE_FOR_ANOTHER_REASON:
ev->event_type = MPTSAS_DEL_DEVICE;
break;
default:
break;
}
break;
case MPI_EVENT_RAID_RC_VOLUME_DELETED: case MPI_EVENT_RAID_RC_VOLUME_DELETED:
ev->event_type = MPTSAS_DEL_RAID; ev->event_type = MPTSAS_DEL_RAID;
break; break;
...@@ -1973,11 +2009,18 @@ mptscsih_send_raid_event(MPT_ADAPTER *ioc, ...@@ -1973,11 +2009,18 @@ mptscsih_send_raid_event(MPT_ADAPTER *ioc,
ev->event_type = MPTSAS_ADD_RAID; ev->event_type = MPTSAS_ADD_RAID;
break; break;
case MPI_EVENT_RAID_RC_VOLUME_STATUS_CHANGED: case MPI_EVENT_RAID_RC_VOLUME_STATUS_CHANGED:
volumeStatus = (RAID_VOL0_STATUS *) & switch (state) {
raid_event_data->SettingsStatus; case MPI_RAIDVOL0_STATUS_STATE_FAILED:
ev->event_type = (volumeStatus->State == case MPI_RAIDVOL0_STATUS_STATE_MISSING:
MPI_RAIDVOL0_STATUS_STATE_FAILED) ? ev->event_type = MPTSAS_DEL_RAID;
MPTSAS_DEL_RAID : MPTSAS_ADD_RAID; break;
case MPI_RAIDVOL0_STATUS_STATE_OPTIMAL:
case MPI_RAIDVOL0_STATUS_STATE_DEGRADED:
ev->event_type = MPTSAS_ADD_RAID;
break;
default:
break;
}
break; break;
default: default:
break; break;
......
...@@ -877,7 +877,7 @@ mptscsih_search_running_cmds(MPT_SCSI_HOST *hd, VirtDevice *vdevice) ...@@ -877,7 +877,7 @@ mptscsih_search_running_cmds(MPT_SCSI_HOST *hd, VirtDevice *vdevice)
struct scsi_cmnd *sc; struct scsi_cmnd *sc;
dsprintk((KERN_INFO MYNAM ": search_running target %d lun %d max %d\n", dsprintk((KERN_INFO MYNAM ": search_running target %d lun %d max %d\n",
vdevice->target_id, vdevice->lun, max)); vdevice->vtarget->target_id, vdevice->lun, max));
for (ii=0; ii < max; ii++) { for (ii=0; ii < max; ii++) {
if ((sc = hd->ScsiLookup[ii]) != NULL) { if ((sc = hd->ScsiLookup[ii]) != NULL) {
......
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