aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/storage
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2014-09-13 06:26:49 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-09-24 00:42:12 -0400
commit1ad7ed5af3d85d0d8b3cdc5a4b823272b85c46cf (patch)
tree7dbd23d73ce526fd2dcfe4478bbb830a3079c3c3 /drivers/usb/storage
parent102c00cb91f36f6f7afa6658b2436b04fb3d95b3 (diff)
uas: Cleanup uas_log_cmd_state usage
Instead of doing: uas_log_cmd_state(cmnd, __func__) scmd_printk(KERN_ERR, cmnd, "error doing foo %d\n", err) On error, resulting in 2 log calls for a single error, make uas_log_cmd_state take a status code, and change calls like the above to: uas_log_cmd_state(cmnd, "error doing foo", err) Also change various sanity checks (which should never trigger) from: "scmd_printk(KERN_ERR, cmnd, "sanity foo failed\n")" to calling the new uas_log_cmd_state(), so that when they do trigger we get more info. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/storage')
-rw-r--r--drivers/usb/storage/uas.c52
1 files changed, 19 insertions, 33 deletions
diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c
index 6da4a48ae7d2..816f56658628 100644
--- a/drivers/usb/storage/uas.c
+++ b/drivers/usb/storage/uas.c
@@ -78,7 +78,8 @@ static int uas_submit_urbs(struct scsi_cmnd *cmnd,
78static void uas_do_work(struct work_struct *work); 78static void uas_do_work(struct work_struct *work);
79static int uas_try_complete(struct scsi_cmnd *cmnd, const char *caller); 79static int uas_try_complete(struct scsi_cmnd *cmnd, const char *caller);
80static void uas_free_streams(struct uas_dev_info *devinfo); 80static void uas_free_streams(struct uas_dev_info *devinfo);
81static void uas_log_cmd_state(struct scsi_cmnd *cmnd, const char *caller); 81static void uas_log_cmd_state(struct scsi_cmnd *cmnd, const char *prefix,
82 int status);
82 83
83static void uas_do_work(struct work_struct *work) 84static void uas_do_work(struct work_struct *work)
84{ 85{
@@ -139,7 +140,7 @@ static void uas_zap_pending(struct uas_dev_info *devinfo, int result)
139 140
140 cmnd = devinfo->cmnd[i]; 141 cmnd = devinfo->cmnd[i];
141 cmdinfo = (void *)&cmnd->SCp; 142 cmdinfo = (void *)&cmnd->SCp;
142 uas_log_cmd_state(cmnd, __func__); 143 uas_log_cmd_state(cmnd, __func__, 0);
143 /* Sense urbs were killed, clear COMMAND_INFLIGHT manually */ 144 /* Sense urbs were killed, clear COMMAND_INFLIGHT manually */
144 cmdinfo->state &= ~COMMAND_INFLIGHT; 145 cmdinfo->state &= ~COMMAND_INFLIGHT;
145 cmnd->result = result << 16; 146 cmnd->result = result << 16;
@@ -188,13 +189,14 @@ static int uas_get_tag(struct scsi_cmnd *cmnd)
188 return tag; 189 return tag;
189} 190}
190 191
191static void uas_log_cmd_state(struct scsi_cmnd *cmnd, const char *caller) 192static void uas_log_cmd_state(struct scsi_cmnd *cmnd, const char *prefix,
193 int status)
192{ 194{
193 struct uas_cmd_info *ci = (void *)&cmnd->SCp; 195 struct uas_cmd_info *ci = (void *)&cmnd->SCp;
194 196
195 scmd_printk(KERN_INFO, cmnd, 197 scmd_printk(KERN_INFO, cmnd,
196 "%s tag %d inflight:%s%s%s%s%s%s%s%s%s%s%s%s ", 198 "%s %d tag %d inflight:%s%s%s%s%s%s%s%s%s%s%s%s ",
197 caller, uas_get_tag(cmnd), 199 prefix, status, uas_get_tag(cmnd),
198 (ci->state & SUBMIT_STATUS_URB) ? " s-st" : "", 200 (ci->state & SUBMIT_STATUS_URB) ? " s-st" : "",
199 (ci->state & ALLOC_DATA_IN_URB) ? " a-in" : "", 201 (ci->state & ALLOC_DATA_IN_URB) ? " a-in" : "",
200 (ci->state & SUBMIT_DATA_IN_URB) ? " s-in" : "", 202 (ci->state & SUBMIT_DATA_IN_URB) ? " s-in" : "",
@@ -295,7 +297,7 @@ static void uas_stat_cmplt(struct urb *urb)
295 cmdinfo = (void *)&cmnd->SCp; 297 cmdinfo = (void *)&cmnd->SCp;
296 298
297 if (!(cmdinfo->state & COMMAND_INFLIGHT)) { 299 if (!(cmdinfo->state & COMMAND_INFLIGHT)) {
298 scmd_printk(KERN_ERR, cmnd, "unexpected status cmplt\n"); 300 uas_log_cmd_state(cmnd, "unexpected status cmplt", 0);
299 goto out; 301 goto out;
300 } 302 }
301 303
@@ -313,7 +315,7 @@ static void uas_stat_cmplt(struct urb *urb)
313 case IU_ID_READ_READY: 315 case IU_ID_READ_READY:
314 if (!cmdinfo->data_in_urb || 316 if (!cmdinfo->data_in_urb ||
315 (cmdinfo->state & DATA_IN_URB_INFLIGHT)) { 317 (cmdinfo->state & DATA_IN_URB_INFLIGHT)) {
316 scmd_printk(KERN_ERR, cmnd, "unexpected read rdy\n"); 318 uas_log_cmd_state(cmnd, "unexpected read rdy", 0);
317 break; 319 break;
318 } 320 }
319 uas_xfer_data(urb, cmnd, SUBMIT_DATA_IN_URB); 321 uas_xfer_data(urb, cmnd, SUBMIT_DATA_IN_URB);
@@ -321,14 +323,13 @@ static void uas_stat_cmplt(struct urb *urb)
321 case IU_ID_WRITE_READY: 323 case IU_ID_WRITE_READY:
322 if (!cmdinfo->data_out_urb || 324 if (!cmdinfo->data_out_urb ||
323 (cmdinfo->state & DATA_OUT_URB_INFLIGHT)) { 325 (cmdinfo->state & DATA_OUT_URB_INFLIGHT)) {
324 scmd_printk(KERN_ERR, cmnd, "unexpected write rdy\n"); 326 uas_log_cmd_state(cmnd, "unexpected write rdy", 0);
325 break; 327 break;
326 } 328 }
327 uas_xfer_data(urb, cmnd, SUBMIT_DATA_OUT_URB); 329 uas_xfer_data(urb, cmnd, SUBMIT_DATA_OUT_URB);
328 break; 330 break;
329 default: 331 default:
330 scmd_printk(KERN_ERR, cmnd, 332 uas_log_cmd_state(cmnd, "bogus IU", iu->iu_id);
331 "Bogus IU (%d) received on status pipe\n", iu->iu_id);
332 } 333 }
333out: 334out:
334 usb_free_urb(urb); 335 usb_free_urb(urb);
@@ -374,17 +375,13 @@ static void uas_data_cmplt(struct urb *urb)
374 375
375 /* Data urbs should not complete before the cmd urb is submitted */ 376 /* Data urbs should not complete before the cmd urb is submitted */
376 if (cmdinfo->state & SUBMIT_CMD_URB) { 377 if (cmdinfo->state & SUBMIT_CMD_URB) {
377 scmd_printk(KERN_ERR, cmnd, "unexpected data cmplt\n"); 378 uas_log_cmd_state(cmnd, "unexpected data cmplt", 0);
378 goto out; 379 goto out;
379 } 380 }
380 381
381 if (urb->status) { 382 if (urb->status) {
382 if (urb->status != -ENOENT && urb->status != -ECONNRESET) { 383 if (urb->status != -ENOENT && urb->status != -ECONNRESET)
383 uas_log_cmd_state(cmnd, __func__); 384 uas_log_cmd_state(cmnd, "data cmplt err", urb->status);
384 scmd_printk(KERN_ERR, cmnd,
385 "data cmplt err %d stream %d\n",
386 urb->status, urb->stream_id);
387 }
388 /* error: no data transfered */ 385 /* error: no data transfered */
389 sdb->resid = sdb->length; 386 sdb->resid = sdb->length;
390 } else { 387 } else {
@@ -508,10 +505,7 @@ static struct urb *uas_submit_sense_urb(struct scsi_cmnd *cmnd,
508 err = usb_submit_urb(urb, gfp); 505 err = usb_submit_urb(urb, gfp);
509 if (err) { 506 if (err) {
510 usb_unanchor_urb(urb); 507 usb_unanchor_urb(urb);
511 uas_log_cmd_state(cmnd, __func__); 508 uas_log_cmd_state(cmnd, "sense submit err", err);
512 shost_printk(KERN_INFO, shost,
513 "sense urb submission error %d stream %d\n",
514 err, stream);
515 usb_free_urb(urb); 509 usb_free_urb(urb);
516 return NULL; 510 return NULL;
517 } 511 }
@@ -547,10 +541,7 @@ static int uas_submit_urbs(struct scsi_cmnd *cmnd,
547 err = usb_submit_urb(cmdinfo->data_in_urb, gfp); 541 err = usb_submit_urb(cmdinfo->data_in_urb, gfp);
548 if (err) { 542 if (err) {
549 usb_unanchor_urb(cmdinfo->data_in_urb); 543 usb_unanchor_urb(cmdinfo->data_in_urb);
550 uas_log_cmd_state(cmnd, __func__); 544 uas_log_cmd_state(cmnd, "data in submit err", err);
551 scmd_printk(KERN_INFO, cmnd,
552 "data in urb submission error %d stream %d\n",
553 err, cmdinfo->data_in_urb->stream_id);
554 return SCSI_MLQUEUE_DEVICE_BUSY; 545 return SCSI_MLQUEUE_DEVICE_BUSY;
555 } 546 }
556 cmdinfo->state &= ~SUBMIT_DATA_IN_URB; 547 cmdinfo->state &= ~SUBMIT_DATA_IN_URB;
@@ -571,10 +562,7 @@ static int uas_submit_urbs(struct scsi_cmnd *cmnd,
571 err = usb_submit_urb(cmdinfo->data_out_urb, gfp); 562 err = usb_submit_urb(cmdinfo->data_out_urb, gfp);
572 if (err) { 563 if (err) {
573 usb_unanchor_urb(cmdinfo->data_out_urb); 564 usb_unanchor_urb(cmdinfo->data_out_urb);
574 uas_log_cmd_state(cmnd, __func__); 565 uas_log_cmd_state(cmnd, "data out submit err", err);
575 scmd_printk(KERN_INFO, cmnd,
576 "data out urb submission error %d stream %d\n",
577 err, cmdinfo->data_out_urb->stream_id);
578 return SCSI_MLQUEUE_DEVICE_BUSY; 566 return SCSI_MLQUEUE_DEVICE_BUSY;
579 } 567 }
580 cmdinfo->state &= ~SUBMIT_DATA_OUT_URB; 568 cmdinfo->state &= ~SUBMIT_DATA_OUT_URB;
@@ -593,9 +581,7 @@ static int uas_submit_urbs(struct scsi_cmnd *cmnd,
593 err = usb_submit_urb(cmdinfo->cmd_urb, gfp); 581 err = usb_submit_urb(cmdinfo->cmd_urb, gfp);
594 if (err) { 582 if (err) {
595 usb_unanchor_urb(cmdinfo->cmd_urb); 583 usb_unanchor_urb(cmdinfo->cmd_urb);
596 uas_log_cmd_state(cmnd, __func__); 584 uas_log_cmd_state(cmnd, "cmd submit err", err);
597 scmd_printk(KERN_INFO, cmnd,
598 "cmd urb submission error %d\n", err);
599 return SCSI_MLQUEUE_DEVICE_BUSY; 585 return SCSI_MLQUEUE_DEVICE_BUSY;
600 } 586 }
601 cmdinfo->cmd_urb = NULL; 587 cmdinfo->cmd_urb = NULL;
@@ -701,7 +687,7 @@ static int uas_eh_abort_handler(struct scsi_cmnd *cmnd)
701 687
702 spin_lock_irqsave(&devinfo->lock, flags); 688 spin_lock_irqsave(&devinfo->lock, flags);
703 689
704 uas_log_cmd_state(cmnd, __func__); 690 uas_log_cmd_state(cmnd, __func__, 0);
705 691
706 /* Ensure that try_complete does not call scsi_done */ 692 /* Ensure that try_complete does not call scsi_done */
707 cmdinfo->state |= COMMAND_ABORTED; 693 cmdinfo->state |= COMMAND_ABORTED;