|
@@ -134,7 +134,7 @@ int sas_smp_host_handler(struct Scsi_Host *shost, struct request *req,
|
|
{
|
|
{
|
|
u8 *req_data = NULL, *resp_data = NULL, *buf;
|
|
u8 *req_data = NULL, *resp_data = NULL, *buf;
|
|
struct sas_ha_struct *sas_ha = SHOST_TO_SAS_HA(shost);
|
|
struct sas_ha_struct *sas_ha = SHOST_TO_SAS_HA(shost);
|
|
- int error = -EINVAL, resp_data_len = rsp->data_len;
|
|
|
|
|
|
+ int error = -EINVAL;
|
|
|
|
|
|
/* eight is the minimum size for request and response frames */
|
|
/* eight is the minimum size for request and response frames */
|
|
if (req->data_len < 8 || rsp->data_len < 8)
|
|
if (req->data_len < 8 || rsp->data_len < 8)
|
|
@@ -176,17 +176,20 @@ int sas_smp_host_handler(struct Scsi_Host *shost, struct request *req,
|
|
resp_data[1] = req_data[1];
|
|
resp_data[1] = req_data[1];
|
|
resp_data[2] = SMP_RESP_FUNC_UNK;
|
|
resp_data[2] = SMP_RESP_FUNC_UNK;
|
|
|
|
|
|
|
|
+ req->resid_len = req->data_len;
|
|
|
|
+ rsp->resid_len = rsp->data_len;
|
|
|
|
+
|
|
switch (req_data[1]) {
|
|
switch (req_data[1]) {
|
|
case SMP_REPORT_GENERAL:
|
|
case SMP_REPORT_GENERAL:
|
|
- req->data_len -= 8;
|
|
|
|
- resp_data_len -= 32;
|
|
|
|
|
|
+ req->resid_len -= 8;
|
|
|
|
+ rsp->resid_len -= 32;
|
|
resp_data[2] = SMP_RESP_FUNC_ACC;
|
|
resp_data[2] = SMP_RESP_FUNC_ACC;
|
|
resp_data[9] = sas_ha->num_phys;
|
|
resp_data[9] = sas_ha->num_phys;
|
|
break;
|
|
break;
|
|
|
|
|
|
case SMP_REPORT_MANUF_INFO:
|
|
case SMP_REPORT_MANUF_INFO:
|
|
- req->data_len -= 8;
|
|
|
|
- resp_data_len -= 64;
|
|
|
|
|
|
+ req->resid_len -= 8;
|
|
|
|
+ rsp->resid_len -= 64;
|
|
resp_data[2] = SMP_RESP_FUNC_ACC;
|
|
resp_data[2] = SMP_RESP_FUNC_ACC;
|
|
memcpy(resp_data + 12, shost->hostt->name,
|
|
memcpy(resp_data + 12, shost->hostt->name,
|
|
SAS_EXPANDER_VENDOR_ID_LEN);
|
|
SAS_EXPANDER_VENDOR_ID_LEN);
|
|
@@ -199,13 +202,13 @@ int sas_smp_host_handler(struct Scsi_Host *shost, struct request *req,
|
|
break;
|
|
break;
|
|
|
|
|
|
case SMP_DISCOVER:
|
|
case SMP_DISCOVER:
|
|
- req->data_len -= 16;
|
|
|
|
- if ((int)req->data_len < 0) {
|
|
|
|
- req->data_len = 0;
|
|
|
|
|
|
+ req->resid_len -= 16;
|
|
|
|
+ if ((int)req->resid_len < 0) {
|
|
|
|
+ req->resid_len = 0;
|
|
error = -EINVAL;
|
|
error = -EINVAL;
|
|
goto out;
|
|
goto out;
|
|
}
|
|
}
|
|
- resp_data_len -= 56;
|
|
|
|
|
|
+ rsp->resid_len -= 56;
|
|
sas_host_smp_discover(sas_ha, resp_data, req_data[9]);
|
|
sas_host_smp_discover(sas_ha, resp_data, req_data[9]);
|
|
break;
|
|
break;
|
|
|
|
|
|
@@ -215,13 +218,13 @@ int sas_smp_host_handler(struct Scsi_Host *shost, struct request *req,
|
|
break;
|
|
break;
|
|
|
|
|
|
case SMP_REPORT_PHY_SATA:
|
|
case SMP_REPORT_PHY_SATA:
|
|
- req->data_len -= 16;
|
|
|
|
- if ((int)req->data_len < 0) {
|
|
|
|
- req->data_len = 0;
|
|
|
|
|
|
+ req->resid_len -= 16;
|
|
|
|
+ if ((int)req->resid_len < 0) {
|
|
|
|
+ req->resid_len = 0;
|
|
error = -EINVAL;
|
|
error = -EINVAL;
|
|
goto out;
|
|
goto out;
|
|
}
|
|
}
|
|
- resp_data_len -= 60;
|
|
|
|
|
|
+ rsp->resid_len -= 60;
|
|
sas_report_phy_sata(sas_ha, resp_data, req_data[9]);
|
|
sas_report_phy_sata(sas_ha, resp_data, req_data[9]);
|
|
break;
|
|
break;
|
|
|
|
|
|
@@ -238,13 +241,13 @@ int sas_smp_host_handler(struct Scsi_Host *shost, struct request *req,
|
|
break;
|
|
break;
|
|
|
|
|
|
case SMP_PHY_CONTROL:
|
|
case SMP_PHY_CONTROL:
|
|
- req->data_len -= 44;
|
|
|
|
- if ((int)req->data_len < 0) {
|
|
|
|
- req->data_len = 0;
|
|
|
|
|
|
+ req->resid_len -= 44;
|
|
|
|
+ if ((int)req->resid_len < 0) {
|
|
|
|
+ req->resid_len = 0;
|
|
error = -EINVAL;
|
|
error = -EINVAL;
|
|
goto out;
|
|
goto out;
|
|
}
|
|
}
|
|
- resp_data_len -= 8;
|
|
|
|
|
|
+ rsp->resid_len -= 8;
|
|
sas_phy_control(sas_ha, req_data[9], req_data[10],
|
|
sas_phy_control(sas_ha, req_data[9], req_data[10],
|
|
req_data[32] >> 4, req_data[33] >> 4,
|
|
req_data[32] >> 4, req_data[33] >> 4,
|
|
resp_data);
|
|
resp_data);
|
|
@@ -265,7 +268,6 @@ int sas_smp_host_handler(struct Scsi_Host *shost, struct request *req,
|
|
flush_kernel_dcache_page(bio_page(rsp->bio));
|
|
flush_kernel_dcache_page(bio_page(rsp->bio));
|
|
kunmap_atomic(buf - bio_offset(rsp->bio), KM_USER0);
|
|
kunmap_atomic(buf - bio_offset(rsp->bio), KM_USER0);
|
|
local_irq_enable();
|
|
local_irq_enable();
|
|
- rsp->data_len = resp_data_len;
|
|
|
|
|
|
|
|
out:
|
|
out:
|
|
kfree(req_data);
|
|
kfree(req_data);
|