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

device property: ACPI: Make use of the new DMA Attribute APIs

Now that we have the new DMA attribute APIs, we can replace the older
acpi_check_dma() and device_dma_is_coherent().

Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Hanjun Guo <hanjun.guo@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Suthikulpanit, Suravee and committed by
Rafael J. Wysocki
1831eff8 e5e55864

+31 -11
+6 -1
drivers/acpi/acpi_platform.c
··· 103 103 pdevinfo.res = resources; 104 104 pdevinfo.num_res = count; 105 105 pdevinfo.fwnode = acpi_fwnode_handle(adev); 106 - pdevinfo.dma_mask = acpi_check_dma(adev, NULL) ? DMA_BIT_MASK(32) : 0; 106 + 107 + if (acpi_dma_supported(adev)) 108 + pdevinfo.dma_mask = DMA_BIT_MASK(32); 109 + else 110 + pdevinfo.dma_mask = 0; 111 + 107 112 pdev = platform_device_register_full(&pdevinfo); 108 113 if (IS_ERR(pdev)) 109 114 dev_err(&adev->dev, "platform device creation failed: %ld\n",
+5 -3
drivers/acpi/glue.c
··· 168 168 struct list_head *physnode_list; 169 169 unsigned int node_id; 170 170 int retval = -EINVAL; 171 - bool coherent; 171 + enum dev_dma_attr attr; 172 172 173 173 if (has_acpi_companion(dev)) { 174 174 if (acpi_dev) { ··· 225 225 if (!has_acpi_companion(dev)) 226 226 ACPI_COMPANION_SET(dev, acpi_dev); 227 227 228 - if (acpi_check_dma(acpi_dev, &coherent)) 229 - arch_setup_dma_ops(dev, 0, 0, NULL, coherent); 228 + attr = acpi_get_dma_attr(acpi_dev); 229 + if (attr != DEV_DMA_NOT_SUPPORTED) 230 + arch_setup_dma_ops(dev, 0, 0, NULL, 231 + attr == DEV_DMA_COHERENT); 230 232 231 233 acpi_physnode_link_name(physical_node_name, node_id); 232 234 retval = sysfs_create_link(&acpi_dev->dev.kobj, &dev->kobj,
+13 -6
drivers/crypto/ccp/ccp-platform.c
··· 96 96 struct ccp_platform *ccp_platform; 97 97 struct device *dev = &pdev->dev; 98 98 struct acpi_device *adev = ACPI_COMPANION(dev); 99 + enum dev_dma_attr attr; 99 100 struct resource *ior; 100 101 int ret; 101 102 ··· 123 122 } 124 123 ccp->io_regs = ccp->io_map; 125 124 125 + attr = device_get_dma_attr(dev); 126 + if (attr == DEV_DMA_NOT_SUPPORTED) { 127 + dev_err(dev, "DMA is not supported"); 128 + goto e_err; 129 + } 130 + 131 + ccp_platform->coherent = (attr == DEV_DMA_COHERENT); 132 + if (ccp_platform->coherent) 133 + ccp->axcache = CACHE_WB_NO_ALLOC; 134 + else 135 + ccp->axcache = CACHE_NONE; 136 + 126 137 ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(48)); 127 138 if (ret) { 128 139 dev_err(dev, "dma_set_mask_and_coherent failed (%d)\n", ret); 129 140 goto e_err; 130 141 } 131 - 132 - ccp_platform->coherent = device_dma_is_coherent(ccp->dev); 133 - if (ccp_platform->coherent) 134 - ccp->axcache = CACHE_WB_NO_ALLOC; 135 - else 136 - ccp->axcache = CACHE_NONE; 137 142 138 143 dev_set_drvdata(dev, ccp); 139 144
+7 -1
drivers/net/ethernet/amd/xgbe/xgbe-main.c
··· 342 342 struct resource *res; 343 343 const char *phy_mode; 344 344 unsigned int i, phy_memnum, phy_irqnum; 345 + enum dev_dma_attr attr; 345 346 int ret; 346 347 347 348 DBGPR("--> xgbe_probe\n"); ··· 610 609 goto err_io; 611 610 612 611 /* Set the DMA coherency values */ 613 - pdata->coherent = device_dma_is_coherent(pdata->dev); 612 + attr = device_get_dma_attr(dev); 613 + if (attr == DEV_DMA_NOT_SUPPORTED) { 614 + dev_err(dev, "DMA is not supported"); 615 + goto err_io; 616 + } 617 + pdata->coherent = (attr == DEV_DMA_COHERENT); 614 618 if (pdata->coherent) { 615 619 pdata->axdomain = XGBE_DMA_OS_AXDOMAIN; 616 620 pdata->arcache = XGBE_DMA_OS_ARCACHE;