Message ID | 20180415145947.1248-2-hch@lst.de |
---|---|
State | Not Applicable |
Delegated to: | David Miller |
Headers | show |
Series | [01/12] iommu-common: move to arch/sparc | expand |
On 04/15/2018 08:29 PM, Christoph Hellwig wrote: > This code is only used by sparc, and all new iommu drivers should use the > drivers/iommu/ framework. Also remove the unused exports. > > Signed-off-by: Christoph Hellwig <hch@lst.de> Right, these functions are used only from SPARC architecture. Simple git grep confirms it as well. Hence it makes sense to move them into arch code instead. git grep iommu_tbl_pool_init ---------------------------- arch/sparc/include/asm/iommu-common.h:extern void iommu_tbl_pool_init(struct iommu_map_table *iommu, arch/sparc/kernel/iommu-common.c:void iommu_tbl_pool_init(struct iommu_map_table *iommu, arch/sparc/kernel/iommu.c: iommu_tbl_pool_init(&iommu->tbl, num_tsb_entries, IO_PAGE_SHIFT, arch/sparc/kernel/ldc.c: iommu_tbl_pool_init(iommu, num_tsb_entries, PAGE_SHIFT, arch/sparc/kernel/pci_sun4v.c: iommu_tbl_pool_init(&atu->tbl, num_iotte, IO_PAGE_SHIFT, arch/sparc/kernel/pci_sun4v.c: iommu_tbl_pool_init(&iommu->tbl, num_tsb_entries, IO_PAGE_SHIFT, git grep iommu_tbl_range_alloc ------------------------------ arch/sparc/include/asm/iommu-common.h:extern unsigned long iommu_tbl_range_alloc(struct device *dev, arch/sparc/kernel/iommu-common.c:unsigned long iommu_tbl_range_alloc(struct device *dev, arch/sparc/kernel/iommu.c: entry = iommu_tbl_range_alloc(dev, &iommu->tbl, npages, NULL, arch/sparc/kernel/iommu.c: entry = iommu_tbl_range_alloc(dev, &iommu->tbl, npages, arch/sparc/kernel/ldc.c: entry = iommu_tbl_range_alloc(NULL, &iommu->iommu_map_table, arch/sparc/kernel/pci_sun4v.c: entry = iommu_tbl_range_alloc(dev, tbl, npages, NULL, arch/sparc/kernel/pci_sun4v.c: entry = iommu_tbl_range_alloc(dev, tbl, npages, NULL, arch/sparc/kernel/pci_sun4v.c: entry = iommu_tbl_range_alloc(dev, tbl, npages, git grep iommu_tbl_range_free ----------------------------- arch/sparc/include/asm/iommu-common.h:extern void iommu_tbl_range_free(struct iommu_map_table *iommu, arch/sparc/kernel/iommu-common.c:void iommu_tbl_range_free(struct iommu_map_table *iommu, u64 dma_addr, arch/sparc/kernel/iommu.c: iommu_tbl_range_free(&iommu->tbl, dvma, npages, IOMMU_ERROR_CODE); arch/sparc/kernel/iommu.c: iommu_tbl_range_free(&iommu->tbl, bus_addr, npages, IOMMU_ERROR_CODE); arch/sparc/kernel/iommu.c: iommu_tbl_range_free(&iommu->tbl, vaddr, npages, arch/sparc/kernel/iommu.c: iommu_tbl_range_free(&iommu->tbl, dma_handle, npages, arch/sparc/kernel/ldc.c: iommu_tbl_range_free(&iommu->iommu_map_table, cookie, npages, entry); arch/sparc/kernel/pci_sun4v.c: iommu_tbl_range_free(tbl, *dma_addrp, npages, IOMMU_ERROR_CODE); arch/sparc/kernel/pci_sun4v.c: iommu_tbl_range_free(tbl, dvma, npages, IOMMU_ERROR_CODE); arch/sparc/kernel/pci_sun4v.c: iommu_tbl_range_free(tbl, bus_addr, npages, IOMMU_ERROR_CODE); arch/sparc/kernel/pci_sun4v.c: iommu_tbl_range_free(tbl, bus_addr, npages, IOMMU_ERROR_CODE); arch/sparc/kernel/pci_sun4v.c: iommu_tbl_range_free(tbl, vaddr, npages, arch/sparc/kernel/pci_sun4v.c: iommu_tbl_range_free(tbl, dma_handle, npages, Reviewed-by: Anshuman Khandual <khandual@linux.vnet.ibm.com> -- To unsubscribe from this list: send the line "unsubscribe linux-ide" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
From: Anshuman Khandual <khandual@linux.vnet.ibm.com> Date: Mon, 16 Apr 2018 14:26:07 +0530 > On 04/15/2018 08:29 PM, Christoph Hellwig wrote: >> This code is only used by sparc, and all new iommu drivers should use the >> drivers/iommu/ framework. Also remove the unused exports. >> >> Signed-off-by: Christoph Hellwig <hch@lst.de> > > Right, these functions are used only from SPARC architecture. Simple > git grep confirms it as well. Hence it makes sense to move them into > arch code instead. Well, we put these into a common location and used type friendly for powerpc because we hoped powerpc would convert over to using this common piece of code as well. But nobody did the powerpc work. If you look at the powerpc iommu support, it's the same code basically for entry allocation. -- To unsubscribe from this list: send the line "unsubscribe linux-ide" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 04/16/2018 07:28 PM, David Miller wrote: > From: Anshuman Khandual <khandual@linux.vnet.ibm.com> > Date: Mon, 16 Apr 2018 14:26:07 +0530 > >> On 04/15/2018 08:29 PM, Christoph Hellwig wrote: >>> This code is only used by sparc, and all new iommu drivers should use the >>> drivers/iommu/ framework. Also remove the unused exports. >>> >>> Signed-off-by: Christoph Hellwig <hch@lst.de> >> >> Right, these functions are used only from SPARC architecture. Simple >> git grep confirms it as well. Hence it makes sense to move them into >> arch code instead. > > Well, we put these into a common location and used type friendly for > powerpc because we hoped powerpc would convert over to using this > common piece of code as well. > > But nobody did the powerpc work. > > If you look at the powerpc iommu support, it's the same code basically > for entry allocation. I understand. But there are some differences in iommu_table structure, how both regular and large IOMMU pools are being initialized etc. So if the movement of code into SPARC help cleaning up these generic config options in general, I guess we should do that. But I will leave it upto others who have more experience in this area. +mpe -- To unsubscribe from this list: send the line "unsubscribe linux-ide" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Anshuman Khandual <khandual@linux.vnet.ibm.com> writes: > On 04/16/2018 07:28 PM, David Miller wrote: >> From: Anshuman Khandual <khandual@linux.vnet.ibm.com> >> Date: Mon, 16 Apr 2018 14:26:07 +0530 >> >>> On 04/15/2018 08:29 PM, Christoph Hellwig wrote: >>>> This code is only used by sparc, and all new iommu drivers should use the >>>> drivers/iommu/ framework. Also remove the unused exports. >>>> >>>> Signed-off-by: Christoph Hellwig <hch@lst.de> >>> >>> Right, these functions are used only from SPARC architecture. Simple >>> git grep confirms it as well. Hence it makes sense to move them into >>> arch code instead. >> >> Well, we put these into a common location and used type friendly for >> powerpc because we hoped powerpc would convert over to using this >> common piece of code as well. >> >> But nobody did the powerpc work. Sorry. >> If you look at the powerpc iommu support, it's the same code basically >> for entry allocation. > > I understand. But there are some differences in iommu_table structure, > how both regular and large IOMMU pools are being initialized etc. So > if the movement of code into SPARC help cleaning up these generic config > options in general, I guess we should do that. But I will leave it upto > others who have more experience in this area. > > +mpe This is the first I've heard of it, I guess it's probably somewhere on Ben's append-only TODO list. Some of the code does look very similar, but not 100%. So someone would need to do some work to reconcile the two and test the result. TBH I doubt we're going to get around to it any time soon. Unless we have a volunteer? cheers -- To unsubscribe from this list: send the line "unsubscribe linux-ide" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Mon, Apr 16, 2018 at 09:58:33AM -0400, David Miller wrote: > From: Anshuman Khandual <khandual@linux.vnet.ibm.com> > Date: Mon, 16 Apr 2018 14:26:07 +0530 > > > On 04/15/2018 08:29 PM, Christoph Hellwig wrote: > >> This code is only used by sparc, and all new iommu drivers should use the > >> drivers/iommu/ framework. Also remove the unused exports. > >> > >> Signed-off-by: Christoph Hellwig <hch@lst.de> > > > > Right, these functions are used only from SPARC architecture. Simple > > git grep confirms it as well. Hence it makes sense to move them into > > arch code instead. > > Well, we put these into a common location and used type friendly for > powerpc because we hoped powerpc would convert over to using this > common piece of code as well. > > But nobody did the powerpc work. > > If you look at the powerpc iommu support, it's the same code basically > for entry allocation. I could also introduce a new config symbol and keep it in common code, but it has been there for a while without any new user. Right now it just means we built the code for everyone who selects CONFIG_IOMMU_HELPER, which is just about anyone these days. -- To unsubscribe from this list: send the line "unsubscribe linux-ide" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/include/linux/iommu-common.h b/arch/sparc/include/asm/iommu-common.h similarity index 100% rename from include/linux/iommu-common.h rename to arch/sparc/include/asm/iommu-common.h diff --git a/arch/sparc/include/asm/iommu_64.h b/arch/sparc/include/asm/iommu_64.h index 9ed6b54caa4b..0ef6dedf747e 100644 --- a/arch/sparc/include/asm/iommu_64.h +++ b/arch/sparc/include/asm/iommu_64.h @@ -17,7 +17,7 @@ #define IOPTE_WRITE 0x0000000000000002UL #define IOMMU_NUM_CTXS 4096 -#include <linux/iommu-common.h> +#include <asm/iommu-common.h> struct iommu_arena { unsigned long *map; diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile index 76cb57750dda..a284662b0e4c 100644 --- a/arch/sparc/kernel/Makefile +++ b/arch/sparc/kernel/Makefile @@ -59,7 +59,7 @@ obj-$(CONFIG_SPARC32) += leon_pmc.o obj-$(CONFIG_SPARC64) += reboot.o obj-$(CONFIG_SPARC64) += sysfs.o -obj-$(CONFIG_SPARC64) += iommu.o +obj-$(CONFIG_SPARC64) += iommu.o iommu-common.o obj-$(CONFIG_SPARC64) += central.o obj-$(CONFIG_SPARC64) += starfire.o obj-$(CONFIG_SPARC64) += power.o diff --git a/lib/iommu-common.c b/arch/sparc/kernel/iommu-common.c similarity index 98% rename from lib/iommu-common.c rename to arch/sparc/kernel/iommu-common.c index 55b00de106b5..59cb16691322 100644 --- a/lib/iommu-common.c +++ b/arch/sparc/kernel/iommu-common.c @@ -8,9 +8,9 @@ #include <linux/bitmap.h> #include <linux/bug.h> #include <linux/iommu-helper.h> -#include <linux/iommu-common.h> #include <linux/dma-mapping.h> #include <linux/hash.h> +#include <asm/iommu-common.h> static unsigned long iommu_large_alloc = 15; @@ -93,7 +93,6 @@ void iommu_tbl_pool_init(struct iommu_map_table *iommu, p->hint = p->start; p->end = num_entries; } -EXPORT_SYMBOL(iommu_tbl_pool_init); unsigned long iommu_tbl_range_alloc(struct device *dev, struct iommu_map_table *iommu, @@ -224,7 +223,6 @@ unsigned long iommu_tbl_range_alloc(struct device *dev, return n; } -EXPORT_SYMBOL(iommu_tbl_range_alloc); static struct iommu_pool *get_pool(struct iommu_map_table *tbl, unsigned long entry) @@ -264,4 +262,3 @@ void iommu_tbl_range_free(struct iommu_map_table *iommu, u64 dma_addr, bitmap_clear(iommu->map, entry, npages); spin_unlock_irqrestore(&(pool->lock), flags); } -EXPORT_SYMBOL(iommu_tbl_range_free); diff --git a/arch/sparc/kernel/iommu.c b/arch/sparc/kernel/iommu.c index b08dc3416f06..40d008b0bd3e 100644 --- a/arch/sparc/kernel/iommu.c +++ b/arch/sparc/kernel/iommu.c @@ -14,7 +14,7 @@ #include <linux/errno.h> #include <linux/iommu-helper.h> #include <linux/bitmap.h> -#include <linux/iommu-common.h> +#include <asm/iommu-common.h> #ifdef CONFIG_PCI #include <linux/pci.h> diff --git a/arch/sparc/kernel/ldc.c b/arch/sparc/kernel/ldc.c index 86b625f9d8dc..c0fa3ef6cf01 100644 --- a/arch/sparc/kernel/ldc.c +++ b/arch/sparc/kernel/ldc.c @@ -16,7 +16,7 @@ #include <linux/list.h> #include <linux/init.h> #include <linux/bitmap.h> -#include <linux/iommu-common.h> +#include <asm/iommu-common.h> #include <asm/hypervisor.h> #include <asm/iommu.h> diff --git a/arch/sparc/kernel/pci_sun4v.c b/arch/sparc/kernel/pci_sun4v.c index 249367228c33..565d9ac883d0 100644 --- a/arch/sparc/kernel/pci_sun4v.c +++ b/arch/sparc/kernel/pci_sun4v.c @@ -16,7 +16,7 @@ #include <linux/export.h> #include <linux/log2.h> #include <linux/of_device.h> -#include <linux/iommu-common.h> +#include <asm/iommu-common.h> #include <asm/iommu.h> #include <asm/irq.h> diff --git a/lib/Makefile b/lib/Makefile index ce20696d5a92..94203b5eecd4 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -147,7 +147,7 @@ obj-$(CONFIG_AUDIT_GENERIC) += audit.o obj-$(CONFIG_AUDIT_COMPAT_GENERIC) += compat_audit.o obj-$(CONFIG_SWIOTLB) += swiotlb.o -obj-$(CONFIG_IOMMU_HELPER) += iommu-helper.o iommu-common.o +obj-$(CONFIG_IOMMU_HELPER) += iommu-helper.o obj-$(CONFIG_FAULT_INJECTION) += fault-inject.o obj-$(CONFIG_NOTIFIER_ERROR_INJECTION) += notifier-error-inject.o obj-$(CONFIG_PM_NOTIFIER_ERROR_INJECT) += pm-notifier-error-inject.o
This code is only used by sparc, and all new iommu drivers should use the drivers/iommu/ framework. Also remove the unused exports. Signed-off-by: Christoph Hellwig <hch@lst.de> --- {include/linux => arch/sparc/include/asm}/iommu-common.h | 0 arch/sparc/include/asm/iommu_64.h | 2 +- arch/sparc/kernel/Makefile | 2 +- {lib => arch/sparc/kernel}/iommu-common.c | 5 +---- arch/sparc/kernel/iommu.c | 2 +- arch/sparc/kernel/ldc.c | 2 +- arch/sparc/kernel/pci_sun4v.c | 2 +- lib/Makefile | 2 +- 8 files changed, 7 insertions(+), 10 deletions(-) rename {include/linux => arch/sparc/include/asm}/iommu-common.h (100%) rename {lib => arch/sparc/kernel}/iommu-common.c (98%)