* Re: [PATCH] powerpc/fsl: Distribute interrupts on all CPUs by default
From: Kumar Gala @ 2012-06-29 19:59 UTC (permalink / raw)
To: Kim Phillips; +Cc: linuxppc-dev
In-Reply-To: <20120413172615.136b60077051430253bb5d0a@freescale.com>
On Apr 13, 2012, at 5:26 PM, Kim Phillips wrote:
> At least for crypto/IPSec, doing so provides users with a better
> performance experience out of the box.
>
> Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
> ---
> arch/powerpc/configs/corenet32_smp_defconfig | 1 +
> arch/powerpc/configs/corenet64_smp_defconfig | 1 +
> arch/powerpc/configs/mpc85xx_smp_defconfig | 1 +
> 3 files changed, 3 insertions(+)
applied
- k
^ permalink raw reply
* Re: [PATCH v3] powerpc/85xx: Enable MTD/NOR/NAND options by default in defconfig
From: Kumar Gala @ 2012-06-29 19:59 UTC (permalink / raw)
To: Shengzhou Liu; +Cc: dwmw2, linuxppc-dev, linux-mtd
In-Reply-To: <1335495660-14898-1-git-send-email-Shengzhou.Liu@freescale.com>
On Apr 26, 2012, at 10:01 PM, Shengzhou Liu wrote:
> Enable MTD/NOR/NAND options by default in mpc85xx_defconfig and
> mpc85xx_smp_defconfig to support NOR, NAND flash.
>=20
> Signed-off-by: Shengzhou Liu <Shengzhou.Liu@freescale.com>
> ---
> based on master branch of =
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git =
tree.
> v3: remove "CONFIG_MTD_NAND_VERIFY_WRITE=3Dy"
> v2: remove typo "CONFIG_MPC8xxx_GPIO=3Dy"
>=20
> arch/powerpc/configs/mpc85xx_defconfig | 24 =
++++++++++++++++++++++++
> arch/powerpc/configs/mpc85xx_smp_defconfig | 24 =
++++++++++++++++++++++++
> 2 files changed, 48 insertions(+), 0 deletions(-)
[ what about the corenet defconfigs?? ]
applied
- k=
^ permalink raw reply
* Re: [PATCH 2/2] powerpc/p1022ds/DTS: Add RTC support
From: Kumar Gala @ 2012-06-29 19:59 UTC (permalink / raw)
To: <Chang-Ming.Huang@freescale.com>; +Cc: linuxppc-dev
In-Reply-To: <1334626955-8069-2-git-send-email-Chang-Ming.Huang@freescale.com>
On Apr 16, 2012, at 8:42 PM, <Chang-Ming.Huang@freescale.com> =
<Chang-Ming.Huang@freescale.com> wrote:
> From: Jerry Huang <Chang-Ming.Huang@freescale.com>
>=20
> Add the RTC support for p1022ds
>=20
> Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
> ---
> arch/powerpc/boot/dts/p1022ds.dtsi | 4 ++++
> 1 files changed, 4 insertions(+), 0 deletions(-)
applied
- k=
^ permalink raw reply
* Re: powerpc/85xx: p2020rdb - move the NAND address.
From: Kumar Gala @ 2012-06-29 20:01 UTC (permalink / raw)
To: Sebastian Andrzej Siewior; +Cc: Bryan Hundven, linuxppc-dev
In-Reply-To: <20120509195307.GA25255@linutronix.de>
On May 9, 2012, at 2:53 PM, Sebastian Andrzej Siewior wrote:
> * Kumar Gala | 2012-03-31 09:48:18 [-0500]:
>
> Sorry for the delay Kumar, I though I allready done it.
>
>> Yes, please do.
> Here it comes.
>
>> From 5b3e09992615e5670fa8e432e50424466fa9ca1a Mon Sep 17 00:00:00 2001
> From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> Date: Wed, 9 May 2012 21:48:42 +0200
> Subject: [PATCH] Revert "powerpc/85xx: p2020rdb - move the NAND address."
>
> This reverts commit 0c00f65653389a408dfbbee7578e671664eea26a.
> The initial commit was my fault. There are two boards out there:
> P2020RDB and P2020RDB-PC. I wasn't aware of that and assumed that I have
> a RDB board in front of me while I the RDB-PC. This patch makes it work
> for the RDB-PC variant and breaks it for the RDB. Now there is a device
> tree file available for the RDB-PC which was not there earlier. So with
> this revert, everything gets back to normal :)
>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
> arch/powerpc/boot/dts/p2020rdb.dts | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
applied
- k
^ permalink raw reply
* Re: [PATCH] powerpc/p1010rdb: add EEPROMs to device tree
From: Kumar Gala @ 2012-06-29 20:02 UTC (permalink / raw)
To: Gustavo Zacarias; +Cc: linuxppc-dev
In-Reply-To: <1337783718-25553-1-git-send-email-gustavo@zacarias.com.ar>
On May 23, 2012, at 9:35 AM, Gustavo Zacarias wrote:
> Add EEPROM to the P1010RDB device tree.
> The 24c01 acts as a memory SPD so it shouldn't be overwritten without
> care.
> The 24c256 is a general purpose memory.
>
> Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
> ---
> arch/powerpc/boot/dts/p1010rdb.dtsi | 12 ++++++++++++
> 1 files changed, 12 insertions(+), 0 deletions(-)
applied
- k
^ permalink raw reply
* Re: [PATCH 1/3] powerpc: remove Wind River SBC8560 support
From: Kumar Gala @ 2012-06-29 20:02 UTC (permalink / raw)
To: Paul Gortmaker; +Cc: linuxppc-dev, David Woodhouse
In-Reply-To: <1340740469-31445-2-git-send-email-paul.gortmaker@windriver.com>
On Jun 26, 2012, at 2:54 PM, Paul Gortmaker wrote:
> This reference board dates back to 2004, and is largely a legacy
> EOL product. The MPC8560 is a pre e500v2 CPU. The SBC8548 is
> a more modern, better e500v2 target for people to use as a
> reference board with today's kernels, should they require one.
>=20
> Removing support for it will also allow us to remove some
> sbc8560 specific quirk handling in 8250 UART code, and some
> MTD mapping support.
>=20
> Cc: David Woodhouse <David.Woodhouse@intel.com>
> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
> ---
> arch/powerpc/boot/Makefile | 1 -
> arch/powerpc/boot/dts/sbc8560.dts | 406 =
---------------------------
> arch/powerpc/configs/85xx/sbc8560_defconfig | 65 -----
> arch/powerpc/platforms/85xx/Kconfig | 6 -
> arch/powerpc/platforms/85xx/Makefile | 1 -
> arch/powerpc/platforms/85xx/sbc8560.c | 254 -----------------
> 6 files changed, 0 insertions(+), 733 deletions(-)
> delete mode 100644 arch/powerpc/boot/dts/sbc8560.dts
> delete mode 100644 arch/powerpc/configs/85xx/sbc8560_defconfig
> delete mode 100644 arch/powerpc/platforms/85xx/sbc8560.c
applied
- k=
^ permalink raw reply
* Re: [PATCH 1/4] powerpc/83xx: use for_each_node_by_name for km83xx.c
From: Kumar Gala @ 2012-06-29 20:03 UTC (permalink / raw)
To: Holger Brunck; +Cc: Heiko Schocher, linuxppc-dev
In-Reply-To: <1336485442-24190-1-git-send-email-holger.brunck@keymile.com>
On May 8, 2012, at 8:57 AM, Holger Brunck wrote:
> Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
> cc: Heiko Schocher <hs@denx.de>
> cc: Kumar Gala <galak@kernel.crashing.org>
> ---
> arch/powerpc/platforms/83xx/km83xx.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
applied
- k
^ permalink raw reply
* Re: [PATCH 2/4] powerpc/83xx: fix RGMII AC values workaround for km83xx
From: Kumar Gala @ 2012-06-29 20:03 UTC (permalink / raw)
To: Holger Brunck; +Cc: Christian Herzig, linuxppc-dev, Heiko Schocher
In-Reply-To: <1336485442-24190-2-git-send-email-holger.brunck@keymile.com>
On May 8, 2012, at 8:57 AM, Holger Brunck wrote:
> From: Christian Herzig <christian.herzig@keymile.com>
>=20
> Fix RGMII workaround code in km83xx.c for MPC8360E and MPC8358E that =
it
> correctly identifes all affected SoC chip models and applies the
> workarounds appropriate for 2.0 and 2.1 revisions as per Freescale
> MPC8360ECE Errata document Rev.5(9/2011) item QE_ENET10.
>=20
> Signed-off-by: Christian Herzig <christian.herzig@keymile.com>
> Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
> cc: Heiko Schocher <hs@denx.de>
> cc: Kumar Gala <galak@kernel.crashing.org>
> ---
> arch/powerpc/platforms/83xx/km83xx.c | 98 =
+++++++++++++++++++++++-----------
> 1 files changed, 66 insertions(+), 32 deletions(-)
applied
- k=
^ permalink raw reply
* Re: [PATCH 3/4] powerpc/83xx: update defconfig for kmeter1
From: Kumar Gala @ 2012-06-29 20:03 UTC (permalink / raw)
To: Holger Brunck; +Cc: Heiko Schocher, linuxppc-dev
In-Reply-To: <1336485442-24190-3-git-send-email-holger.brunck@keymile.com>
On May 8, 2012, at 8:57 AM, Holger Brunck wrote:
> Switch on UBIFS, HOTPLUG and TIPC and update the config to
> the latest kernel version.
>
> Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
> cc: Heiko Schocher <hs@denx.de>
> cc: Kumar Gala <galak@kernel.crashing.org>
> ---
> arch/powerpc/configs/83xx/kmeter1_defconfig | 22 ++++++++--------------
> 1 files changed, 8 insertions(+), 14 deletions(-)
applied
- k
^ permalink raw reply
* Re: [PATCH 4/4] powerpc/82xx: add SPI support for mgcoge
From: Kumar Gala @ 2012-06-29 20:03 UTC (permalink / raw)
To: Holger Brunck; +Cc: Heiko Schocher, linuxppc-dev
In-Reply-To: <1336485442-24190-4-git-send-email-holger.brunck@keymile.com>
On May 8, 2012, at 8:57 AM, Holger Brunck wrote:
> Add spi support for mgcoge into the platform code and the dts
> file. Additionaly SPIDEV is switched on in the defconfig and the
> updates for the newer kernel version are committed. The SPI
> interface is used to drive the Maxim DS3106 clock chip.
>
> Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
> cc: Heiko Schocher <hs@denx.de>
> cc: Kumar Gala <galak@kernel.crashing.org>
> ---
> arch/powerpc/boot/dts/mgcoge.dts | 23 +++++++++++++++++++++++
> arch/powerpc/configs/mgcoge_defconfig | 12 ++++--------
> arch/powerpc/platforms/82xx/km82xx.c | 5 +++++
> 3 files changed, 32 insertions(+), 8 deletions(-)
applied
- k
^ permalink raw reply
* Re: [PATCH 1/2] powerpc/85xx: Add P1024rdb dts support
From: Kumar Gala @ 2012-06-29 20:03 UTC (permalink / raw)
To: <b29983@freescale.com>
Cc: Tang Yuantian, devicetree-discuss, linuxppc-dev
In-Reply-To: <1337850508-31827-1-git-send-email-b29983@freescale.com>
On May 24, 2012, at 4:08 AM, <b29983@freescale.com> =
<b29983@freescale.com> wrote:
> From: Tang Yuantian <Yuantian.Tang@freescale.com>
>=20
> Signed-off-by: Jin Qing <b24347@freescale.com>
> Signed-off-by: Li Yang <leoli@freescale.com>
> Signed-off-by: Tang Yuantian <Yuantian.Tang@freescale.com>
> ---
> arch/powerpc/boot/dts/p1024rdb.dtsi | 228 =
++++++++++++++++++++++++++++++++
> arch/powerpc/boot/dts/p1024rdb_32b.dts | 87 ++++++++++++
> arch/powerpc/boot/dts/p1024rdb_36b.dts | 87 ++++++++++++
> 3 files changed, 402 insertions(+), 0 deletions(-)
> create mode 100644 arch/powerpc/boot/dts/p1024rdb.dtsi
> create mode 100644 arch/powerpc/boot/dts/p1024rdb_32b.dts
> create mode 100644 arch/powerpc/boot/dts/p1024rdb_36b.dts
applied
- k=
^ permalink raw reply
* Re: [PATCH 2/2] powerpc/85xx: Add P1024rdb board support
From: Kumar Gala @ 2012-06-29 20:03 UTC (permalink / raw)
To: <b29983@freescale.com>
Cc: Tang Yuantian, devicetree-discuss, linuxppc-dev
In-Reply-To: <1337850508-31827-2-git-send-email-b29983@freescale.com>
On May 24, 2012, at 4:08 AM, <b29983@freescale.com> =
<b29983@freescale.com> wrote:
> From: Tang Yuantian <Yuantian.Tang@freescale.com>
>=20
> The p1024rdb has the similar feature as the p1020rdb. Therefore, =
p1024rdb use
> the same platform file as the p1/p2 rdb board.
> Overview of P2020RDB platform
> - DDR3 1G
> - NOR flash 16M
> - 3 Ethernet interfaces
> - NAND Flash 32M
> - SPI EEPROM 16M
> - SD/MMC
> - 2 USB ports
> - 4 TDM ports
>=20
> Signed-off-by: Jin Qing <b24347@freescale.com>
> Signed-off-by: Li Yang <leoli@freescale.com>
> Signed-off-by: Tang Yuantian <Yuantian.Tang@freescale.com>
> ---
> arch/powerpc/platforms/85xx/mpc85xx_rdb.c | 22 =
++++++++++++++++++++++
> 1 files changed, 22 insertions(+), 0 deletions(-)
applied
- k=
^ permalink raw reply
* Re: [PATCH] powerpc/p2041rdb: add NAND node in device tree
From: Kumar Gala @ 2012-06-29 20:03 UTC (permalink / raw)
To: Shaohui Xie; +Cc: linuxppc-dev
In-Reply-To: <1340962871-10617-1-git-send-email-Shaohui.Xie@freescale.com>
On Jun 29, 2012, at 4:41 AM, Shaohui Xie wrote:
> NAND on p2041 uses CS1 as chip select.
>=20
> Signed-off-by: Shaohui Xie <Shaohui.Xie@freescale.com>
> ---
> arch/powerpc/boot/dts/p2041rdb.dts | 41 =
+++++++++++++++++++++++++++++++++++-
> 1 files changed, 40 insertions(+), 1 deletions(-)
applied
- k=
^ permalink raw reply
* [PATCH v2 1/3] powerpc/fsl-pci: get PCI init out of board files
From: Scott Wood @ 2012-06-29 20:10 UTC (permalink / raw)
To: galak; +Cc: linuxppc-dev, Jia Hongtao
As an alternative incremental starting point to Jia Hongtao's patchset,
get the FSL PCI init out of the board files, but do not yet convert to a
platform driver.
Rather than having each board supply a magic register offset for
determining the "primary" bus, we look for which PCI host bridge
contains an ISA node within its subtree. If there is no ISA node,
normally that would mean there is no primary bus, but until certain
bugs are fixed we arbitrarily designate a primary in this case.
Conversion to a platform driver and related improvements can happen
after this, as the ordering issues are sorted out.
Signed-off-by: Scott Wood <scottwood@freescale.com>
---
v2: Honor existing fsl_pci_primary if non-NULL, and update copyright year
No change to the rest of the patchset.
arch/powerpc/sysdev/fsl_pci.c | 71 ++++++++++++++++++++++++++++++++++++++++-
arch/powerpc/sysdev/fsl_pci.h | 8 +++++
2 files changed, 78 insertions(+), 1 deletions(-)
diff --git a/arch/powerpc/sysdev/fsl_pci.c b/arch/powerpc/sysdev/fsl_pci.c
index 6073288..fcc9370 100644
--- a/arch/powerpc/sysdev/fsl_pci.c
+++ b/arch/powerpc/sysdev/fsl_pci.c
@@ -1,7 +1,7 @@
/*
* MPC83xx/85xx/86xx PCI/PCIE support routing.
*
- * Copyright 2007-2011 Freescale Semiconductor, Inc.
+ * Copyright 2007-2012 Freescale Semiconductor, Inc.
* Copyright 2008-2009 MontaVista Software, Inc.
*
* Initial author: Xianghua Xiao <x.xiao@freescale.com>
@@ -807,3 +807,72 @@ u64 fsl_pci_immrbar_base(struct pci_controller *hose)
return 0;
}
+
+#if defined(CONFIG_FSL_SOC_BOOKE) || defined(CONFIG_PPC_86xx)
+static const struct of_device_id pci_ids[] = {
+ { .compatible = "fsl,mpc8540-pci", },
+ { .compatible = "fsl,mpc8548-pcie", },
+ { .compatible = "fsl,mpc8610-pci", },
+ { .compatible = "fsl,mpc8641-pcie", },
+ { .compatible = "fsl,p1022-pcie", },
+ { .compatible = "fsl,p1010-pcie", },
+ { .compatible = "fsl,p1023-pcie", },
+ { .compatible = "fsl,p4080-pcie", },
+ { .compatible = "fsl,qoriq-pcie-v2.3", },
+ { .compatible = "fsl,qoriq-pcie-v2.2", },
+ {},
+};
+
+struct device_node *fsl_pci_primary;
+
+void __devinit fsl_pci_init(void)
+{
+ struct device_node *node;
+ struct pci_controller *hose;
+ dma_addr_t max = 0xffffffff;
+
+ /* Callers can specify the primary bus using other means. */
+ if (!fsl_pci_primary) {
+ /* If a PCI host bridge contains an ISA node, it's primary. */
+ node = of_find_node_by_type(NULL, "isa");
+ while ((fsl_pci_primary = of_get_parent(node))) {
+ of_node_put(node);
+ node = fsl_pci_primary;
+
+ if (of_match_node(pci_ids, node))
+ break;
+ }
+ }
+
+ node = NULL;
+ for_each_node_by_type(node, "pci") {
+ if (of_match_node(pci_ids, node)) {
+ /*
+ * If there's no PCI host bridge with ISA, arbitrarily
+ * designate one as primary. This can go away once
+ * various bugs with primary-less systems are fixed.
+ */
+ if (!fsl_pci_primary)
+ fsl_pci_primary = node;
+
+ fsl_add_bridge(node, fsl_pci_primary == node);
+ hose = pci_find_hose_for_OF_device(node);
+ max = min(max, hose->dma_window_base_cur +
+ hose->dma_window_size);
+ }
+ }
+
+#ifdef CONFIG_SWIOTLB
+ /*
+ * if we couldn't map all of DRAM via the dma windows
+ * we need SWIOTLB to handle buffers located outside of
+ * dma capable memory region
+ */
+ if (memblock_end_of_DRAM() - 1 > max) {
+ ppc_swiotlb_enable = 1;
+ set_pci_dma_ops(&swiotlb_dma_ops);
+ ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
+ }
+#endif
+}
+#endif
diff --git a/arch/powerpc/sysdev/fsl_pci.h b/arch/powerpc/sysdev/fsl_pci.h
index a39ed5c..baa0fd1 100644
--- a/arch/powerpc/sysdev/fsl_pci.h
+++ b/arch/powerpc/sysdev/fsl_pci.h
@@ -93,5 +93,13 @@ extern void fsl_pcibios_fixup_bus(struct pci_bus *bus);
extern int mpc83xx_add_bridge(struct device_node *dev);
u64 fsl_pci_immrbar_base(struct pci_controller *hose);
+extern struct device_node *fsl_pci_primary;
+
+#ifdef CONFIG_FSL_PCI
+void fsl_pci_init(void);
+#else
+static inline void fsl_pci_init(void) {}
+#endif
+
#endif /* __POWERPC_FSL_PCI_H */
#endif /* __KERNEL__ */
--
1.7.5.4
^ permalink raw reply related
* [git pull] Please pull powerpc.git merge branch
From: Benjamin Herrenschmidt @ 2012-06-29 20:45 UTC (permalink / raw)
To: Linus Torvalds; +Cc: linuxppc-dev list, Andrew Morton, Linux Kernel list
Hi Linus !
Here are a few powerpc fixes. Arguably some of this should have come to
you earlier but I'm only just catching up after my medical leave.
Mostly these fixes regressions, a couple are long standing bugs.
Cheers,
Ben.
The following changes since commit 9acc7bde23ebb19a704395f76490685e1513e422:
Merge tag 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging (2012-06-28 12:38:51 -0700)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc.git merge
for you to fetch changes up to bc6dc752f35488160ffac07ae91bed1bddaea32a:
powerpc/pseries: Fix software invalidate TCE (2012-06-29 14:35:37 +1000)
----------------------------------------------------------------
Anton Blanchard (1):
powerpc: check_and_cede_processor() never cedes
Li Zhong (1):
powerpc: Fix Section mismatch warnings in prom_init.c
Michael Ellerman (1):
powerpc: Fix BPF_JIT code to link with multiple TOCs
Michael Neuling (2):
powerpc: Fix uninitialised error in numa.c
powerpc/pseries: Fix software invalidate TCE
Steven Rostedt (1):
powerpc/ftrace: Do not trace restore_interrupts()
Tiejun Chen (1):
ppc64: fix missing to check all bits of _TIF_USER_WORK_MASK in preempt
arch/powerpc/include/asm/hw_irq.h | 5 ++
arch/powerpc/kernel/entry_64.S | 97 ++++++++++-------------
arch/powerpc/kernel/irq.c | 2 +-
arch/powerpc/kernel/prom_init.c | 4 +-
arch/powerpc/mm/numa.c | 2 +-
arch/powerpc/net/bpf_jit_64.S | 2 +
arch/powerpc/platforms/pseries/iommu.c | 4 +-
arch/powerpc/platforms/pseries/processor_idle.c | 2 +-
8 files changed, 54 insertions(+), 64 deletions(-)
^ permalink raw reply
* Re: [PATCH -V1 2/9] arch/powerpc: Convert virtual address to a struct
From: Benjamin Herrenschmidt @ 2012-06-29 21:43 UTC (permalink / raw)
To: Aneesh Kumar K.V; +Cc: linuxppc-dev, paulus, anton
In-Reply-To: <1340979457-26018-3-git-send-email-aneesh.kumar@linux.vnet.ibm.com>
On Fri, 2012-06-29 at 19:47 +0530, Aneesh Kumar K.V wrote:
> From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
>
> This is in preparation to the conversion of 64 bit powerpc virtual address
> to the max 78 bits. Later patch will switch struct virt_addr to a struct
> of virtual segment id and segment offset.
I'm not to happy about that.
Mostly, the name of the structure. It's too "generic" and thus likely to
both collide and cause misunderstandings. Do we really need that
anyways ?
Can't we just replace our use of va's everywhere with vpn's instead and
just avoid the type change ?
Cheers,
Ben.
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
> ---
> arch/powerpc/include/asm/kvm_book3s.h | 2 +-
> arch/powerpc/include/asm/machdep.h | 6 +--
> arch/powerpc/include/asm/mmu-hash64.h | 24 ++++++----
> arch/powerpc/include/asm/tlbflush.h | 4 +-
> arch/powerpc/kvm/book3s_64_mmu_host.c | 3 +-
> arch/powerpc/mm/hash_native_64.c | 76 +++++++++++++++++--------------
> arch/powerpc/mm/hash_utils_64.c | 12 ++---
> arch/powerpc/mm/hugetlbpage-hash64.c | 3 +-
> arch/powerpc/mm/tlb_hash64.c | 3 +-
> arch/powerpc/platforms/cell/beat_htab.c | 17 +++----
> arch/powerpc/platforms/ps3/htab.c | 6 +--
> arch/powerpc/platforms/pseries/lpar.c | 30 ++++++------
> 12 files changed, 103 insertions(+), 83 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/kvm_book3s.h b/arch/powerpc/include/asm/kvm_book3s.h
> index fd07f43..374b75d 100644
> --- a/arch/powerpc/include/asm/kvm_book3s.h
> +++ b/arch/powerpc/include/asm/kvm_book3s.h
> @@ -59,7 +59,7 @@ struct hpte_cache {
> struct hlist_node list_vpte;
> struct hlist_node list_vpte_long;
> struct rcu_head rcu_head;
> - u64 host_va;
> + struct virt_addr host_va;
> u64 pfn;
> ulong slot;
> struct kvmppc_pte pte;
> diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h
> index 42ce570..b34d0a9 100644
> --- a/arch/powerpc/include/asm/machdep.h
> +++ b/arch/powerpc/include/asm/machdep.h
> @@ -34,19 +34,19 @@ struct machdep_calls {
> char *name;
> #ifdef CONFIG_PPC64
> void (*hpte_invalidate)(unsigned long slot,
> - unsigned long va,
> + struct virt_addr va,
> int psize, int ssize,
> int local);
> long (*hpte_updatepp)(unsigned long slot,
> unsigned long newpp,
> - unsigned long va,
> + struct virt_addr va,
> int psize, int ssize,
> int local);
> void (*hpte_updateboltedpp)(unsigned long newpp,
> unsigned long ea,
> int psize, int ssize);
> long (*hpte_insert)(unsigned long hpte_group,
> - unsigned long va,
> + struct virt_addr va,
> unsigned long prpn,
> unsigned long rflags,
> unsigned long vflags,
> diff --git a/arch/powerpc/include/asm/mmu-hash64.h b/arch/powerpc/include/asm/mmu-hash64.h
> index 1c65a59..5ff936b 100644
> --- a/arch/powerpc/include/asm/mmu-hash64.h
> +++ b/arch/powerpc/include/asm/mmu-hash64.h
> @@ -143,6 +143,10 @@ struct mmu_psize_def
> unsigned long sllp; /* SLB L||LP (exact mask to use in slbmte) */
> };
>
> +struct virt_addr {
> + unsigned long addr;
> +};
> +
> #endif /* __ASSEMBLY__ */
>
> /*
> @@ -183,11 +187,11 @@ extern int mmu_ci_restrictions;
> * This function sets the AVPN and L fields of the HPTE appropriately
> * for the page size
> */
> -static inline unsigned long hpte_encode_v(unsigned long va, int psize,
> +static inline unsigned long hpte_encode_v(struct virt_addr va, int psize,
> int ssize)
> {
> unsigned long v;
> - v = (va >> 23) & ~(mmu_psize_defs[psize].avpnm);
> + v = (va.addr >> 23) & ~(mmu_psize_defs[psize].avpnm);
> v <<= HPTE_V_AVPN_SHIFT;
> if (psize != MMU_PAGE_4K)
> v |= HPTE_V_LARGE;
> @@ -218,28 +222,30 @@ static inline unsigned long hpte_encode_r(unsigned long pa, int psize)
> /*
> * Build a VA given VSID, EA and segment size
> */
> -static inline unsigned long hpt_va(unsigned long ea, unsigned long vsid,
> +static inline struct virt_addr hpt_va(unsigned long ea, unsigned long vsid,
> int ssize)
> {
> + struct virt_addr va;
> if (ssize == MMU_SEGSIZE_256M)
> - return (vsid << 28) | (ea & 0xfffffffUL);
> - return (vsid << 40) | (ea & 0xffffffffffUL);
> + va.addr = (vsid << 28) | (ea & 0xfffffffUL);
> + va.addr = (vsid << 40) | (ea & 0xffffffffffUL);
> + return va;
> }
>
> /*
> * This hashes a virtual address
> */
>
> -static inline unsigned long hpt_hash(unsigned long va, unsigned int shift,
> +static inline unsigned long hpt_hash(struct virt_addr va, unsigned int shift,
> int ssize)
> {
> unsigned long hash, vsid;
>
> if (ssize == MMU_SEGSIZE_256M) {
> - hash = (va >> 28) ^ ((va & 0x0fffffffUL) >> shift);
> + hash = (va.addr >> 28) ^ ((va.addr & 0x0fffffffUL) >> shift);
> } else {
> - vsid = va >> 40;
> - hash = vsid ^ (vsid << 25) ^ ((va & 0xffffffffffUL) >> shift);
> + vsid = va.addr >> 40;
> + hash = vsid ^ (vsid << 25) ^ ((va.addr & 0xffffffffffUL) >> shift);
> }
> return hash & 0x7fffffffffUL;
> }
> diff --git a/arch/powerpc/include/asm/tlbflush.h b/arch/powerpc/include/asm/tlbflush.h
> index 81143fc..2c8ad50 100644
> --- a/arch/powerpc/include/asm/tlbflush.h
> +++ b/arch/powerpc/include/asm/tlbflush.h
> @@ -95,7 +95,7 @@ struct ppc64_tlb_batch {
> unsigned long index;
> struct mm_struct *mm;
> real_pte_t pte[PPC64_TLB_BATCH_NR];
> - unsigned long vaddr[PPC64_TLB_BATCH_NR];
> + struct virt_addr vaddr[PPC64_TLB_BATCH_NR];
> unsigned int psize;
> int ssize;
> };
> @@ -127,7 +127,7 @@ static inline void arch_leave_lazy_mmu_mode(void)
> #define arch_flush_lazy_mmu_mode() do {} while (0)
>
>
> -extern void flush_hash_page(unsigned long va, real_pte_t pte, int psize,
> +extern void flush_hash_page(struct virt_addr va, real_pte_t pte, int psize,
> int ssize, int local);
> extern void flush_hash_range(unsigned long number, int local);
>
> diff --git a/arch/powerpc/kvm/book3s_64_mmu_host.c b/arch/powerpc/kvm/book3s_64_mmu_host.c
> index 10fc8ec..933b117 100644
> --- a/arch/powerpc/kvm/book3s_64_mmu_host.c
> +++ b/arch/powerpc/kvm/book3s_64_mmu_host.c
> @@ -80,8 +80,9 @@ static struct kvmppc_sid_map *find_sid_vsid(struct kvm_vcpu *vcpu, u64 gvsid)
>
> int kvmppc_mmu_map_page(struct kvm_vcpu *vcpu, struct kvmppc_pte *orig_pte)
> {
> + struct virt_addr va;
> pfn_t hpaddr;
> - ulong hash, hpteg, va;
> + ulong hash, hpteg;
> u64 vsid;
> int ret;
> int rflags = 0x192;
> diff --git a/arch/powerpc/mm/hash_native_64.c b/arch/powerpc/mm/hash_native_64.c
> index 90039bc..cab3892 100644
> --- a/arch/powerpc/mm/hash_native_64.c
> +++ b/arch/powerpc/mm/hash_native_64.c
> @@ -39,62 +39,67 @@
>
> DEFINE_RAW_SPINLOCK(native_tlbie_lock);
>
> -static inline void __tlbie(unsigned long va, int psize, int ssize)
> +/* Verify docs says 14 .. 14+i bits */
> +static inline void __tlbie(struct virt_addr va, int psize, int ssize)
> {
> + unsigned long vaddr = va.addr;
> unsigned int penc;
>
> + vaddr &= ~(0xffffULL << 48);
> +
> /* clear top 16 bits, non SLS segment */
> - va &= ~(0xffffULL << 48);
> + vaddr &= ~(0xffffULL << 48);
>
> switch (psize) {
> case MMU_PAGE_4K:
> - va &= ~0xffful;
> - va |= ssize << 8;
> + vaddr &= ~0xffful;
> + vaddr |= ssize << 8;
> asm volatile(ASM_FTR_IFCLR("tlbie %0,0", PPC_TLBIE(%1,%0), %2)
> - : : "r" (va), "r"(0), "i" (CPU_FTR_ARCH_206)
> + : : "r" (vaddr), "r"(0), "i" (CPU_FTR_ARCH_206)
> : "memory");
> break;
> default:
> penc = mmu_psize_defs[psize].penc;
> - va &= ~((1ul << mmu_psize_defs[psize].shift) - 1);
> - va |= penc << 12;
> - va |= ssize << 8;
> - va |= 1; /* L */
> + vaddr &= ~((1ul << mmu_psize_defs[psize].shift) - 1);
> + vaddr |= penc << 12;
> + vaddr |= ssize << 8;
> + vaddr |= 1; /* L */
> asm volatile(ASM_FTR_IFCLR("tlbie %0,1", PPC_TLBIE(%1,%0), %2)
> - : : "r" (va), "r"(0), "i" (CPU_FTR_ARCH_206)
> + : : "r" (vaddr), "r"(0), "i" (CPU_FTR_ARCH_206)
> : "memory");
> break;
> }
> }
>
> -static inline void __tlbiel(unsigned long va, int psize, int ssize)
> +/* Verify docs says 14 .. 14+i bits */
> +static inline void __tlbiel(struct virt_addr va, int psize, int ssize)
> {
> + unsigned long vaddr = va.addr;
> unsigned int penc;
>
> - /* clear top 16 bits, non SLS segment */
> - va &= ~(0xffffULL << 48);
> + vaddr &= ~(0xffffULL << 48);
>
> switch (psize) {
> case MMU_PAGE_4K:
> - va &= ~0xffful;
> - va |= ssize << 8;
> + vaddr &= ~0xffful;
> + vaddr |= ssize << 8;
> asm volatile(".long 0x7c000224 | (%0 << 11) | (0 << 21)"
> - : : "r"(va) : "memory");
> + : : "r"(vaddr) : "memory");
> break;
> default:
> penc = mmu_psize_defs[psize].penc;
> - va &= ~((1ul << mmu_psize_defs[psize].shift) - 1);
> - va |= penc << 12;
> - va |= ssize << 8;
> - va |= 1; /* L */
> + vaddr &= ~((1ul << mmu_psize_defs[psize].shift) - 1);
> + vaddr |= penc << 12;
> + vaddr |= ssize << 8;
> + vaddr |= 1; /* L */
> asm volatile(".long 0x7c000224 | (%0 << 11) | (1 << 21)"
> - : : "r"(va) : "memory");
> + : : "r"(vaddr) : "memory");
> break;
> }
>
> }
>
> -static inline void tlbie(unsigned long va, int psize, int ssize, int local)
> +static inline void tlbie(struct virt_addr va, int psize, int ssize, int local)
> {
> unsigned int use_local = local && mmu_has_feature(MMU_FTR_TLBIEL);
> int lock_tlbie = !mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE);
> @@ -134,7 +139,7 @@ static inline void native_unlock_hpte(struct hash_pte *hptep)
> clear_bit_unlock(HPTE_LOCK_BIT, word);
> }
>
> -static long native_hpte_insert(unsigned long hpte_group, unsigned long va,
> +static long native_hpte_insert(unsigned long hpte_group, struct virt_addr va,
> unsigned long pa, unsigned long rflags,
> unsigned long vflags, int psize, int ssize)
> {
> @@ -225,7 +230,7 @@ static long native_hpte_remove(unsigned long hpte_group)
> }
>
> static long native_hpte_updatepp(unsigned long slot, unsigned long newpp,
> - unsigned long va, int psize, int ssize,
> + struct virt_addr va, int psize, int ssize,
> int local)
> {
> struct hash_pte *hptep = htab_address + slot;
> @@ -259,7 +264,7 @@ static long native_hpte_updatepp(unsigned long slot, unsigned long newpp,
> return ret;
> }
>
> -static long native_hpte_find(unsigned long va, int psize, int ssize)
> +static long native_hpte_find(struct virt_addr va, int psize, int ssize)
> {
> struct hash_pte *hptep;
> unsigned long hash;
> @@ -295,7 +300,8 @@ static long native_hpte_find(unsigned long va, int psize, int ssize)
> static void native_hpte_updateboltedpp(unsigned long newpp, unsigned long ea,
> int psize, int ssize)
> {
> - unsigned long vsid, va;
> + struct virt_addr va;
> + unsigned long vsid;
> long slot;
> struct hash_pte *hptep;
>
> @@ -315,7 +321,7 @@ static void native_hpte_updateboltedpp(unsigned long newpp, unsigned long ea,
> tlbie(va, psize, ssize, 0);
> }
>
> -static void native_hpte_invalidate(unsigned long slot, unsigned long va,
> +static void native_hpte_invalidate(unsigned long slot, struct virt_addr va,
> int psize, int ssize, int local)
> {
> struct hash_pte *hptep = htab_address + slot;
> @@ -349,7 +355,7 @@ static void native_hpte_invalidate(unsigned long slot, unsigned long va,
> #define LP_MASK(i) ((0xFF >> (i)) << LP_SHIFT)
>
> static void hpte_decode(struct hash_pte *hpte, unsigned long slot,
> - int *psize, int *ssize, unsigned long *va)
> + int *psize, int *ssize, struct virt_addr *va)
> {
> unsigned long hpte_r = hpte->r;
> unsigned long hpte_v = hpte->v;
> @@ -403,7 +409,7 @@ static void hpte_decode(struct hash_pte *hpte, unsigned long slot,
> avpn |= (vpi << mmu_psize_defs[size].shift);
> }
>
> - *va = avpn;
> + va->addr = avpn;
> *psize = size;
> *ssize = hpte_v >> HPTE_V_SSIZE_SHIFT;
> }
> @@ -418,9 +424,10 @@ static void hpte_decode(struct hash_pte *hpte, unsigned long slot,
> */
> static void native_hpte_clear(void)
> {
> + struct virt_addr va;
> unsigned long slot, slots, flags;
> struct hash_pte *hptep = htab_address;
> - unsigned long hpte_v, va;
> + unsigned long hpte_v;
> unsigned long pteg_count;
> int psize, ssize;
>
> @@ -465,7 +472,8 @@ static void native_hpte_clear(void)
> */
> static void native_flush_hash_range(unsigned long number, int local)
> {
> - unsigned long va, hash, index, hidx, shift, slot;
> + struct virt_addr va;
> + unsigned long hash, index, hidx, shift, slot;
> struct hash_pte *hptep;
> unsigned long hpte_v;
> unsigned long want_v;
> @@ -482,7 +490,7 @@ static void native_flush_hash_range(unsigned long number, int local)
> va = batch->vaddr[i];
> pte = batch->pte[i];
>
> - pte_iterate_hashed_subpages(pte, psize, va, index, shift) {
> + pte_iterate_hashed_subpages(pte, psize, va.addr, index, shift) {
> hash = hpt_hash(va, shift, ssize);
> hidx = __rpte_to_hidx(pte, index);
> if (hidx & _PTEIDX_SECONDARY)
> @@ -508,7 +516,7 @@ static void native_flush_hash_range(unsigned long number, int local)
> va = batch->vaddr[i];
> pte = batch->pte[i];
>
> - pte_iterate_hashed_subpages(pte, psize, va, index,
> + pte_iterate_hashed_subpages(pte, psize, va.addr, index,
> shift) {
> __tlbiel(va, psize, ssize);
> } pte_iterate_hashed_end();
> @@ -525,7 +533,7 @@ static void native_flush_hash_range(unsigned long number, int local)
> va = batch->vaddr[i];
> pte = batch->pte[i];
>
> - pte_iterate_hashed_subpages(pte, psize, va, index,
> + pte_iterate_hashed_subpages(pte, psize, va.addr, index,
> shift) {
> __tlbie(va, psize, ssize);
> } pte_iterate_hashed_end();
> diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c
> index 377e5cb..2429d53 100644
> --- a/arch/powerpc/mm/hash_utils_64.c
> +++ b/arch/powerpc/mm/hash_utils_64.c
> @@ -192,7 +192,7 @@ int htab_bolt_mapping(unsigned long vstart, unsigned long vend,
> vaddr += step, paddr += step) {
> unsigned long hash, hpteg;
> unsigned long vsid = get_kernel_vsid(vaddr, ssize);
> - unsigned long va = hpt_va(vaddr, vsid, ssize);
> + struct virt_addr va = hpt_va(vaddr, vsid, ssize);
> unsigned long tprot = prot;
>
> /* Make kernel text executable */
> @@ -1153,13 +1153,13 @@ void hash_preload(struct mm_struct *mm, unsigned long ea,
> /* WARNING: This is called from hash_low_64.S, if you change this prototype,
> * do not forget to update the assembly call site !
> */
> -void flush_hash_page(unsigned long va, real_pte_t pte, int psize, int ssize,
> +void flush_hash_page(struct virt_addr va, real_pte_t pte, int psize, int ssize,
> int local)
> {
> unsigned long hash, index, shift, hidx, slot;
>
> - DBG_LOW("flush_hash_page(va=%016lx)\n", va);
> - pte_iterate_hashed_subpages(pte, psize, va, index, shift) {
> + DBG_LOW("flush_hash_page(va=%016lx)\n", va.addr);
> + pte_iterate_hashed_subpages(pte, psize, va.addr, index, shift) {
> hash = hpt_hash(va, shift, ssize);
> hidx = __rpte_to_hidx(pte, index);
> if (hidx & _PTEIDX_SECONDARY)
> @@ -1208,7 +1208,7 @@ static void kernel_map_linear_page(unsigned long vaddr, unsigned long lmi)
> {
> unsigned long hash, hpteg;
> unsigned long vsid = get_kernel_vsid(vaddr, mmu_kernel_ssize);
> - unsigned long va = hpt_va(vaddr, vsid, mmu_kernel_ssize);
> + struct virt_addr va = hpt_va(vaddr, vsid, mmu_kernel_ssize);
> unsigned long mode = htab_convert_pte_flags(PAGE_KERNEL);
> int ret;
>
> @@ -1229,7 +1229,7 @@ static void kernel_unmap_linear_page(unsigned long vaddr, unsigned long lmi)
> {
> unsigned long hash, hidx, slot;
> unsigned long vsid = get_kernel_vsid(vaddr, mmu_kernel_ssize);
> - unsigned long va = hpt_va(vaddr, vsid, mmu_kernel_ssize);
> + struct virt_addr va = hpt_va(vaddr, vsid, mmu_kernel_ssize);
>
> hash = hpt_hash(va, PAGE_SHIFT, mmu_kernel_ssize);
> spin_lock(&linear_map_hash_lock);
> diff --git a/arch/powerpc/mm/hugetlbpage-hash64.c b/arch/powerpc/mm/hugetlbpage-hash64.c
> index cc5c273..47b4ed0 100644
> --- a/arch/powerpc/mm/hugetlbpage-hash64.c
> +++ b/arch/powerpc/mm/hugetlbpage-hash64.c
> @@ -18,8 +18,9 @@ int __hash_page_huge(unsigned long ea, unsigned long access, unsigned long vsid,
> pte_t *ptep, unsigned long trap, int local, int ssize,
> unsigned int shift, unsigned int mmu_psize)
> {
> + struct virt_addr va;
> unsigned long old_pte, new_pte;
> - unsigned long va, rflags, pa, sz;
> + unsigned long rflags, pa, sz;
> long slot;
>
> BUG_ON(shift != mmu_psize_defs[mmu_psize].shift);
> diff --git a/arch/powerpc/mm/tlb_hash64.c b/arch/powerpc/mm/tlb_hash64.c
> index 31f1820..b830466 100644
> --- a/arch/powerpc/mm/tlb_hash64.c
> +++ b/arch/powerpc/mm/tlb_hash64.c
> @@ -42,8 +42,9 @@ DEFINE_PER_CPU(struct ppc64_tlb_batch, ppc64_tlb_batch);
> void hpte_need_flush(struct mm_struct *mm, unsigned long addr,
> pte_t *ptep, unsigned long pte, int huge)
> {
> + struct virt_addr vaddr;
> struct ppc64_tlb_batch *batch = &get_cpu_var(ppc64_tlb_batch);
> - unsigned long vsid, vaddr;
> + unsigned long vsid;
> unsigned int psize;
> int ssize;
> real_pte_t rpte;
> diff --git a/arch/powerpc/platforms/cell/beat_htab.c b/arch/powerpc/platforms/cell/beat_htab.c
> index b83077e..a2dfc22 100644
> --- a/arch/powerpc/platforms/cell/beat_htab.c
> +++ b/arch/powerpc/platforms/cell/beat_htab.c
> @@ -88,7 +88,7 @@ static inline unsigned int beat_read_mask(unsigned hpte_group)
> }
>
> static long beat_lpar_hpte_insert(unsigned long hpte_group,
> - unsigned long va, unsigned long pa,
> + struct virt_addr va, unsigned long pa,
> unsigned long rflags, unsigned long vflags,
> int psize, int ssize)
> {
> @@ -184,7 +184,7 @@ static void beat_lpar_hptab_clear(void)
> */
> static long beat_lpar_hpte_updatepp(unsigned long slot,
> unsigned long newpp,
> - unsigned long va,
> + struct virt_addr va,
> int psize, int ssize, int local)
> {
> unsigned long lpar_rc;
> @@ -220,7 +220,7 @@ static long beat_lpar_hpte_updatepp(unsigned long slot,
> return 0;
> }
>
> -static long beat_lpar_hpte_find(unsigned long va, int psize)
> +static long beat_lpar_hpte_find(struct virt_addr va, int psize)
> {
> unsigned long hash;
> unsigned long i, j;
> @@ -255,7 +255,8 @@ static void beat_lpar_hpte_updateboltedpp(unsigned long newpp,
> unsigned long ea,
> int psize, int ssize)
> {
> - unsigned long lpar_rc, slot, vsid, va;
> + struct virt_addr va;
> + unsigned long lpar_rc, slot, vsid;
> u64 dummy0, dummy1;
>
> vsid = get_kernel_vsid(ea, MMU_SEGSIZE_256M);
> @@ -272,7 +273,7 @@ static void beat_lpar_hpte_updateboltedpp(unsigned long newpp,
> BUG_ON(lpar_rc != 0);
> }
>
> -static void beat_lpar_hpte_invalidate(unsigned long slot, unsigned long va,
> +static void beat_lpar_hpte_invalidate(unsigned long slot, struct virt_addr va,
> int psize, int ssize, int local)
> {
> unsigned long want_v;
> @@ -311,7 +312,7 @@ void __init hpte_init_beat(void)
> }
>
> static long beat_lpar_hpte_insert_v3(unsigned long hpte_group,
> - unsigned long va, unsigned long pa,
> + struct virt_addr va, unsigned long pa,
> unsigned long rflags, unsigned long vflags,
> int psize, int ssize)
> {
> @@ -364,7 +365,7 @@ static long beat_lpar_hpte_insert_v3(unsigned long hpte_group,
> */
> static long beat_lpar_hpte_updatepp_v3(unsigned long slot,
> unsigned long newpp,
> - unsigned long va,
> + struct virt_addr va,
> int psize, int ssize, int local)
> {
> unsigned long lpar_rc;
> @@ -392,7 +393,7 @@ static long beat_lpar_hpte_updatepp_v3(unsigned long slot,
> return 0;
> }
>
> -static void beat_lpar_hpte_invalidate_v3(unsigned long slot, unsigned long va,
> +static void beat_lpar_hpte_invalidate_v3(unsigned long slot, struct virt_addr va,
> int psize, int ssize, int local)
> {
> unsigned long want_v;
> diff --git a/arch/powerpc/platforms/ps3/htab.c b/arch/powerpc/platforms/ps3/htab.c
> index 3124cf7..6e27576 100644
> --- a/arch/powerpc/platforms/ps3/htab.c
> +++ b/arch/powerpc/platforms/ps3/htab.c
> @@ -43,7 +43,7 @@ enum ps3_lpar_vas_id {
>
> static DEFINE_SPINLOCK(ps3_htab_lock);
>
> -static long ps3_hpte_insert(unsigned long hpte_group, unsigned long va,
> +static long ps3_hpte_insert(unsigned long hpte_group, struct virt_addr va,
> unsigned long pa, unsigned long rflags, unsigned long vflags,
> int psize, int ssize)
> {
> @@ -107,7 +107,7 @@ static long ps3_hpte_remove(unsigned long hpte_group)
> }
>
> static long ps3_hpte_updatepp(unsigned long slot, unsigned long newpp,
> - unsigned long va, int psize, int ssize, int local)
> + struct virt_addr va, int psize, int ssize, int local)
> {
> int result;
> u64 hpte_v, want_v, hpte_rs;
> @@ -159,7 +159,7 @@ static void ps3_hpte_updateboltedpp(unsigned long newpp, unsigned long ea,
> panic("ps3_hpte_updateboltedpp() not implemented");
> }
>
> -static void ps3_hpte_invalidate(unsigned long slot, unsigned long va,
> +static void ps3_hpte_invalidate(unsigned long slot, struct virt_addr va,
> int psize, int ssize, int local)
> {
> unsigned long flags;
> diff --git a/arch/powerpc/platforms/pseries/lpar.c b/arch/powerpc/platforms/pseries/lpar.c
> index 5f3ef87..b4e9641 100644
> --- a/arch/powerpc/platforms/pseries/lpar.c
> +++ b/arch/powerpc/platforms/pseries/lpar.c
> @@ -108,9 +108,9 @@ void vpa_init(int cpu)
> }
>
> static long pSeries_lpar_hpte_insert(unsigned long hpte_group,
> - unsigned long va, unsigned long pa,
> - unsigned long rflags, unsigned long vflags,
> - int psize, int ssize)
> + struct virt_addr va, unsigned long pa,
> + unsigned long rflags, unsigned long vflags,
> + int psize, int ssize)
> {
> unsigned long lpar_rc;
> unsigned long flags;
> @@ -120,7 +120,7 @@ static long pSeries_lpar_hpte_insert(unsigned long hpte_group,
> if (!(vflags & HPTE_V_BOLTED))
> pr_devel("hpte_insert(group=%lx, va=%016lx, pa=%016lx, "
> "rflags=%lx, vflags=%lx, psize=%d)\n",
> - hpte_group, va, pa, rflags, vflags, psize);
> + hpte_group, va.addr, pa, rflags, vflags, psize);
>
> hpte_v = hpte_encode_v(va, psize, ssize) | vflags | HPTE_V_VALID;
> hpte_r = hpte_encode_r(pa, psize) | rflags;
> @@ -231,12 +231,12 @@ static void pSeries_lpar_hptab_clear(void)
> * for use when we want to match an existing PTE. The bottom 7 bits
> * of the returned value are zero.
> */
> -static inline unsigned long hpte_encode_avpn(unsigned long va, int psize,
> +static inline unsigned long hpte_encode_avpn(struct virt_addr va, int psize,
> int ssize)
> {
> unsigned long v;
>
> - v = (va >> 23) & ~(mmu_psize_defs[psize].avpnm);
> + v = (va.addr >> 23) & ~(mmu_psize_defs[psize].avpnm);
> v <<= HPTE_V_AVPN_SHIFT;
> v |= ((unsigned long) ssize) << HPTE_V_SSIZE_SHIFT;
> return v;
> @@ -250,7 +250,7 @@ static inline unsigned long hpte_encode_avpn(unsigned long va, int psize,
> */
> static long pSeries_lpar_hpte_updatepp(unsigned long slot,
> unsigned long newpp,
> - unsigned long va,
> + struct virt_addr va,
> int psize, int ssize, int local)
> {
> unsigned long lpar_rc;
> @@ -295,7 +295,7 @@ static unsigned long pSeries_lpar_hpte_getword0(unsigned long slot)
> return dword0;
> }
>
> -static long pSeries_lpar_hpte_find(unsigned long va, int psize, int ssize)
> +static long pSeries_lpar_hpte_find(struct virt_addr va, int psize, int ssize)
> {
> unsigned long hash;
> unsigned long i;
> @@ -323,7 +323,8 @@ static void pSeries_lpar_hpte_updateboltedpp(unsigned long newpp,
> unsigned long ea,
> int psize, int ssize)
> {
> - unsigned long lpar_rc, slot, vsid, va, flags;
> + struct virt_addr va;
> + unsigned long lpar_rc, slot, vsid, flags;
>
> vsid = get_kernel_vsid(ea, ssize);
> va = hpt_va(ea, vsid, ssize);
> @@ -337,7 +338,7 @@ static void pSeries_lpar_hpte_updateboltedpp(unsigned long newpp,
> BUG_ON(lpar_rc != H_SUCCESS);
> }
>
> -static void pSeries_lpar_hpte_invalidate(unsigned long slot, unsigned long va,
> +static void pSeries_lpar_hpte_invalidate(unsigned long slot, struct virt_addr va,
> int psize, int ssize, int local)
> {
> unsigned long want_v;
> @@ -345,7 +346,7 @@ static void pSeries_lpar_hpte_invalidate(unsigned long slot, unsigned long va,
> unsigned long dummy1, dummy2;
>
> pr_devel(" inval : slot=%lx, va=%016lx, psize: %d, local: %d\n",
> - slot, va, psize, local);
> + slot, va.addr, psize, local);
>
> want_v = hpte_encode_avpn(va, psize, ssize);
> lpar_rc = plpar_pte_remove(H_AVPN, slot, want_v, &dummy1, &dummy2);
> @@ -358,7 +359,8 @@ static void pSeries_lpar_hpte_invalidate(unsigned long slot, unsigned long va,
> static void pSeries_lpar_hpte_removebolted(unsigned long ea,
> int psize, int ssize)
> {
> - unsigned long slot, vsid, va;
> + struct virt_addr va;
> + unsigned long slot, vsid;
>
> vsid = get_kernel_vsid(ea, ssize);
> va = hpt_va(ea, vsid, ssize);
> @@ -382,12 +384,12 @@ static void pSeries_lpar_hpte_removebolted(unsigned long ea,
> */
> static void pSeries_lpar_flush_hash_range(unsigned long number, int local)
> {
> + struct virt_addr va;
> unsigned long i, pix, rc;
> unsigned long flags = 0;
> struct ppc64_tlb_batch *batch = &__get_cpu_var(ppc64_tlb_batch);
> int lock_tlbie = !mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE);
> unsigned long param[9];
> - unsigned long va;
> unsigned long hash, index, shift, hidx, slot;
> real_pte_t pte;
> int psize, ssize;
> @@ -401,7 +403,7 @@ static void pSeries_lpar_flush_hash_range(unsigned long number, int local)
> for (i = 0; i < number; i++) {
> va = batch->vaddr[i];
> pte = batch->pte[i];
> - pte_iterate_hashed_subpages(pte, psize, va, index, shift) {
> + pte_iterate_hashed_subpages(pte, psize, va.addr, index, shift) {
> hash = hpt_hash(va, shift, ssize);
> hidx = __rpte_to_hidx(pte, index);
> if (hidx & _PTEIDX_SECONDARY)
^ permalink raw reply
* Re: [PATCH -V1 4/9] arch/powerpc: Use vsid and segment offset to represent virtual address
From: Benjamin Herrenschmidt @ 2012-06-29 21:45 UTC (permalink / raw)
To: Aneesh Kumar K.V; +Cc: linuxppc-dev, paulus, anton
In-Reply-To: <1340979457-26018-5-git-send-email-aneesh.kumar@linux.vnet.ibm.com>
On Fri, 2012-06-29 at 19:47 +0530, Aneesh Kumar K.V wrote:
>
> +/* 78 bit power virtual address */
> struct virt_addr {
> - unsigned long addr;
> + unsigned long vsid;
> + unsigned long seg_off;
> };
Do we really need to do that ? It's really nasty...
We are trying to add only a few bits, we get 12 for free by just using a
page number (4k based always, not PAGE_SHIFT based btw) no ? That should
get us going for a while....
Cheers,
Ben.
^ permalink raw reply
* [PATCH -v5 5/6] powerpc: pSeries reconfig notifier error injection module
From: Akinobu Mita @ 2012-06-30 5:59 UTC (permalink / raw)
To: linux-kernel, akpm; +Cc: linuxppc-dev, Paul Mackerras, Akinobu Mita
In-Reply-To: <1341035970-20490-1-git-send-email-akinobu.mita@gmail.com>
This provides the ability to inject artifical errors to pSeries reconfig
notifier chain callbacks. It is controlled through debugfs interface
under /sys/kernel/debug/notifier-error-inject/pSeries-reconfig
If the notifier call chain should be failed with some events
notified, write the error code to "actions/<notifier event>/error".
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev@lists.ozlabs.org
---
No changes since v4
lib/Kconfig.debug | 17 +++++++++
lib/Makefile | 2 +
lib/pSeries-reconfig-notifier-error-inject.c | 51 ++++++++++++++++++++++++++
3 files changed, 70 insertions(+)
create mode 100644 lib/pSeries-reconfig-notifier-error-inject.c
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 7cceddc..8f8e226 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -1166,6 +1166,23 @@ config MEMORY_NOTIFIER_ERROR_INJECT
If unsure, say N.
+config PSERIES_RECONFIG_NOTIFIER_ERROR_INJECT
+ tristate "pSeries reconfig notifier error injection module"
+ depends on PPC_PSERIES && NOTIFIER_ERROR_INJECTION
+ help
+ This option provides the ability to inject artifical errors to
+ pSeries reconfig notifier chain callbacks. It is controlled
+ through debugfs interface under
+ /sys/kernel/debug/notifier-error-inject/pSeries-reconfig/
+
+ If the notifier call chain should be failed with some events
+ notified, write the error code to "actions/<notifier event>/error".
+
+ To compile this code as a module, choose M here: the module will
+ be called memory-notifier-error-inject.
+
+ If unsure, say N.
+
config FAULT_INJECTION
bool "Fault-injection framework"
depends on DEBUG_KERNEL
diff --git a/lib/Makefile b/lib/Makefile
index a867aa5..d055cb1 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -94,6 +94,8 @@ obj-$(CONFIG_NOTIFIER_ERROR_INJECTION) += notifier-error-inject.o
obj-$(CONFIG_CPU_NOTIFIER_ERROR_INJECT) += cpu-notifier-error-inject.o
obj-$(CONFIG_PM_NOTIFIER_ERROR_INJECT) += pm-notifier-error-inject.o
obj-$(CONFIG_MEMORY_NOTIFIER_ERROR_INJECT) += memory-notifier-error-inject.o
+obj-$(CONFIG_PSERIES_RECONFIG_NOTIFIER_ERROR_INJECT) += \
+ pSeries-reconfig-notifier-error-inject.o
lib-$(CONFIG_GENERIC_BUG) += bug.o
diff --git a/lib/pSeries-reconfig-notifier-error-inject.c b/lib/pSeries-reconfig-notifier-error-inject.c
new file mode 100644
index 0000000..7f7c98d
--- /dev/null
+++ b/lib/pSeries-reconfig-notifier-error-inject.c
@@ -0,0 +1,51 @@
+#include <linux/kernel.h>
+#include <linux/module.h>
+
+#include <asm/pSeries_reconfig.h>
+
+#include "notifier-error-inject.h"
+
+static int priority;
+module_param(priority, int, 0);
+MODULE_PARM_DESC(priority, "specify pSeries reconfig notifier priority");
+
+static struct notifier_err_inject reconfig_err_inject = {
+ .actions = {
+ { NOTIFIER_ERR_INJECT_ACTION(PSERIES_RECONFIG_ADD) },
+ { NOTIFIER_ERR_INJECT_ACTION(PSERIES_RECONFIG_REMOVE) },
+ { NOTIFIER_ERR_INJECT_ACTION(PSERIES_DRCONF_MEM_ADD) },
+ { NOTIFIER_ERR_INJECT_ACTION(PSERIES_DRCONF_MEM_REMOVE) },
+ {}
+ }
+};
+
+static struct dentry *dir;
+
+static int err_inject_init(void)
+{
+ int err;
+
+ dir = notifier_err_inject_init("pSeries-reconfig",
+ notifier_err_inject_dir, &reconfig_err_inject, priority);
+ if (IS_ERR(dir))
+ return PTR_ERR(dir);
+
+ err = pSeries_reconfig_notifier_register(&reconfig_err_inject.nb);
+ if (err)
+ debugfs_remove_recursive(dir);
+
+ return err;
+}
+
+static void err_inject_exit(void)
+{
+ pSeries_reconfig_notifier_unregister(&reconfig_err_inject.nb);
+ debugfs_remove_recursive(dir);
+}
+
+module_init(err_inject_init);
+module_exit(err_inject_exit);
+
+MODULE_DESCRIPTION("pSeries reconfig notifier error injection module");
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Akinobu Mita <akinobu.mita@gmail.com>");
--
1.7.10.4
^ permalink raw reply related
* [PATCH -v5 6/6] fault-injection: add selftests for cpu and memory hotplug
From: Akinobu Mita @ 2012-06-30 5:59 UTC (permalink / raw)
To: linux-kernel, akpm
Cc: Dave Jones, Greg KH, Akinobu Mita, Rafael J. Wysocki, linux-mm,
Paul Mackerras, Pavel Machek, Américo Wang, linux-pm,
linuxppc-dev
In-Reply-To: <1341035970-20490-1-git-send-email-akinobu.mita@gmail.com>
This adds two selftests
* tools/testing/selftests/cpu-hotplug/on-off-test.sh is testing script
for CPU hotplug
1. Online all hot-pluggable CPUs
2. Offline all hot-pluggable CPUs
3. Online all hot-pluggable CPUs again
4. Exit if cpu-notifier-error-inject.ko is not available
5. Offline all hot-pluggable CPUs in preparation for testing
6. Test CPU hot-add error handling by injecting notifier errors
7. Online all hot-pluggable CPUs in preparation for testing
8. Test CPU hot-remove error handling by injecting notifier errors
* tools/testing/selftests/memory-hotplug/on-off-test.sh is doing the
similar thing for memory hotplug.
1. Online all hot-pluggable memory
2. Offline 10% of hot-pluggable memory
3. Online all hot-pluggable memory again
4. Exit if memory-notifier-error-inject.ko is not available
5. Offline 10% of hot-pluggable memory in preparation for testing
6. Test memory hot-add error handling by injecting notifier errors
7. Online all hot-pluggable memory in preparation for testing
8. Test memory hot-remove error handling by injecting notifier errors
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Suggested-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: linux-pm@lists.linux-foundation.org
Cc: Greg KH <greg@kroah.com>
Cc: linux-mm@kvack.org
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev@lists.ozlabs.org
Cc: Américo Wang <xiyou.wangcong@gmail.com>
Cc: Dave Jones <davej@redhat.com>
---
* v5
- make testing scripts a part of tools/testing/selftests
- do simple on/offline tests even if no notifier error injection support
tools/testing/selftests/Makefile | 2 +-
tools/testing/selftests/cpu-hotplug/Makefile | 6 +
tools/testing/selftests/cpu-hotplug/on-off-test.sh | 221 +++++++++++++++++++
tools/testing/selftests/memory-hotplug/Makefile | 6 +
.../selftests/memory-hotplug/on-off-test.sh | 230 ++++++++++++++++++++
5 files changed, 464 insertions(+), 1 deletion(-)
create mode 100644 tools/testing/selftests/cpu-hotplug/Makefile
create mode 100755 tools/testing/selftests/cpu-hotplug/on-off-test.sh
create mode 100644 tools/testing/selftests/memory-hotplug/Makefile
create mode 100755 tools/testing/selftests/memory-hotplug/on-off-test.sh
diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index a4162e1..85baf11 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -1,4 +1,4 @@
-TARGETS = breakpoints kcmp mqueue vm
+TARGETS = breakpoints kcmp mqueue vm cpu-hotplug memory-hotplug
all:
for TARGET in $(TARGETS); do \
diff --git a/tools/testing/selftests/cpu-hotplug/Makefile b/tools/testing/selftests/cpu-hotplug/Makefile
new file mode 100644
index 0000000..7c9c20f
--- /dev/null
+++ b/tools/testing/selftests/cpu-hotplug/Makefile
@@ -0,0 +1,6 @@
+all:
+
+run_tests:
+ ./on-off-test.sh
+
+clean:
diff --git a/tools/testing/selftests/cpu-hotplug/on-off-test.sh b/tools/testing/selftests/cpu-hotplug/on-off-test.sh
new file mode 100755
index 0000000..bdde7cf
--- /dev/null
+++ b/tools/testing/selftests/cpu-hotplug/on-off-test.sh
@@ -0,0 +1,221 @@
+#!/bin/bash
+
+SYSFS=
+
+prerequisite()
+{
+ msg="skip all tests:"
+
+ if [ $UID != 0 ]; then
+ echo $msg must be run as root >&2
+ exit 0
+ fi
+
+ SYSFS=`mount -t sysfs | head -1 | awk '{ print $3 }'`
+
+ if [ ! -d "$SYSFS" ]; then
+ echo $msg sysfs is not mounted >&2
+ exit 0
+ fi
+
+ if ! ls $SYSFS/devices/system/cpu/cpu* > /dev/null 2>&1; then
+ echo $msg cpu hotplug is not supported >&2
+ exit 0
+ fi
+}
+
+#
+# list all hot-pluggable CPUs
+#
+hotpluggable_cpus()
+{
+ local state=${1:-.\*}
+
+ for cpu in $SYSFS/devices/system/cpu/cpu*; do
+ if [ -f $cpu/online ] && grep -q $state $cpu/online; then
+ echo ${cpu##/*/cpu}
+ fi
+ done
+}
+
+hotplaggable_offline_cpus()
+{
+ hotpluggable_cpus 0
+}
+
+hotpluggable_online_cpus()
+{
+ hotpluggable_cpus 1
+}
+
+cpu_is_online()
+{
+ grep -q 1 $SYSFS/devices/system/cpu/cpu$1/online
+}
+
+cpu_is_offline()
+{
+ grep -q 0 $SYSFS/devices/system/cpu/cpu$1/online
+}
+
+online_cpu()
+{
+ echo 1 > $SYSFS/devices/system/cpu/cpu$1/online
+}
+
+offline_cpu()
+{
+ echo 0 > $SYSFS/devices/system/cpu/cpu$1/online
+}
+
+online_cpu_expect_success()
+{
+ local cpu=$1
+
+ if ! online_cpu $cpu; then
+ echo $FUNCNAME $cpu: unexpected fail >&2
+ elif ! cpu_is_online $cpu; then
+ echo $FUNCNAME $cpu: unexpected offline >&2
+ fi
+}
+
+online_cpu_expect_fail()
+{
+ local cpu=$1
+
+ if online_cpu $cpu 2> /dev/null; then
+ echo $FUNCNAME $cpu: unexpected success >&2
+ elif ! cpu_is_offline $cpu; then
+ echo $FUNCNAME $cpu: unexpected online >&2
+ fi
+}
+
+offline_cpu_expect_success()
+{
+ local cpu=$1
+
+ if ! offline_cpu $cpu; then
+ echo $FUNCNAME $cpu: unexpected fail >&2
+ elif ! cpu_is_offline $cpu; then
+ echo $FUNCNAME $cpu: unexpected offline >&2
+ fi
+}
+
+offline_cpu_expect_fail()
+{
+ local cpu=$1
+
+ if offline_cpu $cpu 2> /dev/null; then
+ echo $FUNCNAME $cpu: unexpected success >&2
+ elif ! cpu_is_online $cpu; then
+ echo $FUNCNAME $cpu: unexpected offline >&2
+ fi
+}
+
+error=-12
+priority=0
+
+while getopts e:hp: opt; do
+ case $opt in
+ e)
+ error=$OPTARG
+ ;;
+ h)
+ echo "Usage $0 [ -e errno ] [ -p notifier-priority ]"
+ exit
+ ;;
+ p)
+ priority=$OPTARG
+ ;;
+ esac
+done
+
+if ! [ "$error" -ge -4095 -a "$error" -lt 0 ]; then
+ echo "error code must be -4095 <= errno < 0" >&2
+ exit 1
+fi
+
+prerequisite
+
+#
+# Online all hot-pluggable CPUs
+#
+for cpu in `hotplaggable_offline_cpus`; do
+ online_cpu_expect_success $cpu
+done
+
+#
+# Offline all hot-pluggable CPUs
+#
+for cpu in `hotpluggable_online_cpus`; do
+ offline_cpu_expect_success $cpu
+done
+
+#
+# Online all hot-pluggable CPUs again
+#
+for cpu in `hotplaggable_offline_cpus`; do
+ online_cpu_expect_success $cpu
+done
+
+#
+# Test with cpu notifier error injection
+#
+
+DEBUGFS=`mount -t debugfs | head -1 | awk '{ print $3 }'`
+NOTIFIER_ERR_INJECT_DIR=$DEBUGFS/notifier-error-inject/cpu
+
+prerequisite_extra()
+{
+ msg="skip extra tests:"
+
+ /sbin/modprobe -q -r cpu-notifier-error-inject
+ /sbin/modprobe -q cpu-notifier-error-inject priority=$priority
+
+ if [ ! -d "$DEBUGFS" ]; then
+ echo $msg debugfs is not mounted >&2
+ exit 0
+ fi
+
+ if [ ! -d $NOTIFIER_ERR_INJECT_DIR ]; then
+ echo $msg cpu-notifier-error-inject module is not available >&2
+ exit 0
+ fi
+}
+
+prerequisite_extra
+
+#
+# Offline all hot-pluggable CPUs
+#
+echo 0 > $NOTIFIER_ERR_INJECT_DIR/actions/CPU_DOWN_PREPARE/error
+for cpu in `hotpluggable_online_cpus`; do
+ offline_cpu_expect_success $cpu
+done
+
+#
+# Test CPU hot-add error handling (offline => online)
+#
+echo $error > $NOTIFIER_ERR_INJECT_DIR/actions/CPU_UP_PREPARE/error
+for cpu in `hotplaggable_offline_cpus`; do
+ online_cpu_expect_fail $cpu
+done
+
+#
+# Online all hot-pluggable CPUs
+#
+echo 0 > $NOTIFIER_ERR_INJECT_DIR/actions/CPU_UP_PREPARE/error
+for cpu in `hotplaggable_offline_cpus`; do
+ online_cpu_expect_success $cpu
+done
+
+#
+# Test CPU hot-remove error handling (online => offline)
+#
+echo $error > $NOTIFIER_ERR_INJECT_DIR/actions/CPU_DOWN_PREPARE/error
+for cpu in `hotpluggable_online_cpus`; do
+ offline_cpu_expect_fail $cpu
+done
+
+echo 0 > $NOTIFIER_ERR_INJECT_DIR/actions/CPU_DOWN_PREPARE/error
+/sbin/modprobe -q -r cpu-notifier-error-inject
diff --git a/tools/testing/selftests/memory-hotplug/Makefile b/tools/testing/selftests/memory-hotplug/Makefile
new file mode 100644
index 0000000..7c9c20f
--- /dev/null
+++ b/tools/testing/selftests/memory-hotplug/Makefile
@@ -0,0 +1,6 @@
+all:
+
+run_tests:
+ ./on-off-test.sh
+
+clean:
diff --git a/tools/testing/selftests/memory-hotplug/on-off-test.sh b/tools/testing/selftests/memory-hotplug/on-off-test.sh
new file mode 100755
index 0000000..a2816f6
--- /dev/null
+++ b/tools/testing/selftests/memory-hotplug/on-off-test.sh
@@ -0,0 +1,230 @@
+#!/bin/bash
+
+SYSFS=
+
+prerequisite()
+{
+ msg="skip all tests:"
+
+ if [ $UID != 0 ]; then
+ echo $msg must be run as root >&2
+ exit 0
+ fi
+
+ SYSFS=`mount -t sysfs | head -1 | awk '{ print $3 }'`
+
+ if [ ! -d "$SYSFS" ]; then
+ echo $msg sysfs is not mounted >&2
+ exit 0
+ fi
+
+ if ! ls $SYSFS/devices/system/memory/memory* > /dev/null 2>&1; then
+ echo $msg memory hotplug is not supported >&2
+ exit 0
+ fi
+}
+
+#
+# list all hot-pluggable memory
+#
+hotpluggable_memory()
+{
+ local state=${1:-.\*}
+
+ for memory in $SYSFS/devices/system/memory/memory*; do
+ if grep -q 1 $memory/removable &&
+ grep -q $state $memory/state; then
+ echo ${memory##/*/memory}
+ fi
+ done
+}
+
+hotplaggable_offline_memory()
+{
+ hotpluggable_memory offline
+}
+
+hotpluggable_online_memory()
+{
+ hotpluggable_memory online
+}
+
+memory_is_online()
+{
+ grep -q online $SYSFS/devices/system/memory/memory$1/state
+}
+
+memory_is_offline()
+{
+ grep -q offline $SYSFS/devices/system/memory/memory$1/state
+}
+
+online_memory()
+{
+ echo online > $SYSFS/devices/system/memory/memory$1/state
+}
+
+offline_memory()
+{
+ echo offline > $SYSFS/devices/system/memory/memory$1/state
+}
+
+online_memory_expect_success()
+{
+ local memory=$1
+
+ if ! online_memory $memory; then
+ echo $FUNCNAME $memory: unexpected fail >&2
+ elif ! memory_is_online $memory; then
+ echo $FUNCNAME $memory: unexpected offline >&2
+ fi
+}
+
+online_memory_expect_fail()
+{
+ local memory=$1
+
+ if online_memory $memory 2> /dev/null; then
+ echo $FUNCNAME $memory: unexpected success >&2
+ elif ! memory_is_offline $memory; then
+ echo $FUNCNAME $memory: unexpected online >&2
+ fi
+}
+
+offline_memory_expect_success()
+{
+ local memory=$1
+
+ if ! offline_memory $memory; then
+ echo $FUNCNAME $memory: unexpected fail >&2
+ elif ! memory_is_offline $memory; then
+ echo $FUNCNAME $memory: unexpected offline >&2
+ fi
+}
+
+offline_memory_expect_fail()
+{
+ local memory=$1
+
+ if offline_memory $memory 2> /dev/null; then
+ echo $FUNCNAME $memory: unexpected success >&2
+ elif ! memory_is_online $memory; then
+ echo $FUNCNAME $memory: unexpected offline >&2
+ fi
+}
+
+error=-12
+priority=0
+ratio=10
+
+while getopts e:hp:r: opt; do
+ case $opt in
+ e)
+ error=$OPTARG
+ ;;
+ h)
+ echo "Usage $0 [ -e errno ] [ -p notifier-priority ] [ -r percent-of-memory-to-offline ]"
+ exit
+ ;;
+ p)
+ priority=$OPTARG
+ ;;
+ r)
+ ratio=$OPTARG
+ ;;
+ esac
+done
+
+if ! [ "$error" -ge -4095 -a "$error" -lt 0 ]; then
+ echo "error code must be -4095 <= errno < 0" >&2
+ exit 1
+fi
+
+prerequisite
+
+#
+# Online all hot-pluggable memory
+#
+for memory in `hotplaggable_offline_memory`; do
+ online_memory_expect_success $memory
+done
+
+#
+# Offline $ratio percent of hot-pluggable memory
+#
+for memory in `hotpluggable_online_memory`; do
+ if [ $((RANDOM % 100)) -lt $ratio ]; then
+ offline_memory_expect_success $memory
+ fi
+done
+
+#
+# Online all hot-pluggable memory again
+#
+for memory in `hotplaggable_offline_memory`; do
+ online_memory_expect_success $memory
+done
+
+#
+# Test with memory notifier error injection
+#
+
+DEBUGFS=`mount -t debugfs | head -1 | awk '{ print $3 }'`
+NOTIFIER_ERR_INJECT_DIR=$DEBUGFS/notifier-error-inject/memory
+
+prerequisite_extra()
+{
+ msg="skip extra tests:"
+
+ /sbin/modprobe -q -r memory-notifier-error-inject
+ /sbin/modprobe -q memory-notifier-error-inject priority=$priority
+
+ if [ ! -d "$DEBUGFS" ]; then
+ echo $msg debugfs is not mounted >&2
+ exit 0
+ fi
+
+ if [ ! -d $NOTIFIER_ERR_INJECT_DIR ]; then
+ echo $msg memory-notifier-error-inject module is not available >&2
+ exit 0
+ fi
+}
+
+prerequisite_extra
+
+#
+# Offline $ratio percent of hot-pluggable memory
+#
+echo 0 > $NOTIFIER_ERR_INJECT_DIR/actions/MEM_GOING_OFFLINE/error
+for memory in `hotpluggable_online_memory`; do
+ if [ $((RANDOM % 100)) -lt $ratio ]; then
+ offline_memory_expect_success $memory
+ fi
+done
+
+#
+# Test memory hot-add error handling (offline => online)
+#
+echo $error > $NOTIFIER_ERR_INJECT_DIR/actions/MEM_GOING_ONLINE/error
+for memory in `hotplaggable_offline_memory`; do
+ online_memory_expect_fail $memory
+done
+
+#
+# Online all hot-pluggable memory
+#
+echo 0 > $NOTIFIER_ERR_INJECT_DIR/actions/MEM_GOING_ONLINE/error
+for memory in `hotplaggable_offline_memory`; do
+ online_memory_expect_success $memory
+done
+
+#
+# Test memory hot-remove error handling (online => offline)
+#
+echo $error > $NOTIFIER_ERR_INJECT_DIR/actions/MEM_GOING_OFFLINE/error
+for memory in `hotpluggable_online_memory`; do
+ offline_memory_expect_fail $memory
+done
+
+echo 0 > $NOTIFIER_ERR_INJECT_DIR/actions/MEM_GOING_OFFLINE/error
+/sbin/modprobe -q -r memory-notifier-error-inject
--
1.7.10.4
^ permalink raw reply related
* [PATCH -v5 0/6] notifier error injection
From: Akinobu Mita @ 2012-06-30 5:59 UTC (permalink / raw)
To: linux-kernel, akpm
Cc: Dave Jones, Greg KH, Akinobu Mita, Rafael J. Wysocki, linux-mm,
Paul Mackerras, Pavel Machek, Américo Wang, linux-pm,
linuxppc-dev
This provides kernel modules that can be used to test the error handling
of notifier call chain failures by injecting artifical errors to the
following notifier chain callbacks.
* CPU notifier
* PM notifier
* memory hotplug notifier
* powerpc pSeries reconfig notifier
Example: Inject CPU offline error (-1 == -EPERM)
# cd /sys/kernel/debug/notifier-error-inject/cpu
# echo -1 > actions/CPU_DOWN_PREPARE/error
# echo 0 > /sys/devices/system/cpu/cpu1/online
bash: echo: write error: Operation not permitted
This also adds cpu and memory hotplug tests to tools/testing/selftests
These tests first do simple online and offline test and then do fault
injection tests if notifier error injection module is available.
Changelog:
* v5 (change only testing scripts)
- make testing scripts a part of tools/testing/selftests
- do simple on/offline tests even if no notifier error injection support
* v4 (It is about 11 months since v3)
- prefix all APIs with notifier_err_inject_*
- rearrange debugfs interface
(e.g. $DEBUGFS/cpu-notifier-error-inject/CPU_DOWN_PREPARE -->
$DEBUGFS/notifier-error-inject/cpu/actions/CPU_DOWN_PREPARE/error)
- update modules to follow new interface
- add -r option for memory-notifier.sh to specify percent of offlining
memory blocks
* v3
- rewrite to be kernel modules instead of initializing at late_initcall()s
(it makes the diffstat look different but most code remains unchanged)
- export err_inject_notifier_block_{init,cleanup} for modules
- export pSeries_reconfig_notifier_{,un}register symbols for a module
- notifier priority can be specified as a module parameter
- add testing scripts in tools/testing/fault-injection
* v2
- "PM: Improve error code of pm_notifier_call_chain()" is now in -next
- "debugfs: add debugfs_create_int" is dropped
- put a comment in err_inject_notifier_block_init()
- only allow valid errno to be injected (-MAX_ERRNO <= errno <= 0)
- improve Kconfig help text
- make CONFIG_PM_NOTIFIER_ERROR_INJECTION visible even if PM_DEBUG is disabled
- make CONFIG_PM_NOTIFIER_ERROR_INJECTION default if PM_DEBUG is enabled
Akinobu Mita (6):
fault-injection: notifier error injection
cpu: rewrite cpu-notifier-error-inject module
PM: PM notifier error injection module
memory: memory notifier error injection module
powerpc: pSeries reconfig notifier error injection module
fault-injection: add selftests for cpu and memory hotplug
lib/Kconfig.debug | 91 +++++++-
lib/Makefile | 5 +
lib/cpu-notifier-error-inject.c | 63 +++---
lib/memory-notifier-error-inject.c | 48 ++++
lib/notifier-error-inject.c | 112 ++++++++++
lib/notifier-error-inject.h | 24 ++
lib/pSeries-reconfig-notifier-error-inject.c | 51 +++++
lib/pm-notifier-error-inject.c | 49 +++++
tools/testing/selftests/Makefile | 2 +-
tools/testing/selftests/cpu-hotplug/Makefile | 6 +
tools/testing/selftests/cpu-hotplug/on-off-test.sh | 221 +++++++++++++++++++
tools/testing/selftests/memory-hotplug/Makefile | 6 +
.../selftests/memory-hotplug/on-off-test.sh | 230 ++++++++++++++++++++
13 files changed, 867 insertions(+), 41 deletions(-)
create mode 100644 lib/memory-notifier-error-inject.c
create mode 100644 lib/notifier-error-inject.c
create mode 100644 lib/notifier-error-inject.h
create mode 100644 lib/pSeries-reconfig-notifier-error-inject.c
create mode 100644 lib/pm-notifier-error-inject.c
create mode 100644 tools/testing/selftests/cpu-hotplug/Makefile
create mode 100755 tools/testing/selftests/cpu-hotplug/on-off-test.sh
create mode 100644 tools/testing/selftests/memory-hotplug/Makefile
create mode 100755 tools/testing/selftests/memory-hotplug/on-off-test.sh
Cc: Pavel Machek <pavel@ucw.cz>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: linux-pm@lists.linux-foundation.org
Cc: Greg KH <greg@kroah.com>
Cc: linux-mm@kvack.org
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev@lists.ozlabs.org
Cc: Américo Wang <xiyou.wangcong@gmail.com>
Cc: Michael Ellerman <michael@ellerman.id.au>
Cc: Dave Jones <davej@redhat.com>
--
1.7.10.4
^ permalink raw reply
* [PATCH -v5 1/6] fault-injection: notifier error injection
From: Akinobu Mita @ 2012-06-30 5:59 UTC (permalink / raw)
To: linux-kernel, akpm
Cc: Greg KH, Akinobu Mita, Rafael J. Wysocki, linux-mm,
Paul Mackerras, Pavel Machek, linux-pm, linuxppc-dev
In-Reply-To: <1341035970-20490-1-git-send-email-akinobu.mita@gmail.com>
The notifier error injection provides the ability to inject artifical
errors to specified notifier chain callbacks. It is useful to test the
error handling of notifier call chain failures.
This adds common basic functions to define which type of events can be
fail and to initialize the debugfs interface to control what error code
should be returned and which event should be failed.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: linux-pm@lists.linux-foundation.org
Cc: Greg KH <greg@kroah.com>
Cc: linux-mm@kvack.org
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev@lists.ozlabs.org
Cc: Michael Ellerman <michael@ellerman.id.au>
---
No changes since v4
lib/Kconfig.debug | 11 +++++
lib/Makefile | 1 +
lib/notifier-error-inject.c | 112 +++++++++++++++++++++++++++++++++++++++++++
lib/notifier-error-inject.h | 24 ++++++++++
4 files changed, 148 insertions(+)
create mode 100644 lib/notifier-error-inject.c
create mode 100644 lib/notifier-error-inject.h
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index ff5bdee..c848758 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -1084,6 +1084,17 @@ config LKDTM
Documentation on how to use the module can be found in
Documentation/fault-injection/provoke-crashes.txt
+config NOTIFIER_ERROR_INJECTION
+ tristate "Notifier error injection"
+ depends on DEBUG_KERNEL
+ select DEBUG_FS
+ help
+ This option provides the ability to inject artifical errors to
+ specified notifier chain callbacks. It is useful to test the error
+ handling of notifier call chain failures.
+
+ Say N if unsure.
+
config CPU_NOTIFIER_ERROR_INJECT
tristate "CPU notifier error injection module"
depends on HOTPLUG_CPU && DEBUG_KERNEL
diff --git a/lib/Makefile b/lib/Makefile
index 8c31a0c..23fba9e 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -90,6 +90,7 @@ obj-$(CONFIG_AUDIT_GENERIC) += audit.o
obj-$(CONFIG_SWIOTLB) += swiotlb.o
obj-$(CONFIG_IOMMU_HELPER) += iommu-helper.o
obj-$(CONFIG_FAULT_INJECTION) += fault-inject.o
+obj-$(CONFIG_NOTIFIER_ERROR_INJECTION) += notifier-error-inject.o
obj-$(CONFIG_CPU_NOTIFIER_ERROR_INJECT) += cpu-notifier-error-inject.o
lib-$(CONFIG_GENERIC_BUG) += bug.o
diff --git a/lib/notifier-error-inject.c b/lib/notifier-error-inject.c
new file mode 100644
index 0000000..44b92cb
--- /dev/null
+++ b/lib/notifier-error-inject.c
@@ -0,0 +1,112 @@
+#include <linux/module.h>
+
+#include "notifier-error-inject.h"
+
+static int debugfs_errno_set(void *data, u64 val)
+{
+ *(int *)data = clamp_t(int, val, -MAX_ERRNO, 0);
+ return 0;
+}
+
+static int debugfs_errno_get(void *data, u64 *val)
+{
+ *val = *(int *)data;
+ return 0;
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(fops_errno, debugfs_errno_get, debugfs_errno_set,
+ "%lld\n");
+
+static struct dentry *debugfs_create_errno(const char *name, mode_t mode,
+ struct dentry *parent, int *value)
+{
+ return debugfs_create_file(name, mode, parent, value, &fops_errno);
+}
+
+static int notifier_err_inject_callback(struct notifier_block *nb,
+ unsigned long val, void *p)
+{
+ int err = 0;
+ struct notifier_err_inject *err_inject =
+ container_of(nb, struct notifier_err_inject, nb);
+ struct notifier_err_inject_action *action;
+
+ for (action = err_inject->actions; action->name; action++) {
+ if (action->val == val) {
+ err = action->error;
+ break;
+ }
+ }
+ if (err)
+ pr_info("Injecting error (%d) to %s\n", err, action->name);
+
+ return notifier_from_errno(err);
+}
+
+struct dentry *notifier_err_inject_dir;
+EXPORT_SYMBOL_GPL(notifier_err_inject_dir);
+
+struct dentry *notifier_err_inject_init(const char *name, struct dentry *parent,
+ struct notifier_err_inject *err_inject, int priority)
+{
+ struct notifier_err_inject_action *action;
+ mode_t mode = S_IFREG | S_IRUSR | S_IWUSR;
+ struct dentry *dir;
+ struct dentry *actions_dir;
+
+ err_inject->nb.notifier_call = notifier_err_inject_callback;
+ err_inject->nb.priority = priority;
+
+ dir = debugfs_create_dir(name, parent);
+ if (!dir)
+ return ERR_PTR(-ENOMEM);
+
+ actions_dir = debugfs_create_dir("actions", dir);
+ if (!actions_dir)
+ goto fail;
+
+ for (action = err_inject->actions; action->name; action++) {
+ struct dentry *action_dir;
+
+ action_dir = debugfs_create_dir(action->name, actions_dir);
+ if (!action_dir)
+ goto fail;
+
+ /*
+ * Create debugfs r/w file containing action->error. If
+ * notifier call chain is called with action->val, it will
+ * fail with the error code
+ */
+ if (!debugfs_create_errno("error", mode, action_dir,
+ &action->error))
+ goto fail;
+ }
+ return dir;
+fail:
+ debugfs_remove_recursive(dir);
+ return ERR_PTR(-ENOMEM);
+}
+EXPORT_SYMBOL_GPL(notifier_err_inject_init);
+
+static int __init err_inject_init(void)
+{
+ notifier_err_inject_dir =
+ debugfs_create_dir("notifier-error-inject", NULL);
+
+ if (!notifier_err_inject_dir)
+ return -ENOMEM;
+
+ return 0;
+}
+
+static void __exit err_inject_exit(void)
+{
+ debugfs_remove_recursive(notifier_err_inject_dir);
+}
+
+module_init(err_inject_init);
+module_exit(err_inject_exit);
+
+MODULE_DESCRIPTION("Notifier error injection module");
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Akinobu Mita <akinobu.mita@gmail.com>");
diff --git a/lib/notifier-error-inject.h b/lib/notifier-error-inject.h
new file mode 100644
index 0000000..99b3b6f
--- /dev/null
+++ b/lib/notifier-error-inject.h
@@ -0,0 +1,24 @@
+#include <linux/atomic.h>
+#include <linux/debugfs.h>
+#include <linux/notifier.h>
+
+struct notifier_err_inject_action {
+ unsigned long val;
+ int error;
+ const char *name;
+};
+
+#define NOTIFIER_ERR_INJECT_ACTION(action) \
+ .name = #action, .val = (action),
+
+struct notifier_err_inject {
+ struct notifier_block nb;
+ struct notifier_err_inject_action actions[];
+ /* The last slot must be terminated with zero sentinel */
+};
+
+extern struct dentry *notifier_err_inject_dir;
+
+extern struct dentry *notifier_err_inject_init(const char *name,
+ struct dentry *parent, struct notifier_err_inject *err_inject,
+ int priority);
--
1.7.10.4
^ permalink raw reply related
* Re: [RFC PATCH 2/12] memory-hogplug : check memory offline in offline_pages
From: Jiang Liu @ 2012-06-30 15:46 UTC (permalink / raw)
To: Yasuaki Ishimatsu
Cc: len.brown, wency, linux-acpi, linux-kernel, linux-mm, paulus,
minchan.kim, kosaki.motohiro, cl, linuxppc-dev, akpm
In-Reply-To: <4FEA9DB1.7010303@jp.fujitsu.com>
On 06/27/2012 01:44 PM, Yasuaki Ishimatsu wrote:
> When offline_pages() is called to offlined memory, the function fails since
> all memory has been offlined. In this case, the function should succeed.
> The patch adds the check function into offline_pages().
>
> CC: Len Brown <len.brown@intel.com>
> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> CC: Paul Mackerras <paulus@samba.org>
> CC: Christoph Lameter <cl@linux.com>
> Cc: Minchan Kim <minchan.kim@gmail.com>
> CC: Andrew Morton <akpm@linux-foundation.org>
> CC: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
> CC: Wen Congyang <wency@cn.fujitsu.com>
> Signed-off-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
>
> ---
> drivers/base/memory.c | 20 ++++++++++++++++++++
> include/linux/memory.h | 1 +
> mm/memory_hotplug.c | 5 +++++
> 3 files changed, 26 insertions(+)
>
> Index: linux-3.5-rc4/drivers/base/memory.c
> ===================================================================
> --- linux-3.5-rc4.orig/drivers/base/memory.c 2012-06-26 13:28:16.726211752 +0900
> +++ linux-3.5-rc4/drivers/base/memory.c 2012-06-26 13:34:22.423639904 +0900
> @@ -70,6 +70,26 @@ void unregister_memory_isolate_notifier(
> }
> EXPORT_SYMBOL(unregister_memory_isolate_notifier);
>
> +bool memory_is_offline(unsigned long start_pfn, unsigned long end_pfn)
> +{
> + struct memory_block *mem;
> + struct mem_section *section;
> + unsigned long pfn, section_nr;
> +
> + for (pfn = start_pfn; pfn < end_pfn; pfn += PAGES_PER_SECTION) {
> + section_nr = pfn_to_section_nr(pfn);
> + section = __nr_to_section(section_nr);
Is it possible for __nr_to_section return NULL here?
> + mem = find_memory_block(section);
> + if (!mem)
> + continue;
> + if (mem->state == MEM_OFFLINE)
> + continue;
> + return false;
> + }
> +
> + return true;
> +}
Need a put_dev(&mem->dev) for the last memory block device handled before return.
> +
> /*
> * register_memory - Setup a sysfs device for a memory block
> */
> Index: linux-3.5-rc4/include/linux/memory.h
> ===================================================================
> --- linux-3.5-rc4.orig/include/linux/memory.h 2012-06-25 04:53:04.000000000 +0900
> +++ linux-3.5-rc4/include/linux/memory.h 2012-06-26 13:34:22.424639891 +0900
> @@ -120,6 +120,7 @@ extern int memory_isolate_notify(unsigne
> extern struct memory_block *find_memory_block_hinted(struct mem_section *,
> struct memory_block *);
> extern struct memory_block *find_memory_block(struct mem_section *);
> +extern bool memory_is_offline(unsigned long start_pfn, unsigned long end_pfn);
> #define CONFIG_MEM_BLOCK_SIZE (PAGES_PER_SECTION<<PAGE_SHIFT)
> enum mem_add_context { BOOT, HOTPLUG };
> #endif /* CONFIG_MEMORY_HOTPLUG_SPARSE */
> Index: linux-3.5-rc4/mm/memory_hotplug.c
> ===================================================================
> --- linux-3.5-rc4.orig/mm/memory_hotplug.c 2012-06-26 13:28:16.743211538 +0900
> +++ linux-3.5-rc4/mm/memory_hotplug.c 2012-06-26 13:48:38.264940468 +0900
> @@ -887,6 +887,11 @@ static int __ref offline_pages(unsigned
>
> lock_memory_hotplug();
>
> + if (memory_is_offline(start_pfn, end_pfn)) {
> + ret = 0;
> + goto out;
> + }
> +
> zone = page_zone(pfn_to_page(start_pfn));
> node = zone_to_nid(zone);
> nr_pages = end_pfn - start_pfn;
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply
* Re: [RFC PATCH 2/12] memory-hogplug : check memory offline in offline_pages
From: Jiang Liu @ 2012-06-30 15:51 UTC (permalink / raw)
To: Yasuaki Ishimatsu
Cc: len.brown, wency, linux-acpi, linux-kernel, linux-mm, paulus,
minchan.kim, kosaki.motohiro, cl, linuxppc-dev, akpm
In-Reply-To: <4FEA9DB1.7010303@jp.fujitsu.com>
On 06/27/2012 01:44 PM, Yasuaki Ishimatsu wrote:
> When offline_pages() is called to offlined memory, the function fails since
> all memory has been offlined. In this case, the function should succeed.
> The patch adds the check function into offline_pages().
>
> CC: Len Brown <len.brown@intel.com>
> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> CC: Paul Mackerras <paulus@samba.org>
> CC: Christoph Lameter <cl@linux.com>
> Cc: Minchan Kim <minchan.kim@gmail.com>
> CC: Andrew Morton <akpm@linux-foundation.org>
> CC: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
> CC: Wen Congyang <wency@cn.fujitsu.com>
> Signed-off-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
>
> ---
> drivers/base/memory.c | 20 ++++++++++++++++++++
> include/linux/memory.h | 1 +
> mm/memory_hotplug.c | 5 +++++
> 3 files changed, 26 insertions(+)
>
> Index: linux-3.5-rc4/drivers/base/memory.c
> ===================================================================
> --- linux-3.5-rc4.orig/drivers/base/memory.c 2012-06-26 13:28:16.726211752 +0900
> +++ linux-3.5-rc4/drivers/base/memory.c 2012-06-26 13:34:22.423639904 +0900
> @@ -70,6 +70,26 @@ void unregister_memory_isolate_notifier(
> }
> EXPORT_SYMBOL(unregister_memory_isolate_notifier);
>
> +bool memory_is_offline(unsigned long start_pfn, unsigned long end_pfn)
> +{
> + struct memory_block *mem;
> + struct mem_section *section;
> + unsigned long pfn, section_nr;
> +
> + for (pfn = start_pfn; pfn < end_pfn; pfn += PAGES_PER_SECTION) {
> + section_nr = pfn_to_section_nr(pfn);
> + section = __nr_to_section(section_nr);
> + mem = find_memory_block(section);
Seems find_memory_block_hinted() is more efficient than find_memory_block() here.
> + if (!mem)
> + continue;
> + if (mem->state == MEM_OFFLINE)
> + continue;
> + return false;
> + }
> +
> + return true;
> +}
> +
> /*
> * register_memory - Setup a sysfs device for a memory block
> */
> Index: linux-3.5-rc4/include/linux/memory.h
> ===================================================================
> --- linux-3.5-rc4.orig/include/linux/memory.h 2012-06-25 04:53:04.000000000 +0900
> +++ linux-3.5-rc4/include/linux/memory.h 2012-06-26 13:34:22.424639891 +0900
> @@ -120,6 +120,7 @@ extern int memory_isolate_notify(unsigne
> extern struct memory_block *find_memory_block_hinted(struct mem_section *,
> struct memory_block *);
> extern struct memory_block *find_memory_block(struct mem_section *);
> +extern bool memory_is_offline(unsigned long start_pfn, unsigned long end_pfn);
> #define CONFIG_MEM_BLOCK_SIZE (PAGES_PER_SECTION<<PAGE_SHIFT)
> enum mem_add_context { BOOT, HOTPLUG };
> #endif /* CONFIG_MEMORY_HOTPLUG_SPARSE */
> Index: linux-3.5-rc4/mm/memory_hotplug.c
> ===================================================================
> --- linux-3.5-rc4.orig/mm/memory_hotplug.c 2012-06-26 13:28:16.743211538 +0900
> +++ linux-3.5-rc4/mm/memory_hotplug.c 2012-06-26 13:48:38.264940468 +0900
> @@ -887,6 +887,11 @@ static int __ref offline_pages(unsigned
>
> lock_memory_hotplug();
>
> + if (memory_is_offline(start_pfn, end_pfn)) {
> + ret = 0;
> + goto out;
> + }
> +
> zone = page_zone(pfn_to_page(start_pfn));
> node = zone_to_nid(zone);
> nr_pages = end_pfn - start_pfn;
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply
* Re: [RFC PATCH 10/12] memory-hotplug : free memmap of sparse-vmemmap
From: Jiang Liu @ 2012-06-30 15:58 UTC (permalink / raw)
To: Yasuaki Ishimatsu
Cc: len.brown, wency, linux-acpi, linux-kernel, linux-mm, paulus,
minchan.kim, kosaki.motohiro, cl, linuxppc-dev, akpm
In-Reply-To: <4FEAA09F.5000907@jp.fujitsu.com>
On 06/27/2012 01:56 PM, Yasuaki Ishimatsu wrote:
> I don't think that all pages of virtual mapping in removed memory can be
> freed, since page which type is MIX_SECTION_INFO is difficult to free.
> So, the patch only frees page which type is SECTION_INFO at first.
>
> CC: Len Brown <len.brown@intel.com>
> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> CC: Paul Mackerras <paulus@samba.org>
> CC: Christoph Lameter <cl@linux.com>
> Cc: Minchan Kim <minchan.kim@gmail.com>
> CC: Andrew Morton <akpm@linux-foundation.org>
> CC: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
> CC: Wen Congyang <wency@cn.fujitsu.com>
> Signed-off-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
>
> ---
> arch/x86/mm/init_64.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++
> include/linux/mm.h | 2 +
> mm/memory_hotplug.c | 5 ++
> mm/sparse.c | 5 +-
> 4 files changed, 99 insertions(+), 2 deletions(-)
>
> Index: linux-3.5-rc4/include/linux/mm.h
> ===================================================================
> --- linux-3.5-rc4.orig/include/linux/mm.h 2012-06-27 09:11:13.790150442 +0900
> +++ linux-3.5-rc4/include/linux/mm.h 2012-06-27 09:11:16.433117400 +0900
> @@ -1588,6 +1588,8 @@ int vmemmap_populate(struct page *start_
> void vmemmap_populate_print_last(void);
> void register_page_bootmem_memmap(unsigned long section_nr, struct page *map,
> unsigned long size);
> +void vmemmap_kfree(struct page *memmpa, unsigned long nr_pages);
> +void vmemmap_free_bootmem(struct page *memmpa, unsigned long nr_pages);
>
> enum mf_flags {
> MF_COUNT_INCREASED = 1 << 0,
> Index: linux-3.5-rc4/mm/sparse.c
> ===================================================================
> --- linux-3.5-rc4.orig/mm/sparse.c 2012-06-27 09:06:35.317631878 +0900
> +++ linux-3.5-rc4/mm/sparse.c 2012-06-27 09:11:16.434117388 +0900
> @@ -614,12 +614,13 @@ static inline struct page *kmalloc_secti
> /* This will make the necessary allocations eventually. */
> return sparse_mem_map_populate(pnum, nid);
> }
> -static void __kfree_section_memmap(struct page *memmap, unsigned long nr_pages)
> +static void __kfree_section_memmap(struct page *page, unsigned long nr_pages)
> {
> - return; /* XXX: Not implemented yet */
> + vmemmap_kfree(page, nr_pages);
> }
> static void free_map_bootmem(struct page *page, unsigned long nr_pages)
> {
> + vmemmap_free_bootmem(page, nr_pages);
> }
> #else
> static struct page *__kmalloc_section_memmap(unsigned long nr_pages)
> Index: linux-3.5-rc4/arch/x86/mm/init_64.c
> ===================================================================
> --- linux-3.5-rc4.orig/arch/x86/mm/init_64.c 2012-06-27 09:11:13.791150430 +0900
> +++ linux-3.5-rc4/arch/x86/mm/init_64.c 2012-06-27 09:11:59.254581998 +0900
> @@ -978,6 +978,95 @@ vmemmap_populate(struct page *start_page
> return 0;
> }
>
> +unsigned long find_and_clear_pte_page(unsigned long addr, unsigned long end,
> + struct page *page)
I think the third parameter should be "struct page **pp" instead of "struct page *page".
And "page = pte_page(*pte)" should be "*pp = pte_page(*pte)".
Otherwise the found page pointer can't be returned to the caller and vmemmap_kfree()
just sees random value in variable "page".
> +{
> + pgd_t *pgd;
> + pud_t *pud;
> + pmd_t *pmd;
> + pte_t *pte;
> + unsigned long next;
> +
> + page = NULL;
> +
> + pgd = pgd_offset_k(addr);
> + if (pgd_none(*pgd))
> + return PAGE_SIZE;
> +
> + pud = pud_offset(pgd, addr);
> + if (pud_none(*pud))
> + return PAGE_SIZE;
> +
> + if (!cpu_has_pse) {
> + next = (addr + PAGE_SIZE) & PAGE_MASK;
> + pmd = pmd_offset(pud, addr);
> + if (pmd_none(*pmd))
> + return next;
> +
> + pte = pte_offset_kernel(pmd, addr);
> + if (pte_none(*pte))
> + return next;
> +
> + page = pte_page(*pte);
> + pte_clear(&init_mm, addr, pte);
> + } else {
> + next = pmd_addr_end(addr, end);
> +
> + pmd = pmd_offset(pud, addr);
> + if (pmd_none(*pmd))
> + return next;
> +
> + page = pmd_page(*pmd);
> + pmd_clear(pmd);
> + }
> +
> + return next;
> +}
> +
> +void __meminit
> +vmemmap_kfree(struct page *memmap, unsigned long nr_pages)
> +{
> + unsigned long addr = (unsigned long)memmap;
> + unsigned long end = (unsigned long)(memmap + nr_pages);
> + unsigned long next;
> + unsigned int order;
> + struct page *page;
> +
> + for (; addr < end; addr = next) {
> + next = find_and_clear_pte_page(addr, end, page);
> + if (!page)
> + continue;
> +
> + if (is_vmalloc_addr(page))
> + vfree(page);
> + else {
> + order = next - addr;
> + free_pages((unsigned long)page,
> + get_order(sizeof(struct page) * order));
> + }
> + }
> +}
> +
> +void __meminit
> +vmemmap_free_bootmem(struct page *memmap, unsigned long nr_pages)
> +{
> + unsigned long addr = (unsigned long)memmap;
> + unsigned long end = (unsigned long)(memmap + nr_pages);
> + unsigned long next;
> + struct page *page;
> + unsigned long magic;
> +
> + for (; addr < end; addr = next) {
> + next = find_and_clear_pte_page(addr, end, page);
> + if (!page)
> + continue;
> +
> + magic = (unsigned long) page->lru.next;
> + if (magic == SECTION_INFO)
> + put_page_bootmem(page);
> + }
> +}
> +
> void __meminit
> register_page_bootmem_memmap(unsigned long section_nr, struct page *start_page,
> unsigned long size)
> Index: linux-3.5-rc4/mm/memory_hotplug.c
> ===================================================================
> --- linux-3.5-rc4.orig/mm/memory_hotplug.c 2012-06-27 09:11:13.789150454 +0900
> +++ linux-3.5-rc4/mm/memory_hotplug.c 2012-06-27 09:11:16.436117363 +0900
> @@ -303,6 +303,8 @@ static int __meminit __add_section(int n
> #ifdef CONFIG_SPARSEMEM_VMEMMAP
> static int __remove_section(struct zone *zone, struct mem_section *ms)
> {
> + unsigned long flags;
> + struct pglist_data *pgdat = zone->zone_pgdat;
> int ret;
>
> if (!valid_section(ms))
> @@ -310,6 +312,9 @@ static int __remove_section(struct zone
>
> ret = unregister_memory_section(ms);
>
> + pgdat_resize_lock(pgdat, &flags);
> + sparse_remove_one_section(zone, ms);
> + pgdat_resize_unlock(pgdat, &flags);
> return ret;
> }
> #else
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply
* MPC5200b jffs2 memcpy alignment problem
From: Stephan Gatzka @ 2012-06-30 19:16 UTC (permalink / raw)
To: linux-mtd, linuxppc-dev
[-- Attachment #1: Type: text/plain, Size: 1470 bytes --]
Hello!
First of all, please apologize my cross posting.
I have a problem running jffs2 on an MPC5200b board. I run kernel 3.4,
but older kernels like 3.1.5 are also affected. Every time I mount
jffs2, previously written content gets garbled.
The problem was nailed down to memcpy(&fd->name, rd->name, checkedlen);
in jffs2_scan_dirent_node in fs/jffs2/scan.c.
This is a copy directly from the mapped flash.
memcpy from copy_32.S only ensures that the 32 bit stores to the
destination ptr are aligned. And that's the problem with the MPC5200b
because the user manual (Chapter 9.2, LocalPlus bus features) clearly
states that unaligned access is not supported. But the code above
results in unaligned loads from the LocalPlus bus.
I think there are two possible solutions:
1. Rewrite memcpy this way: Only if both src and dst are 32 bit aligned,
use 32 bit load/store to copy, otherwise use byte load/store
instructions. (btw. is there a reason for not to use the load multiple
and store multiple instructions in memcpy?) This might be the best way
to do because in my opinion the semantics of memcpy put no restrictions
on the alignment of src and dst.
2. use memcpy_fromio in the jffs2 code. memcpy_fromio behaves exactly in
the way I described above. This could be also a good solution because
flash access via LocalPlus bus is clearly IO.
What is your opinion where to fix this problem?
Regards,
Stephan
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4931 bytes --]
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox