From: Allen Pais Date: Fri, 7 Jul 2017 07:35:34 +0000 (+0530) Subject: Revert "sparc64: bypass iommu to use 64bit address space" X-Git-Tag: v4.1.12-106.0.20170720_1900~88 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=cb401fd9b6c08b7df85cbc31fc8d5d497d11fe2d;p=users%2Fjedix%2Flinux-maple.git Revert "sparc64: bypass iommu to use 64bit address space" This reverts commit 34edb40e5e13cba76ad13646d3a1823d877851c6. Conflicts: arch/sparc/kernel/pci_sun4v.c Orabug: 21149316 Reviewed-by: chris hyser Signed-off-by: Allen Pais --- diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig index d7066e6141c0..0075cb6bb231 100644 --- a/arch/sparc/Kconfig +++ b/arch/sparc/Kconfig @@ -86,10 +86,6 @@ config SPARC64 select ARCH_USE_QUEUED_RWLOCKS select ARCH_USE_QUEUED_SPINLOCKS -config ARCH_DMA_ADDR_T_64BIT - bool - default y if SPARC64 - config ARCH_DEFCONFIG string default "arch/sparc/configs/sparc32_defconfig" if SPARC32 diff --git a/arch/sparc/kernel/iommu.c b/arch/sparc/kernel/iommu.c index 0ecd6d76a746..37686828c3d9 100644 --- a/arch/sparc/kernel/iommu.c +++ b/arch/sparc/kernel/iommu.c @@ -760,6 +760,9 @@ int dma_supported(struct device *dev, u64 device_mask) struct iommu *iommu = dev->archdata.iommu; u64 dma_addr_mask = iommu->dma_addr_mask; + if (device_mask >= (1UL << 32UL)) + return 0; + if ((device_mask & dma_addr_mask) == dma_addr_mask) return 1; diff --git a/arch/sparc/kernel/pci_sun4v.c b/arch/sparc/kernel/pci_sun4v.c index 59c772fedf02..562fd540e6ce 100644 --- a/arch/sparc/kernel/pci_sun4v.c +++ b/arch/sparc/kernel/pci_sun4v.c @@ -71,28 +71,6 @@ struct iommu_batch { static DEFINE_PER_CPU(struct iommu_batch, iommu_batch); static int iommu_batch_initialized; - -unsigned long iommu_getbypass(unsigned long ra, - unsigned long attr, - unsigned long *io_addr_p) -{ - struct iommu_batch *p = this_cpu_ptr(&iommu_batch); - struct pci_pbm_info *pbm = p->dev->archdata.host_controller; - unsigned long devhandle = pbm->devhandle; - unsigned long ret; - - ret = pci_sun4v_iommu_getbypass(devhandle, ra, attr, io_addr_p); - - printk(KERN_ERR "iommu_getbypass: devhandle 0x%lx ra 0x%lx prot 0x%lx dma 0x%lx\n", - devhandle, ra, attr, *io_addr_p); - - if (ret) - printk(KERN_ERR "iommu_getbypass: err 0x%lx\n", ret); - - return ret; -} -EXPORT_SYMBOL(iommu_getbypass); - /* Interrupts must be disabled. */ static inline void iommu_batch_start(struct device *dev, unsigned long prot, unsigned long entry) { @@ -287,40 +265,6 @@ static void dma_4v_free_coherent(struct device *dev, size_t size, void *cpu, free_pages((unsigned long)cpu, order); } -static dma_addr_t dma_4v_map_page_bypass(struct device *dev, struct page *page, - unsigned long offset, size_t sz, - enum dma_data_direction direction, - struct dma_attrs *attrs) -{ - struct pci_pbm_info *pbm; - unsigned long devhandle; - unsigned long ra; - unsigned long prot; - unsigned long dma_addr; - - if (unlikely(direction == DMA_NONE)) - goto bad; - - prot = HV_PCI_MAP_ATTR_READ; - if (direction != DMA_TO_DEVICE) - prot |= HV_PCI_MAP_ATTR_WRITE; - - /* VPCI maj=2, min=[0,1] or greater supports relax ordering */ - if (dma_get_attr(DMA_ATTR_WEAK_ORDERING, attrs) && vpci_major >= 2) - prot |= HV_PCI_MAP_ATTR_RELAXED_ORDER; - - pbm = dev->archdata.host_controller; - devhandle = pbm->devhandle; - ra = __pa(page_address(page) + offset); - if (pci_sun4v_iommu_getbypass(devhandle, ra, prot, &dma_addr)) - goto bad; - - return dma_addr; - -bad: - return DMA_ERROR_CODE; -} - static dma_addr_t dma_4v_map_page(struct device *dev, struct page *page, unsigned long offset, size_t sz, enum dma_data_direction direction, @@ -336,7 +280,7 @@ static dma_addr_t dma_4v_map_page(struct device *dev, struct page *page, if (IS_IB_DEVICE(pdev)) return dma_4v_map_page_bypass(dev, page, offset, sz, - direction, attrs); + direction, attrs); iommu = dev->archdata.iommu; @@ -400,7 +344,7 @@ static void dma_4v_unmap_page(struct device *dev, dma_addr_t bus_addr, long entry; u32 devhandle; - /* IB uses bypass, no need to un-map bypass dma address */ + /* IB uses bypass, no need to unmap for bypass */ if (IS_IB_DEVICE(pdev)) return; @@ -422,45 +366,6 @@ static void dma_4v_unmap_page(struct device *dev, dma_addr_t bus_addr, iommu_tbl_range_free(&iommu->tbl, bus_addr, npages, IOMMU_ERROR_CODE); } -static int dma_4v_map_sg_bypass(struct device *dev, struct scatterlist *sglist, - int nelems, enum dma_data_direction direction, - struct dma_attrs *attrs) -{ - struct pci_pbm_info *pbm; - unsigned long devhandle; - unsigned long ra; - unsigned long prot; - unsigned long dma_addr; - struct scatterlist *s; - int i; - - if (unlikely(direction == DMA_NONE)) - goto bad; - - prot = HV_PCI_MAP_ATTR_READ; - if (direction != DMA_TO_DEVICE) - prot |= HV_PCI_MAP_ATTR_WRITE; - - /* VPCI maj=2, min=[0,1] or greater supports relax ordering */ - if (dma_get_attr(DMA_ATTR_WEAK_ORDERING, attrs) && vpci_major >= 2) - prot |= HV_PCI_MAP_ATTR_RELAXED_ORDER; - - pbm = dev->archdata.host_controller; - devhandle = pbm->devhandle; - for_each_sg(sglist, s, nelems, i) { - ra = (unsigned long)SG_ENT_PHYS_ADDRESS(s); - if (pci_sun4v_iommu_getbypass(devhandle, ra, prot, &dma_addr)) - goto bad; - s->dma_address = dma_addr; - s->dma_length = s->length; - } - - return nelems; - -bad: - return 0; -} - static int dma_4v_map_sg(struct device *dev, struct scatterlist *sglist, int nelems, enum dma_data_direction direction, struct dma_attrs *attrs) @@ -624,7 +529,7 @@ static void dma_4v_unmap_sg(struct device *dev, struct scatterlist *sglist, unsigned long flags, entry; u32 devhandle; - /* IB uses bypass, no need to un-map bypass dma address */ + /* IB uses bypass, no need to unmap for bypass */ if (IS_IB_DEVICE(pdev)) return; diff --git a/arch/sparc/kernel/pci_sun4v.h b/arch/sparc/kernel/pci_sun4v.h index c92eed2609b4..331abd158610 100644 --- a/arch/sparc/kernel/pci_sun4v.h +++ b/arch/sparc/kernel/pci_sun4v.h @@ -18,10 +18,6 @@ unsigned long pci_sun4v_iommu_getmap(unsigned long devhandle, unsigned long tsbid, unsigned long *io_attributes, unsigned long *real_address); -extern unsigned long pci_sun4v_iommu_getbypass(unsigned long dev_hdl, - unsigned long ra, - unsigned long attr, - unsigned long *io_addr_p); unsigned long pci_sun4v_config_get(unsigned long devhandle, unsigned long pci_device, unsigned long config_offset, diff --git a/arch/sparc/kernel/pci_sun4v_asm.S b/arch/sparc/kernel/pci_sun4v_asm.S index 80fda5fd4abf..ff08066d4161 100644 --- a/arch/sparc/kernel/pci_sun4v_asm.S +++ b/arch/sparc/kernel/pci_sun4v_asm.S @@ -56,24 +56,6 @@ ENTRY(pci_sun4v_iommu_getmap) mov %o0, %o0 ENDPROC(pci_sun4v_iommu_getmap) - - /* %o0: devhandle - * %o1: r_addr - * %o2: io_attributes - * %o3: &io_addr - * - * returns: %o0: status - */ -ENTRY(pci_sun4v_iommu_getbypass) - mov HV_FAST_PCI_IOMMU_GETBYPASS, %o5 - ta HV_FAST_TRAP - brnz %o0, 1f - stx %o1, [%o3] -1: retl - nop -ENDPROC(pci_sun4v_iommu_getbypass) - - /* %o0: devhandle * %o1: pci_device * %o2: pci_config_offset