Skip to content

Commit 04cc50c

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: "Two core fixes: one to prevent discard type changes (seen on iSCSI) during intermittent errors and the other is fixing a lockdep problem caused by the queue limits change. And one driver fix in ufs" * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: scsi: sd: Keep the discard mode stable scsi: sd: Move sd_read_cpr() out of the q->limits_lock region scsi: ufs: core: Fix hba->last_dme_cmd_tstamp timestamp updating logic
2 parents 5189daf + f874d72 commit 04cc50c

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

drivers/scsi/sd.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2711,8 +2711,6 @@ static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp,
27112711

27122712
if (buffer[14] & 0x40) /* LBPRZ */
27132713
sdkp->lbprz = 1;
2714-
2715-
sd_config_discard(sdkp, lim, SD_LBP_WS16);
27162714
}
27172715

27182716
sdkp->capacity = lba + 1;
@@ -3365,8 +3363,6 @@ static void sd_read_block_limits(struct scsi_disk *sdkp,
33653363
sdkp->unmap_alignment =
33663364
get_unaligned_be32(&vpd->data[32]) & ~(1 << 31);
33673365

3368-
sd_config_discard(sdkp, lim, sd_discard_mode(sdkp));
3369-
33703366
config_atomic:
33713367
sdkp->max_atomic = get_unaligned_be32(&vpd->data[44]);
33723368
sdkp->atomic_alignment = get_unaligned_be32(&vpd->data[48]);
@@ -3753,9 +3749,10 @@ static int sd_revalidate_disk(struct gendisk *disk)
37533749
sd_read_block_limits_ext(sdkp);
37543750
sd_read_block_characteristics(sdkp, &lim);
37553751
sd_zbc_read_zones(sdkp, &lim, buffer);
3756-
sd_read_cpr(sdkp);
37573752
}
37583753

3754+
sd_config_discard(sdkp, &lim, sd_discard_mode(sdkp));
3755+
37593756
sd_print_capacity(sdkp, old_capacity);
37603757

37613758
sd_read_write_protect_flag(sdkp, buffer);
@@ -3808,6 +3805,14 @@ static int sd_revalidate_disk(struct gendisk *disk)
38083805
if (err)
38093806
return err;
38103807

3808+
/*
3809+
* Query concurrent positioning ranges after
3810+
* queue_limits_commit_update() unlocked q->limits_lock to avoid
3811+
* deadlock with q->sysfs_dir_lock and q->sysfs_lock.
3812+
*/
3813+
if (sdkp->media_present && scsi_device_supports_vpd(sdp))
3814+
sd_read_cpr(sdkp);
3815+
38113816
/*
38123817
* For a zoned drive, revalidating the zones can be done only once
38133818
* the gendisk capacity is set. So if this fails, set back the gendisk

drivers/ufs/core/ufshcd.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4100,11 +4100,16 @@ static inline void ufshcd_add_delay_before_dme_cmd(struct ufs_hba *hba)
41004100
min_sleep_time_us =
41014101
MIN_DELAY_BEFORE_DME_CMDS_US - delta;
41024102
else
4103-
return; /* no more delay required */
4103+
min_sleep_time_us = 0; /* no more delay required */
41044104
}
41054105

4106-
/* allow sleep for extra 50us if needed */
4107-
usleep_range(min_sleep_time_us, min_sleep_time_us + 50);
4106+
if (min_sleep_time_us > 0) {
4107+
/* allow sleep for extra 50us if needed */
4108+
usleep_range(min_sleep_time_us, min_sleep_time_us + 50);
4109+
}
4110+
4111+
/* update the last_dme_cmd_tstamp */
4112+
hba->last_dme_cmd_tstamp = ktime_get();
41084113
}
41094114

41104115
/**

0 commit comments

Comments
 (0)