ACPI/IORT: Make dma masks set-up IORT specific
The introduction of acpi_dma_configure() allows to configure DMA and related IOMMU for any device that is DMA capable. To achieve that goal it ensures DMA masks are set-up to sane default values before proceeding with IOMMU and DMA ops configuration. On x86/ia64 systems, through acpi_bind_one(), acpi_dma_configure() is called for every device that has an ACPI companion, in that every device is considered DMA capable on x86/ia64 systems (ie acpi_get_dma_attr() API), which has the side effect of initializing dma masks also for pseudo-devices (eg CPUs and memory nodes) and potentially for devices whose dma masks were not set-up before the acpi_dma_configure() API was introduced, which may have noxious side effects. Therefore, in preparation for IORT firmware specific DMA masks set-up, wrap the default DMA masks set-up in acpi_dma_configure() inside an IORT specific wrapper that reverts to a NOP on x86/ia64 systems, restoring the default expected behaviour on x86/ia64 systems and keeping DMA default masks set-up on IORT based (ie ARM) arch configurations. Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Acked-by: Will Deacon <will.deacon@arm.com> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Hanjun Guo <hanjun.guo@linaro.org> Tested-by: Hanjun Guo <hanjun.guo@linaro.org> Cc: Will Deacon <will.deacon@arm.com> Cc: Hanjun Guo <hanjun.guo@linaro.org> Cc: Bjorn Helgaas <bhelgaas@google.com> Cc: Robin Murphy <robin.murphy@arm.com> Cc: Tomasz Nowicki <tn@semihalf.com> Cc: Joerg Roedel <joro@8bytes.org> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net> Cc: Sricharan R <sricharan@codeaurora.org> Signed-off-by: Joerg Roedel <jroedel@suse.de>
This commit is contained in:
parent
ac1d35659b
commit
18b709beb5
|
@ -546,6 +546,28 @@ static const struct iommu_ops *iort_iommu_xlate(struct device *dev,
|
||||||
return ret ? NULL : ops;
|
return ret ? NULL : ops;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* iort_set_dma_mask - Set-up dma mask for a device.
|
||||||
|
*
|
||||||
|
* @dev: device to configure
|
||||||
|
*/
|
||||||
|
void iort_set_dma_mask(struct device *dev)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Set default coherent_dma_mask to 32 bit. Drivers are expected to
|
||||||
|
* setup the correct supported mask.
|
||||||
|
*/
|
||||||
|
if (!dev->coherent_dma_mask)
|
||||||
|
dev->coherent_dma_mask = DMA_BIT_MASK(32);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set it to coherent_dma_mask by default if the architecture
|
||||||
|
* code has not set it.
|
||||||
|
*/
|
||||||
|
if (!dev->dma_mask)
|
||||||
|
dev->dma_mask = &dev->coherent_dma_mask;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* iort_iommu_configure - Set-up IOMMU configuration for a device.
|
* iort_iommu_configure - Set-up IOMMU configuration for a device.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1380,19 +1380,7 @@ void acpi_dma_configure(struct device *dev, enum dev_dma_attr attr)
|
||||||
{
|
{
|
||||||
const struct iommu_ops *iommu;
|
const struct iommu_ops *iommu;
|
||||||
|
|
||||||
/*
|
iort_set_dma_mask(dev);
|
||||||
* Set default coherent_dma_mask to 32 bit. Drivers are expected to
|
|
||||||
* setup the correct supported mask.
|
|
||||||
*/
|
|
||||||
if (!dev->coherent_dma_mask)
|
|
||||||
dev->coherent_dma_mask = DMA_BIT_MASK(32);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Set it to coherent_dma_mask by default if the architecture
|
|
||||||
* code has not set it.
|
|
||||||
*/
|
|
||||||
if (!dev->dma_mask)
|
|
||||||
dev->dma_mask = &dev->coherent_dma_mask;
|
|
||||||
|
|
||||||
iommu = iort_iommu_configure(dev);
|
iommu = iort_iommu_configure(dev);
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ bool iort_node_match(u8 type);
|
||||||
u32 iort_msi_map_rid(struct device *dev, u32 req_id);
|
u32 iort_msi_map_rid(struct device *dev, u32 req_id);
|
||||||
struct irq_domain *iort_get_device_domain(struct device *dev, u32 req_id);
|
struct irq_domain *iort_get_device_domain(struct device *dev, u32 req_id);
|
||||||
/* IOMMU interface */
|
/* IOMMU interface */
|
||||||
|
void iort_set_dma_mask(struct device *dev);
|
||||||
const struct iommu_ops *iort_iommu_configure(struct device *dev);
|
const struct iommu_ops *iort_iommu_configure(struct device *dev);
|
||||||
#else
|
#else
|
||||||
static inline void acpi_iort_init(void) { }
|
static inline void acpi_iort_init(void) { }
|
||||||
|
@ -45,6 +46,7 @@ static inline struct irq_domain *iort_get_device_domain(struct device *dev,
|
||||||
u32 req_id)
|
u32 req_id)
|
||||||
{ return NULL; }
|
{ return NULL; }
|
||||||
/* IOMMU interface */
|
/* IOMMU interface */
|
||||||
|
static inline void iort_set_dma_mask(struct device *dev) { }
|
||||||
static inline
|
static inline
|
||||||
const struct iommu_ops *iort_iommu_configure(struct device *dev)
|
const struct iommu_ops *iort_iommu_configure(struct device *dev)
|
||||||
{ return NULL; }
|
{ return NULL; }
|
||||||
|
|
Loading…
Reference in New Issue