Skip to content

Commit 6d20acb

Browse files
committed
Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
Pull SCSI fixes from James Bottomley: "Six fixes: the four driver ones are pretty trivial. The larger two core changes are to try to fix various USB attached devices which have somewhat eccentric ways of handling the VPD and other mode pages which necessitate multiple revalidates (that were removed in the interests of efficiency) and updating the heuristic for supported VPD pages" * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: scsi: jazz_esp: Only build if SCSI core is builtin scsi: smartpqi: Fix disable_managed_interrupts scsi: ufs: Uninitialized variable in ufshcd_devfreq_target() scsi: target: pscsi: Fix bio_put() for error case scsi: core: Consult supported VPD page list prior to fetching page scsi: sd: usb_storage: uas: Access media prior to querying device properties
2 parents fef8526 + 9ddf190 commit 6d20acb

File tree

9 files changed

+72
-13
lines changed

9 files changed

+72
-13
lines changed

drivers/scsi/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1270,7 +1270,7 @@ source "drivers/scsi/arm/Kconfig"
12701270

12711271
config JAZZ_ESP
12721272
bool "MIPS JAZZ FAS216 SCSI support"
1273-
depends on MACH_JAZZ && SCSI
1273+
depends on MACH_JAZZ && SCSI=y
12741274
select SCSI_SPI_ATTRS
12751275
help
12761276
This is the driver for the onboard SCSI host adapter of MIPS Magnum

drivers/scsi/scsi.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,21 +328,39 @@ static int scsi_vpd_inquiry(struct scsi_device *sdev, unsigned char *buffer,
328328
return result + 4;
329329
}
330330

331+
enum scsi_vpd_parameters {
332+
SCSI_VPD_HEADER_SIZE = 4,
333+
SCSI_VPD_LIST_SIZE = 36,
334+
};
335+
331336
static int scsi_get_vpd_size(struct scsi_device *sdev, u8 page)
332337
{
333-
unsigned char vpd_header[SCSI_VPD_HEADER_SIZE] __aligned(4);
338+
unsigned char vpd[SCSI_VPD_LIST_SIZE] __aligned(4);
334339
int result;
335340

336341
if (sdev->no_vpd_size)
337342
return SCSI_DEFAULT_VPD_LEN;
338343

344+
/*
345+
* Fetch the supported pages VPD and validate that the requested page
346+
* number is present.
347+
*/
348+
if (page != 0) {
349+
result = scsi_vpd_inquiry(sdev, vpd, 0, sizeof(vpd));
350+
if (result < SCSI_VPD_HEADER_SIZE)
351+
return 0;
352+
353+
result -= SCSI_VPD_HEADER_SIZE;
354+
if (!memchr(&vpd[SCSI_VPD_HEADER_SIZE], page, result))
355+
return 0;
356+
}
339357
/*
340358
* Fetch the VPD page header to find out how big the page
341359
* is. This is done to prevent problems on legacy devices
342360
* which can not handle allocation lengths as large as
343361
* potentially requested by the caller.
344362
*/
345-
result = scsi_vpd_inquiry(sdev, vpd_header, page, sizeof(vpd_header));
363+
result = scsi_vpd_inquiry(sdev, vpd, page, SCSI_VPD_HEADER_SIZE);
346364
if (result < 0)
347365
return 0;
348366

drivers/scsi/sd.c

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3407,6 +3407,24 @@ static bool sd_validate_opt_xfer_size(struct scsi_disk *sdkp,
34073407
return true;
34083408
}
34093409

3410+
static void sd_read_block_zero(struct scsi_disk *sdkp)
3411+
{
3412+
unsigned int buf_len = sdkp->device->sector_size;
3413+
char *buffer, cmd[10] = { };
3414+
3415+
buffer = kmalloc(buf_len, GFP_KERNEL);
3416+
if (!buffer)
3417+
return;
3418+
3419+
cmd[0] = READ_10;
3420+
put_unaligned_be32(0, &cmd[2]); /* Logical block address 0 */
3421+
put_unaligned_be16(1, &cmd[7]); /* Transfer 1 logical block */
3422+
3423+
scsi_execute_cmd(sdkp->device, cmd, REQ_OP_DRV_IN, buffer, buf_len,
3424+
SD_TIMEOUT, sdkp->max_retries, NULL);
3425+
kfree(buffer);
3426+
}
3427+
34103428
/**
34113429
* sd_revalidate_disk - called the first time a new disk is seen,
34123430
* performs disk spin up, read_capacity, etc.
@@ -3446,7 +3464,13 @@ static int sd_revalidate_disk(struct gendisk *disk)
34463464
*/
34473465
if (sdkp->media_present) {
34483466
sd_read_capacity(sdkp, buffer);
3449-
3467+
/*
3468+
* Some USB/UAS devices return generic values for mode pages
3469+
* until the media has been accessed. Trigger a READ operation
3470+
* to force the device to populate mode pages.
3471+
*/
3472+
if (sdp->read_before_ms)
3473+
sd_read_block_zero(sdkp);
34503474
/*
34513475
* set the default to rotational. All non-rotational devices
34523476
* support the block characteristics VPD page, which will

drivers/scsi/smartpqi/smartpqi_init.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6533,8 +6533,11 @@ static void pqi_map_queues(struct Scsi_Host *shost)
65336533
{
65346534
struct pqi_ctrl_info *ctrl_info = shost_to_hba(shost);
65356535

6536-
blk_mq_pci_map_queues(&shost->tag_set.map[HCTX_TYPE_DEFAULT],
6536+
if (!ctrl_info->disable_managed_interrupts)
6537+
return blk_mq_pci_map_queues(&shost->tag_set.map[HCTX_TYPE_DEFAULT],
65376538
ctrl_info->pci_dev, 0);
6539+
else
6540+
return blk_mq_map_queues(&shost->tag_set.map[HCTX_TYPE_DEFAULT]);
65386541
}
65396542

65406543
static inline bool pqi_is_tape_changer_device(struct pqi_scsi_dev *device)

drivers/target/target_core_pscsi.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -907,12 +907,15 @@ pscsi_map_sg(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents,
907907

908908
return 0;
909909
fail:
910-
if (bio)
911-
bio_put(bio);
910+
if (bio) {
911+
bio_uninit(bio);
912+
kfree(bio);
913+
}
912914
while (req->bio) {
913915
bio = req->bio;
914916
req->bio = bio->bi_next;
915-
bio_put(bio);
917+
bio_uninit(bio);
918+
kfree(bio);
916919
}
917920
req->biotail = NULL;
918921
return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;

drivers/ufs/core/ufshcd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1469,7 +1469,7 @@ static int ufshcd_devfreq_target(struct device *dev,
14691469
int ret = 0;
14701470
struct ufs_hba *hba = dev_get_drvdata(dev);
14711471
ktime_t start;
1472-
bool scale_up, sched_clk_scaling_suspend_work = false;
1472+
bool scale_up = false, sched_clk_scaling_suspend_work = false;
14731473
struct list_head *clk_list = &hba->clk_list_head;
14741474
struct ufs_clk_info *clki;
14751475
unsigned long irq_flags;

drivers/usb/storage/scsiglue.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,13 @@ static int slave_configure(struct scsi_device *sdev)
179179
*/
180180
sdev->use_192_bytes_for_3f = 1;
181181

182+
/*
183+
* Some devices report generic values until the media has been
184+
* accessed. Force a READ(10) prior to querying device
185+
* characteristics.
186+
*/
187+
sdev->read_before_ms = 1;
188+
182189
/*
183190
* Some devices don't like MODE SENSE with page=0x3f,
184191
* which is the command used for checking if a device

drivers/usb/storage/uas.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,13 @@ static int uas_slave_configure(struct scsi_device *sdev)
878878
if (devinfo->flags & US_FL_CAPACITY_HEURISTICS)
879879
sdev->guess_capacity = 1;
880880

881+
/*
882+
* Some devices report generic values until the media has been
883+
* accessed. Force a READ(10) prior to querying device
884+
* characteristics.
885+
*/
886+
sdev->read_before_ms = 1;
887+
881888
/*
882889
* Some devices don't like MODE SENSE with page=0x3f,
883890
* which is the command used for checking if a device

include/scsi/scsi_device.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,6 @@ struct scsi_vpd {
100100
unsigned char data[];
101101
};
102102

103-
enum scsi_vpd_parameters {
104-
SCSI_VPD_HEADER_SIZE = 4,
105-
};
106-
107103
struct scsi_device {
108104
struct Scsi_Host *host;
109105
struct request_queue *request_queue;
@@ -208,6 +204,7 @@ struct scsi_device {
208204
unsigned use_10_for_rw:1; /* first try 10-byte read / write */
209205
unsigned use_10_for_ms:1; /* first try 10-byte mode sense/select */
210206
unsigned set_dbd_for_ms:1; /* Set "DBD" field in mode sense */
207+
unsigned read_before_ms:1; /* perform a READ before MODE SENSE */
211208
unsigned no_report_opcodes:1; /* no REPORT SUPPORTED OPERATION CODES */
212209
unsigned no_write_same:1; /* no WRITE SAME command */
213210
unsigned use_16_for_rw:1; /* Use read/write(16) over read/write(10) */

0 commit comments

Comments
 (0)