mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-28 04:35:17 +07:00
5299709d0a
Most dma_map_ops structures are never modified. Constify these structures such that these can be write-protected. This patch has been generated as follows: git grep -l 'struct dma_map_ops' | xargs -d\\n sed -i \ -e 's/struct dma_map_ops/const struct dma_map_ops/g' \ -e 's/const struct dma_map_ops {/struct dma_map_ops {/g' \ -e 's/^const struct dma_map_ops;$/struct dma_map_ops;/' \ -e 's/const const struct dma_map_ops /const struct dma_map_ops /g'; sed -i -e 's/const \(struct dma_map_ops intel_dma_ops\)/\1/' \ $(git grep -l 'struct dma_map_ops intel_dma_ops'); sed -i -e 's/const \(struct dma_map_ops dma_iommu_ops\)/\1/' \ $(git grep -l 'struct dma_map_ops' | grep ^arch/powerpc); sed -i -e '/^struct vmd_dev {$/,/^};$/ s/const \(struct dma_map_ops[[:blank:]]dma_ops;\)/\1/' \ -e '/^static void vmd_setup_dma_ops/,/^}$/ s/const \(struct dma_map_ops \*dest\)/\1/' \ -e 's/const \(struct dma_map_ops \*dest = \&vmd->dma_ops\)/\1/' \ drivers/pci/host/*.c sed -i -e '/^void __init pci_iommu_alloc(void)$/,/^}$/ s/dma_ops->/intel_dma_ops./' arch/ia64/kernel/pci-dma.c sed -i -e 's/static const struct dma_map_ops sn_dma_ops/static struct dma_map_ops sn_dma_ops/' arch/ia64/sn/pci/pci_dma.c sed -i -e 's/(const struct dma_map_ops \*)//' drivers/misc/mic/bus/vop_bus.c Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com> Cc: David Woodhouse <dwmw2@infradead.org> Cc: Juergen Gross <jgross@suse.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: linux-arch@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: Russell King <linux@armlinux.org.uk> Cc: x86@kernel.org Signed-off-by: Doug Ledford <dledford@redhat.com>
111 lines
2.4 KiB
C
111 lines
2.4 KiB
C
/*
|
|
* Dynamic DMA mapping support.
|
|
*/
|
|
|
|
#include <linux/types.h>
|
|
#include <linux/mm.h>
|
|
#include <linux/string.h>
|
|
#include <linux/pci.h>
|
|
#include <linux/module.h>
|
|
#include <linux/dmar.h>
|
|
#include <asm/iommu.h>
|
|
#include <asm/machvec.h>
|
|
#include <linux/dma-mapping.h>
|
|
|
|
|
|
#ifdef CONFIG_INTEL_IOMMU
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <asm/page.h>
|
|
|
|
dma_addr_t bad_dma_address __read_mostly;
|
|
EXPORT_SYMBOL(bad_dma_address);
|
|
|
|
static int iommu_sac_force __read_mostly;
|
|
|
|
int no_iommu __read_mostly;
|
|
#ifdef CONFIG_IOMMU_DEBUG
|
|
int force_iommu __read_mostly = 1;
|
|
#else
|
|
int force_iommu __read_mostly;
|
|
#endif
|
|
|
|
int iommu_pass_through;
|
|
|
|
extern struct dma_map_ops intel_dma_ops;
|
|
|
|
static int __init pci_iommu_init(void)
|
|
{
|
|
if (iommu_detected)
|
|
intel_iommu_init();
|
|
|
|
return 0;
|
|
}
|
|
|
|
/* Must execute after PCI subsystem */
|
|
fs_initcall(pci_iommu_init);
|
|
|
|
void pci_iommu_shutdown(void)
|
|
{
|
|
return;
|
|
}
|
|
|
|
void __init
|
|
iommu_dma_init(void)
|
|
{
|
|
return;
|
|
}
|
|
|
|
int iommu_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;
|
|
|
|
/* Tell the device to use SAC when IOMMU force is on. This
|
|
allows the driver to use cheaper accesses in some cases.
|
|
|
|
Problem with this is that if we overflow the IOMMU area and
|
|
return DAC as fallback address the device may not handle it
|
|
correctly.
|
|
|
|
As a special case some controllers have a 39bit address
|
|
mode that is as efficient as 32bit (aic79xx). Don't force
|
|
SAC for these. Assume all masks <= 40 bits are of this
|
|
type. Normally this doesn't make any difference, but gives
|
|
more gentle handling of IOMMU overflow. */
|
|
if (iommu_sac_force && (mask >= DMA_BIT_MASK(40))) {
|
|
dev_info(dev, "Force SAC with mask %llx\n", mask);
|
|
return 0;
|
|
}
|
|
|
|
return 1;
|
|
}
|
|
EXPORT_SYMBOL(iommu_dma_supported);
|
|
|
|
void __init pci_iommu_alloc(void)
|
|
{
|
|
dma_ops = &intel_dma_ops;
|
|
|
|
intel_dma_ops.sync_single_for_cpu = machvec_dma_sync_single;
|
|
intel_dma_ops.sync_sg_for_cpu = machvec_dma_sync_sg;
|
|
intel_dma_ops.sync_single_for_device = machvec_dma_sync_single;
|
|
intel_dma_ops.sync_sg_for_device = machvec_dma_sync_sg;
|
|
intel_dma_ops.dma_supported = iommu_dma_supported;
|
|
|
|
/*
|
|
* The order of these functions is important for
|
|
* fall-back/fail-over reasons
|
|
*/
|
|
detect_intel_iommu();
|
|
|
|
#ifdef CONFIG_SWIOTLB
|
|
pci_swiotlb_init();
|
|
#endif
|
|
}
|
|
|
|
#endif
|