diff options
-rw-r--r-- | drivers/scsi/scsi_debug.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index 41a21772df12..fb9af207d61d 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c | |||
@@ -101,6 +101,8 @@ static const char * scsi_debug_version_date = "20070104"; | |||
101 | #define DEF_DIF 0 | 101 | #define DEF_DIF 0 |
102 | #define DEF_GUARD 0 | 102 | #define DEF_GUARD 0 |
103 | #define DEF_ATO 1 | 103 | #define DEF_ATO 1 |
104 | #define DEF_PHYSBLK_EXP 0 | ||
105 | #define DEF_LOWEST_ALIGNED 0 | ||
104 | 106 | ||
105 | /* bit mask values for scsi_debug_opts */ | 107 | /* bit mask values for scsi_debug_opts */ |
106 | #define SCSI_DEBUG_OPT_NOISE 1 | 108 | #define SCSI_DEBUG_OPT_NOISE 1 |
@@ -156,6 +158,8 @@ static int scsi_debug_dix = DEF_DIX; | |||
156 | static int scsi_debug_dif = DEF_DIF; | 158 | static int scsi_debug_dif = DEF_DIF; |
157 | static int scsi_debug_guard = DEF_GUARD; | 159 | static int scsi_debug_guard = DEF_GUARD; |
158 | static int scsi_debug_ato = DEF_ATO; | 160 | static int scsi_debug_ato = DEF_ATO; |
161 | static int scsi_debug_physblk_exp = DEF_PHYSBLK_EXP; | ||
162 | static int scsi_debug_lowest_aligned = DEF_LOWEST_ALIGNED; | ||
159 | 163 | ||
160 | static int scsi_debug_cmnd_count = 0; | 164 | static int scsi_debug_cmnd_count = 0; |
161 | 165 | ||
@@ -657,7 +661,12 @@ static unsigned char vpdb0_data[] = { | |||
657 | 661 | ||
658 | static int inquiry_evpd_b0(unsigned char * arr) | 662 | static int inquiry_evpd_b0(unsigned char * arr) |
659 | { | 663 | { |
664 | unsigned int gran; | ||
665 | |||
660 | memcpy(arr, vpdb0_data, sizeof(vpdb0_data)); | 666 | memcpy(arr, vpdb0_data, sizeof(vpdb0_data)); |
667 | gran = 1 << scsi_debug_physblk_exp; | ||
668 | arr[2] = (gran >> 8) & 0xff; | ||
669 | arr[3] = gran & 0xff; | ||
661 | if (sdebug_store_sectors > 0x400) { | 670 | if (sdebug_store_sectors > 0x400) { |
662 | arr[4] = (sdebug_store_sectors >> 24) & 0xff; | 671 | arr[4] = (sdebug_store_sectors >> 24) & 0xff; |
663 | arr[5] = (sdebug_store_sectors >> 16) & 0xff; | 672 | arr[5] = (sdebug_store_sectors >> 16) & 0xff; |
@@ -945,6 +954,9 @@ static int resp_readcap16(struct scsi_cmnd * scp, | |||
945 | arr[9] = (scsi_debug_sector_size >> 16) & 0xff; | 954 | arr[9] = (scsi_debug_sector_size >> 16) & 0xff; |
946 | arr[10] = (scsi_debug_sector_size >> 8) & 0xff; | 955 | arr[10] = (scsi_debug_sector_size >> 8) & 0xff; |
947 | arr[11] = scsi_debug_sector_size & 0xff; | 956 | arr[11] = scsi_debug_sector_size & 0xff; |
957 | arr[13] = scsi_debug_physblk_exp & 0xf; | ||
958 | arr[14] = (scsi_debug_lowest_aligned >> 8) & 0x3f; | ||
959 | arr[15] = scsi_debug_lowest_aligned & 0xff; | ||
948 | 960 | ||
949 | if (scsi_debug_dif) { | 961 | if (scsi_debug_dif) { |
950 | arr[12] = (scsi_debug_dif - 1) << 1; /* P_TYPE */ | 962 | arr[12] = (scsi_debug_dif - 1) << 1; /* P_TYPE */ |
@@ -2380,6 +2392,8 @@ module_param_named(dix, scsi_debug_dix, int, S_IRUGO); | |||
2380 | module_param_named(dif, scsi_debug_dif, int, S_IRUGO); | 2392 | module_param_named(dif, scsi_debug_dif, int, S_IRUGO); |
2381 | module_param_named(guard, scsi_debug_guard, int, S_IRUGO); | 2393 | module_param_named(guard, scsi_debug_guard, int, S_IRUGO); |
2382 | module_param_named(ato, scsi_debug_ato, int, S_IRUGO); | 2394 | module_param_named(ato, scsi_debug_ato, int, S_IRUGO); |
2395 | module_param_named(physblk_exp, scsi_debug_physblk_exp, int, S_IRUGO); | ||
2396 | module_param_named(lowest_aligned, scsi_debug_lowest_aligned, int, S_IRUGO); | ||
2383 | 2397 | ||
2384 | MODULE_AUTHOR("Eric Youngdale + Douglas Gilbert"); | 2398 | MODULE_AUTHOR("Eric Youngdale + Douglas Gilbert"); |
2385 | MODULE_DESCRIPTION("SCSI debug adapter driver"); | 2399 | MODULE_DESCRIPTION("SCSI debug adapter driver"); |
@@ -2401,7 +2415,9 @@ MODULE_PARM_DESC(ptype, "SCSI peripheral type(def=0[disk])"); | |||
2401 | MODULE_PARM_DESC(scsi_level, "SCSI level to simulate(def=5[SPC-3])"); | 2415 | MODULE_PARM_DESC(scsi_level, "SCSI level to simulate(def=5[SPC-3])"); |
2402 | MODULE_PARM_DESC(virtual_gb, "virtual gigabyte size (def=0 -> use dev_size_mb)"); | 2416 | MODULE_PARM_DESC(virtual_gb, "virtual gigabyte size (def=0 -> use dev_size_mb)"); |
2403 | MODULE_PARM_DESC(vpd_use_hostno, "0 -> dev ids ignore hostno (def=1 -> unique dev ids)"); | 2417 | MODULE_PARM_DESC(vpd_use_hostno, "0 -> dev ids ignore hostno (def=1 -> unique dev ids)"); |
2404 | MODULE_PARM_DESC(sector_size, "hardware sector size in bytes (def=512)"); | 2418 | MODULE_PARM_DESC(sector_size, "logical block size in bytes (def=512)"); |
2419 | MODULE_PARM_DESC(physblk_exp, "physical block exponent (def=0)"); | ||
2420 | MODULE_PARM_DESC(lowest_aligned, "lowest aligned lba (def=0)"); | ||
2405 | MODULE_PARM_DESC(dix, "data integrity extensions mask (def=0)"); | 2421 | MODULE_PARM_DESC(dix, "data integrity extensions mask (def=0)"); |
2406 | MODULE_PARM_DESC(dif, "data integrity field type: 0-3 (def=0)"); | 2422 | MODULE_PARM_DESC(dif, "data integrity field type: 0-3 (def=0)"); |
2407 | MODULE_PARM_DESC(guard, "protection checksum: 0=crc, 1=ip (def=0)"); | 2423 | MODULE_PARM_DESC(guard, "protection checksum: 0=crc, 1=ip (def=0)"); |
@@ -2874,6 +2890,18 @@ static int __init scsi_debug_init(void) | |||
2874 | return -EINVAL; | 2890 | return -EINVAL; |
2875 | } | 2891 | } |
2876 | 2892 | ||
2893 | if (scsi_debug_physblk_exp > 15) { | ||
2894 | printk(KERN_ERR "scsi_debug_init: invalid physblk_exp %u\n", | ||
2895 | scsi_debug_physblk_exp); | ||
2896 | return -EINVAL; | ||
2897 | } | ||
2898 | |||
2899 | if (scsi_debug_lowest_aligned > 0x3fff) { | ||
2900 | printk(KERN_ERR "scsi_debug_init: lowest_aligned too big: %u\n", | ||
2901 | scsi_debug_lowest_aligned); | ||
2902 | return -EINVAL; | ||
2903 | } | ||
2904 | |||
2877 | if (scsi_debug_dev_size_mb < 1) | 2905 | if (scsi_debug_dev_size_mb < 1) |
2878 | scsi_debug_dev_size_mb = 1; /* force minimum 1 MB ramdisk */ | 2906 | scsi_debug_dev_size_mb = 1; /* force minimum 1 MB ramdisk */ |
2879 | sz = (unsigned long)scsi_debug_dev_size_mb * 1048576; | 2907 | sz = (unsigned long)scsi_debug_dev_size_mb * 1048576; |