Skip to content

Commit 22cb4e6

Browse files
Christoph Hellwigaxboe
authored andcommitted
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: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent f17b5f0 commit 22cb4e6

File tree

1 file changed

+16
-21
lines changed

1 file changed

+16
-21
lines changed

drivers/block/mtip32xx/mtip32xx.c

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,7 +1415,7 @@ static blk_status_t mtip_send_trim(struct driver_data *dd, unsigned int lba,
14151415
WARN_ON(sizeof(struct mtip_trim) > ATA_SECT_SIZE);
14161416

14171417
/* Allocate a DMA buffer for the trim structure */
1418-
buf = dmam_alloc_coherent(&dd->pdev->dev, ATA_SECT_SIZE, &dma_addr,
1418+
buf = dma_alloc_coherent(&dd->pdev->dev, ATA_SECT_SIZE, &dma_addr,
14191419
GFP_KERNEL);
14201420
if (!buf)
14211421
return BLK_STS_RESOURCE;
@@ -1452,7 +1452,7 @@ static blk_status_t mtip_send_trim(struct driver_data *dd, unsigned int lba,
14521452
MTIP_TRIM_TIMEOUT_MS) < 0)
14531453
ret = BLK_STS_IOERR;
14541454

1455-
dmam_free_coherent(&dd->pdev->dev, ATA_SECT_SIZE, buf, dma_addr);
1455+
dma_free_coherent(&dd->pdev->dev, ATA_SECT_SIZE, buf, dma_addr);
14561456
return ret;
14571457
}
14581458

@@ -1655,7 +1655,7 @@ static int exec_drive_command(struct mtip_port *port, u8 *command,
16551655
if (!user_buffer)
16561656
return -EFAULT;
16571657

1658-
buf = dmam_alloc_coherent(&port->dd->pdev->dev,
1658+
buf = dma_alloc_coherent(&port->dd->pdev->dev,
16591659
ATA_SECT_SIZE * xfer_sz,
16601660
&dma_addr,
16611661
GFP_KERNEL);
@@ -1733,7 +1733,7 @@ static int exec_drive_command(struct mtip_port *port, u8 *command,
17331733
}
17341734
exit_drive_command:
17351735
if (buf)
1736-
dmam_free_coherent(&port->dd->pdev->dev,
1736+
dma_free_coherent(&port->dd->pdev->dev,
17371737
ATA_SECT_SIZE * xfer_sz, buf, dma_addr);
17381738
return rv;
17391739
}
@@ -2837,11 +2837,11 @@ static void mtip_dma_free(struct driver_data *dd)
28372837
struct mtip_port *port = dd->port;
28382838

28392839
if (port->block1)
2840-
dmam_free_coherent(&dd->pdev->dev, BLOCK_DMA_ALLOC_SZ,
2840+
dma_free_coherent(&dd->pdev->dev, BLOCK_DMA_ALLOC_SZ,
28412841
port->block1, port->block1_dma);
28422842

28432843
if (port->command_list) {
2844-
dmam_free_coherent(&dd->pdev->dev, AHCI_CMD_TBL_SZ,
2844+
dma_free_coherent(&dd->pdev->dev, AHCI_CMD_TBL_SZ,
28452845
port->command_list, port->command_list_dma);
28462846
}
28472847
}
@@ -2860,18 +2860,18 @@ static int mtip_dma_alloc(struct driver_data *dd)
28602860

28612861
/* Allocate dma memory for RX Fis, Identify, and Sector Bufffer */
28622862
port->block1 =
2863-
dmam_alloc_coherent(&dd->pdev->dev, BLOCK_DMA_ALLOC_SZ,
2863+
dma_alloc_coherent(&dd->pdev->dev, BLOCK_DMA_ALLOC_SZ,
28642864
&port->block1_dma, GFP_KERNEL);
28652865
if (!port->block1)
28662866
return -ENOMEM;
28672867
memset(port->block1, 0, BLOCK_DMA_ALLOC_SZ);
28682868

28692869
/* Allocate dma memory for command list */
28702870
port->command_list =
2871-
dmam_alloc_coherent(&dd->pdev->dev, AHCI_CMD_TBL_SZ,
2871+
dma_alloc_coherent(&dd->pdev->dev, AHCI_CMD_TBL_SZ,
28722872
&port->command_list_dma, GFP_KERNEL);
28732873
if (!port->command_list) {
2874-
dmam_free_coherent(&dd->pdev->dev, BLOCK_DMA_ALLOC_SZ,
2874+
dma_free_coherent(&dd->pdev->dev, BLOCK_DMA_ALLOC_SZ,
28752875
port->block1, port->block1_dma);
28762876
port->block1 = NULL;
28772877
port->block1_dma = 0;
@@ -3056,13 +3056,8 @@ static int mtip_hw_init(struct driver_data *dd)
30563056
mtip_start_port(dd->port);
30573057

30583058
/* Setup the ISR and enable interrupts. */
3059-
rv = devm_request_irq(&dd->pdev->dev,
3060-
dd->pdev->irq,
3061-
mtip_irq_handler,
3062-
IRQF_SHARED,
3063-
dev_driver_string(&dd->pdev->dev),
3064-
dd);
3065-
3059+
rv = request_irq(dd->pdev->irq, mtip_irq_handler, IRQF_SHARED,
3060+
dev_driver_string(&dd->pdev->dev), dd);
30663061
if (rv) {
30673062
dev_err(&dd->pdev->dev,
30683063
"Unable to allocate IRQ %d\n", dd->pdev->irq);
@@ -3090,7 +3085,7 @@ static int mtip_hw_init(struct driver_data *dd)
30903085

30913086
/* Release the IRQ. */
30923087
irq_set_affinity_hint(dd->pdev->irq, NULL);
3093-
devm_free_irq(&dd->pdev->dev, dd->pdev->irq, dd);
3088+
free_irq(dd->pdev->irq, dd);
30943089

30953090
out2:
30963091
mtip_deinit_port(dd->port);
@@ -3145,7 +3140,7 @@ static int mtip_hw_exit(struct driver_data *dd)
31453140

31463141
/* Release the IRQ. */
31473142
irq_set_affinity_hint(dd->pdev->irq, NULL);
3148-
devm_free_irq(&dd->pdev->dev, dd->pdev->irq, dd);
3143+
free_irq(dd->pdev->irq, dd);
31493144
msleep(1000);
31503145

31513146
/* Free dma regions */
@@ -3609,8 +3604,8 @@ static void mtip_free_cmd(struct blk_mq_tag_set *set, struct request *rq,
36093604
if (!cmd->command)
36103605
return;
36113606

3612-
dmam_free_coherent(&dd->pdev->dev, CMD_DMA_ALLOC_SZ,
3613-
cmd->command, cmd->command_dma);
3607+
dma_free_coherent(&dd->pdev->dev, CMD_DMA_ALLOC_SZ, cmd->command,
3608+
cmd->command_dma);
36143609
}
36153610

36163611
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,
36193614
struct driver_data *dd = set->driver_data;
36203615
struct mtip_cmd *cmd = blk_mq_rq_to_pdu(rq);
36213616

3622-
cmd->command = dmam_alloc_coherent(&dd->pdev->dev, CMD_DMA_ALLOC_SZ,
3617+
cmd->command = dma_alloc_coherent(&dd->pdev->dev, CMD_DMA_ALLOC_SZ,
36233618
&cmd->command_dma, GFP_KERNEL);
36243619
if (!cmd->command)
36253620
return -ENOMEM;

0 commit comments

Comments
 (0)