Message ID | 20220308082048.9774-5-njavali@marvell.com |
---|---|
State | Superseded |
Headers | show |
Series | qla2xxx driver fixes | expand |
> On Mar 8, 2022, at 12:20 AM, Nilesh Javali <njavali@marvell.com> wrote: > > From: Arun Easi <aeasi@marvell.com> > > At NVME ELS request time, request structure is DMA mapped > and never unmapped. Fix this by calling the unmap on > ELS completion. > > Cc: stable@vger.kernel.org > Fixes: e84067d74301 ("scsi: qla2xxx: Add FC-NVMe F/W initialization and transport registration") > Signed-off-by: Arun Easi <aeasi@marvell.com> > Signed-off-by: Nilesh Javali <njavali@marvell.com> > --- > drivers/scsi/qla2xxx/qla_nvme.c | 17 +++++++++++++++++ > 1 file changed, 17 insertions(+) > > diff --git a/drivers/scsi/qla2xxx/qla_nvme.c b/drivers/scsi/qla2xxx/qla_nvme.c > index 3bf5cbd754a7..794a95b2e3b4 100644 > --- a/drivers/scsi/qla2xxx/qla_nvme.c > +++ b/drivers/scsi/qla2xxx/qla_nvme.c > @@ -175,6 +175,18 @@ static void qla_nvme_release_fcp_cmd_kref(struct kref *kref) > qla2xxx_rel_qpair_sp(sp->qpair, sp); > } > > +static void qla_nvme_ls_unmap(struct srb *sp, struct nvmefc_ls_req *fd) > +{ > + if (sp->flags & SRB_DMA_VALID) { > + struct srb_iocb *nvme = &sp->u.iocb_cmd; > + struct qla_hw_data *ha = sp->fcport->vha->hw; > + > + dma_unmap_single(&ha->pdev->dev, nvme->u.nvme.cmd_dma, > + fd->rqstlen, DMA_TO_DEVICE); > + sp->flags &= ~SRB_DMA_VALID; > + } > +} > + > static void qla_nvme_release_ls_cmd_kref(struct kref *kref) > { > struct srb *sp = container_of(kref, struct srb, cmd_kref); > @@ -191,6 +203,8 @@ static void qla_nvme_release_ls_cmd_kref(struct kref *kref) > spin_unlock_irqrestore(&priv->cmd_lock, flags); > > fd = priv->fd; > + > + qla_nvme_ls_unmap(sp, fd); > fd->done(fd, priv->comp_status); > out: > qla2x00_rel_sp(sp); > @@ -361,6 +375,8 @@ static int qla_nvme_ls_req(struct nvme_fc_local_port *lport, > dma_sync_single_for_device(&ha->pdev->dev, nvme->u.nvme.cmd_dma, > fd->rqstlen, DMA_TO_DEVICE); > > + sp->flags |= SRB_DMA_VALID; > + > rval = qla2x00_start_sp(sp); > if (rval != QLA_SUCCESS) { > ql_log(ql_log_warn, vha, 0x700e, > @@ -368,6 +384,7 @@ static int qla_nvme_ls_req(struct nvme_fc_local_port *lport, > wake_up(&sp->nvme_ls_waitq); > sp->priv = NULL; > priv->sp = NULL; > + qla_nvme_ls_unmap(sp, fd); > qla2x00_rel_sp(sp); > return rval; > } > -- > 2.19.0.rc0 > Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com> -- Himanshu Madhani Oracle Linux Engineering
diff --git a/drivers/scsi/qla2xxx/qla_nvme.c b/drivers/scsi/qla2xxx/qla_nvme.c index 3bf5cbd754a7..794a95b2e3b4 100644 --- a/drivers/scsi/qla2xxx/qla_nvme.c +++ b/drivers/scsi/qla2xxx/qla_nvme.c @@ -175,6 +175,18 @@ static void qla_nvme_release_fcp_cmd_kref(struct kref *kref) qla2xxx_rel_qpair_sp(sp->qpair, sp); } +static void qla_nvme_ls_unmap(struct srb *sp, struct nvmefc_ls_req *fd) +{ + if (sp->flags & SRB_DMA_VALID) { + struct srb_iocb *nvme = &sp->u.iocb_cmd; + struct qla_hw_data *ha = sp->fcport->vha->hw; + + dma_unmap_single(&ha->pdev->dev, nvme->u.nvme.cmd_dma, + fd->rqstlen, DMA_TO_DEVICE); + sp->flags &= ~SRB_DMA_VALID; + } +} + static void qla_nvme_release_ls_cmd_kref(struct kref *kref) { struct srb *sp = container_of(kref, struct srb, cmd_kref); @@ -191,6 +203,8 @@ static void qla_nvme_release_ls_cmd_kref(struct kref *kref) spin_unlock_irqrestore(&priv->cmd_lock, flags); fd = priv->fd; + + qla_nvme_ls_unmap(sp, fd); fd->done(fd, priv->comp_status); out: qla2x00_rel_sp(sp); @@ -361,6 +375,8 @@ static int qla_nvme_ls_req(struct nvme_fc_local_port *lport, dma_sync_single_for_device(&ha->pdev->dev, nvme->u.nvme.cmd_dma, fd->rqstlen, DMA_TO_DEVICE); + sp->flags |= SRB_DMA_VALID; + rval = qla2x00_start_sp(sp); if (rval != QLA_SUCCESS) { ql_log(ql_log_warn, vha, 0x700e, @@ -368,6 +384,7 @@ static int qla_nvme_ls_req(struct nvme_fc_local_port *lport, wake_up(&sp->nvme_ls_waitq); sp->priv = NULL; priv->sp = NULL; + qla_nvme_ls_unmap(sp, fd); qla2x00_rel_sp(sp); return rval; }