aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Jiang <dave.jiang@intel.com>2011-05-24 22:21:57 -0400
committerDan Williams <dan.j.williams@intel.com>2011-07-03 07:04:50 -0400
commit77d67385f7b4a630912fd567f104946be137f477 (patch)
treec180e5fd1721aca43d0296a61d36562420d30ac4
parent8db02da52895285e99d7eb2fa825fd393e61d9c5 (diff)
isci: removing the kmalloc in smp request construct
It doesn't look like there is any reason to do a kmalloc. We can do the byte swap in place and avoid the allocation. This allow us to remove a kmalloc and a memcpy. Signed-off-by: Dave Jiang <dave.jiang@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
-rw-r--r--drivers/scsi/isci/request.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/drivers/scsi/isci/request.c b/drivers/scsi/isci/request.c
index 063ef04080d5..7c0928ed9e63 100644
--- a/drivers/scsi/isci/request.c
+++ b/drivers/scsi/isci/request.c
@@ -3187,7 +3187,7 @@ static enum sci_status isci_request_stp_request_construct(
3187 */ 3187 */
3188static void 3188static void
3189scu_smp_request_construct_task_context(struct scic_sds_request *sci_req, 3189scu_smp_request_construct_task_context(struct scic_sds_request *sci_req,
3190 struct smp_req *smp_req) 3190 ssize_t req_len)
3191{ 3191{
3192 dma_addr_t dma_addr; 3192 dma_addr_t dma_addr;
3193 struct scic_sds_controller *scic; 3193 struct scic_sds_controller *scic;
@@ -3197,7 +3197,7 @@ scu_smp_request_construct_task_context(struct scic_sds_request *sci_req,
3197 ssize_t word_cnt = sizeof(struct smp_req) / sizeof(u32); 3197 ssize_t word_cnt = sizeof(struct smp_req) / sizeof(u32);
3198 3198
3199 /* byte swap the smp request. */ 3199 /* byte swap the smp request. */
3200 sci_swab32_cpy(&sci_req->smp.cmd, smp_req, 3200 sci_swab32_cpy(&sci_req->smp.cmd, &sci_req->smp.cmd,
3201 word_cnt); 3201 word_cnt);
3202 3202
3203 task_context = scic_sds_request_get_task_context(sci_req); 3203 task_context = scic_sds_request_get_task_context(sci_req);
@@ -3238,7 +3238,7 @@ scu_smp_request_construct_task_context(struct scic_sds_request *sci_req,
3238 task_context->address_modifier = 0; 3238 task_context->address_modifier = 0;
3239 3239
3240 /* 10h */ 3240 /* 10h */
3241 task_context->ssp_command_iu_length = smp_req->req_len; 3241 task_context->ssp_command_iu_length = req_len;
3242 3242
3243 /* 14h */ 3243 /* 14h */
3244 task_context->transfer_length_bytes = 0; 3244 task_context->transfer_length_bytes = 0;
@@ -3299,22 +3299,18 @@ scu_smp_request_construct_task_context(struct scic_sds_request *sci_req,
3299 task_context->response_iu_lower = 0; 3299 task_context->response_iu_lower = 0;
3300} 3300}
3301 3301
3302static enum sci_status scic_io_request_construct_smp(struct scic_sds_request *sci_req) 3302static enum sci_status
3303scic_io_request_construct_smp(struct scic_sds_request *sci_req)
3303{ 3304{
3304 struct smp_req *smp_req = kmalloc(sizeof(*smp_req), GFP_KERNEL); 3305 struct smp_req *smp_req = &sci_req->smp.cmd;
3305
3306 if (!smp_req)
3307 return SCI_FAILURE_INSUFFICIENT_RESOURCES;
3308 3306
3309 sci_req->protocol = SCIC_SMP_PROTOCOL; 3307 sci_req->protocol = SCIC_SMP_PROTOCOL;
3310 3308
3311 /* Construct the SMP SCU Task Context */
3312 memcpy(smp_req, &sci_req->smp.cmd, sizeof(*smp_req));
3313
3314 /* 3309 /*
3315 * Look at the SMP requests' header fields; for certain SAS 1.x SMP 3310 * Look at the SMP requests' header fields; for certain SAS 1.x SMP
3316 * functions under SAS 2.0, a zero request length really indicates 3311 * functions under SAS 2.0, a zero request length really indicates
3317 * a non-zero default length. */ 3312 * a non-zero default length.
3313 */
3318 if (smp_req->req_len == 0) { 3314 if (smp_req->req_len == 0) {
3319 switch (smp_req->func) { 3315 switch (smp_req->func) {
3320 case SMP_DISCOVER: 3316 case SMP_DISCOVER:
@@ -3332,12 +3328,10 @@ static enum sci_status scic_io_request_construct_smp(struct scic_sds_request *sc
3332 } 3328 }
3333 } 3329 }
3334 3330
3335 scu_smp_request_construct_task_context(sci_req, smp_req); 3331 scu_smp_request_construct_task_context(sci_req, smp_req->req_len);
3336 3332
3337 sci_base_state_machine_change_state(&sci_req->state_machine, 3333 sci_base_state_machine_change_state(&sci_req->state_machine,
3338 SCI_BASE_REQUEST_STATE_CONSTRUCTED); 3334 SCI_BASE_REQUEST_STATE_CONSTRUCTED);
3339
3340 kfree(smp_req);
3341 3335
3342 return SCI_SUCCESS; 3336 return SCI_SUCCESS;
3343} 3337}