Skip to content

Commit 0950fcb

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: "Five fixes, all in drivers. The big change is the UFS task management rework, with lpfc next and the rest being fairly minor and obvious fixes" * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: scsi: iscsi: Fix iscsi_task use after free scsi: lpfc: Fix memory overwrite during FC-GS I/O abort handling scsi: elx: efct: Delete stray unlock statement scsi: ufs: core: Fix task management completion scsi: acornscsi: Remove scsi_cmd_to_tag() reference
2 parents 50eb0a0 + 258aad7 commit 0950fcb

File tree

6 files changed

+41
-43
lines changed

6 files changed

+41
-43
lines changed

drivers/scsi/arm/acornscsi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1776,7 +1776,7 @@ int acornscsi_reconnect_finish(AS_Host *host)
17761776
host->scsi.disconnectable = 0;
17771777
if (host->SCpnt->device->id == host->scsi.reconnected.target &&
17781778
host->SCpnt->device->lun == host->scsi.reconnected.lun &&
1779-
scsi_cmd_to_tag(host->SCpnt) == host->scsi.reconnected.tag) {
1779+
scsi_cmd_to_rq(host->SCpnt)->tag == host->scsi.reconnected.tag) {
17801780
#if (DEBUG & (DEBUG_QUEUES|DEBUG_DISCON))
17811781
DBG(host->SCpnt, printk("scsi%d.%c: reconnected",
17821782
host->host->host_no, acornscsi_target(host)));

drivers/scsi/elx/efct/efct_scsi.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ efct_scsi_io_alloc(struct efct_node *node)
3232
struct efct *efct;
3333
struct efct_xport *xport;
3434
struct efct_io *io;
35-
unsigned long flags = 0;
35+
unsigned long flags;
3636

3737
efct = node->efct;
3838

@@ -44,7 +44,6 @@ efct_scsi_io_alloc(struct efct_node *node)
4444
if (!io) {
4545
efc_log_err(efct, "IO alloc Failed\n");
4646
atomic_add_return(1, &xport->io_alloc_failed_count);
47-
spin_unlock_irqrestore(&node->active_ios_lock, flags);
4847
return NULL;
4948
}
5049

drivers/scsi/libiscsi.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2281,20 +2281,23 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)
22812281
return FAILED;
22822282
}
22832283

2284-
conn = session->leadconn;
2285-
iscsi_get_conn(conn->cls_conn);
2286-
conn->eh_abort_cnt++;
2287-
age = session->age;
2288-
22892284
spin_lock(&session->back_lock);
22902285
task = (struct iscsi_task *)sc->SCp.ptr;
22912286
if (!task || !task->sc) {
22922287
/* task completed before time out */
22932288
ISCSI_DBG_EH(session, "sc completed while abort in progress\n");
22942289

22952290
spin_unlock(&session->back_lock);
2296-
goto success;
2291+
spin_unlock_bh(&session->frwd_lock);
2292+
mutex_unlock(&session->eh_mutex);
2293+
return SUCCESS;
22972294
}
2295+
2296+
conn = session->leadconn;
2297+
iscsi_get_conn(conn->cls_conn);
2298+
conn->eh_abort_cnt++;
2299+
age = session->age;
2300+
22982301
ISCSI_DBG_EH(session, "aborting [sc %p itt 0x%x]\n", sc, task->itt);
22992302
__iscsi_get_task(task);
23002303
spin_unlock(&session->back_lock);

drivers/scsi/lpfc/lpfc_sli.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12292,23 +12292,26 @@ void
1229212292
lpfc_ignore_els_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
1229312293
struct lpfc_iocbq *rspiocb)
1229412294
{
12295-
struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) cmdiocb->context1;
12295+
struct lpfc_nodelist *ndlp = NULL;
1229612296
IOCB_t *irsp = &rspiocb->iocb;
1229712297

1229812298
/* ELS cmd tag <ulpIoTag> completes */
1229912299
lpfc_printf_log(phba, KERN_INFO, LOG_ELS,
12300-
"0139 Ignoring ELS cmd tag x%x completion Data: "
12300+
"0139 Ignoring ELS cmd code x%x completion Data: "
1230112301
"x%x x%x x%x\n",
1230212302
irsp->ulpIoTag, irsp->ulpStatus,
1230312303
irsp->un.ulpWord[4], irsp->ulpTimeout);
1230412304
/*
1230512305
* Deref the ndlp after free_iocb. sli_release_iocb will access the ndlp
1230612306
* if exchange is busy.
1230712307
*/
12308-
if (cmdiocb->iocb.ulpCommand == CMD_GEN_REQUEST64_CR)
12308+
if (cmdiocb->iocb.ulpCommand == CMD_GEN_REQUEST64_CR) {
12309+
ndlp = cmdiocb->context_un.ndlp;
1230912310
lpfc_ct_free_iocb(phba, cmdiocb);
12310-
else
12311+
} else {
12312+
ndlp = (struct lpfc_nodelist *) cmdiocb->context1;
1231112313
lpfc_els_free_iocb(phba, cmdiocb);
12314+
}
1231212315

1231312316
lpfc_nlp_put(ndlp);
1231412317
}

drivers/scsi/ufs/ufshcd.c

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6377,27 +6377,6 @@ static irqreturn_t ufshcd_check_errors(struct ufs_hba *hba, u32 intr_status)
63776377
return retval;
63786378
}
63796379

6380-
struct ctm_info {
6381-
struct ufs_hba *hba;
6382-
unsigned long pending;
6383-
unsigned int ncpl;
6384-
};
6385-
6386-
static bool ufshcd_compl_tm(struct request *req, void *priv, bool reserved)
6387-
{
6388-
struct ctm_info *const ci = priv;
6389-
struct completion *c;
6390-
6391-
WARN_ON_ONCE(reserved);
6392-
if (test_bit(req->tag, &ci->pending))
6393-
return true;
6394-
ci->ncpl++;
6395-
c = req->end_io_data;
6396-
if (c)
6397-
complete(c);
6398-
return true;
6399-
}
6400-
64016380
/**
64026381
* ufshcd_tmc_handler - handle task management function completion
64036382
* @hba: per adapter instance
@@ -6408,18 +6387,24 @@ static bool ufshcd_compl_tm(struct request *req, void *priv, bool reserved)
64086387
*/
64096388
static irqreturn_t ufshcd_tmc_handler(struct ufs_hba *hba)
64106389
{
6411-
unsigned long flags;
6412-
struct request_queue *q = hba->tmf_queue;
6413-
struct ctm_info ci = {
6414-
.hba = hba,
6415-
};
6390+
unsigned long flags, pending, issued;
6391+
irqreturn_t ret = IRQ_NONE;
6392+
int tag;
6393+
6394+
pending = ufshcd_readl(hba, REG_UTP_TASK_REQ_DOOR_BELL);
64166395

64176396
spin_lock_irqsave(hba->host->host_lock, flags);
6418-
ci.pending = ufshcd_readl(hba, REG_UTP_TASK_REQ_DOOR_BELL);
6419-
blk_mq_tagset_busy_iter(q->tag_set, ufshcd_compl_tm, &ci);
6397+
issued = hba->outstanding_tasks & ~pending;
6398+
for_each_set_bit(tag, &issued, hba->nutmrs) {
6399+
struct request *req = hba->tmf_rqs[tag];
6400+
struct completion *c = req->end_io_data;
6401+
6402+
complete(c);
6403+
ret = IRQ_HANDLED;
6404+
}
64206405
spin_unlock_irqrestore(hba->host->host_lock, flags);
64216406

6422-
return ci.ncpl ? IRQ_HANDLED : IRQ_NONE;
6407+
return ret;
64236408
}
64246409

64256410
/**
@@ -6542,9 +6527,9 @@ static int __ufshcd_issue_tm_cmd(struct ufs_hba *hba,
65426527
ufshcd_hold(hba, false);
65436528

65446529
spin_lock_irqsave(host->host_lock, flags);
6545-
blk_mq_start_request(req);
65466530

65476531
task_tag = req->tag;
6532+
hba->tmf_rqs[req->tag] = req;
65486533
treq->upiu_req.req_header.dword_0 |= cpu_to_be32(task_tag);
65496534

65506535
memcpy(hba->utmrdl_base_addr + task_tag, treq, sizeof(*treq));
@@ -6585,6 +6570,7 @@ static int __ufshcd_issue_tm_cmd(struct ufs_hba *hba,
65856570
}
65866571

65876572
spin_lock_irqsave(hba->host->host_lock, flags);
6573+
hba->tmf_rqs[req->tag] = NULL;
65886574
__clear_bit(task_tag, &hba->outstanding_tasks);
65896575
spin_unlock_irqrestore(hba->host->host_lock, flags);
65906576

@@ -9635,6 +9621,12 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
96359621
err = PTR_ERR(hba->tmf_queue);
96369622
goto free_tmf_tag_set;
96379623
}
9624+
hba->tmf_rqs = devm_kcalloc(hba->dev, hba->nutmrs,
9625+
sizeof(*hba->tmf_rqs), GFP_KERNEL);
9626+
if (!hba->tmf_rqs) {
9627+
err = -ENOMEM;
9628+
goto free_tmf_queue;
9629+
}
96389630

96399631
/* Reset the attached device */
96409632
ufshcd_device_reset(hba);

drivers/scsi/ufs/ufshcd.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,7 @@ struct ufs_hba {
828828

829829
struct blk_mq_tag_set tmf_tag_set;
830830
struct request_queue *tmf_queue;
831+
struct request **tmf_rqs;
831832

832833
struct uic_command *active_uic_cmd;
833834
struct mutex uic_cmd_mutex;

0 commit comments

Comments
 (0)