Commit 55897af6 authored by Christoph Hellwig's avatar Christoph Hellwig
Browse files

dma-direct: merge swiotlb_dma_ops into the dma_direct code



While the dma-direct code is (relatively) clean and simple we actually
have to use the swiotlb ops for the mapping on many architectures due
to devices with addressing limits.  Instead of keeping two
implementations around this commit allows the dma-direct
implementation to call the swiotlb bounce buffering functions and
thus share the guts of the mapping implementation.  This also
simplified the dma-mapping setup on a few architectures where we
don't have to differenciate which implementation to use.

Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Acked-by: default avatarJesper Dangaard Brouer <brouer@redhat.com>
Tested-by: default avatarJesper Dangaard Brouer <brouer@redhat.com>
Tested-by: default avatarTony Luck <tony.luck@intel.com>
parent 17ac5247
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -463,7 +463,7 @@ void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
			const struct iommu_ops *iommu, bool coherent)
{
	if (!dev->dma_ops)
		dev->dma_ops = &swiotlb_dma_ops;
		dev->dma_ops = &dma_direct_ops;

	dev->dma_coherent = coherent;
	__iommu_setup_dma_ops(dev, dma_base, size, iommu);
+1 −1
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ static inline int use_swiotlb(struct device *dev)
const struct dma_map_ops *hwsw_dma_get_ops(struct device *dev)
{
	if (use_swiotlb(dev))
		return &swiotlb_dma_ops;
		return &dma_direct_ops;
	return &sba_dma_ops;
}
EXPORT_SYMBOL(hwsw_dma_get_ops);
+2 −4
Original line number Diff line number Diff line
@@ -2065,8 +2065,6 @@ static int __init acpi_sba_ioc_init_acpi(void)
/* This has to run before acpi_scan_init(). */
arch_initcall(acpi_sba_ioc_init_acpi);

extern const struct dma_map_ops swiotlb_dma_ops;

static int __init
sba_init(void)
{
@@ -2080,7 +2078,7 @@ sba_init(void)
	 * a successful kdump kernel boot is to use the swiotlb.
	 */
	if (is_kdump_kernel()) {
		dma_ops = &swiotlb_dma_ops;
		dma_ops = &dma_direct_ops;
		if (swiotlb_late_init_with_default_size(64 * (1<<20)) != 0)
			panic("Unable to initialize software I/O TLB:"
				  " Try machvec=dig boot option");
@@ -2102,7 +2100,7 @@ sba_init(void)
		 * If we didn't find something sba_iommu can claim, we
		 * need to setup the swiotlb and switch to the dig machvec.
		 */
		dma_ops = &swiotlb_dma_ops;
		dma_ops = &dma_direct_ops;
		if (swiotlb_late_init_with_default_size(64 * (1<<20)) != 0)
			panic("Unable to find SBA IOMMU or initialize "
			      "software I/O TLB: Try machvec=dig boot option");
+1 −1
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ long arch_dma_coherent_to_pfn(struct device *dev, void *cpu_addr,

void __init swiotlb_dma_init(void)
{
	dma_ops = &swiotlb_dma_ops;
	dma_ops = &dma_direct_ops;
	swiotlb_init(1);
}
#endif
+0 −2
Original line number Diff line number Diff line
@@ -10,8 +10,6 @@ static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
{
#if defined(CONFIG_MACH_JAZZ)
	return &jazz_dma_ops;
#elif defined(CONFIG_SWIOTLB)
	return &swiotlb_dma_ops;
#else
	return &dma_direct_ops;
#endif
Loading