mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-05-24 10:39:52 +00:00
of: restricted dma: Don't fail device probe on rmem init failure
If CONFIG_DMA_RESTRICTED_POOL=n then probing a device with a reference to a "restricted-dma-pool" will fail with a reasonably cryptic error: | pci-host-generic: probe of 10000.pci failed with error -22 Rework of_dma_set_restricted_buffer() so that it does not cause probing failure and instead either returns early if CONFIG_DMA_RESTRICTED_POOL=n or emits a diagnostic if the reserved DMA pool fails to initialise. Cc: Claire Chang <tientzu@chromium.org> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Cc: Christoph Hellwig <hch@lst.de> Cc: Rob Herring <robh+dt@kernel.org> Cc: Robin Murphy <robin.murphy@arm.com> Signed-off-by: Will Deacon <will@kernel.org> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
This commit is contained in:
parent
ce5cb67c66
commit
f3cfd136ae
1 changed files with 8 additions and 5 deletions
|
@ -53,12 +53,15 @@ int of_device_add(struct platform_device *ofdev)
|
||||||
return device_add(&ofdev->dev);
|
return device_add(&ofdev->dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static void
|
||||||
of_dma_set_restricted_buffer(struct device *dev, struct device_node *np)
|
of_dma_set_restricted_buffer(struct device *dev, struct device_node *np)
|
||||||
{
|
{
|
||||||
struct device_node *node, *of_node = dev->of_node;
|
struct device_node *node, *of_node = dev->of_node;
|
||||||
int count, i;
|
int count, i;
|
||||||
|
|
||||||
|
if (!IS_ENABLED(CONFIG_DMA_RESTRICTED_POOL))
|
||||||
|
return;
|
||||||
|
|
||||||
count = of_property_count_elems_of_size(of_node, "memory-region",
|
count = of_property_count_elems_of_size(of_node, "memory-region",
|
||||||
sizeof(u32));
|
sizeof(u32));
|
||||||
/*
|
/*
|
||||||
|
@ -79,11 +82,11 @@ of_dma_set_restricted_buffer(struct device *dev, struct device_node *np)
|
||||||
*/
|
*/
|
||||||
if (of_device_is_compatible(node, "restricted-dma-pool") &&
|
if (of_device_is_compatible(node, "restricted-dma-pool") &&
|
||||||
of_device_is_available(node))
|
of_device_is_available(node))
|
||||||
return of_reserved_mem_device_init_by_idx(dev, of_node,
|
break;
|
||||||
i);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
if (i != count && of_reserved_mem_device_init_by_idx(dev, of_node, i))
|
||||||
|
dev_warn(dev, "failed to initialise \"restricted-dma-pool\" memory node\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -200,7 +203,7 @@ int of_dma_configure_id(struct device *dev, struct device_node *np,
|
||||||
arch_setup_dma_ops(dev, dma_start, size, iommu, coherent);
|
arch_setup_dma_ops(dev, dma_start, size, iommu, coherent);
|
||||||
|
|
||||||
if (!iommu)
|
if (!iommu)
|
||||||
return of_dma_set_restricted_buffer(dev, np);
|
of_dma_set_restricted_buffer(dev, np);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue