[PATCHv2 2/2] uio:powerpc:mpc85xx: l2-cache-sram uio driver implementation
Freescale mpc85xx l2-cache could be optionally configured as SRAM partly or fully. Users can make use of it as a block of independent memory that offers special usage, such as for debuging or other critical status info storage, which keeps consistently even when the whole system crashed. Applications can make use of UIO driver to access the SRAM from user level. Once there was another driver version for the l2-cache-sram for SRAM access in kernel space. It had been removed recently. See: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/commit/?id=dc21ed2aef4150fc2fcf58227a4ff24502015c03 Signed-off-by: Wang Wenhu --- v2: - Use __be32 instead of u32 for big-endian data declarations; - Use generic ioremap_cache instead of ioremap_coherent; - Physical address support both 32 and 64 bits; - Addressed some other comments from Greg. --- drivers/uio/Kconfig | 14 ++ drivers/uio/Makefile | 1 + drivers/uio/uio_fsl_85xx_cache_sram.c | 288 ++ 3 files changed, 303 insertions(+) create mode 100644 drivers/uio/uio_fsl_85xx_cache_sram.c diff --git a/drivers/uio/Kconfig b/drivers/uio/Kconfig index 2e16c5338e5b..f7604584a12c 100644 --- a/drivers/uio/Kconfig +++ b/drivers/uio/Kconfig @@ -105,6 +105,20 @@ config UIO_NETX To compile this driver as a module, choose M here; the module will be called uio_netx. +config UIO_FSL_85XX_CACHE_SRAM + tristate "Freescale 85xx L2-Cache-SRAM UIO driver" + depends on FSL_SOC_BOOKE && PPC32 + help + Driver for user level access of freescale mpc85xx l2-cache-sram. + + Freescale's mpc85xx provides an option of configuring a part of + (or full) cache memory as SRAM. The driver does this configuring + work and exports SRAM to user-space for access form user level. + This is extremely helpful for user applications that require + high performance memory accesses. + + If you don't know what to do here, say N. + config UIO_FSL_ELBC_GPCM tristate "eLBC/GPCM driver" depends on FSL_LBC diff --git a/drivers/uio/Makefile b/drivers/uio/Makefile index f2f416a14228..1ba07d92a1b1 100644 --- a/drivers/uio/Makefile +++ b/drivers/uio/Makefile @@ -12,3 +12,4 @@ obj-$(CONFIG_UIO_MF624) += uio_mf624.o obj-$(CONFIG_UIO_FSL_ELBC_GPCM)+= uio_fsl_elbc_gpcm.o obj-$(CONFIG_UIO_HV_GENERIC) += uio_hv_generic.o obj-$(CONFIG_UIO_DFL) += uio_dfl.o +obj-$(CONFIG_UIO_FSL_85XX_CACHE_SRAM) += uio_fsl_85xx_cache_sram.o diff --git a/drivers/uio/uio_fsl_85xx_cache_sram.c b/drivers/uio/uio_fsl_85xx_cache_sram.c new file mode 100644 index ..6f91b0aa946b --- /dev/null +++ b/drivers/uio/uio_fsl_85xx_cache_sram.c @@ -0,0 +1,288 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2022 Wang Wenhu + * All rights reserved. + */ + +#include +#include +#include +#include +#include +#include +#include + +#define DRIVER_NAME"uio_mpc85xx_cache_sram" +#define UIO_INFO_VER "0.0.1" +#define UIO_NAME "uio_cache_sram" + +#define L2CR_L2FI 0x4000 /* L2 flash invalidate */ +#define L2CR_L2IO 0x0020 /* L2 instruction only */ +#define L2CR_SRAM_ZERO 0x /* L2SRAM zero size */ +#define L2CR_SRAM_FULL 0x0001 /* L2SRAM full size */ +#define L2CR_SRAM_HALF 0x0002 /* L2SRAM half size */ +#define L2CR_SRAM_TWO_HALFS0x0003 /* L2SRAM two half sizes */ +#define L2CR_SRAM_QUART0x0004 /* L2SRAM one quarter size */ +#define L2CR_SRAM_TWO_QUARTS 0x0005 /* L2SRAM two quarter size */ +#define L2CR_SRAM_EIGHTH 0x0006 /* L2SRAM one eighth size */ +#define L2CR_SRAM_TWO_EIGHTH 0x0007 /* L2SRAM two eighth size */ + +#define L2SRAM_OPTIMAL_SZ_SHIFT0x0003 /* Optimum size for L2SRAM */ + +#define L2SRAM_BAR_MSK_LO180xC000 /* Lower 18 bits */ +#define L2SRAM_BARE_MSK_HI40x000F /* Upper 4 bits */ + +enum cache_sram_lock_ways { + LOCK_WAYS_ZERO = 0, + LOCK_WAYS_EIGHTH= 1, + LOCK_WAYS_TWO_EIGHTH= 2, + LOCK_WAYS_HALF = 4, + LOCK_WAYS_FULL = 8, +}; + +struct mpc85xx_l2ctlr { + __be32 ctl;/* 0x000 - L2 control */ + u8 res1[0xC]; + __be32 ewar0; /* 0x010 - External write address 0 */ + __be32 ewarea0;/* 0x014 - External write address extended 0 */ + __be32 ewcr0; /* 0x018 - External write ctrl */ + u8 res2[4]; + __be32 ewar1; /* 0x020 - External write address 1 */ + __be32 ewarea1;/* 0x024 - External write address extended 1 */ + __be32 ewcr1; /* 0x028 - External write ctrl 1 */ + u8 res3[4]; + __be32 ewar2;
[PATCHv2 1/2] mm: eliminate ifdef of HAVE_IOREMAP_PROT in .c files
It is recommended in the "Conditional Compilation" chapter of kernel coding-style documentation that preprocessor conditionals should not be used in .c files wherever possible. As for the macro CONFIG_HAVE_IOREMAP_PROT, now it's a proper chance to eliminate it in .c files which are referencers. We constrict its usage only to mm/memory.c. HAVE_IOREMAP_PROT is supported by part of archectures such as powerpc and x86, but not supported by some others such as arm. So for some functions, a no-op version should be available. Currently it's generic_access_phys, which is referenced by some other modules. Signed-off-by: Wang Wenhu --- v2: - Added IS_ENABLED(CONFIG_HAVE_IOREMAP_PROT) condition in __access_remote_vm - Added generic_access_phys() function with no-op in mm/memory.c instead of the former one of "static inline" in include/linux/mm.h Former: https://lore.kernel.org/linux-mm/yqmrtwah5fiws...@kroah.com/T/ --- drivers/char/mem.c | 2 -- drivers/fpga/dfl-afu-main.c | 2 -- drivers/pci/mmap.c | 2 -- drivers/uio/uio.c | 2 -- mm/memory.c | 13 + 5 files changed, 9 insertions(+), 12 deletions(-) diff --git a/drivers/char/mem.c b/drivers/char/mem.c index 84ca98ed1dad..40186a441e38 100644 --- a/drivers/char/mem.c +++ b/drivers/char/mem.c @@ -354,9 +354,7 @@ static inline int private_mapping_ok(struct vm_area_struct *vma) #endif static const struct vm_operations_struct mmap_mem_ops = { -#ifdef CONFIG_HAVE_IOREMAP_PROT .access = generic_access_phys -#endif }; static int mmap_mem(struct file *file, struct vm_area_struct *vma) diff --git a/drivers/fpga/dfl-afu-main.c b/drivers/fpga/dfl-afu-main.c index 7f621e96d3b8..833e14806c7a 100644 --- a/drivers/fpga/dfl-afu-main.c +++ b/drivers/fpga/dfl-afu-main.c @@ -797,9 +797,7 @@ static long afu_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) } static const struct vm_operations_struct afu_vma_ops = { -#ifdef CONFIG_HAVE_IOREMAP_PROT .access = generic_access_phys, -#endif }; static int afu_mmap(struct file *filp, struct vm_area_struct *vma) diff --git a/drivers/pci/mmap.c b/drivers/pci/mmap.c index b8c9011987f4..1dcfabf80453 100644 --- a/drivers/pci/mmap.c +++ b/drivers/pci/mmap.c @@ -35,9 +35,7 @@ int pci_mmap_page_range(struct pci_dev *pdev, int bar, #endif static const struct vm_operations_struct pci_phys_vm_ops = { -#ifdef CONFIG_HAVE_IOREMAP_PROT .access = generic_access_phys, -#endif }; int pci_mmap_resource_range(struct pci_dev *pdev, int bar, diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c index 43afbb7c5ab9..c9205a121007 100644 --- a/drivers/uio/uio.c +++ b/drivers/uio/uio.c @@ -719,9 +719,7 @@ static int uio_mmap_logical(struct vm_area_struct *vma) } static const struct vm_operations_struct uio_physical_vm_ops = { -#ifdef CONFIG_HAVE_IOREMAP_PROT .access = generic_access_phys, -#endif }; static int uio_mmap_physical(struct vm_area_struct *vma) diff --git a/mm/memory.c b/mm/memory.c index 7a089145cad4..7c0e59085456 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -5413,6 +5413,13 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr, return ret; } EXPORT_SYMBOL_GPL(generic_access_phys); +#else +int generic_access_phys(struct vm_area_struct *vma, unsigned long addr, + void *buf, int len, int write) +{ + return 0; +} +EXPORT_SYMBOL_GPL(generic_access_phys); #endif /* @@ -5437,9 +5444,8 @@ int __access_remote_vm(struct mm_struct *mm, unsigned long addr, void *buf, ret = get_user_pages_remote(mm, addr, 1, gup_flags, &page, &vma, NULL); if (ret <= 0) { -#ifndef CONFIG_HAVE_IOREMAP_PROT - break; -#else + if (!IS_ENABLED(CONFIG_HAVE_IOREMAP_PROT)) + break; /* * Check if this is a VM_IO | VM_PFNMAP VMA, which * we can access using slightly different code. @@ -5453,7 +5459,6 @@ int __access_remote_vm(struct mm_struct *mm, unsigned long addr, void *buf, if (ret <= 0) break; bytes = ret; -#endif } else { bytes = len; offset = addr & (PAGE_SIZE-1); -- 2.25.1
[PATCHv2 0/2] uio:powerpc:mpc85xx: l2-cache-sram uio driver
This series try to push an uio driver which works on freescale mpc85xx to configure its l2-cache-sram as a block of SRAM and enable user level application access of the SRAM. 1/2: For coding-style consideration of macro CONFIG_HAVE_IOREMAP_PORT; 2/2: Implementation of the uio driver. This is the second version, which addressed some commets: 1. Use __be32 instead of u32 for the big-endian data declarations; 2. Remove "static inline" version of generic_access_phys definition in .h file and give a version of no-op definition in mm/memory.c; 3. Use generic ioremap_cache instead of ioremap_coherent For v1, see: 1/2: https://lore.kernel.org/all/20220610144348.GA595923@bhelgaas/T/ 2/2: https://lore.kernel.org/lkml/yqhy1uxwclljm...@kroah.com/ Wang Wenhu (2): mm: eliminate ifdef of HAVE_IOREMAP_PROT in .c files uio:powerpc:mpc85xx: l2-cache-sram uio driver implementation drivers/char/mem.c| 2 - drivers/fpga/dfl-afu-main.c | 2 - drivers/pci/mmap.c| 2 - drivers/uio/Kconfig | 14 ++ drivers/uio/Makefile | 1 + drivers/uio/uio.c | 2 - drivers/uio/uio_fsl_85xx_cache_sram.c | 288 ++ mm/memory.c | 13 +- 8 files changed, 312 insertions(+), 12 deletions(-) create mode 100644 drivers/uio/uio_fsl_85xx_cache_sram.c -- 2.25.1
[PATCH 2/2] uio:powerpc:mpc85xx: l2-cache-sram uio driver implementation
The l2-cache could be optionally configured as SRAM partly or fully. Users can make use of it as a block of independent memory that offers special usage, such as for debuging or other cratical status info storage which keeps consistently even when the whole system crashed. The hardware related configuration process utilized the work of the earlier implementation, which has been removed now. See: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/commit/?id=dc21ed2aef4150fc2fcf58227a4ff24502015c03 Cc: Christophe Leroy Signed-off-by: Wang Wenhu --- drivers/uio/Kconfig | 10 + drivers/uio/Makefile | 1 + drivers/uio/uio_fsl_85xx_cache_sram.c | 286 ++ 3 files changed, 297 insertions(+) create mode 100644 drivers/uio/uio_fsl_85xx_cache_sram.c diff --git a/drivers/uio/Kconfig b/drivers/uio/Kconfig index 2e16c5338e5b..9199ced03880 100644 --- a/drivers/uio/Kconfig +++ b/drivers/uio/Kconfig @@ -105,6 +105,16 @@ config UIO_NETX To compile this driver as a module, choose M here; the module will be called uio_netx. +config UIO_FSL_85XX_CACHE_SRAM + tristate "Freescale 85xx Cache-Sram driver" + depends on FSL_SOC_BOOKE && PPC32 + help + Generic driver for accessing the Cache-Sram form user level. This + is extremely helpful for some user-space applications that require + high performance memory accesses. + + If you don't know what to do here, say N. + config UIO_FSL_ELBC_GPCM tristate "eLBC/GPCM driver" depends on FSL_LBC diff --git a/drivers/uio/Makefile b/drivers/uio/Makefile index f2f416a14228..1ba07d92a1b1 100644 --- a/drivers/uio/Makefile +++ b/drivers/uio/Makefile @@ -12,3 +12,4 @@ obj-$(CONFIG_UIO_MF624) += uio_mf624.o obj-$(CONFIG_UIO_FSL_ELBC_GPCM)+= uio_fsl_elbc_gpcm.o obj-$(CONFIG_UIO_HV_GENERIC) += uio_hv_generic.o obj-$(CONFIG_UIO_DFL) += uio_dfl.o +obj-$(CONFIG_UIO_FSL_85XX_CACHE_SRAM) += uio_fsl_85xx_cache_sram.o diff --git a/drivers/uio/uio_fsl_85xx_cache_sram.c b/drivers/uio/uio_fsl_85xx_cache_sram.c new file mode 100644 index ..d363f9d2b179 --- /dev/null +++ b/drivers/uio/uio_fsl_85xx_cache_sram.c @@ -0,0 +1,286 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2022 Wang Wenhu + * All rights reserved. + */ + +#include +#include +#include +#include +#include +#include +#include + +#define DRIVER_NAME"uio_mpc85xx_cache_sram" +#define UIO_INFO_VER "0.0.1" +#define UIO_NAME "uio_cache_sram" + +#define L2CR_L2FI 0x4000 /* L2 flash invalidate */ +#define L2CR_L2IO 0x0020 /* L2 instruction only */ +#define L2CR_SRAM_ZERO 0x /* L2SRAM zero size */ +#define L2CR_SRAM_FULL 0x0001 /* L2SRAM full size */ +#define L2CR_SRAM_HALF 0x0002 /* L2SRAM half size */ +#define L2CR_SRAM_TWO_HALFS0x0003 /* L2SRAM two half sizes */ +#define L2CR_SRAM_QUART0x0004 /* L2SRAM one quarter size */ +#define L2CR_SRAM_TWO_QUARTS 0x0005 /* L2SRAM two quarter size */ +#define L2CR_SRAM_EIGHTH 0x0006 /* L2SRAM one eighth size */ +#define L2CR_SRAM_TWO_EIGHTH 0x0007 /* L2SRAM two eighth size */ + +#define L2SRAM_OPTIMAL_SZ_SHIFT0x0003 /* Optimum size for L2SRAM */ + +#define L2SRAM_BAR_MSK_LO180xC000 /* Lower 18 bits */ +#define L2SRAM_BARE_MSK_HI40x000F /* Upper 4 bits */ + +enum cache_sram_lock_ways { + LOCK_WAYS_ZERO, + LOCK_WAYS_EIGHTH, + LOCK_WAYS_TWO_EIGHTH, + LOCK_WAYS_HALF = 4, + LOCK_WAYS_FULL = 8, +}; + +struct mpc85xx_l2ctlr { + u32 ctl;/* 0x000 - L2 control */ + u8 res1[0xC]; + u32 ewar0; /* 0x010 - External write address 0 */ + u32 ewarea0;/* 0x014 - External write address extended 0 */ + u32 ewcr0; /* 0x018 - External write ctrl */ + u8 res2[4]; + u32 ewar1; /* 0x020 - External write address 1 */ + u32 ewarea1;/* 0x024 - External write address extended 1 */ + u32 ewcr1; /* 0x028 - External write ctrl 1 */ + u8 res3[4]; + u32 ewar2; /* 0x030 - External write address 2 */ + u32 ewarea2;/* 0x034 - External write address extended 2 */ + u32 ewcr2; /* 0x038 - External write ctrl 2 */ + u8 res4[4]; + u32 ewar3; /* 0x040 - External write address 3 */ + u32 ewarea3;/* 0x044 - External write address extended 3 */ + u32 ewcr3; /* 0x048 - External write ctrl 3 */ + u8 res5[0xB4];
[PATCH 1/2] powerpc:mm: export symbol ioremap_coherent
The function ioremap_coherent may be called by modules such as fsl_85xx_cache_sram. So export it for access in other modules. Signed-off-by: Wang Wenhu --- arch/powerpc/mm/ioremap.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/mm/ioremap.c b/arch/powerpc/mm/ioremap.c index 4f12504fb405..08a00dacef0b 100644 --- a/arch/powerpc/mm/ioremap.c +++ b/arch/powerpc/mm/ioremap.c @@ -40,6 +40,7 @@ void __iomem *ioremap_coherent(phys_addr_t addr, unsigned long size) return iowa_ioremap(addr, size, prot, caller); return __ioremap_caller(addr, size, prot, caller); } +EXPORT_SYMBOL(ioremap_coherent); void __iomem *ioremap_prot(phys_addr_t addr, unsigned long size, unsigned long flags) { -- 2.25.1
[PATCH 0/2] uio:ppc: cache-sram driver implementation
Patch 1 exports the symbol ioremap_coherent which is used by the driver. Patch 2 is the implementation of uio driver for freescale mpc85xx. Wang Wenhu (2): powerpc:mm: export symbol ioremap_coherent uio:powerpc:mpc85xx: l2-cache-sram uio driver implementation arch/powerpc/mm/ioremap.c | 1 + drivers/uio/Kconfig | 10 + drivers/uio/Makefile | 1 + drivers/uio/uio_fsl_85xx_cache_sram.c | 286 ++ 4 files changed, 298 insertions(+) create mode 100644 drivers/uio/uio_fsl_85xx_cache_sram.c -- 2.25.1
[PATCH v4, 5/5] powerpc: sysdev: support userspace access of fsl_85xx_sram
New module which registers its memory allocation and free APIs to the sram_dynamic module, which would create a device of struct sram_device type to act as an interface for user level applications to access the backend hardware device, fsl_85xx_cache_sram, which is drived by the FSL_85XX_CACHE_SRAM module. Signed-off-by: Wang Wenhu Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: Greg Kroah-Hartman Cc: Arnd Bergmann Cc: linuxppc-dev@lists.ozlabs.org --- Changes since v3: Addressed comments from Christophe * Move the module to drivers/soc/fsl/ directory * Minor changes of coding-style --- .../powerpc/include/asm/fsl_85xx_cache_sram.h | 17 arch/powerpc/sysdev/fsl_85xx_cache_ctlr.h | 2 + arch/powerpc/sysdev/fsl_85xx_cache_sram.c | 2 + arch/powerpc/sysdev/fsl_85xx_sram_uapi.c | 39 +++ drivers/soc/fsl/Kconfig | 12 ++ drivers/soc/fsl/Makefile | 1 + drivers/soc/fsl/fsl_85xx_sram.h | 13 +++ drivers/soc/fsl/fsl_85xx_sram_uapi.c | 39 +++ 8 files changed, 125 insertions(+) create mode 100644 arch/powerpc/sysdev/fsl_85xx_sram_uapi.c create mode 100644 drivers/soc/fsl/fsl_85xx_sram.h create mode 100644 drivers/soc/fsl/fsl_85xx_sram_uapi.c diff --git a/arch/powerpc/include/asm/fsl_85xx_cache_sram.h b/arch/powerpc/include/asm/fsl_85xx_cache_sram.h index 0235a0447baa..50fd6733c506 100644 --- a/arch/powerpc/include/asm/fsl_85xx_cache_sram.h +++ b/arch/powerpc/include/asm/fsl_85xx_cache_sram.h @@ -26,8 +26,25 @@ struct mpc85xx_cache_sram { unsigned int size; rh_info_t *rh; spinlock_t lock; + +#ifdef CONFIG_FSL_85XX_SRAM_UAPI + struct device *dev; +#endif }; +#ifdef CONFIG_FSL_85XX_SRAM_UAPI +static inline void set_cache_sram_dev(struct mpc85xx_cache_sram *sram, + struct device *dev) +{ + sram->dev = dev; +} +#else +static inline void set_cache_sram_dev(struct mpc85xx_cache_sram *sram, + struct device *dev) +{ +} +#endif + extern void mpc85xx_cache_sram_free(void *ptr); extern void *mpc85xx_cache_sram_alloc(unsigned int size, phys_addr_t *phys, unsigned int align); diff --git a/arch/powerpc/sysdev/fsl_85xx_cache_ctlr.h b/arch/powerpc/sysdev/fsl_85xx_cache_ctlr.h index ce370749add9..beb855adcfec 100644 --- a/arch/powerpc/sysdev/fsl_85xx_cache_ctlr.h +++ b/arch/powerpc/sysdev/fsl_85xx_cache_ctlr.h @@ -10,6 +10,8 @@ #ifndef __FSL_85XX_CACHE_CTLR_H__ #define __FSL_85XX_CACHE_CTLR_H__ +#include + #define L2CR_L2FI 0x4000 /* L2 flash invalidate */ #define L2CR_L2IO 0x0020 /* L2 instruction only */ #define L2CR_SRAM_ZERO 0x /* L2SRAM zero size */ diff --git a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c index 3de5ac8382c0..96d4a02b06fe 100644 --- a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c +++ b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c @@ -115,6 +115,8 @@ int instantiate_cache_sram(struct platform_device *dev, rh_attach_region(cache_sram->rh, 0, cache_sram->size); spin_lock_init(&cache_sram->lock); + set_cache_sram_dev(cache_sram, &dev->dev); + dev_info(&dev->dev, "[base:0x%llx, size:0x%x] configured and loaded\n", (unsigned long long)cache_sram->base_phys, cache_sram->size); diff --git a/arch/powerpc/sysdev/fsl_85xx_sram_uapi.c b/arch/powerpc/sysdev/fsl_85xx_sram_uapi.c new file mode 100644 index ..64fdf082d069 --- /dev/null +++ b/arch/powerpc/sysdev/fsl_85xx_sram_uapi.c @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2020 Vivo Communication Technology Co. Ltd. + * Copyright (C) 2020 Wang Wenhu + * All rights reserved. + */ + +#include +#include +#include +#include +#include "fsl_85xx_sram.h" + +static struct sram_api mpc85xx_sram_api = { + .name = "mpc85xx_sram", + .alloc = mpc85xx_cache_sram_alloc, + .free = mpc85xx_cache_sram_free, +}; + +static int __init mpc85xx_sram_uapi_init(void) +{ + struct mpc85xx_cache_sram *sram = mpc85xx_get_cache_sram(); + + if (!sram) + return -ENODEV; + + return sram_register_device(sram->dev, &mpc85xx_sram_api); +} +subsys_initcall(mpc85xx_sram_uapi_init); + +static void __exit mpc85xx_sram_uapi_exit(void) +{ + sram_unregister_device(&mpc85xx_sram_api); +} +module_exit(mpc85xx_sram_uapi_exit); + +MODULE_AUTHOR("Wang Wenhu "); +MODULE_DESCRIPTION("MPC85xx SRAM User-Space API Support"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig index 4df32bc4c7a6..ceeebb22f6d3 100644 --- a/drivers/soc/fsl/Kconfig +++ b/drivers/soc/fsl/Kconfig @@ -50,4 +50,16 @@ config FSL_RCPM tasks
[PATCH v4, 3/5] powerpc: sysdev: fix compile warning for fsl_85xx_cache_sram
Function instantiate_cache_sram should not be linked into the init section for its caller mpc85xx_l2ctlr_of_probe is none-__init. Cc: Greg Kroah-Hartman Cc: Arnd Bergmann Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: Randy Dunlap Cc: linuxppc-dev@lists.ozlabs.org Fixes: 6db92cc9d07d ("powerpc/85xx: add cache-sram support") Reviewed-by: Christophe Leroy Signed-off-by: Wang Wenhu --- No change v1-v4 --- arch/powerpc/sysdev/fsl_85xx_cache_sram.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c index be3aef4229d7..3de5ac8382c0 100644 --- a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c +++ b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c @@ -68,7 +68,7 @@ void mpc85xx_cache_sram_free(void *ptr) } EXPORT_SYMBOL(mpc85xx_cache_sram_free); -int __init instantiate_cache_sram(struct platform_device *dev, +int instantiate_cache_sram(struct platform_device *dev, struct sram_parameters sram_params) { int ret = 0; -- 2.17.1
[PATCH v4,4/5] misc: sram_dynamic for user level SRAM access
A generic User-Kernel interface module that allows a misc device created when a backend SRAM hardware device driver registers its APIs to support file operations of ioctl and mmap for user space applications to allocate SRAM memory, mmap it to process address space and free it then after. It is extremely helpful for the user space applications that require high performance memory accesses, such as embedded networking devices that would process data in user space, and PowerPC e500 is one case. Signed-off-by: Wang Wenhu Cc: Greg Kroah-Hartman Cc: Arnd Bergmann Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org --- Changes since v1: addressed comments from Arnd * Changed the ioctl cmd definitions using _IO micros * Export interfaces for HW-SRAM drivers to register apis to available list * Modified allocation alignment to PAGE_SIZE * Use phys_addr_t as type of SRAM resource size and offset * Support compat_ioctl * Misc device name:sram * Use tristate for SRAM_UAPI * Use postcore_initcall Changes since v2: addressed comments from Arnd, greg and Scott * Name the module with sram_dynamic in comparing with drivers/misc/sram.c I tried to tie the sram_dynamic with the abstractions in sram.c as Arnd suggested, and actually sram.c probes SRAM devices from devicetree and manages them with different partitions and create memory pools which are managed with genalloc functions. Here sram_dynamic acts only as a interface to user space. A SRAM memory pool is managed by the module that registers APIs to us, such as the backend hardware driver of Freescale 85xx Cache-SRAM. * Create one sram_device for each backend SRAM device(from Scott) * Allow only one block of SRAM memory allocated to a file descriptor(from Scott) * Add sysfs files for every allocated SRAM memory block * More documentations(As Greg commented) * Make uapi and non-uapi components apart(from Arnd and Greg) Changes since v3: * Addressed comments from Christophe * Auto select SRAM_DYNAMIC by the caller modules * Delete useless sram_uapi.c Links: v1: https://lore.kernel.org/lkml/20200418162157.50428-5-wenhu.w...@vivo.com/ v2: https://lore.kernel.org/lkml/20200420030538.101696-1-wenhu.w...@vivo.com/ UIO version: v5: https://lore.kernel.org/lkml/20200417071616.44598-5-wenhu.w...@vivo.com/ --- drivers/misc/Kconfig | 11 + drivers/misc/Makefile| 1 + drivers/misc/sram_dynamic.c | 580 +++ include/linux/sram_dynamic.h | 23 ++ include/uapi/linux/sram.h| 11 + 5 files changed, 626 insertions(+) create mode 100644 drivers/misc/sram_dynamic.c create mode 100644 include/linux/sram_dynamic.h create mode 100644 include/uapi/linux/sram.h diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index 99e151475d8f..26f161bc0282 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -465,6 +465,17 @@ config PVPANIC a paravirtualized device provided by QEMU; it lets a virtual machine (guest) communicate panic events to the host. +config SRAM_DYNAMIC + tristate + help + This driver allows you to create a misc device which could be used + as an interface to allocate SRAM memory from user level dynamically. + + It is extremely helpful for some user space applications that require + high performance memory accesses. + + If unsure, say N. + source "drivers/misc/c2port/Kconfig" source "drivers/misc/eeprom/Kconfig" source "drivers/misc/cb710/Kconfig" diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index 9abf2923d831..c32085026d30 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -46,6 +46,7 @@ obj-$(CONFIG_VMWARE_VMCI) += vmw_vmci/ obj-$(CONFIG_LATTICE_ECP3_CONFIG) += lattice-ecp3-config.o obj-$(CONFIG_SRAM) += sram.o obj-$(CONFIG_SRAM_EXEC)+= sram-exec.o +obj-$(CONFIG_SRAM_DYNAMIC) += sram_dynamic.o obj-y += mic/ obj-$(CONFIG_GENWQE) += genwqe/ obj-$(CONFIG_ECHO) += echo/ diff --git a/drivers/misc/sram_dynamic.c b/drivers/misc/sram_dynamic.c new file mode 100644 index ..ea2d4d92cccf --- /dev/null +++ b/drivers/misc/sram_dynamic.c @@ -0,0 +1,580 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2020 Vivo Communication Technology Co. Ltd. + * Copyright (C) 2020 Wang Wenhu + * All rights reserved. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define SRAM_MAX_DEVICES (1U << MINORBITS) + +/** + * struct sram_res - allocated SRAM memory resource description. + * + * @virt: virtual memory address of the SRAM memory resource + * @phys: physical memory address of the SRAM memory resource + * @size: size of the SRAM memory resource + * @sdev: sram_device the resource belongs t
[PATCH v4, 2/5] powerpc: sysdev: fix compile error for fsl_85xx_cache_sram
Include linux/io.h into fsl_85xx_cache_sram.c to fix the implicit-declaration compile error when building Cache-Sram. arch/powerpc/sysdev/fsl_85xx_cache_sram.c: In function ‘instantiate_cache_sram’: arch/powerpc/sysdev/fsl_85xx_cache_sram.c:97:26: error: implicit declaration of function ‘ioremap_coherent’; did you mean ‘bitmap_complement’? [-Werror=implicit-function-declaration] cache_sram->base_virt = ioremap_coherent(cache_sram->base_phys, ^~~~ bitmap_complement arch/powerpc/sysdev/fsl_85xx_cache_sram.c:97:24: error: assignment makes pointer from integer without a cast [-Werror=int-conversion] cache_sram->base_virt = ioremap_coherent(cache_sram->base_phys, ^ arch/powerpc/sysdev/fsl_85xx_cache_sram.c:123:2: error: implicit declaration of function ‘iounmap’; did you mean ‘roundup’? [-Werror=implicit-function-declaration] iounmap(cache_sram->base_virt); ^~~ roundup cc1: all warnings being treated as errors Cc: Greg Kroah-Hartman Cc: Arnd Bergmann Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: Randy Dunlap Cc: linuxppc-dev@lists.ozlabs.org Fixes: 6db92cc9d07d ("powerpc/85xx: add cache-sram support") Reviewed-by: Christophe Leroy Signed-off-by: Wang Wenhu --- No change v1-v4 --- arch/powerpc/sysdev/fsl_85xx_cache_sram.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c index f6c665dac725..be3aef4229d7 100644 --- a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c +++ b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "fsl_85xx_cache_ctlr.h" -- 2.17.1
[PATCH v4, 1/5] powerpc: sysdev: fix compile error for fsl_85xx_l2ctlr
Include "linux/of_address.h" to fix the compile error for mpc85xx_l2ctlr_of_probe() when compiling fsl_85xx_cache_sram.c. CC arch/powerpc/sysdev/fsl_85xx_l2ctlr.o arch/powerpc/sysdev/fsl_85xx_l2ctlr.c: In function ‘mpc85xx_l2ctlr_of_probe’: arch/powerpc/sysdev/fsl_85xx_l2ctlr.c:90:11: error: implicit declaration of function ‘of_iomap’; did you mean ‘pci_iomap’? [-Werror=implicit-function-declaration] l2ctlr = of_iomap(dev->dev.of_node, 0); ^~~~ pci_iomap arch/powerpc/sysdev/fsl_85xx_l2ctlr.c:90:9: error: assignment makes pointer from integer without a cast [-Werror=int-conversion] l2ctlr = of_iomap(dev->dev.of_node, 0); ^ cc1: all warnings being treated as errors scripts/Makefile.build:267: recipe for target 'arch/powerpc/sysdev/fsl_85xx_l2ctlr.o' failed make[2]: *** [arch/powerpc/sysdev/fsl_85xx_l2ctlr.o] Error 1 Cc: Greg Kroah-Hartman Cc: Arnd Bergmann Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: Randy Dunlap Cc: linuxppc-dev@lists.ozlabs.org Fixes: 6db92cc9d07d ("powerpc/85xx: add cache-sram support") Reviewed-by: Christophe Leroy Signed-off-by: Wang Wenhu --- No change v1-v4 --- arch/powerpc/sysdev/fsl_85xx_l2ctlr.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c b/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c index 2d0af0c517bb..7533572492f0 100644 --- a/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c +++ b/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include "fsl_85xx_cache_ctlr.h" -- 2.17.1
[PATCH v3, 5/5] powerpc: sysdev: support userspace access of fsl_85xx_sram
New module which registers its memory allocation and free APIs to the sram_dynamic module, which would create a device of struct sram_device type to act as an interface for user level applications to access the backend hardware device, fsl_85xx_cache_sram, which is drived by the FSL_85XX_CACHE_SRAM module. Signed-off-by: Wang Wenhu Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: Greg Kroah-Hartman Cc: Arnd Bergmann Cc: linuxppc-dev@lists.ozlabs.org --- .../powerpc/include/asm/fsl_85xx_cache_sram.h | 4 ++ arch/powerpc/platforms/85xx/Kconfig | 10 + arch/powerpc/sysdev/Makefile | 1 + arch/powerpc/sysdev/fsl_85xx_cache_ctlr.h | 6 +++ arch/powerpc/sysdev/fsl_85xx_cache_sram.c | 12 ++ arch/powerpc/sysdev/fsl_85xx_sram_uapi.c | 39 +++ 6 files changed, 72 insertions(+) create mode 100644 arch/powerpc/sysdev/fsl_85xx_sram_uapi.c diff --git a/arch/powerpc/include/asm/fsl_85xx_cache_sram.h b/arch/powerpc/include/asm/fsl_85xx_cache_sram.h index 0235a0447baa..99cb7e202c38 100644 --- a/arch/powerpc/include/asm/fsl_85xx_cache_sram.h +++ b/arch/powerpc/include/asm/fsl_85xx_cache_sram.h @@ -26,6 +26,10 @@ struct mpc85xx_cache_sram { unsigned int size; rh_info_t *rh; spinlock_t lock; + +#ifdef CONFIG_FSL_85XX_SRAM_UAPI + struct device *dev; +#endif }; extern void mpc85xx_cache_sram_free(void *ptr); diff --git a/arch/powerpc/platforms/85xx/Kconfig b/arch/powerpc/platforms/85xx/Kconfig index fa3d29dcb57e..3a6f6af973eb 100644 --- a/arch/powerpc/platforms/85xx/Kconfig +++ b/arch/powerpc/platforms/85xx/Kconfig @@ -16,6 +16,16 @@ if FSL_SOC_BOOKE if PPC32 +config FSL_85XX_SRAM_UAPI + tristate "Freescale MPC85xx SRAM UAPI Support" + depends on FSL_SOC_BOOKE && SRAM_DYNAMIC + select FSL_85XX_CACHE_SRAM + help + This registers a device of struct sram_device type which would act as + an interface for user level applications to access the Freescale 85xx + Cache-SRAM memory dynamically, meaning allocate on demand dynamically + while they are running. + config FSL_85XX_CACHE_SRAM bool select PPC_LIB_RHEAP diff --git a/arch/powerpc/sysdev/Makefile b/arch/powerpc/sysdev/Makefile index cb5a5bd2cef5..e71f82f0d2c3 100644 --- a/arch/powerpc/sysdev/Makefile +++ b/arch/powerpc/sysdev/Makefile @@ -24,6 +24,7 @@ obj-$(CONFIG_FSL_CORENET_RCPM)+= fsl_rcpm.o obj-$(CONFIG_FSL_LBC) += fsl_lbc.o obj-$(CONFIG_FSL_GTM) += fsl_gtm.o obj-$(CONFIG_FSL_85XX_CACHE_SRAM) += fsl_85xx_l2ctlr.o fsl_85xx_cache_sram.o +obj-$(CONFIG_FSL_85XX_SRAM_UAPI) += fsl_85xx_sram_uapi.o obj-$(CONFIG_FSL_RIO) += fsl_rio.o fsl_rmu.o obj-$(CONFIG_TSI108_BRIDGE)+= tsi108_pci.o tsi108_dev.o obj-$(CONFIG_RTC_DRV_CMOS) += rtc_cmos_setup.o diff --git a/arch/powerpc/sysdev/fsl_85xx_cache_ctlr.h b/arch/powerpc/sysdev/fsl_85xx_cache_ctlr.h index ce370749add9..4930784d9852 100644 --- a/arch/powerpc/sysdev/fsl_85xx_cache_ctlr.h +++ b/arch/powerpc/sysdev/fsl_85xx_cache_ctlr.h @@ -10,6 +10,8 @@ #ifndef __FSL_85XX_CACHE_CTLR_H__ #define __FSL_85XX_CACHE_CTLR_H__ +#include + #define L2CR_L2FI 0x4000 /* L2 flash invalidate */ #define L2CR_L2IO 0x0020 /* L2 instruction only */ #define L2CR_SRAM_ZERO 0x /* L2SRAM zero size */ @@ -81,6 +83,10 @@ struct sram_parameters { phys_addr_t sram_offset; }; +#ifdef CONFIG_FSL_85XX_SRAM_UAPI +extern struct mpc85xx_cache_sram *mpc85xx_get_cache_sram(void); +#endif + extern int instantiate_cache_sram(struct platform_device *dev, struct sram_parameters sram_params); extern void remove_cache_sram(struct platform_device *dev); diff --git a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c index 3de5ac8382c0..0156ea63a3a2 100644 --- a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c +++ b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c @@ -23,6 +23,14 @@ struct mpc85xx_cache_sram *cache_sram; + +#ifdef CONFIG_FSL_85XX_SRAM_UAPI +struct mpc85xx_cache_sram *mpc85xx_get_cache_sram(void) +{ + return cache_sram; +} +#endif + void *mpc85xx_cache_sram_alloc(unsigned int size, phys_addr_t *phys, unsigned int align) { @@ -115,6 +123,10 @@ int instantiate_cache_sram(struct platform_device *dev, rh_attach_region(cache_sram->rh, 0, cache_sram->size); spin_lock_init(&cache_sram->lock); +#ifdef CONFIG_FSL_85XX_SRAM_UAPI + cache_sram->dev = &dev->dev; +#endif + dev_info(&dev->dev, "[base:0x%llx, size:0x%x] configured and loaded\n", (unsigned long long)cache_sram->base_phys, cache_sram->size); diff --git a/arch/powerpc/sysdev/fsl_85xx_sram_uapi.c b/arch/powerpc/sysdev/fsl_85xx_sram_uapi.c new file mode 100644 index 00
[PATCH v3,4/5] misc: sram_dynamic for user level SRAM access
A generic User-Kernel interface module that allows a misc device created when a backend SRAM hardware device driver registers its APIs to support file operations of ioctl and mmap for user space applications to allocate SRAM memory, mmap it to process address space and free it then after. It is extremely helpful for the user space applications that require high performance memory accesses, such as embedded networking devices that would process data in user space, and PowerPC e500 is one case. Signed-off-by: Wang Wenhu Cc: Greg Kroah-Hartman Cc: Arnd Bergmann Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org --- Changes since v1: addressed comments from Arnd * Changed the ioctl cmd definitions using _IO micros * Export interfaces for HW-SRAM drivers to register apis to available list * Modified allocation alignment to PAGE_SIZE * Use phys_addr_t as type of SRAM resource size and offset * Support compat_ioctl * Misc device name:sram * Use tristate for SRAM_UAPI * Use postcore_initcall Changes since v2: addressed comments from Arnd, greg and Scott * Name the module with sram_dynamic in comparing with drivers/misc/sram.c I tried to tie the sram_dynamic with the abstractions in sram.c as Arnd suggested, and actually sram.c probes SRAM devices from devicetree and manages them with different partitions and create memory pools which are managed with genalloc functions. Here sram_dynamic acts only as a interface to user space. A SRAM memory pool is managed by the module that registers APIs to us, such as the backend hardware driver of Freescale 85xx Cache-SRAM. * Create one sram_device for each backend SRAM device(from Scott) * Allow only one block of SRAM memory allocated to a file descriptor(from Scott) * Add sysfs files for every allocated SRAM memory block * More documentations(As Greg commented) * Make uapi and non-uapi components apart(from Arnd and Greg) Links: v1: https://lore.kernel.org/lkml/20200418162157.50428-5-wenhu.w...@vivo.com/ v2: https://lore.kernel.org/lkml/20200420030538.101696-1-wenhu.w...@vivo.com/ UIO version: v5: https://lore.kernel.org/lkml/20200417071616.44598-5-wenhu.w...@vivo.com/ --- drivers/misc/Kconfig | 11 + drivers/misc/Makefile| 1 + drivers/misc/sram_dynamic.c | 580 +++ drivers/misc/sram_uapi.c | 351 + include/linux/sram_dynamic.h | 23 ++ include/uapi/linux/sram.h| 11 + 6 files changed, 977 insertions(+) create mode 100644 drivers/misc/sram_dynamic.c create mode 100644 drivers/misc/sram_uapi.c create mode 100644 include/linux/sram_dynamic.h create mode 100644 include/uapi/linux/sram.h diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index 99e151475d8f..b7ad84e93855 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -465,6 +465,17 @@ config PVPANIC a paravirtualized device provided by QEMU; it lets a virtual machine (guest) communicate panic events to the host. +config SRAM_DYNAMIC + tristate "Generic SRAM User Level Dynamic Access API support" + help + This driver allows you to create a misc device which could be used + as an interface to allocate SRAM memory from user level dynamically. + + It is extremely helpful for some user space applications that require + high performance memory accesses. + + If unsure, say N. + source "drivers/misc/c2port/Kconfig" source "drivers/misc/eeprom/Kconfig" source "drivers/misc/cb710/Kconfig" diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index 9abf2923d831..c32085026d30 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -46,6 +46,7 @@ obj-$(CONFIG_VMWARE_VMCI) += vmw_vmci/ obj-$(CONFIG_LATTICE_ECP3_CONFIG) += lattice-ecp3-config.o obj-$(CONFIG_SRAM) += sram.o obj-$(CONFIG_SRAM_EXEC)+= sram-exec.o +obj-$(CONFIG_SRAM_DYNAMIC) += sram_dynamic.o obj-y += mic/ obj-$(CONFIG_GENWQE) += genwqe/ obj-$(CONFIG_ECHO) += echo/ diff --git a/drivers/misc/sram_dynamic.c b/drivers/misc/sram_dynamic.c new file mode 100644 index ..ea2d4d92cccf --- /dev/null +++ b/drivers/misc/sram_dynamic.c @@ -0,0 +1,580 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2020 Vivo Communication Technology Co. Ltd. + * Copyright (C) 2020 Wang Wenhu + * All rights reserved. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define SRAM_MAX_DEVICES (1U << MINORBITS) + +/** + * struct sram_res - allocated SRAM memory resource description. + * + * @virt: virtual memory address of the SRAM memory resource + * @phys: physical memory address of the SRAM memory resource + * @size: size of the SRAM memory resource + * @sdev:
[PATCH v3, 3/5] powerpc: sysdev: fix compile warning for fsl_85xx_cache_sram
Function instantiate_cache_sram should not be linked into the init section for its caller mpc85xx_l2ctlr_of_probe is none-__init. Cc: Greg Kroah-Hartman Cc: Arnd Bergmann Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org Fixes: 6db92cc9d07d ("powerpc/85xx: add cache-sram support") Reviewed-by: Christophe Leroy Signed-off-by: Wang Wenhu --- No changes --- arch/powerpc/sysdev/fsl_85xx_cache_sram.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c index be3aef4229d7..3de5ac8382c0 100644 --- a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c +++ b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c @@ -68,7 +68,7 @@ void mpc85xx_cache_sram_free(void *ptr) } EXPORT_SYMBOL(mpc85xx_cache_sram_free); -int __init instantiate_cache_sram(struct platform_device *dev, +int instantiate_cache_sram(struct platform_device *dev, struct sram_parameters sram_params) { int ret = 0; -- 2.17.1
[PATCH v3, 2/5] powerpc: sysdev: fix compile error for fsl_85xx_cache_sram
Include linux/io.h into fsl_85xx_cache_sram.c to fix the implicit-declaration compile error when building Cache-Sram. arch/powerpc/sysdev/fsl_85xx_cache_sram.c: In function ‘instantiate_cache_sram’: arch/powerpc/sysdev/fsl_85xx_cache_sram.c:97:26: error: implicit declaration of function ‘ioremap_coherent’; did you mean ‘bitmap_complement’? [-Werror=implicit-function-declaration] cache_sram->base_virt = ioremap_coherent(cache_sram->base_phys, ^~~~ bitmap_complement arch/powerpc/sysdev/fsl_85xx_cache_sram.c:97:24: error: assignment makes pointer from integer without a cast [-Werror=int-conversion] cache_sram->base_virt = ioremap_coherent(cache_sram->base_phys, ^ arch/powerpc/sysdev/fsl_85xx_cache_sram.c:123:2: error: implicit declaration of function ‘iounmap’; did you mean ‘roundup’? [-Werror=implicit-function-declaration] iounmap(cache_sram->base_virt); ^~~ roundup cc1: all warnings being treated as errors Cc: Greg Kroah-Hartman Cc: Arnd Bergmann Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org Fixes: 6db92cc9d07d ("powerpc/85xx: add cache-sram support") Reviewed-by: Christophe Leroy Signed-off-by: Wang Wenhu --- No changes --- arch/powerpc/sysdev/fsl_85xx_cache_sram.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c index f6c665dac725..be3aef4229d7 100644 --- a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c +++ b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "fsl_85xx_cache_ctlr.h" -- 2.17.1
[PATCH v3,0/5] misc: generic user level sram dynamic access support
This series add a new misc module that act as an interface for user level applications to access SRAM memory dynamically. Freescale 85xx Cache-SRAM is exact an example. This is extremely helpful for the user level applications that require high performance memory accesses, such as some embedded networking devices that need to process data in user space. The series also fix the compile errors and warning of the freescale 85xx Cache-SRAM driver, and implement a module to register the SRAM device to sram_dynamic module, which enables its access for users in user space. Changes since v1: addressed comments from Arnd * Changed the ioctl cmd definitions using _IO micros * Export interfaces for HW-SRAM drivers to register apis to available list * Modified allocation alignment to PAGE_SIZE * Use phys_addr_t as type of SRAM resource size and offset * Support compat_ioctl * Misc device name:sram * Use tristate for SRAM_UAPI * Use postcore_initcall Changes since v2: addressed comments from Arnd, greg and Scott * Name the module with sram_dynamic in comparing with drivers/misc/sram.c I tried to tie the sram_dynamic with the abstractions in sram.c as Arnd suggested, and actually sram.c probes SRAM devices from devicetree and manages them with different partitions and create memory pools which are managed with genalloc functions. Here sram_dynamic acts only as a interface to user space. A SRAM memory pool is managed by the module that registers APIs to us, such as the backend hardware driver of Freescale 85xx Cache-SRAM. * Create one sram_device for each backend SRAM device(from Scott) * Allow only one block of SRAM memory allocated to a file descriptor(from Scott) * Add sysfs files for every allocated SRAM memory block * More documentations(As Greg commented) * Make uapi and non-uapi components apart(from Arnd and Greg) * Add a new module to register freescale 85xx Cache-SRAM APIs to the sram_dynamic module Wang Wenhu (5): powerpc: sysdev: fix compile error for fsl_85xx_l2ctlr powerpc: sysdev: fix compile error for fsl_85xx_cache_sram powerpc: sysdev: fix compile warning for fsl_85xx_cache_sram misc: sram_dynamic for user level SRAM access powerpc: sysdev: support userspace access of fsl 85xx sram .../powerpc/include/asm/fsl_85xx_cache_sram.h | 4 + arch/powerpc/platforms/85xx/Kconfig | 10 + arch/powerpc/sysdev/Makefile | 1 + arch/powerpc/sysdev/fsl_85xx_cache_ctlr.h | 6 + arch/powerpc/sysdev/fsl_85xx_cache_sram.c | 15 +- arch/powerpc/sysdev/fsl_85xx_l2ctlr.c | 1 + arch/powerpc/sysdev/fsl_85xx_sram_uapi.c | 39 ++ drivers/misc/Kconfig | 11 + drivers/misc/Makefile | 1 + drivers/misc/sram_dynamic.c | 580 ++ drivers/misc/sram_uapi.c | 351 +++ include/linux/sram_dynamic.h | 23 + include/uapi/linux/sram.h | 11 + 13 files changed, 1052 insertions(+), 1 deletion(-) create mode 100644 arch/powerpc/sysdev/fsl_85xx_sram_uapi.c create mode 100644 drivers/misc/sram_dynamic.c create mode 100644 drivers/misc/sram_uapi.c create mode 100644 include/linux/sram_dynamic.h create mode 100644 include/uapi/linux/sram.h -- 2.17.1
[PATCH v3, 1/5] powerpc: sysdev: fix compile error for fsl_85xx_l2ctlr
Include "linux/of_address.h" to fix the compile error for mpc85xx_l2ctlr_of_probe() when compiling fsl_85xx_cache_sram.c. CC arch/powerpc/sysdev/fsl_85xx_l2ctlr.o arch/powerpc/sysdev/fsl_85xx_l2ctlr.c: In function ‘mpc85xx_l2ctlr_of_probe’: arch/powerpc/sysdev/fsl_85xx_l2ctlr.c:90:11: error: implicit declaration of function ‘of_iomap’; did you mean ‘pci_iomap’? [-Werror=implicit-function-declaration] l2ctlr = of_iomap(dev->dev.of_node, 0); ^~~~ pci_iomap arch/powerpc/sysdev/fsl_85xx_l2ctlr.c:90:9: error: assignment makes pointer from integer without a cast [-Werror=int-conversion] l2ctlr = of_iomap(dev->dev.of_node, 0); ^ cc1: all warnings being treated as errors scripts/Makefile.build:267: recipe for target 'arch/powerpc/sysdev/fsl_85xx_l2ctlr.o' failed make[2]: *** [arch/powerpc/sysdev/fsl_85xx_l2ctlr.o] Error 1 Cc: Greg Kroah-Hartman Cc: Arnd Bergmann Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org Fixes: 6db92cc9d07d ("powerpc/85xx: add cache-sram support") Reviewed-by: Christophe Leroy Signed-off-by: Wang Wenhu --- No changes --- arch/powerpc/sysdev/fsl_85xx_l2ctlr.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c b/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c index 2d0af0c517bb..7533572492f0 100644 --- a/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c +++ b/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include "fsl_85xx_cache_ctlr.h" -- 2.17.1
[PATCH v2, RESEND] misc: new driver sram_uapi for user level SRAM access
A generic User-Kernel interface that allows a misc device created by it to support file-operations of ioctl and mmap to access SRAM memory from user level. Different kinds of SRAM alloction and free APIs could be registered by specific SRAM hardware level driver to the available list and then be chosen by users to allocate and map SRAM memory from user level. It is extremely helpful for the user space applications that require high performance memory accesses, such as embedded networking devices that would process data in user space, and PowerPC e500 is a case. Signed-off-by: Wang Wenhu Cc: Greg Kroah-Hartman Cc: Arnd Bergmann Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: Randy Dunlap Cc: linuxppc-dev@lists.ozlabs.org --- Changes since v1: addressed comments from Arnd * Changed the ioctl cmd definitions using _IO micros * Export interfaces for HW-SRAM drivers to register apis to available list * Modified allocation alignment to PAGE_SIZE * Use phys_addr_t as type of SRAM resource size and offset * Support compat_ioctl * Misc device name:sram Note: From this on, the SRAM_UAPI driver is independent to any hardware drivers, so I would only commit the patch itself as v2, while the v1 of it was wrapped together with patches for Freescale L2-Cache-SRAM device. Then after, I'd create patches for Freescale L2-Cache-SRAM device as another series. Link for v1: * https://lore.kernel.org/lkml/20200418162157.50428-5-wenhu.w...@vivo.com/ --- drivers/misc/Kconfig | 11 ++ drivers/misc/Makefile | 1 + drivers/misc/sram_uapi.c | 352 ++ include/linux/sram_uapi.h | 28 +++ 4 files changed, 392 insertions(+) create mode 100644 drivers/misc/sram_uapi.c create mode 100644 include/linux/sram_uapi.h diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index 99e151475d8f..b19c8b24f18e 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -465,6 +465,17 @@ config PVPANIC a paravirtualized device provided by QEMU; it lets a virtual machine (guest) communicate panic events to the host. +config SRAM_UAPI + bool "Generic SRAM User Level API driver" + help + This driver allows you to create a misc device which could be used + as an interface to allocate SRAM memory from user level. + + It is extremely helpful for some user space applications that require + high performance memory accesses. + + If unsure, say N. + source "drivers/misc/c2port/Kconfig" source "drivers/misc/eeprom/Kconfig" source "drivers/misc/cb710/Kconfig" diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index 9abf2923d831..794447ca07ca 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -46,6 +46,7 @@ obj-$(CONFIG_VMWARE_VMCI) += vmw_vmci/ obj-$(CONFIG_LATTICE_ECP3_CONFIG) += lattice-ecp3-config.o obj-$(CONFIG_SRAM) += sram.o obj-$(CONFIG_SRAM_EXEC)+= sram-exec.o +obj-$(CONFIG_SRAM_UAPI)+= sram_uapi.o obj-y += mic/ obj-$(CONFIG_GENWQE) += genwqe/ obj-$(CONFIG_ECHO) += echo/ diff --git a/drivers/misc/sram_uapi.c b/drivers/misc/sram_uapi.c new file mode 100644 index ..66c7b56b635f --- /dev/null +++ b/drivers/misc/sram_uapi.c @@ -0,0 +1,352 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2020 Vivo Communication Technology Co. Ltd. + * Copyright (C) 2020 Wang Wenhu + * All rights reserved. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define DRIVER_NAME"sram_uapi" + +struct res_info { + phys_addr_t offset; + phys_addr_t size; +}; + +struct sram_resource { + struct list_headlist; + struct res_info info; + phys_addr_t phys; + void*virt; + struct vm_area_struct *vma; + struct sram_uapi*parent; +}; + +struct sram_uapi { + struct list_headres_list; + struct sram_api *sa; +}; + +static DEFINE_MUTEX(sram_api_list_lock); +static LIST_HEAD(sram_api_list); + +long sram_api_register(struct sram_api *sa) +{ + struct sram_api *cur; + + if (!sa || !sa->name || !sa->sram_alloc || !sa->sram_free) + return -EINVAL; + + mutex_lock(&sram_api_list_lock); + list_for_each_entry(cur, &sram_api_list, list) { + if (cur->type == sa->type) { + pr_err("error sram %s type %d exists\n", sa->name, + sa->type); + mutex_unlock(&sram_api_list_lock); + return -EEXIST; + } + } + + kref_init(&sa->kref); + list_add_tail(&sa->list, &sram_api_list); + pr_info("sram %s type %d registered\n&quo
[PATCH v2] misc: new driver sram_uapi for user level SRAM access
A generic User-Kernel interface that allows a misc device created by it to support file-operations of ioctl and mmap to access SRAM memory from user level. Different kinds of SRAM alloction and free APIs could be registered by specific SRAM hardware level driver to the available list and then be chosen by users to allocate and map SRAM memory from user level. It is extremely helpful for the user space applications that require high performance memory accesses. One case is that on some embedded networking devices, data throughput is high and should be processed form user level, and the SRAM memory buffer for the processes in user space is of great preferences. Signed-off-by: Wang Wenhu Cc: Greg Kroah-Hartman Cc: Arnd Bergmann Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: Randy Dunlap Cc: linuxppc-dev@lists.ozlabs.org --- Changes since v1: * Addressed comments from Arnd Note: From this on, the SRAM_UAPI driver is dependent from any hardware drivers, so I would only commit the patch as a series itself, while the v1 of this patch was wrapped together with patches for Freescale device. After this I would re-commit patches for Freescale device as another series. Link for v1: * https://lore.kernel.org/lkml/20200418162157.50428-5-wenhu.w...@vivo.com/ --- drivers/misc/Kconfig | 11 ++ drivers/misc/Makefile| 1 + drivers/misc/sram_uapi.c | 348 +++ drivers/misc/sram_uapi.h | 37 + 4 files changed, 397 insertions(+) create mode 100644 drivers/misc/sram_uapi.c create mode 100644 drivers/misc/sram_uapi.h diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index 99e151475d8f..b19c8b24f18e 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -465,6 +465,17 @@ config PVPANIC a paravirtualized device provided by QEMU; it lets a virtual machine (guest) communicate panic events to the host. +config SRAM_UAPI + bool "Generic SRAM User Level API driver" + help + This driver allows you to create a misc device which could be used + as an interface to allocate SRAM memory from user level. + + It is extremely helpful for some user space applications that require + high performance memory accesses. + + If unsure, say N. + source "drivers/misc/c2port/Kconfig" source "drivers/misc/eeprom/Kconfig" source "drivers/misc/cb710/Kconfig" diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index 9abf2923d831..794447ca07ca 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -46,6 +46,7 @@ obj-$(CONFIG_VMWARE_VMCI) += vmw_vmci/ obj-$(CONFIG_LATTICE_ECP3_CONFIG) += lattice-ecp3-config.o obj-$(CONFIG_SRAM) += sram.o obj-$(CONFIG_SRAM_EXEC)+= sram-exec.o +obj-$(CONFIG_SRAM_UAPI)+= sram_uapi.o obj-y += mic/ obj-$(CONFIG_GENWQE) += genwqe/ obj-$(CONFIG_ECHO) += echo/ diff --git a/drivers/misc/sram_uapi.c b/drivers/misc/sram_uapi.c new file mode 100644 index ..858e43e559d0 --- /dev/null +++ b/drivers/misc/sram_uapi.c @@ -0,0 +1,348 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2020 Vivo Communication Technology Co. Ltd. + * Copyright (C) 2020 Wang Wenhu + * All rights reserved. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "sram_uapi.h" + +#define DRIVER_NAME"sram_uapi" + +struct sram_resource { + struct list_headlist; + struct res_info info; + phys_addr_t phys; + void*virt; + struct vm_area_struct *vma; + struct sram_uapi*parent; +}; + +struct sram_uapi { + struct list_headres_list; + struct sram_api *sa; +}; + +static DEFINE_MUTEX(sram_list_lock); +static LIST_HEAD(sram_list); + +long sram_api_register(struct sram_api *sa) +{ + struct sram_api *cur; + + if (!sa || !sa->name || !sa->sram_alloc || !sa->sram_free) + return -EINVAL; + + mutex_lock(&sram_list_lock); + list_for_each_entry(cur, &sram_list, list) { + if (cur->type == sa->type) { + pr_err("error sram %s type %d exists\n", sa->name, + sa->type); + mutex_unlock(&sram_list_lock); + return -EEXIST; + } + } + + kref_init(&sa->kref); + list_add_tail(&sa->list, &sram_list); + pr_info("sram %s type %d registered\n", sa->name, sa->type); + + mutex_unlock(&sram_list_lock); + + return 0; +}; +EXPORT_SYMBOL(sram_api_register); + +long sram_api_unregister(struct sram_api *sa) +{ + struct sram_api *cur, *tmp; + long ret = -ENOD
[PATCH v6, 4/4] drivers: misc: new driver sram_uapi for user level SRAM access
A generic User-Kernel interface that allows a misc device created by it to support file-operations of ioctl and mmap to access SRAM memory from user level. Different kinds of SRAM alloction and free APIs could be added to the available array and could be configured from user level. Signed-off-by: Wang Wenhu Cc: Greg Kroah-Hartman Cc: Arnd Bergmann Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: Randy Dunlap Cc: linuxppc-dev@lists.ozlabs.org --- Notes: Implement the interface driver for SRAM access from user level upon the comments from Scott. The former versions(1-5) were implemented with UIO, but for this version, UIO is not used as suggested by Scott. Links: https://lore.kernel.org/patchwork/patch/1226475/ https://lore.kernel.org/patchwork/patch/1225798/ --- drivers/misc/Kconfig | 25 drivers/misc/Makefile| 1 + drivers/misc/sram_uapi.c | 294 +++ 3 files changed, 320 insertions(+) create mode 100644 drivers/misc/sram_uapi.c diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index 99e151475d8f..e6897ba22684 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -465,6 +465,31 @@ config PVPANIC a paravirtualized device provided by QEMU; it lets a virtual machine (guest) communicate panic events to the host. +config SRAM_UAPI + bool "Generic SRAM User Level API driver" + help + This driver allows you to create a misc device which could be used + as an interface to allocate SRAM memory from user level. + + It is extremely helpful for some user space applications that require + high performance memory accesses. + + If unsure, say N. + +if SRAM_UAPI + +config FSL_85XX_SRAM_UAPI + bool "Freescale MPC85xx Cache-SRAM UAPI support" + depends on FSL_SOC_BOOKE && PPC32 + select FSL_85XX_CACHE_SRAM + help + This adds the Freescale MPC85xx Cache-SRAM memory allocation and + free interfaces to the available SRAM API array, which finally could + be used from user level to access the Freescale MPC85xx Cache-SRAM + memory. + +endif + source "drivers/misc/c2port/Kconfig" source "drivers/misc/eeprom/Kconfig" source "drivers/misc/cb710/Kconfig" diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index 9abf2923d831..794447ca07ca 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -46,6 +46,7 @@ obj-$(CONFIG_VMWARE_VMCI) += vmw_vmci/ obj-$(CONFIG_LATTICE_ECP3_CONFIG) += lattice-ecp3-config.o obj-$(CONFIG_SRAM) += sram.o obj-$(CONFIG_SRAM_EXEC)+= sram-exec.o +obj-$(CONFIG_SRAM_UAPI)+= sram_uapi.o obj-y += mic/ obj-$(CONFIG_GENWQE) += genwqe/ obj-$(CONFIG_ECHO) += echo/ diff --git a/drivers/misc/sram_uapi.c b/drivers/misc/sram_uapi.c new file mode 100644 index ..53f818e1898d --- /dev/null +++ b/drivers/misc/sram_uapi.c @@ -0,0 +1,294 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2020 Vivo Communication Technology Co. Ltd. + * Copyright (C) 2020 Wang Wenhu + * All rights reserved. + */ + +#include +#include +#include +#include +#include +#include +#include + +#define DRIVER_NAME"sram_uapi" + +#define SRAM_UAPI_IOCTL_SET_SRAM_TYPE 0 +#define SRAM_UAPI_IOCTL_ALLOC 1 +#define SRAM_UAPI_IOCTL_FREE 2 + +struct res_info { + u32 offset; + u32 size; +}; + +struct sram_resource { + struct list_headlist; + struct res_info info; + phys_addr_t phys; + void*virt; + struct vm_area_struct *vma; + struct sram_uapi*parent; +}; + +struct sram_api { + u32 type; + long (*sram_alloc)(u32 size, phys_addr_t *phys, u32 align); + void (*sram_free)(void *ptr); +}; + +struct sram_uapi { + struct list_headres_list; + struct sram_api *sa; +}; + +enum SRAM_TYPE { +#ifdef FSL_85XX_CACHE_SRAM + SRAM_TYPE_FSL_85XX_CACHE_SRAM, +#endif + SRAM_TYPE_MAX, +}; + +/* keep the SRAM_TYPE value the same with array index */ +static struct sram_api srams[] = { +#ifdef FSL_85XX_CACHE_SRAM + { + .type = SRAM_TYPE_FSL_85XX_CACHE_SRAM, + .sram_alloc = mpc85xx_cache_sram_alloc, + .sram_free = mpc85xx_cache_sram_free, + }, +#endif +}; + +static void sram_uapi_res_insert(struct sram_uapi *uapi, +struct sram_resource *res) +{ + struct sram_resource *cur, *tmp; + struct list_head *head = &uapi->res_list; + + list_for_each_entry_safe(cur, tmp, head, list) { + if (&tmp->list != head && + (cur->info.offset + cur->in
[PATCH v6, 1/4] powerpc: sysdev: fix compile error for fsl_85xx_l2ctlr
Include "linux/of_address.h" to fix the compile error for mpc85xx_l2ctlr_of_probe() when compiling fsl_85xx_cache_sram.c. CC arch/powerpc/sysdev/fsl_85xx_l2ctlr.o arch/powerpc/sysdev/fsl_85xx_l2ctlr.c: In function ‘mpc85xx_l2ctlr_of_probe’: arch/powerpc/sysdev/fsl_85xx_l2ctlr.c:90:11: error: implicit declaration of function ‘of_iomap’; did you mean ‘pci_iomap’? [-Werror=implicit-function-declaration] l2ctlr = of_iomap(dev->dev.of_node, 0); ^~~~ pci_iomap arch/powerpc/sysdev/fsl_85xx_l2ctlr.c:90:9: error: assignment makes pointer from integer without a cast [-Werror=int-conversion] l2ctlr = of_iomap(dev->dev.of_node, 0); ^ cc1: all warnings being treated as errors scripts/Makefile.build:267: recipe for target 'arch/powerpc/sysdev/fsl_85xx_l2ctlr.o' failed make[2]: *** [arch/powerpc/sysdev/fsl_85xx_l2ctlr.o] Error 1 Cc: Greg Kroah-Hartman Cc: Arnd Bergmann Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: Randy Dunlap Cc: linuxppc-dev@lists.ozlabs.org Fixes: 6db92cc9d07d ("powerpc/85xx: add cache-sram support") Reviewed-by: Christophe Leroy Signed-off-by: Wang Wenhu --- No change v1-v5 --- arch/powerpc/sysdev/fsl_85xx_l2ctlr.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c b/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c index 2d0af0c517bb..7533572492f0 100644 --- a/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c +++ b/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include "fsl_85xx_cache_ctlr.h" -- 2.17.1
[PATCH v6, 2/4] powerpc: sysdev: fix compile error for fsl_85xx_cache_sram
Include linux/io.h into fsl_85xx_cache_sram.c to fix the implicit-declaration compile error when building Cache-Sram. arch/powerpc/sysdev/fsl_85xx_cache_sram.c: In function ‘instantiate_cache_sram’: arch/powerpc/sysdev/fsl_85xx_cache_sram.c:97:26: error: implicit declaration of function ‘ioremap_coherent’; did you mean ‘bitmap_complement’? [-Werror=implicit-function-declaration] cache_sram->base_virt = ioremap_coherent(cache_sram->base_phys, ^~~~ bitmap_complement arch/powerpc/sysdev/fsl_85xx_cache_sram.c:97:24: error: assignment makes pointer from integer without a cast [-Werror=int-conversion] cache_sram->base_virt = ioremap_coherent(cache_sram->base_phys, ^ arch/powerpc/sysdev/fsl_85xx_cache_sram.c:123:2: error: implicit declaration of function ‘iounmap’; did you mean ‘roundup’? [-Werror=implicit-function-declaration] iounmap(cache_sram->base_virt); ^~~ roundup cc1: all warnings being treated as errors Cc: Greg Kroah-Hartman Cc: Arnd Bergmann Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: Randy Dunlap Cc: linuxppc-dev@lists.ozlabs.org Fixes: 6db92cc9d07d ("powerpc/85xx: add cache-sram support") Reviewed-by: Christophe Leroy Signed-off-by: Wang Wenhu --- No change v1-v5 --- arch/powerpc/sysdev/fsl_85xx_cache_sram.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c index f6c665dac725..be3aef4229d7 100644 --- a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c +++ b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "fsl_85xx_cache_ctlr.h" -- 2.17.1
[PATCH v6, 3/4] powerpc: sysdev: fix compile warning for fsl_85xx_cache_sram
Function instantiate_cache_sram should not be linked into the init section for its caller mpc85xx_l2ctlr_of_probe is none-__init. Cc: Greg Kroah-Hartman Cc: Arnd Bergmann Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: Randy Dunlap Cc: linuxppc-dev@lists.ozlabs.org Fixes: 6db92cc9d07d ("powerpc/85xx: add cache-sram support") Reviewed-by: Christophe Leroy Signed-off-by: Wang Wenhu --- No change v1-v5 --- arch/powerpc/sysdev/fsl_85xx_cache_sram.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c index be3aef4229d7..3de5ac8382c0 100644 --- a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c +++ b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c @@ -68,7 +68,7 @@ void mpc85xx_cache_sram_free(void *ptr) } EXPORT_SYMBOL(mpc85xx_cache_sram_free); -int __init instantiate_cache_sram(struct platform_device *dev, +int instantiate_cache_sram(struct platform_device *dev, struct sram_parameters sram_params) { int ret = 0; -- 2.17.1
[PATCH v6,0/4] misc: new driver sram_uapi for user level SRAM access
This series add a new misc device driver which act as an interface to access the Cache-SRAM from user level. This is extremely helpful for some user space applications that require high performance memory accesses. It also fixes the compile errors and warning of the Freescale MPC85xx Cache-SRAM hardware driver. The former five version implemented the driver with UIO but they were commented of not fitful. This version uses a misc divice and implements the memory allocation and free operations via file operation as suggested by Scott. Wang Wenhu (4): powerpc: sysdev: fix compile error for fsl_85xx_l2ctlr powerpc: sysdev: fix compile error for fsl_85xx_cache_sram powerpc: sysdev: fix compile warning for fsl_85xx_cache_sram drivers: misc: new driver sram_uapi for user level SRAM access arch/powerpc/sysdev/fsl_85xx_cache_sram.c | 3 +- arch/powerpc/sysdev/fsl_85xx_l2ctlr.c | 1 + drivers/misc/Kconfig | 25 ++ drivers/misc/Makefile | 1 + drivers/misc/sram_uapi.c | 294 ++ 5 files changed, 323 insertions(+), 1 deletion(-) create mode 100644 drivers/misc/sram_uapi.c -- 2.17.1
[PATCH] drivers: uio: new driver uio_fsl_85xx_cache_sram
Implements a new uio driver for freescale 85xx platforms to access the Cache-Sram form user level. It is extremely helpful for the user space applications that require high performance memory accesses. Cc: Greg Kroah-Hartman Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org Signed-off-by: Wang Wenhu --- drivers/uio/Kconfig | 8 + drivers/uio/Makefile | 1 + drivers/uio/uio_fsl_85xx_cache_sram.c | 407 ++ 3 files changed, 416 insertions(+) create mode 100644 drivers/uio/uio_fsl_85xx_cache_sram.c diff --git a/drivers/uio/Kconfig b/drivers/uio/Kconfig index 202ee81cfc2b..f6e6ec0089c0 100644 --- a/drivers/uio/Kconfig +++ b/drivers/uio/Kconfig @@ -105,6 +105,14 @@ config UIO_NETX To compile this driver as a module, choose M here; the module will be called uio_netx. +config UIO_FSL_85XX_CACHE_SRAM + tristate "Freescale MPC85xx Cache-Sram driver" + depends on FSL_SOC_BOOKE && PPC32 && !FSL_85XX_CACHE_SRAM + help + Generic driver for accessing the Cache-Sram form user level. This + is extremely helpful for some user-space applications that require + high performance memory accesses. + config UIO_FSL_ELBC_GPCM tristate "eLBC/GPCM driver" depends on FSL_LBC diff --git a/drivers/uio/Makefile b/drivers/uio/Makefile index c285dd2a4539..be2056cffc21 100644 --- a/drivers/uio/Makefile +++ b/drivers/uio/Makefile @@ -10,4 +10,5 @@ obj-$(CONFIG_UIO_NETX)+= uio_netx.o obj-$(CONFIG_UIO_PRUSS) += uio_pruss.o obj-$(CONFIG_UIO_MF624) += uio_mf624.o obj-$(CONFIG_UIO_FSL_ELBC_GPCM)+= uio_fsl_elbc_gpcm.o +obj-$(CONFIG_UIO_FSL_85XX_CACHE_SRAM) += uio_fsl_85xx_cache_sram.o obj-$(CONFIG_UIO_HV_GENERIC) += uio_hv_generic.o diff --git a/drivers/uio/uio_fsl_85xx_cache_sram.c b/drivers/uio/uio_fsl_85xx_cache_sram.c new file mode 100644 index ..312ca38e93e1 --- /dev/null +++ b/drivers/uio/uio_fsl_85xx_cache_sram.c @@ -0,0 +1,407 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2020 Vivo Communication Technology Co. Ltd. + * Copyright (C) 2020 Wang Wenhu + * All rights reserved. + */ + +#include +#include +#include +#include +#include + +#define DRIVER_NAME"uio_fsl_85xx_cache_sram" +#define UIO_INFO_VER "devicetree,pseudo" + +#define MAX_SRAM_UIO_INFOS 5 + +#define L2CR_L2FI 0x4000 /* L2 flash invalidate */ +#define L2CR_SRAM_FULL 0x0001 /* L2SRAM full size */ +#define L2CR_SRAM_HALF 0x0002 /* L2SRAM half size */ +#define L2CR_SRAM_QUART0x0004 /* L2SRAM one quarter size */ +#define L2CR_SRAM_EIGHTH 0x0006 /* L2SRAM one eighth size */ + +#define L2SRAM_BAR_MSK_LO180xC000 /* Lower 18 bits */ +#define L2SRAM_BARE_MSK_HI40x000F /* Upper 4 bits */ + +enum cache_sram_lock_ways { + LOCK_WAYS_ZERO, + LOCK_WAYS_EIGHTH, + LOCK_WAYS_TWO_EIGHTH, + LOCK_WAYS_HALF = 4, + LOCK_WAYS_FULL = 8, +}; + +struct mpc85xx_l2ctlr { + u32 ctl;/* 0x000 - L2 control */ + u8 res1[0xC]; + u32 ewar0; /* 0x010 - External write address 0 */ + u32 ewarea0;/* 0x014 - External write address extended 0 */ + u32 ewcr0; /* 0x018 - External write ctrl */ + u8 res2[4]; + u32 ewar1; /* 0x020 - External write address 1 */ + u32 ewarea1;/* 0x024 - External write address extended 1 */ + u32 ewcr1; /* 0x028 - External write ctrl 1 */ + u8 res3[4]; + u32 ewar2; /* 0x030 - External write address 2 */ + u32 ewarea2;/* 0x034 - External write address extended 2 */ + u32 ewcr2; /* 0x038 - External write ctrl 2 */ + u8 res4[4]; + u32 ewar3; /* 0x040 - External write address 3 */ + u32 ewarea3;/* 0x044 - External write address extended 3 */ + u32 ewcr3; /* 0x048 - External write ctrl 3 */ + u8 res5[0xB4]; + u32 srbar0; /* 0x100 - SRAM base address 0 */ + u32 srbarea0; /* 0x104 - SRAM base addr reg ext address 0 */ + u32 srbar1; /* 0x108 - SRAM base address 1 */ + u32 srbarea1; /* 0x10C - SRAM base addr reg ext address 1 */ + u8 res6[0xCF0]; + u32 errinjhi; /* 0xE00 - Error injection mask high */ + u32 errinjlo; /* 0xE04 - Error injection mask low */ + u32 errinjctl; /* 0xE08 - Error injection tag/ecc control */ + u8 res7[0x14]; + u32 captdatahi; /* 0xE20 - Error data high capture */ + u32 captdatalo; /* 0xE24 - Error data low capture */ + u32 captecc;
[PATCH v5, 3/4] powerpc: sysdev: fix compile warning for fsl_85xx_cache_sram
Function instantiate_cache_sram should not be linked into the init section for its caller mpc85xx_l2ctlr_of_probe is none-__init. Cc: Greg Kroah-Hartman Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org Fixes: 6db92cc9d07d ("powerpc/85xx: add cache-sram support") Reviewed-by: Christophe Leroy Signed-off-by: Wang Wenhu Warning information: MODPOST vmlinux.o WARNING: modpost: vmlinux.o(.text+0x1e540): Section mismatch in reference from the function mpc85xx_l2ctlr_of_probe() to the function .init.text:instantiate_cache_sram() The function mpc85xx_l2ctlr_of_probe() references the function __init instantiate_cache_sram(). This is often because mpc85xx_l2ctlr_of_probe lacks a __init annotation or the annotation of instantiate_cache_sram is wrong. --- Changes since v1: * None Changes since v2: * None Changes since v3: * None Changes since v4: * None --- arch/powerpc/sysdev/fsl_85xx_cache_sram.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c index be3aef4229d7..3de5ac8382c0 100644 --- a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c +++ b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c @@ -68,7 +68,7 @@ void mpc85xx_cache_sram_free(void *ptr) } EXPORT_SYMBOL(mpc85xx_cache_sram_free); -int __init instantiate_cache_sram(struct platform_device *dev, +int instantiate_cache_sram(struct platform_device *dev, struct sram_parameters sram_params) { int ret = 0; -- 2.17.1
[PATCH v5, 2/4] powerpc: sysdev: fix compile error for fsl_85xx_cache_sram
Include linux/io.h into fsl_85xx_cache_sram.c to fix the implicit-declaration compile error when building Cache-Sram. arch/powerpc/sysdev/fsl_85xx_cache_sram.c: In function ‘instantiate_cache_sram’: arch/powerpc/sysdev/fsl_85xx_cache_sram.c:97:26: error: implicit declaration of function ‘ioremap_coherent’; did you mean ‘bitmap_complement’? [-Werror=implicit-function-declaration] cache_sram->base_virt = ioremap_coherent(cache_sram->base_phys, ^~~~ bitmap_complement arch/powerpc/sysdev/fsl_85xx_cache_sram.c:97:24: error: assignment makes pointer from integer without a cast [-Werror=int-conversion] cache_sram->base_virt = ioremap_coherent(cache_sram->base_phys, ^ arch/powerpc/sysdev/fsl_85xx_cache_sram.c:123:2: error: implicit declaration of function ‘iounmap’; did you mean ‘roundup’? [-Werror=implicit-function-declaration] iounmap(cache_sram->base_virt); ^~~ roundup cc1: all warnings being treated as errors Cc: Greg Kroah-Hartman Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org Fixes: 6db92cc9d07d ("powerpc/85xx: add cache-sram support") Reviewed-by: Christophe Leroy Signed-off-by: Wang Wenhu --- Changes since v1: * None Changes since v2: * None Changes since v3: * None Changes since v4: * None --- arch/powerpc/sysdev/fsl_85xx_cache_sram.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c index f6c665dac725..be3aef4229d7 100644 --- a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c +++ b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "fsl_85xx_cache_ctlr.h" -- 2.17.1
[PATCH v5, 1/4] powerpc: sysdev: fix compile error for fsl_85xx_l2ctlr
Include "linux/of_address.h" to fix the compile error for mpc85xx_l2ctlr_of_probe() when compiling fsl_85xx_cache_sram.c. CC arch/powerpc/sysdev/fsl_85xx_l2ctlr.o arch/powerpc/sysdev/fsl_85xx_l2ctlr.c: In function ‘mpc85xx_l2ctlr_of_probe’: arch/powerpc/sysdev/fsl_85xx_l2ctlr.c:90:11: error: implicit declaration of function ‘of_iomap’; did you mean ‘pci_iomap’? [-Werror=implicit-function-declaration] l2ctlr = of_iomap(dev->dev.of_node, 0); ^~~~ pci_iomap arch/powerpc/sysdev/fsl_85xx_l2ctlr.c:90:9: error: assignment makes pointer from integer without a cast [-Werror=int-conversion] l2ctlr = of_iomap(dev->dev.of_node, 0); ^ cc1: all warnings being treated as errors scripts/Makefile.build:267: recipe for target 'arch/powerpc/sysdev/fsl_85xx_l2ctlr.o' failed make[2]: *** [arch/powerpc/sysdev/fsl_85xx_l2ctlr.o] Error 1 Cc: Greg Kroah-Hartman Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org Fixes: 6db92cc9d07d ("powerpc/85xx: add cache-sram support") Reviewed-by: Christophe Leroy Signed-off-by: Wang Wenhu --- Changes since v1: * None Changes since v2: * None Changes since v3: * None Changes since v4: * None --- arch/powerpc/sysdev/fsl_85xx_l2ctlr.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c b/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c index 2d0af0c517bb..7533572492f0 100644 --- a/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c +++ b/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include "fsl_85xx_cache_ctlr.h" -- 2.17.1
[PATCH v5,0/4] drivers: uio: new driver uio_fsl_85xx_cache_sram
This series add a new uio driver for freescale 85xx platforms to access the Cache-Sram form user level. This is extremely helpful for the user-space applications that require high performance memory accesses. It fixes the compile errors and warning of the hardware level drivers and implements the uio driver in uio_fsl_85xx_cache_sram.c. Changes since v1: * Addressed comments from Greg K-H * Moved kfree(info->name) into uio_info_free_internal() Changes since v2: * Drop the patch that modifies Kconfigs of arch/powerpc/platforms and modified the sequence of patches: 01:dropped, 02->03, 03->02, 04->01, 05->04 * Addressed comments from Greg, Scott and Christophe * Use "uiomem->internal_addr" as if condition for sram memory free, and memset the uiomem entry * Modified of_match_table make the driver apart from Cache-Sram HW info which belong to the HW level driver fsl_85xx_cache_sram to match * Use roundup_pow_of_two for align calc * Remove useless clear block of uiomem entries. * Use UIO_INFO_VER micro for info->version, and define it as "devicetree,pseudo", meaning this is pseudo device and probed from device tree configuration * Select FSL_85XX_CACHE_SRAM rather than depends on it Changes since v3: * Addressed comments from Christophe(use devm_xxx memory alloc interfaces) Changes since v4: * Use module_param_string for of_match_table, no binding to devicetree Wang Wenhu (4): powerpc: sysdev: fix compile error for fsl_85xx_l2ctlr powerpc: sysdev: fix compile error for fsl_85xx_cache_sram powerpc: sysdev: fix compile warning for fsl_85xx_cache_sram drivers: uio: new driver for fsl_85xx_cache_sram arch/powerpc/sysdev/fsl_85xx_cache_sram.c | 3 +- arch/powerpc/sysdev/fsl_85xx_l2ctlr.c | 1 + drivers/uio/Kconfig | 9 ++ drivers/uio/Makefile | 1 + drivers/uio/uio_fsl_85xx_cache_sram.c | 154 ++ 5 files changed, 167 insertions(+), 1 deletion(-) create mode 100644 drivers/uio/uio_fsl_85xx_cache_sram.c -- 2.17.1
[PATCH v5,4/4] drivers: uio: new driver for fsl_85xx_cache_sram
A driver for freescale 85xx platforms to access the Cache-Sram form user level. This is extremely helpful for some user-space applications that require high performance memory accesses. Cc: Greg Kroah-Hartman Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org Reviewed-by: Christophe Leroy Signed-off-by: Wang Wenhu --- Changes since v1: * Addressed comments from Greg K-H * Moved kfree(info->name) into uio_info_free_internal() Changes since v2: * Addressed comments from Greg, Scott and Christophe * Use "uiomem->internal_addr" as if condition for sram memory free, and memset the uiomem entry * of_match_table modified to be apart from HW info which belong to the HW level driver fsl_85xx_cache_sram to match * Use roundup_pow_of_two for align calc * Remove useless clear block of uiomem entries. * Use UIO_INFO_VER micro for info->version, and define it as "devicetree,pseudo", meaning this is pseudo device and probed from device tree configuration Changes since v3: * Addressed comments from Christophe(use devm_xxx memory alloc interfaces) Changes since v4: * Use module_param_string for of_match_table, no binding to devicetree --- drivers/uio/Kconfig | 9 ++ drivers/uio/Makefile | 1 + drivers/uio/uio_fsl_85xx_cache_sram.c | 154 ++ 3 files changed, 164 insertions(+) create mode 100644 drivers/uio/uio_fsl_85xx_cache_sram.c diff --git a/drivers/uio/Kconfig b/drivers/uio/Kconfig index 202ee81cfc2b..9c3b47461b71 100644 --- a/drivers/uio/Kconfig +++ b/drivers/uio/Kconfig @@ -105,6 +105,15 @@ config UIO_NETX To compile this driver as a module, choose M here; the module will be called uio_netx. +config UIO_FSL_85XX_CACHE_SRAM + tristate "Freescale 85xx Cache-Sram driver" + depends on FSL_SOC_BOOKE && PPC32 + select FSL_85XX_CACHE_SRAM + help + Generic driver for accessing the Cache-Sram form user level. This + is extremely helpful for some user-space applications that require + high performance memory accesses. + config UIO_FSL_ELBC_GPCM tristate "eLBC/GPCM driver" depends on FSL_LBC diff --git a/drivers/uio/Makefile b/drivers/uio/Makefile index c285dd2a4539..be2056cffc21 100644 --- a/drivers/uio/Makefile +++ b/drivers/uio/Makefile @@ -10,4 +10,5 @@ obj-$(CONFIG_UIO_NETX)+= uio_netx.o obj-$(CONFIG_UIO_PRUSS) += uio_pruss.o obj-$(CONFIG_UIO_MF624) += uio_mf624.o obj-$(CONFIG_UIO_FSL_ELBC_GPCM)+= uio_fsl_elbc_gpcm.o +obj-$(CONFIG_UIO_FSL_85XX_CACHE_SRAM) += uio_fsl_85xx_cache_sram.o obj-$(CONFIG_UIO_HV_GENERIC) += uio_hv_generic.o diff --git a/drivers/uio/uio_fsl_85xx_cache_sram.c b/drivers/uio/uio_fsl_85xx_cache_sram.c new file mode 100644 index ..4db3648629b3 --- /dev/null +++ b/drivers/uio/uio_fsl_85xx_cache_sram.c @@ -0,0 +1,154 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2020 Vivo Communication Technology Co. Ltd. + * Copyright (C) 2020 Wang Wenhu + * All rights reserved. + */ + +#include +#include +#include +#include +#include +#include + +#define DRIVER_NAME"uio_fsl_85xx_cache_sram" +#define UIO_INFO_VER "devicetree,pseudo" +#define UIO_NAME "uio_cache_sram" + +static void uio_info_free_internal(struct uio_info *info) +{ + int i; + + for (i = 0; i < MAX_UIO_MAPS; i++) { + struct uio_mem *uiomem = &info->mem[i]; + + if (uiomem->internal_addr) { + mpc85xx_cache_sram_free(uiomem->internal_addr); + memset(uiomem, 0, sizeof(*uiomem)); + } + } +} + +static int uio_fsl_85xx_cache_sram_probe(struct platform_device *pdev) +{ + struct device_node *parent = pdev->dev.of_node; + struct device_node *node = NULL; + struct uio_info *info; + struct uio_mem *uiomem; + const char *dt_name; + u32 mem_size; + int ret; + + /* alloc uio_info for one device */ + info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); + if (!info) + return -ENOMEM; + + /* get optional uio name */ + if (of_property_read_string(parent, "uio_name", &dt_name)) + dt_name = UIO_NAME; + + info->name = devm_kstrdup(&pdev->dev, dt_name, GFP_KERNEL); + if (!info->name) + return -ENOMEM; + + uiomem = info->mem; + for_each_child_of_node(parent, node) { + void *virt; + phys_addr_t phys; + + ret = of_property_read_u32(node, "cache-mem-size", &mem_size); + if (ret) { + ret = -EINVAL; + goto err_out; + } + + if (mem_size == 0) { +
[PATCH v4, 3/4] powerpc: sysdev: fix compile warning for fsl_85xx_cache_sram
Function instantiate_cache_sram should not be linked into the init section for its caller mpc85xx_l2ctlr_of_probe is none-__init. Cc: Greg Kroah-Hartman Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org Fixes: 6db92cc9d07d ("powerpc/85xx: add cache-sram support") Signed-off-by: Wang Wenhu Warning information: MODPOST vmlinux.o WARNING: modpost: vmlinux.o(.text+0x1e540): Section mismatch in reference from the function mpc85xx_l2ctlr_of_probe() to the function .init.text:instantiate_cache_sram() The function mpc85xx_l2ctlr_of_probe() references the function __init instantiate_cache_sram(). This is often because mpc85xx_l2ctlr_of_probe lacks a __init annotation or the annotation of instantiate_cache_sram is wrong. --- Changes since v1: * None Changes since v2: * None Changes since v3: * None --- arch/powerpc/sysdev/fsl_85xx_cache_sram.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c index be3aef4229d7..3de5ac8382c0 100644 --- a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c +++ b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c @@ -68,7 +68,7 @@ void mpc85xx_cache_sram_free(void *ptr) } EXPORT_SYMBOL(mpc85xx_cache_sram_free); -int __init instantiate_cache_sram(struct platform_device *dev, +int instantiate_cache_sram(struct platform_device *dev, struct sram_parameters sram_params) { int ret = 0; -- 2.17.1
[PATCH v4,4/4] drivers: uio: new driver for fsl_85xx_cache_sram
A driver for freescale 85xx platforms to access the Cache-Sram form user level. This is extremely helpful for some user-space applications that require high performance memory accesses. Cc: Greg Kroah-Hartman Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org Signed-off-by: Wang Wenhu --- Changes since v1: * Addressed comments from Greg K-H * Moved kfree(info->name) into uio_info_free_internal() Changes since v2: * Addressed comments from Greg, Scott and Christophe * Use "uiomem->internal_addr" as if condition for sram memory free, and memset the uiomem entry * of_match_table modified to be apart from HW info which belong to the HW level driver fsl_85xx_cache_sram to match * Use roundup_pow_of_two for align calc(really learned a lot from Christophe) * Remove useless clear block of uiomem entries. * Use UIO_INFO_VER micro for info->version, and define it as "devicetree,pseudo", meaning this is pseudo device and probed from device tree configuration Changes since v3: * Addressed comments from Christophe(use devm_xxx memory alloc interfaces) --- drivers/uio/Kconfig | 9 ++ drivers/uio/Makefile | 1 + drivers/uio/uio_fsl_85xx_cache_sram.c | 148 ++ 3 files changed, 158 insertions(+) create mode 100644 drivers/uio/uio_fsl_85xx_cache_sram.c diff --git a/drivers/uio/Kconfig b/drivers/uio/Kconfig index 202ee81cfc2b..9c3b47461b71 100644 --- a/drivers/uio/Kconfig +++ b/drivers/uio/Kconfig @@ -105,6 +105,15 @@ config UIO_NETX To compile this driver as a module, choose M here; the module will be called uio_netx. +config UIO_FSL_85XX_CACHE_SRAM + tristate "Freescale 85xx Cache-Sram driver" + depends on FSL_SOC_BOOKE && PPC32 + select FSL_85XX_CACHE_SRAM + help + Generic driver for accessing the Cache-Sram form user level. This + is extremely helpful for some user-space applications that require + high performance memory accesses. + config UIO_FSL_ELBC_GPCM tristate "eLBC/GPCM driver" depends on FSL_LBC diff --git a/drivers/uio/Makefile b/drivers/uio/Makefile index c285dd2a4539..be2056cffc21 100644 --- a/drivers/uio/Makefile +++ b/drivers/uio/Makefile @@ -10,4 +10,5 @@ obj-$(CONFIG_UIO_NETX)+= uio_netx.o obj-$(CONFIG_UIO_PRUSS) += uio_pruss.o obj-$(CONFIG_UIO_MF624) += uio_mf624.o obj-$(CONFIG_UIO_FSL_ELBC_GPCM)+= uio_fsl_elbc_gpcm.o +obj-$(CONFIG_UIO_FSL_85XX_CACHE_SRAM) += uio_fsl_85xx_cache_sram.o obj-$(CONFIG_UIO_HV_GENERIC) += uio_hv_generic.o diff --git a/drivers/uio/uio_fsl_85xx_cache_sram.c b/drivers/uio/uio_fsl_85xx_cache_sram.c new file mode 100644 index ..cb339d1f9019 --- /dev/null +++ b/drivers/uio/uio_fsl_85xx_cache_sram.c @@ -0,0 +1,148 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2020 Vivo Communication Technology Co. Ltd. + * Copyright (C) 2020 Wang Wenhu + * All rights reserved. + */ + +#include +#include +#include +#include +#include +#include + +#define DRIVER_NAME"uio_fsl_85xx_cache_sram" +#define UIO_INFO_VER "devicetree,pseudo" +#define UIO_NAME "uio_cache_sram" + +static void uio_info_free_internal(struct uio_info *info) +{ + int i; + + for (i = 0; i < MAX_UIO_MAPS; i++) { + struct uio_mem *uiomem = &info->mem[i]; + + if (uiomem->internal_addr) { + mpc85xx_cache_sram_free(uiomem->internal_addr); + memset(uiomem, 0, sizeof(*uiomem)); + } + } +} + +static int uio_fsl_85xx_cache_sram_probe(struct platform_device *pdev) +{ + struct device_node *parent = pdev->dev.of_node; + struct device_node *node = NULL; + struct uio_info *info; + struct uio_mem *uiomem; + const char *dt_name; + u32 mem_size; + int ret; + + /* alloc uio_info for one device */ + info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); + if (!info) + return -ENOMEM; + + /* get optional uio name */ + if (of_property_read_string(parent, "uio_name", &dt_name)) + dt_name = UIO_NAME; + + info->name = devm_kstrdup(&pdev->dev, dt_name, GFP_KERNEL); + if (!info->name) + return -ENOMEM; + + uiomem = info->mem; + for_each_child_of_node(parent, node) { + void *virt; + phys_addr_t phys; + + ret = of_property_read_u32(node, "cache-mem-size", &mem_size); + if (ret) { + ret = -EINVAL; + goto err_out; + } + + if (mem_size == 0) { + dev_err(&pdev->dev, "error cache-mem-size should not be
[PATCH v4, 1/4] powerpc: sysdev: fix compile error for fsl_85xx_l2ctlr
Include "linux/of_address.h" to fix the compile error for mpc85xx_l2ctlr_of_probe() when compiling fsl_85xx_cache_sram.c. CC arch/powerpc/sysdev/fsl_85xx_l2ctlr.o arch/powerpc/sysdev/fsl_85xx_l2ctlr.c: In function ‘mpc85xx_l2ctlr_of_probe’: arch/powerpc/sysdev/fsl_85xx_l2ctlr.c:90:11: error: implicit declaration of function ‘of_iomap’; did you mean ‘pci_iomap’? [-Werror=implicit-function-declaration] l2ctlr = of_iomap(dev->dev.of_node, 0); ^~~~ pci_iomap arch/powerpc/sysdev/fsl_85xx_l2ctlr.c:90:9: error: assignment makes pointer from integer without a cast [-Werror=int-conversion] l2ctlr = of_iomap(dev->dev.of_node, 0); ^ cc1: all warnings being treated as errors scripts/Makefile.build:267: recipe for target 'arch/powerpc/sysdev/fsl_85xx_l2ctlr.o' failed make[2]: *** [arch/powerpc/sysdev/fsl_85xx_l2ctlr.o] Error 1 Cc: Greg Kroah-Hartman Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org Fixes: 6db92cc9d07d ("powerpc/85xx: add cache-sram support") Signed-off-by: Wang Wenhu --- Changes since v1: * None Changes since v2: * None Changes since v3: * None --- arch/powerpc/sysdev/fsl_85xx_l2ctlr.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c b/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c index 2d0af0c517bb..7533572492f0 100644 --- a/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c +++ b/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include "fsl_85xx_cache_ctlr.h" -- 2.17.1
[PATCH v4, 2/4] powerpc: sysdev: fix compile error for fsl_85xx_cache_sram
Include linux/io.h into fsl_85xx_cache_sram.c to fix the implicit-declaration compile error when building Cache-Sram. arch/powerpc/sysdev/fsl_85xx_cache_sram.c: In function ‘instantiate_cache_sram’: arch/powerpc/sysdev/fsl_85xx_cache_sram.c:97:26: error: implicit declaration of function ‘ioremap_coherent’; did you mean ‘bitmap_complement’? [-Werror=implicit-function-declaration] cache_sram->base_virt = ioremap_coherent(cache_sram->base_phys, ^~~~ bitmap_complement arch/powerpc/sysdev/fsl_85xx_cache_sram.c:97:24: error: assignment makes pointer from integer without a cast [-Werror=int-conversion] cache_sram->base_virt = ioremap_coherent(cache_sram->base_phys, ^ arch/powerpc/sysdev/fsl_85xx_cache_sram.c:123:2: error: implicit declaration of function ‘iounmap’; did you mean ‘roundup’? [-Werror=implicit-function-declaration] iounmap(cache_sram->base_virt); ^~~ roundup cc1: all warnings being treated as errors Cc: Greg Kroah-Hartman Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org Fixes: 6db92cc9d07d ("powerpc/85xx: add cache-sram support") Signed-off-by: Wang Wenhu --- Changes since v1: * None Changes since v2: * None Changes since v3: * None --- arch/powerpc/sysdev/fsl_85xx_cache_sram.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c index f6c665dac725..be3aef4229d7 100644 --- a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c +++ b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "fsl_85xx_cache_ctlr.h" -- 2.17.1
[PATCH v4,0/4] drivers: uio: new driver uio_fsl_85xx_cache_sram
Changes since v1: * Addressed comments from Greg K-H * Moved kfree(info->name) into uio_info_free_internal() Changes since v2: * Drop the patch that modifies Kconfigs of arch/powerpc/platforms and modified the sequence of patches: 01:dropped, 02->03, 03->02, 04->01, 05->04 * Addressed comments from Greg, Scott and Christophe * Use "uiomem->internal_addr" as if condition for sram memory free, and memset the uiomem entry * Modified of_match_table make the driver apart from Cache-Sram HW info which belong to the HW level driver fsl_85xx_cache_sram to match * Use roundup_pow_of_two for align calc(really learned a lot from Christophe) * Remove useless clear block of uiomem entries. * Use UIO_INFO_VER micro for info->version, and define it as "devicetree,pseudo", meaning this is pseudo device and probed from device tree configuration * Select FSL_85XX_CACHE_SRAM rather than depends on it Changes since v3: * Addressed comments from Christophe(use devm_xxx memory alloc interfaces) Wang Wenhu (4): powerpc: sysdev: fix compile error for fsl_85xx_l2ctlr powerpc: sysdev: fix compile error for fsl_85xx_cache_sram powerpc: sysdev: fix compile warning for fsl_85xx_cache_sram drivers: uio: new driver for fsl_85xx_cache_sram arch/powerpc/sysdev/fsl_85xx_cache_sram.c | 3 +- arch/powerpc/sysdev/fsl_85xx_l2ctlr.c | 1 + drivers/uio/Kconfig | 9 ++ drivers/uio/Makefile | 1 + drivers/uio/uio_fsl_85xx_cache_sram.c | 148 ++ 5 files changed, 161 insertions(+), 1 deletion(-) create mode 100644 drivers/uio/uio_fsl_85xx_cache_sram.c -- 2.17.1
[PATCH RESEND, v3, 0/4] drivers: uio: new driver uio_fsl_85xx_cache_sram
This series add a new uio driver for freescale 85xx platforms to access the Cache-Sram form user level. This is extremely helpful for the user-space applications that require high performance memory accesses. It fixes the compile errors and warning of the hardware level drivers and implements the uio driver in uio_fsl_85xx_cache_sram.c. Changes since v1: * Addressed comments from Greg K-H * Moved kfree(info->name) into uio_info_free_internal() Changes since v2: * Drop the patch that modifies Kconfigs of arch/powerpc/platforms and modified the sequence of patches: 01:dropped, 02->03, 03->02, 04->01, 05->04 * Addressed comments from Greg, Scott and Christophe * Use "uiomem->internal_addr" as if condition for sram memory free, and memset the uiomem entry * Modified of_match_table make the driver apart from Cache-Sram HW info which belong to the HW level driver fsl_85xx_cache_sram to match * Use roundup_pow_of_two for align calc(really learned a lot from Christophe) * Remove useless clear block of uiomem entries. * Use UIO_INFO_VER micro for info->version, and define it as "devicetree,pseudo", meaning this is pseudo device and probed from device tree configuration * Select FSL_85XX_CACHE_SRAM rather than depends on it Wang Wenhu (4): powerpc: sysdev: fix compile error for fsl_85xx_l2ctlr powerpc: sysdev: fix compile error for fsl_85xx_cache_sram powerpc: sysdev: fix compile warning for fsl_85xx_cache_sram drivers: uio: new driver for fsl_85xx_cache_sram arch/powerpc/sysdev/fsl_85xx_cache_sram.c | 3 +- arch/powerpc/sysdev/fsl_85xx_l2ctlr.c | 1 + drivers/uio/Kconfig | 9 ++ drivers/uio/Makefile | 1 + drivers/uio/uio_fsl_85xx_cache_sram.c | 158 ++ 5 files changed, 171 insertions(+), 1 deletion(-) create mode 100644 drivers/uio/uio_fsl_85xx_cache_sram.c -- 2.17.1
[PATCH RESEND, v3, 1/4] powerpc: sysdev: fix compile error for fsl_85xx_l2ctlr
Include "linux/of_address.h" to fix the compile error for mpc85xx_l2ctlr_of_probe() when compiling fsl_85xx_cache_sram.c. CC arch/powerpc/sysdev/fsl_85xx_l2ctlr.o arch/powerpc/sysdev/fsl_85xx_l2ctlr.c: In function ‘mpc85xx_l2ctlr_of_probe’: arch/powerpc/sysdev/fsl_85xx_l2ctlr.c:90:11: error: implicit declaration of function ‘of_iomap’; did you mean ‘pci_iomap’? [-Werror=implicit-function-declaration] l2ctlr = of_iomap(dev->dev.of_node, 0); ^~~~ pci_iomap arch/powerpc/sysdev/fsl_85xx_l2ctlr.c:90:9: error: assignment makes pointer from integer without a cast [-Werror=int-conversion] l2ctlr = of_iomap(dev->dev.of_node, 0); ^ cc1: all warnings being treated as errors scripts/Makefile.build:267: recipe for target 'arch/powerpc/sysdev/fsl_85xx_l2ctlr.o' failed make[2]: *** [arch/powerpc/sysdev/fsl_85xx_l2ctlr.o] Error 1 Cc: Greg Kroah-Hartman Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org Fixes: 6db92cc9d07d ("powerpc/85xx: add cache-sram support") Signed-off-by: Wang Wenhu --- Changes since v1: * None Changes since v2: * None --- arch/powerpc/sysdev/fsl_85xx_l2ctlr.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c b/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c index 2d0af0c517bb..7533572492f0 100644 --- a/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c +++ b/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include "fsl_85xx_cache_ctlr.h" -- 2.17.1
[PATCH RESEND, v3, 3/4] powerpc: sysdev: fix compile warning for fsl_85xx_cache_sram
Function instantiate_cache_sram should not be linked into the init section for its caller mpc85xx_l2ctlr_of_probe is none-__init. Cc: Greg Kroah-Hartman Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org Fixes: 6db92cc9d07d ("powerpc/85xx: add cache-sram support") Signed-off-by: Wang Wenhu Warning information: MODPOST vmlinux.o WARNING: modpost: vmlinux.o(.text+0x1e540): Section mismatch in reference from the function mpc85xx_l2ctlr_of_probe() to the function .init.text:instantiate_cache_sram() The function mpc85xx_l2ctlr_of_probe() references the function __init instantiate_cache_sram(). This is often because mpc85xx_l2ctlr_of_probe lacks a __init annotation or the annotation of instantiate_cache_sram is wrong. --- Changes since v1: * None Changes since v2: * None --- arch/powerpc/sysdev/fsl_85xx_cache_sram.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c index be3aef4229d7..3de5ac8382c0 100644 --- a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c +++ b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c @@ -68,7 +68,7 @@ void mpc85xx_cache_sram_free(void *ptr) } EXPORT_SYMBOL(mpc85xx_cache_sram_free); -int __init instantiate_cache_sram(struct platform_device *dev, +int instantiate_cache_sram(struct platform_device *dev, struct sram_parameters sram_params) { int ret = 0; -- 2.17.1
[PATCH RESEND, v3, 2/4] powerpc: sysdev: fix compile error for fsl_85xx_cache_sram
Include linux/io.h into fsl_85xx_cache_sram.c to fix the implicit-declaration compile error when building Cache-Sram. arch/powerpc/sysdev/fsl_85xx_cache_sram.c: In function ‘instantiate_cache_sram’: arch/powerpc/sysdev/fsl_85xx_cache_sram.c:97:26: error: implicit declaration of function ‘ioremap_coherent’; did you mean ‘bitmap_complement’? [-Werror=implicit-function-declaration] cache_sram->base_virt = ioremap_coherent(cache_sram->base_phys, ^~~~ bitmap_complement arch/powerpc/sysdev/fsl_85xx_cache_sram.c:97:24: error: assignment makes pointer from integer without a cast [-Werror=int-conversion] cache_sram->base_virt = ioremap_coherent(cache_sram->base_phys, ^ arch/powerpc/sysdev/fsl_85xx_cache_sram.c:123:2: error: implicit declaration of function ‘iounmap’; did you mean ‘roundup’? [-Werror=implicit-function-declaration] iounmap(cache_sram->base_virt); ^~~ roundup cc1: all warnings being treated as errors Cc: Greg Kroah-Hartman Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org Fixes: 6db92cc9d07d ("powerpc/85xx: add cache-sram support") Signed-off-by: WANG Wenhu --- Changes since v1: * None Changes since v2: * None --- arch/powerpc/sysdev/fsl_85xx_cache_sram.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c index f6c665dac725..be3aef4229d7 100644 --- a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c +++ b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "fsl_85xx_cache_ctlr.h" -- 2.17.1
[PATCH RESEND, v3, 4/4] drivers: uio: new driver for fsl_85xx_cache_sram
A driver for freescale 85xx platforms to access the Cache-Sram form user level. This is extremely helpful for some user-space applications that require high performance memory accesses. Cc: Greg Kroah-Hartman Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org Signed-off-by: Wang Wenhu --- Changes since v1: * Addressed comments from Greg K-H * Moved kfree(info->name) into uio_info_free_internal() Changes since v2: * Addressed comments from Greg, Scott and Christophe * Use "uiomem->internal_addr" as if condition for sram memory free, and memset the uiomem entry * Modified of_match_table make the driver apart from Cache-Sram HW info which belong to the HW level driver fsl_85xx_cache_sram to match * Use roundup_pow_of_two for align calculation * Remove useless clear block of uiomem entries. * Use UIO_INFO_VER micro for info->version, and define it as "devicetree,pseudo", meaning this is pseudo device and probed from device tree configuration * Select FSL_85XX_CACHE_SRAM rather than depends on it --- drivers/uio/Kconfig | 9 ++ drivers/uio/Makefile | 1 + drivers/uio/uio_fsl_85xx_cache_sram.c | 158 ++ 3 files changed, 168 insertions(+) create mode 100644 drivers/uio/uio_fsl_85xx_cache_sram.c diff --git a/drivers/uio/Kconfig b/drivers/uio/Kconfig index 202ee81cfc2b..9c3b47461b71 100644 --- a/drivers/uio/Kconfig +++ b/drivers/uio/Kconfig @@ -105,6 +105,15 @@ config UIO_NETX To compile this driver as a module, choose M here; the module will be called uio_netx. +config UIO_FSL_85XX_CACHE_SRAM + tristate "Freescale 85xx Cache-Sram driver" + depends on FSL_SOC_BOOKE && PPC32 + select FSL_85XX_CACHE_SRAM + help + Generic driver for accessing the Cache-Sram form user level. This + is extremely helpful for some user-space applications that require + high performance memory accesses. + config UIO_FSL_ELBC_GPCM tristate "eLBC/GPCM driver" depends on FSL_LBC diff --git a/drivers/uio/Makefile b/drivers/uio/Makefile index c285dd2a4539..be2056cffc21 100644 --- a/drivers/uio/Makefile +++ b/drivers/uio/Makefile @@ -10,4 +10,5 @@ obj-$(CONFIG_UIO_NETX)+= uio_netx.o obj-$(CONFIG_UIO_PRUSS) += uio_pruss.o obj-$(CONFIG_UIO_MF624) += uio_mf624.o obj-$(CONFIG_UIO_FSL_ELBC_GPCM)+= uio_fsl_elbc_gpcm.o +obj-$(CONFIG_UIO_FSL_85XX_CACHE_SRAM) += uio_fsl_85xx_cache_sram.o obj-$(CONFIG_UIO_HV_GENERIC) += uio_hv_generic.o diff --git a/drivers/uio/uio_fsl_85xx_cache_sram.c b/drivers/uio/uio_fsl_85xx_cache_sram.c new file mode 100644 index ..8701df695307 --- /dev/null +++ b/drivers/uio/uio_fsl_85xx_cache_sram.c @@ -0,0 +1,158 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2020 Vivo Communication Technology Co. Ltd. + * Copyright (C) 2020 Wang Wenhu + * All rights reserved. + */ + +#include +#include +#include +#include +#include +#include + +#define DRIVER_NAME"uio_fsl_85xx_cache_sram" +#define UIO_INFO_VER "devicetree,pseudo" +#define UIO_NAME "uio_cache_sram" + +static void uio_info_free_internal(struct uio_info *info) +{ + struct uio_mem *uiomem = info->mem; + + while (uiomem < &info->mem[MAX_UIO_MAPS]) { + if (uiomem->internal_addr) { + mpc85xx_cache_sram_free(uiomem->internal_addr); + kfree(uiomem->name); + memset(uiomem, 0, sizeof(*uiomem)); + } + uiomem++; + } + + kfree(info->name); +} + +static int uio_fsl_85xx_cache_sram_probe(struct platform_device *pdev) +{ + struct device_node *parent = pdev->dev.of_node; + struct device_node *node = NULL; + struct uio_info *info; + struct uio_mem *uiomem; + const char *dt_name; + u32 mem_size; + int ret; + + /* alloc uio_info for one device */ + info = kzalloc(sizeof(*info), GFP_KERNEL); + if (!info) + return -ENOMEM; + + /* get optional uio name */ + if (of_property_read_string(parent, "uio_name", &dt_name)) + dt_name = UIO_NAME; + + info->name = kstrdup(dt_name, GFP_KERNEL); + if (!info->name) { + ret = -ENOMEM; + goto err_info_free; + } + + uiomem = info->mem; + for_each_child_of_node(parent, node) { + void *virt; + phys_addr_t phys; + + ret = of_property_read_u32(node, "cache-mem-size", &mem_size); + if (ret) { + ret = -EINVAL; + goto err_info_free_internal; + } + + if (mem_size == 0) { +
[PATCH v3, 3/4] powerpc: sysdev: fix compile warning for fsl_85xx_cache_sram
Function instantiate_cache_sram should not be linked into the init section for its caller mpc85xx_l2ctlr_of_probe is none-__init. Cc: Greg Kroah-Hartman Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org Fixes: 6db92cc9d07d ("powerpc/85xx: add cache-sram support") Signed-off-by: Wang Wenhu Warning information: MODPOST vmlinux.o WARNING: modpost: vmlinux.o(.text+0x1e540): Section mismatch in reference from the function mpc85xx_l2ctlr_of_probe() to the function .init.text:instantiate_cache_sram() The function mpc85xx_l2ctlr_of_probe() references the function __init instantiate_cache_sram(). This is often because mpc85xx_l2ctlr_of_probe lacks a __init annotation or the annotation of instantiate_cache_sram is wrong. --- Changes since v1: * None Changes since v2: * None --- arch/powerpc/sysdev/fsl_85xx_cache_sram.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c index be3aef4229d7..3de5ac8382c0 100644 --- a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c +++ b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c @@ -68,7 +68,7 @@ void mpc85xx_cache_sram_free(void *ptr) } EXPORT_SYMBOL(mpc85xx_cache_sram_free); -int __init instantiate_cache_sram(struct platform_device *dev, +int instantiate_cache_sram(struct platform_device *dev, struct sram_parameters sram_params) { int ret = 0; -- 2.17.1
[PATCH v3,4/4] drivers: uio: new driver for fsl_85xx_cache_sram
A driver for freescale 85xx platforms to access the Cache-Sram form user level. This is extremely helpful for some user-space applications that require high performance memory accesses. Cc: Greg Kroah-Hartman Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org Signed-off-by: Wang Wenhu --- Changes since v1: * Addressed comments from Greg K-H * Moved kfree(info->name) into uio_info_free_internal() Changes since v2: * Addressed comments from Greg, Scott and Christophe * Use "uiomem->internal_addr" as if condition for sram memory free, and memset the uiomem entry * Modified of_match_table make the driver apart from Cache-Sram HW info which belong to the HW level driver fsl_85xx_cache_sram to match * Use roundup_pow_of_two for align calculation * Remove useless clear block of uiomem entries. * Use UIO_INFO_VER micro for info->version, and define it as "devicetree,pseudo", meaning this is pseudo device and probed from device tree configuration * Select FSL_85XX_CACHE_SRAM rather than depends on it --- drivers/uio/Kconfig | 9 ++ drivers/uio/Makefile | 1 + drivers/uio/uio_fsl_85xx_cache_sram.c | 158 ++ 3 files changed, 168 insertions(+) create mode 100644 drivers/uio/uio_fsl_85xx_cache_sram.c diff --git a/drivers/uio/Kconfig b/drivers/uio/Kconfig index 202ee81cfc2b..9c3b47461b71 100644 --- a/drivers/uio/Kconfig +++ b/drivers/uio/Kconfig @@ -105,6 +105,15 @@ config UIO_NETX To compile this driver as a module, choose M here; the module will be called uio_netx. +config UIO_FSL_85XX_CACHE_SRAM + tristate "Freescale 85xx Cache-Sram driver" + depends on FSL_SOC_BOOKE && PPC32 + select FSL_85XX_CACHE_SRAM + help + Generic driver for accessing the Cache-Sram form user level. This + is extremely helpful for some user-space applications that require + high performance memory accesses. + config UIO_FSL_ELBC_GPCM tristate "eLBC/GPCM driver" depends on FSL_LBC diff --git a/drivers/uio/Makefile b/drivers/uio/Makefile index c285dd2a4539..be2056cffc21 100644 --- a/drivers/uio/Makefile +++ b/drivers/uio/Makefile @@ -10,4 +10,5 @@ obj-$(CONFIG_UIO_NETX)+= uio_netx.o obj-$(CONFIG_UIO_PRUSS) += uio_pruss.o obj-$(CONFIG_UIO_MF624) += uio_mf624.o obj-$(CONFIG_UIO_FSL_ELBC_GPCM)+= uio_fsl_elbc_gpcm.o +obj-$(CONFIG_UIO_FSL_85XX_CACHE_SRAM) += uio_fsl_85xx_cache_sram.o obj-$(CONFIG_UIO_HV_GENERIC) += uio_hv_generic.o diff --git a/drivers/uio/uio_fsl_85xx_cache_sram.c b/drivers/uio/uio_fsl_85xx_cache_sram.c new file mode 100644 index ..8701df695307 --- /dev/null +++ b/drivers/uio/uio_fsl_85xx_cache_sram.c @@ -0,0 +1,158 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2020 Vivo Communication Technology Co. Ltd. + * Copyright (C) 2020 Wang Wenhu + * All rights reserved. + */ + +#include +#include +#include +#include +#include +#include + +#define DRIVER_NAME"uio_fsl_85xx_cache_sram" +#define UIO_INFO_VER "devicetree,pseudo" +#define UIO_NAME "uio_cache_sram" + +static void uio_info_free_internal(struct uio_info *info) +{ + struct uio_mem *uiomem = info->mem; + + while (uiomem < &info->mem[MAX_UIO_MAPS]) { + if (uiomem->internal_addr) { + mpc85xx_cache_sram_free(uiomem->internal_addr); + kfree(uiomem->name); + memset(uiomem, 0, sizeof(*uiomem)); + } + uiomem++; + } + + kfree(info->name); +} + +static int uio_fsl_85xx_cache_sram_probe(struct platform_device *pdev) +{ + struct device_node *parent = pdev->dev.of_node; + struct device_node *node = NULL; + struct uio_info *info; + struct uio_mem *uiomem; + const char *dt_name; + u32 mem_size; + int ret; + + /* alloc uio_info for one device */ + info = kzalloc(sizeof(*info), GFP_KERNEL); + if (!info) + return -ENOMEM; + + /* get optional uio name */ + if (of_property_read_string(parent, "uio_name", &dt_name)) + dt_name = UIO_NAME; + + info->name = kstrdup(dt_name, GFP_KERNEL); + if (!info->name) { + ret = -ENOMEM; + goto err_info_free; + } + + uiomem = info->mem; + for_each_child_of_node(parent, node) { + void *virt; + phys_addr_t phys; + + ret = of_property_read_u32(node, "cache-mem-size", &mem_size); + if (ret) { + ret = -EINVAL; + goto err_info_free_internal; + } + + if (mem_size == 0) { +
[PATCH v3,0/4] drivers: uio: new driver uio_fsl_85xx_cache_sram
This series add a new uio driver for freescale 85xx platforms to access the Cache-Sram form user level. This is extremely helpful for the user-space applications that require high performance memory accesses. It fixes the compile errors and warning of the hardware level drivers and implements the uio driver in uio_fsl_85xx_cache_sram.c. Changes since v1: * Addressed comments from Greg K-H * Moved kfree(info->name) into uio_info_free_internal() Changes since v2: * Drop the patch that modifies Kconfigs of arch/powerpc/platforms and modified the sequence of patches: 01:dropped, 02->03, 03->02, 04->01, 05->04 * Addressed comments from Greg, Scott and Christophe * Use "uiomem->internal_addr" as if condition for sram memory free, and memset the uiomem entry * Modified of_match_table make the driver apart from Cache-Sram HW info which belong to the HW level driver fsl_85xx_cache_sram to match * Use roundup_pow_of_two for align calc(really learned a lot from Christophe) * Remove useless clear block of uiomem entries. * Use UIO_INFO_VER micro for info->version, and define it as "devicetree,pseudo", meaning this is pseudo device and probed from device tree configuration * Select FSL_85XX_CACHE_SRAM rather than depends on it Wang Wenhu (4): powerpc: sysdev: fix compile error for fsl_85xx_l2ctlr powerpc: sysdev: fix compile error for fsl_85xx_cache_sram powerpc: sysdev: fix compile warning for fsl_85xx_cache_sram drivers: uio: new driver for fsl_85xx_cache_sram arch/powerpc/sysdev/fsl_85xx_cache_sram.c | 3 +- arch/powerpc/sysdev/fsl_85xx_l2ctlr.c | 1 + drivers/uio/Kconfig | 9 ++ drivers/uio/Makefile | 1 + drivers/uio/uio_fsl_85xx_cache_sram.c | 158 ++ 5 files changed, 171 insertions(+), 1 deletion(-) create mode 100644 drivers/uio/uio_fsl_85xx_cache_sram.c -- 2.17.1
[PATCH v3, 2/4] powerpc: sysdev: fix compile error for fsl_85xx_cache_sram
Include linux/io.h into fsl_85xx_cache_sram.c to fix the implicit-declaration compile error when building Cache-Sram. arch/powerpc/sysdev/fsl_85xx_cache_sram.c: In function ‘instantiate_cache_sram’: arch/powerpc/sysdev/fsl_85xx_cache_sram.c:97:26: error: implicit declaration of function ‘ioremap_coherent’; did you mean ‘bitmap_complement’? [-Werror=implicit-function-declaration] cache_sram->base_virt = ioremap_coherent(cache_sram->base_phys, ^~~~ bitmap_complement arch/powerpc/sysdev/fsl_85xx_cache_sram.c:97:24: error: assignment makes pointer from integer without a cast [-Werror=int-conversion] cache_sram->base_virt = ioremap_coherent(cache_sram->base_phys, ^ arch/powerpc/sysdev/fsl_85xx_cache_sram.c:123:2: error: implicit declaration of function ‘iounmap’; did you mean ‘roundup’? [-Werror=implicit-function-declaration] iounmap(cache_sram->base_virt); ^~~ roundup cc1: all warnings being treated as errors Cc: Greg Kroah-Hartman Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org Fixes: 6db92cc9d07d ("powerpc/85xx: add cache-sram support") Signed-off-by: WANG Wenhu --- Changes since v1: * None Changes since v2: * None --- arch/powerpc/sysdev/fsl_85xx_cache_sram.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c index f6c665dac725..be3aef4229d7 100644 --- a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c +++ b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "fsl_85xx_cache_ctlr.h" -- 2.17.1
[PATCH v3, 1/4] powerpc: sysdev: fix compile error for fsl_85xx_l2ctlr
Include "linux/of_address.h" to fix the compile error for mpc85xx_l2ctlr_of_probe() when compiling fsl_85xx_cache_sram.c. CC arch/powerpc/sysdev/fsl_85xx_l2ctlr.o arch/powerpc/sysdev/fsl_85xx_l2ctlr.c: In function ‘mpc85xx_l2ctlr_of_probe’: arch/powerpc/sysdev/fsl_85xx_l2ctlr.c:90:11: error: implicit declaration of function ‘of_iomap’; did you mean ‘pci_iomap’? [-Werror=implicit-function-declaration] l2ctlr = of_iomap(dev->dev.of_node, 0); ^~~~ pci_iomap arch/powerpc/sysdev/fsl_85xx_l2ctlr.c:90:9: error: assignment makes pointer from integer without a cast [-Werror=int-conversion] l2ctlr = of_iomap(dev->dev.of_node, 0); ^ cc1: all warnings being treated as errors scripts/Makefile.build:267: recipe for target 'arch/powerpc/sysdev/fsl_85xx_l2ctlr.o' failed make[2]: *** [arch/powerpc/sysdev/fsl_85xx_l2ctlr.o] Error 1 Cc: Greg Kroah-Hartman Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org Fixes: 6db92cc9d07d ("powerpc/85xx: add cache-sram support") Signed-off-by: Wang Wenhu --- Changes since v1: * None Changes since v2: * None --- arch/powerpc/sysdev/fsl_85xx_l2ctlr.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c b/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c index 2d0af0c517bb..7533572492f0 100644 --- a/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c +++ b/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include "fsl_85xx_cache_ctlr.h" -- 2.17.1
[PATCH v3,4/4] drivers: uio: new driver for fsl_85xx_cache_sram
A driver for freescale 85xx platforms to access the Cache-Sram form user level. This is extremely helpful for some user-space applications that require high performance memory accesses. Cc: Greg Kroah-Hartman Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org Signed-off-by: Wang Wenhu --- Changes since v1: * Addressed comments from Greg K-H * Moved kfree(info->name) into uio_info_free_internal() Changes since v2: * Addressed comments from Greg, Scott and Christophe * Use "uiomem->internal_addr" as if condition for sram memory free, and memset the uiomem entry * Modified of_match_table make the driver apart from Cache-Sram HW info which belong to the HW level driver fsl_85xx_cache_sram to match * Use roundup_pow_of_two for align calculation * Remove useless clear block of uiomem entries. * Use UIO_INFO_VER micro for info->version, and define it as "devicetree,pseudo", meaning this is pseudo device and probed from device tree configuration * Select FSL_85XX_CACHE_SRAM rather than depends on it --- drivers/uio/Kconfig | 9 ++ drivers/uio/Makefile | 1 + drivers/uio/uio_fsl_85xx_cache_sram.c | 158 ++ 3 files changed, 168 insertions(+) create mode 100644 drivers/uio/uio_fsl_85xx_cache_sram.c diff --git a/drivers/uio/Kconfig b/drivers/uio/Kconfig index 202ee81cfc2b..9c3b47461b71 100644 --- a/drivers/uio/Kconfig +++ b/drivers/uio/Kconfig @@ -105,6 +105,15 @@ config UIO_NETX To compile this driver as a module, choose M here; the module will be called uio_netx. +config UIO_FSL_85XX_CACHE_SRAM + tristate "Freescale 85xx Cache-Sram driver" + depends on FSL_SOC_BOOKE && PPC32 + select FSL_85XX_CACHE_SRAM + help + Generic driver for accessing the Cache-Sram form user level. This + is extremely helpful for some user-space applications that require + high performance memory accesses. + config UIO_FSL_ELBC_GPCM tristate "eLBC/GPCM driver" depends on FSL_LBC diff --git a/drivers/uio/Makefile b/drivers/uio/Makefile index c285dd2a4539..be2056cffc21 100644 --- a/drivers/uio/Makefile +++ b/drivers/uio/Makefile @@ -10,4 +10,5 @@ obj-$(CONFIG_UIO_NETX)+= uio_netx.o obj-$(CONFIG_UIO_PRUSS) += uio_pruss.o obj-$(CONFIG_UIO_MF624) += uio_mf624.o obj-$(CONFIG_UIO_FSL_ELBC_GPCM)+= uio_fsl_elbc_gpcm.o +obj-$(CONFIG_UIO_FSL_85XX_CACHE_SRAM) += uio_fsl_85xx_cache_sram.o obj-$(CONFIG_UIO_HV_GENERIC) += uio_hv_generic.o diff --git a/drivers/uio/uio_fsl_85xx_cache_sram.c b/drivers/uio/uio_fsl_85xx_cache_sram.c new file mode 100644 index ..8701df695307 --- /dev/null +++ b/drivers/uio/uio_fsl_85xx_cache_sram.c @@ -0,0 +1,158 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2020 Vivo Communication Technology Co. Ltd. + * Copyright (C) 2020 Wang Wenhu + * All rights reserved. + */ + +#include +#include +#include +#include +#include +#include + +#define DRIVER_NAME"uio_fsl_85xx_cache_sram" +#define UIO_INFO_VER "devicetree,pseudo" +#define UIO_NAME "uio_cache_sram" + +static void uio_info_free_internal(struct uio_info *info) +{ + struct uio_mem *uiomem = info->mem; + + while (uiomem < &info->mem[MAX_UIO_MAPS]) { + if (uiomem->internal_addr) { + mpc85xx_cache_sram_free(uiomem->internal_addr); + kfree(uiomem->name); + memset(uiomem, 0, sizeof(*uiomem)); + } + uiomem++; + } + + kfree(info->name); +} + +static int uio_fsl_85xx_cache_sram_probe(struct platform_device *pdev) +{ + struct device_node *parent = pdev->dev.of_node; + struct device_node *node = NULL; + struct uio_info *info; + struct uio_mem *uiomem; + const char *dt_name; + u32 mem_size; + int ret; + + /* alloc uio_info for one device */ + info = kzalloc(sizeof(*info), GFP_KERNEL); + if (!info) + return -ENOMEM; + + /* get optional uio name */ + if (of_property_read_string(parent, "uio_name", &dt_name)) + dt_name = UIO_NAME; + + info->name = kstrdup(dt_name, GFP_KERNEL); + if (!info->name) { + ret = -ENOMEM; + goto err_info_free; + } + + uiomem = info->mem; + for_each_child_of_node(parent, node) { + void *virt; + phys_addr_t phys; + + ret = of_property_read_u32(node, "cache-mem-size", &mem_size); + if (ret) { + ret = -EINVAL; + goto err_info_free_internal; + } + + if (mem_size == 0) { +
[PATCH v3, 3/4] powerpc: sysdev: fix compile warning for fsl_85xx_cache_sram
Function instantiate_cache_sram should not be linked into the init section for its caller mpc85xx_l2ctlr_of_probe is none-__init. Cc: Greg Kroah-Hartman Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org Fixes: 6db92cc9d07d ("powerpc/85xx: add cache-sram support") Signed-off-by: Wang Wenhu Warning information: MODPOST vmlinux.o WARNING: modpost: vmlinux.o(.text+0x1e540): Section mismatch in reference from the function mpc85xx_l2ctlr_of_probe() to the function .init.text:instantiate_cache_sram() The function mpc85xx_l2ctlr_of_probe() references the function __init instantiate_cache_sram(). This is often because mpc85xx_l2ctlr_of_probe lacks a __init annotation or the annotation of instantiate_cache_sram is wrong. --- Changes since v1: * None Changes since v2: * None --- arch/powerpc/sysdev/fsl_85xx_cache_sram.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c index be3aef4229d7..3de5ac8382c0 100644 --- a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c +++ b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c @@ -68,7 +68,7 @@ void mpc85xx_cache_sram_free(void *ptr) } EXPORT_SYMBOL(mpc85xx_cache_sram_free); -int __init instantiate_cache_sram(struct platform_device *dev, +int instantiate_cache_sram(struct platform_device *dev, struct sram_parameters sram_params) { int ret = 0; -- 2.17.1
[PATCH v3, 2/4] powerpc: sysdev: fix compile error for fsl_85xx_cache_sram
Include linux/io.h into fsl_85xx_cache_sram.c to fix the implicit-declaration compile error when building Cache-Sram. arch/powerpc/sysdev/fsl_85xx_cache_sram.c: In function ‘instantiate_cache_sram’: arch/powerpc/sysdev/fsl_85xx_cache_sram.c:97:26: error: implicit declaration of function ‘ioremap_coherent’; did you mean ‘bitmap_complement’? [-Werror=implicit-function-declaration] cache_sram->base_virt = ioremap_coherent(cache_sram->base_phys, ^~~~ bitmap_complement arch/powerpc/sysdev/fsl_85xx_cache_sram.c:97:24: error: assignment makes pointer from integer without a cast [-Werror=int-conversion] cache_sram->base_virt = ioremap_coherent(cache_sram->base_phys, ^ arch/powerpc/sysdev/fsl_85xx_cache_sram.c:123:2: error: implicit declaration of function ‘iounmap’; did you mean ‘roundup’? [-Werror=implicit-function-declaration] iounmap(cache_sram->base_virt); ^~~ roundup cc1: all warnings being treated as errors Cc: Greg Kroah-Hartman Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org Fixes: 6db92cc9d07d ("powerpc/85xx: add cache-sram support") Signed-off-by: WANG Wenhu --- Changes since v1: * None Changes since v2: * None --- arch/powerpc/sysdev/fsl_85xx_cache_sram.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c index f6c665dac725..be3aef4229d7 100644 --- a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c +++ b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "fsl_85xx_cache_ctlr.h" -- 2.17.1
[PATCH v3, 1/4] powerpc: sysdev: fix compile error for fsl_85xx_l2ctlr
Include "linux/of_address.h" to fix the compile error for mpc85xx_l2ctlr_of_probe() when compiling fsl_85xx_cache_sram.c. CC arch/powerpc/sysdev/fsl_85xx_l2ctlr.o arch/powerpc/sysdev/fsl_85xx_l2ctlr.c: In function ‘mpc85xx_l2ctlr_of_probe’: arch/powerpc/sysdev/fsl_85xx_l2ctlr.c:90:11: error: implicit declaration of function ‘of_iomap’; did you mean ‘pci_iomap’? [-Werror=implicit-function-declaration] l2ctlr = of_iomap(dev->dev.of_node, 0); ^~~~ pci_iomap arch/powerpc/sysdev/fsl_85xx_l2ctlr.c:90:9: error: assignment makes pointer from integer without a cast [-Werror=int-conversion] l2ctlr = of_iomap(dev->dev.of_node, 0); ^ cc1: all warnings being treated as errors scripts/Makefile.build:267: recipe for target 'arch/powerpc/sysdev/fsl_85xx_l2ctlr.o' failed make[2]: *** [arch/powerpc/sysdev/fsl_85xx_l2ctlr.o] Error 1 Cc: Greg Kroah-Hartman Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org Fixes: 6db92cc9d07d ("powerpc/85xx: add cache-sram support") Signed-off-by: Wang Wenhu --- Changes since v1: * None Changes since v2: * None --- arch/powerpc/sysdev/fsl_85xx_l2ctlr.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c b/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c index 2d0af0c517bb..7533572492f0 100644 --- a/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c +++ b/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include "fsl_85xx_cache_ctlr.h" -- 2.17.1
[PATCH v3,0/4] drivers: uio: new driver uio_fsl_85xx_cache_sram
This series add a new uio driver for freescale 85xx platforms to access the Cache-Sram form user level. This is extremely helpful for the user-space applications that require high performance memory accesses. It fixes the compile errors and warning of the hardware level drivers and implements the uio driver in uio_fsl_85xx_cache_sram.c. Changes since v1: * Addressed comments from Greg K-H * Moved kfree(info->name) into uio_info_free_internal() Changes since v2: * Drop the patch that modifies Kconfigs of arch/powerpc/platforms and modified the sequence of patches: 01:dropped, 02->03, 03->02, 04->01, 05->04 * Addressed comments from Greg, Scott and Christophe * Use "uiomem->internal_addr" as if condition for sram memory free, and memset the uiomem entry * Modified of_match_table make the driver apart from Cache-Sram HW info which belong to the HW level driver fsl_85xx_cache_sram to match * Use roundup_pow_of_two for align calc(really learned a lot from Christophe) * Remove useless clear block of uiomem entries. * Use UIO_INFO_VER micro for info->version, and define it as "devicetree,pseudo", meaning this is pseudo device and probed from device tree configuration * Select FSL_85XX_CACHE_SRAM rather than depends on it Wang Wenhu (4): powerpc: sysdev: fix compile error for fsl_85xx_l2ctlr powerpc: sysdev: fix compile error for fsl_85xx_cache_sram powerpc: sysdev: fix compile warning for fsl_85xx_cache_sram drivers: uio: new driver for fsl_85xx_cache_sram arch/powerpc/sysdev/fsl_85xx_cache_sram.c | 3 +- arch/powerpc/sysdev/fsl_85xx_l2ctlr.c | 1 + drivers/uio/Kconfig | 9 ++ drivers/uio/Makefile | 1 + drivers/uio/uio_fsl_85xx_cache_sram.c | 158 ++ 5 files changed, 171 insertions(+), 1 deletion(-) create mode 100644 drivers/uio/uio_fsl_85xx_cache_sram.c -- 2.17.1
[PATCH v3, 3/4] powerpc: sysdev: fix compile warning for fsl_85xx_cache_sram
Function instantiate_cache_sram should not be linked into the init section for its caller mpc85xx_l2ctlr_of_probe is none-__init. Cc: Greg Kroah-Hartman Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org Fixes: 6db92cc9d07d ("powerpc/85xx: add cache-sram support") Signed-off-by: Wang Wenhu Warning information: MODPOST vmlinux.o WARNING: modpost: vmlinux.o(.text+0x1e540): Section mismatch in reference from the function mpc85xx_l2ctlr_of_probe() to the function .init.text:instantiate_cache_sram() The function mpc85xx_l2ctlr_of_probe() references the function __init instantiate_cache_sram(). This is often because mpc85xx_l2ctlr_of_probe lacks a __init annotation or the annotation of instantiate_cache_sram is wrong. --- Changes since v1: * None Changes since v2: * None --- arch/powerpc/sysdev/fsl_85xx_cache_sram.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c index be3aef4229d7..3de5ac8382c0 100644 --- a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c +++ b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c @@ -68,7 +68,7 @@ void mpc85xx_cache_sram_free(void *ptr) } EXPORT_SYMBOL(mpc85xx_cache_sram_free); -int __init instantiate_cache_sram(struct platform_device *dev, +int instantiate_cache_sram(struct platform_device *dev, struct sram_parameters sram_params) { int ret = 0; -- 2.17.1
[PATCH v3,0/4] drivers: uio: new driver uio_fsl_85xx_cache_sram
This series add a new uio driver for freescale 85xx platforms to access the Cache-Sram form user level. This is extremely helpful for the user-space applications that require high performance memory accesses. It fixes the compile errors and warning of the hardware level drivers and implements the uio driver in uio_fsl_85xx_cache_sram.c. Changes since v1: * Addressed comments from Greg K-H * Moved kfree(info->name) into uio_info_free_internal() Changes since v2: * Drop the patch that modifies Kconfigs of arch/powerpc/platforms and modified the sequence of patches: 01:dropped, 02->03, 03->02, 04->01, 05->04 * Addressed comments from Greg, Scott and Christophe * Use "uiomem->internal_addr" as if condition for sram memory free, and memset the uiomem entry * Modified of_match_table make the driver apart from Cache-Sram HW info which belong to the HW level driver fsl_85xx_cache_sram to match * Use roundup_pow_of_two for align calc(really learned a lot from Christophe) * Remove useless clear block of uiomem entries. * Use UIO_INFO_VER micro for info->version, and define it as "devicetree,pseudo", meaning this is pseudo device and probed from device tree configuration * Select FSL_85XX_CACHE_SRAM rather than depends on it Wang Wenhu (4): powerpc: sysdev: fix compile error for fsl_85xx_l2ctlr powerpc: sysdev: fix compile error for fsl_85xx_cache_sram powerpc: sysdev: fix compile warning for fsl_85xx_cache_sram drivers: uio: new driver for fsl_85xx_cache_sram arch/powerpc/sysdev/fsl_85xx_cache_sram.c | 3 +- arch/powerpc/sysdev/fsl_85xx_l2ctlr.c | 1 + drivers/uio/Kconfig | 9 ++ drivers/uio/Makefile | 1 + drivers/uio/uio_fsl_85xx_cache_sram.c | 158 ++ 5 files changed, 171 insertions(+), 1 deletion(-) create mode 100644 drivers/uio/uio_fsl_85xx_cache_sram.c -- 2.17.1
[PATCH v3, 2/4] powerpc: sysdev: fix compile error for fsl_85xx_cache_sram
Include linux/io.h into fsl_85xx_cache_sram.c to fix the implicit-declaration compile error when building Cache-Sram. arch/powerpc/sysdev/fsl_85xx_cache_sram.c: In function ‘instantiate_cache_sram’: arch/powerpc/sysdev/fsl_85xx_cache_sram.c:97:26: error: implicit declaration of function ‘ioremap_coherent’; did you mean ‘bitmap_complement’? [-Werror=implicit-function-declaration] cache_sram->base_virt = ioremap_coherent(cache_sram->base_phys, ^~~~ bitmap_complement arch/powerpc/sysdev/fsl_85xx_cache_sram.c:97:24: error: assignment makes pointer from integer without a cast [-Werror=int-conversion] cache_sram->base_virt = ioremap_coherent(cache_sram->base_phys, ^ arch/powerpc/sysdev/fsl_85xx_cache_sram.c:123:2: error: implicit declaration of function ‘iounmap’; did you mean ‘roundup’? [-Werror=implicit-function-declaration] iounmap(cache_sram->base_virt); ^~~ roundup cc1: all warnings being treated as errors Cc: Greg Kroah-Hartman Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org Fixes: 6db92cc9d07d ("powerpc/85xx: add cache-sram support") Signed-off-by: WANG Wenhu --- Changes since v1: * None Changes since v2: * None --- arch/powerpc/sysdev/fsl_85xx_cache_sram.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c index f6c665dac725..be3aef4229d7 100644 --- a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c +++ b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "fsl_85xx_cache_ctlr.h" -- 2.17.1
[PATCH v3, 1/4] powerpc: sysdev: fix compile error for fsl_85xx_l2ctlr
Include "linux/of_address.h" to fix the compile error for mpc85xx_l2ctlr_of_probe() when compiling fsl_85xx_cache_sram.c. CC arch/powerpc/sysdev/fsl_85xx_l2ctlr.o arch/powerpc/sysdev/fsl_85xx_l2ctlr.c: In function ‘mpc85xx_l2ctlr_of_probe’: arch/powerpc/sysdev/fsl_85xx_l2ctlr.c:90:11: error: implicit declaration of function ‘of_iomap’; did you mean ‘pci_iomap’? [-Werror=implicit-function-declaration] l2ctlr = of_iomap(dev->dev.of_node, 0); ^~~~ pci_iomap arch/powerpc/sysdev/fsl_85xx_l2ctlr.c:90:9: error: assignment makes pointer from integer without a cast [-Werror=int-conversion] l2ctlr = of_iomap(dev->dev.of_node, 0); ^ cc1: all warnings being treated as errors scripts/Makefile.build:267: recipe for target 'arch/powerpc/sysdev/fsl_85xx_l2ctlr.o' failed make[2]: *** [arch/powerpc/sysdev/fsl_85xx_l2ctlr.o] Error 1 Cc: Greg Kroah-Hartman Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org Fixes: 6db92cc9d07d ("powerpc/85xx: add cache-sram support") Signed-off-by: Wang Wenhu --- Changes since v1: * None Changes since v2: * None --- arch/powerpc/sysdev/fsl_85xx_l2ctlr.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c b/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c index 2d0af0c517bb..7533572492f0 100644 --- a/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c +++ b/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include "fsl_85xx_cache_ctlr.h" -- 2.17.1
[PATCH v3,4/4] drivers: uio: new driver for fsl_85xx_cache_sram
A driver for freescale 85xx platforms to access the Cache-Sram form user level. This is extremely helpful for some user-space applications that require high performance memory accesses. Cc: Greg Kroah-Hartman Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org Signed-off-by: Wang Wenhu --- Changes since v1: * Addressed comments from Greg K-H * Moved kfree(info->name) into uio_info_free_internal() Changes since v2: * Addressed comments from Greg, Scott and Christophe * Use "uiomem->internal_addr" as if condition for sram memory free, and memset the uiomem entry * Modified of_match_table make the driver apart from Cache-Sram HW info which belong to the HW level driver fsl_85xx_cache_sram to match * Use roundup_pow_of_two for align calculation * Remove useless clear block of uiomem entries. * Use UIO_INFO_VER micro for info->version, and define it as "devicetree,pseudo", meaning this is pseudo device and probed from device tree configuration * Select FSL_85XX_CACHE_SRAM rather than depends on it --- drivers/uio/Kconfig | 9 ++ drivers/uio/Makefile | 1 + drivers/uio/uio_fsl_85xx_cache_sram.c | 158 ++ 3 files changed, 168 insertions(+) create mode 100644 drivers/uio/uio_fsl_85xx_cache_sram.c diff --git a/drivers/uio/Kconfig b/drivers/uio/Kconfig index 202ee81cfc2b..9c3b47461b71 100644 --- a/drivers/uio/Kconfig +++ b/drivers/uio/Kconfig @@ -105,6 +105,15 @@ config UIO_NETX To compile this driver as a module, choose M here; the module will be called uio_netx. +config UIO_FSL_85XX_CACHE_SRAM + tristate "Freescale 85xx Cache-Sram driver" + depends on FSL_SOC_BOOKE && PPC32 + select FSL_85XX_CACHE_SRAM + help + Generic driver for accessing the Cache-Sram form user level. This + is extremely helpful for some user-space applications that require + high performance memory accesses. + config UIO_FSL_ELBC_GPCM tristate "eLBC/GPCM driver" depends on FSL_LBC diff --git a/drivers/uio/Makefile b/drivers/uio/Makefile index c285dd2a4539..be2056cffc21 100644 --- a/drivers/uio/Makefile +++ b/drivers/uio/Makefile @@ -10,4 +10,5 @@ obj-$(CONFIG_UIO_NETX)+= uio_netx.o obj-$(CONFIG_UIO_PRUSS) += uio_pruss.o obj-$(CONFIG_UIO_MF624) += uio_mf624.o obj-$(CONFIG_UIO_FSL_ELBC_GPCM)+= uio_fsl_elbc_gpcm.o +obj-$(CONFIG_UIO_FSL_85XX_CACHE_SRAM) += uio_fsl_85xx_cache_sram.o obj-$(CONFIG_UIO_HV_GENERIC) += uio_hv_generic.o diff --git a/drivers/uio/uio_fsl_85xx_cache_sram.c b/drivers/uio/uio_fsl_85xx_cache_sram.c new file mode 100644 index ..8701df695307 --- /dev/null +++ b/drivers/uio/uio_fsl_85xx_cache_sram.c @@ -0,0 +1,158 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2020 Vivo Communication Technology Co. Ltd. + * Copyright (C) 2020 Wang Wenhu + * All rights reserved. + */ + +#include +#include +#include +#include +#include +#include + +#define DRIVER_NAME"uio_fsl_85xx_cache_sram" +#define UIO_INFO_VER "devicetree,pseudo" +#define UIO_NAME "uio_cache_sram" + +static void uio_info_free_internal(struct uio_info *info) +{ + struct uio_mem *uiomem = info->mem; + + while (uiomem < &info->mem[MAX_UIO_MAPS]) { + if (uiomem->internal_addr) { + mpc85xx_cache_sram_free(uiomem->internal_addr); + kfree(uiomem->name); + memset(uiomem, 0, sizeof(*uiomem)); + } + uiomem++; + } + + kfree(info->name); +} + +static int uio_fsl_85xx_cache_sram_probe(struct platform_device *pdev) +{ + struct device_node *parent = pdev->dev.of_node; + struct device_node *node = NULL; + struct uio_info *info; + struct uio_mem *uiomem; + const char *dt_name; + u32 mem_size; + int ret; + + /* alloc uio_info for one device */ + info = kzalloc(sizeof(*info), GFP_KERNEL); + if (!info) + return -ENOMEM; + + /* get optional uio name */ + if (of_property_read_string(parent, "uio_name", &dt_name)) + dt_name = UIO_NAME; + + info->name = kstrdup(dt_name, GFP_KERNEL); + if (!info->name) { + ret = -ENOMEM; + goto err_info_free; + } + + uiomem = info->mem; + for_each_child_of_node(parent, node) { + void *virt; + phys_addr_t phys; + + ret = of_property_read_u32(node, "cache-mem-size", &mem_size); + if (ret) { + ret = -EINVAL; + goto err_info_free_internal; + } + + if (mem_size == 0) { +
Re: [PATCH v2,5/5] drivers: uio: new driver for fsl_85xx_cache_sram
Yes, kzalloc() would clean the allocated areas and the init of remaining array elements are redundant. I will remove the block in v3. >> > + dev_err(&pdev->dev, "error no valid uio-map configured\n"); >> > + ret = -EINVAL; >> > + goto err_info_free_internel; >> > + } >> > + >> > + info->version = "0.1.0"; >> >> Could you define some DRIVER_VERSION in the top of the file next to >> DRIVER_NAME instead of hard coding in the middle on a function ? > >That's what v1 had, and Greg KH said to remove it. I'm guessing that he >thought it was the common-but-pointless practice of having the driver print a >version number that never gets updated, rather than something the UIO API >(unfortunately, compared to a feature query interface) expects. That said, >I'm not sure what the value is of making it a macro since it should only be >used once, that use is self documenting, it isn't tunable, etc. Though if >this isn't a macro, UIO_NAME also shouldn't be (and if it is made a macro >again, it should be UIO_VERSION, not DRIVER_VERSION). > >Does this really need a three-part version scheme? What's wrong with a >version of "1", to be changed to "2" in the hopefully-unlikely event that the >userspace API changes? Assuming UIO is used for this at all, which doesn't >seem like a great fit to me. > >-Scott > As Scott mentioned, the version define as necessity by uio core but actually useless for us here(and for many other type of devices I guess). So maybe the better way is to set it optionally, but this belong first to uio core. For the cache-sram uio driver, I will define an UIO_VERSION micro as a compromise fit all wonders, no confusing as Greg first mentioned. >> +static const struct of_device_id uio_mpc85xx_l2ctlr_of_match[] = { >> +{ .compatible = "uio,fsl,p2020-l2-cache-controller", }, >> +{ .compatible = "uio,fsl,p2010-l2-cache-controller", }, >> +{ .compatible = "uio,fsl,p1020-l2-cache-controller", }, >> +{ .compatible = "uio,fsl,p1011-l2-cache-controller", }, >> +{ .compatible = "uio,fsl,p1013-l2-cache-controller", }, >> +{ .compatible = "uio,fsl,p1022-l2-cache-controller", }, >> +{ .compatible = "uio,fsl,mpc8548-l2-cache-controller",}, >> +{ .compatible = "uio,fsl,mpc8544-l2-cache-controller",}, >> +{ .compatible = "uio,fsl,mpc8572-l2-cache-controller",}, >> +{ .compatible = "uio,fsl,mpc8536-l2-cache-controller",}, >> +{ .compatible = "uio,fsl,p1021-l2-cache-controller", }, >> +{ .compatible = "uio,fsl,p1012-l2-cache-controller", }, >> +{ .compatible = "uio,fsl,p1025-l2-cache-controller", }, >> +{ .compatible = "uio,fsl,p1016-l2-cache-controller", }, >> +{ .compatible = "uio,fsl,p1024-l2-cache-controller", }, >> +{ .compatible = "uio,fsl,p1015-l2-cache-controller", }, >> +{ .compatible = "uio,fsl,p1010-l2-cache-controller", }, >> +{ .compatible = "uio,fsl,bsc9131-l2-cache-controller",}, >> +{}, >> +}; > >NACK > >The device tree describes the hardware, not what driver you want to bind the >hardware to, or how you want to allocate the resources. And even if defining >nodes for sram allocation were the right way to go, why do you have a separate >compatible for each chip when you're just describing software configuration? > >Instead, have module parameters that take the sizes and alignments you'd like >to allocate and expose to userspace. Better still would be some sort of >dynamic allocation (e.g. open a fd, ioctl to set the requested size/alignment, >if it succeeds you can mmap it, and when the fd is closed the region is >freed). > >-Scott > Can not agree more. But what if I want to define more than one cache-sram uio devices? How about use the device tree for pseudo uio cache-sram driver? static const struct of_device_id uio_mpc85xx_l2ctlr_of_match[] = { { .compatible = "uio,cache-sram", }, {}, }; Thanks, Wenhu
Re: [PATCH v2, 1/5] powerpc: 85xx: make FSL_85XX_CACHE_SRAM configurable
From: Scott Wood >> +bool "32-bit kernel" > >Why make that user selectable ? > >Either a kernel is 64-bit or it is 32-bit. So having PPC64 user >selectable is all we need. > >And what is the link between this change and the description in the log ? > >> default y if !PPC64 >> select KASAN_VMALLOC if KASAN && MODULES >> >> @@ -15,6 +15,7 @@ config PPC_BOOK3S_32 >> bool >> >> menu "Processor support" >> + > >Why adding this space ? > >> choice >> prompt "Processor Type" >> depends on PPC32 >> @@ -211,9 +212,9 @@ config PPC_BOOK3E >> depends on PPC_BOOK3E_64 >> >> config E500 >> +bool "e500 Support" >> select FSL_EMB_PERFMON >> select PPC_FSL_BOOK3E >> -bool > >Why make this user-selectable ? This is already selected by the >processors requiring it, ie 8500, e5500 and e6500. > >Is there any other case where we need E500 ? > >And again, what's the link between this change and the description in >the log ? > > >> >> config PPC_E500MC >> bool "e500mc Support" >> > >Christophe Hi, Scott, Christophe! I find that I did not get the point well of the defferences between configurability and selectability(maybe words I created) of Kconfig items. You are right that FSL_85XX_CACHE_SRAM should only be selected by a caller but never enable it seperately. Same answer for the comments from Christophe. I will drop this patch in v3. Thanks, Wenhu
[PATCH v2, 4/5] powerpc: sysdev: fix compile error for fsl_85xx_l2ctlr
Include "linux/of_address.h" to fix the compile error for mpc85xx_l2ctlr_of_probe() when compiling fsl_85xx_cache_sram.c. CC arch/powerpc/sysdev/fsl_85xx_l2ctlr.o arch/powerpc/sysdev/fsl_85xx_l2ctlr.c: In function ‘mpc85xx_l2ctlr_of_probe’: arch/powerpc/sysdev/fsl_85xx_l2ctlr.c:90:11: error: implicit declaration of function ‘of_iomap’; did you mean ‘pci_iomap’? [-Werror=implicit-function-declaration] l2ctlr = of_iomap(dev->dev.of_node, 0); ^~~~ pci_iomap arch/powerpc/sysdev/fsl_85xx_l2ctlr.c:90:9: error: assignment makes pointer from integer without a cast [-Werror=int-conversion] l2ctlr = of_iomap(dev->dev.of_node, 0); ^ cc1: all warnings being treated as errors scripts/Makefile.build:267: recipe for target 'arch/powerpc/sysdev/fsl_85xx_l2ctlr.o' failed make[2]: *** [arch/powerpc/sysdev/fsl_85xx_l2ctlr.o] Error 1 Cc: Greg Kroah-Hartman Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org Fixes: 6db92cc9d07d ("powerpc/85xx: add cache-sram support") Signed-off-by: Wang Wenhu --- Changes since v1: * None --- arch/powerpc/sysdev/fsl_85xx_l2ctlr.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c b/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c index 2d0af0c517bb..7533572492f0 100644 --- a/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c +++ b/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include "fsl_85xx_cache_ctlr.h" -- 2.17.1
[PATCH v2,5/5] drivers: uio: new driver for fsl_85xx_cache_sram
A driver for freescale 85xx platforms to access the Cache-Sram form user level. This is extremely helpful for some user-space applications that require high performance memory accesses. Cc: Greg Kroah-Hartman Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org Signed-off-by: Wang Wenhu --- Changes since v1: * Addressed comments of Greg K-H * Moved kfree(info->name) into uio_info_free_internal() --- drivers/uio/Kconfig | 8 ++ drivers/uio/Makefile | 1 + drivers/uio/uio_fsl_85xx_cache_sram.c | 182 ++ 3 files changed, 191 insertions(+) create mode 100644 drivers/uio/uio_fsl_85xx_cache_sram.c diff --git a/drivers/uio/Kconfig b/drivers/uio/Kconfig index 202ee81cfc2b..afd38ec13de0 100644 --- a/drivers/uio/Kconfig +++ b/drivers/uio/Kconfig @@ -105,6 +105,14 @@ config UIO_NETX To compile this driver as a module, choose M here; the module will be called uio_netx. +config UIO_FSL_85XX_CACHE_SRAM + tristate "Freescale 85xx Cache-Sram driver" + depends on FSL_85XX_CACHE_SRAM + help + Generic driver for accessing the Cache-Sram form user level. This + is extremely helpful for some user-space applications that require + high performance memory accesses. + config UIO_FSL_ELBC_GPCM tristate "eLBC/GPCM driver" depends on FSL_LBC diff --git a/drivers/uio/Makefile b/drivers/uio/Makefile index c285dd2a4539..be2056cffc21 100644 --- a/drivers/uio/Makefile +++ b/drivers/uio/Makefile @@ -10,4 +10,5 @@ obj-$(CONFIG_UIO_NETX)+= uio_netx.o obj-$(CONFIG_UIO_PRUSS) += uio_pruss.o obj-$(CONFIG_UIO_MF624) += uio_mf624.o obj-$(CONFIG_UIO_FSL_ELBC_GPCM)+= uio_fsl_elbc_gpcm.o +obj-$(CONFIG_UIO_FSL_85XX_CACHE_SRAM) += uio_fsl_85xx_cache_sram.o obj-$(CONFIG_UIO_HV_GENERIC) += uio_hv_generic.o diff --git a/drivers/uio/uio_fsl_85xx_cache_sram.c b/drivers/uio/uio_fsl_85xx_cache_sram.c new file mode 100644 index ..fb6903fdaddb --- /dev/null +++ b/drivers/uio/uio_fsl_85xx_cache_sram.c @@ -0,0 +1,182 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2020 Vivo Communication Technology Co. Ltd. + * Copyright (C) 2020 Wang Wenhu + * All rights reserved. + */ + +#include +#include +#include +#include +#include +#include + +#define DRIVER_NAME"uio_fsl_85xx_cache_sram" +#define UIO_NAME "uio_cache_sram" + +static const struct of_device_id uio_mpc85xx_l2ctlr_of_match[] = { + { .compatible = "uio,fsl,p2020-l2-cache-controller", }, + { .compatible = "uio,fsl,p2010-l2-cache-controller", }, + { .compatible = "uio,fsl,p1020-l2-cache-controller", }, + { .compatible = "uio,fsl,p1011-l2-cache-controller", }, + { .compatible = "uio,fsl,p1013-l2-cache-controller", }, + { .compatible = "uio,fsl,p1022-l2-cache-controller", }, + { .compatible = "uio,fsl,mpc8548-l2-cache-controller",}, + { .compatible = "uio,fsl,mpc8544-l2-cache-controller",}, + { .compatible = "uio,fsl,mpc8572-l2-cache-controller",}, + { .compatible = "uio,fsl,mpc8536-l2-cache-controller",}, + { .compatible = "uio,fsl,p1021-l2-cache-controller", }, + { .compatible = "uio,fsl,p1012-l2-cache-controller", }, + { .compatible = "uio,fsl,p1025-l2-cache-controller", }, + { .compatible = "uio,fsl,p1016-l2-cache-controller", }, + { .compatible = "uio,fsl,p1024-l2-cache-controller", }, + { .compatible = "uio,fsl,p1015-l2-cache-controller", }, + { .compatible = "uio,fsl,p1010-l2-cache-controller", }, + { .compatible = "uio,fsl,bsc9131-l2-cache-controller",}, + {}, +}; + +static void uio_info_free_internal(struct uio_info *info) +{ + struct uio_mem *uiomem = &info->mem[0]; + + while (uiomem < &info->mem[MAX_UIO_MAPS]) { + if (uiomem->size) { + mpc85xx_cache_sram_free(uiomem->internal_addr); + kfree(uiomem->name); + } + uiomem++; + } + + kfree(info->name); +} + +static int uio_fsl_85xx_cache_sram_probe(struct platform_device *pdev) +{ + struct device_node *parent = pdev->dev.of_node; + struct device_node *node = NULL; + struct uio_info *info; + struct uio_mem *uiomem; + const char *dt_name; + u32 mem_size; + u32 align; + void *virt; + phys_addr_t phys; + int ret = -ENODEV; + + /* alloc uio_info for one
[PATCH v2, 2/5] powerpc: sysdev: fix compile error for fsl_85xx_cache_sram
Include linux/io.h into fsl_85xx_cache_sram.c to fix the implicit-declaration compile error when building Cache-Sram. arch/powerpc/sysdev/fsl_85xx_cache_sram.c: In function ‘instantiate_cache_sram’: arch/powerpc/sysdev/fsl_85xx_cache_sram.c:97:26: error: implicit declaration of function ‘ioremap_coherent’; did you mean ‘bitmap_complement’? [-Werror=implicit-function-declaration] cache_sram->base_virt = ioremap_coherent(cache_sram->base_phys, ^~~~ bitmap_complement arch/powerpc/sysdev/fsl_85xx_cache_sram.c:97:24: error: assignment makes pointer from integer without a cast [-Werror=int-conversion] cache_sram->base_virt = ioremap_coherent(cache_sram->base_phys, ^ arch/powerpc/sysdev/fsl_85xx_cache_sram.c:123:2: error: implicit declaration of function ‘iounmap’; did you mean ‘roundup’? [-Werror=implicit-function-declaration] iounmap(cache_sram->base_virt); ^~~ roundup cc1: all warnings being treated as errors Cc: Greg Kroah-Hartman Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org Fixes: 6db92cc9d07d ("powerpc/85xx: add cache-sram support") Signed-off-by: WANG Wenhu --- Changes since v1: * None --- arch/powerpc/sysdev/fsl_85xx_cache_sram.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c index f6c665dac725..be3aef4229d7 100644 --- a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c +++ b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "fsl_85xx_cache_ctlr.h" -- 2.17.1
[PATCH v2,0/5] drivers: uio: new driver uio_fsl_85xx_cache_sram
This series add a new uio driver for freescale 85xx platforms to access the Cache-Sram form user level. This is extremely helpful for the user-space applications that require high performance memory accesses. It fixes the compile errors and warning of the hardware level drivers and implements the uio driver in uio_fsl_85xx_cache_sram.c. Changes since v1: * Addressed comments of Greg K-H * Moved kfree(info->name) into uio_info_free_internal() Wang Wenhu (5): powerpc: 85xx: make FSL_85XX_CACHE_SRAM configurable powerpc: sysdev: fix compile error for fsl_85xx_cache_sram powerpc: sysdev: fix compile warning for fsl_85xx_cache_sram powerpc: sysdev: fix compile error for fsl_85xx_l2ctlr drivers: uio: new driver for fsl_85xx_cache_sram arch/powerpc/platforms/85xx/Kconfig | 2 +- arch/powerpc/platforms/Kconfig.cputype| 5 +- arch/powerpc/sysdev/fsl_85xx_cache_sram.c | 3 +- arch/powerpc/sysdev/fsl_85xx_l2ctlr.c | 1 + drivers/uio/Kconfig | 8 + drivers/uio/Makefile | 1 + drivers/uio/uio_fsl_85xx_cache_sram.c | 182 ++ 7 files changed, 198 insertions(+), 4 deletions(-) create mode 100644 drivers/uio/uio_fsl_85xx_cache_sram.c -- 2.17.1
[PATCH v2,1/5] powerpc: 85xx: make FSL_85XX_CACHE_SRAM configurable
Enable FSL_85XX_CACHE_SRAM selection. On e500 platforms, the cache could be configured and used as a piece of SRAM which is hignly friendly for some user level application performances. Cc: Greg Kroah-Hartman Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org Signed-off-by: Wang Wenhu --- Changes since v1: * None --- arch/powerpc/platforms/85xx/Kconfig| 2 +- arch/powerpc/platforms/Kconfig.cputype | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/platforms/85xx/Kconfig b/arch/powerpc/platforms/85xx/Kconfig index fa3d29dcb57e..6debb4f1b9cc 100644 --- a/arch/powerpc/platforms/85xx/Kconfig +++ b/arch/powerpc/platforms/85xx/Kconfig @@ -17,7 +17,7 @@ if FSL_SOC_BOOKE if PPC32 config FSL_85XX_CACHE_SRAM - bool + bool "Freescale 85xx Cache-Sram" select PPC_LIB_RHEAP help When selected, this option enables cache-sram support diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype index 0c3c1902135c..1921e9a573e8 100644 --- a/arch/powerpc/platforms/Kconfig.cputype +++ b/arch/powerpc/platforms/Kconfig.cputype @@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 config PPC32 - bool + bool "32-bit kernel" default y if !PPC64 select KASAN_VMALLOC if KASAN && MODULES @@ -15,6 +15,7 @@ config PPC_BOOK3S_32 bool menu "Processor support" + choice prompt "Processor Type" depends on PPC32 @@ -211,9 +212,9 @@ config PPC_BOOK3E depends on PPC_BOOK3E_64 config E500 + bool "e500 Support" select FSL_EMB_PERFMON select PPC_FSL_BOOK3E - bool config PPC_E500MC bool "e500mc Support" -- 2.17.1
[PATCH v2, 3/5] powerpc: sysdev: fix compile warning for fsl_85xx_cache_sram
Function instantiate_cache_sram should not be linked into the init section for its caller mpc85xx_l2ctlr_of_probe is none-__init. Cc: Greg Kroah-Hartman Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org Fixes: 6db92cc9d07d ("powerpc/85xx: add cache-sram support") Signed-off-by: Wang Wenhu Warning information: MODPOST vmlinux.o WARNING: modpost: vmlinux.o(.text+0x1e540): Section mismatch in reference from the function mpc85xx_l2ctlr_of_probe() to the function .init.text:instantiate_cache_sram() The function mpc85xx_l2ctlr_of_probe() references the function __init instantiate_cache_sram(). This is often because mpc85xx_l2ctlr_of_probe lacks a __init annotation or the annotation of instantiate_cache_sram is wrong. --- Changes since v1: * None --- arch/powerpc/sysdev/fsl_85xx_cache_sram.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c index be3aef4229d7..3de5ac8382c0 100644 --- a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c +++ b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c @@ -68,7 +68,7 @@ void mpc85xx_cache_sram_free(void *ptr) } EXPORT_SYMBOL(mpc85xx_cache_sram_free); -int __init instantiate_cache_sram(struct platform_device *dev, +int instantiate_cache_sram(struct platform_device *dev, struct sram_parameters sram_params) { int ret = 0; -- 2.17.1
Re: [PATCH 5/5] drivers: uio: new driver for fsl_85xx_cache_sram>On Wed, Apr 15, 2020 at 05:33:46AM -0700, Wang Wenhu wrote:
Hi, Greg k-h! Thank you for you fast reply. All the comments will be addressed with v2 soon. Detailed explanations are just below specific comment. >> A driver for freescale 85xx platforms to access the Cache-Sram form >> user level. This is extremely helpful for some user-space applications >> that require high performance memory accesses. >> >> Cc: Greg Kroah-Hartman >> Cc: Christophe Leroy >> Cc: Scott Wood >> Cc: Michael Ellerman >> Cc: linuxppc-dev@lists.ozlabs.org >> Signed-off-by: Wang Wenhu >> --- >> drivers/uio/Kconfig | 8 ++ >> drivers/uio/Makefile | 1 + >> drivers/uio/uio_fsl_85xx_cache_sram.c | 195 ++ >> 3 files changed, 204 insertions(+) >> create mode 100644 drivers/uio/uio_fsl_85xx_cache_sram.c >> >> diff --git a/drivers/uio/Kconfig b/drivers/uio/Kconfig >> index 202ee81cfc2b..afd38ec13de0 100644 >> --- a/drivers/uio/Kconfig >> +++ b/drivers/uio/Kconfig >> @@ -105,6 +105,14 @@ config UIO_NETX >>To compile this driver as a module, choose M here; the module >>will be called uio_netx. >> >> +config UIO_FSL_85XX_CACHE_SRAM >> +tristate "Freescale 85xx Cache-Sram driver" >> +depends on FSL_85XX_CACHE_SRAM >> +help >> + Generic driver for accessing the Cache-Sram form user level. This >> + is extremely helpful for some user-space applications that require >> + high performance memory accesses. >> + >> config UIO_FSL_ELBC_GPCM >> tristate "eLBC/GPCM driver" >> depends on FSL_LBC >> diff --git a/drivers/uio/Makefile b/drivers/uio/Makefile >> index c285dd2a4539..be2056cffc21 100644 >> --- a/drivers/uio/Makefile >> +++ b/drivers/uio/Makefile >> @@ -10,4 +10,5 @@ obj-$(CONFIG_UIO_NETX) += uio_netx.o >> obj-$(CONFIG_UIO_PRUSS) += uio_pruss.o >> obj-$(CONFIG_UIO_MF624) += uio_mf624.o >> obj-$(CONFIG_UIO_FSL_ELBC_GPCM) += uio_fsl_elbc_gpcm.o >> +obj-$(CONFIG_UIO_FSL_85XX_CACHE_SRAM) += uio_fsl_85xx_cache_sram.o >> obj-$(CONFIG_UIO_HV_GENERIC)+= uio_hv_generic.o >> diff --git a/drivers/uio/uio_fsl_85xx_cache_sram.c >> b/drivers/uio/uio_fsl_85xx_cache_sram.c >> new file mode 100644 >> index ..e11202dd5b93 >> --- /dev/null >> +++ b/drivers/uio/uio_fsl_85xx_cache_sram.c >> @@ -0,0 +1,195 @@ >> +// SPDX-License-Identifier: GPL-2.0 >> +/* >> + * Copyright (C) 2020 Vivo Communication Technology Co. Ltd. >> + * Copyright (C) 2020 Wang Wenhu >> + * All rights reserved. >> + * >> + * This program is free software; you can redistribute it and/or modify it >> + * under the terms of the GNU General Public License version 2 as published >> + * by the Free Software Foundation. > >Nit, you don't need this sentance anymore now that you have the SPDX >line above > Got, I will delete it with v2. >> + */ >> + >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> + >> +#define DRIVER_VERSION "0.1.0" > >Don't do DRIVER_VERSIONs, they never work once the code is in the kernel >tree. > >> +#define DRIVER_NAME "uio_fsl_85xx_cache_sram" > >KBUILD_MODNAME? Yes, and sorry for that I did not get what should have been done? > >> +#define UIO_NAME"uio_cache_sram" >> + >> +static const struct of_device_id uio_mpc85xx_l2ctlr_of_match[] = { >> +{ .compatible = "uio,fsl,p2020-l2-cache-controller", }, >> +{ .compatible = "uio,fsl,p2010-l2-cache-controller", }, >> +{ .compatible = "uio,fsl,p1020-l2-cache-controller", }, >> +{ .compatible = "uio,fsl,p1011-l2-cache-controller", }, >> +{ .compatible = "uio,fsl,p1013-l2-cache-controller", }, >> +{ .compatible = "uio,fsl,p1022-l2-cache-controller", }, >> +{ .compatible = "uio,fsl,mpc8548-l2-cache-controller",}, >> +{ .compatible = "uio,fsl,mpc8544-l2-cache-controller",}, >> +{ .compatible = "uio,fsl,mpc8572-l2-cache-controller",}, >> +{ .compatible = "uio,fsl,mpc8536-l2-cache-controller",}, >> +{ .compatible = "uio,fsl,p1021-l2-cache-controller", }, >> +{ .compatible = "uio,fsl,p1012-l2-cache-controller", }, >> +{ .compatible = "uio,fsl,p1025-
[PATCH 4/5] powerpc: sysdev: fix compile error for fsl_85xx_l2ctlr
Include "linux/of_address.h" to fix the compile error for mpc85xx_l2ctlr_of_probe() when compiling fsl_85xx_cache_sram.c. CC arch/powerpc/sysdev/fsl_85xx_l2ctlr.o arch/powerpc/sysdev/fsl_85xx_l2ctlr.c: In function ‘mpc85xx_l2ctlr_of_probe’: arch/powerpc/sysdev/fsl_85xx_l2ctlr.c:90:11: error: implicit declaration of function ‘of_iomap’; did you mean ‘pci_iomap’? [-Werror=implicit-function-declaration] l2ctlr = of_iomap(dev->dev.of_node, 0); ^~~~ pci_iomap arch/powerpc/sysdev/fsl_85xx_l2ctlr.c:90:9: error: assignment makes pointer from integer without a cast [-Werror=int-conversion] l2ctlr = of_iomap(dev->dev.of_node, 0); ^ cc1: all warnings being treated as errors scripts/Makefile.build:267: recipe for target 'arch/powerpc/sysdev/fsl_85xx_l2ctlr.o' failed make[2]: *** [arch/powerpc/sysdev/fsl_85xx_l2ctlr.o] Error 1 Cc: Greg Kroah-Hartman Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org Fixes: 6db92cc9d07d ("powerpc/85xx: add cache-sram support") Signed-off-by: Wang Wenhu --- arch/powerpc/sysdev/fsl_85xx_l2ctlr.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c b/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c index 2d0af0c517bb..7533572492f0 100644 --- a/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c +++ b/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include "fsl_85xx_cache_ctlr.h" -- 2.17.1
[PATCH 5/5] drivers: uio: new driver for fsl_85xx_cache_sram
A driver for freescale 85xx platforms to access the Cache-Sram form user level. This is extremely helpful for some user-space applications that require high performance memory accesses. Cc: Greg Kroah-Hartman Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org Signed-off-by: Wang Wenhu --- drivers/uio/Kconfig | 8 ++ drivers/uio/Makefile | 1 + drivers/uio/uio_fsl_85xx_cache_sram.c | 195 ++ 3 files changed, 204 insertions(+) create mode 100644 drivers/uio/uio_fsl_85xx_cache_sram.c diff --git a/drivers/uio/Kconfig b/drivers/uio/Kconfig index 202ee81cfc2b..afd38ec13de0 100644 --- a/drivers/uio/Kconfig +++ b/drivers/uio/Kconfig @@ -105,6 +105,14 @@ config UIO_NETX To compile this driver as a module, choose M here; the module will be called uio_netx. +config UIO_FSL_85XX_CACHE_SRAM + tristate "Freescale 85xx Cache-Sram driver" + depends on FSL_85XX_CACHE_SRAM + help + Generic driver for accessing the Cache-Sram form user level. This + is extremely helpful for some user-space applications that require + high performance memory accesses. + config UIO_FSL_ELBC_GPCM tristate "eLBC/GPCM driver" depends on FSL_LBC diff --git a/drivers/uio/Makefile b/drivers/uio/Makefile index c285dd2a4539..be2056cffc21 100644 --- a/drivers/uio/Makefile +++ b/drivers/uio/Makefile @@ -10,4 +10,5 @@ obj-$(CONFIG_UIO_NETX)+= uio_netx.o obj-$(CONFIG_UIO_PRUSS) += uio_pruss.o obj-$(CONFIG_UIO_MF624) += uio_mf624.o obj-$(CONFIG_UIO_FSL_ELBC_GPCM)+= uio_fsl_elbc_gpcm.o +obj-$(CONFIG_UIO_FSL_85XX_CACHE_SRAM) += uio_fsl_85xx_cache_sram.o obj-$(CONFIG_UIO_HV_GENERIC) += uio_hv_generic.o diff --git a/drivers/uio/uio_fsl_85xx_cache_sram.c b/drivers/uio/uio_fsl_85xx_cache_sram.c new file mode 100644 index ..e11202dd5b93 --- /dev/null +++ b/drivers/uio/uio_fsl_85xx_cache_sram.c @@ -0,0 +1,195 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2020 Vivo Communication Technology Co. Ltd. + * Copyright (C) 2020 Wang Wenhu + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include +#include + +#define DRIVER_VERSION "0.1.0" +#define DRIVER_NAME"uio_fsl_85xx_cache_sram" +#define UIO_NAME "uio_cache_sram" + +static const struct of_device_id uio_mpc85xx_l2ctlr_of_match[] = { + { .compatible = "uio,fsl,p2020-l2-cache-controller", }, + { .compatible = "uio,fsl,p2010-l2-cache-controller", }, + { .compatible = "uio,fsl,p1020-l2-cache-controller", }, + { .compatible = "uio,fsl,p1011-l2-cache-controller", }, + { .compatible = "uio,fsl,p1013-l2-cache-controller", }, + { .compatible = "uio,fsl,p1022-l2-cache-controller", }, + { .compatible = "uio,fsl,mpc8548-l2-cache-controller",}, + { .compatible = "uio,fsl,mpc8544-l2-cache-controller",}, + { .compatible = "uio,fsl,mpc8572-l2-cache-controller",}, + { .compatible = "uio,fsl,mpc8536-l2-cache-controller",}, + { .compatible = "uio,fsl,p1021-l2-cache-controller", }, + { .compatible = "uio,fsl,p1012-l2-cache-controller", }, + { .compatible = "uio,fsl,p1025-l2-cache-controller", }, + { .compatible = "uio,fsl,p1016-l2-cache-controller", }, + { .compatible = "uio,fsl,p1024-l2-cache-controller", }, + { .compatible = "uio,fsl,p1015-l2-cache-controller", }, + { .compatible = "uio,fsl,p1010-l2-cache-controller", }, + { .compatible = "uio,fsl,bsc9131-l2-cache-controller",}, + {}, +}; + +static void uio_info_free_internal(struct uio_info *info) +{ + struct uio_mem *uiomem = &info->mem[0]; + + while (uiomem < &info->mem[MAX_UIO_MAPS]) { + if (uiomem->size) { + mpc85xx_cache_sram_free(uiomem->internal_addr); + kfree(uiomem->name); + } + uiomem++; + } +} + +static int uio_fsl_85xx_cache_sram_probe(struct platform_device *pdev) +{ + struct device_node *parent = pdev->dev.of_node; + struct device_node *node = NULL; + struct uio_info *info; + struct uio_mem *uiomem; + const char *dt_name; + u32 mem_size; + u32 align; + void *virt; +
[PATCH 3/5] powerpc: sysdev: fix compile warning for fsl_85xx_cache_sram
Function instantiate_cache_sram should not be linked into the init section for its caller mpc85xx_l2ctlr_of_probe is none-__init. Cc: Greg Kroah-Hartman Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org Fixes: 6db92cc9d07d ("powerpc/85xx: add cache-sram support") Signed-off-by: Wang Wenhu Warning information: MODPOST vmlinux.o WARNING: modpost: vmlinux.o(.text+0x1e540): Section mismatch in reference from the function mpc85xx_l2ctlr_of_probe() to the function .init.text:instantiate_cache_sram() The function mpc85xx_l2ctlr_of_probe() references the function __init instantiate_cache_sram(). This is often because mpc85xx_l2ctlr_of_probe lacks a __init annotation or the annotation of instantiate_cache_sram is wrong. --- arch/powerpc/sysdev/fsl_85xx_cache_sram.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c index be3aef4229d7..3de5ac8382c0 100644 --- a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c +++ b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c @@ -68,7 +68,7 @@ void mpc85xx_cache_sram_free(void *ptr) } EXPORT_SYMBOL(mpc85xx_cache_sram_free); -int __init instantiate_cache_sram(struct platform_device *dev, +int instantiate_cache_sram(struct platform_device *dev, struct sram_parameters sram_params) { int ret = 0; -- 2.17.1
[PATCH 2/5] powerpc: sysdev: fix compile error for fsl_85xx_cache_sram
Include linux/io.h into fsl_85xx_cache_sram.c to fix the implicit-declaration compile error when building Cache-Sram. arch/powerpc/sysdev/fsl_85xx_cache_sram.c: In function ‘instantiate_cache_sram’: arch/powerpc/sysdev/fsl_85xx_cache_sram.c:97:26: error: implicit declaration of function ‘ioremap_coherent’; did you mean ‘bitmap_complement’? [-Werror=implicit-function-declaration] cache_sram->base_virt = ioremap_coherent(cache_sram->base_phys, ^~~~ bitmap_complement arch/powerpc/sysdev/fsl_85xx_cache_sram.c:97:24: error: assignment makes pointer from integer without a cast [-Werror=int-conversion] cache_sram->base_virt = ioremap_coherent(cache_sram->base_phys, ^ arch/powerpc/sysdev/fsl_85xx_cache_sram.c:123:2: error: implicit declaration of function ‘iounmap’; did you mean ‘roundup’? [-Werror=implicit-function-declaration] iounmap(cache_sram->base_virt); ^~~ roundup cc1: all warnings being treated as errors Cc: Greg Kroah-Hartman Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org Fixes: 6db92cc9d07d ("powerpc/85xx: add cache-sram support") Signed-off-by: Wang Wenhu --- arch/powerpc/sysdev/fsl_85xx_cache_sram.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c index f6c665dac725..be3aef4229d7 100644 --- a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c +++ b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "fsl_85xx_cache_ctlr.h" -- 2.17.1
[PATCH 0/5] drivers: uio: new driver uio_fsl_85xx_cache_sram
This series add a new uio driver for freescale 85xx platforms to access the Cache-Sram form user level. This is extremely helpful for the user-space applications that require high performance memory accesses. It fixes the compile errors and warning of the hardware level drivers and implements the uio driver in uio_fsl_85xx_cache_sram.c. Wang Wenhu (5): powerpc: 85xx: make FSL_85XX_CACHE_SRAM configurable powerpc: sysdev: fix compile error for fsl_85xx_cache_sram powerpc: sysdev: fix compile warning for fsl_85xx_cache_sram powerpc: sysdev: fix compile error for fsl_85xx_l2ctlr drivers: uio: new driver for fsl_85xx_cache_sram arch/powerpc/platforms/85xx/Kconfig | 2 +- arch/powerpc/platforms/Kconfig.cputype| 5 +- arch/powerpc/sysdev/fsl_85xx_cache_sram.c | 3 +- arch/powerpc/sysdev/fsl_85xx_l2ctlr.c | 1 + drivers/uio/Kconfig | 8 + drivers/uio/Makefile | 1 + drivers/uio/uio_fsl_85xx_cache_sram.c | 195 ++ 7 files changed, 211 insertions(+), 4 deletions(-) create mode 100644 drivers/uio/uio_fsl_85xx_cache_sram.c -- 2.17.1
[PATCH 1/5] powerpc: 85xx: make FSL_85XX_CACHE_SRAM configurable
Enable FSL_85XX_CACHE_SRAM selection. On e500 platforms, the cache could be configured and used as a piece of SRAM which is hignly friendly for some user level application performances. Cc: Greg Kroah-Hartman Cc: Christophe Leroy Cc: Scott Wood Cc: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org Signed-off-by: Wang Wenhu --- arch/powerpc/platforms/85xx/Kconfig| 2 +- arch/powerpc/platforms/Kconfig.cputype | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/platforms/85xx/Kconfig b/arch/powerpc/platforms/85xx/Kconfig index fa3d29dcb57e..6debb4f1b9cc 100644 --- a/arch/powerpc/platforms/85xx/Kconfig +++ b/arch/powerpc/platforms/85xx/Kconfig @@ -17,7 +17,7 @@ if FSL_SOC_BOOKE if PPC32 config FSL_85XX_CACHE_SRAM - bool + bool "Freescale 85xx Cache-Sram" select PPC_LIB_RHEAP help When selected, this option enables cache-sram support diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype index 0c3c1902135c..1921e9a573e8 100644 --- a/arch/powerpc/platforms/Kconfig.cputype +++ b/arch/powerpc/platforms/Kconfig.cputype @@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 config PPC32 - bool + bool "32-bit kernel" default y if !PPC64 select KASAN_VMALLOC if KASAN && MODULES @@ -15,6 +15,7 @@ config PPC_BOOK3S_32 bool menu "Processor support" + choice prompt "Processor Type" depends on PPC32 @@ -211,9 +212,9 @@ config PPC_BOOK3E depends on PPC_BOOK3E_64 config E500 + bool "e500 Support" select FSL_EMB_PERFMON select PPC_FSL_BOOK3E - bool config PPC_E500MC bool "e500mc Support" -- 2.17.1
[PATCH v3] powerpc/fsl-85xx: fix compile error
Include "linux/of_address.h" to fix the compile error for mpc85xx_l2ctlr_of_probe() when compiling fsl_85xx_cache_sram.c. CC arch/powerpc/sysdev/fsl_85xx_l2ctlr.o arch/powerpc/sysdev/fsl_85xx_l2ctlr.c: In function ‘mpc85xx_l2ctlr_of_probe’: arch/powerpc/sysdev/fsl_85xx_l2ctlr.c:90:11: error: implicit declaration of function ‘of_iomap’; did you mean ‘pci_iomap’? [-Werror=implicit-function-declaration] l2ctlr = of_iomap(dev->dev.of_node, 0); ^~~~ pci_iomap arch/powerpc/sysdev/fsl_85xx_l2ctlr.c:90:9: error: assignment makes pointer from integer without a cast [-Werror=int-conversion] l2ctlr = of_iomap(dev->dev.of_node, 0); ^ cc1: all warnings being treated as errors scripts/Makefile.build:267: recipe for target 'arch/powerpc/sysdev/fsl_85xx_l2ctlr.o' failed make[2]: *** [arch/powerpc/sysdev/fsl_85xx_l2ctlr.o] Error 1 Fixes: commit 6db92cc9d07d ("powerpc/85xx: add cache-sram support") Cc: stable Signed-off-by: WANG Wenhu --- Changes since v1: 1. v3: Cc stable into the sign-off area; 2. v2: modified the label: "Fixed: " -> "Fixes: "; Link: https://lore.kernel.org/linuxppc-dev/acmabgcmcmykfkbub-5a5qo0.3.1584161421763.hmail.wenhu.w...@vivo.com arch/powerpc/sysdev/fsl_85xx_l2ctlr.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c b/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c index 2d0af0c517bb..7533572492f0 100644 --- a/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c +++ b/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include "fsl_85xx_cache_ctlr.h" -- 2.17.1
[PATCH v2] powerpc/fsl-85xx: fix compile error
Include "linux/of_address.h" to fix the compile error for mpc85xx_l2ctlr_of_probe() when compiling fsl_85xx_cache_sram.c. CC arch/powerpc/sysdev/fsl_85xx_l2ctlr.o arch/powerpc/sysdev/fsl_85xx_l2ctlr.c: In function ‘mpc85xx_l2ctlr_of_probe’: arch/powerpc/sysdev/fsl_85xx_l2ctlr.c:90:11: error: implicit declaration of function ‘of_iomap’; did you mean ‘pci_iomap’? [-Werror=implicit-function-declaration] l2ctlr = of_iomap(dev->dev.of_node, 0); ^~~~ pci_iomap arch/powerpc/sysdev/fsl_85xx_l2ctlr.c:90:9: error: assignment makes pointer from integer without a cast [-Werror=int-conversion] l2ctlr = of_iomap(dev->dev.of_node, 0); ^ cc1: all warnings being treated as errors scripts/Makefile.build:267: recipe for target 'arch/powerpc/sysdev/fsl_85xx_l2ctlr.o' failed make[2]: *** [arch/powerpc/sysdev/fsl_85xx_l2ctlr.o] Error 1 Fixes: commit 6db92cc9d07d ("powerpc/85xx: add cache-sram support") Signed-off-by: WANG Wenhu --- arch/powerpc/sysdev/fsl_85xx_l2ctlr.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c b/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c index 2d0af0c517bb..7533572492f0 100644 --- a/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c +++ b/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include "fsl_85xx_cache_ctlr.h" -- 2.17.1
[PATCH] powerpc/fsl-85xx: fix compile error
Include "linux/of_address.h" to fix the compile error while compiling file fsl_85xx_cache_sram.c. CC arch/powerpc/sysdev/fsl_85xx_l2ctlr.o arch/powerpc/sysdev/fsl_85xx_l2ctlr.c: In function ‘mpc85xx_l2ctlr_of_probe’: arch/powerpc/sysdev/fsl_85xx_l2ctlr.c:90:11: error: implicit declaration of function ‘of_iomap’; did you mean ‘pci_iomap’? [-Werror=implicit-function-declaration] l2ctlr = of_iomap(dev->dev.of_node, 0); ^~~~ pci_iomap arch/powerpc/sysdev/fsl_85xx_l2ctlr.c:90:9: error: assignment makes pointer from integer without a cast [-Werror=int-conversion] l2ctlr = of_iomap(dev->dev.of_node, 0); ^ cc1: all warnings being treated as errors scripts/Makefile.build:267: recipe for target 'arch/powerpc/sysdev/fsl_85xx_l2ctlr.o' failed make[2]: *** [arch/powerpc/sysdev/fsl_85xx_l2ctlr.o] Error 1 Fixed: commit 6db92cc9d07d ("powerpc/85xx: add cache-sram support") Signed-off-by: WANG Wenhu --- arch/powerpc/sysdev/fsl_85xx_l2ctlr.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c b/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c index 2d0af0c517bb..7533572492f0 100644 --- a/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c +++ b/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include "fsl_85xx_cache_ctlr.h" -- 2.17.1
[PATCH] powerpc/sysdev: fix compile errors
Include linux/io.h into fsl_85xx_cache_sram.c to fix the implicit-declaration compile errors when building Cache-Sram. arch/powerpc/sysdev/fsl_85xx_cache_sram.c: In function ‘instantiate_cache_sram’: arch/powerpc/sysdev/fsl_85xx_cache_sram.c:97:26: error: implicit declaration of function ‘ioremap_coherent’; did you mean ‘bitmap_complement’? [-Werror=implicit-function-declaration] cache_sram->base_virt = ioremap_coherent(cache_sram->base_phys, ^~~~ bitmap_complement arch/powerpc/sysdev/fsl_85xx_cache_sram.c:97:24: error: assignment makes pointer from integer without a cast [-Werror=int-conversion] cache_sram->base_virt = ioremap_coherent(cache_sram->base_phys, ^ arch/powerpc/sysdev/fsl_85xx_cache_sram.c:123:2: error: implicit declaration of function ‘iounmap’; did you mean ‘roundup’? [-Werror=implicit-function-declaration] iounmap(cache_sram->base_virt); ^~~ roundup cc1: all warnings being treated as errors Fixed: commit 6db92cc9d07d ("powerpc/85xx: add cache-sram support") Signed-off-by: WANG Wenhu --- arch/powerpc/sysdev/fsl_85xx_cache_sram.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c index f6c665dac725..be3aef4229d7 100644 --- a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c +++ b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "fsl_85xx_cache_ctlr.h" -- 2.17.1