On Thursday 18 October 2018 15:01:14 Christoph Hellwig wrote: > Hi Ondrej, > > can you look over this series, which cleans up a few dma-related > bits in the wd719x driver? Hello, this patch is needed to make it work: diff --git a/drivers/scsi/wd719x.c b/drivers/scsi/wd719x.c index d47190f08ed6..b73e7f24a1c4 100644 --- a/drivers/scsi/wd719x.c +++ b/drivers/scsi/wd719x.c @@ -183,7 +183,7 @@ static void wd719x_finish_cmd(struct wd719x_scb *scb, int result) list_del(&scb->list); dma_unmap_single(&wd->pdev->dev, scb->phys, - sizeof(struct wd719x_scb), DMA_TO_DEVICE); + sizeof(struct wd719x_scb), DMA_BIDIRECTIONAL); scsi_dma_unmap(cmd); dma_unmap_single(&wd->pdev->dev, cmd->SCp.dma_handle, SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE); @@ -209,12 +209,19 @@ static int wd719x_queuecommand(struct Scsi_Host *sh, struct scsi_cmnd *cmd) /* copy the command */ memcpy(scb->CDB, cmd->cmnd, cmd->cmd_len); + /* map SCB */ + scb->phys = dma_map_single(&wd->pdev->dev, scb, sizeof(*scb), + DMA_BIDIRECTIONAL); + + if (dma_mapping_error(&wd->pdev->dev, scb->phys)) + goto out_error; + /* map sense buffer */ scb->sense_buf_length = SCSI_SENSE_BUFFERSIZE; cmd->SCp.dma_handle = dma_map_single(&wd->pdev->dev, cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE); if (dma_mapping_error(&wd->pdev->dev, cmd->SCp.dma_handle)) - goto out_error; + goto out_unmap_scb; scb->sense_buf = cpu_to_le32(cmd->SCp.dma_handle); /* request autosense */ @@ -246,11 +253,6 @@ static int wd719x_queuecommand(struct Scsi_Host *sh, struct scsi_cmnd *cmd) scb->sg_list[i].length = cpu_to_le32(sg_dma_len(sg)); } scb->SCB_options |= WD719X_SCB_FLAGS_DO_SCATTER_GATHER; - - scb->phys = dma_map_single(&wd->pdev->dev, scb, sizeof(*scb), - DMA_TO_DEVICE); - if (dma_mapping_error(&wd->pdev->dev, scb->phys)) - goto out_unmap_scsi_cmd; } else { /* zero length */ scb->data_length = 0; scb->data_p = 0; @@ -274,11 +276,12 @@ static int wd719x_queuecommand(struct Scsi_Host *sh, struct scsi_cmnd *cmd) spin_unlock_irqrestore(wd->sh->host_lock, flags); return 0; -out_unmap_scsi_cmd: - scsi_dma_unmap(cmd); out_unmap_sense: dma_unmap_single(&wd->pdev->dev, cmd->SCp.dma_handle, SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE); +out_unmap_scb: + dma_unmap_single(&wd->pdev->dev, scb->phys, sizeof(*scb), + DMA_BIDIRECTIONAL); out_error: cmd->result = DID_ERROR << 16; cmd->scsi_done(cmd); -- Ondrej Zary