]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - drivers/scsi/libsas/sas_host_smp.c
Merge branches 'for-4.11/upstream-fixes', 'for-4.12/accutouch', 'for-4.12/cp2112...
[mirror_ubuntu-artful-kernel.git] / drivers / scsi / libsas / sas_host_smp.c
index 3814d3eed401176679fe40ab0684e80804aaf60e..45cbbc44f4d7d9d74923fbccc813294aa4c73b9e 100644 (file)
@@ -187,11 +187,14 @@ static void sas_phy_control(struct sas_ha_struct *sas_ha, u8 phy_id,
        struct sas_internal *i =
                to_sas_internal(sas_ha->core.shost->transportt);
        struct sas_phy_linkrates rates;
+       struct asd_sas_phy *asd_phy;
 
        if (phy_id >= sas_ha->num_phys) {
                resp_data[2] = SMP_RESP_NO_PHY;
                return;
        }
+
+       asd_phy = sas_ha->sas_phy[phy_id];
        switch (phy_op) {
        case PHY_FUNC_NOP:
        case PHY_FUNC_LINK_RESET:
@@ -210,7 +213,13 @@ static void sas_phy_control(struct sas_ha_struct *sas_ha, u8 phy_id,
        rates.minimum_linkrate = min;
        rates.maximum_linkrate = max;
 
-       if (i->dft->lldd_control_phy(sas_ha->sas_phy[phy_id], phy_op, &rates))
+       /* filter reset requests through libata eh */
+       if (phy_op == PHY_FUNC_LINK_RESET && sas_try_ata_reset(asd_phy) == 0) {
+               resp_data[2] = SMP_RESP_FUNC_ACC;
+               return;
+       }
+
+       if (i->dft->lldd_control_phy(asd_phy, phy_op, &rates))
                resp_data[2] = SMP_RESP_FUNC_FAILED;
        else
                resp_data[2] = SMP_RESP_FUNC_ACC;
@@ -265,15 +274,15 @@ int sas_smp_host_handler(struct Scsi_Host *shost, struct request *req,
 
        switch (req_data[1]) {
        case SMP_REPORT_GENERAL:
-               req->resid_len -= 8;
-               rsp->resid_len -= 32;
+               scsi_req(req)->resid_len -= 8;
+               scsi_req(rsp)->resid_len -= 32;
                resp_data[2] = SMP_RESP_FUNC_ACC;
                resp_data[9] = sas_ha->num_phys;
                break;
 
        case SMP_REPORT_MANUF_INFO:
-               req->resid_len -= 8;
-               rsp->resid_len -= 64;
+               scsi_req(req)->resid_len -= 8;
+               scsi_req(rsp)->resid_len -= 64;
                resp_data[2] = SMP_RESP_FUNC_ACC;
                memcpy(resp_data + 12, shost->hostt->name,
                       SAS_EXPANDER_VENDOR_ID_LEN);
@@ -286,13 +295,13 @@ int sas_smp_host_handler(struct Scsi_Host *shost, struct request *req,
                break;
 
        case SMP_DISCOVER:
-               req->resid_len -= 16;
-               if ((int)req->resid_len < 0) {
-                       req->resid_len = 0;
+               scsi_req(req)->resid_len -= 16;
+               if ((int)scsi_req(req)->resid_len < 0) {
+                       scsi_req(req)->resid_len = 0;
                        error = -EINVAL;
                        goto out;
                }
-               rsp->resid_len -= 56;
+               scsi_req(rsp)->resid_len -= 56;
                sas_host_smp_discover(sas_ha, resp_data, req_data[9]);
                break;
 
@@ -302,13 +311,13 @@ int sas_smp_host_handler(struct Scsi_Host *shost, struct request *req,
                break;
 
        case SMP_REPORT_PHY_SATA:
-               req->resid_len -= 16;
-               if ((int)req->resid_len < 0) {
-                       req->resid_len = 0;
+               scsi_req(req)->resid_len -= 16;
+               if ((int)scsi_req(req)->resid_len < 0) {
+                       scsi_req(req)->resid_len = 0;
                        error = -EINVAL;
                        goto out;
                }
-               rsp->resid_len -= 60;
+               scsi_req(rsp)->resid_len -= 60;
                sas_report_phy_sata(sas_ha, resp_data, req_data[9]);
                break;
 
@@ -322,15 +331,15 @@ int sas_smp_host_handler(struct Scsi_Host *shost, struct request *req,
                int to_write = req_data[4];
 
                if (blk_rq_bytes(req) < base_frame_size + to_write * 4 ||
-                   req->resid_len < base_frame_size + to_write * 4) {
+                   scsi_req(req)->resid_len < base_frame_size + to_write * 4) {
                        resp_data[2] = SMP_RESP_INV_FRM_LEN;
                        break;
                }
 
                to_write = sas_host_smp_write_gpio(sas_ha, resp_data, req_data[2],
                                                   req_data[3], to_write, &req_data[8]);
-               req->resid_len -= base_frame_size + to_write * 4;
-               rsp->resid_len -= 8;
+               scsi_req(req)->resid_len -= base_frame_size + to_write * 4;
+               scsi_req(rsp)->resid_len -= 8;
                break;
        }
 
@@ -339,13 +348,13 @@ int sas_smp_host_handler(struct Scsi_Host *shost, struct request *req,
                break;
 
        case SMP_PHY_CONTROL:
-               req->resid_len -= 44;
-               if ((int)req->resid_len < 0) {
-                       req->resid_len = 0;
+               scsi_req(req)->resid_len -= 44;
+               if ((int)scsi_req(req)->resid_len < 0) {
+                       scsi_req(req)->resid_len = 0;
                        error = -EINVAL;
                        goto out;
                }
-               rsp->resid_len -= 8;
+               scsi_req(rsp)->resid_len -= 8;
                sas_phy_control(sas_ha, req_data[9], req_data[10],
                                req_data[32] >> 4, req_data[33] >> 4,
                                resp_data);