Skip to content

Commit

Permalink
device property: ACPI: Make use of the new DMA Attribute APIs
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Suthikulpanit, Suravee authored and Rafael J. Wysocki committed Nov 7, 2015
1 parent e5e5586 commit 1831eff
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 9 deletions.
7 changes: 6 additions & 1 deletion drivers/acpi/acpi_platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,12 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev)
pdevinfo.res = resources;
pdevinfo.num_res = count;
pdevinfo.fwnode = acpi_fwnode_handle(adev);
pdevinfo.dma_mask = acpi_check_dma(adev, NULL) ? DMA_BIT_MASK(32) : 0;

if (acpi_dma_supported(adev))
pdevinfo.dma_mask = DMA_BIT_MASK(32);
else
pdevinfo.dma_mask = 0;

pdev = platform_device_register_full(&pdevinfo);
if (IS_ERR(pdev))
dev_err(&adev->dev, "platform device creation failed: %ld\n",
Expand Down
8 changes: 5 additions & 3 deletions drivers/acpi/glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ int acpi_bind_one(struct device *dev, struct acpi_device *acpi_dev)
struct list_head *physnode_list;
unsigned int node_id;
int retval = -EINVAL;
bool coherent;
enum dev_dma_attr attr;

if (has_acpi_companion(dev)) {
if (acpi_dev) {
Expand Down Expand Up @@ -225,8 +225,10 @@ int acpi_bind_one(struct device *dev, struct acpi_device *acpi_dev)
if (!has_acpi_companion(dev))
ACPI_COMPANION_SET(dev, acpi_dev);

if (acpi_check_dma(acpi_dev, &coherent))
arch_setup_dma_ops(dev, 0, 0, NULL, coherent);
attr = acpi_get_dma_attr(acpi_dev);
if (attr != DEV_DMA_NOT_SUPPORTED)
arch_setup_dma_ops(dev, 0, 0, NULL,
attr == DEV_DMA_COHERENT);

acpi_physnode_link_name(physical_node_name, node_id);
retval = sysfs_create_link(&acpi_dev->dev.kobj, &dev->kobj,
Expand Down
15 changes: 11 additions & 4 deletions drivers/crypto/ccp/ccp-platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ static int ccp_platform_probe(struct platform_device *pdev)
struct ccp_platform *ccp_platform;
struct device *dev = &pdev->dev;
struct acpi_device *adev = ACPI_COMPANION(dev);
enum dev_dma_attr attr;
struct resource *ior;
int ret;

Expand All @@ -122,18 +123,24 @@ static int ccp_platform_probe(struct platform_device *pdev)
}
ccp->io_regs = ccp->io_map;

ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(48));
if (ret) {
dev_err(dev, "dma_set_mask_and_coherent failed (%d)\n", ret);
attr = device_get_dma_attr(dev);
if (attr == DEV_DMA_NOT_SUPPORTED) {
dev_err(dev, "DMA is not supported");
goto e_err;
}

ccp_platform->coherent = device_dma_is_coherent(ccp->dev);
ccp_platform->coherent = (attr == DEV_DMA_COHERENT);
if (ccp_platform->coherent)
ccp->axcache = CACHE_WB_NO_ALLOC;
else
ccp->axcache = CACHE_NONE;

ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(48));
if (ret) {
dev_err(dev, "dma_set_mask_and_coherent failed (%d)\n", ret);
goto e_err;
}

dev_set_drvdata(dev, ccp);

ret = ccp_init(ccp);
Expand Down
8 changes: 7 additions & 1 deletion drivers/net/ethernet/amd/xgbe/xgbe-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ static int xgbe_probe(struct platform_device *pdev)
struct resource *res;
const char *phy_mode;
unsigned int i, phy_memnum, phy_irqnum;
enum dev_dma_attr attr;
int ret;

DBGPR("--> xgbe_probe\n");
Expand Down Expand Up @@ -609,7 +610,12 @@ static int xgbe_probe(struct platform_device *pdev)
goto err_io;

/* Set the DMA coherency values */
pdata->coherent = device_dma_is_coherent(pdata->dev);
attr = device_get_dma_attr(dev);
if (attr == DEV_DMA_NOT_SUPPORTED) {
dev_err(dev, "DMA is not supported");
goto err_io;
}
pdata->coherent = (attr == DEV_DMA_COHERENT);
if (pdata->coherent) {
pdata->axdomain = XGBE_DMA_OS_AXDOMAIN;
pdata->arcache = XGBE_DMA_OS_ARCACHE;
Expand Down

0 comments on commit 1831eff

Please sign in to comment.