aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNamjae Jeon <namjae.jeon@samsung.com>2012-07-07 23:05:28 -0400
committerJames Bottomley <JBottomley@Parallels.com>2012-07-20 03:59:00 -0400
commiteaa05dfcdb12cf3a7bedf8918dc8699c00944384 (patch)
treef05101a4a1353bbb578fa2a83634ab7404335873
parentb81478d82e389dd0961760f5ff6f56b50d29db6d (diff)
[SCSI] usb-storage: add support for write cache quirk
Add support for write cache quirk on usb hdd. scsi driver will be set to wce by detecting write cache quirk in quirk list when plugging usb hdd. Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com> Signed-off-by: Pankaj Kumar <pankaj.km@samsung.com> Signed-off-by: Amit Sahrawat <a.sahrawat@samsung.com> Acked-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
-rw-r--r--Documentation/kernel-parameters.txt2
-rw-r--r--drivers/usb/storage/scsiglue.c5
-rw-r--r--drivers/usb/storage/usb.c5
-rw-r--r--include/linux/usb_usual.h4
4 files changed, 14 insertions, 2 deletions
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index a92c5ebf373e..c68634edd451 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -2932,6 +2932,8 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
2932 initial READ(10) command); 2932 initial READ(10) command);
2933 o = CAPACITY_OK (accept the capacity 2933 o = CAPACITY_OK (accept the capacity
2934 reported by the device); 2934 reported by the device);
2935 p = WRITE_CACHE (the device cache is ON
2936 by default);
2935 r = IGNORE_RESIDUE (the device reports 2937 r = IGNORE_RESIDUE (the device reports
2936 bogus residue values); 2938 bogus residue values);
2937 s = SINGLE_LUN (the device has only one 2939 s = SINGLE_LUN (the device has only one
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
index 11418da9bc09..a3d54366afcc 100644
--- a/drivers/usb/storage/scsiglue.c
+++ b/drivers/usb/storage/scsiglue.c
@@ -236,6 +236,11 @@ static int slave_configure(struct scsi_device *sdev)
236 US_FL_SCM_MULT_TARG)) && 236 US_FL_SCM_MULT_TARG)) &&
237 us->protocol == USB_PR_BULK) 237 us->protocol == USB_PR_BULK)
238 us->use_last_sector_hacks = 1; 238 us->use_last_sector_hacks = 1;
239
240 /* Check if write cache default on flag is set or not */
241 if (us->fflags & US_FL_WRITE_CACHE)
242 sdev->wce_default_on = 1;
243
239 } else { 244 } else {
240 245
241 /* Non-disk-type devices don't need to blacklist any pages 246 /* Non-disk-type devices don't need to blacklist any pages
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index e23c30ab66da..d012fe4329e7 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -473,7 +473,7 @@ static void adjust_quirks(struct us_data *us)
473 US_FL_CAPACITY_OK | US_FL_IGNORE_RESIDUE | 473 US_FL_CAPACITY_OK | US_FL_IGNORE_RESIDUE |
474 US_FL_SINGLE_LUN | US_FL_NO_WP_DETECT | 474 US_FL_SINGLE_LUN | US_FL_NO_WP_DETECT |
475 US_FL_NO_READ_DISC_INFO | US_FL_NO_READ_CAPACITY_16 | 475 US_FL_NO_READ_DISC_INFO | US_FL_NO_READ_CAPACITY_16 |
476 US_FL_INITIAL_READ10); 476 US_FL_INITIAL_READ10 | US_FL_WRITE_CACHE);
477 477
478 p = quirks; 478 p = quirks;
479 while (*p) { 479 while (*p) {
@@ -529,6 +529,9 @@ static void adjust_quirks(struct us_data *us)
529 case 'o': 529 case 'o':
530 f |= US_FL_CAPACITY_OK; 530 f |= US_FL_CAPACITY_OK;
531 break; 531 break;
532 case 'p':
533 f |= US_FL_WRITE_CACHE;
534 break;
532 case 'r': 535 case 'r':
533 f |= US_FL_IGNORE_RESIDUE; 536 f |= US_FL_IGNORE_RESIDUE;
534 break; 537 break;
diff --git a/include/linux/usb_usual.h b/include/linux/usb_usual.h
index 17df3600bcef..e84e769aaddc 100644
--- a/include/linux/usb_usual.h
+++ b/include/linux/usb_usual.h
@@ -64,7 +64,9 @@
64 US_FLAG(NO_READ_CAPACITY_16, 0x00080000) \ 64 US_FLAG(NO_READ_CAPACITY_16, 0x00080000) \
65 /* cannot handle READ_CAPACITY_16 */ \ 65 /* cannot handle READ_CAPACITY_16 */ \
66 US_FLAG(INITIAL_READ10, 0x00100000) \ 66 US_FLAG(INITIAL_READ10, 0x00100000) \
67 /* Initial READ(10) (and others) must be retried */ 67 /* Initial READ(10) (and others) must be retried */ \
68 US_FLAG(WRITE_CACHE, 0x00200000) \
69 /* Write Cache status is not available */
68 70
69#define US_FLAG(name, value) US_FL_##name = value , 71#define US_FLAG(name, value) US_FL_##name = value ,
70enum { US_DO_ALL_FLAGS }; 72enum { US_DO_ALL_FLAGS };