]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/scsi/ipr.c
[SCSI] lpfc 8.1.2: Allow turning on internal loop-back mode
[linux-2.6-omap-h63xx.git] / drivers / scsi / ipr.c
index 97f33ddc7bdda8cd72ea8046d983aec23a0b18db..5890e5f92d820c6fcf6c18e983636933bc45d313 100644 (file)
@@ -93,11 +93,12 @@ static unsigned int ipr_fastfail = 0;
 static unsigned int ipr_transop_timeout = IPR_OPERATIONAL_TIMEOUT;
 static unsigned int ipr_enable_cache = 1;
 static unsigned int ipr_debug = 0;
+static int ipr_auto_create = 1;
 static DEFINE_SPINLOCK(ipr_driver_lock);
 
 /* This table describes the differences between DMA controller chips */
 static const struct ipr_chip_cfg_t ipr_chip_cfg[] = {
-       { /* Gemstone and Citrine */
+       { /* Gemstone, Citrine, and Obsidian */
                .mailbox = 0x0042C,
                .cache_line_size = 0x20,
                {
@@ -132,6 +133,8 @@ static const struct ipr_chip_cfg_t ipr_chip_cfg[] = {
 static const struct ipr_chip_t ipr_chip[] = {
        { PCI_VENDOR_ID_MYLEX, PCI_DEVICE_ID_IBM_GEMSTONE, &ipr_chip_cfg[0] },
        { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CITRINE, &ipr_chip_cfg[0] },
+       { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_OBSIDIAN, &ipr_chip_cfg[0] },
+       { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN, &ipr_chip_cfg[0] },
        { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_SNIPE, &ipr_chip_cfg[1] },
        { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_SCAMP, &ipr_chip_cfg[1] }
 };
@@ -156,6 +159,8 @@ module_param_named(enable_cache, ipr_enable_cache, int, 0);
 MODULE_PARM_DESC(enable_cache, "Enable adapter's non-volatile write cache (default: 1)");
 module_param_named(debug, ipr_debug, int, 0);
 MODULE_PARM_DESC(debug, "Enable device driver debugging logging. Set to 1 to enable. (default: 0)");
+module_param_named(auto_create, ipr_auto_create, int, 0);
+MODULE_PARM_DESC(auto_create, "Auto-create single device RAID 0 arrays when initialized (default: 1)");
 MODULE_LICENSE("GPL");
 MODULE_VERSION(IPR_DRIVER_VERSION);
 
@@ -811,7 +816,7 @@ static void ipr_send_hcam(struct ipr_ioa_cfg *ioa_cfg, u8 type,
  **/
 static void ipr_init_res_entry(struct ipr_resource_entry *res)
 {
-       res->needs_sync_complete = 1;
+       res->needs_sync_complete = 0;
        res->in_erp = 0;
        res->add_to_ml = 0;
        res->del_from_ml = 0;
@@ -932,6 +937,52 @@ static void ipr_log_vpd(struct ipr_vpd *vpd)
        ipr_err("    Serial Number: %s\n", buffer);
 }
 
+/**
+ * ipr_log_ext_vpd - Log the passed extended VPD to the error log.
+ * @vpd:               vendor/product id/sn/wwn struct
+ *
+ * Return value:
+ *     none
+ **/
+static void ipr_log_ext_vpd(struct ipr_ext_vpd *vpd)
+{
+       ipr_log_vpd(&vpd->vpd);
+       ipr_err("    WWN: %08X%08X\n", be32_to_cpu(vpd->wwid[0]),
+               be32_to_cpu(vpd->wwid[1]));
+}
+
+/**
+ * ipr_log_enhanced_cache_error - Log a cache error.
+ * @ioa_cfg:   ioa config struct
+ * @hostrcb:   hostrcb struct
+ *
+ * Return value:
+ *     none
+ **/
+static void ipr_log_enhanced_cache_error(struct ipr_ioa_cfg *ioa_cfg,
+                                        struct ipr_hostrcb *hostrcb)
+{
+       struct ipr_hostrcb_type_12_error *error =
+               &hostrcb->hcam.u.error.u.type_12_error;
+
+       ipr_err("-----Current Configuration-----\n");
+       ipr_err("Cache Directory Card Information:\n");
+       ipr_log_ext_vpd(&error->ioa_vpd);
+       ipr_err("Adapter Card Information:\n");
+       ipr_log_ext_vpd(&error->cfc_vpd);
+
+       ipr_err("-----Expected Configuration-----\n");
+       ipr_err("Cache Directory Card Information:\n");
+       ipr_log_ext_vpd(&error->ioa_last_attached_to_cfc_vpd);
+       ipr_err("Adapter Card Information:\n");
+       ipr_log_ext_vpd(&error->cfc_last_attached_to_ioa_vpd);
+
+       ipr_err("Additional IOA Data: %08X %08X %08X\n",
+                    be32_to_cpu(error->ioa_data[0]),
+                    be32_to_cpu(error->ioa_data[1]),
+                    be32_to_cpu(error->ioa_data[2]));
+}
+
 /**
  * ipr_log_cache_error - Log a cache error.
  * @ioa_cfg:   ioa config struct
@@ -964,6 +1015,46 @@ static void ipr_log_cache_error(struct ipr_ioa_cfg *ioa_cfg,
                     be32_to_cpu(error->ioa_data[2]));
 }
 
+/**
+ * ipr_log_enhanced_config_error - Log a configuration error.
+ * @ioa_cfg:   ioa config struct
+ * @hostrcb:   hostrcb struct
+ *
+ * Return value:
+ *     none
+ **/
+static void ipr_log_enhanced_config_error(struct ipr_ioa_cfg *ioa_cfg,
+                                         struct ipr_hostrcb *hostrcb)
+{
+       int errors_logged, i;
+       struct ipr_hostrcb_device_data_entry_enhanced *dev_entry;
+       struct ipr_hostrcb_type_13_error *error;
+
+       error = &hostrcb->hcam.u.error.u.type_13_error;
+       errors_logged = be32_to_cpu(error->errors_logged);
+
+       ipr_err("Device Errors Detected/Logged: %d/%d\n",
+               be32_to_cpu(error->errors_detected), errors_logged);
+
+       dev_entry = error->dev;
+
+       for (i = 0; i < errors_logged; i++, dev_entry++) {
+               ipr_err_separator;
+
+               ipr_phys_res_err(ioa_cfg, dev_entry->dev_res_addr, "Device %d", i + 1);
+               ipr_log_ext_vpd(&dev_entry->vpd);
+
+               ipr_err("-----New Device Information-----\n");
+               ipr_log_ext_vpd(&dev_entry->new_vpd);
+
+               ipr_err("Cache Directory Card Information:\n");
+               ipr_log_ext_vpd(&dev_entry->ioa_last_with_dev_vpd);
+
+               ipr_err("Adapter Card Information:\n");
+               ipr_log_ext_vpd(&dev_entry->cfc_last_with_dev_vpd);
+       }
+}
+
 /**
  * ipr_log_config_error - Log a configuration error.
  * @ioa_cfg:   ioa config struct
@@ -1011,6 +1102,57 @@ static void ipr_log_config_error(struct ipr_ioa_cfg *ioa_cfg,
        }
 }
 
+/**
+ * ipr_log_enhanced_array_error - Log an array configuration error.
+ * @ioa_cfg:   ioa config struct
+ * @hostrcb:   hostrcb struct
+ *
+ * Return value:
+ *     none
+ **/
+static void ipr_log_enhanced_array_error(struct ipr_ioa_cfg *ioa_cfg,
+                                        struct ipr_hostrcb *hostrcb)
+{
+       int i, num_entries;
+       struct ipr_hostrcb_type_14_error *error;
+       struct ipr_hostrcb_array_data_entry_enhanced *array_entry;
+       const u8 zero_sn[IPR_SERIAL_NUM_LEN] = { [0 ... IPR_SERIAL_NUM_LEN-1] = '0' };
+
+       error = &hostrcb->hcam.u.error.u.type_14_error;
+
+       ipr_err_separator;
+
+       ipr_err("RAID %s Array Configuration: %d:%d:%d:%d\n",
+               error->protection_level,
+               ioa_cfg->host->host_no,
+               error->last_func_vset_res_addr.bus,
+               error->last_func_vset_res_addr.target,
+               error->last_func_vset_res_addr.lun);
+
+       ipr_err_separator;
+
+       array_entry = error->array_member;
+       num_entries = min_t(u32, be32_to_cpu(error->num_entries),
+                           sizeof(error->array_member));
+
+       for (i = 0; i < num_entries; i++, array_entry++) {
+               if (!memcmp(array_entry->vpd.vpd.sn, zero_sn, IPR_SERIAL_NUM_LEN))
+                       continue;
+
+               if (be32_to_cpu(error->exposed_mode_adn) == i)
+                       ipr_err("Exposed Array Member %d:\n", i);
+               else
+                       ipr_err("Array Member %d:\n", i);
+
+               ipr_log_ext_vpd(&array_entry->vpd);
+               ipr_phys_res_err(ioa_cfg, array_entry->dev_res_addr, "Current Location");
+               ipr_phys_res_err(ioa_cfg, array_entry->expected_dev_res_addr,
+                                "Expected Location");
+
+               ipr_err_separator;
+       }
+}
+
 /**
  * ipr_log_array_error - Log an array configuration error.
  * @ioa_cfg:   ioa config struct
@@ -1090,6 +1232,31 @@ static void ipr_log_hex_data(u32 *data, int len)
        }
 }
 
+/**
+ * ipr_log_enhanced_dual_ioa_error - Log an enhanced dual adapter error.
+ * @ioa_cfg:   ioa config struct
+ * @hostrcb:   hostrcb struct
+ *
+ * Return value:
+ *     none
+ **/
+static void ipr_log_enhanced_dual_ioa_error(struct ipr_ioa_cfg *ioa_cfg,
+                                           struct ipr_hostrcb *hostrcb)
+{
+       struct ipr_hostrcb_type_17_error *error;
+
+       error = &hostrcb->hcam.u.error.u.type_17_error;
+       error->failure_reason[sizeof(error->failure_reason) - 1] = '\0';
+
+       ipr_err("%s\n", error->failure_reason);
+       ipr_err("Remote Adapter VPD:\n");
+       ipr_log_ext_vpd(&error->vpd);
+       ipr_log_hex_data(error->data,
+                        be32_to_cpu(hostrcb->hcam.length) -
+                        (offsetof(struct ipr_hostrcb_error, u) +
+                         offsetof(struct ipr_hostrcb_type_17_error, data)));
+}
+
 /**
  * ipr_log_dual_ioa_error - Log a dual adapter error.
  * @ioa_cfg:   ioa config struct
@@ -1218,6 +1385,19 @@ static void ipr_handle_log_data(struct ipr_ioa_cfg *ioa_cfg,
        case IPR_HOST_RCB_OVERLAY_ID_7:
                ipr_log_dual_ioa_error(ioa_cfg, hostrcb);
                break;
+       case IPR_HOST_RCB_OVERLAY_ID_12:
+               ipr_log_enhanced_cache_error(ioa_cfg, hostrcb);
+               break;
+       case IPR_HOST_RCB_OVERLAY_ID_13:
+               ipr_log_enhanced_config_error(ioa_cfg, hostrcb);
+               break;
+       case IPR_HOST_RCB_OVERLAY_ID_14:
+       case IPR_HOST_RCB_OVERLAY_ID_16:
+               ipr_log_enhanced_array_error(ioa_cfg, hostrcb);
+               break;
+       case IPR_HOST_RCB_OVERLAY_ID_17:
+               ipr_log_enhanced_dual_ioa_error(ioa_cfg, hostrcb);
+               break;
        case IPR_HOST_RCB_OVERLAY_ID_1:
        case IPR_HOST_RCB_OVERLAY_ID_DEFAULT:
        default:
@@ -1952,7 +2132,7 @@ restart:
        }
 
        spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
-       kobject_uevent(&ioa_cfg->host->shost_classdev.kobj, KOBJ_CHANGE, NULL);
+       kobject_uevent(&ioa_cfg->host->shost_classdev.kobj, KOBJ_CHANGE);
        LEAVE;
 }
 
@@ -3073,7 +3253,8 @@ static int ipr_slave_alloc(struct scsi_device *sdev)
                        res->add_to_ml = 0;
                        res->in_erp = 0;
                        sdev->hostdata = res;
-                       res->needs_sync_complete = 1;
+                       if (!ipr_is_naca_model(res))
+                               res->needs_sync_complete = 1;
                        rc = 0;
                        break;
                }
@@ -3145,7 +3326,7 @@ static int __ipr_eh_dev_reset(struct scsi_cmnd * scsi_cmd)
        ioa_cfg = (struct ipr_ioa_cfg *) scsi_cmd->device->host->hostdata;
        res = scsi_cmd->device->hostdata;
 
-       if (!res || (!ipr_is_gscsi(res) && !ipr_is_vset_device(res)))
+       if (!res)
                return FAILED;
 
        /*
@@ -3337,7 +3518,8 @@ static int ipr_cancel_op(struct scsi_cmnd * scsi_cmd)
        }
 
        list_add_tail(&ipr_cmd->queue, &ioa_cfg->free_q);
-       res->needs_sync_complete = 1;
+       if (!ipr_is_naca_model(res))
+               res->needs_sync_complete = 1;
 
        LEAVE;
        return (IPR_IOASC_SENSE_KEY(ioasc) ? FAILED : SUCCESS);
@@ -3641,7 +3823,8 @@ static void ipr_erp_done(struct ipr_cmnd *ipr_cmd)
        }
 
        if (res) {
-               res->needs_sync_complete = 1;
+               if (!ipr_is_naca_model(res))
+                       res->needs_sync_complete = 1;
                res->in_erp = 0;
        }
        ipr_unmap_sglist(ioa_cfg, ipr_cmd);
@@ -3910,6 +4093,30 @@ static void ipr_gen_sense(struct ipr_cmnd *ipr_cmd)
        }
 }
 
+/**
+ * ipr_get_autosense - Copy autosense data to sense buffer
+ * @ipr_cmd:   ipr command struct
+ *
+ * This function copies the autosense buffer to the buffer
+ * in the scsi_cmd, if there is autosense available.
+ *
+ * Return value:
+ *     1 if autosense was available / 0 if not
+ **/
+static int ipr_get_autosense(struct ipr_cmnd *ipr_cmd)
+{
+       struct ipr_ioasa *ioasa = &ipr_cmd->ioasa;
+
+       if ((be32_to_cpu(ioasa->ioasc_specific) &
+            (IPR_ADDITIONAL_STATUS_FMT | IPR_AUTOSENSE_VALID)) == 0)
+               return 0;
+
+       memcpy(ipr_cmd->scsi_cmd->sense_buffer, ioasa->auto_sense.data,
+              min_t(u16, be16_to_cpu(ioasa->auto_sense.auto_sense_len),
+                  SCSI_SENSE_BUFFERSIZE));
+       return 1;
+}
+
 /**
  * ipr_erp_start - Process an error response for a SCSI op
  * @ioa_cfg:   ioa config struct
@@ -3940,7 +4147,10 @@ static void ipr_erp_start(struct ipr_ioa_cfg *ioa_cfg,
 
        switch (ioasc & IPR_IOASC_IOASC_MASK) {
        case IPR_IOASC_ABORTED_CMD_TERM_BY_HOST:
-               scsi_cmd->result |= (DID_IMM_RETRY << 16);
+               if (ipr_is_naca_model(res))
+                       scsi_cmd->result |= (DID_ABORT << 16);
+               else
+                       scsi_cmd->result |= (DID_IMM_RETRY << 16);
                break;
        case IPR_IOASC_IR_RESOURCE_HANDLE:
        case IPR_IOASC_IR_NO_CMDS_TO_2ND_IOA:
@@ -3948,7 +4158,8 @@ static void ipr_erp_start(struct ipr_ioa_cfg *ioa_cfg,
                break;
        case IPR_IOASC_HW_SEL_TIMEOUT:
                scsi_cmd->result |= (DID_NO_CONNECT << 16);
-               res->needs_sync_complete = 1;
+               if (!ipr_is_naca_model(res))
+                       res->needs_sync_complete = 1;
                break;
        case IPR_IOASC_SYNC_REQUIRED:
                if (!res->in_erp)
@@ -3968,21 +4179,27 @@ static void ipr_erp_start(struct ipr_ioa_cfg *ioa_cfg,
                if (!res->resetting_device)
                        scsi_report_bus_reset(ioa_cfg->host, scsi_cmd->device->channel);
                scsi_cmd->result |= (DID_ERROR << 16);
-               res->needs_sync_complete = 1;
+               if (!ipr_is_naca_model(res))
+                       res->needs_sync_complete = 1;
                break;
        case IPR_IOASC_HW_DEV_BUS_STATUS:
                scsi_cmd->result |= IPR_IOASC_SENSE_STATUS(ioasc);
                if (IPR_IOASC_SENSE_STATUS(ioasc) == SAM_STAT_CHECK_CONDITION) {
-                       ipr_erp_cancel_all(ipr_cmd);
-                       return;
+                       if (!ipr_get_autosense(ipr_cmd)) {
+                               if (!ipr_is_naca_model(res)) {
+                                       ipr_erp_cancel_all(ipr_cmd);
+                                       return;
+                               }
+                       }
                }
-               res->needs_sync_complete = 1;
+               if (!ipr_is_naca_model(res))
+                       res->needs_sync_complete = 1;
                break;
        case IPR_IOASC_NR_INIT_CMD_REQUIRED:
                break;
        default:
                scsi_cmd->result |= (DID_ERROR << 16);
-               if (!ipr_is_vset_device(res))
+               if (!ipr_is_vset_device(res) && !ipr_is_naca_model(res))
                        res->needs_sync_complete = 1;
                break;
        }
@@ -4018,35 +4235,6 @@ static void ipr_scsi_done(struct ipr_cmnd *ipr_cmd)
                ipr_erp_start(ioa_cfg, ipr_cmd);
 }
 
-/**
- * ipr_save_ioafp_mode_select - Save adapters mode select data
- * @ioa_cfg:   ioa config struct
- * @scsi_cmd:  scsi command struct
- *
- * This function saves mode select data for the adapter to
- * use following an adapter reset.
- *
- * Return value:
- *     0 on success / SCSI_MLQUEUE_HOST_BUSY on failure
- **/
-static int ipr_save_ioafp_mode_select(struct ipr_ioa_cfg *ioa_cfg,
-                                      struct scsi_cmnd *scsi_cmd)
-{
-       if (!ioa_cfg->saved_mode_pages) {
-               ioa_cfg->saved_mode_pages  = kmalloc(sizeof(struct ipr_mode_pages),
-                                                    GFP_ATOMIC);
-               if (!ioa_cfg->saved_mode_pages) {
-                       dev_err(&ioa_cfg->pdev->dev,
-                               "IOA mode select buffer allocation failed\n");
-                       return SCSI_MLQUEUE_HOST_BUSY;
-               }
-       }
-
-       memcpy(ioa_cfg->saved_mode_pages, scsi_cmd->buffer, scsi_cmd->cmnd[4]);
-       ioa_cfg->saved_mode_page_len = scsi_cmd->cmnd[4];
-       return 0;
-}
-
 /**
  * ipr_queuecommand - Queue a mid-layer request
  * @scsi_cmd:  scsi command struct
@@ -4121,9 +4309,6 @@ static int ipr_queuecommand(struct scsi_cmnd *scsi_cmd,
            (!ipr_is_gscsi(res) || scsi_cmd->cmnd[0] == IPR_QUERY_RSRC_STATE))
                ioarcb->cmd_pkt.request_type = IPR_RQTYPE_IOACMD;
 
-       if (ipr_is_ioa_resource(res) && scsi_cmd->cmnd[0] == MODE_SELECT)
-               rc = ipr_save_ioafp_mode_select(ioa_cfg, scsi_cmd);
-
        if (likely(rc == 0))
                rc = ipr_build_ioadl(ioa_cfg, ipr_cmd);
 
@@ -4612,17 +4797,11 @@ static int ipr_ioafp_mode_select_page28(struct ipr_cmnd *ipr_cmd)
        int length;
 
        ENTER;
-       if (ioa_cfg->saved_mode_pages) {
-               memcpy(mode_pages, ioa_cfg->saved_mode_pages,
-                      ioa_cfg->saved_mode_page_len);
-               length = ioa_cfg->saved_mode_page_len;
-       } else {
-               ipr_scsi_bus_speed_limit(ioa_cfg);
-               ipr_check_term_power(ioa_cfg, mode_pages);
-               ipr_modify_ioafp_mode_page_28(ioa_cfg, mode_pages);
-               length = mode_pages->hdr.length + 1;
-               mode_pages->hdr.length = 0;
-       }
+       ipr_scsi_bus_speed_limit(ioa_cfg);
+       ipr_check_term_power(ioa_cfg, mode_pages);
+       ipr_modify_ioafp_mode_page_28(ioa_cfg, mode_pages);
+       length = mode_pages->hdr.length + 1;
+       mode_pages->hdr.length = 0;
 
        ipr_build_mode_select(ipr_cmd, cpu_to_be32(IPR_IOA_RES_HANDLE), 0x11,
                              ioa_cfg->vpd_cbs_dma + offsetof(struct ipr_misc_cbs, mode_pages),
@@ -4666,6 +4845,51 @@ static void ipr_build_mode_sense(struct ipr_cmnd *ipr_cmd,
        ioarcb->read_data_transfer_length = cpu_to_be32(xfer_len);
 }
 
+/**
+ * ipr_reset_cmd_failed - Handle failure of IOA reset command
+ * @ipr_cmd:   ipr command struct
+ *
+ * This function handles the failure of an IOA bringup command.
+ *
+ * Return value:
+ *     IPR_RC_JOB_RETURN
+ **/
+static int ipr_reset_cmd_failed(struct ipr_cmnd *ipr_cmd)
+{
+       struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg;
+       u32 ioasc = be32_to_cpu(ipr_cmd->ioasa.ioasc);
+
+       dev_err(&ioa_cfg->pdev->dev,
+               "0x%02X failed with IOASC: 0x%08X\n",
+               ipr_cmd->ioarcb.cmd_pkt.cdb[0], ioasc);
+
+       ipr_initiate_ioa_reset(ioa_cfg, IPR_SHUTDOWN_NONE);
+       list_add_tail(&ipr_cmd->queue, &ioa_cfg->free_q);
+       return IPR_RC_JOB_RETURN;
+}
+
+/**
+ * ipr_reset_mode_sense_failed - Handle failure of IOAFP mode sense
+ * @ipr_cmd:   ipr command struct
+ *
+ * This function handles the failure of a Mode Sense to the IOAFP.
+ * Some adapters do not handle all mode pages.
+ *
+ * Return value:
+ *     IPR_RC_JOB_CONTINUE / IPR_RC_JOB_RETURN
+ **/
+static int ipr_reset_mode_sense_failed(struct ipr_cmnd *ipr_cmd)
+{
+       u32 ioasc = be32_to_cpu(ipr_cmd->ioasa.ioasc);
+
+       if (ioasc == IPR_IOASC_IR_INVALID_REQ_TYPE_OR_PKT) {
+               ipr_cmd->job_step = ipr_setup_write_cache;
+               return IPR_RC_JOB_CONTINUE;
+       }
+
+       return ipr_reset_cmd_failed(ipr_cmd);
+}
+
 /**
  * ipr_ioafp_mode_sense_page28 - Issue Mode Sense Page 28 to IOA
  * @ipr_cmd:   ipr command struct
@@ -4687,6 +4911,7 @@ static int ipr_ioafp_mode_sense_page28(struct ipr_cmnd *ipr_cmd)
                             sizeof(struct ipr_mode_pages));
 
        ipr_cmd->job_step = ipr_ioafp_mode_select_page28;
+       ipr_cmd->job_step_failed = ipr_reset_mode_sense_failed;
 
        ipr_do_req(ipr_cmd, ipr_reset_ioa_job, ipr_timeout, IPR_INTERNAL_TIMEOUT);
 
@@ -5499,7 +5724,6 @@ static int ipr_reset_shutdown_ioa(struct ipr_cmnd *ipr_cmd)
 static void ipr_reset_ioa_job(struct ipr_cmnd *ipr_cmd)
 {
        u32 rc, ioasc;
-       unsigned long scratch = ipr_cmd->u.scratch;
        struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg;
 
        do {
@@ -5515,17 +5739,13 @@ static void ipr_reset_ioa_job(struct ipr_cmnd *ipr_cmd)
                }
 
                if (IPR_IOASC_SENSE_KEY(ioasc)) {
-                       dev_err(&ioa_cfg->pdev->dev,
-                               "0x%02X failed with IOASC: 0x%08X\n",
-                               ipr_cmd->ioarcb.cmd_pkt.cdb[0], ioasc);
-
-                       ipr_initiate_ioa_reset(ioa_cfg, IPR_SHUTDOWN_NONE);
-                       list_add_tail(&ipr_cmd->queue, &ioa_cfg->free_q);
-                       return;
+                       rc = ipr_cmd->job_step_failed(ipr_cmd);
+                       if (rc == IPR_RC_JOB_RETURN)
+                               return;
                }
 
                ipr_reinit_ipr_cmnd(ipr_cmd);
-               ipr_cmd->u.scratch = scratch;
+               ipr_cmd->job_step_failed = ipr_reset_cmd_failed;
                rc = ipr_cmd->job_step(ipr_cmd);
        } while(rc == IPR_RC_JOB_CONTINUE);
 }
@@ -5610,6 +5830,109 @@ static void ipr_initiate_ioa_reset(struct ipr_ioa_cfg *ioa_cfg,
                                shutdown_type);
 }
 
+/**
+ * ipr_reset_freeze - Hold off all I/O activity
+ * @ipr_cmd:   ipr command struct
+ *
+ * Description: If the PCI slot is frozen, hold off all I/O
+ * activity; then, as soon as the slot is available again,
+ * initiate an adapter reset.
+ */
+static int ipr_reset_freeze(struct ipr_cmnd *ipr_cmd)
+{
+       /* Disallow new interrupts, avoid loop */
+       ipr_cmd->ioa_cfg->allow_interrupts = 0;
+       list_add_tail(&ipr_cmd->queue, &ipr_cmd->ioa_cfg->pending_q);
+       ipr_cmd->done = ipr_reset_ioa_job;
+       return IPR_RC_JOB_RETURN;
+}
+
+/**
+ * ipr_pci_frozen - Called when slot has experienced a PCI bus error.
+ * @pdev:      PCI device struct
+ *
+ * Description: This routine is called to tell us that the PCI bus
+ * is down. Can't do anything here, except put the device driver
+ * into a holding pattern, waiting for the PCI bus to come back.
+ */
+static void ipr_pci_frozen(struct pci_dev *pdev)
+{
+       unsigned long flags = 0;
+       struct ipr_ioa_cfg *ioa_cfg = pci_get_drvdata(pdev);
+
+       spin_lock_irqsave(ioa_cfg->host->host_lock, flags);
+       _ipr_initiate_ioa_reset(ioa_cfg, ipr_reset_freeze, IPR_SHUTDOWN_NONE);
+       spin_unlock_irqrestore(ioa_cfg->host->host_lock, flags);
+}
+
+/**
+ * ipr_pci_slot_reset - Called when PCI slot has been reset.
+ * @pdev:      PCI device struct
+ *
+ * Description: This routine is called by the pci error recovery
+ * code after the PCI slot has been reset, just before we
+ * should resume normal operations.
+ */
+static pci_ers_result_t ipr_pci_slot_reset(struct pci_dev *pdev)
+{
+       unsigned long flags = 0;
+       struct ipr_ioa_cfg *ioa_cfg = pci_get_drvdata(pdev);
+
+       spin_lock_irqsave(ioa_cfg->host->host_lock, flags);
+       _ipr_initiate_ioa_reset(ioa_cfg, ipr_reset_restore_cfg_space,
+                                        IPR_SHUTDOWN_NONE);
+       spin_unlock_irqrestore(ioa_cfg->host->host_lock, flags);
+       return PCI_ERS_RESULT_RECOVERED;
+}
+
+/**
+ * ipr_pci_perm_failure - Called when PCI slot is dead for good.
+ * @pdev:      PCI device struct
+ *
+ * Description: This routine is called when the PCI bus has
+ * permanently failed.
+ */
+static void ipr_pci_perm_failure(struct pci_dev *pdev)
+{
+       unsigned long flags = 0;
+       struct ipr_ioa_cfg *ioa_cfg = pci_get_drvdata(pdev);
+
+       spin_lock_irqsave(ioa_cfg->host->host_lock, flags);
+       if (ioa_cfg->sdt_state == WAIT_FOR_DUMP)
+               ioa_cfg->sdt_state = ABORT_DUMP;
+       ioa_cfg->reset_retries = IPR_NUM_RESET_RELOAD_RETRIES;
+       ioa_cfg->in_ioa_bringdown = 1;
+       ipr_initiate_ioa_reset(ioa_cfg, IPR_SHUTDOWN_NONE);
+       spin_unlock_irqrestore(ioa_cfg->host->host_lock, flags);
+}
+
+/**
+ * ipr_pci_error_detected - Called when a PCI error is detected.
+ * @pdev:      PCI device struct
+ * @state:     PCI channel state
+ *
+ * Description: Called when a PCI error is detected.
+ *
+ * Return value:
+ *     PCI_ERS_RESULT_NEED_RESET or PCI_ERS_RESULT_DISCONNECT
+ */
+static pci_ers_result_t ipr_pci_error_detected(struct pci_dev *pdev,
+                                              pci_channel_state_t state)
+{
+       switch (state) {
+       case pci_channel_io_frozen:
+               ipr_pci_frozen(pdev);
+               return PCI_ERS_RESULT_NEED_RESET;
+       case pci_channel_io_perm_failure:
+               ipr_pci_perm_failure(pdev);
+               return PCI_ERS_RESULT_DISCONNECT;
+               break;
+       default:
+               break;
+       }
+       return PCI_ERS_RESULT_NEED_RESET;
+}
+
 /**
  * ipr_probe_ioa_part2 - Initializes IOAs found in ipr_probe_ioa(..)
  * @ioa_cfg:   ioa cfg struct
@@ -5629,7 +5952,12 @@ static int __devinit ipr_probe_ioa_part2(struct ipr_ioa_cfg *ioa_cfg)
        ENTER;
        spin_lock_irqsave(ioa_cfg->host->host_lock, host_lock_flags);
        dev_dbg(&ioa_cfg->pdev->dev, "ioa_cfg adx: 0x%p\n", ioa_cfg);
-       _ipr_initiate_ioa_reset(ioa_cfg, ipr_reset_enable_ioa, IPR_SHUTDOWN_NONE);
+       if (ioa_cfg->needs_hard_reset) {
+               ioa_cfg->needs_hard_reset = 0;
+               ipr_initiate_ioa_reset(ioa_cfg, IPR_SHUTDOWN_NONE);
+       } else
+               _ipr_initiate_ioa_reset(ioa_cfg, ipr_reset_enable_ioa,
+                                       IPR_SHUTDOWN_NONE);
 
        spin_unlock_irqrestore(ioa_cfg->host->host_lock, host_lock_flags);
        wait_event(ioa_cfg->reset_wait_q, !ioa_cfg->in_reset_reload);
@@ -5706,7 +6034,6 @@ static void ipr_free_mem(struct ipr_ioa_cfg *ioa_cfg)
        }
 
        ipr_free_dump(ioa_cfg);
-       kfree(ioa_cfg->saved_mode_pages);
        kfree(ioa_cfg->trace);
 }
 
@@ -5919,6 +6246,8 @@ static void __devinit ipr_init_ioa_cfg(struct ipr_ioa_cfg *ioa_cfg,
        ioa_cfg->pdev = pdev;
        ioa_cfg->log_level = ipr_log_level;
        ioa_cfg->doorbell = IPR_DOORBELL;
+       if (!ipr_auto_create)
+               ioa_cfg->doorbell |= IPR_RUNTIME_RESET;
        sprintf(ioa_cfg->eye_catcher, IPR_EYECATCHER);
        sprintf(ioa_cfg->trace_start, IPR_TRACE_START_LABEL);
        sprintf(ioa_cfg->ipr_free_label, IPR_FREEQ_LABEL);
@@ -6004,6 +6333,7 @@ static int __devinit ipr_probe_ioa(struct pci_dev *pdev,
        unsigned long ipr_regs_pci;
        void __iomem *ipr_regs;
        u32 rc = PCIBIOS_SUCCESSFUL;
+       volatile u32 mask, uproc;
 
        ENTER;
 
@@ -6096,6 +6426,15 @@ static int __devinit ipr_probe_ioa(struct pci_dev *pdev,
                goto cleanup_nomem;
        }
 
+       /*
+        * If HRRQ updated interrupt is not masked, or reset alert is set,
+        * the card is in an unknown state and needs a hard reset
+        */
+       mask = readl(ioa_cfg->regs.sense_interrupt_mask_reg);
+       uproc = readl(ioa_cfg->regs.sense_uproc_interrupt_reg);
+       if ((mask & IPR_PCII_HRRQ_UPDATED) == 0 || (uproc & IPR_UPROCI_RESET_ALERT))
+               ioa_cfg->needs_hard_reset = 1;
+
        ipr_mask_and_clear_interrupts(ioa_cfg, ~IPR_PCII_IOA_TRANS_TO_OPER);
        rc = request_irq(pdev->irq, ipr_isr, SA_SHIRQ, IPR_NAME, ioa_cfg);
 
@@ -6337,22 +6676,46 @@ static struct pci_device_id ipr_pci_table[] __devinitdata = {
        { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CITRINE,
                PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_571A,
              0, 0, (kernel_ulong_t)&ipr_chip_cfg[0] },
+       { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CITRINE,
+               PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_575B,
+               0, 0, (kernel_ulong_t)&ipr_chip_cfg[0] },
+       { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_OBSIDIAN,
+             PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_572A,
+             0, 0, (kernel_ulong_t)&ipr_chip_cfg[0] },
+       { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_OBSIDIAN,
+             PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_572B,
+             0, 0, (kernel_ulong_t)&ipr_chip_cfg[0] },
+       { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN,
+             PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_572A,
+             0, 0, (kernel_ulong_t)&ipr_chip_cfg[0] },
+       { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN,
+             PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_572B,
+             0, 0, (kernel_ulong_t)&ipr_chip_cfg[0] },
        { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_SNIPE,
                PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_2780,
                0, 0, (kernel_ulong_t)&ipr_chip_cfg[1] },
        { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_SCAMP,
                PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_571E,
                0, 0, (kernel_ulong_t)&ipr_chip_cfg[1] },
+       { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_SCAMP,
+               PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_571F,
+               0, 0, (kernel_ulong_t)&ipr_chip_cfg[1] },
        { }
 };
 MODULE_DEVICE_TABLE(pci, ipr_pci_table);
 
+static struct pci_error_handlers ipr_err_handler = {
+       .error_detected = ipr_pci_error_detected,
+       .slot_reset = ipr_pci_slot_reset,
+};
+
 static struct pci_driver ipr_driver = {
        .name = IPR_NAME,
        .id_table = ipr_pci_table,
        .probe = ipr_probe,
        .remove = ipr_remove,
        .shutdown = ipr_shutdown,
+       .err_handler = &ipr_err_handler,
 };
 
 /**