Skip to content

Commit 5c5e6b6

Browse files
tititiou36martinkpetersen
authored andcommitted
scsi: message: fusion: mptbase: Use dma_alloc_coherent()
In [1], Christoph Hellwig has proposed to remove the wrappers in include/linux/pci-dma-compat.h. Some reasons why this API should be removed have been given by Julia Lawall in [2]. In all these places where some memory is allocated GFP_KERNEL can be used because they already call mpt_config() which has an explicit might_sleep(). [1]: https://lore.kernel.org/kernel-janitors/20200421081257.GA131897@infradead.org/ [2]: https://lore.kernel.org/kernel-janitors/alpine.DEB.2.22.394.2007120902170.2424@hadrien/ Link: https://lore.kernel.org/r/3bea2452deb8cc8be65982e87efa4c6861caa01c.1641500561.git.christophe.jaillet@wanadoo.fr Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 2d50607 commit 5c5e6b6

File tree

1 file changed

+32
-20
lines changed

1 file changed

+32
-20
lines changed

drivers/message/fusion/mptbase.c

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,8 @@ mpt_is_discovery_complete(MPT_ADAPTER *ioc)
300300
if (!hdr.ExtPageLength)
301301
goto out;
302302

303-
buffer = pci_alloc_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
304-
&dma_handle);
303+
buffer = dma_alloc_coherent(&ioc->pcidev->dev, hdr.ExtPageLength * 4,
304+
&dma_handle, GFP_KERNEL);
305305
if (!buffer)
306306
goto out;
307307

@@ -4966,7 +4966,8 @@ GetLanConfigPages(MPT_ADAPTER *ioc)
49664966

49674967
if (hdr.PageLength > 0) {
49684968
data_sz = hdr.PageLength * 4;
4969-
ppage0_alloc = pci_alloc_consistent(ioc->pcidev, data_sz, &page0_dma);
4969+
ppage0_alloc = dma_alloc_coherent(&ioc->pcidev->dev, data_sz,
4970+
&page0_dma, GFP_KERNEL);
49704971
rc = -ENOMEM;
49714972
if (ppage0_alloc) {
49724973
memset((u8 *)ppage0_alloc, 0, data_sz);
@@ -5013,7 +5014,8 @@ GetLanConfigPages(MPT_ADAPTER *ioc)
50135014

50145015
data_sz = hdr.PageLength * 4;
50155016
rc = -ENOMEM;
5016-
ppage1_alloc = pci_alloc_consistent(ioc->pcidev, data_sz, &page1_dma);
5017+
ppage1_alloc = dma_alloc_coherent(&ioc->pcidev->dev, data_sz,
5018+
&page1_dma, GFP_KERNEL);
50175019
if (ppage1_alloc) {
50185020
memset((u8 *)ppage1_alloc, 0, data_sz);
50195021
cfg.physAddr = page1_dma;
@@ -5315,7 +5317,8 @@ GetIoUnitPage2(MPT_ADAPTER *ioc)
53155317
/* Read the config page */
53165318
data_sz = hdr.PageLength * 4;
53175319
rc = -ENOMEM;
5318-
ppage_alloc = pci_alloc_consistent(ioc->pcidev, data_sz, &page_dma);
5320+
ppage_alloc = dma_alloc_coherent(&ioc->pcidev->dev, data_sz,
5321+
&page_dma, GFP_KERNEL);
53195322
if (ppage_alloc) {
53205323
memset((u8 *)ppage_alloc, 0, data_sz);
53215324
cfg.physAddr = page_dma;
@@ -5401,7 +5404,9 @@ mpt_GetScsiPortSettings(MPT_ADAPTER *ioc, int portnum)
54015404
return -EFAULT;
54025405

54035406
if (header.PageLength > 0) {
5404-
pbuf = pci_alloc_consistent(ioc->pcidev, header.PageLength * 4, &buf_dma);
5407+
pbuf = dma_alloc_coherent(&ioc->pcidev->dev,
5408+
header.PageLength * 4, &buf_dma,
5409+
GFP_KERNEL);
54055410
if (pbuf) {
54065411
cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT;
54075412
cfg.physAddr = buf_dma;
@@ -5481,7 +5486,9 @@ mpt_GetScsiPortSettings(MPT_ADAPTER *ioc, int portnum)
54815486
if (header.PageLength > 0) {
54825487
/* Allocate memory and read SCSI Port Page 2
54835488
*/
5484-
pbuf = pci_alloc_consistent(ioc->pcidev, header.PageLength * 4, &buf_dma);
5489+
pbuf = dma_alloc_coherent(&ioc->pcidev->dev,
5490+
header.PageLength * 4, &buf_dma,
5491+
GFP_KERNEL);
54855492
if (pbuf) {
54865493
cfg.action = MPI_CONFIG_ACTION_PAGE_READ_NVRAM;
54875494
cfg.physAddr = buf_dma;
@@ -5664,8 +5671,8 @@ mpt_inactive_raid_volumes(MPT_ADAPTER *ioc, u8 channel, u8 id)
56645671
if (!hdr.PageLength)
56655672
goto out;
56665673

5667-
buffer = pci_alloc_consistent(ioc->pcidev, hdr.PageLength * 4,
5668-
&dma_handle);
5674+
buffer = dma_alloc_coherent(&ioc->pcidev->dev, hdr.PageLength * 4,
5675+
&dma_handle, GFP_KERNEL);
56695676

56705677
if (!buffer)
56715678
goto out;
@@ -5757,8 +5764,8 @@ mpt_raid_phys_disk_pg0(MPT_ADAPTER *ioc, u8 phys_disk_num,
57575764
goto out;
57585765
}
57595766

5760-
buffer = pci_alloc_consistent(ioc->pcidev, hdr.PageLength * 4,
5761-
&dma_handle);
5767+
buffer = dma_alloc_coherent(&ioc->pcidev->dev, hdr.PageLength * 4,
5768+
&dma_handle, GFP_KERNEL);
57625769

57635770
if (!buffer) {
57645771
rc = -ENOMEM;
@@ -5824,8 +5831,8 @@ mpt_raid_phys_disk_get_num_paths(MPT_ADAPTER *ioc, u8 phys_disk_num)
58245831
goto out;
58255832
}
58265833

5827-
buffer = pci_alloc_consistent(ioc->pcidev, hdr.PageLength * 4,
5828-
&dma_handle);
5834+
buffer = dma_alloc_coherent(&ioc->pcidev->dev, hdr.PageLength * 4,
5835+
&dma_handle, GFP_KERNEL);
58295836

58305837
if (!buffer) {
58315838
rc = 0;
@@ -5896,8 +5903,8 @@ mpt_raid_phys_disk_pg1(MPT_ADAPTER *ioc, u8 phys_disk_num,
58965903
goto out;
58975904
}
58985905

5899-
buffer = pci_alloc_consistent(ioc->pcidev, hdr.PageLength * 4,
5900-
&dma_handle);
5906+
buffer = dma_alloc_coherent(&ioc->pcidev->dev, hdr.PageLength * 4,
5907+
&dma_handle, GFP_KERNEL);
59015908

59025909
if (!buffer) {
59035910
rc = -ENOMEM;
@@ -5991,7 +5998,8 @@ mpt_findImVolumes(MPT_ADAPTER *ioc)
59915998
return -EFAULT;
59925999

59936000
iocpage2sz = header.PageLength * 4;
5994-
pIoc2 = pci_alloc_consistent(ioc->pcidev, iocpage2sz, &ioc2_dma);
6001+
pIoc2 = dma_alloc_coherent(&ioc->pcidev->dev, iocpage2sz, &ioc2_dma,
6002+
GFP_KERNEL);
59956003
if (!pIoc2)
59966004
return -ENOMEM;
59976005

@@ -6058,7 +6066,8 @@ mpt_read_ioc_pg_3(MPT_ADAPTER *ioc)
60586066
/* Read Header good, alloc memory
60596067
*/
60606068
iocpage3sz = header.PageLength * 4;
6061-
pIoc3 = pci_alloc_consistent(ioc->pcidev, iocpage3sz, &ioc3_dma);
6069+
pIoc3 = dma_alloc_coherent(&ioc->pcidev->dev, iocpage3sz, &ioc3_dma,
6070+
GFP_KERNEL);
60626071
if (!pIoc3)
60636072
return 0;
60646073

@@ -6109,7 +6118,8 @@ mpt_read_ioc_pg_4(MPT_ADAPTER *ioc)
61096118

61106119
if ( (pIoc4 = ioc->spi_data.pIocPg4) == NULL ) {
61116120
iocpage4sz = (header.PageLength + 4) * 4; /* Allow 4 additional SEP's */
6112-
pIoc4 = pci_alloc_consistent(ioc->pcidev, iocpage4sz, &ioc4_dma);
6121+
pIoc4 = dma_alloc_coherent(&ioc->pcidev->dev, iocpage4sz,
6122+
&ioc4_dma, GFP_KERNEL);
61136123
if (!pIoc4)
61146124
return;
61156125
ioc->alloc_total += iocpage4sz;
@@ -6165,7 +6175,8 @@ mpt_read_ioc_pg_1(MPT_ADAPTER *ioc)
61656175
/* Read Header good, alloc memory
61666176
*/
61676177
iocpage1sz = header.PageLength * 4;
6168-
pIoc1 = pci_alloc_consistent(ioc->pcidev, iocpage1sz, &ioc1_dma);
6178+
pIoc1 = dma_alloc_coherent(&ioc->pcidev->dev, iocpage1sz, &ioc1_dma,
6179+
GFP_KERNEL);
61696180
if (!pIoc1)
61706181
return;
61716182

@@ -6245,7 +6256,8 @@ mpt_get_manufacturing_pg_0(MPT_ADAPTER *ioc)
62456256
goto out;
62466257

62476258
cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT;
6248-
pbuf = pci_alloc_consistent(ioc->pcidev, hdr.PageLength * 4, &buf_dma);
6259+
pbuf = dma_alloc_coherent(&ioc->pcidev->dev, hdr.PageLength * 4,
6260+
&buf_dma, GFP_KERNEL);
62496261
if (!pbuf)
62506262
goto out;
62516263

0 commit comments

Comments
 (0)