Re: [PATCH v2 1/2] PCI: Make pci_msi_setup_pci_dev() non-static for use by arch code
On 08/24/2015 04:37 AM, Michael Ellerman wrote: more: I was testing driver issues on kernel 2.6.32 (RHEL 6.6), and when I tried the mainline kernel, the driver wasn't able to enable MSI-X capabilities. Interestingly, on kernel 4.1 this behavior doesn't happen and the driver can use MSI-X interrupts. So, I figured that something was wrong and found the problem described on the patches. I tried the proposed solution (calling manually the function that is not reachable anymore) and it works. Regarding the bnx2x driver, below are two dmesg outputs: 1) With kernel 4.2-rc7 bnx2x :01:00.0: no msix capability found OK. This is because the initialisation of dev-msix_cap was lost due to commit 1851617cd2da. 2) With kernel 4.1 bnx2x :01:00.0: msix capability found bnx2x :01:00.0 eth2: using MSI-X IRQs: sp 24 fp[0] 26 ... fp[7] 33 OK. And I assume with these patches you see the above output again. Exactly. With the proposed patches applied, dev-msix_cap is initialized normally, so the driver is able to do its job as usual. Or anywhere after the first '---', which means the version commentary is discarded in the final commit. I used scissors, but there's no problem in stop using it in this list. Thanks, but my scripts don't grok scissors. So I prefer the commentary after the '---'. Thanks for the info. Cheers ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 2/2] powerpc/PCI: Disable MSI/MSI-X interrupts at PCI probe time in OF case
From: Guilherme G. Piccoli gpicc...@linux.vnet.ibm.com Since commit 1851617cd2da (PCI/MSI: Disable MSI at enumeration even if kernel doesn't support MSI), the setup of dev-msi_cap/msix_cap and the disable of MSI/MSI-X interrupts isn't being done at PCI probe time, as the logic responsible for this was moved in the aforementioned commit from pci_device_add() to pci_setup_device(). The latter function is not reachable on PowerPC pseries platform during Open Firmware PCI probing time. This exhibits as drivers not being able to enable MSI, eg: bnx2x :01:00.0: no msix capability found This patch calls pci_msi_setup_pci_dev() explicitly to disable MSI/MSI-X during PCI probe time on pSeries platform. Fixes: 1851617cd2da (PCI/MSI: Disable MSI at enumeration even if kernel doesn't support MSI) [mpe: Flesh out change log and clarify comment] Signed-off-by: Guilherme G. Piccoli gpicc...@linux.vnet.ibm.com Signed-off-by: Michael Ellerman m...@ellerman.id.au --- arch/powerpc/kernel/pci_of_scan.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/powerpc/kernel/pci_of_scan.c b/arch/powerpc/kernel/pci_of_scan.c index 42e02a2d570b..efc3fa54c90b 100644 --- a/arch/powerpc/kernel/pci_of_scan.c +++ b/arch/powerpc/kernel/pci_of_scan.c @@ -191,6 +191,9 @@ struct pci_dev *of_create_pci_dev(struct device_node *node, pci_device_add(dev, bus); + /* Setup MSI caps disable MSI/MSI-X interrupts */ + pci_msi_setup_pci_dev(dev); + return dev; } EXPORT_SYMBOL(of_create_pci_dev); -- 2.1.4 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 1/2] PCI: Make pci_msi_setup_pci_dev() non-static for use by arch code
From: Guilherme G. Piccoli gpicc...@linux.vnet.ibm.com Commit 1851617cd2da (PCI/MSI: Disable MSI at enumeration even if kernel doesn't support MSI) changed the location of the code that initialises dev-msi_cap/msix_cap and then disables MSI/MSI-X interrupts at PCI probe time in devices that have this flag set. It moved the code from pci_msi_init_pci_dev() to a new function named pci_msi_setup_pci_dev(), called by pci_setup_device(). The pseries PCI probing code does not call pci_setup_device(), so since the aforementioned commit the function pci_msi_setup_pci_dev() is not called and MSI/MSI-X interrupts are left enabled. Additionally because dev-msi_cap/msix_cap are not initialised no driver can ever enable MSI/MSI-X. To fix this, the pseries PCI probe should manually call pci_msi_setup_pci_dev(), so this patch makes it non-static. Fixes: 1851617cd2da (PCI/MSI: Disable MSI at enumeration even if kernel doesn't support MSI) [mpe: Update change log to mention dev-msi_cap/msix_cap] Signed-off-by: Guilherme G. Piccoli gpicc...@linux.vnet.ibm.com Signed-off-by: Michael Ellerman m...@ellerman.id.au --- drivers/pci/probe.c | 2 +- include/linux/pci.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) Bjorn, I plan to put this series in my fixes branch and ask Linus to pull it before the 4.2 release. Unless you want to take it. diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index b978bbfe044c..f6ae0d0052eb 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -1108,7 +1108,7 @@ int pci_cfg_space_size(struct pci_dev *dev) #define LEGACY_IO_RESOURCE (IORESOURCE_IO | IORESOURCE_PCI_FIXED) -static void pci_msi_setup_pci_dev(struct pci_dev *dev) +void pci_msi_setup_pci_dev(struct pci_dev *dev) { /* * Disable the MSI hardware to avoid screaming interrupts diff --git a/include/linux/pci.h b/include/linux/pci.h index 8a0321a8fb59..860c751810fc 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1202,6 +1202,7 @@ struct msix_entry { u16 entry; /* driver uses to specify entry, OS writes */ }; +void pci_msi_setup_pci_dev(struct pci_dev *dev); #ifdef CONFIG_PCI_MSI int pci_msi_vec_count(struct pci_dev *dev); -- 2.1.4 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH] powerpc/fsl_pci: Check for get_user/probe_kernel_address failure
Signed-off-by: Scott Wood scottw...@freescale.com Reported-by: Andrew Morton a...@linux-foundation.org Cc: Andrew Morton a...@linux-foundation.org Cc: Benjamin Herrenschmidt b...@kernel.crashing.org Cc: Hongtao Jia hongtao@freescale.com --- arch/powerpc/sysdev/fsl_pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/sysdev/fsl_pci.c b/arch/powerpc/sysdev/fsl_pci.c index ebc1f412..5dab1fd 100644 --- a/arch/powerpc/sysdev/fsl_pci.c +++ b/arch/powerpc/sysdev/fsl_pci.c @@ -1002,7 +1002,7 @@ int fsl_pci_mcheck_exception(struct pt_regs *regs) ret = probe_kernel_address(regs-nip, inst); } - if (mcheck_handle_load(regs, inst)) { + if (ret mcheck_handle_load(regs, inst)) { regs-nip += 4; return 1; } -- 2.1.4 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v6 3/3] qe_common: add qe_muram_ functions to manage muram
On Mon, 2015-08-24 at 17:31 +0800, Zhao Qiang wrote: muram is used for qe, add qe_muram_ functions to manage muram. Signed-off-by: Zhao Qiang qiang.z...@freescale.com --- Changes for v2: - no changes Changes for v3: - no changes Changes for v4: - no changes Changes for v5: - no changes Changes for v5: - using genalloc instead rheap to manage QE MURAM - remove qe_reset from platform file, using - subsys_initcall to call qe_init function. This patch should come before the one that moves the code. diff --git a/drivers/soc/fsl/qe/qe_common.c b/drivers/soc/fsl/qe/qe_common.c new file mode 100644 index 000..7f1762c --- /dev/null +++ b/drivers/soc/fsl/qe/qe_common.c @@ -0,0 +1,193 @@ +/* + * common qe code + * + * author: scott wood scottw...@freescale.com + * + * copyright 2007-2008,2010 freescale Semiconductor, Inc. + * + * some parts derived from commproc.c/qe2_common.c, which is: + * copyright (c) 1997 dan error_act (dma...@jlc.net) + * copyright (c) 1999-2001 dan Malek d...@embeddedalley.com + * copyright (c) 2000 montavista Software, Inc (sou...@mvista.com) + * 2006 (c) montavista software, Inc. + * vitaly bordug vbor...@ru.mvista.com Why did you lowercase everyone's names? Why is this copying code rather than moving it? diff --git a/include/linux/genalloc.h b/include/linux/genalloc.h index 55da07e..aaf3dc2 100644 --- a/include/linux/genalloc.h +++ b/include/linux/genalloc.h @@ -30,6 +30,7 @@ #ifndef __GENALLOC_H__ #define __GENALLOC_H__ +#include linux/types.h #include linux/spinlock_types.h struct device; This does not belong in this patch. @@ -187,12 +190,41 @@ static inline int qe_alive_during_sleep(void) } /* we actually use cpm_muram implementation, define this for convenience */ -#define qe_muram_init cpm_muram_init -#define qe_muram_alloc cpm_muram_alloc -#define qe_muram_alloc_fixed cpm_muram_alloc_fixed -#define qe_muram_free cpm_muram_free -#define qe_muram_addr cpm_muram_addr -#define qe_muram_offset cpm_muram_offset +int qe_muram_init(void); + +#if defined(CONFIG_QUICC_ENGINE) +unsigned long qe_muram_alloc(unsigned long size, unsigned long align); +int qe_muram_free(unsigned long offset); +void __iomem *qe_muram_addr(unsigned long offset); +unsigned long qe_muram_offset(void __iomem *addr); +dma_addr_t qe_muram_dma(void __iomem *addr); +#else +static inline unsigned long qe_muram_alloc(unsigned long size, + unsigned long align) +{ + return -ENOSYS; +} What code calls these functions without CONFIG_QUICC_ENGINE? Are you converting qe without cpm? Why? -Scott ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v2] powerpc/fsl_pci: Check for get_user/probe_kernel_address failure
Signed-off-by: Scott Wood scottw...@freescale.com Reported-by: Andrew Morton a...@linux-foundation.org Cc: Andrew Morton a...@linux-foundation.org Cc: Benjamin Herrenschmidt b...@kernel.crashing.org Cc: Hongtao Jia hongtao@freescale.com --- v2: s/ret/!ret/ arch/powerpc/sysdev/fsl_pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/sysdev/fsl_pci.c b/arch/powerpc/sysdev/fsl_pci.c index ebc1f412..c42609d 100644 --- a/arch/powerpc/sysdev/fsl_pci.c +++ b/arch/powerpc/sysdev/fsl_pci.c @@ -1002,7 +1002,7 @@ int fsl_pci_mcheck_exception(struct pt_regs *regs) ret = probe_kernel_address(regs-nip, inst); } - if (mcheck_handle_load(regs, inst)) { + if (!ret mcheck_handle_load(regs, inst)) { regs-nip += 4; return 1; } -- 2.1.4 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 2/5] powerpc/fsl: Move fsl_guts.h out of arch/powerpc
Freescale's Layerscape ARM chips use the same structure. Signed-off-by: Scott Wood scottw...@freescale.com Cc: Madalin-Cristian Bucur madalin.bu...@freescale.com --- v3: Add linux/types.h to linux/fsl/guts.h arch/powerpc/include/asm/fsl_guts.h| 192 - arch/powerpc/platforms/85xx/mpc85xx_mds.c | 2 +- arch/powerpc/platforms/85xx/mpc85xx_rdb.c | 2 +- arch/powerpc/platforms/85xx/p1022_ds.c | 2 +- arch/powerpc/platforms/85xx/p1022_rdk.c| 2 +- arch/powerpc/platforms/85xx/smp.c | 2 +- arch/powerpc/platforms/85xx/twr_p102x.c| 2 +- arch/powerpc/platforms/86xx/mpc8610_hpcd.c | 2 +- drivers/iommu/fsl_pamu.c | 2 +- include/linux/fsl/guts.h | 192 + sound/soc/fsl/mpc8610_hpcd.c | 2 +- sound/soc/fsl/p1022_ds.c | 2 +- sound/soc/fsl/p1022_rdk.c | 2 +- 13 files changed, 203 insertions(+), 203 deletions(-) delete mode 100644 arch/powerpc/include/asm/fsl_guts.h create mode 100644 include/linux/fsl/guts.h diff --git a/arch/powerpc/include/asm/fsl_guts.h b/arch/powerpc/include/asm/fsl_guts.h deleted file mode 100644 index 43b6bb1..000 --- a/arch/powerpc/include/asm/fsl_guts.h +++ /dev/null @@ -1,192 +0,0 @@ -/** - * Freecale 85xx and 86xx Global Utilties register set - * - * Authors: Jeff Brown - * Timur Tabi ti...@freescale.com - * - * Copyright 2004,2007,2012 Freescale Semiconductor, Inc - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - */ - -#ifndef __ASM_POWERPC_FSL_GUTS_H__ -#define __ASM_POWERPC_FSL_GUTS_H__ -#ifdef __KERNEL__ - -/** - * Global Utility Registers. - * - * Not all registers defined in this structure are available on all chips, so - * you are expected to know whether a given register actually exists on your - * chip before you access it. - * - * Also, some registers are similar on different chips but have slightly - * different names. In these cases, one name is chosen to avoid extraneous - * #ifdefs. - */ -struct ccsr_guts { - __be32 porpllsr; /* 0x. - POR PLL Ratio Status Register */ - __be32 porbmsr;/* 0x.0004 - POR Boot Mode Status Register */ - __be32 porimpscr; /* 0x.0008 - POR I/O Impedance Status and Control Register */ - __be32 pordevsr; /* 0x.000c - POR I/O Device Status Register */ - __be32 pordbgmsr; /* 0x.0010 - POR Debug Mode Status Register */ - __be32 pordevsr2; /* 0x.0014 - POR device status register 2 */ - u8 res018[0x20 - 0x18]; - __be32 porcir; /* 0x.0020 - POR Configuration Information Register */ - u8 res024[0x30 - 0x24]; - __be32 gpiocr; /* 0x.0030 - GPIO Control Register */ - u8 res034[0x40 - 0x34]; - __be32 gpoutdr;/* 0x.0040 - General-Purpose Output Data Register */ - u8 res044[0x50 - 0x44]; - __be32 gpindr; /* 0x.0050 - General-Purpose Input Data Register */ - u8 res054[0x60 - 0x54]; - __be32 pmuxcr; /* 0x.0060 - Alternate Function Signal Multiplex Control */ -__be32 pmuxcr2; /* 0x.0064 - Alternate function signal multiplex control 2 */ -__be32 dmuxcr;/* 0x.0068 - DMA Mux Control Register */ -u8 res06c[0x70 - 0x6c]; - __be32 devdisr;/* 0x.0070 - Device Disable Control */ -#define CCSR_GUTS_DEVDISR_TB1 0x1000 -#define CCSR_GUTS_DEVDISR_TB0 0x4000 - __be32 devdisr2; /* 0x.0074 - Device Disable Control 2 */ - u8 res078[0x7c - 0x78]; - __be32 pmjcr; /* 0x.007c - 4 Power Management Jog Control Register */ - __be32 powmgtcsr; /* 0x.0080 - Power Management Status and Control Register */ - __be32 pmrccr; /* 0x.0084 - Power Management Reset Counter Configuration Register */ - __be32 pmpdccr;/* 0x.0088 - Power Management Power Down Counter Configuration Register */ - __be32 pmcdr; /* 0x.008c - 4Power management clock disable register */ - __be32 mcpsumr;/* 0x.0090 - Machine Check Summary Register */ - __be32 rstrscr;/* 0x.0094 - Reset Request Status and Control Register */ - __be32 ectrstcr; /* 0x.0098 - Exception reset control register */ - __be32 autorstsr; /* 0x.009c - Automatic reset status register */ - __be32 pvr;/* 0x.00a0 - Processor Version Register */ - __be32 svr;/* 0x.00a4 - System Version Register */ - u8 res0a8[0xb0 - 0xa8]; - __be32 rstcr; /* 0x.00b0 - Reset Control Register */ - u8 res0b4[0xc0 - 0xb4]; - __be32
Re: [PATCH v2 1/2] PCI: Make pci_msi_setup_pci_dev() non-static for use by arch code
On Thu, 2015-08-20 at 16:10 -0300, Guilherme G. Piccoli wrote: On 08/19/2015 10:02 PM, Michael Ellerman wrote: In future you should send a reply like the above to my mail, and then separately send the new patch series. My preference is that the new series is not a reply to anything, though some other maintainers may disagree on that point. OK, sure. I can send new patch series as new messages instead of replies to the same thread. Thanks. The other question, which I neglected to ask yesterday, is what is the symptom of the bug? ie. does the system fail to boot or otherwise crash etc.? This is briefly explained on cover-letter, but I can elaborate a bit Sure, but the cover-letter is not committed, so the commit change logs need to be self describing. more: I was testing driver issues on kernel 2.6.32 (RHEL 6.6), and when I tried the mainline kernel, the driver wasn't able to enable MSI-X capabilities. Interestingly, on kernel 4.1 this behavior doesn't happen and the driver can use MSI-X interrupts. So, I figured that something was wrong and found the problem described on the patches. I tried the proposed solution (calling manually the function that is not reachable anymore) and it works. Regarding the bnx2x driver, below are two dmesg outputs: 1) With kernel 4.2-rc7 bnx2x :01:00.0: no msix capability found OK. This is because the initialisation of dev-msix_cap was lost due to commit 1851617cd2da. 2) With kernel 4.1 bnx2x :01:00.0: msix capability found bnx2x :01:00.0 eth2: using MSI-X IRQs: sp 24 fp[0] 26 ... fp[7] 33 OK. And I assume with these patches you see the above output again. This is changes *in* v2, or since v1. My bad, sorry. Or anywhere after the first '---', which means the version commentary is discarded in the final commit. I used scissors, but there's no problem in stop using it in this list. Thanks, but my scripts don't grok scissors. So I prefer the commentary after the '---'. cheers ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: Build regressions/improvements in v4.2-rc8
On Mon, Aug 24, 2015 at 10:34 AM, Geert Uytterhoeven ge...@linux-m68k.org wrote: JFYI, when comparing v4.2-rc8[1] to v4.2-rc7[3], the summaries are: - build errors: +4/-7 4 regressions: + /home/kisskb/slave/src/include/linux/kvm_host.h: error: array subscript is above array bounds [-Werror=array-bounds]: = 430:19 (arch/powerpc/kvm/book3s_64_mmu.c: In function 'kvmppc_mmu _book3s_64_tlbie':) powerpc-randconfig (seen before in a v3.15-rc1 build?) + error: initramfs.c: undefined reference to `__stack_chk_guard': = .init.text+0x1cb0) (init/built-in.o: In function `parse_header':) x86_64-randconfig + error: pci.c: undefined reference to `pci_ioremap_io': = .init.text+0x3c4) (arch/arm/mach-versatile/built-in.o: In function `pci_versatile_setup') arm-randconfig [1] http://kisskb.ellerman.id.au/kisskb/head/9289/ (253 out of 254 configs) [3] http://kisskb.ellerman.id.au/kisskb/head/9260/ (253 out of 254 configs) Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say programmer or something like that. -- Linus Torvalds ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v6 3/3] qe_common: add qe_muram_ functions to manage muram
muram is used for qe, add qe_muram_ functions to manage muram. Signed-off-by: Zhao Qiang qiang.z...@freescale.com --- Changes for v2: - no changes Changes for v3: - no changes Changes for v4: - no changes Changes for v5: - no changes Changes for v5: - using genalloc instead rheap to manage QE MURAM - remove qe_reset from platform file, using - subsys_initcall to call qe_init function. arch/powerpc/platforms/83xx/km83xx.c | 2 - arch/powerpc/platforms/83xx/mpc832x_mds.c | 2 - arch/powerpc/platforms/83xx/mpc832x_rdb.c | 2 - arch/powerpc/platforms/83xx/mpc836x_mds.c | 2 - arch/powerpc/platforms/83xx/mpc836x_rdk.c | 3 - arch/powerpc/platforms/85xx/common.c | 1 - drivers/soc/fsl/qe/Kconfig| 1 + drivers/soc/fsl/qe/Makefile | 3 +- drivers/soc/fsl/qe/qe.c | 15 +++ drivers/soc/fsl/qe/qe_common.c| 193 ++ include/linux/genalloc.h | 1 + include/soc/fsl/qe/qe.h | 67 +-- 12 files changed, 271 insertions(+), 21 deletions(-) create mode 100644 drivers/soc/fsl/qe/qe_common.c diff --git a/arch/powerpc/platforms/83xx/km83xx.c b/arch/powerpc/platforms/83xx/km83xx.c index 996a109..7ecd758 100644 --- a/arch/powerpc/platforms/83xx/km83xx.c +++ b/arch/powerpc/platforms/83xx/km83xx.c @@ -136,8 +136,6 @@ static void __init mpc83xx_km_setup_arch(void) mpc83xx_setup_pci(); #ifdef CONFIG_QUICC_ENGINE - qe_reset(); - np = of_find_node_by_name(NULL, par_io); if (np != NULL) { par_io_init(np); diff --git a/arch/powerpc/platforms/83xx/mpc832x_mds.c b/arch/powerpc/platforms/83xx/mpc832x_mds.c index 1efb6b4..20dce79 100644 --- a/arch/powerpc/platforms/83xx/mpc832x_mds.c +++ b/arch/powerpc/platforms/83xx/mpc832x_mds.c @@ -74,8 +74,6 @@ static void __init mpc832x_sys_setup_arch(void) mpc83xx_setup_pci(); #ifdef CONFIG_QUICC_ENGINE - qe_reset(); - if ((np = of_find_node_by_name(NULL, par_io)) != NULL) { par_io_init(np); of_node_put(np); diff --git a/arch/powerpc/platforms/83xx/mpc832x_rdb.c b/arch/powerpc/platforms/83xx/mpc832x_rdb.c index 67b27b4..2e6a6a4 100644 --- a/arch/powerpc/platforms/83xx/mpc832x_rdb.c +++ b/arch/powerpc/platforms/83xx/mpc832x_rdb.c @@ -203,8 +203,6 @@ static void __init mpc832x_rdb_setup_arch(void) mpc83xx_setup_pci(); #ifdef CONFIG_QUICC_ENGINE - qe_reset(); - if ((np = of_find_node_by_name(NULL, par_io)) != NULL) { par_io_init(np); of_node_put(np); diff --git a/arch/powerpc/platforms/83xx/mpc836x_mds.c b/arch/powerpc/platforms/83xx/mpc836x_mds.c index a01d363..b1b8ab8 100644 --- a/arch/powerpc/platforms/83xx/mpc836x_mds.c +++ b/arch/powerpc/platforms/83xx/mpc836x_mds.c @@ -82,8 +82,6 @@ static void __init mpc836x_mds_setup_arch(void) mpc83xx_setup_pci(); #ifdef CONFIG_QUICC_ENGINE - qe_reset(); - if ((np = of_find_node_by_name(NULL, par_io)) != NULL) { par_io_init(np); of_node_put(np); diff --git a/arch/powerpc/platforms/83xx/mpc836x_rdk.c b/arch/powerpc/platforms/83xx/mpc836x_rdk.c index 64c5d17..9a5a00d 100644 --- a/arch/powerpc/platforms/83xx/mpc836x_rdk.c +++ b/arch/powerpc/platforms/83xx/mpc836x_rdk.c @@ -35,9 +35,6 @@ static void __init mpc836x_rdk_setup_arch(void) ppc_md.progress(mpc836x_rdk_setup_arch(), 0); mpc83xx_setup_pci(); -#ifdef CONFIG_QUICC_ENGINE - qe_reset(); -#endif } /* diff --git a/arch/powerpc/platforms/85xx/common.c b/arch/powerpc/platforms/85xx/common.c index a79d34e..d81ea0c 100644 --- a/arch/powerpc/platforms/85xx/common.c +++ b/arch/powerpc/platforms/85xx/common.c @@ -105,7 +105,6 @@ void __init mpc85xx_qe_init(void) return; } - qe_reset(); of_node_put(np); } diff --git a/drivers/soc/fsl/qe/Kconfig b/drivers/soc/fsl/qe/Kconfig index ee692b0..6e82c89 100644 --- a/drivers/soc/fsl/qe/Kconfig +++ b/drivers/soc/fsl/qe/Kconfig @@ -5,6 +5,7 @@ config QUICC_ENGINE bool Freescale QUICC Engine (QE) Support depends on FSL_SOC PPC32 select PPC_LIB_RHEAP + select GENERIC_ALLOCATOR select CRC32 help The QUICC Engine (QE) is a new generation of communications diff --git a/drivers/soc/fsl/qe/Makefile b/drivers/soc/fsl/qe/Makefile index 703793f..49acb89 100644 --- a/drivers/soc/fsl/qe/Makefile +++ b/drivers/soc/fsl/qe/Makefile @@ -1,8 +1,7 @@ # # Makefile for the linux ppc-specific parts of QE # -obj-$(CONFIG_QUICC_ENGINE) += qe.o - +obj-$(CONFIG_QUICC_ENGINE) += qe.o qe_common.o obj-$(CONFIG_UCC) += ucc.o obj-$(CONFIG_UCC_SLOW) += ucc_slow.o obj-$(CONFIG_UCC_FAST) += ucc_fast.o diff --git a/drivers/soc/fsl/qe/qe.c b/drivers/soc/fsl/qe/qe.c index 4d17b2d..d8fd4cd 100644 ---
[PATCH v6 2/3] QE: Move QE from arch/powerpc to drivers/soc
ls1 has qe and ls1 has arm cpu. move qe from arch/powerpc to drivers/soc/fsl to adapt to powerpc and arm Signed-off-by: Zhao Qiang qiang.z...@freescale.com --- Changes for v2: - move code to driver/soc Changes for v3: - change drivers/soc/qe to drivers/soc/fsl-qe Changes for v4: - move drivers/soc/fsl-qe to drivers/soc/fsl/qe - move head files for qe from include/linux/fsl to include/soc/fsl - move qe_ic.c to drivers/irqchip/ Changes for v5: - update MAINTAINERS Changes for v6: - rebase MAINTAINERS| 5 ++-- arch/powerpc/platforms/83xx/km83xx.c | 4 +-- arch/powerpc/platforms/83xx/misc.c | 2 +- arch/powerpc/platforms/83xx/mpc832x_mds.c | 4 +-- arch/powerpc/platforms/83xx/mpc832x_rdb.c | 4 +-- arch/powerpc/platforms/83xx/mpc836x_mds.c | 4 +-- arch/powerpc/platforms/83xx/mpc836x_rdk.c | 4 +-- arch/powerpc/platforms/85xx/common.c | 2 +- arch/powerpc/platforms/85xx/corenet_generic.c | 2 +- arch/powerpc/platforms/85xx/mpc85xx_mds.c | 4 +-- arch/powerpc/platforms/85xx/mpc85xx_rdb.c | 4 +-- arch/powerpc/platforms/85xx/twr_p102x.c| 4 +-- arch/powerpc/platforms/Kconfig | 19 - arch/powerpc/sysdev/qe_lib/Kconfig | 25 + arch/powerpc/sysdev/qe_lib/Makefile| 6 + arch/powerpc/sysdev/qe_lib/gpio.c | 2 +- arch/powerpc/sysdev/qe_lib/qe_io.c | 2 +- arch/powerpc/sysdev/qe_lib/usb.c | 4 +-- drivers/irqchip/Makefile | 1 + .../sysdev/qe_lib = drivers/irqchip}/qe_ic.c | 4 +-- .../sysdev/qe_lib = drivers/irqchip}/qe_ic.h | 2 +- drivers/net/ethernet/freescale/fsl_pq_mdio.c | 2 +- drivers/net/ethernet/freescale/ucc_geth.c | 8 +++--- drivers/net/ethernet/freescale/ucc_geth.h | 8 +++--- drivers/soc/Kconfig| 1 + drivers/soc/Makefile | 1 + drivers/soc/fsl/Makefile | 6 + drivers/soc/fsl/qe/Kconfig | 31 ++ drivers/soc/fsl/qe/Makefile| 8 ++ .../sysdev/qe_lib = drivers/soc/fsl/qe}/qe.c | 4 +-- .../sysdev/qe_lib = drivers/soc/fsl/qe}/ucc.c | 6 ++--- .../qe_lib = drivers/soc/fsl/qe}/ucc_fast.c | 8 +++--- .../qe_lib = drivers/soc/fsl/qe}/ucc_slow.c | 8 +++--- drivers/spi/spi-fsl-cpm.c | 2 +- drivers/tty/serial/ucc_uart.c | 2 +- drivers/usb/gadget/udc/fsl_qe_udc.c| 2 +- drivers/usb/host/fhci-hcd.c| 2 +- drivers/usb/host/fhci-hub.c| 2 +- drivers/usb/host/fhci-sched.c | 2 +- drivers/usb/host/fhci.h| 4 +-- .../include/asm = include/linux/fsl/qe}/qe_ic.h | 0 .../include/asm = include/soc/fsl/qe}/immap_qe.h | 0 .../include/asm = include/soc/fsl/qe}/qe.h| 2 +- .../include/asm = include/soc/fsl/qe}/ucc.h | 4 +-- .../include/asm = include/soc/fsl/qe}/ucc_fast.h | 6 ++--- .../include/asm = include/soc/fsl/qe}/ucc_slow.h | 6 ++--- 46 files changed, 124 insertions(+), 109 deletions(-) rename {arch/powerpc/sysdev/qe_lib = drivers/irqchip}/qe_ic.c (99%) rename {arch/powerpc/sysdev/qe_lib = drivers/irqchip}/qe_ic.h (98%) create mode 100644 drivers/soc/fsl/Makefile create mode 100644 drivers/soc/fsl/qe/Kconfig create mode 100644 drivers/soc/fsl/qe/Makefile rename {arch/powerpc/sysdev/qe_lib = drivers/soc/fsl/qe}/qe.c (99%) rename {arch/powerpc/sysdev/qe_lib = drivers/soc/fsl/qe}/ucc.c (98%) rename {arch/powerpc/sysdev/qe_lib = drivers/soc/fsl/qe}/ucc_fast.c (98%) rename {arch/powerpc/sysdev/qe_lib = drivers/soc/fsl/qe}/ucc_slow.c (98%) rename {arch/powerpc/include/asm = include/linux/fsl/qe}/qe_ic.h (100%) rename {arch/powerpc/include/asm = include/soc/fsl/qe}/immap_qe.h (100%) rename {arch/powerpc/include/asm = include/soc/fsl/qe}/qe.h (99%) rename {arch/powerpc/include/asm = include/soc/fsl/qe}/ucc.h (96%) rename {arch/powerpc/include/asm = include/soc/fsl/qe}/ucc_fast.h (98%) rename {arch/powerpc/include/asm = include/soc/fsl/qe}/ucc_slow.h (99%) diff --git a/MAINTAINERS b/MAINTAINERS index 562ae4e..c688e61 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -4155,8 +4155,9 @@ F:include/linux/fs_enet_pd.h FREESCALE QUICC ENGINE LIBRARY L: linuxppc-dev@lists.ozlabs.org S: Orphan -F: arch/powerpc/sysdev/qe_lib/ -F: arch/powerpc/include/asm/*qe.h +F: drivers/soc/fsl/qe/ +F: include/soc/fsl/*qe*.h +F: include/soc/fsl/*ucc*.h FREESCALE USB PERIPHERAL DRIVERS M: Li Yang le...@freescale.com diff --git a/arch/powerpc/platforms/83xx/km83xx.c
[PATCH v2 0/6] powerpc: use jump label for {cpu,mmu}_has_feature()
Hi, v2: Drop the following two patches as suggested by Ingo and Peter: jump_label: no need to acquire the jump_label_mutex in jump_lable_init() jump_label: introduce DEFINE_STATIC_KEY_{TRUE,FALSE}_ARRAY macros v1: I have tried to change the {cpu,mmu}_has_feature() to use jump label two yeas ago [1]. But that codes seem a bit ugly. This is a reimplementation by moving the jump_label_init() much earlier so the jump label can be used in a very earlier stage. Boot test on p4080ds, t2080rdb and powermac (qemu). This patch series is against linux-next. [1] https://lists.ozlabs.org/pipermail/linuxppc-dev/2013-September/111026.html Kevin Hao (6): jump_label: make it possible for the archs to invoke jump_label_init() much earlier powerpc: invoke jump_label_init() in a much earlier stage powerpc: kill mfvtb() powerpc: move the cpu_has_feature to a separate file powerpc: use the jump label for cpu_has_feature powerpc: use jump label for mmu_has_feature arch/powerpc/include/asm/cacheflush.h | 1 + arch/powerpc/include/asm/cpufeatures.h | 34 ++ arch/powerpc/include/asm/cputable.h | 16 +++--- arch/powerpc/include/asm/cputime.h | 1 + arch/powerpc/include/asm/dbell.h| 1 + arch/powerpc/include/asm/dcr-native.h | 1 + arch/powerpc/include/asm/mman.h | 1 + arch/powerpc/include/asm/mmu.h | 29 ++ arch/powerpc/include/asm/reg.h | 9 arch/powerpc/include/asm/time.h | 3 ++- arch/powerpc/include/asm/xor.h | 1 + arch/powerpc/kernel/align.c | 1 + arch/powerpc/kernel/cputable.c | 37 + arch/powerpc/kernel/irq.c | 1 + arch/powerpc/kernel/process.c | 1 + arch/powerpc/kernel/setup-common.c | 1 + arch/powerpc/kernel/setup_32.c | 5 + arch/powerpc/kernel/setup_64.c | 4 arch/powerpc/kernel/smp.c | 1 + arch/powerpc/platforms/cell/pervasive.c | 1 + arch/powerpc/xmon/ppc-dis.c | 1 + kernel/jump_label.c | 3 +++ 22 files changed, 135 insertions(+), 18 deletions(-) create mode 100644 arch/powerpc/include/asm/cpufeatures.h -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v2 1/6] jump_label: make it possible for the archs to invoke jump_label_init() much earlier
For some archs (such as powerpc) would want to invoke jump_label_init() in a much earlier stage. So check static_key_initialized in order to make sure this function run only once. Signed-off-by: Kevin Hao haoke...@gmail.com --- v2: No change. kernel/jump_label.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/jump_label.c b/kernel/jump_label.c index f7dd15d537f9..cfc7d7b65432 100644 --- a/kernel/jump_label.c +++ b/kernel/jump_label.c @@ -205,6 +205,9 @@ void __init jump_label_init(void) struct static_key *key = NULL; struct jump_entry *iter; + if (static_key_initialized) + return; + jump_label_lock(); jump_label_sort_entries(iter_start, iter_stop); -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v2 2/6] powerpc: invoke jump_label_init() in a much earlier stage
So we can use static_key for cpu_has_feature() and mmu_has_feature(). Signed-off-by: Kevin Hao haoke...@gmail.com --- v2: No change. arch/powerpc/kernel/setup_32.c | 2 ++ arch/powerpc/kernel/setup_64.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c index bb02e9f6944e..35980a2785ba 100644 --- a/arch/powerpc/kernel/setup_32.c +++ b/arch/powerpc/kernel/setup_32.c @@ -113,6 +113,8 @@ notrace void __init machine_init(u64 dt_ptr) { lockdep_init(); + jump_label_init(); + /* Enable early debugging if any specified (see udbg.h) */ udbg_early_init(); diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c index bdcbb716f4d6..f0802a0b4a20 100644 --- a/arch/powerpc/kernel/setup_64.c +++ b/arch/powerpc/kernel/setup_64.c @@ -250,6 +250,8 @@ void __init early_setup(unsigned long dt_ptr) /* Initialize lockdep early or else spinlocks will blow */ lockdep_init(); + jump_label_init(); + /* printk is now safe to use --- */ /* Enable early debugging if any specified (see udbg.h) */ -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v2 3/6] powerpc: kill mfvtb()
This function is only used by get_vtb(). They are almost the same except the reading from the real register. Move the mfspr() to get_vtb() and kill the function mfvtb(). With this, we can eliminate the use of cpu_has_feature() in very core header file like reg.h. This is a preparation for the use of jump label for cpu_has_feature(). Signed-off-by: Kevin Hao haoke...@gmail.com --- v2: No change. arch/powerpc/include/asm/reg.h | 9 - arch/powerpc/include/asm/time.h | 2 +- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h index aa1cc5f015ee..d0b5f4b63776 100644 --- a/arch/powerpc/include/asm/reg.h +++ b/arch/powerpc/include/asm/reg.h @@ -1207,15 +1207,6 @@ : r ((unsigned long)(v)) \ : memory) -static inline unsigned long mfvtb (void) -{ -#ifdef CONFIG_PPC_BOOK3S_64 - if (cpu_has_feature(CPU_FTR_ARCH_207S)) - return mfspr(SPRN_VTB); -#endif - return 0; -} - #ifdef __powerpc64__ #if defined(CONFIG_PPC_CELL) || defined(CONFIG_PPC_FSL_BOOK3E) #define mftb() ({unsigned long rval; \ diff --git a/arch/powerpc/include/asm/time.h b/arch/powerpc/include/asm/time.h index 10fc784a2ad4..6f69828458fb 100644 --- a/arch/powerpc/include/asm/time.h +++ b/arch/powerpc/include/asm/time.h @@ -106,7 +106,7 @@ static inline u64 get_vtb(void) { #ifdef CONFIG_PPC_BOOK3S_64 if (cpu_has_feature(CPU_FTR_ARCH_207S)) - return mfvtb(); + return mfspr(SPRN_VTB); #endif return 0; } -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v2 4/6] powerpc: move the cpu_has_feature to a separate file
We plan to use jump label for cpu_has_feature. In order to implement this we need to include the linux/jump_label.h in asm/cputable.h. But it seems that asm/cputable.h is so basic header file for ppc that it is almost included by all the other header files. The including of the linux/jump_label.h will introduces various recursive inclusion. And it is very hard to fix that. So we choose to move the function cpu_has_feature to a separate header file before using the jump label for it. No functional change. Signed-off-by: Kevin Hao haoke...@gmail.com --- v2: No change. arch/powerpc/include/asm/cacheflush.h | 1 + arch/powerpc/include/asm/cpufeatures.h | 14 ++ arch/powerpc/include/asm/cputable.h | 8 arch/powerpc/include/asm/cputime.h | 1 + arch/powerpc/include/asm/dbell.h| 1 + arch/powerpc/include/asm/dcr-native.h | 1 + arch/powerpc/include/asm/mman.h | 1 + arch/powerpc/include/asm/time.h | 1 + arch/powerpc/include/asm/xor.h | 1 + arch/powerpc/kernel/align.c | 1 + arch/powerpc/kernel/irq.c | 1 + arch/powerpc/kernel/process.c | 1 + arch/powerpc/kernel/setup-common.c | 1 + arch/powerpc/kernel/setup_32.c | 1 + arch/powerpc/kernel/smp.c | 1 + arch/powerpc/platforms/cell/pervasive.c | 1 + arch/powerpc/xmon/ppc-dis.c | 1 + 17 files changed, 29 insertions(+), 8 deletions(-) create mode 100644 arch/powerpc/include/asm/cpufeatures.h diff --git a/arch/powerpc/include/asm/cacheflush.h b/arch/powerpc/include/asm/cacheflush.h index 6229e6b6037b..3bdcd9231852 100644 --- a/arch/powerpc/include/asm/cacheflush.h +++ b/arch/powerpc/include/asm/cacheflush.h @@ -11,6 +11,7 @@ #include linux/mm.h #include asm/cputable.h +#include asm/cpufeatures.h /* * No cache flushing is required when address mappings are changed, diff --git a/arch/powerpc/include/asm/cpufeatures.h b/arch/powerpc/include/asm/cpufeatures.h new file mode 100644 index ..37650db5044f --- /dev/null +++ b/arch/powerpc/include/asm/cpufeatures.h @@ -0,0 +1,14 @@ +#ifndef __ASM_POWERPC_CPUFEATURES_H +#define __ASM_POWERPC_CPUFEATURES_H + +#include asm/cputable.h + +static inline int cpu_has_feature(unsigned long feature) +{ + return (CPU_FTRS_ALWAYS feature) || + (CPU_FTRS_POSSIBLE +cur_cpu_spec-cpu_features +feature); +} + +#endif /* __ASM_POWERPC_CPUFEATURE_H */ diff --git a/arch/powerpc/include/asm/cputable.h b/arch/powerpc/include/asm/cputable.h index b118072670fb..ae4b6ef341cd 100644 --- a/arch/powerpc/include/asm/cputable.h +++ b/arch/powerpc/include/asm/cputable.h @@ -556,14 +556,6 @@ enum { }; #endif /* __powerpc64__ */ -static inline int cpu_has_feature(unsigned long feature) -{ - return (CPU_FTRS_ALWAYS feature) || - (CPU_FTRS_POSSIBLE -cur_cpu_spec-cpu_features -feature); -} - #define HBP_NUM 1 #endif /* !__ASSEMBLY__ */ diff --git a/arch/powerpc/include/asm/cputime.h b/arch/powerpc/include/asm/cputime.h index e2452550bcb1..b91837865c0e 100644 --- a/arch/powerpc/include/asm/cputime.h +++ b/arch/powerpc/include/asm/cputime.h @@ -28,6 +28,7 @@ static inline void setup_cputime_one_jiffy(void) { } #include asm/div64.h #include asm/time.h #include asm/param.h +#include asm/cpufeatures.h typedef u64 __nocast cputime_t; typedef u64 __nocast cputime64_t; diff --git a/arch/powerpc/include/asm/dbell.h b/arch/powerpc/include/asm/dbell.h index 5fa6b20eba10..2d9eae338f70 100644 --- a/arch/powerpc/include/asm/dbell.h +++ b/arch/powerpc/include/asm/dbell.h @@ -16,6 +16,7 @@ #include linux/threads.h #include asm/ppc-opcode.h +#include asm/cpufeatures.h #define PPC_DBELL_MSG_BRDCAST (0x0400) #define PPC_DBELL_TYPE(x) (((x) 0xf) (63-36)) diff --git a/arch/powerpc/include/asm/dcr-native.h b/arch/powerpc/include/asm/dcr-native.h index 4efc11dacb98..0186ba05bfe1 100644 --- a/arch/powerpc/include/asm/dcr-native.h +++ b/arch/powerpc/include/asm/dcr-native.h @@ -24,6 +24,7 @@ #include linux/spinlock.h #include asm/cputable.h +#include asm/cpufeatures.h typedef struct { unsigned int base; diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h index 8565c254151a..74922ad05e6c 100644 --- a/arch/powerpc/include/asm/mman.h +++ b/arch/powerpc/include/asm/mman.h @@ -13,6 +13,7 @@ #include asm/cputable.h #include linux/mm.h +#include asm/cpufeatures.h /* * This file is included by linux/mman.h, so we can't use cacl_vm_prot_bits() diff --git a/arch/powerpc/include/asm/time.h b/arch/powerpc/include/asm/time.h index 6f69828458fb..fa63005f827f 100644 --- a/arch/powerpc/include/asm/time.h +++ b/arch/powerpc/include/asm/time.h @@ -18,6 +18,7 @@ #include linux/percpu.h #include asm/processor.h +#include asm/cpufeatures.h /* time.c */ extern unsigned long tb_ticks_per_jiffy; diff --git
[PATCH v2 5/6] powerpc: use the jump label for cpu_has_feature
The cpu features are fixed once the probe of cpu features are done. And the function cpu_has_feature() does be used in some hot path. The checking of the cpu features for each time of invoking of cpu_has_feature() seems suboptimal. This tries to reduce this overhead of this check by using jump label. The generated assemble code of the following c program: if (cpu_has_feature(CPU_FTR_XXX)) xxx() Before: lis r9,-16230 lwz r9,12324(r9) lwz r9,12(r9) andi. r10,r9,512 beqlr- After: nop if CPU_FTR_XXX is enabled b xxx if CPU_FTR_XXX is not enabled Signed-off-by: Kevin Hao haoke...@gmail.com --- v2: Use the open-coded definition and initialization for cpu_feat_keys[]. arch/powerpc/include/asm/cpufeatures.h | 20 arch/powerpc/include/asm/cputable.h| 8 arch/powerpc/kernel/cputable.c | 20 arch/powerpc/kernel/setup_32.c | 1 + arch/powerpc/kernel/setup_64.c | 1 + 5 files changed, 50 insertions(+) diff --git a/arch/powerpc/include/asm/cpufeatures.h b/arch/powerpc/include/asm/cpufeatures.h index 37650db5044f..405a97fe6ef9 100644 --- a/arch/powerpc/include/asm/cpufeatures.h +++ b/arch/powerpc/include/asm/cpufeatures.h @@ -3,6 +3,25 @@ #include asm/cputable.h +#ifdef CONFIG_JUMP_LABEL +#include linux/jump_label.h + +extern struct static_key_true cpu_feat_keys[MAX_CPU_FEATURES]; + +static inline int cpu_has_feature(unsigned long feature) +{ + int i; + + if (CPU_FTRS_ALWAYS feature) + return 1; + + if (!(CPU_FTRS_POSSIBLE feature)) + return 0; + + i = __builtin_ctzl(feature); + return static_branch_likely(cpu_feat_keys[i]); +} +#else static inline int cpu_has_feature(unsigned long feature) { return (CPU_FTRS_ALWAYS feature) || @@ -10,5 +29,6 @@ static inline int cpu_has_feature(unsigned long feature) cur_cpu_spec-cpu_features feature); } +#endif #endif /* __ASM_POWERPC_CPUFEATURE_H */ diff --git a/arch/powerpc/include/asm/cputable.h b/arch/powerpc/include/asm/cputable.h index ae4b6ef341cd..2ebee2894102 100644 --- a/arch/powerpc/include/asm/cputable.h +++ b/arch/powerpc/include/asm/cputable.h @@ -114,6 +114,12 @@ extern void do_feature_fixups(unsigned long value, void *fixup_start, extern const char *powerpc_base_platform; +#ifdef CONFIG_JUMP_LABEL +extern void cpu_feat_keys_init(void); +#else +static inline void cpu_feat_keys_init(void) { } +#endif + /* TLB flush actions. Used as argument to cpu_spec.flush_tlb() hook */ enum { TLB_INVAL_SCOPE_GLOBAL = 0, /* invalidate all TLBs */ @@ -124,6 +130,8 @@ enum { /* CPU kernel features */ +#define MAX_CPU_FEATURES (8 * sizeof(((struct cpu_spec *)0)-cpu_features)) + /* Retain the 32b definitions all use bottom half of word */ #define CPU_FTR_COHERENT_ICACHEASM_CONST(0x0001) #define CPU_FTR_L2CR ASM_CONST(0x0002) diff --git a/arch/powerpc/kernel/cputable.c b/arch/powerpc/kernel/cputable.c index 7d80bfdfb15e..ea94931c5e70 100644 --- a/arch/powerpc/kernel/cputable.c +++ b/arch/powerpc/kernel/cputable.c @@ -15,6 +15,7 @@ #include linux/threads.h #include linux/init.h #include linux/export.h +#include linux/jump_label.h #include asm/oprofile_impl.h #include asm/cputable.h @@ -2195,3 +2196,22 @@ struct cpu_spec * __init identify_cpu(unsigned long offset, unsigned int pvr) return NULL; } + +#ifdef CONFIG_JUMP_LABEL +struct static_key_true cpu_feat_keys[MAX_CPU_FEATURES] = { + [0 ... MAX_CPU_FEATURES - 1] = STATIC_KEY_TRUE_INIT +}; +EXPORT_SYMBOL_GPL(cpu_feat_keys); + +void __init cpu_feat_keys_init(void) +{ + int i; + + for (i = 0; i MAX_CPU_FEATURES; i++) { + unsigned long f = 1ul i; + + if (!(cur_cpu_spec-cpu_features f)) + static_branch_disable(cpu_feat_keys[i]); + } +} +#endif diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c index f0868f510b3b..93756175a13c 100644 --- a/arch/powerpc/kernel/setup_32.c +++ b/arch/powerpc/kernel/setup_32.c @@ -115,6 +115,7 @@ notrace void __init machine_init(u64 dt_ptr) lockdep_init(); jump_label_init(); + cpu_feat_keys_init(); /* Enable early debugging if any specified (see udbg.h) */ udbg_early_init(); diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c index f0802a0b4a20..4cf3894d91fa 100644 --- a/arch/powerpc/kernel/setup_64.c +++ b/arch/powerpc/kernel/setup_64.c @@ -251,6 +251,7 @@ void __init early_setup(unsigned long dt_ptr) lockdep_init(); jump_label_init(); + cpu_feat_keys_init(); /* printk is now safe to use --- */ -- 2.1.0 ___ Linuxppc-dev mailing list
[PATCH v2 6/6] powerpc: use jump label for mmu_has_feature
The mmu features are fixed once the probe of mmu features are done. And the function mmu_has_feature() does be used in some hot path. The checking of the mmu features for each time of invoking of mmu_has_feature() seems suboptimal. This tries to reduce this overhead of this check by using jump label. The generated assemble code of the following c program: if (mmu_has_feature(MMU_FTR_XXX)) xxx() Before: lis r9,-16230 lwz r9,12324(r9) lwz r9,24(r9) andi. r10,r9,16 beqlr+ After: nop if MMU_FTR_XXX is enabled b xxx if MMU_FTR_XXX is not enabled Signed-off-by: Kevin Hao haoke...@gmail.com --- v2: Use the open-coded definition and initialization for mmu_feat_keys[]. arch/powerpc/include/asm/mmu.h | 29 + arch/powerpc/kernel/cputable.c | 17 + arch/powerpc/kernel/setup_32.c | 1 + arch/powerpc/kernel/setup_64.c | 1 + 4 files changed, 48 insertions(+) diff --git a/arch/powerpc/include/asm/mmu.h b/arch/powerpc/include/asm/mmu.h index 3d5abfe6ba67..e091de352a75 100644 --- a/arch/powerpc/include/asm/mmu.h +++ b/arch/powerpc/include/asm/mmu.h @@ -109,6 +109,34 @@ DECLARE_PER_CPU(int, next_tlbcam_idx); #endif +#ifdef CONFIG_JUMP_LABEL +#include linux/jump_label.h + +#define MAX_MMU_FEATURES (8 * sizeof(((struct cpu_spec *)0)-mmu_features)) + +extern struct static_key_true mmu_feat_keys[MAX_MMU_FEATURES]; + +extern void mmu_feat_keys_init(void); + +static inline int mmu_has_feature(unsigned long feature) +{ + int i; + + i = __builtin_ctzl(feature); + return static_branch_likely(mmu_feat_keys[i]); +} + +static inline void mmu_clear_feature(unsigned long feature) +{ + int i; + + i = __builtin_ctzl(feature); + cur_cpu_spec-mmu_features = ~feature; + static_branch_disable(mmu_feat_keys[i]); +} +#else +static inline void mmu_feat_keys_init(void) { } + static inline int mmu_has_feature(unsigned long feature) { return (cur_cpu_spec-mmu_features feature); @@ -118,6 +146,7 @@ static inline void mmu_clear_feature(unsigned long feature) { cur_cpu_spec-mmu_features = ~feature; } +#endif extern unsigned int __start___mmu_ftr_fixup, __stop___mmu_ftr_fixup; diff --git a/arch/powerpc/kernel/cputable.c b/arch/powerpc/kernel/cputable.c index ea94931c5e70..6b505c98520b 100644 --- a/arch/powerpc/kernel/cputable.c +++ b/arch/powerpc/kernel/cputable.c @@ -2214,4 +2214,21 @@ void __init cpu_feat_keys_init(void) static_branch_disable(cpu_feat_keys[i]); } } + +struct static_key_true mmu_feat_keys[MAX_MMU_FEATURES] = { + [0 ... MAX_MMU_FEATURES - 1] = STATIC_KEY_TRUE_INIT +}; +EXPORT_SYMBOL_GPL(mmu_feat_keys); + +void __init mmu_feat_keys_init(void) +{ + int i; + + for (i = 0; i MAX_MMU_FEATURES; i++) { + unsigned long f = 1ul i; + + if (!(cur_cpu_spec-mmu_features f)) + static_branch_disable(mmu_feat_keys[i]); + } +} #endif diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c index 93756175a13c..8acff5a4bc3e 100644 --- a/arch/powerpc/kernel/setup_32.c +++ b/arch/powerpc/kernel/setup_32.c @@ -116,6 +116,7 @@ notrace void __init machine_init(u64 dt_ptr) jump_label_init(); cpu_feat_keys_init(); + mmu_feat_keys_init(); /* Enable early debugging if any specified (see udbg.h) */ udbg_early_init(); diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c index 4cf3894d91fa..df6f98f1c46c 100644 --- a/arch/powerpc/kernel/setup_64.c +++ b/arch/powerpc/kernel/setup_64.c @@ -252,6 +252,7 @@ void __init early_setup(unsigned long dt_ptr) jump_label_init(); cpu_feat_keys_init(); + mmu_feat_keys_init(); /* printk is now safe to use --- */ -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [RFC PATCH 14/17] powerpc/book3e-64/kexec: Enable SMP release
On Thu, 2015-08-20 at 14:54 +1000, Michael Ellerman wrote: Hi Scott, Sorry for the delay. So I'm back to square one on this patch. On Sat, 2015-07-18 at 15:08 -0500, Scott Wood wrote: booted_from_exec is similar to __run_at_load, except that it is set for regular kexec as well as kdump. The flag is needed because the SMP release mechanism for FSL book3e is different from when booting with normal hardware. In theory we could simulate the normal spin table mechanism, but not at the addresses U-Boot put in the device tree -- so there'd need to be even more communication between the kernel and kexec to set that up. Since there's already a similar flag being set (for kdump only), this seemed like a reasonable approach. Although this is a reasonable approach, I don't think it's the best approach. AFAICS there's no reason why we can't use a device tree property for this, so I think we should do that. OK, I'll look into that. diff --git a/arch/powerpc/platforms/85xx/smp.c b/arch/powerpc/platforms/85xx/smp.c index 5152289..4abda43 100644 --- a/arch/powerpc/platforms/85xx/smp.c +++ b/arch/powerpc/platforms/85xx/smp.c @@ -305,10 +310,13 @@ static int smp_85xx_kick_cpu(int nr) __secondary_hold_acknowledge = -1; } #endif - flush_spin_table(spin_table); - out_be32(spin_table-pir, hw_cpu); - out_be32(spin_table-addr_l, __pa(__early_start)); - flush_spin_table(spin_table); + + if (have_spin_table) { + flush_spin_table(spin_table); + out_be32(spin_table-pir, hw_cpu); + out_be32(spin_table-addr_l, __pa(__early_start)); + flush_spin_table(spin_table); + } /* Wait a bit for the CPU to ack. */ if (!spin_event_timeout(__secondary_hold_acknowledge == hw_cpu, This looks like it's inside an #ifdef CONFIG_PPC32 block, which doesn't make sense, so I must be missing a lead-up patch or something? (I looked on the list but didn't find anything immediately) Thanks for catching this. This is apparently a mismerge due to the code having been previously worked on in the context of the SDK tree, which does not have that code inside #ifdef CONFIG_PPC32. When I then applied the result to mainline, everything still appeared to work, because there's no real consequence to writing to the spin table in this case -- it's just a no-op. setup_64.c is the part where checking booted_from_kexec (or devicetree equivalent) really matters. -Scott ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [v2 02/11] soc/fsl: Introduce DPAA BMan device management driver
On Wed, 2015-08-12 at 16:14 -0400, Roy Pledge wrote: From: Geoff Thorpe geoff.tho...@freescale.com This driver enables the Freescale DPAA 1.0 Buffer Manager block. BMan is a hardware buffer pool manager that allows accelerators connected to the SoC datapath to acquire and release buffers during data processing. Signed-off-by: Geoff Thorpe geoff.tho...@freescale.com Signed-off-by: Emil Medve emilian.me...@freescale.com Signed-off-by: Roy Pledge roy.ple...@freescale.com --- drivers/soc/Kconfig |1 + drivers/soc/Makefile |1 + drivers/soc/fsl/Kconfig |5 + drivers/soc/fsl/Makefile |3 + drivers/soc/fsl/qbman/Kconfig | 25 ++ drivers/soc/fsl/qbman/Makefile|1 + drivers/soc/fsl/qbman/bman.c | 553 + drivers/soc/fsl/qbman/bman_priv.h | 53 drivers/soc/fsl/qbman/dpaa_sys.h | 55 9 files changed, 697 insertions(+) create mode 100644 drivers/soc/fsl/Kconfig create mode 100644 drivers/soc/fsl/Makefile create mode 100644 drivers/soc/fsl/qbman/Kconfig create mode 100644 drivers/soc/fsl/qbman/Makefile create mode 100644 drivers/soc/fsl/qbman/bman.c create mode 100644 drivers/soc/fsl/qbman/bman_priv.h create mode 100644 drivers/soc/fsl/qbman/dpaa_sys.h diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig index 96ddecb..4e3c8f4 100644 --- a/drivers/soc/Kconfig +++ b/drivers/soc/Kconfig @@ -1,6 +1,7 @@ menu SOC (System On Chip) specific Drivers source drivers/soc/mediatek/Kconfig +source drivers/soc/fsl/Kconfig source drivers/soc/qcom/Kconfig source drivers/soc/sunxi/Kconfig source drivers/soc/ti/Kconfig diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile index 7dc7c0d..7adcd97 100644 --- a/drivers/soc/Makefile +++ b/drivers/soc/Makefile @@ -3,6 +3,7 @@ # obj-$(CONFIG_ARCH_MEDIATEK) += mediatek/ +obj-$(CONFIG_FSL_SOC)+= fsl/ obj-$(CONFIG_ARCH_QCOM) += qcom/ obj-$(CONFIG_ARCH_SUNXI) += sunxi/ obj-$(CONFIG_ARCH_TEGRA) += tegra/ diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig new file mode 100644 index 000..daa9c0d --- /dev/null +++ b/drivers/soc/fsl/Kconfig @@ -0,0 +1,5 @@ +menu Freescale SOC (System On Chip) specific Drivers + +source drivers/soc/fsl/qbman/Kconfig + +endmenu diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile new file mode 100644 index 000..19e74bb --- /dev/null +++ b/drivers/soc/fsl/Makefile @@ -0,0 +1,3 @@ +# Common +obj-$(CONFIG_FSL_DPA)+= qbman/ + diff --git a/drivers/soc/fsl/qbman/Kconfig b/drivers/soc/fsl/qbman/Kconfig new file mode 100644 index 000..be4ae01 --- /dev/null +++ b/drivers/soc/fsl/qbman/Kconfig @@ -0,0 +1,25 @@ +menuconfig FSL_DPA + bool Freescale DPAA support + depends on FSL_SOC || COMPILE_TEST + default n Drop the COMPILE_TEST -- this driver still has PPCisms that will break the build elsewhere. + help + FSL Data-Path Acceleration Architecture drivers + + These are not the actual Ethernet driver(s) + +if FSL_DPA + +config FSL_DPA_CHECKING + bool additional driver checking + default n + help + Compiles in additional checks to sanity-check the drivers and + any use of it by other code. Not recommended for performance + +config FSL_BMAN + tristate BMan device management + default n + help + FSL DPAA BMan driver Please describe here what BMan is and when it should be enabled. Why isn't it always enabled when DPA is enabled? +endif # FSL_DPA diff --git a/drivers/soc/fsl/qbman/Makefile b/drivers/soc/fsl/qbman/Makefile new file mode 100644 index 000..02014d9 --- /dev/null +++ b/drivers/soc/fsl/qbman/Makefile @@ -0,0 +1 @@ +obj-$(CONFIG_FSL_BMAN) += bman.o diff --git a/drivers/soc/fsl/qbman/bman.c b/drivers/soc/fsl/qbman/bman.c new file mode 100644 index 000..9a500ce --- /dev/null +++ b/drivers/soc/fsl/qbman/bman.c @@ -0,0 +1,553 @@ +/* Copyright (c) 2009 - 2015 Freescale Semiconductor, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * * Neither the name of Freescale Semiconductor nor the + *names of its contributors may be used to endorse or promote products + *derived from this software without specific prior written permission. + * + * ALTERNATIVELY, this
Re: [PATCH v6 1/3] genalloc:support memory-allocation with bytes-alignment to genalloc
On 08/24/2015 02:31 AM, Zhao Qiang wrote: Bytes alignment is required to manage some special RAM, so add gen_pool_first_fit_align to genalloc, meanwhile add gen_pool_alloc_data to pass data to gen_pool_first_fit_align(modify gen_pool_alloc as a wrapper) Signed-off-by: Zhao Qiang qiang.z...@freescale.com --- Changes for v6: - patches set v6 include a new patch because of using - genalloc to manage QE MURAM, patch 0001 is the new - patch, adding bytes alignment for allocation for use. include/linux/genalloc.h | 23 +++ lib/genalloc.c | 58 +++- 2 files changed, 72 insertions(+), 9 deletions(-) diff --git a/include/linux/genalloc.h b/include/linux/genalloc.h index 1ccaab4..55da07e 100644 --- a/include/linux/genalloc.h +++ b/include/linux/genalloc.h @@ -34,6 +34,7 @@ struct device; struct device_node; +struct gen_pool; /** * Allocation callback function type definition @@ -47,7 +48,7 @@ typedef unsigned long (*genpool_algo_t)(unsigned long *map, unsigned long size, unsigned long start, unsigned int nr, - void *data); + void *data, struct gen_pool *pool); /* * General purpose special memory pool descriptor. @@ -73,6 +74,13 @@ struct gen_pool_chunk { unsigned long bits[0]; /* bitmap for allocating memory chunk */ }; +/* + * gen_pool data descriptor for gen_pool_first_fit_align. + */ +struct genpool_data_align { + int align; /* alignment by bytes for starting address */ +}; + (sorry for chiming in late, I've been traveling) Is there an advantage here to wrapping this in a structure instead of just passing a pointer to an align integer? Thanks, Laura ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [v2 03/11] soc/fsl: Introduce the DPAA BMan portal driver
On Wed, Aug 12, 2015 at 04:14:49PM -0400, Roy Pledge wrote: diff --git a/drivers/soc/fsl/qbman/bman.c b/drivers/soc/fsl/qbman/bman.c index 9a500ce..d6e2204 100644 --- a/drivers/soc/fsl/qbman/bman.c +++ b/drivers/soc/fsl/qbman/bman.c @@ -165,11 +165,11 @@ static struct bman *bm_create(void *regs) static inline u32 __bm_in(struct bman *bm, u32 offset) { - return in_be32((void *)bm + offset); + return ioread32be((void *)bm + offset); } static inline void __bm_out(struct bman *bm, u32 offset, u32 val) { - out_be32((void *)bm + offset, val); + iowrite32be(val, (void*) bm + offset); } Don't introduce a problem in one patch and then fix it in another. What does this change have to do with introducing the portal driver? #define bm_in(reg) __bm_in(bm, REG_##reg) #define bm_out(reg, val) __bm_out(bm, REG_##reg, val) @@ -341,6 +341,7 @@ u32 bm_pool_free_buffers(u32 bpid) { return bm_in(POOL_CONTENT(bpid)); } +EXPORT_SYMBOL(bm_pool_free_buffers); If you're exporting this (or even making it global), where's the documentation? +/* BTW, the drivers (and h/w programming model) already obtain the required + * synchronisation for portal accesses via lwsync(), hwsync(), and + * data-dependencies. Use of barrier()s or other order-preserving primitives + * simply degrade performance. Hence the use of the __raw_*() interfaces, which + * simply ensure that the compiler treats the portal registers as volatile (ie. + * non-coherent). */ volatile does not mean non-coherent. Be careful with this regarding endian, e.g. on ARM we can run the CPU in big or little endian on the same chip, and the raw accessors also unfortunately bypass endian conversion. + +/* Cache-inhibited register access. */ +#define __bm_in(bm, o) __raw_readl((bm)-addr_ci + (o)) +#define __bm_out(bm, o, val) __raw_writel((val), (bm)-addr_ci + (o)) +#define bm_in(reg) __bm_in(portal-addr, BM_REG_##reg) +#define bm_out(reg, val) __bm_out(portal-addr, BM_REG_##reg, val) Don't have multiple implementations of bm_in/out, with the same name, where bm in both refers to bman, but which have different functions. +/* Cache-enabled (index) register access */ +#define __bm_cl_touch_ro(bm, o) dcbt_ro((bm)-addr_ce + (o)) +#define __bm_cl_touch_rw(bm, o) dcbt_rw((bm)-addr_ce + (o)) +#define __bm_cl_in(bm, o)__raw_readl((bm)-addr_ce + (o)) +#define __bm_cl_out(bm, o, val) \ + do { \ + u32 *__tmpclout = (bm)-addr_ce + (o); \ + __raw_writel((val), __tmpclout); \ + dcbf(__tmpclout); \ + } while (0) +#define __bm_cl_invalidate(bm, o) dcbi((bm)-addr_ce + (o)) +#define bm_cl_touch_ro(reg) __bm_cl_touch_ro(portal-addr, BM_CL_##reg##_CENA) +#define bm_cl_touch_rw(reg) __bm_cl_touch_rw(portal-addr, BM_CL_##reg##_CENA) +#define bm_cl_in(reg)__bm_cl_in(portal-addr, BM_CL_##reg##_CENA) +#define bm_cl_out(reg, val) __bm_cl_out(portal-addr, BM_CL_##reg##_CENA, val) +#define bm_cl_invalidate(reg)\ + __bm_cl_invalidate(portal-addr, BM_CL_##reg##_CENA) Define these using functions to operate on pointers, and pass the pointer in without all the token-pasting. Some extra explanation of the cache manipulation would also be helpful. +/* --- RCR API --- */ + +/* Bit-wise logic to wrap a ring pointer by clearing the carry bit */ +#define RCR_CARRYCLEAR(p) \ + (void *)((unsigned long)(p) (~(unsigned long)(BM_RCR_SIZE 6))) This could be a function. Where does 6 come from? You use it again in the next function. Please define it symbolically. + +/* Bit-wise logic to convert a ring pointer to a ring index */ +static inline u8 RCR_PTR2IDX(struct bm_rcr_entry *e) +{ + return ((uintptr_t)e 6) (BM_RCR_SIZE - 1); +} This is a function, so don't use ALLCAPS. +/* Increment the 'cursor' ring pointer, taking 'vbit' into account */ +static inline void RCR_INC(struct bm_rcr *rcr) +{ + /* NB: this is odd-looking, but experiments show that it generates + * fast code with essentially no branching overheads. We increment to + * the next RCR pointer and handle overflow and 'vbit'. */ + struct bm_rcr_entry *partial = rcr-cursor + 1; + + rcr-cursor = RCR_CARRYCLEAR(partial); + if (partial != rcr-cursor) + rcr-vbit ^= BM_RCR_VERB_VBIT; +} + +static inline int bm_rcr_init(struct bm_portal *portal, enum bm_rcr_pmode pmode, + __maybe_unused enum bm_rcr_cmode cmode) +{ + /* This use of 'register', as well as all other occurrences, is because + * it has been observed to generate much faster code with gcc than is + * otherwise the case. */ + register struct bm_rcr *rcr = portal-rcr; What version of GCC? Normal optimization settings? Has the seemingly excessive use of inline also been benchmarked against not doing so? +/* Buffer Pool Cleanup */ +static inline int bm_shutdown_pool(struct bm_portal
Re: [PATCH v6 3/3] qe_common: add qe_muram_ functions to manage muram
On 08/24/2015 02:31 AM, Zhao Qiang wrote: diff --git a/drivers/soc/fsl/qe/qe_common.c b/drivers/soc/fsl/qe/qe_common.c new file mode 100644 index 000..7f1762c --- /dev/null +++ b/drivers/soc/fsl/qe/qe_common.c @@ -0,0 +1,193 @@ +/* + * common qe code + * + * author: scott wood scottw...@freescale.com + * + * copyright 2007-2008,2010 freescale Semiconductor, Inc. + * + * some parts derived from commproc.c/qe2_common.c, which is: + * copyright (c) 1997 dan error_act (dma...@jlc.net) + * copyright (c) 1999-2001 dan Malek d...@embeddedalley.com + * copyright (c) 2000 montavista Software, Inc (sou...@mvista.com) + * 2006 (c) montavista software, Inc. + * vitaly bordug vbor...@ru.mvista.com + * + * this program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the free software Foundation. + */ + +#include linux/genalloc.h +#include linux/list.h +#include linux/init.h +#include linux/of_device.h +#include linux/spinlock.h +#include linux/export.h +#include linux/of.h +#include linux/of_address.h +#include linux/slab.h + +#include linux/io.h +#include soc/fsl/qe/qe.h + +static struct gen_pool *muram_pool; +static struct genpool_data_align muram_pool_data; +static spinlock_t qe_muram_lock; +static u8 __iomem *muram_vbase; +static phys_addr_t muram_pbase; + +struct muram_block { + struct list_head head; + unsigned long start; + int size; +}; + +static LIST_HEAD(muram_block_list); + +/* max address size we deal with */ +#define OF_MAX_ADDR_CELLS 4 + +int qe_muram_init(void) +{ + struct device_node *np; + struct resource r; + u32 zero[OF_MAX_ADDR_CELLS] = {}; + resource_size_t max = 0; + int i = 0; + int ret = 0; + + if (muram_pbase) + return 0; + + muram_pool = gen_pool_create(1, -1); + gen_pool_set_algo(muram_pool, gen_pool_first_fit_align, + muram_pool_data); + + np = of_find_compatible_node(NULL, NULL, fsl,qe-muram-data); + if (!np) { + /* try legacy bindings */ + np = of_find_node_by_name(NULL, data-only); + if (!np) { + pr_err(Cannot find CPM muram data node); + ret = -ENODEV; + goto out; + } + } + + muram_pbase = of_translate_address(np, zero); + if (muram_pbase == (phys_addr_t)OF_BAD_ADDR) { + pr_err(Cannot translate zero through CPM muram node); + ret = -ENODEV; + goto out; + } + + while (of_address_to_resource(np, i++, r) == 0) { + if (r.end max) + max = r.end; + ret = gen_pool_add(muram_pool, r.start - muram_pbase, + resource_size(r), -1); + if (ret) { + pr_err(QE MURAM: could not add muram ); + pr_err(remainder to pool!\n); Don't split the error string over two lines + return ret; returning here misses the error path + } + + } + + muram_vbase = ioremap(muram_pbase, max - muram_pbase + 1); + if (!muram_vbase) { + pr_err(Cannot map CPM muram); + ret = -ENOMEM; + } + gen_pool_destroy on the error path +out: + of_node_put(np); + return ret; +} + +/** + * qe_muram_alloc - allocate the requested size worth of multi-user ram + * @size: number of bytes to allocate + * @align: requested alignment, in bytes + * + * This function returns an offset into the muram area. + * Use qe_dpram_addr() to get the virtual address of the area. + * Use qe_muram_free() to free the allocation. + */ +unsigned long qe_muram_alloc(unsigned long size, unsigned long align) +{ + unsigned long start; + unsigned long flags; + struct muram_block *entry; + + spin_lock_irqsave(qe_muram_lock, flags); + muram_pool_data.align = align; + start = gen_pool_alloc(muram_pool, size); The advantage of creating gen_pool_alloc_data was so that you could pass in the align automatically without having to modify the structure. Is there a reason you aren't using that? + memset(qe_muram_addr(start), 0, size); There doesn't seem to be a check for allocation failure from the gen_alloc. + entry = kmalloc(sizeof(*entry), GFP_KERNEL); + if (!entry) + goto out; + entry-start = start; + entry-size = size; + list_add(entry-head, muram_block_list); What's the point of keeping the block list anyway? It's used only in this file and it only seems to duplicate what gen_alloc is doing internally. Is there some lookup functionality you still need? Could you use a gen_alloc API to do so? + spin_unlock_irqrestore(qe_muram_lock, flags); + + return start; +out: +
Re: [RFC PATCH 14/17] powerpc/book3e-64/kexec: Enable SMP release
On Mon, 2015-08-24 at 15:25 -0500, Scott Wood wrote: On Thu, 2015-08-20 at 14:54 +1000, Michael Ellerman wrote: Hi Scott, Sorry for the delay. So I'm back to square one on this patch. On Sat, 2015-07-18 at 15:08 -0500, Scott Wood wrote: booted_from_exec is similar to __run_at_load, except that it is set for regular kexec as well as kdump. The flag is needed because the SMP release mechanism for FSL book3e is different from when booting with normal hardware. In theory we could simulate the normal spin table mechanism, but not at the addresses U-Boot put in the device tree -- so there'd need to be even more communication between the kernel and kexec to set that up. Since there's already a similar flag being set (for kdump only), this seemed like a reasonable approach. Although this is a reasonable approach, I don't think it's the best approach. AFAICS there's no reason why we can't use a device tree property for this, so I think we should do that. OK, I'll look into that. Thanks. diff --git a/arch/powerpc/platforms/85xx/smp.c b/arch/powerpc/platforms/85xx/smp.c index 5152289..4abda43 100644 --- a/arch/powerpc/platforms/85xx/smp.c +++ b/arch/powerpc/platforms/85xx/smp.c @@ -305,10 +310,13 @@ static int smp_85xx_kick_cpu(int nr) __secondary_hold_acknowledge = -1; } #endif - flush_spin_table(spin_table); - out_be32(spin_table-pir, hw_cpu); - out_be32(spin_table-addr_l, __pa(__early_start)); - flush_spin_table(spin_table); + + if (have_spin_table) { + flush_spin_table(spin_table); + out_be32(spin_table-pir, hw_cpu); + out_be32(spin_table-addr_l, __pa(__early_start)); + flush_spin_table(spin_table); + } /* Wait a bit for the CPU to ack. */ if (!spin_event_timeout(__secondary_hold_acknowledge == hw_cpu, This looks like it's inside an #ifdef CONFIG_PPC32 block, which doesn't make sense, so I must be missing a lead-up patch or something? (I looked on the list but didn't find anything immediately) Thanks for catching this. This is apparently a mismerge due to the code having been previously worked on in the context of the SDK tree, which does not have that code inside #ifdef CONFIG_PPC32. When I then applied the result to mainline, everything still appeared to work, because there's no real consequence to writing to the spin table in this case -- it's just a no-op. Aha, that's good, I stared at it for ages thinking I was going mad, but I wasn't! setup_64.c is the part where checking booted_from_kexec (or devicetree equivalent) really matters. OK. Can we avoid that too? All smp_release_cpus() does is whack __secondary_hold_spinloop and then spin for a while. For the non-kexec case writing to __secondary_hold_spinloop should be harmless I think, so the only problem is we'll get stuck for a while in the udelay() loop. But you could avoid that by preemptively setting spinning_secondaries to 0 in platform code. That'd have to be in ppc_md.init_early(), but that's actually not very early, the device tree is already unflattened. I guess it's arguable whether that's more or less horrible than adding an #ifdef'ed booted_from_kexec check, but I think I'd prefer the spinning_secondaries solution. cheers ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [v2 00/11] Freescale DPAA QBMan Drivers
On Wed, 2015-08-12 at 16:14 -0400, Roy Pledge wrote: The Freescale Data Path Acceleration Architecture (DPAA) is a set of hardware components on specific QorIQ multicore processors. This architecture provides the infrastructure to support simplified sharing of networking interfaces and accelerators by multiple CPU cores and the accelerators. The Queue Manager (QMan) is a hardware queue management block that allows software and accelerators on the datapath to enqueue and dequeue frames in order to communicate. The Buffer Manager (BMan) is a hardware buffer pool management block that allows software and accelerators on the datapath to acquire and release buffers in order to build frames. This patch set introduces the QBMan driver code that configures initializes the QBMan hardware and provides APIs for software to use the frame queues and buffer pools the blocks provide. These drivers provide the base fuctionality for software to communicate with the other DPAA accelerators on Freescale QorIQ processors. Changes from v1: - Cleanup Kconfig options - Changed base QMan and BMan drivers to only be buit in. Will add loadable support in future patch CONFIG_FSL_BMAN is tristate -- is it not expected to work if you select 'm'? - Replace panic() call with WARN_ON() panic() is still there. - Replaced PowerPC specific IO accessors with platform independent versions PowerPC accessors, and other PPC-specfic things like cache flushing and memory barriers, are still there. -Scott ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
RE: [PATCH v6 1/3] genalloc:support memory-allocation with bytes-alignment to genalloc
On 08/25/2015 07:11 AM, Laura Abbott wrote: -Original Message- From: Laura Abbott [mailto:labb...@redhat.com] Sent: Tuesday, August 25, 2015 7:11 AM To: Zhao Qiang-B45475; Wood Scott-B07421 Cc: linux-ker...@vger.kernel.org; linuxppc-dev@lists.ozlabs.org; lau...@codeaurora.org; Xie Xiaobo-R63061; b...@kernel.crashing.org; Li Yang-Leo-R58472; pau...@samba.org Subject: Re: [PATCH v6 1/3] genalloc:support memory-allocation with bytes-alignment to genalloc On 08/24/2015 02:31 AM, Zhao Qiang wrote: Bytes alignment is required to manage some special RAM, so add gen_pool_first_fit_align to genalloc, meanwhile add gen_pool_alloc_data to pass data to gen_pool_first_fit_align(modify gen_pool_alloc as a wrapper) Signed-off-by: Zhao Qiang qiang.z...@freescale.com --- Changes for v6: - patches set v6 include a new patch because of using - genalloc to manage QE MURAM, patch 0001 is the new - patch, adding bytes alignment for allocation for use. include/linux/genalloc.h | 23 +++ lib/genalloc.c | 58 +++- 2 files changed, 72 insertions(+), 9 deletions(-) diff --git a/include/linux/genalloc.h b/include/linux/genalloc.h index 1ccaab4..55da07e 100644 --- a/include/linux/genalloc.h +++ b/include/linux/genalloc.h @@ -34,6 +34,7 @@ struct device; struct device_node; +struct gen_pool; /** * Allocation callback function type definition @@ -47,7 +48,7 @@ typedef unsigned long (*genpool_algo_t)(unsigned long *map, unsigned long size, unsigned long start, unsigned int nr, - void *data); + void *data, struct gen_pool *pool); /* * General purpose special memory pool descriptor. @@ -73,6 +74,13 @@ struct gen_pool_chunk { unsigned long bits[0]; /* bitmap for allocating memory chunk */ }; +/* + * gen_pool data descriptor for gen_pool_first_fit_align. + */ +struct genpool_data_align { + int align; /* alignment by bytes for starting address */ +}; + (sorry for chiming in late, I've been traveling) Is there an advantage here to wrapping this in a structure instead of just passing a pointer to an align integer? Please look at the commit message for ca279cf1065fb689abea1dc7d8c11787729bb185 which adds data: As I can't predict all the possible requirements/needs for all allocation uses cases, I add a free field 'void *data' to pass any needed information to the allocation function. For example 'data' could be used to handle a structure where you store the alignment, the expected memory bank, the requester device, or any information that could influence the allocation algorithm. Thanks, Laura -Zhao ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v6 3/3] qe_common: add qe_muram_ functions to manage muram
On 08/24/2015 08:03 PM, Zhao Qiang wrote: -Original Message- From: Laura Abbott [mailto:labb...@redhat.com] Sent: Tuesday, August 25, 2015 7:32 AM To: Zhao Qiang-B45475; Wood Scott-B07421 Cc: linux-ker...@vger.kernel.org; linuxppc-dev@lists.ozlabs.org; lau...@codeaurora.org; Xie Xiaobo-R63061; b...@kernel.crashing.org; Li Yang-Leo-R58472; pau...@samba.org Subject: Re: [PATCH v6 3/3] qe_common: add qe_muram_ functions to manage muram On 08/24/2015 02:31 AM, Zhao Qiang wrote: +out: + of_node_put(np); + return ret; +} + +/** + * qe_muram_alloc - allocate the requested size worth of multi-user +ram + * @size: number of bytes to allocate + * @align: requested alignment, in bytes + * + * This function returns an offset into the muram area. + * Use qe_dpram_addr() to get the virtual address of the area. + * Use qe_muram_free() to free the allocation. + */ +unsigned long qe_muram_alloc(unsigned long size, unsigned long align) +{ + unsigned long start; + unsigned long flags; + struct muram_block *entry; + + spin_lock_irqsave(qe_muram_lock, flags); + muram_pool_data.align = align; + start = gen_pool_alloc(muram_pool, size); The advantage of creating gen_pool_alloc_data was so that you could pass in the align automatically without having to modify the structure. Is there a reason you aren't using that? + memset(qe_muram_addr(start), 0, size); There doesn't seem to be a check for allocation failure from the gen_alloc. gen_pool_alloc will return 0 if there is error, but if the address returned is just 0x0, it can't distinguish it is address or error. Yes, that's a bad limitation of gen_pool. Maybe one day that will get fixed. In a previous out of tree driver, I worked around this by offsetting the gen_pool_add by a constant so any return value was non-zero and out of memory was zero and then subtracting the constant off of the return value. Not sure if that's better or worse than just fixing gen_alloc. + entry = kmalloc(sizeof(*entry), GFP_KERNEL); + if (!entry) + goto out; + entry-start = start; + entry-size = size; + list_add(entry-head, muram_block_list); What's the point of keeping the block list anyway? It's used only in this file and it only seems to duplicate what gen_alloc is doing internally. Is there some lookup functionality you still need? Could you use a gen_alloc API to do so? I need to record the size when allocation, so when free the block, I can get The right size for the block, and pass the right size to gen_pool_free(struct gen_pool *pool, unsigned long addr, size_t size). Yes, I see now what you are doing. Thanks, Laura Thanks Zhao Thanks, Laura ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH] cxl: Release irqs if memory allocation fails
This minor patch plugs a potential irq leak in case of a memory allocation failure inside function the afu_allocate_irqs. Presently the irqs allocated to the context gets leaked if allocation of either one of context irq_bitmap or irq_names fails. Signed-off-by: Vaibhav Jain vaib...@linux.vnet.ibm.com --- drivers/misc/cxl/irq.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/misc/cxl/irq.c b/drivers/misc/cxl/irq.c index c8f1f9d..e8b887e 100644 --- a/drivers/misc/cxl/irq.c +++ b/drivers/misc/cxl/irq.c @@ -421,6 +421,9 @@ int afu_allocate_irqs(struct cxl_context *ctx, u32 count) int rc, r, i, j = 1; struct cxl_irq_name *irq_name; + /* Initialize the list head to hold irq names */ + INIT_LIST_HEAD(ctx-irq_names); + if ((rc = cxl_alloc_irq_ranges(ctx-irqs, ctx-afu-adapter, count))) return rc; @@ -432,13 +435,12 @@ int afu_allocate_irqs(struct cxl_context *ctx, u32 count) ctx-irq_bitmap = kcalloc(BITS_TO_LONGS(count), sizeof(*ctx-irq_bitmap), GFP_KERNEL); if (!ctx-irq_bitmap) - return -ENOMEM; + goto out; /* * Allocate names first. If any fail, bail out before allocating * actual hardware IRQs. */ - INIT_LIST_HEAD(ctx-irq_names); for (r = 1; r CXL_IRQ_RANGES; r++) { for (i = 0; i ctx-irqs.range[r]; i++) { irq_name = kmalloc(sizeof(struct cxl_irq_name), @@ -460,6 +462,7 @@ int afu_allocate_irqs(struct cxl_context *ctx, u32 count) return 0; out: + cxl_release_irq_ranges(ctx-irqs, ctx-afu-adapter); afu_irq_name_free(ctx); return -ENOMEM; } -- 2.2.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH] powerpc: Add user-return-notifier support
Add user return notifier support for powerpc. Similar to x86, this feature keys off of the KVM Kconfig. Signed-off-by: Ananth N Mavinakayanahalli ana...@in.ibm.com --- Documentation/features/debug/user-ret-profiler/arch-support.txt |2 +- arch/powerpc/Kconfig|1 + arch/powerpc/include/asm/thread_info.h |2 ++ arch/powerpc/kernel/process.c |4 arch/powerpc/kernel/signal.c|4 arch/powerpc/kvm/Kconfig|1 + 6 files changed, 13 insertions(+), 1 deletion(-) Index: linux-4.2-rc6/Documentation/features/debug/user-ret-profiler/arch-support.txt === --- linux-4.2-rc6.orig/Documentation/features/debug/user-ret-profiler/arch-support.txt +++ linux-4.2-rc6/Documentation/features/debug/user-ret-profiler/arch-support.txt @@ -27,7 +27,7 @@ | nios2: | TODO | |openrisc: | TODO | | parisc: | TODO | -| powerpc: | TODO | +| powerpc: | ok | |s390: | TODO | | score: | TODO | | sh: | TODO | Index: linux-4.2-rc6/arch/powerpc/Kconfig === --- linux-4.2-rc6.orig/arch/powerpc/Kconfig +++ linux-4.2-rc6/arch/powerpc/Kconfig @@ -106,6 +106,7 @@ config PPC select HAVE_ARCH_KGDB select HAVE_KRETPROBES select HAVE_ARCH_TRACEHOOK + select HAVE_USER_RETURN_NOTIFIER select HAVE_MEMBLOCK select HAVE_MEMBLOCK_NODE_MAP select HAVE_DMA_ATTRS Index: linux-4.2-rc6/arch/powerpc/include/asm/thread_info.h === --- linux-4.2-rc6.orig/arch/powerpc/include/asm/thread_info.h +++ linux-4.2-rc6/arch/powerpc/include/asm/thread_info.h @@ -86,6 +86,7 @@ static inline struct thread_info *curren TIF_NEED_RESCHED */ #define TIF_32BIT 4 /* 32 bit binary */ #define TIF_RESTORE_TM 5 /* need to restore TM FP/VEC/VSX */ +#define TIF_USER_RETURN_NOTIFY 6 /* notify kernel of userspace return */ #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */ #define TIF_SINGLESTEP 8 /* singlestepping active */ #define TIF_NOHZ 9 /* in adaptive nohz mode */ @@ -109,6 +110,7 @@ static inline struct thread_info *curren #define _TIF_POLLING_NRFLAG(1TIF_POLLING_NRFLAG) #define _TIF_32BIT (1TIF_32BIT) #define _TIF_RESTORE_TM(1TIF_RESTORE_TM) +#define _TIF_USER_RETURN_NOTIFY(1TIF_USER_RETURN_NOTIFY) #define _TIF_SYSCALL_AUDIT (1TIF_SYSCALL_AUDIT) #define _TIF_SINGLESTEP(1TIF_SINGLESTEP) #define _TIF_SECCOMP (1TIF_SECCOMP) Index: linux-4.2-rc6/arch/powerpc/kernel/process.c === --- linux-4.2-rc6.orig/arch/powerpc/kernel/process.c +++ linux-4.2-rc6/arch/powerpc/kernel/process.c @@ -38,6 +38,7 @@ #include linux/random.h #include linux/hw_breakpoint.h #include linux/uaccess.h +#include linux/user-return-notifier.h #include asm/pgtable.h #include asm/io.h @@ -894,6 +895,9 @@ struct task_struct *__switch_to(struct t } #endif /* CONFIG_PPC_BOOK3S_64 */ + if (unlikely(task_thread_info(prev)-flags _TIF_USER_RETURN_NOTIFY)) + propagate_user_return_notify(prev, new); + return last; } Index: linux-4.2-rc6/arch/powerpc/kernel/signal.c === --- linux-4.2-rc6.orig/arch/powerpc/kernel/signal.c +++ linux-4.2-rc6/arch/powerpc/kernel/signal.c @@ -14,6 +14,7 @@ #include linux/uprobes.h #include linux/key.h #include linux/context_tracking.h +#include linux/user-return-notifier.h #include asm/hw_breakpoint.h #include asm/uaccess.h #include asm/unistd.h @@ -159,6 +160,9 @@ void do_notify_resume(struct pt_regs *re tracehook_notify_resume(regs); } + if (thread_info_flags _TIF_USER_RETURN_NOTIFY) + fire_user_return_notifiers(); + user_enter(); } Index: linux-4.2-rc6/arch/powerpc/kvm/Kconfig === --- linux-4.2-rc6.orig/arch/powerpc/kvm/Kconfig +++ linux-4.2-rc6/arch/powerpc/kvm/Kconfig @@ -22,6 +22,7 @@ config KVM select ANON_INODES select HAVE_KVM_EVENTFD select SRCU + select USER_RETURN_NOTIFIER config KVM_BOOK3S_HANDLER bool ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v6 1/3] genalloc:support memory-allocation with bytes-alignment to genalloc
On 08/24/2015 07:40 PM, Zhao Qiang wrote: On 08/25/2015 07:11 AM, Laura Abbott wrote: -Original Message- From: Laura Abbott [mailto:labb...@redhat.com] Sent: Tuesday, August 25, 2015 7:11 AM To: Zhao Qiang-B45475; Wood Scott-B07421 Cc: linux-ker...@vger.kernel.org; linuxppc-dev@lists.ozlabs.org; lau...@codeaurora.org; Xie Xiaobo-R63061; b...@kernel.crashing.org; Li Yang-Leo-R58472; pau...@samba.org Subject: Re: [PATCH v6 1/3] genalloc:support memory-allocation with bytes-alignment to genalloc On 08/24/2015 02:31 AM, Zhao Qiang wrote: Bytes alignment is required to manage some special RAM, so add gen_pool_first_fit_align to genalloc, meanwhile add gen_pool_alloc_data to pass data to gen_pool_first_fit_align(modify gen_pool_alloc as a wrapper) Signed-off-by: Zhao Qiang qiang.z...@freescale.com --- Changes for v6: - patches set v6 include a new patch because of using - genalloc to manage QE MURAM, patch 0001 is the new - patch, adding bytes alignment for allocation for use. include/linux/genalloc.h | 23 +++ lib/genalloc.c | 58 +++- 2 files changed, 72 insertions(+), 9 deletions(-) diff --git a/include/linux/genalloc.h b/include/linux/genalloc.h index 1ccaab4..55da07e 100644 --- a/include/linux/genalloc.h +++ b/include/linux/genalloc.h @@ -34,6 +34,7 @@ struct device; struct device_node; +struct gen_pool; /** * Allocation callback function type definition @@ -47,7 +48,7 @@ typedef unsigned long (*genpool_algo_t)(unsigned long *map, unsigned long size, unsigned long start, unsigned int nr, - void *data); + void *data, struct gen_pool *pool); /* * General purpose special memory pool descriptor. @@ -73,6 +74,13 @@ struct gen_pool_chunk { unsigned long bits[0]; /* bitmap for allocating memory chunk */ }; +/* + * gen_pool data descriptor for gen_pool_first_fit_align. + */ +struct genpool_data_align { + int align; /* alignment by bytes for starting address */ +}; + (sorry for chiming in late, I've been traveling) Is there an advantage here to wrapping this in a structure instead of just passing a pointer to an align integer? Please look at the commit message for ca279cf1065fb689abea1dc7d8c11787729bb185 which adds data: As I can't predict all the possible requirements/needs for all allocation uses cases, I add a free field 'void *data' to pass any needed information to the allocation function. For example 'data' could be used to handle a structure where you store the alignment, the expected memory bank, the requester device, or any information that could influence the allocation algorithm. Right, I understand what the purpose is but I'm not sure what you're getting from the structure vs passing a pointer, e.g. int align; align = 4; gen_pool_alloc_data(pool, size, align); it just seems to obfuscate what's going on by wrapping a single integer in a structure that's narrowly defined in a generic function right now. I guess it could change later which would necessitate having the structure but again it's so generic I'm not sure what else you would pass that would be applicable to all clients. Thanks, Laura ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
RE: [PATCH v6 3/3] qe_common: add qe_muram_ functions to manage muram
-Original Message- From: Laura Abbott [mailto:labb...@redhat.com] Sent: Tuesday, August 25, 2015 7:32 AM To: Zhao Qiang-B45475; Wood Scott-B07421 Cc: linux-ker...@vger.kernel.org; linuxppc-dev@lists.ozlabs.org; lau...@codeaurora.org; Xie Xiaobo-R63061; b...@kernel.crashing.org; Li Yang-Leo-R58472; pau...@samba.org Subject: Re: [PATCH v6 3/3] qe_common: add qe_muram_ functions to manage muram On 08/24/2015 02:31 AM, Zhao Qiang wrote: +out: + of_node_put(np); + return ret; +} + +/** + * qe_muram_alloc - allocate the requested size worth of multi-user +ram + * @size: number of bytes to allocate + * @align: requested alignment, in bytes + * + * This function returns an offset into the muram area. + * Use qe_dpram_addr() to get the virtual address of the area. + * Use qe_muram_free() to free the allocation. + */ +unsigned long qe_muram_alloc(unsigned long size, unsigned long align) +{ + unsigned long start; + unsigned long flags; + struct muram_block *entry; + + spin_lock_irqsave(qe_muram_lock, flags); + muram_pool_data.align = align; + start = gen_pool_alloc(muram_pool, size); The advantage of creating gen_pool_alloc_data was so that you could pass in the align automatically without having to modify the structure. Is there a reason you aren't using that? + memset(qe_muram_addr(start), 0, size); There doesn't seem to be a check for allocation failure from the gen_alloc. gen_pool_alloc will return 0 if there is error, but if the address returned is just 0x0, it can't distinguish it is address or error. + entry = kmalloc(sizeof(*entry), GFP_KERNEL); + if (!entry) + goto out; + entry-start = start; + entry-size = size; + list_add(entry-head, muram_block_list); What's the point of keeping the block list anyway? It's used only in this file and it only seems to duplicate what gen_alloc is doing internally. Is there some lookup functionality you still need? Could you use a gen_alloc API to do so? I need to record the size when allocation, so when free the block, I can get The right size for the block, and pass the right size to gen_pool_free(struct gen_pool *pool, unsigned long addr, size_t size). Thanks, Laura Thanks Zhao ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev