Skip to content

Commit 5373081

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: "Ten fixes. Of the three core changes, the two large ones are a complete reversion of the async rework and an ALUA timing rework (the latter shouldn't affect non-ALUA paths). The remaining patches are all small and all but one in drivers" * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: scsi: sd: Revert "Rework asynchronous resume support" scsi: core: Fix passthrough retry counter handling scsi: ufs: core: Reduce the power mode change timeout scsi: storvsc: Remove WQ_MEM_RECLAIM from storvsc_error_wq scsi: ufs: host: ufs-exynos: Make fsd_ufs_drvs static scsi: megaraid_sas: Remove unnecessary kfree() scsi: megaraid_sas: Fix double kfree() scsi: ufs: core: Enable link lost interrupt scsi: core: Allow the ALUA transitioning state enough time scsi: qla2xxx: Disable ATIO interrupt coalesce for quad port ISP27XX
2 parents 8238b45 + 785538b commit 5373081

File tree

10 files changed

+60
-114
lines changed

10 files changed

+60
-114
lines changed

drivers/scsi/megaraid/megaraid_sas_base.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7153,22 +7153,18 @@ static int megasas_alloc_ctrl_mem(struct megasas_instance *instance)
71537153
switch (instance->adapter_type) {
71547154
case MFI_SERIES:
71557155
if (megasas_alloc_mfi_ctrl_mem(instance))
7156-
goto fail;
7156+
return -ENOMEM;
71577157
break;
71587158
case AERO_SERIES:
71597159
case VENTURA_SERIES:
71607160
case THUNDERBOLT_SERIES:
71617161
case INVADER_SERIES:
71627162
if (megasas_alloc_fusion_context(instance))
7163-
goto fail;
7163+
return -ENOMEM;
71647164
break;
71657165
}
71667166

71677167
return 0;
7168-
fail:
7169-
kfree(instance->reply_map);
7170-
instance->reply_map = NULL;
7171-
return -ENOMEM;
71727168
}
71737169

71747170
/*

drivers/scsi/megaraid/megaraid_sas_fusion.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5310,7 +5310,6 @@ megasas_alloc_fusion_context(struct megasas_instance *instance)
53105310
if (!fusion->log_to_span) {
53115311
dev_err(&instance->pdev->dev, "Failed from %s %d\n",
53125312
__func__, __LINE__);
5313-
kfree(instance->ctrl_context);
53145313
return -ENOMEM;
53155314
}
53165315
}

drivers/scsi/qla2xxx/qla_target.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6935,14 +6935,8 @@ qlt_24xx_config_rings(struct scsi_qla_host *vha)
69356935

69366936
if (ha->flags.msix_enabled) {
69376937
if (IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha)) {
6938-
if (IS_QLA2071(ha)) {
6939-
/* 4 ports Baker: Enable Interrupt Handshake */
6940-
icb->msix_atio = 0;
6941-
icb->firmware_options_2 |= cpu_to_le32(BIT_26);
6942-
} else {
6943-
icb->msix_atio = cpu_to_le16(msix->entry);
6944-
icb->firmware_options_2 &= cpu_to_le32(~BIT_26);
6945-
}
6938+
icb->msix_atio = cpu_to_le16(msix->entry);
6939+
icb->firmware_options_2 &= cpu_to_le32(~BIT_26);
69466940
ql_dbg(ql_dbg_init, vha, 0xf072,
69476941
"Registering ICB vector 0x%x for atio que.\n",
69486942
msix->entry);

drivers/scsi/scsi_lib.c

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ scsi_set_blocked(struct scsi_cmnd *cmd, int reason)
111111
}
112112
}
113113

114-
static void scsi_mq_requeue_cmd(struct scsi_cmnd *cmd)
114+
static void scsi_mq_requeue_cmd(struct scsi_cmnd *cmd, unsigned long msecs)
115115
{
116116
struct request *rq = scsi_cmd_to_rq(cmd);
117117

@@ -121,7 +121,12 @@ static void scsi_mq_requeue_cmd(struct scsi_cmnd *cmd)
121121
} else {
122122
WARN_ON_ONCE(true);
123123
}
124-
blk_mq_requeue_request(rq, true);
124+
125+
if (msecs) {
126+
blk_mq_requeue_request(rq, false);
127+
blk_mq_delay_kick_requeue_list(rq->q, msecs);
128+
} else
129+
blk_mq_requeue_request(rq, true);
125130
}
126131

127132
/**
@@ -651,14 +656,6 @@ static unsigned int scsi_rq_err_bytes(const struct request *rq)
651656
return bytes;
652657
}
653658

654-
/* Helper for scsi_io_completion() when "reprep" action required. */
655-
static void scsi_io_completion_reprep(struct scsi_cmnd *cmd,
656-
struct request_queue *q)
657-
{
658-
/* A new command will be prepared and issued. */
659-
scsi_mq_requeue_cmd(cmd);
660-
}
661-
662659
static bool scsi_cmd_runtime_exceeced(struct scsi_cmnd *cmd)
663660
{
664661
struct request *req = scsi_cmd_to_rq(cmd);
@@ -676,14 +673,21 @@ static bool scsi_cmd_runtime_exceeced(struct scsi_cmnd *cmd)
676673
return false;
677674
}
678675

676+
/*
677+
* When ALUA transition state is returned, reprep the cmd to
678+
* use the ALUA handler's transition timeout. Delay the reprep
679+
* 1 sec to avoid aggressive retries of the target in that
680+
* state.
681+
*/
682+
#define ALUA_TRANSITION_REPREP_DELAY 1000
683+
679684
/* Helper for scsi_io_completion() when special action required. */
680685
static void scsi_io_completion_action(struct scsi_cmnd *cmd, int result)
681686
{
682-
struct request_queue *q = cmd->device->request_queue;
683687
struct request *req = scsi_cmd_to_rq(cmd);
684688
int level = 0;
685-
enum {ACTION_FAIL, ACTION_REPREP, ACTION_RETRY,
686-
ACTION_DELAYED_RETRY} action;
689+
enum {ACTION_FAIL, ACTION_REPREP, ACTION_DELAYED_REPREP,
690+
ACTION_RETRY, ACTION_DELAYED_RETRY} action;
687691
struct scsi_sense_hdr sshdr;
688692
bool sense_valid;
689693
bool sense_current = true; /* false implies "deferred sense" */
@@ -772,8 +776,8 @@ static void scsi_io_completion_action(struct scsi_cmnd *cmd, int result)
772776
action = ACTION_DELAYED_RETRY;
773777
break;
774778
case 0x0a: /* ALUA state transition */
775-
blk_stat = BLK_STS_TRANSPORT;
776-
fallthrough;
779+
action = ACTION_DELAYED_REPREP;
780+
break;
777781
default:
778782
action = ACTION_FAIL;
779783
break;
@@ -832,7 +836,10 @@ static void scsi_io_completion_action(struct scsi_cmnd *cmd, int result)
832836
return;
833837
fallthrough;
834838
case ACTION_REPREP:
835-
scsi_io_completion_reprep(cmd, q);
839+
scsi_mq_requeue_cmd(cmd, 0);
840+
break;
841+
case ACTION_DELAYED_REPREP:
842+
scsi_mq_requeue_cmd(cmd, ALUA_TRANSITION_REPREP_DELAY);
836843
break;
837844
case ACTION_RETRY:
838845
/* Retry the same command immediately */
@@ -926,7 +933,7 @@ static int scsi_io_completion_nz_result(struct scsi_cmnd *cmd, int result,
926933
* command block will be released and the queue function will be goosed. If we
927934
* are not done then we have to figure out what to do next:
928935
*
929-
* a) We can call scsi_io_completion_reprep(). The request will be
936+
* a) We can call scsi_mq_requeue_cmd(). The request will be
930937
* unprepared and put back on the queue. Then a new command will
931938
* be created for it. This should be used if we made forward
932939
* progress, or if we want to switch from READ(10) to READ(6) for
@@ -942,7 +949,6 @@ static int scsi_io_completion_nz_result(struct scsi_cmnd *cmd, int result,
942949
void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
943950
{
944951
int result = cmd->result;
945-
struct request_queue *q = cmd->device->request_queue;
946952
struct request *req = scsi_cmd_to_rq(cmd);
947953
blk_status_t blk_stat = BLK_STS_OK;
948954

@@ -979,7 +985,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
979985
* request just queue the command up again.
980986
*/
981987
if (likely(result == 0))
982-
scsi_io_completion_reprep(cmd, q);
988+
scsi_mq_requeue_cmd(cmd, 0);
983989
else
984990
scsi_io_completion_action(cmd, result);
985991
}
@@ -1542,7 +1548,6 @@ static blk_status_t scsi_prepare_cmd(struct request *req)
15421548
scsi_init_command(sdev, cmd);
15431549

15441550
cmd->eh_eflags = 0;
1545-
cmd->allowed = 0;
15461551
cmd->prot_type = 0;
15471552
cmd->prot_flags = 0;
15481553
cmd->submitter = 0;
@@ -1593,6 +1598,8 @@ static blk_status_t scsi_prepare_cmd(struct request *req)
15931598
return ret;
15941599
}
15951600

1601+
/* Usually overridden by the ULP */
1602+
cmd->allowed = 0;
15961603
memset(cmd->cmnd, 0, sizeof(cmd->cmnd));
15971604
return scsi_cmd_to_driver(cmd)->init_command(cmd);
15981605
}

drivers/scsi/sd.c

Lines changed: 18 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ static void sd_config_discard(struct scsi_disk *, unsigned int);
103103
static void sd_config_write_same(struct scsi_disk *);
104104
static int sd_revalidate_disk(struct gendisk *);
105105
static void sd_unlock_native_capacity(struct gendisk *disk);
106-
static void sd_start_done_work(struct work_struct *work);
107106
static int sd_probe(struct device *);
108107
static int sd_remove(struct device *);
109108
static void sd_shutdown(struct device *);
@@ -3471,7 +3470,6 @@ static int sd_probe(struct device *dev)
34713470
sdkp->max_retries = SD_MAX_RETRIES;
34723471
atomic_set(&sdkp->openers, 0);
34733472
atomic_set(&sdkp->device->ioerr_cnt, 0);
3474-
INIT_WORK(&sdkp->start_done_work, sd_start_done_work);
34753473

34763474
if (!sdp->request_queue->rq_timeout) {
34773475
if (sdp->type != TYPE_MOD)
@@ -3594,69 +3592,12 @@ static void scsi_disk_release(struct device *dev)
35943592
kfree(sdkp);
35953593
}
35963594

3597-
/* Process sense data after a START command finished. */
3598-
static void sd_start_done_work(struct work_struct *work)
3599-
{
3600-
struct scsi_disk *sdkp = container_of(work, typeof(*sdkp),
3601-
start_done_work);
3602-
struct scsi_sense_hdr sshdr;
3603-
int res = sdkp->start_result;
3604-
3605-
if (res == 0)
3606-
return;
3607-
3608-
sd_print_result(sdkp, "Start/Stop Unit failed", res);
3609-
3610-
if (res < 0)
3611-
return;
3612-
3613-
if (scsi_normalize_sense(sdkp->start_sense_buffer,
3614-
sdkp->start_sense_len, &sshdr))
3615-
sd_print_sense_hdr(sdkp, &sshdr);
3616-
}
3617-
3618-
/* A START command finished. May be called from interrupt context. */
3619-
static void sd_start_done(struct request *req, blk_status_t status)
3620-
{
3621-
const struct scsi_cmnd *scmd = blk_mq_rq_to_pdu(req);
3622-
struct scsi_disk *sdkp = scsi_disk(req->q->disk);
3623-
3624-
sdkp->start_result = scmd->result;
3625-
WARN_ON_ONCE(scmd->sense_len > SCSI_SENSE_BUFFERSIZE);
3626-
sdkp->start_sense_len = scmd->sense_len;
3627-
memcpy(sdkp->start_sense_buffer, scmd->sense_buffer,
3628-
ARRAY_SIZE(sdkp->start_sense_buffer));
3629-
WARN_ON_ONCE(!schedule_work(&sdkp->start_done_work));
3630-
}
3631-
3632-
/* Submit a START command asynchronously. */
3633-
static int sd_submit_start(struct scsi_disk *sdkp, u8 cmd[], u8 cmd_len)
3634-
{
3635-
struct scsi_device *sdev = sdkp->device;
3636-
struct request_queue *q = sdev->request_queue;
3637-
struct request *req;
3638-
struct scsi_cmnd *scmd;
3639-
3640-
req = scsi_alloc_request(q, REQ_OP_DRV_IN, BLK_MQ_REQ_PM);
3641-
if (IS_ERR(req))
3642-
return PTR_ERR(req);
3643-
3644-
scmd = blk_mq_rq_to_pdu(req);
3645-
scmd->cmd_len = cmd_len;
3646-
memcpy(scmd->cmnd, cmd, cmd_len);
3647-
scmd->allowed = sdkp->max_retries;
3648-
req->timeout = SD_TIMEOUT;
3649-
req->rq_flags |= RQF_PM | RQF_QUIET;
3650-
req->end_io = sd_start_done;
3651-
blk_execute_rq_nowait(req, /*at_head=*/true);
3652-
3653-
return 0;
3654-
}
3655-
36563595
static int sd_start_stop_device(struct scsi_disk *sdkp, int start)
36573596
{
36583597
unsigned char cmd[6] = { START_STOP }; /* START_VALID */
3598+
struct scsi_sense_hdr sshdr;
36593599
struct scsi_device *sdp = sdkp->device;
3600+
int res;
36603601

36613602
if (start)
36623603
cmd[4] |= 1; /* START */
@@ -3667,10 +3608,23 @@ static int sd_start_stop_device(struct scsi_disk *sdkp, int start)
36673608
if (!scsi_device_online(sdp))
36683609
return -ENODEV;
36693610

3670-
/* Wait until processing of sense data has finished. */
3671-
flush_work(&sdkp->start_done_work);
3611+
res = scsi_execute(sdp, cmd, DMA_NONE, NULL, 0, NULL, &sshdr,
3612+
SD_TIMEOUT, sdkp->max_retries, 0, RQF_PM, NULL);
3613+
if (res) {
3614+
sd_print_result(sdkp, "Start/Stop Unit failed", res);
3615+
if (res > 0 && scsi_sense_valid(&sshdr)) {
3616+
sd_print_sense_hdr(sdkp, &sshdr);
3617+
/* 0x3a is medium not present */
3618+
if (sshdr.asc == 0x3a)
3619+
res = 0;
3620+
}
3621+
}
36723622

3673-
return sd_submit_start(sdkp, cmd, sizeof(cmd));
3623+
/* SCSI error codes must not go to the generic layer */
3624+
if (res)
3625+
return -EIO;
3626+
3627+
return 0;
36743628
}
36753629

36763630
/*
@@ -3697,8 +3651,6 @@ static void sd_shutdown(struct device *dev)
36973651
sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n");
36983652
sd_start_stop_device(sdkp, 0);
36993653
}
3700-
3701-
flush_work(&sdkp->start_done_work);
37023654
}
37033655

37043656
static int sd_suspend_common(struct device *dev, bool ignore_stop_errors)

drivers/scsi/sd.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,6 @@ struct scsi_disk {
150150
unsigned urswrz : 1;
151151
unsigned security : 1;
152152
unsigned ignore_medium_access_errors : 1;
153-
154-
int start_result;
155-
u32 start_sense_len;
156-
u8 start_sense_buffer[SCSI_SENSE_BUFFERSIZE];
157-
struct work_struct start_done_work;
158153
};
159154
#define to_scsi_disk(obj) container_of(obj, struct scsi_disk, disk_dev)
160155

drivers/scsi/storvsc_drv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2012,7 +2012,7 @@ static int storvsc_probe(struct hv_device *device,
20122012
*/
20132013
host_dev->handle_error_wq =
20142014
alloc_ordered_workqueue("storvsc_error_wq_%d",
2015-
WQ_MEM_RECLAIM,
2015+
0,
20162016
host->host_no);
20172017
if (!host_dev->handle_error_wq) {
20182018
ret = -ENOMEM;

drivers/ufs/core/ufshcd.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8741,6 +8741,8 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba,
87418741
struct scsi_device *sdp;
87428742
unsigned long flags;
87438743
int ret, retries;
8744+
unsigned long deadline;
8745+
int32_t remaining;
87448746

87458747
spin_lock_irqsave(hba->host->host_lock, flags);
87468748
sdp = hba->ufs_device_wlun;
@@ -8773,9 +8775,14 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba,
87738775
* callbacks hence set the RQF_PM flag so that it doesn't resume the
87748776
* already suspended childs.
87758777
*/
8778+
deadline = jiffies + 10 * HZ;
87768779
for (retries = 3; retries > 0; --retries) {
8780+
ret = -ETIMEDOUT;
8781+
remaining = deadline - jiffies;
8782+
if (remaining <= 0)
8783+
break;
87778784
ret = scsi_execute(sdp, cmd, DMA_NONE, NULL, 0, NULL, &sshdr,
8778-
START_STOP_TIMEOUT, 0, 0, RQF_PM, NULL);
8785+
remaining / HZ, 0, 0, RQF_PM, NULL);
87798786
if (!scsi_status_is_check_condition(ret) ||
87808787
!scsi_sense_valid(&sshdr) ||
87818788
sshdr.sense_key != UNIT_ATTENTION)

drivers/ufs/host/ufs-exynos.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1711,7 +1711,7 @@ static struct exynos_ufs_uic_attr fsd_uic_attr = {
17111711
.pa_dbg_option_suite = 0x2E820183,
17121712
};
17131713

1714-
struct exynos_ufs_drv_data fsd_ufs_drvs = {
1714+
static const struct exynos_ufs_drv_data fsd_ufs_drvs = {
17151715
.uic_attr = &fsd_uic_attr,
17161716
.quirks = UFSHCD_QUIRK_PRDT_BYTE_GRAN |
17171717
UFSHCI_QUIRK_BROKEN_REQ_LIST_CLR |

include/ufs/ufshci.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,7 @@ static inline u32 ufshci_version(u32 major, u32 minor)
135135

136136
#define UFSHCD_UIC_MASK (UIC_COMMAND_COMPL | UFSHCD_UIC_PWR_MASK)
137137

138-
#define UFSHCD_ERROR_MASK (UIC_ERROR |\
139-
DEVICE_FATAL_ERROR |\
140-
CONTROLLER_FATAL_ERROR |\
141-
SYSTEM_BUS_FATAL_ERROR |\
142-
CRYPTO_ENGINE_FATAL_ERROR)
138+
#define UFSHCD_ERROR_MASK (UIC_ERROR | INT_FATAL_ERRORS)
143139

144140
#define INT_FATAL_ERRORS (DEVICE_FATAL_ERROR |\
145141
CONTROLLER_FATAL_ERROR |\

0 commit comments

Comments
 (0)