aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-05-02 14:03:08 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-05-02 14:03:08 -0400
commit1be1d6b7f3f6e3a87f872dd5e7a867d03d8a6851 (patch)
tree102ef63f93d7d6d8400fc88158cc859a92a2b44f /drivers/block
parent37b6a04fd9fc887bbcc1a27d9354a5e7a5a4cdd8 (diff)
parent62fd2cac5bf5cf9e6fcb2fc40b32e7271e605c53 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6: (32 commits) USB GADGET/PERIPHERAL: g_file_storage Bulk-Only Transport compliance, clear-feature ignore USB GADGET/PERIPHERAL: g_file_storage Bulk-Only Transport compliance usb_serial: some coding style fixes USB: Remove redundant dependencies on USB_ATM. USB: UHCI: disable remote wakeup when it's not needed USB: OHCI: work around bogus compiler warning USB: add Cypress c67x00 OTG controller HCD driver USB: add Cypress c67x00 OTG controller core driver USB: add Cypress c67x00 low level interface code USB: airprime: unlock mutex instead of trying to lock it again USB: storage: Update mailling list address USB: storage: UNUSUAL_DEVS() for PanDigital Picture frame. USB: Add the USB 2.0 extension descriptor. USB: add more FTDI device ids USB: fix cannot work usb storage when using ohci-sm501 usb: gadget zero timer init fix usb: gadget zero style fixups (mostly whitespace) usb serial gadget: CDC ACM fixes usb: pxa27x_udc driver USB: INTOVA Pixtreme camera mass storage device ...
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/ub.c63
1 files changed, 39 insertions, 24 deletions
diff --git a/drivers/block/ub.c b/drivers/block/ub.c
index e322cce8c12d..3a281ef11ffa 100644
--- a/drivers/block/ub.c
+++ b/drivers/block/ub.c
@@ -205,6 +205,7 @@ struct ub_scsi_cmd {
205 unsigned char key, asc, ascq; /* May be valid if error==-EIO */ 205 unsigned char key, asc, ascq; /* May be valid if error==-EIO */
206 206
207 int stat_count; /* Retries getting status. */ 207 int stat_count; /* Retries getting status. */
208 unsigned int timeo; /* jiffies until rq->timeout changes */
208 209
209 unsigned int len; /* Requested length */ 210 unsigned int len; /* Requested length */
210 unsigned int current_sg; 211 unsigned int current_sg;
@@ -318,6 +319,7 @@ struct ub_dev {
318 int openc; /* protected by ub_lock! */ 319 int openc; /* protected by ub_lock! */
319 /* kref is too implicit for our taste */ 320 /* kref is too implicit for our taste */
320 int reset; /* Reset is running */ 321 int reset; /* Reset is running */
322 int bad_resid;
321 unsigned int tagcnt; 323 unsigned int tagcnt;
322 char name[12]; 324 char name[12];
323 struct usb_device *dev; 325 struct usb_device *dev;
@@ -764,6 +766,12 @@ static void ub_cmd_build_packet(struct ub_dev *sc, struct ub_lun *lun,
764 cmd->cdb_len = rq->cmd_len; 766 cmd->cdb_len = rq->cmd_len;
765 767
766 cmd->len = rq->data_len; 768 cmd->len = rq->data_len;
769
770 /*
771 * To reapply this to every URB is not as incorrect as it looks.
772 * In return, we avoid any complicated tracking calculations.
773 */
774 cmd->timeo = rq->timeout;
767} 775}
768 776
769static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd) 777static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
@@ -785,10 +793,6 @@ static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
785 scsi_status = 0; 793 scsi_status = 0;
786 } else { 794 } else {
787 if (cmd->act_len != cmd->len) { 795 if (cmd->act_len != cmd->len) {
788 if ((cmd->key == MEDIUM_ERROR ||
789 cmd->key == UNIT_ATTENTION) &&
790 ub_rw_cmd_retry(sc, lun, urq, cmd) == 0)
791 return;
792 scsi_status = SAM_STAT_CHECK_CONDITION; 796 scsi_status = SAM_STAT_CHECK_CONDITION;
793 } else { 797 } else {
794 scsi_status = 0; 798 scsi_status = 0;
@@ -804,7 +808,10 @@ static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
804 else 808 else
805 scsi_status = DID_ERROR << 16; 809 scsi_status = DID_ERROR << 16;
806 } else { 810 } else {
807 if (cmd->error == -EIO) { 811 if (cmd->error == -EIO &&
812 (cmd->key == 0 ||
813 cmd->key == MEDIUM_ERROR ||
814 cmd->key == UNIT_ATTENTION)) {
808 if (ub_rw_cmd_retry(sc, lun, urq, cmd) == 0) 815 if (ub_rw_cmd_retry(sc, lun, urq, cmd) == 0)
809 return; 816 return;
810 } 817 }
@@ -1259,14 +1266,19 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
1259 return; 1266 return;
1260 } 1267 }
1261 1268
1262 len = le32_to_cpu(bcs->Residue); 1269 if (!sc->bad_resid) {
1263 if (len != cmd->len - cmd->act_len) { 1270 len = le32_to_cpu(bcs->Residue);
1264 /* 1271 if (len != cmd->len - cmd->act_len) {
1265 * It is all right to transfer less, the caller has 1272 /*
1266 * to check. But it's not all right if the device 1273 * Only start ignoring if this cmd ended well.
1267 * counts disagree with our counts. 1274 */
1268 */ 1275 if (cmd->len == cmd->act_len) {
1269 goto Bad_End; 1276 printk(KERN_NOTICE "%s: "
1277 "bad residual %d of %d, ignoring\n",
1278 sc->name, len, cmd->len);
1279 sc->bad_resid = 1;
1280 }
1281 }
1270 } 1282 }
1271 1283
1272 switch (bcs->Status) { 1284 switch (bcs->Status) {
@@ -1297,8 +1309,7 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
1297 ub_state_done(sc, cmd, -EIO); 1309 ub_state_done(sc, cmd, -EIO);
1298 1310
1299 } else { 1311 } else {
1300 printk(KERN_WARNING "%s: " 1312 printk(KERN_WARNING "%s: wrong command state %d\n",
1301 "wrong command state %d\n",
1302 sc->name, cmd->state); 1313 sc->name, cmd->state);
1303 ub_state_done(sc, cmd, -EINVAL); 1314 ub_state_done(sc, cmd, -EINVAL);
1304 return; 1315 return;
@@ -1336,7 +1347,10 @@ static void ub_data_start(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
1336 return; 1347 return;
1337 } 1348 }
1338 1349
1339 sc->work_timer.expires = jiffies + UB_DATA_TIMEOUT; 1350 if (cmd->timeo)
1351 sc->work_timer.expires = jiffies + cmd->timeo;
1352 else
1353 sc->work_timer.expires = jiffies + UB_DATA_TIMEOUT;
1340 add_timer(&sc->work_timer); 1354 add_timer(&sc->work_timer);
1341 1355
1342 cmd->state = UB_CMDST_DATA; 1356 cmd->state = UB_CMDST_DATA;
@@ -1376,7 +1390,10 @@ static int __ub_state_stat(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
1376 return -1; 1390 return -1;
1377 } 1391 }
1378 1392
1379 sc->work_timer.expires = jiffies + UB_STAT_TIMEOUT; 1393 if (cmd->timeo)
1394 sc->work_timer.expires = jiffies + cmd->timeo;
1395 else
1396 sc->work_timer.expires = jiffies + UB_STAT_TIMEOUT;
1380 add_timer(&sc->work_timer); 1397 add_timer(&sc->work_timer);
1381 return 0; 1398 return 0;
1382} 1399}
@@ -1515,8 +1532,7 @@ static void ub_top_sense_done(struct ub_dev *sc, struct ub_scsi_cmd *scmd)
1515 return; 1532 return;
1516 } 1533 }
1517 if (cmd->state != UB_CMDST_SENSE) { 1534 if (cmd->state != UB_CMDST_SENSE) {
1518 printk(KERN_WARNING "%s: " 1535 printk(KERN_WARNING "%s: sense done with bad cmd state %d\n",
1519 "sense done with bad cmd state %d\n",
1520 sc->name, cmd->state); 1536 sc->name, cmd->state);
1521 return; 1537 return;
1522 } 1538 }
@@ -1720,7 +1736,7 @@ static int ub_bd_ioctl(struct inode *inode, struct file *filp,
1720} 1736}
1721 1737
1722/* 1738/*
1723 * This is called once a new disk was seen by the block layer or by ub_probe(). 1739 * This is called by check_disk_change if we reported a media change.
1724 * The main onjective here is to discover the features of the media such as 1740 * The main onjective here is to discover the features of the media such as
1725 * the capacity, read-only status, etc. USB storage generally does not 1741 * the capacity, read-only status, etc. USB storage generally does not
1726 * need to be spun up, but if we needed it, this would be the place. 1742 * need to be spun up, but if we needed it, this would be the place.
@@ -2136,8 +2152,7 @@ static int ub_get_pipes(struct ub_dev *sc, struct usb_device *dev,
2136 } 2152 }
2137 2153
2138 if (ep_in == NULL || ep_out == NULL) { 2154 if (ep_in == NULL || ep_out == NULL) {
2139 printk(KERN_NOTICE "%s: failed endpoint check\n", 2155 printk(KERN_NOTICE "%s: failed endpoint check\n", sc->name);
2140 sc->name);
2141 return -ENODEV; 2156 return -ENODEV;
2142 } 2157 }
2143 2158
@@ -2354,7 +2369,7 @@ static void ub_disconnect(struct usb_interface *intf)
2354 spin_unlock_irqrestore(&ub_lock, flags); 2369 spin_unlock_irqrestore(&ub_lock, flags);
2355 2370
2356 /* 2371 /*
2357 * Fence stall clearnings, operations triggered by unlinkings and so on. 2372 * Fence stall clearings, operations triggered by unlinkings and so on.
2358 * We do not attempt to unlink any URBs, because we do not trust the 2373 * We do not attempt to unlink any URBs, because we do not trust the
2359 * unlink paths in HC drivers. Also, we get -84 upon disconnect anyway. 2374 * unlink paths in HC drivers. Also, we get -84 upon disconnect anyway.
2360 */ 2375 */
@@ -2417,7 +2432,7 @@ static void ub_disconnect(struct usb_interface *intf)
2417 spin_unlock_irqrestore(sc->lock, flags); 2432 spin_unlock_irqrestore(sc->lock, flags);
2418 2433
2419 /* 2434 /*
2420 * There is virtually no chance that other CPU runs times so long 2435 * There is virtually no chance that other CPU runs a timeout so long
2421 * after ub_urb_complete should have called del_timer, but only if HCD 2436 * after ub_urb_complete should have called del_timer, but only if HCD
2422 * didn't forget to deliver a callback on unlink. 2437 * didn't forget to deliver a callback on unlink.
2423 */ 2438 */