Skip to content

Commit 96b171d

Browse files
bvanasschemartinkpetersen
authored andcommitted
scsi: core: Query the Block Limits Extension VPD page
Parse the Reduced Stream Control Supported (RSCS) bit from the block limits extension VPD page. The RSCS bit is defined in SBC-5 r05 (https://www.t10.org/cgi-bin/ac.pl?t=f&f=sbc5r05.pdf). Reviewed-by: Avri Altman <[email protected]> Reviewed-by: Daejun Park <[email protected]> Cc: Martin K. Petersen <[email protected]> Signed-off-by: Bart Van Assche <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 4498135 commit 96b171d

File tree

5 files changed

+27
-0
lines changed

5 files changed

+27
-0
lines changed

drivers/scsi/scsi.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,8 @@ void scsi_attach_vpd(struct scsi_device *sdev)
499499
scsi_update_vpd_page(sdev, 0xb1, &sdev->vpd_pgb1);
500500
if (vpd_buf->data[i] == 0xb2)
501501
scsi_update_vpd_page(sdev, 0xb2, &sdev->vpd_pgb2);
502+
if (vpd_buf->data[i] == 0xb7)
503+
scsi_update_vpd_page(sdev, 0xb7, &sdev->vpd_pgb7);
502504
}
503505
kfree(vpd_buf);
504506
}

drivers/scsi/scsi_sysfs.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,7 @@ static void scsi_device_dev_release(struct device *dev)
449449
struct scsi_vpd *vpd_pg80 = NULL, *vpd_pg83 = NULL;
450450
struct scsi_vpd *vpd_pg0 = NULL, *vpd_pg89 = NULL;
451451
struct scsi_vpd *vpd_pgb0 = NULL, *vpd_pgb1 = NULL, *vpd_pgb2 = NULL;
452+
struct scsi_vpd *vpd_pgb7 = NULL;
452453
unsigned long flags;
453454

454455
might_sleep();
@@ -494,6 +495,8 @@ static void scsi_device_dev_release(struct device *dev)
494495
lockdep_is_held(&sdev->inquiry_mutex));
495496
vpd_pgb2 = rcu_replace_pointer(sdev->vpd_pgb2, vpd_pgb2,
496497
lockdep_is_held(&sdev->inquiry_mutex));
498+
vpd_pgb7 = rcu_replace_pointer(sdev->vpd_pgb7, vpd_pgb7,
499+
lockdep_is_held(&sdev->inquiry_mutex));
497500
mutex_unlock(&sdev->inquiry_mutex);
498501

499502
if (vpd_pg0)
@@ -510,6 +513,8 @@ static void scsi_device_dev_release(struct device *dev)
510513
kfree_rcu(vpd_pgb1, rcu);
511514
if (vpd_pgb2)
512515
kfree_rcu(vpd_pgb2, rcu);
516+
if (vpd_pgb7)
517+
kfree_rcu(vpd_pgb7, rcu);
513518
kfree(sdev->inquiry);
514519
kfree(sdev);
515520

@@ -921,6 +926,7 @@ sdev_vpd_pg_attr(pg89);
921926
sdev_vpd_pg_attr(pgb0);
922927
sdev_vpd_pg_attr(pgb1);
923928
sdev_vpd_pg_attr(pgb2);
929+
sdev_vpd_pg_attr(pgb7);
924930
sdev_vpd_pg_attr(pg0);
925931

926932
static ssize_t show_inquiry(struct file *filep, struct kobject *kobj,
@@ -1295,6 +1301,9 @@ static umode_t scsi_sdev_bin_attr_is_visible(struct kobject *kobj,
12951301
if (attr == &dev_attr_vpd_pgb2 && !sdev->vpd_pgb2)
12961302
return 0;
12971303

1304+
if (attr == &dev_attr_vpd_pgb7 && !sdev->vpd_pgb7)
1305+
return 0;
1306+
12981307
return S_IRUGO;
12991308
}
13001309

@@ -1347,6 +1356,7 @@ static struct bin_attribute *scsi_sdev_bin_attrs[] = {
13471356
&dev_attr_vpd_pgb0,
13481357
&dev_attr_vpd_pgb1,
13491358
&dev_attr_vpd_pgb2,
1359+
&dev_attr_vpd_pgb7,
13501360
&dev_attr_inquiry,
13511361
NULL
13521362
};

drivers/scsi/sd.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3108,6 +3108,18 @@ static void sd_read_block_limits(struct scsi_disk *sdkp)
31083108
rcu_read_unlock();
31093109
}
31103110

3111+
/* Parse the Block Limits Extension VPD page (0xb7) */
3112+
static void sd_read_block_limits_ext(struct scsi_disk *sdkp)
3113+
{
3114+
struct scsi_vpd *vpd;
3115+
3116+
rcu_read_lock();
3117+
vpd = rcu_dereference(sdkp->device->vpd_pgb7);
3118+
if (vpd && vpd->len >= 2)
3119+
sdkp->rscs = vpd->data[5] & 1;
3120+
rcu_read_unlock();
3121+
}
3122+
31113123
/**
31123124
* sd_read_block_characteristics - Query block dev. characteristics
31133125
* @sdkp: disk to query
@@ -3459,6 +3471,7 @@ static int sd_revalidate_disk(struct gendisk *disk)
34593471
if (scsi_device_supports_vpd(sdp)) {
34603472
sd_read_block_provisioning(sdkp);
34613473
sd_read_block_limits(sdkp);
3474+
sd_read_block_limits_ext(sdkp);
34623475
sd_read_block_characteristics(sdkp);
34633476
sd_zbc_read_zones(sdkp, buffer);
34643477
sd_read_cpr(sdkp);

drivers/scsi/sd.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ struct scsi_disk {
151151
unsigned urswrz : 1;
152152
unsigned security : 1;
153153
unsigned ignore_medium_access_errors : 1;
154+
bool rscs : 1; /* reduced stream control support */
154155
};
155156
#define to_scsi_disk(obj) container_of(obj, struct scsi_disk, disk_dev)
156157

include/scsi/scsi_device.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ struct scsi_device {
153153
struct scsi_vpd __rcu *vpd_pgb0;
154154
struct scsi_vpd __rcu *vpd_pgb1;
155155
struct scsi_vpd __rcu *vpd_pgb2;
156+
struct scsi_vpd __rcu *vpd_pgb7;
156157

157158
struct scsi_target *sdev_target;
158159

0 commit comments

Comments
 (0)