Commit 22cb4e68 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

mtip32xx: ѕtop abusing the managed resource APIs

The mtip32xx driver uses managed resources for DMA coherent memory
and irqs, but then always pairs them with free calls anyway, making
the resource tracking rather pointless.  Given some DMA allocations
are transient anyway, the irq freeing seems to require ordering vs
other hardware access the best solution seems to be to stop using
the managed resource API entirely.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent f17b5f06
...@@ -1415,7 +1415,7 @@ static blk_status_t mtip_send_trim(struct driver_data *dd, unsigned int lba, ...@@ -1415,7 +1415,7 @@ static blk_status_t mtip_send_trim(struct driver_data *dd, unsigned int lba,
WARN_ON(sizeof(struct mtip_trim) > ATA_SECT_SIZE); WARN_ON(sizeof(struct mtip_trim) > ATA_SECT_SIZE);
/* Allocate a DMA buffer for the trim structure */ /* Allocate a DMA buffer for the trim structure */
buf = dmam_alloc_coherent(&dd->pdev->dev, ATA_SECT_SIZE, &dma_addr, buf = dma_alloc_coherent(&dd->pdev->dev, ATA_SECT_SIZE, &dma_addr,
GFP_KERNEL); GFP_KERNEL);
if (!buf) if (!buf)
return BLK_STS_RESOURCE; return BLK_STS_RESOURCE;
...@@ -1452,7 +1452,7 @@ static blk_status_t mtip_send_trim(struct driver_data *dd, unsigned int lba, ...@@ -1452,7 +1452,7 @@ static blk_status_t mtip_send_trim(struct driver_data *dd, unsigned int lba,
MTIP_TRIM_TIMEOUT_MS) < 0) MTIP_TRIM_TIMEOUT_MS) < 0)
ret = BLK_STS_IOERR; ret = BLK_STS_IOERR;
dmam_free_coherent(&dd->pdev->dev, ATA_SECT_SIZE, buf, dma_addr); dma_free_coherent(&dd->pdev->dev, ATA_SECT_SIZE, buf, dma_addr);
return ret; return ret;
} }
...@@ -1655,7 +1655,7 @@ static int exec_drive_command(struct mtip_port *port, u8 *command, ...@@ -1655,7 +1655,7 @@ static int exec_drive_command(struct mtip_port *port, u8 *command,
if (!user_buffer) if (!user_buffer)
return -EFAULT; return -EFAULT;
buf = dmam_alloc_coherent(&port->dd->pdev->dev, buf = dma_alloc_coherent(&port->dd->pdev->dev,
ATA_SECT_SIZE * xfer_sz, ATA_SECT_SIZE * xfer_sz,
&dma_addr, &dma_addr,
GFP_KERNEL); GFP_KERNEL);
...@@ -1733,7 +1733,7 @@ static int exec_drive_command(struct mtip_port *port, u8 *command, ...@@ -1733,7 +1733,7 @@ static int exec_drive_command(struct mtip_port *port, u8 *command,
} }
exit_drive_command: exit_drive_command:
if (buf) if (buf)
dmam_free_coherent(&port->dd->pdev->dev, dma_free_coherent(&port->dd->pdev->dev,
ATA_SECT_SIZE * xfer_sz, buf, dma_addr); ATA_SECT_SIZE * xfer_sz, buf, dma_addr);
return rv; return rv;
} }
...@@ -2837,11 +2837,11 @@ static void mtip_dma_free(struct driver_data *dd) ...@@ -2837,11 +2837,11 @@ static void mtip_dma_free(struct driver_data *dd)
struct mtip_port *port = dd->port; struct mtip_port *port = dd->port;
if (port->block1) if (port->block1)
dmam_free_coherent(&dd->pdev->dev, BLOCK_DMA_ALLOC_SZ, dma_free_coherent(&dd->pdev->dev, BLOCK_DMA_ALLOC_SZ,
port->block1, port->block1_dma); port->block1, port->block1_dma);
if (port->command_list) { if (port->command_list) {
dmam_free_coherent(&dd->pdev->dev, AHCI_CMD_TBL_SZ, dma_free_coherent(&dd->pdev->dev, AHCI_CMD_TBL_SZ,
port->command_list, port->command_list_dma); port->command_list, port->command_list_dma);
} }
} }
...@@ -2860,7 +2860,7 @@ static int mtip_dma_alloc(struct driver_data *dd) ...@@ -2860,7 +2860,7 @@ static int mtip_dma_alloc(struct driver_data *dd)
/* Allocate dma memory for RX Fis, Identify, and Sector Bufffer */ /* Allocate dma memory for RX Fis, Identify, and Sector Bufffer */
port->block1 = port->block1 =
dmam_alloc_coherent(&dd->pdev->dev, BLOCK_DMA_ALLOC_SZ, dma_alloc_coherent(&dd->pdev->dev, BLOCK_DMA_ALLOC_SZ,
&port->block1_dma, GFP_KERNEL); &port->block1_dma, GFP_KERNEL);
if (!port->block1) if (!port->block1)
return -ENOMEM; return -ENOMEM;
...@@ -2868,10 +2868,10 @@ static int mtip_dma_alloc(struct driver_data *dd) ...@@ -2868,10 +2868,10 @@ static int mtip_dma_alloc(struct driver_data *dd)
/* Allocate dma memory for command list */ /* Allocate dma memory for command list */
port->command_list = port->command_list =
dmam_alloc_coherent(&dd->pdev->dev, AHCI_CMD_TBL_SZ, dma_alloc_coherent(&dd->pdev->dev, AHCI_CMD_TBL_SZ,
&port->command_list_dma, GFP_KERNEL); &port->command_list_dma, GFP_KERNEL);
if (!port->command_list) { if (!port->command_list) {
dmam_free_coherent(&dd->pdev->dev, BLOCK_DMA_ALLOC_SZ, dma_free_coherent(&dd->pdev->dev, BLOCK_DMA_ALLOC_SZ,
port->block1, port->block1_dma); port->block1, port->block1_dma);
port->block1 = NULL; port->block1 = NULL;
port->block1_dma = 0; port->block1_dma = 0;
...@@ -3056,13 +3056,8 @@ static int mtip_hw_init(struct driver_data *dd) ...@@ -3056,13 +3056,8 @@ static int mtip_hw_init(struct driver_data *dd)
mtip_start_port(dd->port); mtip_start_port(dd->port);
/* Setup the ISR and enable interrupts. */ /* Setup the ISR and enable interrupts. */
rv = devm_request_irq(&dd->pdev->dev, rv = request_irq(dd->pdev->irq, mtip_irq_handler, IRQF_SHARED,
dd->pdev->irq, dev_driver_string(&dd->pdev->dev), dd);
mtip_irq_handler,
IRQF_SHARED,
dev_driver_string(&dd->pdev->dev),
dd);
if (rv) { if (rv) {
dev_err(&dd->pdev->dev, dev_err(&dd->pdev->dev,
"Unable to allocate IRQ %d\n", dd->pdev->irq); "Unable to allocate IRQ %d\n", dd->pdev->irq);
...@@ -3090,7 +3085,7 @@ static int mtip_hw_init(struct driver_data *dd) ...@@ -3090,7 +3085,7 @@ static int mtip_hw_init(struct driver_data *dd)
/* Release the IRQ. */ /* Release the IRQ. */
irq_set_affinity_hint(dd->pdev->irq, NULL); irq_set_affinity_hint(dd->pdev->irq, NULL);
devm_free_irq(&dd->pdev->dev, dd->pdev->irq, dd); free_irq(dd->pdev->irq, dd);
out2: out2:
mtip_deinit_port(dd->port); mtip_deinit_port(dd->port);
...@@ -3145,7 +3140,7 @@ static int mtip_hw_exit(struct driver_data *dd) ...@@ -3145,7 +3140,7 @@ static int mtip_hw_exit(struct driver_data *dd)
/* Release the IRQ. */ /* Release the IRQ. */
irq_set_affinity_hint(dd->pdev->irq, NULL); irq_set_affinity_hint(dd->pdev->irq, NULL);
devm_free_irq(&dd->pdev->dev, dd->pdev->irq, dd); free_irq(dd->pdev->irq, dd);
msleep(1000); msleep(1000);
/* Free dma regions */ /* Free dma regions */
...@@ -3609,8 +3604,8 @@ static void mtip_free_cmd(struct blk_mq_tag_set *set, struct request *rq, ...@@ -3609,8 +3604,8 @@ static void mtip_free_cmd(struct blk_mq_tag_set *set, struct request *rq,
if (!cmd->command) if (!cmd->command)
return; return;
dmam_free_coherent(&dd->pdev->dev, CMD_DMA_ALLOC_SZ, dma_free_coherent(&dd->pdev->dev, CMD_DMA_ALLOC_SZ, cmd->command,
cmd->command, cmd->command_dma); cmd->command_dma);
} }
static int mtip_init_cmd(struct blk_mq_tag_set *set, struct request *rq, static int mtip_init_cmd(struct blk_mq_tag_set *set, struct request *rq,
...@@ -3619,7 +3614,7 @@ static int mtip_init_cmd(struct blk_mq_tag_set *set, struct request *rq, ...@@ -3619,7 +3614,7 @@ static int mtip_init_cmd(struct blk_mq_tag_set *set, struct request *rq,
struct driver_data *dd = set->driver_data; struct driver_data *dd = set->driver_data;
struct mtip_cmd *cmd = blk_mq_rq_to_pdu(rq); struct mtip_cmd *cmd = blk_mq_rq_to_pdu(rq);
cmd->command = dmam_alloc_coherent(&dd->pdev->dev, CMD_DMA_ALLOC_SZ, cmd->command = dma_alloc_coherent(&dd->pdev->dev, CMD_DMA_ALLOC_SZ,
&cmd->command_dma, GFP_KERNEL); &cmd->command_dma, GFP_KERNEL);
if (!cmd->command) if (!cmd->command)
return -ENOMEM; return -ENOMEM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment