Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4d9b977c authored by FUJITA Tomonori's avatar FUJITA Tomonori Committed by Ingo Molnar
Browse files

set up dma_ops appropriately



This patch introduces a global pointer, dma_ops, which points to an
appropriate dma_mapping_ops that the kernel should use. This is a
common way to handle multiple dma_mapping_ops (X86, POWER, and SPARC).

dma_ops is set in platform_dma_init. We also set it by hand where
machvec_init is callev via subsys_initcall.

- IA64_DIG_VTD uses vtd_dma_ops.
- IA64_HP_ZX1 uses sba_dma_ops.
- IA64_HP_ZX1_SWIOTLB uses hwsw_dma_ops.
- IA64_SGI_SN2 uses sn_dma_ops.
- The rest use swiotlb_dma_ops.

Signed-off-by: default avatarFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Acked-by: default avatarTony Luck <tony.luck@intel.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent c82e4417
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -56,9 +56,12 @@ use_swiotlb (struct device *dev)
	return dev && dev->dma_mask && !hwiommu_dma_supported(dev, *dev->dma_mask);
}

struct dma_mapping_ops hwsw_dma_ops;

void __init
hwsw_init (void)
{
	dma_ops = &hwsw_dma_ops;
	/* default to a smallish 2MB sw I/O TLB */
	if (swiotlb_late_init_with_default_size (2 * (1<<20)) != 0) {
#ifdef CONFIG_IA64_GENERIC
+9 −0
Original line number Diff line number Diff line
@@ -2065,6 +2065,8 @@ static struct acpi_driver acpi_sba_ioc_driver = {
	},
};

extern struct dma_mapping_ops swiotlb_dma_ops;

static int __init
sba_init(void)
{
@@ -2078,6 +2080,7 @@ sba_init(void)
	 * a successful kdump kernel boot is to use the swiotlb.
	 */
	if (is_kdump_kernel()) {
		dma_ops = &swiotlb_dma_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");
@@ -2093,6 +2096,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;
		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");
@@ -2196,3 +2200,8 @@ struct dma_mapping_ops sba_dma_ops = {
	.dma_supported_op	= sba_dma_supported,
	.mapping_error		= sba_dma_mapping_error,
};

void sba_dma_init(void)
{
	dma_ops = &sba_dma_ops;
}
+3 −1
Original line number Diff line number Diff line
@@ -298,6 +298,8 @@ extern void machvec_init_from_cmdline(const char *cmdline);
#  error Unknown configuration.  Update arch/ia64/include/asm/machvec.h.
# endif /* CONFIG_IA64_GENERIC */

extern void swiotlb_dma_init(void);

/*
 * Define default versions so we can extend machvec for new platforms without having
 * to update the machvec files for all existing platforms.
@@ -328,7 +330,7 @@ extern void machvec_init_from_cmdline(const char *cmdline);
# define platform_kernel_launch_event	machvec_noop
#endif
#ifndef platform_dma_init
# define platform_dma_init		swiotlb_init
# define platform_dma_init		swiotlb_dma_init
#endif
#ifndef platform_dma_alloc_coherent
# define platform_dma_alloc_coherent	swiotlb_alloc_coherent
+2 −1
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@
#define _ASM_IA64_MACHVEC_HPZX1_h

extern ia64_mv_setup_t			dig_setup;
extern ia64_mv_dma_init			sba_dma_init;
extern ia64_mv_dma_alloc_coherent	sba_alloc_coherent;
extern ia64_mv_dma_free_coherent	sba_free_coherent;
extern ia64_mv_dma_map_single_attrs	sba_map_single_attrs;
@@ -20,7 +21,7 @@ extern ia64_mv_dma_mapping_error sba_dma_mapping_error;
 */
#define platform_name				"hpzx1"
#define platform_setup				dig_setup
#define platform_dma_init			machvec_noop
#define platform_dma_init			sba_dma_init
#define platform_dma_alloc_coherent		sba_alloc_coherent
#define platform_dma_free_coherent		sba_free_coherent
#define platform_dma_map_single_attrs		sba_map_single_attrs
+2 −1
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ extern ia64_mv_readb_t __sn_readb_relaxed;
extern ia64_mv_readw_t __sn_readw_relaxed;
extern ia64_mv_readl_t __sn_readl_relaxed;
extern ia64_mv_readq_t __sn_readq_relaxed;
extern ia64_mv_dma_init			sn_dma_init;
extern ia64_mv_dma_alloc_coherent	sn_dma_alloc_coherent;
extern ia64_mv_dma_free_coherent	sn_dma_free_coherent;
extern ia64_mv_dma_map_single_attrs	sn_dma_map_single_attrs;
@@ -110,7 +111,7 @@ extern ia64_mv_pci_fixup_bus_t sn_pci_fixup_bus;
#define platform_pci_get_legacy_mem	sn_pci_get_legacy_mem
#define platform_pci_legacy_read	sn_pci_legacy_read
#define platform_pci_legacy_write	sn_pci_legacy_write
#define platform_dma_init		machvec_noop
#define platform_dma_init		sn_dma_init
#define platform_dma_alloc_coherent	sn_dma_alloc_coherent
#define platform_dma_free_coherent	sn_dma_free_coherent
#define platform_dma_map_single_attrs	sn_dma_map_single_attrs
Loading