提交 cea9d03c 编写于 作者: C Christoph Hellwig

dma-mapping: add an arch_dma_supported hook

To implement the x86 forbid_dac and iommu_sac_force we want an arch hook
so that it can apply the global options across all dma_map_ops
implementations.
Signed-off-by: NChristoph Hellwig <hch@lst.de>
Reviewed-by: NKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
上级 57bf5a89
...@@ -30,6 +30,9 @@ static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus) ...@@ -30,6 +30,9 @@ static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
return dma_ops; return dma_ops;
} }
int arch_dma_supported(struct device *dev, u64 mask);
#define arch_dma_supported arch_dma_supported
bool arch_dma_alloc_attrs(struct device **dev, gfp_t *gfp); bool arch_dma_alloc_attrs(struct device **dev, gfp_t *gfp);
#define arch_dma_alloc_attrs arch_dma_alloc_attrs #define arch_dma_alloc_attrs arch_dma_alloc_attrs
......
...@@ -215,7 +215,7 @@ static __init int iommu_setup(char *p) ...@@ -215,7 +215,7 @@ static __init int iommu_setup(char *p)
} }
early_param("iommu", iommu_setup); early_param("iommu", iommu_setup);
int x86_dma_supported(struct device *dev, u64 mask) int arch_dma_supported(struct device *dev, u64 mask)
{ {
#ifdef CONFIG_PCI #ifdef CONFIG_PCI
if (mask > 0xffffffff && forbid_dac > 0) { if (mask > 0xffffffff && forbid_dac > 0) {
...@@ -224,12 +224,6 @@ int x86_dma_supported(struct device *dev, u64 mask) ...@@ -224,12 +224,6 @@ int x86_dma_supported(struct device *dev, u64 mask)
} }
#endif #endif
/* Copied from i386. Doesn't make much sense, because it will
only work for pci_alloc_coherent.
The caller just has to use GFP_DMA in this case. */
if (mask < DMA_BIT_MASK(24))
return 0;
/* Tell the device to use SAC when IOMMU force is on. This /* Tell the device to use SAC when IOMMU force is on. This
allows the driver to use cheaper accesses in some cases. allows the driver to use cheaper accesses in some cases.
...@@ -249,6 +243,17 @@ int x86_dma_supported(struct device *dev, u64 mask) ...@@ -249,6 +243,17 @@ int x86_dma_supported(struct device *dev, u64 mask)
return 1; return 1;
} }
EXPORT_SYMBOL(arch_dma_supported);
int x86_dma_supported(struct device *dev, u64 mask)
{
/* Copied from i386. Doesn't make much sense, because it will
only work for pci_alloc_coherent.
The caller just has to use GFP_DMA in this case. */
if (mask < DMA_BIT_MASK(24))
return 0;
return 1;
}
static int __init pci_iommu_init(void) static int __init pci_iommu_init(void)
{ {
......
...@@ -576,6 +576,14 @@ static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr) ...@@ -576,6 +576,14 @@ static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
return 0; return 0;
} }
/*
* This is a hack for the legacy x86 forbid_dac and iommu_sac_force. Please
* don't use this is new code.
*/
#ifndef arch_dma_supported
#define arch_dma_supported(dev, mask) (1)
#endif
static inline void dma_check_mask(struct device *dev, u64 mask) static inline void dma_check_mask(struct device *dev, u64 mask)
{ {
if (sme_active() && (mask < (((u64)sme_get_me_mask() << 1) - 1))) if (sme_active() && (mask < (((u64)sme_get_me_mask() << 1) - 1)))
...@@ -588,6 +596,9 @@ static inline int dma_supported(struct device *dev, u64 mask) ...@@ -588,6 +596,9 @@ static inline int dma_supported(struct device *dev, u64 mask)
if (!ops) if (!ops)
return 0; return 0;
if (!arch_dma_supported(dev, mask))
return 0;
if (!ops->dma_supported) if (!ops->dma_supported)
return 1; return 1;
return ops->dma_supported(dev, mask); return ops->dma_supported(dev, mask);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册