Skip to content

Commit a9b9e3a

Browse files
Christoph Hellwigmartinkpetersen
authored andcommitted
scsi: pmcraid: don't allocate a dma coherent buffer for sense data
We can just dma map the sense buffer passed with the scsi command, and that gets us out of the nasty business of doing dma coherent allocations from irq context. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 203654b commit a9b9e3a

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

drivers/scsi/pmcraid.c

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -846,16 +846,9 @@ static void pmcraid_erp_done(struct pmcraid_cmd *cmd)
846846
cmd->ioa_cb->ioarcb.cdb[0], ioasc);
847847
}
848848

849-
/* if we had allocated sense buffers for request sense, copy the sense
850-
* release the buffers
851-
*/
852-
if (cmd->sense_buffer != NULL) {
853-
memcpy(scsi_cmd->sense_buffer,
854-
cmd->sense_buffer,
855-
SCSI_SENSE_BUFFERSIZE);
856-
pci_free_consistent(pinstance->pdev,
857-
SCSI_SENSE_BUFFERSIZE,
858-
cmd->sense_buffer, cmd->sense_buffer_dma);
849+
if (cmd->sense_buffer) {
850+
dma_unmap_single(&pinstance->pdev->dev, cmd->sense_buffer_dma,
851+
SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE);
859852
cmd->sense_buffer = NULL;
860853
cmd->sense_buffer_dma = 0;
861854
}
@@ -2444,13 +2437,12 @@ static void pmcraid_request_sense(struct pmcraid_cmd *cmd)
24442437
{
24452438
struct pmcraid_ioarcb *ioarcb = &cmd->ioa_cb->ioarcb;
24462439
struct pmcraid_ioadl_desc *ioadl = ioarcb->add_data.u.ioadl;
2440+
struct device *dev = &cmd->drv_inst->pdev->dev;
24472441

2448-
/* allocate DMAable memory for sense buffers */
2449-
cmd->sense_buffer = pci_alloc_consistent(cmd->drv_inst->pdev,
2450-
SCSI_SENSE_BUFFERSIZE,
2451-
&cmd->sense_buffer_dma);
2452-
2453-
if (cmd->sense_buffer == NULL) {
2442+
cmd->sense_buffer = cmd->scsi_cmd->sense_buffer;
2443+
cmd->sense_buffer_dma = dma_map_single(dev, cmd->sense_buffer,
2444+
SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE);
2445+
if (dma_mapping_error(dev, cmd->sense_buffer_dma)) {
24542446
pmcraid_err
24552447
("couldn't allocate sense buffer for request sense\n");
24562448
pmcraid_erp_done(cmd);

0 commit comments

Comments
 (0)