Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec
[firefly-linux-kernel-4.4.55.git] / drivers / scsi / ipr.c
index 238efab90bf29a207f199bbc888c11d56eeecc9c..536cd5a8042245f4ad46929a256098e047d745dd 100644 (file)
@@ -6363,15 +6363,19 @@ static int ipr_queuecommand(struct Scsi_Host *shost,
        ipr_cmd->scsi_cmd = scsi_cmd;
        ipr_cmd->done = ipr_scsi_eh_done;
 
-       if (ipr_is_gscsi(res) || ipr_is_vset_device(res)) {
+       if (ipr_is_gscsi(res)) {
                if (scsi_cmd->underflow == 0)
                        ioarcb->cmd_pkt.flags_hi |= IPR_FLAGS_HI_NO_ULEN_CHK;
 
-               ioarcb->cmd_pkt.flags_hi |= IPR_FLAGS_HI_NO_LINK_DESC;
-               if (ipr_is_gscsi(res) && res->reset_occurred) {
+               if (res->reset_occurred) {
                        res->reset_occurred = 0;
                        ioarcb->cmd_pkt.flags_lo |= IPR_FLAGS_LO_DELAY_AFTER_RST;
                }
+       }
+
+       if (ipr_is_gscsi(res) || ipr_is_vset_device(res)) {
+               ioarcb->cmd_pkt.flags_hi |= IPR_FLAGS_HI_NO_LINK_DESC;
+
                ioarcb->cmd_pkt.flags_lo |= IPR_FLAGS_LO_ALIGNED_BFR;
                if (scsi_cmd->flags & SCMD_TAGGED)
                        ioarcb->cmd_pkt.flags_lo |= IPR_FLAGS_LO_SIMPLE_TASK;
@@ -6502,7 +6506,6 @@ static struct scsi_host_template driver_template = {
        .shost_attrs = ipr_ioa_attrs,
        .sdev_attrs = ipr_dev_attrs,
        .proc_name = IPR_NAME,
-       .use_blk_tags = 1,
 };
 
 /**
@@ -7671,6 +7674,63 @@ static int ipr_ioafp_query_ioa_cfg(struct ipr_cmnd *ipr_cmd)
        return IPR_RC_JOB_RETURN;
 }
 
+static int ipr_ioa_service_action_failed(struct ipr_cmnd *ipr_cmd)
+{
+       u32 ioasc = be32_to_cpu(ipr_cmd->s.ioasa.hdr.ioasc);
+
+       if (ioasc == IPR_IOASC_IR_INVALID_REQ_TYPE_OR_PKT)
+               return IPR_RC_JOB_CONTINUE;
+
+       return ipr_reset_cmd_failed(ipr_cmd);
+}
+
+static void ipr_build_ioa_service_action(struct ipr_cmnd *ipr_cmd,
+                                        __be32 res_handle, u8 sa_code)
+{
+       struct ipr_ioarcb *ioarcb = &ipr_cmd->ioarcb;
+
+       ioarcb->res_handle = res_handle;
+       ioarcb->cmd_pkt.cdb[0] = IPR_IOA_SERVICE_ACTION;
+       ioarcb->cmd_pkt.cdb[1] = sa_code;
+       ioarcb->cmd_pkt.request_type = IPR_RQTYPE_IOACMD;
+}
+
+/**
+ * ipr_ioafp_set_caching_parameters - Issue Set Cache parameters service
+ * action
+ *
+ * Return value:
+ *     none
+ **/
+static int ipr_ioafp_set_caching_parameters(struct ipr_cmnd *ipr_cmd)
+{
+       struct ipr_ioarcb *ioarcb = &ipr_cmd->ioarcb;
+       struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg;
+       struct ipr_inquiry_pageC4 *pageC4 = &ioa_cfg->vpd_cbs->pageC4_data;
+
+       ENTER;
+
+       ipr_cmd->job_step = ipr_ioafp_query_ioa_cfg;
+
+       if (pageC4->cache_cap[0] & IPR_CAP_SYNC_CACHE) {
+               ipr_build_ioa_service_action(ipr_cmd,
+                                            cpu_to_be32(IPR_IOA_RES_HANDLE),
+                                            IPR_IOA_SA_CHANGE_CACHE_PARAMS);
+
+               ioarcb->cmd_pkt.cdb[2] = 0x40;
+
+               ipr_cmd->job_step_failed = ipr_ioa_service_action_failed;
+               ipr_do_req(ipr_cmd, ipr_reset_ioa_job, ipr_timeout,
+                          IPR_SET_SUP_DEVICE_TIMEOUT);
+
+               LEAVE;
+               return IPR_RC_JOB_RETURN;
+       }
+
+       LEAVE;
+       return IPR_RC_JOB_CONTINUE;
+}
+
 /**
  * ipr_ioafp_inquiry - Send an Inquiry to the adapter.
  * @ipr_cmd:   ipr command struct
@@ -7721,6 +7781,39 @@ static int ipr_inquiry_page_supported(struct ipr_inquiry_page0 *page0, u8 page)
        return 0;
 }
 
+/**
+ * ipr_ioafp_pageC4_inquiry - Send a Page 0xC4 Inquiry to the adapter.
+ * @ipr_cmd:   ipr command struct
+ *
+ * This function sends a Page 0xC4 inquiry to the adapter
+ * to retrieve software VPD information.
+ *
+ * Return value:
+ *     IPR_RC_JOB_CONTINUE / IPR_RC_JOB_RETURN
+ **/
+static int ipr_ioafp_pageC4_inquiry(struct ipr_cmnd *ipr_cmd)
+{
+       struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg;
+       struct ipr_inquiry_page0 *page0 = &ioa_cfg->vpd_cbs->page0_data;
+       struct ipr_inquiry_pageC4 *pageC4 = &ioa_cfg->vpd_cbs->pageC4_data;
+
+       ENTER;
+       ipr_cmd->job_step = ipr_ioafp_set_caching_parameters;
+       memset(pageC4, 0, sizeof(*pageC4));
+
+       if (ipr_inquiry_page_supported(page0, 0xC4)) {
+               ipr_ioafp_inquiry(ipr_cmd, 1, 0xC4,
+                                 (ioa_cfg->vpd_cbs_dma
+                                  + offsetof(struct ipr_misc_cbs,
+                                             pageC4_data)),
+                                 sizeof(struct ipr_inquiry_pageC4));
+               return IPR_RC_JOB_RETURN;
+       }
+
+       LEAVE;
+       return IPR_RC_JOB_CONTINUE;
+}
+
 /**
  * ipr_ioafp_cap_inquiry - Send a Page 0xD0 Inquiry to the adapter.
  * @ipr_cmd:   ipr command struct
@@ -7738,7 +7831,7 @@ static int ipr_ioafp_cap_inquiry(struct ipr_cmnd *ipr_cmd)
        struct ipr_inquiry_cap *cap = &ioa_cfg->vpd_cbs->cap;
 
        ENTER;
-       ipr_cmd->job_step = ipr_ioafp_query_ioa_cfg;
+       ipr_cmd->job_step = ipr_ioafp_pageC4_inquiry;
        memset(cap, 0, sizeof(*cap));
 
        if (ipr_inquiry_page_supported(page0, 0xD0)) {