Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Christophe JAILLET and committed by
Martin K. Petersen
5c5e6b6f 2d506072

+32 -20
+32 -20
drivers/message/fusion/mptbase.c
··· 300 300 if (!hdr.ExtPageLength) 301 301 goto out; 302 302 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); 305 305 if (!buffer) 306 306 goto out; 307 307 ··· 4966 4966 4967 4967 if (hdr.PageLength > 0) { 4968 4968 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); 4970 4971 rc = -ENOMEM; 4971 4972 if (ppage0_alloc) { 4972 4973 memset((u8 *)ppage0_alloc, 0, data_sz); ··· 5014 5013 5015 5014 data_sz = hdr.PageLength * 4; 5016 5015 rc = -ENOMEM; 5017 - ppage1_alloc = pci_alloc_consistent(ioc->pcidev, data_sz, &page1_dma); 5016 + ppage1_alloc = dma_alloc_coherent(&ioc->pcidev->dev, data_sz, 5017 + &page1_dma, GFP_KERNEL); 5018 5018 if (ppage1_alloc) { 5019 5019 memset((u8 *)ppage1_alloc, 0, data_sz); 5020 5020 cfg.physAddr = page1_dma; ··· 5317 5315 /* Read the config page */ 5318 5316 data_sz = hdr.PageLength * 4; 5319 5317 rc = -ENOMEM; 5320 - ppage_alloc = pci_alloc_consistent(ioc->pcidev, data_sz, &page_dma); 5318 + ppage_alloc = dma_alloc_coherent(&ioc->pcidev->dev, data_sz, 5319 + &page_dma, GFP_KERNEL); 5321 5320 if (ppage_alloc) { 5322 5321 memset((u8 *)ppage_alloc, 0, data_sz); 5323 5322 cfg.physAddr = page_dma; ··· 5404 5401 return -EFAULT; 5405 5402 5406 5403 if (header.PageLength > 0) { 5407 - pbuf = pci_alloc_consistent(ioc->pcidev, header.PageLength * 4, &buf_dma); 5404 + pbuf = dma_alloc_coherent(&ioc->pcidev->dev, 5405 + header.PageLength * 4, &buf_dma, 5406 + GFP_KERNEL); 5408 5407 if (pbuf) { 5409 5408 cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT; 5410 5409 cfg.physAddr = buf_dma; ··· 5486 5481 if (header.PageLength > 0) { 5487 5482 /* Allocate memory and read SCSI Port Page 2 5488 5483 */ 5489 - pbuf = pci_alloc_consistent(ioc->pcidev, header.PageLength * 4, &buf_dma); 5484 + pbuf = dma_alloc_coherent(&ioc->pcidev->dev, 5485 + header.PageLength * 4, &buf_dma, 5486 + GFP_KERNEL); 5490 5487 if (pbuf) { 5491 5488 cfg.action = MPI_CONFIG_ACTION_PAGE_READ_NVRAM; 5492 5489 cfg.physAddr = buf_dma; ··· 5671 5664 if (!hdr.PageLength) 5672 5665 goto out; 5673 5666 5674 - buffer = pci_alloc_consistent(ioc->pcidev, hdr.PageLength * 4, 5675 - &dma_handle); 5667 + buffer = dma_alloc_coherent(&ioc->pcidev->dev, hdr.PageLength * 4, 5668 + &dma_handle, GFP_KERNEL); 5676 5669 5677 5670 if (!buffer) 5678 5671 goto out; ··· 5764 5757 goto out; 5765 5758 } 5766 5759 5767 - buffer = pci_alloc_consistent(ioc->pcidev, hdr.PageLength * 4, 5768 - &dma_handle); 5760 + buffer = dma_alloc_coherent(&ioc->pcidev->dev, hdr.PageLength * 4, 5761 + &dma_handle, GFP_KERNEL); 5769 5762 5770 5763 if (!buffer) { 5771 5764 rc = -ENOMEM; ··· 5831 5824 goto out; 5832 5825 } 5833 5826 5834 - buffer = pci_alloc_consistent(ioc->pcidev, hdr.PageLength * 4, 5835 - &dma_handle); 5827 + buffer = dma_alloc_coherent(&ioc->pcidev->dev, hdr.PageLength * 4, 5828 + &dma_handle, GFP_KERNEL); 5836 5829 5837 5830 if (!buffer) { 5838 5831 rc = 0; ··· 5903 5896 goto out; 5904 5897 } 5905 5898 5906 - buffer = pci_alloc_consistent(ioc->pcidev, hdr.PageLength * 4, 5907 - &dma_handle); 5899 + buffer = dma_alloc_coherent(&ioc->pcidev->dev, hdr.PageLength * 4, 5900 + &dma_handle, GFP_KERNEL); 5908 5901 5909 5902 if (!buffer) { 5910 5903 rc = -ENOMEM; ··· 5998 5991 return -EFAULT; 5999 5992 6000 5993 iocpage2sz = header.PageLength * 4; 6001 - pIoc2 = pci_alloc_consistent(ioc->pcidev, iocpage2sz, &ioc2_dma); 5994 + pIoc2 = dma_alloc_coherent(&ioc->pcidev->dev, iocpage2sz, &ioc2_dma, 5995 + GFP_KERNEL); 6002 5996 if (!pIoc2) 6003 5997 return -ENOMEM; 6004 5998 ··· 6066 6058 /* Read Header good, alloc memory 6067 6059 */ 6068 6060 iocpage3sz = header.PageLength * 4; 6069 - pIoc3 = pci_alloc_consistent(ioc->pcidev, iocpage3sz, &ioc3_dma); 6061 + pIoc3 = dma_alloc_coherent(&ioc->pcidev->dev, iocpage3sz, &ioc3_dma, 6062 + GFP_KERNEL); 6070 6063 if (!pIoc3) 6071 6064 return 0; 6072 6065 ··· 6118 6109 6119 6110 if ( (pIoc4 = ioc->spi_data.pIocPg4) == NULL ) { 6120 6111 iocpage4sz = (header.PageLength + 4) * 4; /* Allow 4 additional SEP's */ 6121 - pIoc4 = pci_alloc_consistent(ioc->pcidev, iocpage4sz, &ioc4_dma); 6112 + pIoc4 = dma_alloc_coherent(&ioc->pcidev->dev, iocpage4sz, 6113 + &ioc4_dma, GFP_KERNEL); 6122 6114 if (!pIoc4) 6123 6115 return; 6124 6116 ioc->alloc_total += iocpage4sz; ··· 6175 6165 /* Read Header good, alloc memory 6176 6166 */ 6177 6167 iocpage1sz = header.PageLength * 4; 6178 - pIoc1 = pci_alloc_consistent(ioc->pcidev, iocpage1sz, &ioc1_dma); 6168 + pIoc1 = dma_alloc_coherent(&ioc->pcidev->dev, iocpage1sz, &ioc1_dma, 6169 + GFP_KERNEL); 6179 6170 if (!pIoc1) 6180 6171 return; 6181 6172 ··· 6256 6245 goto out; 6257 6246 6258 6247 cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT; 6259 - pbuf = pci_alloc_consistent(ioc->pcidev, hdr.PageLength * 4, &buf_dma); 6248 + pbuf = dma_alloc_coherent(&ioc->pcidev->dev, hdr.PageLength * 4, 6249 + &buf_dma, GFP_KERNEL); 6260 6250 if (!pbuf) 6261 6251 goto out; 6262 6252