RE: Linuxppc-dev Digest, Vol 88, Issue 24

2011-12-09 Thread Liu Shengzhou-B36685


 -Original Message-
 
 Message: 4
 Date: Sun, 4 Dec 2011 12:31:38 +0800
 From: shuo@freescale.com
 To: dw...@infradead.org, artem.bityuts...@nokia.com,
   scottw...@freescale.com
 Cc: linux-ker...@vger.kernel.org, shuo@freescale.com,
   linux-...@lists.infradead.org, a...@linux-foundation.org,
   linuxppc-dev@lists.ozlabs.org
 Subject: [PATCH 3/3] mtd/nand : workaround for Freescale FCM to
   support large-page Nand chip
 Message-ID: 1322973098-2528-3-git-send-email-shuo@freescale.com
 Content-Type: text/plain
 
 From: Liu Shuo shuo@freescale.com
 
 Freescale FCM controller has a 2K size limitation of buffer RAM. In order
 to support the Nand flash chip whose page size is larger than 2K bytes,
 we read/write 2k data repeatedly by issuing FIR_OP_RB/FIR_OP_WB and save
 them to a large buffer.
 
 Signed-off-by: Liu Shuo shuo@freescale.com
 ---
 v3:
 -remove page_size of struct fsl_elbc_mtd.
 -do a oob write by NAND_CMD_RNDIN.
 
  drivers/mtd/nand/fsl_elbc_nand.c |  243
 ++
  1 files changed, 218 insertions(+), 25 deletions(-)
 
 diff --git a/drivers/mtd/nand/fsl_elbc_nand.c
 b/drivers/mtd/nand/fsl_elbc_nand.c
 index d634c5f..a92411a 100644
 --- a/drivers/mtd/nand/fsl_elbc_nand.c
 +++ b/drivers/mtd/nand/fsl_elbc_nand.c

[SNIP]

 @@ -500,6 +654,7 @@ static void fsl_elbc_cmdfunc(struct mtd_info *mtd,
 unsigned int command,
* write-protected, even when it is not.
*/
   setbits8(elbc_fcm_ctrl-addr, NAND_STATUS_WP);
 + elbc_fcm_ctrl-buffer[0] = in_8(elbc_fcm_ctrl-addr);

[Shengzhou] add if (mtd-writesize  2048) 

   return;
 
   /* RESET without waiting for the ready line */
 @@ -548,7 +703,14 @@ static void fsl_elbc_write_buf(struct mtd_info *mtd,
 const u8 *buf, int len)
   len = bufsize - elbc_fcm_ctrl-index;
   }
 
 - memcpy_toio(elbc_fcm_ctrl-addr[elbc_fcm_ctrl-index], buf, len);
 + if (mtd-writesize  2048) {
 + memcpy(elbc_fcm_ctrl-buffer[elbc_fcm_ctrl-index],
 + buf, len);
 + } else {
 + memcpy_toio(elbc_fcm_ctrl-addr[elbc_fcm_ctrl-index],
 + buf, len);
 + }
 +
   setbits32(lbc-bank[priv-bank].or, OR_FCM_PGS);
   /* adjust ecc setup if needed */
   if ((in_be32(lbc-bank[priv-bank].br)  BR_DECC) ==
 @@ -891,6 +1070,19 @@ static int __devinit fsl_elbc_nand_probe(struct
 platform_device *pdev)
   goto err;
   }
   elbc_fcm_ctrl-counter++;
 + /*
 +  * Freescale FCM controller has a 2K size limitation of
 buffer
 +  * RAM, so elbc_fcm_ctrl-buffer have to be used if writesize
 +  * of chip is greater than 2048.
 +  * We malloc a large enough buffer (maximum page size is 16K).
 +  */
 + elbc_fcm_ctrl-buffer = kmalloc(1024 * 16 + 1024, GFP_KERNEL);
 + if (!elbc_fcm_ctrl-buffer) {
 + dev_err(dev, failed to allocate memory\n);
 + mutex_unlock(fsl_elbc_nand_mutex);
 + ret = -ENOMEM;
 + goto err;
 + }
 
[Shengzhou] 
Before calling nand_scan_ident(), we can still use 2k FCM RAM, not need a 
buffer greater than 2k,
After nand_scan_ident(),  if writesize  2048, then allocate a large buffer.
We can do it in fsl_elbc_chip_init_tail()
  if (mtd-writesize  2048)
  ctrl-buffer = kmalloc(mtd-writesize + mtd-oobsize, GFP_KERNEL);

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: cpu idle time going backward

2011-12-09 Thread Andreas Schwab
kevin diggs diggskevi...@gmail.com writes:

 On 12/8/11, Andreas Schwab sch...@linux-m68k.org wrote:
 There seems to be something wrong with cpu idle time accounting at least
 on G5.  The value as reported in the cpu lines in /proc/stat seems to be
 stuck in the interval [10,21] for each cpu, jumping back at
 random points.  Any idea what could be the problem?

 Andreas.

 --
 What kernel versions?

It started with 3.2-rc1.  Will try to bisect.

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
And now for something completely different.
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH 1/2] mtd/nand : set Nand flash page address to FBAR and FPAR correctly

2011-12-09 Thread shuo.liu
From: Liu Shuo b35...@freescale.com

If we use the Nand flash chip whose number of pages in a block is greater
than 64(for large page), we must treat the low bit of FBAR as being the
high bit of the page address due to the limitation of FCM, it simply uses
the low 6-bits (for large page) of the combined block/page address as the
FPAR component, rather than considering the actual block size.

Signed-off-by: Liu Shuo b35...@freescale.com
Signed-off-by: Jerry Huang chang-ming.hu...@freescale.com
Signed-off-by: Tang Yuantian b29...@freescale.com
Signed-off-by: Li Yang le...@freescale.com
---
 drivers/mtd/nand/fsl_elbc_nand.c |   13 ++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/nand/fsl_elbc_nand.c b/drivers/mtd/nand/fsl_elbc_nand.c
index 7db573e..d29479a 100644
--- a/drivers/mtd/nand/fsl_elbc_nand.c
+++ b/drivers/mtd/nand/fsl_elbc_nand.c
@@ -166,15 +166,22 @@ static void set_addr(struct mtd_info *mtd, int column, 
int page_addr, int oob)
 
elbc_fcm_ctrl-page = page_addr;
 
-   out_be32(lbc-fbar,
-page_addr  (chip-phys_erase_shift - chip-page_shift));
-
if (priv-page_size) {
+   /*
+* large page size chip : FPAR[PI] save the lowest 6 bits,
+*FBAR[BLK] save the other bits.
+*/
+   out_be32(lbc-fbar, page_addr  6);
out_be32(lbc-fpar,
 ((page_addr  FPAR_LP_PI_SHIFT)  FPAR_LP_PI) |
 (oob ? FPAR_LP_MS : 0) | column);
buf_num = (page_addr  1)  2;
} else {
+   /*
+* small page size chip : FPAR[PI] save the lowest 5 bits,
+*FBAR[BLK] save the other bits.
+*/
+   out_be32(lbc-fbar, page_addr  5);
out_be32(lbc-fpar,
 ((page_addr  FPAR_SP_PI_SHIFT)  FPAR_SP_PI) |
 (oob ? FPAR_SP_MS : 0) | column);
-- 
1.7.1


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH 2/2 v4] mtd/nand : workaround for Freescale FCM to support large-page Nand chip

2011-12-09 Thread shuo.liu
From: Liu Shuo shuo@freescale.com

Freescale FCM controller has a 2K size limitation of buffer RAM. In order
to support the Nand flash chip whose page size is larger than 2K bytes,
we read/write 2k data repeatedly by issuing FIR_OP_RB/FIR_OP_WB and save
them to a large buffer.

Signed-off-by: Liu Shuo shuo@freescale.com
Signed-off-by: Shengzhou Liu shengzhou@freescale.com
Signed-off-by: Li Yang le...@freescale.com
---
v4 : allocate (8+1)k buffer for large page chip.

 drivers/mtd/nand/fsl_elbc_nand.c |  246 ++
 1 files changed, 221 insertions(+), 25 deletions(-)

diff --git a/drivers/mtd/nand/fsl_elbc_nand.c b/drivers/mtd/nand/fsl_elbc_nand.c
index d29479a..9f58e78 100644
--- a/drivers/mtd/nand/fsl_elbc_nand.c
+++ b/drivers/mtd/nand/fsl_elbc_nand.c
@@ -55,7 +55,6 @@ struct fsl_elbc_mtd {
struct device *dev;
int bank;   /* Chip select bank number   */
u8 __iomem *vbase;  /* Chip select base virtual address  */
-   int page_size;  /* NAND page size (0=512, 1=2048)*/
unsigned int fmr;   /* FCM Flash Mode Register value */
 };
 
@@ -75,6 +74,8 @@ struct fsl_elbc_fcm_ctrl {
unsigned int use_mdr;/* Non zero if the MDR is to be set  */
unsigned int oob;/* Non zero if operating on OOB data */
unsigned int counter;/* counter for the initializations   */
+
+   char *buffer;/* just be used when pagesize  2048 */
 };
 
 /* These map to the positions used by the FCM hardware ECC generator */
@@ -150,6 +151,42 @@ static struct nand_bbt_descr bbt_mirror_descr = {
 };
 
 /*=*/
+static void io_to_buffer(struct mtd_info *mtd, int subpage, int oob)
+{
+   struct nand_chip *chip = mtd-priv;
+   struct fsl_elbc_mtd *priv = chip-priv;
+   struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl = priv-ctrl-nand;
+   void *src, *dst;
+   int len = (oob ? 64 : 2048);
+
+   if (oob)
+   dst = elbc_fcm_ctrl-buffer + mtd-writesize + subpage * 64;
+   else
+   dst = elbc_fcm_ctrl-buffer + subpage * 2048;
+
+   src = elbc_fcm_ctrl-addr + (oob ? 2048 : 0);
+   memcpy_fromio(dst, src, len);
+}
+
+static void buffer_to_io(struct mtd_info *mtd, int subpage, int oob)
+{
+   struct nand_chip *chip = mtd-priv;
+   struct fsl_elbc_mtd *priv = chip-priv;
+   struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl = priv-ctrl-nand;
+   void *src, *dst;
+   int len = (oob ? 64 : 2048);
+
+   if (oob)
+   src = elbc_fcm_ctrl-buffer + mtd-writesize + subpage * 64;
+   else
+   src = elbc_fcm_ctrl-buffer + subpage * 2048;
+
+   dst = elbc_fcm_ctrl-addr + (oob ? 2048 : 0);
+   memcpy_toio(dst, src, len);
+
+   /* See the in_8() in fsl_elbc_write_buf() */
+   in_8(elbc_fcm_ctrl-addr + (oob ? 2111 : 2047));
+}
 
 /*
  * Set up the FCM hardware block and page address fields, and the fcm
@@ -166,7 +203,7 @@ static void set_addr(struct mtd_info *mtd, int column, int 
page_addr, int oob)
 
elbc_fcm_ctrl-page = page_addr;
 
-   if (priv-page_size) {
+   if (mtd-writesize = 2048) {
/*
 * large page size chip : FPAR[PI] save the lowest 6 bits,
 *FBAR[BLK] save the other bits.
@@ -193,7 +230,7 @@ static void set_addr(struct mtd_info *mtd, int column, int 
page_addr, int oob)
 
/* for OOB data point to the second half of the buffer */
if (oob)
-   elbc_fcm_ctrl-index += priv-page_size ? 2048 : 512;
+   elbc_fcm_ctrl-index += mtd-writesize;
 
dev_vdbg(priv-dev, set_addr: bank=%d, 
elbc_fcm_ctrl-addr=0x%p (0x%p), 
@@ -272,13 +309,14 @@ static int fsl_elbc_run_command(struct mtd_info *mtd)
return 0;
 }
 
-static void fsl_elbc_do_read(struct nand_chip *chip, int oob)
+static void fsl_elbc_do_read(struct mtd_info *mtd, int oob)
 {
+   struct nand_chip *chip = mtd-priv;
struct fsl_elbc_mtd *priv = chip-priv;
struct fsl_lbc_ctrl *ctrl = priv-ctrl;
struct fsl_lbc_regs __iomem *lbc = ctrl-regs;
 
-   if (priv-page_size) {
+   if (mtd-writesize = 2048) {
out_be32(lbc-fir,
 (FIR_OP_CM0  FIR_OP0_SHIFT) |
 (FIR_OP_CA   FIR_OP1_SHIFT) |
@@ -311,6 +349,7 @@ static void fsl_elbc_cmdfunc(struct mtd_info *mtd, unsigned 
int command,
struct fsl_lbc_ctrl *ctrl = priv-ctrl;
struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl = ctrl-nand;
struct fsl_lbc_regs __iomem *lbc = ctrl-regs;
+   int i, n;
 
elbc_fcm_ctrl-use_mdr = 0;
 
@@ -337,8 +376,30 @@ static void fsl_elbc_cmdfunc(struct mtd_info *mtd, 
unsigned int command,
elbc_fcm_ctrl-read_bytes = mtd-writesize + mtd-oobsize;
elbc_fcm_ctrl-index += column;
 
-   

[PATCH v4 0/7] Kudmp support for PPC440x

2011-12-09 Thread Suzuki K. Poulose
The following series implements:

 * Generic framework for relocatable kernel on PPC32, based on processing 
   the dynamic relocation entries.
 * Relocatable kernel support for 44x
 * Kdump support for 44x. Doesn't support 47x yet, as the kexec 
   support is missing.

Changes from V3:

 * Added a new config - NONSTATIC_KERNEL - to group different types of 
relocatable
   kernel. (Suggested by: Josh Boyer)
 * Added supported ppc relocation types in relocs_check.pl for verifying the
   relocations used in the kernel.

Changes from V2:

 * Renamed old style mapping based RELOCATABLE on BookE to DYNAMIC_MEMSTART.
   Suggested by: Scott Wood
 * Added support for DYNAMIC_MEMSTART on PPC440x
 * Reverted back to RELOCATABLE and RELOCATABLE_PPC32 from RELOCATABLE_PPC32_PIE
   for relocation based on processing dynamic reloc entries for PPC32.
 * Ensure the modified instructions are flushed and the i-cache invalidated at
   the end of relocate(). - Reported by : Josh Poimboeuf

Changes from V1:

 * Splitted patch 'Enable CONFIG_RELOCATABLE for PPC44x' to move some
   of the generic bits to a new patch.
 * Renamed RELOCATABLE_PPC32 to RELOCATABLE_PPC32_PIE and provided options to
   retained old style mapping. (Suggested by: Scott Wood)
 * Added support for avoiding the overlapping of uncompressed kernel
   with boot wrapper for PPC images.

The patches are based on -next tree for ppc.

I have tested these patches on Ebony, Sequoia and Virtex(QEMU Emulated).
I haven't tested the RELOCATABLE bits on PPC_47x yet, as I don't have access
to one. However, RELOCATABLE should work fine there as we only depend on the 
runtime address and the XLAT entry setup by the boot loader. It would be great 
if
somebody could test these patches on a 47x.


---

Suzuki K. Poulose (7):
  [boot] Change the load address for the wrapper to fit the kernel
  [44x] Enable CRASH_DUMP for 440x
  [44x] Enable CONFIG_RELOCATABLE for PPC44x
  [ppc] Define virtual-physical translations for RELOCATABLE
  [ppc] Process dynamic relocations for kernel
  [44x] Enable DYNAMIC_MEMSTART for 440x
  [booke] Rename mapping based RELOCATABLE to DYNAMIC_MEMSTART for BookE


 arch/powerpc/Kconfig  |   46 +--
 arch/powerpc/Makefile |6 +
 arch/powerpc/boot/wrapper |   20 +
 arch/powerpc/configs/44x/iss476-smp_defconfig |2 
 arch/powerpc/include/asm/kdump.h  |4 -
 arch/powerpc/include/asm/page.h   |   89 -
 arch/powerpc/kernel/Makefile  |2 
 arch/powerpc/kernel/crash_dump.c  |4 -
 arch/powerpc/kernel/head_44x.S|  105 +
 arch/powerpc/kernel/head_fsl_booke.S  |2 
 arch/powerpc/kernel/machine_kexec.c   |2 
 arch/powerpc/kernel/prom_init.c   |2 
 arch/powerpc/kernel/vmlinux.lds.S |8 ++
 arch/powerpc/mm/44x_mmu.c |2 
 arch/powerpc/mm/init_32.c |7 ++
 arch/powerpc/relocs_check.pl  |7 ++
 16 files changed, 282 insertions(+), 26 deletions(-)

--
Suzuki

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH v4 1/7] [booke] Rename mapping based RELOCATABLE to DYNAMIC_MEMSTART for BookE

2011-12-09 Thread Suzuki K. Poulose
The current implementation of CONFIG_RELOCATABLE in BookE is based
on mapping the page aligned kernel load address to KERNELBASE. This
approach however is not enough for platforms, where the TLB page size
is large (e.g, 256M on 44x). So we are renaming the RELOCATABLE used
currently in BookE to DYNAMIC_MEMSTART to reflect the actual method.

The CONFIG_RELOCATABLE for PPC32(BookE) based on processing of the
dynamic relocations will be introduced in the later in the patch series.

This change would allow the use of the old method of RELOCATABLE for
platforms which can afford to enforce the page alignment (platforms with
smaller TLB size).

Changes since v3:

* Introduced a new config, NONSTATIC_KERNEL, to denote a kernel which is
  either a RELOCATABLE or DYNAMIC_MEMSTART(Suggested by: Josh Boyer)

Suggested-by: Scott Wood scottw...@freescale.com
Tested-by: Scott Wood scottw...@freescale.com

Signed-off-by: Suzuki K. Poulose suz...@in.ibm.com
Cc: Scott Wood scottw...@freescale.com
Cc: Kumar Gala ga...@kernel.crashing.org
Cc: Josh Boyer jwbo...@gmail.com
Cc: Benjamin Herrenschmidt b...@kernel.crashing.org
Cc: linux ppc dev linuxppc-dev@lists.ozlabs.org
---

 arch/powerpc/Kconfig  |   60 +
 arch/powerpc/configs/44x/iss476-smp_defconfig |2 -
 arch/powerpc/include/asm/kdump.h  |4 +-
 arch/powerpc/include/asm/page.h   |4 +-
 arch/powerpc/kernel/crash_dump.c  |4 +-
 arch/powerpc/kernel/head_44x.S|4 +-
 arch/powerpc/kernel/head_fsl_booke.S  |2 -
 arch/powerpc/kernel/machine_kexec.c   |2 -
 arch/powerpc/kernel/prom_init.c   |2 -
 arch/powerpc/mm/44x_mmu.c |2 -
 10 files changed, 55 insertions(+), 31 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 7c93c7e..fac92ce 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -364,7 +364,8 @@ config KEXEC
 config CRASH_DUMP
bool Build a kdump crash kernel
depends on PPC64 || 6xx || FSL_BOOKE
-   select RELOCATABLE if PPC64 || FSL_BOOKE
+   select RELOCATABLE if PPC64
+   select DYNAMIC_MEMSTART if FSL_BOOKE
help
  Build a kernel suitable for use as a kdump capture kernel.
  The same kernel binary can be used as production kernel and dump
@@ -773,6 +774,10 @@ source drivers/rapidio/Kconfig
 
 endmenu
 
+config NONSTATIC_KERNEL
+   bool
+   default n
+
 menu Advanced setup
depends on PPC32
 
@@ -822,23 +827,39 @@ config LOWMEM_CAM_NUM
int Number of CAMs to use to map low memory if LOWMEM_CAM_NUM_BOOL
default 3
 
-config RELOCATABLE
-   bool Build a relocatable kernel (EXPERIMENTAL)
+config DYNAMIC_MEMSTART
+   bool Enable page aligned dynamic load address for kernel 
(EXPERIMENTAL)
depends on EXPERIMENTAL  ADVANCED_OPTIONS  FLATMEM  (FSL_BOOKE || 
PPC_47x)
-   help
- This builds a kernel image that is capable of running at the
- location the kernel is loaded at (some alignment restrictions may
- exist).
-
- One use is for the kexec on panic case where the recovery kernel
- must live at a different physical address than the primary
- kernel.
-
- Note: If CONFIG_RELOCATABLE=y, then the kernel runs from the address
- it has been loaded at and the compile time physical addresses
- CONFIG_PHYSICAL_START is ignored.  However CONFIG_PHYSICAL_START
- setting can still be useful to bootwrappers that need to know the
- load location of the kernel (eg. u-boot/mkimage).
+   select NONSTATIC_KERNEL
+   help
+ This option enables the kernel to be loaded at any page aligned
+ physical address. The kernel creates a mapping from KERNELBASE to 
+ the address where the kernel is loaded. The page size here implies
+ the TLB page size of the mapping for kernel on the particular 
platform.
+ Please refer to the init code for finding the TLB page size.
+
+ DYNAMIC_MEMSTART is an easy way of implementing pseudo-RELOCATABLE
+ kernel image, where the only restriction is the page aligned kernel
+ load address. When this option is enabled, the compile time physical 
+ address CONFIG_PHYSICAL_START is ignored.
+
+# Mapping based RELOCATABLE is moved to DYNAMIC_MEMSTART
+# config RELOCATABLE
+#  bool Build a relocatable kernel (EXPERIMENTAL)
+#  depends on EXPERIMENTAL  ADVANCED_OPTIONS  FLATMEM  (FSL_BOOKE || 
PPC_47x)
+#  help
+#This builds a kernel image that is capable of running at the
+#location the kernel is loaded at, without any alignment restrictions.
+#
+#One use is for the kexec on panic case where the recovery kernel
+#must live at a different physical address than the primary
+#kernel.
+#
+#Note: If CONFIG_RELOCATABLE=y, then the kernel runs from 

[PATCH v4 2/7] [44x] Enable DYNAMIC_MEMSTART for 440x

2011-12-09 Thread Suzuki K. Poulose
DYNAMIC_MEMSTART(old RELOCATABLE) was restricted only to PPC_47x variants
of 44x. This patch enables DYNAMIC_MEMSTART for 440x based chipsets.

Signed-off-by: Suzuki K. Poulose suz...@in.ibm.com
Cc: Josh Boyer jwbo...@gmail.com
Cc: Kumar Gala ga...@kernel.crashing.org
Cc: Benjamin Herrenschmidt b...@kernel.crashing.org
Cc: linux ppc dev linuxppc-dev@lists.ozlabs.org
---

 arch/powerpc/Kconfig   |2 +-
 arch/powerpc/kernel/head_44x.S |   12 
 2 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index fac92ce..5eafe95 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -829,7 +829,7 @@ config LOWMEM_CAM_NUM
 
 config DYNAMIC_MEMSTART
bool Enable page aligned dynamic load address for kernel 
(EXPERIMENTAL)
-   depends on EXPERIMENTAL  ADVANCED_OPTIONS  FLATMEM  (FSL_BOOKE || 
PPC_47x)
+   depends on EXPERIMENTAL  ADVANCED_OPTIONS  FLATMEM  (FSL_BOOKE || 
44x)
select NONSTATIC_KERNEL
help
  This option enables the kernel to be loaded at any page aligned
diff --git a/arch/powerpc/kernel/head_44x.S b/arch/powerpc/kernel/head_44x.S
index d5f787d..62a4cd5 100644
--- a/arch/powerpc/kernel/head_44x.S
+++ b/arch/powerpc/kernel/head_44x.S
@@ -802,12 +802,24 @@ skpinv:   addir4,r4,1 /* 
Increment */
 /*
  * Configure and load pinned entry into TLB slot 63.
  */
+#ifdef CONFIG_DYNAMIC_MEMSTART
+
+   /* Read the XLAT entry for our current mapping */
+   tlbre   r25,r23,PPC44x_TLB_XLAT
+
+   lis r3,KERNELBASE@h
+   ori r3,r3,KERNELBASE@l
+
+   /* Use our current RPN entry */
+   mr  r4,r25
+#else
 
lis r3,PAGE_OFFSET@h
ori r3,r3,PAGE_OFFSET@l
 
/* Kernel is at the base of RAM */
li r4, 0/* Load the kernel physical address */
+#endif
 
/* Load the kernel PID = 0 */
li  r0,0

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH v4 3/7] [ppc] Process dynamic relocations for kernel

2011-12-09 Thread Suzuki K. Poulose
The following patch implements the dynamic relocation processing for
PPC32 kernel. relocate() accepts the target virtual address and relocates
 the kernel image to the same.

Currently the following relocation types are handled :

R_PPC_RELATIVE
R_PPC_ADDR16_LO
R_PPC_ADDR16_HI
R_PPC_ADDR16_HA

The last 3 relocations in the above list depends on value of Symbol indexed
whose index is encoded in the Relocation entry. Hence we need the Symbol
Table for processing such relocations.

Note: The GNU ld for ppc32 produces buggy relocations for relocation types
that depend on symbols. The value of the symbols with STB_LOCAL scope
should be assumed to be zero. - Alan Modra

Changes since V3:
 * Updated relocation types for ppc in arch/powerpc/relocs_check.pl

Changes since v2:
  * Flush the d-cache'd instructions and invalidate the i-cache to reflect
the processed instructions.(Reported by: Josh Poimboeuf)

Signed-off-by: Suzuki K. Poulose suz...@in.ibm.com
Signed-off-by: Josh Poimboeuf jpoim...@linux.vnet.ibm.com
Cc: Paul Mackerras pau...@samba.org
Cc: Benjamin Herrenschmidt b...@kernel.crashing.org
Cc: Alan Modra amo...@au1.ibm.com
Cc: Kumar Gala ga...@kernel.crashing.org
Cc: linuxppc-dev linuxppc-dev@lists.ozlabs.org
---

 arch/powerpc/Kconfig  |   42 ++---
 arch/powerpc/Makefile |6 +++--
 arch/powerpc/kernel/Makefile  |2 ++
 arch/powerpc/kernel/vmlinux.lds.S |8 ++-
 arch/powerpc/relocs_check.pl  |7 ++
 5 files changed, 44 insertions(+), 21 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 5eafe95..6936cb0 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -843,23 +843,31 @@ config DYNAMIC_MEMSTART
  load address. When this option is enabled, the compile time physical 
  address CONFIG_PHYSICAL_START is ignored.
 
-# Mapping based RELOCATABLE is moved to DYNAMIC_MEMSTART
-# config RELOCATABLE
-#  bool Build a relocatable kernel (EXPERIMENTAL)
-#  depends on EXPERIMENTAL  ADVANCED_OPTIONS  FLATMEM  (FSL_BOOKE || 
PPC_47x)
-#  help
-#This builds a kernel image that is capable of running at the
-#location the kernel is loaded at, without any alignment restrictions.
-#
-#One use is for the kexec on panic case where the recovery kernel
-#must live at a different physical address than the primary
-#kernel.
-#
-#Note: If CONFIG_RELOCATABLE=y, then the kernel runs from the address
-#it has been loaded at and the compile time physical addresses
-#CONFIG_PHYSICAL_START is ignored.  However CONFIG_PHYSICAL_START
-#setting can still be useful to bootwrappers that need to know the
-#load location of the kernel (eg. u-boot/mkimage).
+ This option is overridden by RELOCATABLE.
+
+config RELOCATABLE
+   bool Build a relocatable kernel (EXPERIMENTAL)
+   depends on EXPERIMENTAL  ADVANCED_OPTIONS  FLATMEM
+   select NONSTATIC_KERNEL
+   help
+ This builds a kernel image that is capable of running at the
+ location the kernel is loaded at, without any alignment restrictions.
+ This feature is a superset of DYNAMIC_MEMSTART, and hence overrides 
+ it.
+
+ One use is for the kexec on panic case where the recovery kernel
+ must live at a different physical address than the primary
+ kernel.
+
+ Note: If CONFIG_RELOCATABLE=y, then the kernel runs from the address
+ it has been loaded at and the compile time physical addresses
+ CONFIG_PHYSICAL_START is ignored.  However CONFIG_PHYSICAL_START
+ setting can still be useful to bootwrappers that need to know the
+ load address of the kernel (eg. u-boot/mkimage).
+
+config RELOCATABLE_PPC32
+   def_bool y
+   depends on PPC32  RELOCATABLE
 
 config PAGE_OFFSET_BOOL
bool Set custom page offset address
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index ffe4d88..b8b105c 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -63,9 +63,9 @@ override CC   += -m$(CONFIG_WORD_SIZE)
 override AR:= GNUTARGET=elf$(CONFIG_WORD_SIZE)-powerpc $(AR)
 endif
 
-LDFLAGS_vmlinux-yy := -Bstatic
-LDFLAGS_vmlinux-$(CONFIG_PPC64)$(CONFIG_RELOCATABLE) := -pie
-LDFLAGS_vmlinux:= $(LDFLAGS_vmlinux-yy)
+LDFLAGS_vmlinux-y := -Bstatic
+LDFLAGS_vmlinux-$(CONFIG_RELOCATABLE) := -pie
+LDFLAGS_vmlinux:= $(LDFLAGS_vmlinux-y)
 
 CFLAGS-$(CONFIG_PPC64) := -mminimal-toc -mtraceback=no -mcall-aixdesc
 CFLAGS-$(CONFIG_PPC32) := -ffixed-r2 -mmultiple
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index ce4f7f1..ee728e4 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -85,6 +85,8 @@ extra-$(CONFIG_FSL_BOOKE) := head_fsl_booke.o
 extra-$(CONFIG_8xx):= head_8xx.o
 extra-y+= 

[PATCH v4 4/7] [ppc] Define virtual-physical translations for RELOCATABLE

2011-12-09 Thread Suzuki K. Poulose
We find the runtime address of _stext and relocate ourselves based
on the following calculation.

virtual_base = ALIGN(KERNELBASE,KERNEL_TLB_PIN_SIZE) +
MODULO(_stext.run,KERNEL_TLB_PIN_SIZE)

relocate() is called with the Effective Virtual Base Address (as
shown below)

| Phys. Addr| Virt. Addr |
Page||
Boundary|   ||
|   ||
|   ||
Kernel Load |___|_ __ _ _ _ _|- Effective
Addr(_stext)|   |  ^ |Virt. Base Addr
|   |  | |
|   |  | |
|   |reloc_offset|
|   |  | |
|   |  | |
|   |__v_|-(KERNELBASE)%TLB_SIZE
|   ||
|   ||
|   ||
Page|---||
Boundary|   ||


On BookE, we need __va()  __pa() early in the boot process to access
the device tree.

Currently this has been defined as :

#define __va(x) ((void *)(unsigned long)((phys_addr_t)(x) -
PHYSICAL_START + KERNELBASE)
where:
 PHYSICAL_START is kernstart_addr - a variable updated at runtime.
 KERNELBASE is the compile time Virtual base address of kernel.

This won't work for us, as kernstart_addr is dynamic and will yield different
results for __va()/__pa() for same mapping.

e.g.,

Let the kernel be loaded at 64MB and KERNELBASE be 0xc000 (same as
PAGE_OFFSET).

In this case, we would be mapping 0 to 0xc000, and kernstart_addr = 64M

Now __va(1MB) = (0x10) - (0x400) + 0xc000
= 0xbc10 , which is wrong.

it should be : 0xc000 + 0x10 = 0xc010

On platforms which support AMP, like PPC_47x (based on 44x), the kernel
could be loaded at highmem. Hence we cannot always depend on the compile
time constants for mapping.

Here are the possible solutions:

1) Update kernstart_addr(PHSYICAL_START) to match the Physical address of
compile time KERNELBASE value, instead of the actual Physical_Address(_stext).

The disadvantage is that we may break other users of PHYSICAL_START. They
could be replaced with __pa(_stext).

2) Redefine __va()  __pa() with relocation offset


#ifdef  CONFIG_RELOCATABLE_PPC32
#define __va(x) ((void *)(unsigned long)((phys_addr_t)(x) - PHYSICAL_START + 
(KERNELBASE + RELOC_OFFSET)))
#define __pa(x) ((unsigned long)(x) + PHYSICAL_START - (KERNELBASE + 
RELOC_OFFSET))
#endif

where, RELOC_OFFSET could be

  a) A variable, say relocation_offset (like kernstart_addr), updated
 at boot time. This impacts performance, as we have to load an additional
 variable from memory.

OR

  b) #define RELOC_OFFSET ((PHYSICAL_START  PPC_PIN_SIZE_OFFSET_MASK) - \
  (KERNELBASE  PPC_PIN_SIZE_OFFSET_MASK))

   This introduces more calculations for doing the translation.

3) Redefine __va()  __pa() with a new variable

i.e,

#define __va(x) ((void *)(unsigned long)((phys_addr_t)(x) + VIRT_PHYS_OFFSET))

where VIRT_PHYS_OFFSET :

#ifdef CONFIG_RELOCATABLE_PPC32
#define VIRT_PHYS_OFFSET virt_phys_offset
#else
#define VIRT_PHYS_OFFSET (KERNELBASE - PHYSICAL_START)
#endif /* CONFIG_RELOCATABLE_PPC32 */

where virt_phy_offset is updated at runtime to :

Effective KERNELBASE - kernstart_addr.

Taking our example, above:

virt_phys_offset = effective_kernelstart_vaddr - kernstart_addr
 = 0xc040 - 0x40
 = 0xc000
and

__va(0x10) = 0xc000 + 0x10 = 0xc010
 which is what we want.

I have implemented (3) in the following patch which has same cost of
operation as the existing one.

I have tested the patches on 440x platforms only. However this should
work fine for PPC_47x also, as we only depend on the runtime address
and the current TLB XLAT entry for the startup code, which is available
in r25. I don't have access to a 47x board yet. So, it would be great if
somebody could test this on 47x.

Signed-off-by: Suzuki K. Poulose suz...@in.ibm.com
Cc: Benjamin Herrenschmidt b...@kernel.crashing.org
Cc: Kumar Gala ga...@kernel.crashing.org
Cc: linuxppc-dev linuxppc-dev@lists.ozlabs.org
---

 arch/powerpc/include/asm/page.h |   85 ++-
 arch/powerpc/mm/init_32.c   |7 +++
 2 files changed, 89 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
index f149967..f072e97 100644
--- a/arch/powerpc/include/asm/page.h
+++ b/arch/powerpc/include/asm/page.h
@@ -97,12 +97,26 @@ extern unsigned int HPAGE_SHIFT;
 
 extern phys_addr_t memstart_addr;
 extern phys_addr_t kernstart_addr;
+
+#ifdef CONFIG_RELOCATABLE_PPC32
+extern long long virt_phys_offset;
 #endif
+
+#endif /* 

[PATCH v4 5/7] [44x] Enable CONFIG_RELOCATABLE for PPC44x

2011-12-09 Thread Suzuki K. Poulose
The following patch adds relocatable kernel support - based on processing
of dynamic relocations - for PPC44x kernel.

We find the runtime address of _stext and relocate ourselves based
on the following calculation.

virtual_base = ALIGN(KERNELBASE,256M) +
MODULO(_stext.run,256M)

relocate() is called with the Effective Virtual Base Address (as
shown below)

| Phys. Addr| Virt. Addr |
Page (256M) ||
Boundary|   ||
|   ||
|   ||
Kernel Load |___|_ __ _ _ _ _|- Effective
Addr(_stext)|   |  ^ |Virt. Base Addr
|   |  | |
|   |  | |
|   |reloc_offset|
|   |  | |
|   |  | |
|   |__v_|-(KERNELBASE)%256M
|   ||
|   ||
|   ||
Page(256M)  |---||
Boundary|   ||

The virt_phys_offset is updated accordingly, i.e,

virt_phys_offset = effective. kernel virt base - kernstart_addr

I have tested the patches on 440x platforms only. However this should
work fine for PPC_47x also, as we only depend on the runtime address
and the current TLB XLAT entry for the startup code, which is available
in r25. I don't have access to a 47x board yet. So, it would be great if
somebody could test this on 47x.

Signed-off-by: Suzuki K. Poulose suz...@in.ibm.com
Cc: Benjamin Herrenschmidt b...@kernel.crashing.org
Cc: Kumar Gala ga...@kernel.crashing.org
Cc: Tony Breeds t...@bakeyournoodle.com
Cc: Josh Boyer jwbo...@gmail.com
Cc: linuxppc-dev linuxppc-dev@lists.ozlabs.org
---

 arch/powerpc/Kconfig   |2 -
 arch/powerpc/kernel/head_44x.S |   95 +++-
 2 files changed, 94 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 6936cb0..90cd8d3 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -847,7 +847,7 @@ config DYNAMIC_MEMSTART
 
 config RELOCATABLE
bool Build a relocatable kernel (EXPERIMENTAL)
-   depends on EXPERIMENTAL  ADVANCED_OPTIONS  FLATMEM
+   depends on EXPERIMENTAL  ADVANCED_OPTIONS  FLATMEM  44x
select NONSTATIC_KERNEL
help
  This builds a kernel image that is capable of running at the
diff --git a/arch/powerpc/kernel/head_44x.S b/arch/powerpc/kernel/head_44x.S
index 62a4cd5..213ed31 100644
--- a/arch/powerpc/kernel/head_44x.S
+++ b/arch/powerpc/kernel/head_44x.S
@@ -64,6 +64,35 @@ _ENTRY(_start);
mr  r31,r3  /* save device tree ptr */
li  r24,0   /* CPU number */
 
+#ifdef CONFIG_RELOCATABLE
+/*
+ * Relocate ourselves to the current runtime address.
+ * This is called only by the Boot CPU.
+ * relocate is called with our current runtime virutal
+ * address.
+ * r21 will be loaded with the physical runtime address of _stext
+ */
+   bl  0f  /* Get our runtime address */
+0: mflrr21 /* Make it accessible */
+   addis   r21,r21,(_stext - 0b)@ha
+   addir21,r21,(_stext - 0b)@l /* Get our current runtime base 
*/
+
+   /*
+* We have the runtime (virutal) address of our base.
+* We calculate our shift of offset from a 256M page.
+* We could map the 256M page we belong to at PAGE_OFFSET and
+* get going from there.
+*/
+   lis r4,KERNELBASE@h
+   ori r4,r4,KERNELBASE@l
+   rlwinm  r6,r21,0,4,31   /* r6 = PHYS_START % 256M */
+   rlwinm  r5,r4,0,4,31/* r5 = KERNELBASE % 256M */
+   subfr3,r5,r6/* r3 = r6 - r5 */
+   add r3,r4,r3/* Required Virutal Address */
+
+   bl  relocate
+#endif
+
bl  init_cpu_state
 
/*
@@ -86,7 +115,64 @@ _ENTRY(_start);
 
bl  early_init
 
-#ifdef CONFIG_DYNAMIC_MEMSTART
+#ifdef CONFIG_RELOCATABLE
+   /*
+* Relocatable kernel support based on processing of dynamic
+* relocation entries.
+*
+* r25 will contain RPN/ERPN for the start address of memory
+* r21 will contain the current offset of _stext
+*/
+   lis r3,kernstart_addr@ha
+   la  r3,kernstart_addr@l(r3)
+
+   /*
+* Compute the kernstart_addr.
+* kernstart_addr = (r6,r8)
+* kernstart_addr  ~0xfff = (r6,r7)
+*/
+   rlwinm  r6,r25,0,28,31  /* ERPN. Bits 32-35 of Address */
+   rlwinm  r7,r25,0,0,3/* RPN - assuming 256 MB page size */
+   rlwinm  r8,r21,0,4,31   /* r8 = (_stext  0xfff) */
+   or  r8,r7,r8/* Compute the lower 32bit of kernstart_addr */
+
+   /* 

[PATCH v4 6/7] [44x] Enable CRASH_DUMP for 440x

2011-12-09 Thread Suzuki K. Poulose
Now that we have relocatable kernel, supporting CRASH_DUMP only requires
turning the switches on for UP machines.

We don't have kexec support on 47x yet. Enabling SMP support would be done
as part of enabling the PPC_47x support.


Signed-off-by: Suzuki K. Poulose suz...@in.ibm.com
Cc: Josh Boyer jwbo...@gmail.com
Cc: Benjamin Herrenschmidt b...@kernel.crashing.org
Cc: linuxppc-dev linuxppc-dev@lists.ozlabs.org
---

 arch/powerpc/Kconfig |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 90cd8d3..d612943 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -363,8 +363,8 @@ config KEXEC
 
 config CRASH_DUMP
bool Build a kdump crash kernel
-   depends on PPC64 || 6xx || FSL_BOOKE
-   select RELOCATABLE if PPC64
+   depends on PPC64 || 6xx || FSL_BOOKE || (44x  !SMP  !PPC_47x)
+   select RELOCATABLE if PPC64 || 44x
select DYNAMIC_MEMSTART if FSL_BOOKE
help
  Build a kernel suitable for use as a kdump capture kernel.

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH v4 7/7] [boot] Change the load address for the wrapper to fit the kernel

2011-12-09 Thread Suzuki K. Poulose
The wrapper code which uncompresses the kernel in case of a 'ppc' boot
is by default loaded at 0x0040 and the kernel will be uncompressed
to fit the location 0-0x0040. But with dynamic relocations, the size
of the kernel may exceed 0x0040(4M). This would cause an overlap
of the uncompressed kernel and the boot wrapper, causing a failure in
boot.

The message looks like :


   zImage starting: loaded at 0x0040 (sp: 0x0065ffb0)
   Allocating 0x5ce650 bytes for kernel ...
   Insufficient memory for kernel at address 0! (_start=0040, uncompressed 
size=00591a20)

This patch shifts the load address of the boot wrapper code to the next higher 
MB,
according to the size of  the uncompressed vmlinux.

Signed-off-by: Suzuki K. Poulose suz...@in.ibm.com
---

 arch/powerpc/boot/wrapper |   20 
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/boot/wrapper b/arch/powerpc/boot/wrapper
index 14cd4bc..4d625cd 100755
--- a/arch/powerpc/boot/wrapper
+++ b/arch/powerpc/boot/wrapper
@@ -257,6 +257,8 @@ vmz=$tmpdir/`basename \$kernel\`.$ext
 if [ -z $cacheit -o ! -f $vmz$gzip -o $vmz$gzip -ot $kernel ]; then
 ${CROSS}objcopy $objflags $kernel $vmz.$$
 
+strip_size=$(stat -c %s $vmz.$$)
+
 if [ -n $gzip ]; then
 gzip -n -f -9 $vmz.$$
 fi
@@ -266,6 +268,24 @@ if [ -z $cacheit -o ! -f $vmz$gzip -o $vmz$gzip -ot 
$kernel ]; then
 else
vmz=$vmz.$$
 fi
+else
+# Calculate the vmlinux.strip size
+${CROSS}objcopy $objflags $kernel $vmz.$$
+strip_size=$(stat -c %s $vmz.$$)
+rm -f $vmz.$$
+fi
+
+# Round the size to next higher MB limit
+round_size=$(((strip_size + 0xf)  0xfff0))
+
+round_size=0x$(printf %x $round_size)
+link_addr=$(printf %d $link_address)
+
+if [ $link_addr -lt $strip_size ]; then
+echo WARN: Uncompressed kernel size(0x$(printf %x\n $strip_size)) \
+exceeds the address of the wrapper($link_address)
+echo WARN: Fixing the link_address to ($round_size))
+link_address=$round_size
 fi
 
 vmz=$vmz$gzip

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Unable to connect via Ethernet on P1022RDK

2011-12-09 Thread Arshad, Farrukh
Greetings All,

I am doing a dual boot on P1022RDK with following configuration

Core 0: Linux RT: Running fine, ethernet@B is working fine.
Core 1: Linux: Crashing at following, ethernet@B1000 is not creating a link

I have allocated ethernet1 to core 1 in its DTS file but when I boot my kernel 
over NFS there seems no link and kernel crashes at following

[2.812122] rxbd[7]: addr,vaddr=0x1f70fc00,0xcf70fc00
[3.821896] IP-Config: Guessing netmask 255.255.0.0
[3.826931] IP-Config: Complete:
[3.829992]  device=eth0, addr=137.202.156.128, mask=255.255.0.0, 
gw=137.202.156.191,
[3.838109]  host=137.202.156.128, domain=, nis-domain=(none),
[3.844292]  bootserver=255.255.255.255, rootserver=137.202.156.191, 
rootpath=
[3.852308] Looking up port of RPC 13/2 on 137.202.156.191
OK
[   38.857888] rpcbind: server 137.202.156.191 not responding, timed out
[   38.864387] Root-NFS: Unable to get nfsd port number from server, using 
default
[   38.871708] Looking up port of RPC 15/1 on 137.202.156.191
[   73.873886] rpcbind: server 137.202.156.191 not responding, timed out
[   73.880382] Root-NFS: Unable to get mountd port number from server, using 
default

Given is my DTS files for both cores.

Core 1 DTS: ethernet1 is not creating a link

   mdio@25000 {
#address-cells = 1;
#size-cells = 0;
compatible = fsl,etsec2-mdio;
reg = 0x25000 0x1000 0xb1030 0x4;
phy1: ethernet-phy@1 {
 interrupt-parent = mpic;
 interrupts = 9 1;
 reg = 0x2;
};
   };

   enet1: ethernet@B1000 {
#address-cells = 1;
#size-cells = 1;
cell-index = 0;
device_type = network;
model = eTSEC;
compatible = fsl,etsec2;
fsl,num_rx_queues = 0x8;
fsl,num_tx_queues = 0x8;
clk-handle = etsec2_clk;
local-mac-address = [ 00 00 00 00 00 00 ];
interrupt-parent = mpic;
//fixed-link = 1 1 1000 0 0;
fixed-link = 1 1 100 0 0;
//phy-handle = phy1;
phy-connection-type = rgmii-id;
queue-group@0{
 #address-cells = 1;
 #size-cells = 1;
 reg = 0xB1000 0x1000;
 interrupts = 35 2 36 2 40 2;
};
queue-group@1{
 #address-cells = 1;
 #size-cells = 1;
 reg = 0xB5000 0x1000;
 interrupts = 51 2 52 2 67 2;
};
   };

Core 0 DTS file. Running smooth

   mdio@24000 {
#address-cells = 1;
#size-cells = 0;
compatible = fsl,etsec2-mdio;
reg = 0x24000 0x1000 0xb0030 0x4;

phy0: ethernet-phy@0 {
 interrupts = 3 1;
 reg = 0x1;
};
   };

   enet0: ethernet@B {
#address-cells = 1;
#size-cells = 1;
cell-index = 0;
device_type = network;
model = eTSEC;
compatible = fsl,etsec2;
fsl,num_rx_queues = 0x8;
fsl,num_tx_queues = 0x8;
fsl,magic-packet;
fsl,wake-on-filer;
clk-handle = etsec1_clk;
local-mac-address = [ 00 00 00 00 00 00 ];
interrupt-parent = mpic;
phy-handle = phy0;
phy-connection-type = rgmii-id;
queue-group@0{
 #address-cells = 1;
 #size-cells = 1;
 reg = 0xB 0x1000;
 interrupts = 29 2 30 2 34 2;
};
queue-group@1{
 #address-cells = 1;
 #size-cells = 1;
 reg = 0xB4000 0x1000;
 interrupts = 17 2 18 2 24 2;
};
   };

Any thoughts on what I am doing wrong.

Best Regards

Farrukh Arshad

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH v4 3/7] [ppc] Process dynamic relocations for kernel

2011-12-09 Thread Josh Boyer
On Fri, Dec 9, 2011 at 6:47 AM, Suzuki K. Poulose suz...@in.ibm.com wrote:

 Signed-off-by: Suzuki K. Poulose suz...@in.ibm.com
 Signed-off-by: Josh Poimboeuf jpoim...@linux.vnet.ibm.com
 Cc: Paul Mackerras pau...@samba.org
 Cc: Benjamin Herrenschmidt b...@kernel.crashing.org
 Cc: Alan Modra amo...@au1.ibm.com
 Cc: Kumar Gala ga...@kernel.crashing.org
 Cc: linuxppc-dev linuxppc-dev@lists.ozlabs.org
 ---

  arch/powerpc/Kconfig              |   42 
 ++---
  arch/powerpc/Makefile             |    6 +++--
  arch/powerpc/kernel/Makefile      |    2 ++
  arch/powerpc/kernel/vmlinux.lds.S |    8 ++-
  arch/powerpc/relocs_check.pl      |    7 ++
  5 files changed, 44 insertions(+), 21 deletions(-)

You're missing the whole reloc_32.S file in this patch.  Forget to do a git-add?

Can you resend just this patch with that fixed up?

josh
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Please pull 'next' branch of new 4xx tree (updated)

2011-12-09 Thread Josh Boyer
On Wed, Nov 30, 2011 at 10:14 AM, Josh Boyer jwbo...@gmail.com wrote:
 Hi Ben,

 I have a new 4xx tree setup now.  Two small commits for the next
 branch are queued up.  I'd like to get the patch series from Suzie and
 Tony included soon as well, but thought I'd start with these to get
 things rolling.

I've updated my next branch to include the Currituck changes from
Tony.  Suzie's patches from today look good, but he has an error in
one of them that is missing a file, so I'll have to send those on once
that is fixed.

Please pull this time ;)

josh

The following changes since commit fa8cbaaf5a68f62db3f9a8444ecbb940b47984cb:

  powerpc+sparc64/mm: Remove hack in mmap randomize layout (2011-11-28
11:42:09 +1100)

are available in the git repository at:
  git://git.infradead.org/users/jwboyer/powerpc-4xx.git next

Christoph Egger (1):
  powerpc/44x: Removing dead CONFIG_PPC47x

Josh Boyer (1):
  MAINTAINERS: Update PowerPC 4xx git tree

Tanmay Inamdar (1):
  powerpc/40x: Add APM8018X SOC support

Tony Breeds (7):
  powerpc/44x: pci: Use PCI_BASE_ADDRESS_MEM_PREFETCH rather than
magic value.
  powerpc/44x: pci: Add a want_sdr flag into ppc4xx_pciex_hwops
  powerpc/44x: pci: Setup the dma_window properties for each pci_controller
  powerpc/boot: Add extended precision shifts to the boot wrapper.
  powerpc/boot: Add mfdcrx
  powerpc/476fpe: Add 476fpe SoC code
  powerpc/47x: Add support for the new IBM currituck platform

 MAINTAINERS  |2 +-
 arch/powerpc/boot/Makefile   |5 +-
 arch/powerpc/boot/dcr.h  |6 +
 arch/powerpc/boot/div64.S|   52 ++
 arch/powerpc/boot/dts/currituck.dts  |  237 ++
 arch/powerpc/boot/dts/klondike.dts   |  227 
 arch/powerpc/boot/treeboot-currituck.c   |  119 +
 arch/powerpc/boot/wrapper|3 +
 arch/powerpc/configs/40x/klondike_defconfig  |   55 ++
 arch/powerpc/configs/44x/currituck_defconfig |  110 
 arch/powerpc/include/asm/reg.h   |1 +
 arch/powerpc/kernel/cputable.c   |   27 +++
 arch/powerpc/kernel/head_44x.S   |2 +
 arch/powerpc/mm/44x_mmu.c|4 -
 arch/powerpc/platforms/40x/Kconfig   |   11 ++
 arch/powerpc/platforms/40x/ppc40x_simple.c   |1 +
 arch/powerpc/platforms/44x/Kconfig   |   14 ++
 arch/powerpc/platforms/44x/Makefile  |1 +
 arch/powerpc/platforms/44x/currituck.c   |  204 ++
 arch/powerpc/sysdev/ppc4xx_pci.c |   85 +-
 arch/powerpc/sysdev/ppc4xx_pci.h |7 +
 21 files changed, 1159 insertions(+), 14 deletions(-)
 create mode 100644 arch/powerpc/boot/dts/currituck.dts
 create mode 100644 arch/powerpc/boot/dts/klondike.dts
 create mode 100644 arch/powerpc/boot/treeboot-currituck.c
 create mode 100644 arch/powerpc/configs/40x/klondike_defconfig
 create mode 100644 arch/powerpc/configs/44x/currituck_defconfig
 create mode 100644 arch/powerpc/platforms/44x/currituck.c
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH 1/2] [v3] powerpc/85xx: p1022ds: disable the NOR flash node if video is enabled

2011-12-09 Thread Timur Tabi
The Freescale P1022 has a unique pin muxing feature where the DIU video
controller's video signals are muxed with 24 of the local bus address signals.
When the DIU is enabled, the bulk of the local bus is disabled, preventing
access to memory-mapped devices like NOR flash and the pixis FPGA.

Therefore, if the DIU is going to be enabled, then memory-mapped devices on
the localbus, like NOR flash, need to be disabled.

This also means that the localbus is not a 'simple-bus' any more, so remove
that string from the compatible node.

Signed-off-by: Timur Tabi ti...@freescale.com
---
 arch/powerpc/boot/dts/fsl/p1022si-post.dtsi |6 ++-
 arch/powerpc/platforms/85xx/p1022_ds.c  |   71 +++
 2 files changed, 76 insertions(+), 1 deletions(-)

diff --git a/arch/powerpc/boot/dts/fsl/p1022si-post.dtsi 
b/arch/powerpc/boot/dts/fsl/p1022si-post.dtsi
index 16239b1..2a62edd 100644
--- a/arch/powerpc/boot/dts/fsl/p1022si-post.dtsi
+++ b/arch/powerpc/boot/dts/fsl/p1022si-post.dtsi
@@ -35,7 +35,11 @@
 lbc {
#address-cells = 2;
#size-cells = 1;
-   compatible = fsl,p1022-elbc, fsl,elbc, simple-bus;
+   /*
+* The localbus on the P1022 is not a simple-bus because of the eLBC
+* pin muxing when the DIU is enabled.
+*/
+   compatible = fsl,p1022-elbc, fsl,elbc;
interrupts = 19 2 0 0;
 };
 
diff --git a/arch/powerpc/platforms/85xx/p1022_ds.c 
b/arch/powerpc/platforms/85xx/p1022_ds.c
index 2ec39f4..29de80c 100644
--- a/arch/powerpc/platforms/85xx/p1022_ds.c
+++ b/arch/powerpc/platforms/85xx/p1022_ds.c
@@ -360,6 +360,49 @@ void __init p1022_ds_pic_init(void)
 void __init mpc85xx_smp_init(void);
 #endif
 
+#if defined(CONFIG_FB_FSL_DIU) || defined(CONFIG_FB_FSL_DIU_MODULE)
+
+/*
+ * Disables a node in the device tree.
+ *
+ * This function is called before kmalloc() is available, so the 'new' object
+ * should be allocated in the global area.  The easiest way is to do that is
+ * to allocate one static local variable for each call to this function.
+ */
+static void __init disable_one_node(struct device_node *np, struct property 
*new)
+{
+   struct property *old;
+
+   old = of_find_property(np, new-name, NULL);
+   if (old)
+   prom_update_property(np, new, old);
+   else
+   prom_add_property(np, new);
+}
+
+/* TRUE if there is a video=fslfb command-line parameter. */
+static bool fslfb;
+
+/*
+ * Search for a video=fslfb command-line parameter, and set 'fslfb' to
+ * true if we find it.
+ *
+ * We need to use early_param() instead of __setup() because the normal
+ * __setup() gets called to late.  However, early_param() gets called very
+ * early, before the device tree is unflattened, so all we can do now is set a
+ * global variable.  Later on, p1022_ds_setup_arch() will use that variable
+ * to determine if we need to update the device tree.
+ */
+static int __init early_video_setup(char *options)
+{
+   fslfb = (strncmp(options, fslfb:, 6) == 0);
+
+   return 0;
+}
+early_param(video, early_video_setup);
+
+#endif
+
 /*
  * Setup the architecture
  */
@@ -397,6 +440,34 @@ static void __init p1022_ds_setup_arch(void)
diu_ops.set_monitor_port= p1022ds_set_monitor_port;
diu_ops.set_pixel_clock = p1022ds_set_pixel_clock;
diu_ops.valid_monitor_port  = p1022ds_valid_monitor_port;
+
+   /*
+* Disable the NOR flash node if there is video=fslfb... command-line
+* parameter.  When the DIU is active, NOR flash is unavailable, so we
+* have to disable the node before the MTD driver loads.
+*/
+   if (fslfb) {
+   struct device_node *np =
+   of_find_compatible_node(NULL, NULL, fsl,p1022-elbc);
+
+   if (np) {
+   np = of_find_compatible_node(np, NULL, cfi-flash);
+   if (np) {
+   static struct property nor_status = {
+   .name = status,
+   .value = disabled,
+   .length = sizeof(disabled),
+   };
+
+   pr_info(p1022ds: disabling %s node,
+   np-full_name);
+   disable_one_node(np, nor_status);
+   of_node_put(np);
+   }
+   }
+
+   }
+
 #endif
 
 #ifdef CONFIG_SMP
-- 
1.7.3.4


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH 2/2] [v3] powerpc/85xx: create 32-bit DTS for the P1022DS

2011-12-09 Thread Timur Tabi
Create a 32-bit address space version of p1022ds.dts.  To avoid confusion,
p1022ds.dts is renamed to p1022ds_36b.dts.  We also create p1022ds.dtsi
to store some common nodes.

Signed-off-by: Timur Tabi ti...@freescale.com
---
 arch/powerpc/boot/dts/p1022ds.dts |  270 -
 arch/powerpc/boot/dts/p1022ds.dtsi|  115 ++
 arch/powerpc/boot/dts/p1022ds_32b.dts |  220 +++
 arch/powerpc/boot/dts/p1022ds_36b.dts |  220 +++
 4 files changed, 555 insertions(+), 270 deletions(-)
 delete mode 100644 arch/powerpc/boot/dts/p1022ds.dts
 create mode 100644 arch/powerpc/boot/dts/p1022ds.dtsi
 create mode 100644 arch/powerpc/boot/dts/p1022ds_32b.dts
 create mode 100644 arch/powerpc/boot/dts/p1022ds_36b.dts

diff --git a/arch/powerpc/boot/dts/p1022ds.dts 
b/arch/powerpc/boot/dts/p1022ds.dts
deleted file mode 100644
index a54dd13..000
--- a/arch/powerpc/boot/dts/p1022ds.dts
+++ /dev/null
@@ -1,270 +0,0 @@
-/*
- * P1022 DS 36Bit Physical Address Map Device Tree Source
- *
- * Copyright 2010 Freescale Semiconductor, Inc.
- *
- * This file is licensed under the terms of the GNU General Public License
- * version 2.  This program is licensed as is without any warranty of any
- * kind, whether express or implied.
- */
-
-/include/ fsl/p1022si-pre.dtsi
-/ {
-   model = fsl,P1022DS;
-   compatible = fsl,P1022DS;
-
-   memory {
-   device_type = memory;
-   };
-
-   lbc: localbus@fffe05000 {
-   reg = 0xf 0xffe05000 0 0x1000;
-   ranges = 0x0 0x0 0xf 0xe800 0x0800
- 0x1 0x0 0xf 0xe000 0x0800
- 0x2 0x0 0xf 0xff80 0x0004
- 0x3 0x0 0xf 0xffdf 0x8000;
-
-   /*
-* This node is used to access the pixis via indirect mode,
-* which is done by writing the pixis register index to chip
-* select 0 and the value to/from chip select 1.  Indirect
-* mode is the only way to access the pixis when DIU video
-* is enabled.  Note that this assumes that the first column
-* of the 'ranges' property above is the chip select number.
-*/
-   board-control@0,0 {
-   compatible = fsl,p1022ds-indirect-pixis;
-   reg = 0x0 0x0 1/* CS0 */
-  0x1 0x0 1;  /* CS1 */
-   };
-
-   nor@0,0 {
-   #address-cells = 1;
-   #size-cells = 1;
-   compatible = cfi-flash;
-   reg = 0x0 0x0 0x800;
-   bank-width = 2;
-   device-width = 1;
-
-   partition@0 {
-   reg = 0x0 0x0300;
-   label = ramdisk-nor;
-   read-only;
-   };
-
-   partition@300 {
-   reg = 0x0300 0x00e0;
-   label = diagnostic-nor;
-   read-only;
-   };
-
-   partition@3e0 {
-   reg = 0x03e0 0x0020;
-   label = dink-nor;
-   read-only;
-   };
-
-   partition@400 {
-   reg = 0x0400 0x0040;
-   label = kernel-nor;
-   read-only;
-   };
-
-   partition@440 {
-   reg = 0x0440 0x03b0;
-   label = jffs2-nor;
-   };
-
-   partition@7f0 {
-   reg = 0x07f0 0x0008;
-   label = dtb-nor;
-   read-only;
-   };
-
-   partition@7f8 {
-   reg = 0x07f8 0x0008;
-   label = u-boot-nor;
-   read-only;
-   };
-   };
-
-   nand@2,0 {
-   #address-cells = 1;
-   #size-cells = 1;
-   compatible = fsl,elbc-fcm-nand;
-   reg = 0x2 0x0 0x4;
-
-   partition@0 {
-   reg = 0x0 0x0200;
-   label = u-boot-nand;
-   read-only;
-   };
-
-   partition@200 {
-   reg = 0x0200 0x1000;
-   label = jffs2-nand;
-  

[PATCH] [for-3.2] powerpc/85xx: fix PCI and localbus properties in p1022ds.dts

2011-12-09 Thread Timur Tabi
Signed-off-by: Timur Tabi ti...@freescale.com
---
 arch/powerpc/boot/dts/p1022ds.dts |   10 +-
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/boot/dts/p1022ds.dts 
b/arch/powerpc/boot/dts/p1022ds.dts
index e627f70..d4c1439 100644
--- a/arch/powerpc/boot/dts/p1022ds.dts
+++ b/arch/powerpc/boot/dts/p1022ds.dts
@@ -51,12 +51,12 @@
#address-cells = 2;
#size-cells = 1;
compatible = fsl,p1022-elbc, fsl,elbc, simple-bus;
-   reg = 0 0xffe05000 0 0x1000;
+   reg = 0xf 0xffe05000 0 0x1000;
interrupts = 19 2 0 0;
 
ranges = 0x0 0x0 0xf 0xe800 0x0800
  0x1 0x0 0xf 0xe000 0x0800
- 0x2 0x0 0x0 0xffa0 0x0004
+ 0x2 0x0 0xf 0xff80 0x0004
  0x3 0x0 0xf 0xffdf 0x8000;
 
nor@0,0 {
@@ -561,7 +561,7 @@
#address-cells = 3;
reg = 0xf 0xffe09000 0 0x1000;
bus-range = 0 255;
-   ranges = 0x200 0x0 0xa000 0xc 0x2000 0x0 0x2000
+   ranges = 0x200 0x0 0xe000 0xc 0x2000 0x0 0x2000
  0x100 0x0 0x 0xf 0xffc1 0x0 0x1;
clock-frequency = ;
interrupts = 16 2 0 0;
@@ -596,7 +596,7 @@
#address-cells = 3;
reg = 0xf 0xffe0a000 0 0x1000;
bus-range = 0 255;
-   ranges = 0x200 0x0 0xc000 0xc 0x4000 0x0 0x2000
+   ranges = 0x200 0x0 0xe000 0xc 0x4000 0x0 0x2000
  0x100 0x0 0x 0xf 0xffc2 0x0 0x1;
clock-frequency = ;
interrupts = 16 2 0 0;
@@ -632,7 +632,7 @@
#address-cells = 3;
reg = 0xf 0xffe0b000 0 0x1000;
bus-range = 0 255;
-   ranges = 0x200 0x0 0x8000 0xc 0x 0x0 0x2000
+   ranges = 0x200 0x0 0xe000 0xc 0x 0x0 0x2000
  0x100 0x0 0x 0xf 0xffc0 0x0 0x1;
clock-frequency = ;
interrupts = 16 2 0 0;
-- 
1.7.3.4


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH 61/62] highmem: kill all __kmap_atomic()

2011-12-09 Thread Ralf Baechle
On Sun, Nov 27, 2011 at 01:27:41PM +0800, Cong Wang wrote:

Acked-by: Ralf Baechle r...@linux-mips.org

  Ralf
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: Linuxppc-dev Digest, Vol 88, Issue 24

2011-12-09 Thread Scott Wood
On 12/09/2011 03:27 AM, Liu Shengzhou-B36685 wrote:
 Before calling nand_scan_ident(), we can still use 2k FCM RAM, not need a 
 buffer greater than 2k,
 After nand_scan_ident(),  if writesize  2048, then allocate a large buffer.
 We can do it in fsl_elbc_chip_init_tail()
   if (mtd-writesize  2048)
   ctrl-buffer = kmalloc(mtd-writesize + mtd-oobsize, GFP_KERNEL);

As we discussed elsewhere in the thread, the buffer is a controller-wide
resource.  It is not associated with any one NAND chip.

-Scott

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: linux-next bad Kconfig for drivers/hid

2011-12-09 Thread Randy Dunlap

On Thu, December 8, 2011 9:33 pm, Jeremy Fitzhardinge wrote:
 On 12/08/2011 05:27 PM, Tony Breeds wrote:
 Commit 4f5ca836bef3 (HID: hid-input: add support for HID devices
 reporting Battery Strength) went into linux-next on Dec 1st since then a
 ppc6xx_defconfig has been failing with:

 ---
 drivers/built-in.o: In function `hidinput_cleanup_battery':
 /scratch/tony/working/drivers/hid/hid-input.c:351: undefined reference
 to `power_supply_unregister'
 drivers/built-in.o: In function `hidinput_setup_battery':
 /scratch/tony/working/drivers/hid/hid-input.c:338: undefined reference
 to `power_supply_register'
 make[1]: *** [.tmp_vmlinux1] Error 1
 ---

 http://kisskb.ellerman.id.au/kisskb/buildresult/5012563/
 vs
 http://kisskb.ellerman.id.au/kisskb/buildresult/5017366/

 The defconfig in question doens't mention either option
 (CONFIG_POWER_SUPPLY or CONFIG_HID_BATTERY_STRENGTH) and kbuild is
 genertaing
 CONFIG_HID_BATTERY_STRENGTH=y
 CONFIG_POWER_SUPPLY=m
 which clearly isn't going to work.

 The following change to HID_BATTERY_STRENGTH Kconfig works but seems a
 little gross.

 diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
 index 5ed64f6..d2a94e6 100644
 --- a/drivers/hid/Kconfig
 +++ b/drivers/hid/Kconfig
 @@ -33,7 +33,7 @@ config HID

  config HID_BATTERY_STRENGTH
 bool
 -   depends on POWER_SUPPLY
 +   depends on POWER_SUPPLY=y
 default y

  config HIDRAW

 Any chance we can get a fix into linux-next?

 Hm.  How about making it depends on HID  POWER_SUPPLY?  I think that
 would needlessly disable it if HID is also modular, but I'm not sure how
 to fix that.  depends on HID  POWER_SUPPLY  HID == POWER_SUPPLY?

The last suggestion looks good to me.

-- 
~Randy

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH v2] ipc: provide generic compat versions of IPC syscalls

2011-12-09 Thread Chris Metcalf
When using the compat APIs, architectures will generally want to
be able to make direct syscalls to msgsnd(), shmctl(), etc., and
in the kernel we would want them to be handled directly by
compat_sys_xxx() functions, as is true for other compat syscalls.

However, for historical reasons, several of the existing compat IPC
syscalls do not do this.  semctl() expects a pointer to the fourth
argument, instead of the fourth argument itself.  msgsnd(), msgrcv()
and shmat() expect arguments in different order.

This change adds an __ARCH_WANT_OLD_COMPAT_IPC define that can be
set in asm/compat.h to preserve this behavior for ports that use it
(x86, sparc, powerpc, s390, and mips).  No actual semantics are changed
for those architectures, and there is only a minimal amount of code
refactoring in ipc/compat.c.

Newer architectures like tile (and perhaps future architectures such
as arm64 and unicore64) should not supply this define, and thus can
avoid having any IPC-specific code at all in their architecture-specific
compat layer.  In the same vein, if this define is omitted, IPC_64 mode
is assumed, since that's what the asm-generic headers expect.

The workaround code in tile for msgsnd() and msgrcv() is removed
with this change; it also fixes the bug that shmat() and semctl() were
not being properly handled.

Signed-off-by: Chris Metcalf cmetc...@tilera.com
---
The first version used an __ARCH_WANT_GENERIC_COMPAT_IPC define that
was set by tile, and presumably would be set by all future architectures.
Arnd Bergmann observed:

 I like the patch, but I think the __ARCH_WANT_GENERIC_COMPAT_IPC
 should be defined as the opposite, so all old architectures
 have to set it while tile (and future architectures like arm64
 and unicore64) just get the default. [...]
 We have powerpc, mips, s390, sparc and
 x86 using the legacy method, while only parisc and tile get it right
 and use the syscalls directly.

 arch/mips/include/asm/compat.h|3 ++
 arch/powerpc/include/asm/compat.h |3 ++
 arch/s390/include/asm/compat.h|3 ++
 arch/sparc/include/asm/compat.h   |3 ++
 arch/tile/include/asm/compat.h|   11 --
 arch/tile/kernel/compat.c |   43 --
 arch/x86/include/asm/compat.h |3 ++
 include/linux/compat.h|   12 ++-
 ipc/compat.c  |   70 +---
 9 files changed, 90 insertions(+), 61 deletions(-)

diff --git a/arch/mips/include/asm/compat.h b/arch/mips/include/asm/compat.h
index b77df03..41a57cb 100644
--- a/arch/mips/include/asm/compat.h
+++ b/arch/mips/include/asm/compat.h
@@ -8,6 +8,9 @@
 #include asm/page.h
 #include asm/ptrace.h
 
+/* Use different 32-bit syscall convention than 64-bit for some syscalls. */
+#define __ARCH_WANT_OLD_COMPAT_IPC
+
 #define COMPAT_USER_HZ 100
 #define COMPAT_UTS_MACHINE mips\0\0\0
 
diff --git a/arch/powerpc/include/asm/compat.h 
b/arch/powerpc/include/asm/compat.h
index 88e602f..450a976 100644
--- a/arch/powerpc/include/asm/compat.h
+++ b/arch/powerpc/include/asm/compat.h
@@ -7,6 +7,9 @@
 #include linux/types.h
 #include linux/sched.h
 
+/* Use different 32-bit syscall convention than 64-bit for some syscalls. */
+#define __ARCH_WANT_OLD_COMPAT_IPC
+
 #define COMPAT_USER_HZ 100
 #define COMPAT_UTS_MACHINE ppc\0\0
 
diff --git a/arch/s390/include/asm/compat.h b/arch/s390/include/asm/compat.h
index 2e49748..9a38bae 100644
--- a/arch/s390/include/asm/compat.h
+++ b/arch/s390/include/asm/compat.h
@@ -7,6 +7,9 @@
 #include linux/sched.h
 #include linux/thread_info.h
 
+/* Use different 32-bit syscall convention than 64-bit for some syscalls. */
+#define __ARCH_WANT_OLD_COMPAT_IPC
+
 #define PSW32_MASK_PER 0x4000UL
 #define PSW32_MASK_DAT 0x0400UL
 #define PSW32_MASK_IO  0x0200UL
diff --git a/arch/sparc/include/asm/compat.h b/arch/sparc/include/asm/compat.h
index b8be20d..bfd3d8b 100644
--- a/arch/sparc/include/asm/compat.h
+++ b/arch/sparc/include/asm/compat.h
@@ -5,6 +5,9 @@
  */
 #include linux/types.h
 
+/* Use different 32-bit syscall convention than 64-bit for some syscalls. */
+#define __ARCH_WANT_OLD_COMPAT_IPC
+
 #define COMPAT_USER_HZ 100
 #define COMPAT_UTS_MACHINE sparc\0\0
 
diff --git a/arch/tile/include/asm/compat.h b/arch/tile/include/asm/compat.h
index bf95f55..4b4b289 100644
--- a/arch/tile/include/asm/compat.h
+++ b/arch/tile/include/asm/compat.h
@@ -242,17 +242,6 @@ long compat_sys_fallocate(int fd, int mode,
 long compat_sys_sched_rr_get_interval(compat_pid_t pid,
  struct compat_timespec __user *interval);
 
-/* Versions of compat functions that differ from generic Linux. */
-struct compat_msgbuf;
-long tile_compat_sys_msgsnd(int msqid,
-   struct compat_msgbuf __user *msgp,
-   size_t msgsz, int msgflg);
-long tile_compat_sys_msgrcv(int msqid,
-   struct compat_msgbuf 

Re: [PATCH 1/2] mtd/nand : set Nand flash page address to FBAR and FPAR correctly

2011-12-09 Thread Scott Wood
On 12/09/2011 03:42 AM, shuo@freescale.com wrote:
 From: Liu Shuo b35...@freescale.com
 
 If we use the Nand flash chip whose number of pages in a block is greater
 than 64(for large page), we must treat the low bit of FBAR as being the
 high bit of the page address due to the limitation of FCM, it simply uses
 the low 6-bits (for large page) of the combined block/page address as the
 FPAR component, rather than considering the actual block size.
 
 Signed-off-by: Liu Shuo b35...@freescale.com
 Signed-off-by: Jerry Huang chang-ming.hu...@freescale.com
 Signed-off-by: Tang Yuantian b29...@freescale.com
 Signed-off-by: Li Yang le...@freescale.com
 ---
  drivers/mtd/nand/fsl_elbc_nand.c |   13 ++---
  1 files changed, 10 insertions(+), 3 deletions(-)

Acked-by: Scott Wood scottw...@freescale.com

-Scott

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH 2/2 v4] mtd/nand : workaround for Freescale FCM to support large-page Nand chip

2011-12-09 Thread Scott Wood
On 12/09/2011 03:42 AM, shuo@freescale.com wrote:
 From: Liu Shuo shuo@freescale.com
 
 Freescale FCM controller has a 2K size limitation of buffer RAM. In order
 to support the Nand flash chip whose page size is larger than 2K bytes,
 we read/write 2k data repeatedly by issuing FIR_OP_RB/FIR_OP_WB and save
 them to a large buffer.
 
 Signed-off-by: Liu Shuo shuo@freescale.com
 Signed-off-by: Shengzhou Liu shengzhou@freescale.com
 Signed-off-by: Li Yang le...@freescale.com
 ---
 v4 : allocate (8+1)k buffer for large page chip.
 
  drivers/mtd/nand/fsl_elbc_nand.c |  246 
 ++
  1 files changed, 221 insertions(+), 25 deletions(-)

Again, I think we need to sort out the bad block migration first -- at
least how we're going to mark the chip as having been migrated, so the
driver can check for it.

-Scott

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH] powerpc: Fix compiliation with hugetlbfs enabled

2011-12-09 Thread Tabi Timur-B04825
On Thu, Nov 24, 2011 at 1:40 PM, Kumar Gala ga...@kernel.crashing.org wrote:
 arch/powerpc/mm/hugetlbpage.c: In function 'reserve_hugetlb_gpages':
 arch/powerpc/mm/hugetlbpage.c:312:2: error: implicit declaration of function 
 'parse_args'

 Signed-off-by: Kumar Gala ga...@kernel.crashing.org

Acked-by: Timur Tabi ti...@freescale.com

Would you please apply this to your 'next' branch?  It won't compile
with this patch.

-- 
Timur Tabi
Linux kernel developer at Freescale
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH] powerpc: fix wrong divisor in usecs_to_cputime

2011-12-09 Thread Andreas Schwab
Commit d57af9b (taskstats: use real microsecond granularity for CPU times)
renamed msecs_to_cputime to usecs_to_cputime, but failed to update all
numbers on the way.  This causes nonsensical cpu idle/iowait values to be
displayed in /proc/stat (the only user of usecs_to_cputime so far).

This also renames __cputime_msec_factor to __cputime_usec_factor, adapting
its value and using it directly in cputime_to_usecs instead of doing two
multiplications.

Signed-off-by: Andreas Schwab sch...@linux-m68k.org
---
 arch/powerpc/include/asm/cputime.h |6 +++---
 arch/powerpc/kernel/time.c |   10 +-
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/arch/powerpc/include/asm/cputime.h 
b/arch/powerpc/include/asm/cputime.h
index 1cf20bd..33a3580 100644
--- a/arch/powerpc/include/asm/cputime.h
+++ b/arch/powerpc/include/asm/cputime.h
@@ -126,11 +126,11 @@ static inline u64 cputime64_to_jiffies64(const cputime_t 
ct)
 /*
  * Convert cputime - microseconds
  */
-extern u64 __cputime_msec_factor;
+extern u64 __cputime_usec_factor;
 
 static inline unsigned long cputime_to_usecs(const cputime_t ct)
 {
-   return mulhdu(ct, __cputime_msec_factor) * USEC_PER_MSEC;
+   return mulhdu(ct, __cputime_usec_factor);
 }
 
 static inline cputime_t usecs_to_cputime(const unsigned long us)
@@ -143,7 +143,7 @@ static inline cputime_t usecs_to_cputime(const unsigned 
long us)
sec = us / 100;
if (ct) {
ct *= tb_ticks_per_sec;
-   do_div(ct, 1000);
+   do_div(ct, 100);
}
if (sec)
ct += (cputime_t) sec * tb_ticks_per_sec;
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index 522bb1d..69477e5 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -168,13 +168,13 @@ EXPORT_SYMBOL_GPL(ppc_tb_freq);
 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
 /*
  * Factors for converting from cputime_t (timebase ticks) to
- * jiffies, milliseconds, seconds, and clock_t (1/USER_HZ seconds).
+ * jiffies, microseconds, seconds, and clock_t (1/USER_HZ seconds).
  * These are all stored as 0.64 fixed-point binary fractions.
  */
 u64 __cputime_jiffies_factor;
 EXPORT_SYMBOL(__cputime_jiffies_factor);
-u64 __cputime_msec_factor;
-EXPORT_SYMBOL(__cputime_msec_factor);
+u64 __cputime_usec_factor;
+EXPORT_SYMBOL(__cputime_usec_factor);
 u64 __cputime_sec_factor;
 EXPORT_SYMBOL(__cputime_sec_factor);
 u64 __cputime_clockt_factor;
@@ -192,8 +192,8 @@ static void calc_cputime_factors(void)
 
div128_by_32(HZ, 0, tb_ticks_per_sec, res);
__cputime_jiffies_factor = res.result_low;
-   div128_by_32(1000, 0, tb_ticks_per_sec, res);
-   __cputime_msec_factor = res.result_low;
+   div128_by_32(100, 0, tb_ticks_per_sec, res);
+   __cputime_usec_factor = res.result_low;
div128_by_32(1, 0, tb_ticks_per_sec, res);
__cputime_sec_factor = res.result_low;
div128_by_32(USER_HZ, 0, tb_ticks_per_sec, res);
-- 
1.7.8


-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
And now for something completely different.
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH v2] ipc: provide generic compat versions of IPC syscalls

2011-12-09 Thread Andrew Morton
On Fri, 9 Dec 2011 10:29:07 -0500
Chris Metcalf cmetc...@tilera.com wrote:

 When using the compat APIs, architectures will generally want to
 be able to make direct syscalls to msgsnd(), shmctl(), etc., and
 in the kernel we would want them to be handled directly by
 compat_sys_xxx() functions, as is true for other compat syscalls.
 
 However, for historical reasons, several of the existing compat IPC
 syscalls do not do this.  semctl() expects a pointer to the fourth
 argument, instead of the fourth argument itself.  msgsnd(), msgrcv()
 and shmat() expect arguments in different order.
 
 This change adds an __ARCH_WANT_OLD_COMPAT_IPC define that can be
 set in asm/compat.h to preserve this behavior for ports that use it
 (x86, sparc, powerpc, s390, and mips).  No actual semantics are changed
 for those architectures, and there is only a minimal amount of code
 refactoring in ipc/compat.c.
 
 Newer architectures like tile (and perhaps future architectures such
 as arm64 and unicore64) should not supply this define, and thus can
 avoid having any IPC-specific code at all in their architecture-specific
 compat layer.  In the same vein, if this define is omitted, IPC_64 mode
 is assumed, since that's what the asm-generic headers expect.
 
 The workaround code in tile for msgsnd() and msgrcv() is removed
 with this change; it also fixes the bug that shmat() and semctl() were
 not being properly handled.

What would we need to do to get all architectures using the new
interfaces, and remove __ARCH_WANT_OLD_COMPAT_IPC?

Regarding the implementation: rather than patching the header
files, it would be more conventional (and arguably better) to add

select ARCH_WANT_OLD_COMPAT_IPC

to arch/*/Kconfig, then use CONFIG_ARCH_WANT_OLD_COMPAT_IPC.
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH 10/13] powerpc: Update mpc85xx/corenet 32-bit defconfigs

2011-12-09 Thread Tabi Timur-B04825
On Mon, Oct 10, 2011 at 3:50 PM, Becky Bruce bec...@kernel.crashing.org wrote:
 From: Becky Bruce bec...@kernel.crashing.org

 Results from updates via make savedefconfig.

 Signed-off-by: Becky Bruce bec...@kernel.crashing.org
 ---

...

 -CONFIG_PPC_EPAPR_HV_BYTECHAN=y

I guess no one noticed that this patch removes byte channel support,
thereby preventing this kernel from booting under the hypervisor?

-- 
Timur Tabi
Linux kernel developer at Freescale
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH v2] ipc: provide generic compat versions of IPC syscalls

2011-12-09 Thread Arnd Bergmann
On Friday 09 December 2011 13:48:52 Andrew Morton wrote:
 What would we need to do to get all architectures using the new
 interfaces, and remove __ARCH_WANT_OLD_COMPAT_IPC?

We would change the various compat_sys_ipc functions (mips, powerpc,
s390, sparc, x86) to call the new functions instead of the existing
ones, and test each architecture. For parisc, we might not
actually need the either version, but I'd have to take a closer look
to be sure.

 Regarding the implementation: rather than patching the header
 files, it would be more conventional (and arguably better) to add
 
 select ARCH_WANT_OLD_COMPAT_IPC
 
 to arch/*/Kconfig, then use CONFIG_ARCH_WANT_OLD_COMPAT_IPC.

Yes.

Arnd
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH] powerpc: fix wrong divisor in usecs_to_cputime

2011-12-09 Thread Anton Blanchard
Hi Andreas,

 Commit d57af9b (taskstats: use real microsecond granularity for CPU
 times) renamed msecs_to_cputime to usecs_to_cputime, but failed to
 update all numbers on the way.  This causes nonsensical cpu
 idle/iowait values to be displayed in /proc/stat (the only user of
 usecs_to_cputime so far).
 
 This also renames __cputime_msec_factor to __cputime_usec_factor,
 adapting its value and using it directly in cputime_to_usecs instead
 of doing two multiplications.

Thanks for finding this! I noticed the strange behaviour yesterday and
was just about to investigate.

Can I suggest we add: 

Cc: sta...@vger.kernel.org [2.6.37+]

so it will make it back into the stable trees?

Anton

 Signed-off-by: Andreas Schwab sch...@linux-m68k.org

FWIW:
Acked-by: Anton Blanchard an...@samba.org

 ---
  arch/powerpc/include/asm/cputime.h |6 +++---
  arch/powerpc/kernel/time.c |   10 +-
  2 files changed, 8 insertions(+), 8 deletions(-)
 
 diff --git a/arch/powerpc/include/asm/cputime.h
 b/arch/powerpc/include/asm/cputime.h index 1cf20bd..33a3580 100644
 --- a/arch/powerpc/include/asm/cputime.h
 +++ b/arch/powerpc/include/asm/cputime.h
 @@ -126,11 +126,11 @@ static inline u64 cputime64_to_jiffies64(const
 cputime_t ct) /*
   * Convert cputime - microseconds
   */
 -extern u64 __cputime_msec_factor;
 +extern u64 __cputime_usec_factor;
  
  static inline unsigned long cputime_to_usecs(const cputime_t ct)
  {
 - return mulhdu(ct, __cputime_msec_factor) * USEC_PER_MSEC;
 + return mulhdu(ct, __cputime_usec_factor);
  }
  
  static inline cputime_t usecs_to_cputime(const unsigned long us)
 @@ -143,7 +143,7 @@ static inline cputime_t usecs_to_cputime(const
 unsigned long us) sec = us / 100;
   if (ct) {
   ct *= tb_ticks_per_sec;
 - do_div(ct, 1000);
 + do_div(ct, 100);
   }
   if (sec)
   ct += (cputime_t) sec * tb_ticks_per_sec;
 diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
 index 522bb1d..69477e5 100644
 --- a/arch/powerpc/kernel/time.c
 +++ b/arch/powerpc/kernel/time.c
 @@ -168,13 +168,13 @@ EXPORT_SYMBOL_GPL(ppc_tb_freq);
  #ifdef CONFIG_VIRT_CPU_ACCOUNTING
  /*
   * Factors for converting from cputime_t (timebase ticks) to
 - * jiffies, milliseconds, seconds, and clock_t (1/USER_HZ seconds).
 + * jiffies, microseconds, seconds, and clock_t (1/USER_HZ seconds).
   * These are all stored as 0.64 fixed-point binary fractions.
   */
  u64 __cputime_jiffies_factor;
  EXPORT_SYMBOL(__cputime_jiffies_factor);
 -u64 __cputime_msec_factor;
 -EXPORT_SYMBOL(__cputime_msec_factor);
 +u64 __cputime_usec_factor;
 +EXPORT_SYMBOL(__cputime_usec_factor);
  u64 __cputime_sec_factor;
  EXPORT_SYMBOL(__cputime_sec_factor);
  u64 __cputime_clockt_factor;
 @@ -192,8 +192,8 @@ static void calc_cputime_factors(void)
  
   div128_by_32(HZ, 0, tb_ticks_per_sec, res);
   __cputime_jiffies_factor = res.result_low;
 - div128_by_32(1000, 0, tb_ticks_per_sec, res);
 - __cputime_msec_factor = res.result_low;
 + div128_by_32(100, 0, tb_ticks_per_sec, res);
 + __cputime_usec_factor = res.result_low;
   div128_by_32(1, 0, tb_ticks_per_sec, res);
   __cputime_sec_factor = res.result_low;
   div128_by_32(USER_HZ, 0, tb_ticks_per_sec, res);

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH] powerpc: fix wrong divisor in usecs_to_cputime

2011-12-09 Thread Andreas Schwab
Anton Blanchard an...@samba.org writes:

 Hi Andreas,

 Commit d57af9b (taskstats: use real microsecond granularity for CPU
 times) renamed msecs_to_cputime to usecs_to_cputime, but failed to
 update all numbers on the way.  This causes nonsensical cpu
 idle/iowait values to be displayed in /proc/stat (the only user of
 usecs_to_cputime so far).
 
 This also renames __cputime_msec_factor to __cputime_usec_factor,
 adapting its value and using it directly in cputime_to_usecs instead
 of doing two multiplications.

 Thanks for finding this! I noticed the strange behaviour yesterday and
 was just about to investigate.

 Can I suggest we add: 

 Cc: sta...@vger.kernel.org [2.6.37+]

 so it will make it back into the stable trees?

There is no user of usecs_to_cputime before 3.2-rc1, so it wouldn't have
any effect for older versions.

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
And now for something completely different.
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH] powerpc: fix wrong divisor in usecs_to_cputime

2011-12-09 Thread Anton Blanchard

Hi Andreas,

 There is no user of usecs_to_cputime before 3.2-rc1, so it wouldn't
 have any effect for older versions.

Great, that explains why I only noticed it last week :)

Anton
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH v4 3/7] [ppc] Process dynamic relocations for kernel

2011-12-09 Thread Suzuki Poulose

On 12/09/11 19:10, Josh Boyer wrote:

On Fri, Dec 9, 2011 at 6:47 AM, Suzuki K. Poulosesuz...@in.ibm.com  wrote:


Signed-off-by: Suzuki K. Poulosesuz...@in.ibm.com
Signed-off-by: Josh Poimboeufjpoim...@linux.vnet.ibm.com
Cc: Paul Mackerraspau...@samba.org
Cc: Benjamin Herrenschmidtb...@kernel.crashing.org
Cc: Alan Modraamo...@au1.ibm.com
Cc: Kumar Galaga...@kernel.crashing.org
Cc: linuxppc-devlinuxppc-dev@lists.ozlabs.org
---

  arch/powerpc/Kconfig  |   42 ++---
  arch/powerpc/Makefile |6 +++--
  arch/powerpc/kernel/Makefile  |2 ++
  arch/powerpc/kernel/vmlinux.lds.S |8 ++-
  arch/powerpc/relocs_check.pl  |7 ++
  5 files changed, 44 insertions(+), 21 deletions(-)


You're missing the whole reloc_32.S file in this patch.  Forget to do a git-add?

Can you resend just this patch with that fixed up?


Yikes, missed that. Will send the updated one.

Thanks
Suzuki


josh



___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[UPDATED] [PATCH v4 3/7] [ppc] Process dynamic relocations for kernel

2011-12-09 Thread Suzuki K. Poulose
The following patch implements the dynamic relocation processing for
PPC32 kernel. relocate() accepts the target virtual address and relocates
 the kernel image to the same.

Currently the following relocation types are handled :

R_PPC_RELATIVE
R_PPC_ADDR16_LO
R_PPC_ADDR16_HI
R_PPC_ADDR16_HA

The last 3 relocations in the above list depends on value of Symbol indexed
whose index is encoded in the Relocation entry. Hence we need the Symbol
Table for processing such relocations.

Note: The GNU ld for ppc32 produces buggy relocations for relocation types
that depend on symbols. The value of the symbols with STB_LOCAL scope
should be assumed to be zero. - Alan Modra

Changes since V3:
 * Updated relocation types for ppc in arch/powerpc/relocs_check.pl

Changes since v2:
  * Flush the d-cache'd instructions and invalidate the i-cache to reflect
the processed instructions.(Reported by: Josh Poimboeuf)

Signed-off-by: Suzuki K. Poulose suz...@in.ibm.com
Signed-off-by: Josh Poimboeuf jpoim...@linux.vnet.ibm.com
Cc: Paul Mackerras pau...@samba.org
Cc: Benjamin Herrenschmidt b...@kernel.crashing.org
Cc: Alan Modra amo...@au1.ibm.com
Cc: Kumar Gala ga...@kernel.crashing.org
Cc: linuxppc-dev linuxppc-dev@lists.ozlabs.org
---

 arch/powerpc/Kconfig  |   42 
 arch/powerpc/Makefile |6 +
 arch/powerpc/kernel/Makefile  |2 
 arch/powerpc/kernel/reloc_32.S|  207 +
 arch/powerpc/kernel/vmlinux.lds.S |8 +
 arch/powerpc/relocs_check.pl  |7 +
 6 files changed, 251 insertions(+), 21 deletions(-)
 create mode 100644 arch/powerpc/kernel/reloc_32.S

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 5eafe95..6936cb0 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -843,23 +843,31 @@ config DYNAMIC_MEMSTART
  load address. When this option is enabled, the compile time physical 
  address CONFIG_PHYSICAL_START is ignored.
 
-# Mapping based RELOCATABLE is moved to DYNAMIC_MEMSTART
-# config RELOCATABLE
-#  bool Build a relocatable kernel (EXPERIMENTAL)
-#  depends on EXPERIMENTAL  ADVANCED_OPTIONS  FLATMEM  (FSL_BOOKE || 
PPC_47x)
-#  help
-#This builds a kernel image that is capable of running at the
-#location the kernel is loaded at, without any alignment restrictions.
-#
-#One use is for the kexec on panic case where the recovery kernel
-#must live at a different physical address than the primary
-#kernel.
-#
-#Note: If CONFIG_RELOCATABLE=y, then the kernel runs from the address
-#it has been loaded at and the compile time physical addresses
-#CONFIG_PHYSICAL_START is ignored.  However CONFIG_PHYSICAL_START
-#setting can still be useful to bootwrappers that need to know the
-#load location of the kernel (eg. u-boot/mkimage).
+ This option is overridden by RELOCATABLE.
+
+config RELOCATABLE
+   bool Build a relocatable kernel (EXPERIMENTAL)
+   depends on EXPERIMENTAL  ADVANCED_OPTIONS  FLATMEM
+   select NONSTATIC_KERNEL
+   help
+ This builds a kernel image that is capable of running at the
+ location the kernel is loaded at, without any alignment restrictions.
+ This feature is a superset of DYNAMIC_MEMSTART, and hence overrides 
+ it.
+
+ One use is for the kexec on panic case where the recovery kernel
+ must live at a different physical address than the primary
+ kernel.
+
+ Note: If CONFIG_RELOCATABLE=y, then the kernel runs from the address
+ it has been loaded at and the compile time physical addresses
+ CONFIG_PHYSICAL_START is ignored.  However CONFIG_PHYSICAL_START
+ setting can still be useful to bootwrappers that need to know the
+ load address of the kernel (eg. u-boot/mkimage).
+
+config RELOCATABLE_PPC32
+   def_bool y
+   depends on PPC32  RELOCATABLE
 
 config PAGE_OFFSET_BOOL
bool Set custom page offset address
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index ffe4d88..b8b105c 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -63,9 +63,9 @@ override CC   += -m$(CONFIG_WORD_SIZE)
 override AR:= GNUTARGET=elf$(CONFIG_WORD_SIZE)-powerpc $(AR)
 endif
 
-LDFLAGS_vmlinux-yy := -Bstatic
-LDFLAGS_vmlinux-$(CONFIG_PPC64)$(CONFIG_RELOCATABLE) := -pie
-LDFLAGS_vmlinux:= $(LDFLAGS_vmlinux-yy)
+LDFLAGS_vmlinux-y := -Bstatic
+LDFLAGS_vmlinux-$(CONFIG_RELOCATABLE) := -pie
+LDFLAGS_vmlinux:= $(LDFLAGS_vmlinux-y)
 
 CFLAGS-$(CONFIG_PPC64) := -mminimal-toc -mtraceback=no -mcall-aixdesc
 CFLAGS-$(CONFIG_PPC32) := -ffixed-r2 -mmultiple
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index ce4f7f1..ee728e4 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -85,6 +85,8 @@ extra-$(CONFIG_FSL_BOOKE) := head_fsl_booke.o
 

Re: [GIT PULL] tty-next: Fix Fsl 8250 BRK bug

2011-12-09 Thread Greg KH
On Tue, Dec 06, 2011 at 10:39:57PM -0500, Paul Gortmaker wrote:
 Hi Greg,
 
 This is the Freescale hardware bug fix which turned into a
 six-pack of 8250 updates.  This is exactly what was posted
 in the v2 review, with just Alan's ack added[1].  Since nobody
 else has had any follow-on comments since then, I'm assuming
 that it is now good to go.
 
 [1] https://lkml.org/lkml/2011/12/5/156
 
 Thanks,
 Paul.
 ---
 
 Please pull for tty-next to get:
 
 The following changes since commit 5611cc4572e889b62a7b4c72a413536bf6a9c416:
 
   Linux 3.2-rc4 (2011-12-01 14:56:01 -0800)
 
 are available in the git repository at:
   git://git.kernel.org/pub/scm/linux/kernel/git/paulg/linux fsl-uart-fix

I took the raw patches from the emails, so you can delete this branch
now.

thanks,

greg k-h
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH v4 0/7] Kudmp support for PPC440x

2011-12-09 Thread Suzuki Poulose

On 12/09/11 17:13, Suzuki K. Poulose wrote:

The following series implements:

  * Generic framework for relocatable kernel on PPC32, based on processing
the dynamic relocation entries.
  * Relocatable kernel support for 44x
  * Kdump support for 44x. Doesn't support 47x yet, as the kexec
support is missing.

Changes from V3:

  * Added a new config - NONSTATIC_KERNEL - to group different types of 
relocatable
kernel. (Suggested by: Josh Boyer)
  * Added supported ppc relocation types in relocs_check.pl for verifying the
relocations used in the kernel.

Changes from V2:

  * Renamed old style mapping based RELOCATABLE on BookE to DYNAMIC_MEMSTART.
Suggested by: Scott Wood
  * Added support for DYNAMIC_MEMSTART on PPC440x
  * Reverted back to RELOCATABLE and RELOCATABLE_PPC32 from 
RELOCATABLE_PPC32_PIE
for relocation based on processing dynamic reloc entries for PPC32.
  * Ensure the modified instructions are flushed and the i-cache invalidated at
the end of relocate(). - Reported by : Josh Poimboeuf

Changes from V1:

  * Splitted patch 'Enable CONFIG_RELOCATABLE for PPC44x' to move some
of the generic bits to a new patch.
  * Renamed RELOCATABLE_PPC32 to RELOCATABLE_PPC32_PIE and provided options to
retained old style mapping. (Suggested by: Scott Wood)
  * Added support for avoiding the overlapping of uncompressed kernel
with boot wrapper for PPC images.

The patches are based on -next tree for ppc.

I have tested these patches on Ebony, Sequoia and Virtex(QEMU Emulated).
I haven't tested the RELOCATABLE bits on PPC_47x yet, as I don't have access
to one. However, RELOCATABLE should work fine there as we only depend on the
runtime address and the XLAT entry setup by the boot loader. It would be great 
if
somebody could test these patches on a 47x.


---


Updated diffstats:

Suzuki K. Poulose (7):
  [boot] Change the load address for the wrapper to fit the kernel
  [44x] Enable CRASH_DUMP for 440x
  [44x] Enable CONFIG_RELOCATABLE for PPC44x
  [ppc] Define virtual-physical translations for RELOCATABLE
  [ppc] Process dynamic relocations for kernel
  [44x] Enable DYNAMIC_MEMSTART for 440x
  [booke] Rename mapping based RELOCATABLE to DYNAMIC_MEMSTART for BookE


 arch/powerpc/Kconfig  |   46 +-
 arch/powerpc/Makefile |6 -
 arch/powerpc/boot/wrapper |   20 ++
 arch/powerpc/configs/44x/iss476-smp_defconfig |2
 arch/powerpc/include/asm/kdump.h  |4
 arch/powerpc/include/asm/page.h   |   89 ++-
 arch/powerpc/kernel/Makefile  |2
 arch/powerpc/kernel/crash_dump.c  |4
 arch/powerpc/kernel/head_44x.S|  105 +
 arch/powerpc/kernel/head_fsl_booke.S  |2
 arch/powerpc/kernel/machine_kexec.c   |2
 arch/powerpc/kernel/prom_init.c   |2
 arch/powerpc/kernel/reloc_32.S|  207 +
 arch/powerpc/kernel/vmlinux.lds.S |8 +
 arch/powerpc/mm/44x_mmu.c |2
 arch/powerpc/mm/init_32.c |7 +
 arch/powerpc/relocs_check.pl  |7 +
 17 files changed, 489 insertions(+), 26 deletions(-)
 create mode 100644 arch/powerpc/kernel/reloc_32.S


Thanks
Suzuki

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [RFC PATCH v5 1/9] fadump: Add documentation for firmware-assisted dump.

2011-12-09 Thread Mahesh Jagannath Salgaonkar
On 11/25/2011 04:04 AM, Paul Mackerras wrote:
 + /sys/kernel/debug/powerpc/fadump_region
 +
 +This file shows the reserved memory regions if fadump is
 +enabled otherwise this file is empty. The output format
 +is:
 +region: [start-end] reserved-size bytes, Dumped: dump-size
 +
 +e.g.
 +Contents when fadump is registered during first kernel
 +
 +# cat /sys/kernel/debug/powerpc/fadump_region
 +CPU : [0x006ffb-0x006fff001f] 0x40020 bytes, Dumped: 0x0
 +HPTE: [0x006fff0020-0x006fff101f] 0x1000 bytes, Dumped: 0x0
 +DUMP: [0x006fff1020-0x007fff101f] 0x1000 bytes, Dumped: 0x0
 
 How come the HPTE region is only 0x1000 (4k) bytes?  The hashed page
 table (HPT) will be much bigger than this.  Is this our way of telling
 the hypervisor that we don't care about the HPT?  If so, is it
 possible to make this region 0 bytes instead of 0x1000?
 

The firmware assisted dump registration fails with Hardware
error (-1) when called with HPTE dump section with size 0.

According to PAPR the size returned by ibm,configure-kernel-dump-sizes
node for HPTE dump section is a minimum size for HPTE dump section.

Though PAPR dose not mention this, but after sevaral trial and error, it
looks like the HPTE dump section is one of the mandatory
argument that needs to be passed (with non-zero size) while making
ibm,configure-kernel-dump rtas call.

Thanks,
-Mahesh.

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[RFC PATCH v6 00/10] fadump: Firmware-assisted dump support for Powerpc.

2011-12-09 Thread Mahesh J Salgaonkar
Hi All,

Please find the version 6 of the patchset that implements firmware-assisted
dump mechanism to capture kernel crash dump for Powerpc architecture. The
firmware-assisted dump is a robust mechanism to get reliable kernel crash
dump with assistance from firmware. This approach does not use kexec, instead
firmware assists in booting the kdump kernel while preserving memory contents.

These patches cleanly apply on commit dc47ce90c3 in linux-2.6 git tree.

Change in v6:
-
- Use of_read_number and of_read_ulong while reading the dump sizes
  from rtas node ibm,configure-kernel-kdump-sizes and few minor changes.
- Kernel command line option 'fadump' now uses on/off values to
  enable/disable fadump.
- Added the last patch in this series 10/10 to remove phyp dump code.

Change in v5:
-
- Added 'fadump_' prefix to all static functions defined.

patch 02/10:
- Merged patch 10/10 which introduces a config option CONFIG_FA_DUMP
  for firmware assisted dump feature on Powerpc (ppc64) architecture.
- Increased MIN_BOOT_MEM by 64M to avoid OOM issue during network
  dump capture. When kdump infrastructure is configured to save vmcore
  over network, we run into OOM issue while loading modules related to
  network setup.

Changes in v4:
--
patch 04/10:
- Move the init_elfcore_header() function and 'memblock_num_regions' macro
 from generic code to power specific code as these are used only by
 firmware assisted dump implementation which is power specific feature.

patch 05/10:
- Fixes a issue where memblock_free() is invoked from build_cpu_notes()
  function during error_out path. Invoke cpu_notes_buf_free() in error_out
  path instead of memblock_free().

Changes in v3:
-
- Re-factored the implementation to work with kdump service start/stop.
  Introduce fadump_registered sysfs control file which will be used by
  kdump init scripts to start/stop firmware assisted dump. echo 1 to
  /sys/kernel/fadump_registered file for fadump registration and
  echo 0 to /sys/kernel/fadump_registered file for fadump un-registration.
- Introduced the locking mechanism to handle simultaneous writes to
  sysfs control files fadump_registered and fadump_release_mem

  Affected patches are: 01/10, 03/10, 08/10.

Changes in v2:
-
patch 01/10:
- Modified the documentation to reflect the change of fadump_region
  file under debugfs filesystem.

patch 02/10:
- Modified to use standard pr_debug() macro.
- Modified early_init_dt_scan_fw_dump() to get the size of
  ibm,configure-kernel-dump-sizes property and use it to iterate through
  an array of dump sections.
- Introduced boot option 'fadump_reserve_mem=' to let user specify the
  fadump boot memory to be reserved.

patch 03/10:
- Removed few debug print statements.
- Moved the setup_fadump() call from setup_system() and now calling it
  subsys_initcall.
- Moved fadump_region attribute under debugfs.
- Clear the TCE entries if firmware assisted dump is active.

patch 05/10:
- Moved the crash_fadump() invocation from generic code to panic notifier.
- Introduced cpu_notes_buf_alloc() function to allocate cpu notes buffer
  using get_free_pages().

patch 08/10:
- Introduced cpu_notes_buf_free() function to free memory allocated for
  cpu notes buffer.

The most of the code implementation has been adapted from phyp assisted dump
implementation written by Linas Vepstas and Manish Ahuja.

The first patch is a documentation that talks about firmware-assisted dump
mechanism, implementation details and TODO list.

I have tested the patches on following system configuration:
1. LPAR on Power6 with 4GB RAM and 8 CPUs
2. LPAR on Power7 with 2GB RAM and 20 CPUs
3. LPAR on Power7 with 1TB RAM and 896 CPUs

Please review the patchset and let me know your comments.

Thanks,
-Mahesh.
---

Mahesh Salgaonkar (10):
  fadump: Add documentation for firmware-assisted dump.
  fadump: Reserve the memory for firmware assisted dump.
  fadump: Register for firmware assisted dump.
  fadump: Initialize elfcore header and add PT_LOAD program headers.
  fadump: Convert firmware-assisted cpu state dump data into elf notes.
  fadump: Add PT_NOTE program header for vmcoreinfo
  fadump: Introduce cleanup routine to invalidate /proc/vmcore.
  fadump: Invalidate registration and release reserved memory for general 
use.
  fadump: Invalidate the fadump registration during machine shutdown.
  fadump: Remove the phyp assisted dump code.


 Documentation/powerpc/firmware-assisted-dump.txt |  243 
 Documentation/powerpc/phyp-assisted-dump.txt |  127 --
 arch/powerpc/Kconfig |   17 
 arch/powerpc/include/asm/fadump.h|  218 
 arch/powerpc/include/asm/phyp_dump.h |   47 -
 arch/powerpc/kernel/Makefile |1 
 arch/powerpc/kernel/fadump.c | 1312 ++
 arch/powerpc/kernel/iommu.c  |8 
 

[RFC PATCH v6 01/10] fadump: Add documentation for firmware-assisted dump.

2011-12-09 Thread Mahesh J Salgaonkar
From: Mahesh Salgaonkar mah...@linux.vnet.ibm.com

Documentation for firmware-assisted dump. This document is based on the
original documentation written for phyp assisted dump by Linas Vepstas
and Manish Ahuja, with few changes to reflect the current implementation.

Signed-off-by: Mahesh Salgaonkar mah...@linux.vnet.ibm.com
---
 Documentation/powerpc/firmware-assisted-dump.txt |  243 ++
 1 files changed, 243 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/powerpc/firmware-assisted-dump.txt

diff --git a/Documentation/powerpc/firmware-assisted-dump.txt 
b/Documentation/powerpc/firmware-assisted-dump.txt
new file mode 100644
index 000..f77a44e
--- /dev/null
+++ b/Documentation/powerpc/firmware-assisted-dump.txt
@@ -0,0 +1,243 @@
+
+   Firmware-Assisted Dump
+   
+   July 2011
+
+The goal of firmware-assisted dump is to enable the dump of
+a crashed system, and to do so from a fully-reset system, and
+to minimize the total elapsed time until the system is back
+in production use.
+
+Comparing with kdump or other strategies, firmware-assisted
+dump offers several strong, practical advantages:
+
+-- Unlike kdump, the system has been reset, and loaded
+   with a fresh copy of the kernel.  In particular,
+   PCI and I/O devices have been reinitialized and are
+   in a clean, consistent state.
+-- Once the dump is copied out, the memory that held the dump
+   is immediately available to the running kernel. A further
+   reboot isn't required.
+
+The above can only be accomplished by coordination with,
+and assistance from the Power firmware. The procedure is
+as follows:
+
+-- The first kernel registers the sections of memory with the
+   Power firmware for dump preservation during OS initialization.
+   These registered sections of memory are reserved by the first
+   kernel during early boot.
+
+-- When a system crashes, the Power firmware will save
+   the low memory (boot memory of size larger of 5% of system RAM
+   or 256MB) of RAM to the previous registered region. It will
+   also save system registers, and hardware PTE's.
+
+   NOTE: The term 'boot memory' means size of the low memory chunk
+ that is required for a kernel to boot successfully when
+ booted with restricted memory. By default, the boot memory
+ size will be the larger of 5% of system RAM or 256MB.
+ Alternatively, user can also specify boot memory size
+ through boot parameter 'fadump_reserve_mem=' which will
+ override the default calculated size.
+
+-- After the low memory (boot memory) area has been saved, the
+   firmware will reset PCI and other hardware state.  It will
+   *not* clear the RAM. It will then launch the bootloader, as
+   normal.
+
+-- The freshly booted kernel will notice that there is a new
+   node (ibm,dump-kernel) in the device tree, indicating that
+   there is crash data available from a previous boot. During
+   the early boot OS will reserve rest of the memory above
+   boot memory size effectively booting with restricted memory
+   size. This will make sure that the second kernel will not
+   touch any of the dump memory area.
+
+-- User-space tools will read /proc/vmcore to obtain the contents
+   of memory, which holds the previous crashed kernel dump in ELF
+   format. The userspace tools may copy this info to disk, or
+   network, nas, san, iscsi, etc. as desired.
+
+-- Once the userspace tool is done saving dump, it will echo
+   '1' to /sys/kernel/fadump_release_mem to release the reserved
+   memory back to general use, except the memory required for
+   next firmware-assisted dump registration.
+
+   e.g.
+ # echo 1  /sys/kernel/fadump_release_mem
+
+Please note that the firmware-assisted dump feature
+is only available on Power6 and above systems with recent
+firmware versions.
+
+Implementation details:
+--
+
+During boot, a check is made to see if firmware supports
+this feature on that particular machine. If it does, then
+we check to see if an active dump is waiting for us. If yes
+then everything but boot memory size of RAM is reserved during
+early boot (See Fig. 2). This area is released once we finish
+collecting the dump from user land scripts (e.g. kdump scripts)
+that are run. If there is dump data, then the
+/sys/kernel/fadump_release_mem file is created, and the reserved
+memory is held.
+
+If there is no waiting dump data, then only the memory required
+to hold CPU state, HPTE region, boot memory dump and elfcore
+header, is reserved at the top of memory (see Fig. 1). This area
+is *not* released: this region will be kept permanently reserved,
+so that it can act as a receptacle for a copy of the boot memory
+content in addition to CPU state and HPTE region, in the case a
+crash does occur.
+
+  o Memory Reservation during first kernel
+
+  Low memoryTop of 

[RFC PATCH v6 03/10] fadump: Register for firmware assisted dump.

2011-12-09 Thread Mahesh J Salgaonkar
From: Mahesh Salgaonkar mah...@linux.vnet.ibm.com

This patch registers for firmware-assisted dump using rtas token
ibm,configure-kernel-dump. During registration firmware is informed about
the reserved area where it saves the CPU state data, HPTE table and contents
of RMR region at the time of kernel crash. Apart from this, firmware also
preserves the contents of entire partition memory even if it is not specified
during registration.

This patch also populates sysfs files under /sys/kernel to display
fadump status and reserved memory regions.

This patch introduces fadump_registered sysfs control file which will be
used by kdump init scripts to start/stop firmware assisted dump. echo 1 to
/sys/kernel/fadump_registered file for fadump registration and
echo 0 to /sys/kernel/fadump_registered file for fadump un-registration.

Signed-off-by: Mahesh Salgaonkar mah...@linux.vnet.ibm.com
---
 arch/powerpc/include/asm/fadump.h |   57 ++
 arch/powerpc/kernel/fadump.c  |  352 +
 arch/powerpc/kernel/iommu.c   |8 +
 arch/powerpc/mm/hash_utils_64.c   |   11 +
 4 files changed, 424 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/include/asm/fadump.h 
b/arch/powerpc/include/asm/fadump.h
index 7be25d3..bbaf278 100644
--- a/arch/powerpc/include/asm/fadump.h
+++ b/arch/powerpc/include/asm/fadump.h
@@ -48,6 +48,58 @@
 #define FADUMP_HPTE_REGION 0x0002
 #define FADUMP_REAL_MODE_REGION0x0011
 
+/* Dump request flag */
+#define FADUMP_REQUEST_FLAG0x0001
+
+/* FAD commands */
+#define FADUMP_REGISTER1
+#define FADUMP_UNREGISTER  2
+#define FADUMP_INVALIDATE  3
+
+/* Kernel Dump section info */
+struct fadump_section {
+   u32 request_flag;
+   u16 source_data_type;
+   u16 error_flags;
+   u64 source_address;
+   u64 source_len;
+   u64 bytes_dumped;
+   u64 destination_address;
+};
+
+/* ibm,configure-kernel-dump header. */
+struct fadump_section_header {
+   u32 dump_format_version;
+   u16 dump_num_sections;
+   u16 dump_status_flag;
+   u32 offset_first_dump_section;
+
+   /* Fields for disk dump option. */
+   u32 dd_block_size;
+   u64 dd_block_offset;
+   u64 dd_num_blocks;
+   u32 dd_offset_disk_path;
+
+   /* Maximum time allowed to prevent an automatic dump-reboot. */
+   u32 max_time_auto;
+};
+
+/*
+ * Firmware Assisted dump memory structure. This structure is required for
+ * registering future kernel dump with power firmware through rtas call.
+ *
+ * No disk dump option. Hence disk dump path string section is not included.
+ */
+struct fadump_mem_struct {
+   struct fadump_section_headerheader;
+
+   /* Kernel dump sections */
+   struct fadump_section   cpu_state_data;
+   struct fadump_section   hpte_region;
+   struct fadump_section   rmr_region;
+};
+
+/* Firmware-assisted dump configuration details. */
 struct fw_dump {
unsigned long   cpu_state_data_size;
unsigned long   hpte_region_size;
@@ -62,10 +114,15 @@ struct fw_dump {
unsigned long   fadump_enabled:1;
unsigned long   fadump_supported:1;
unsigned long   dump_active:1;
+   unsigned long   dump_registered:1;
 };
 
 extern int early_init_dt_scan_fw_dump(unsigned long node,
const char *uname, int depth, void *data);
 extern int fadump_reserve_mem(void);
+extern int setup_fadump(void);
+extern int is_fadump_active(void);
+#else  /* CONFIG_FA_DUMP */
+static inline int is_fadump_active(void) { return 0; }
 #endif
 #endif
diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c
index deb276a..13c22cd 100644
--- a/arch/powerpc/kernel/fadump.c
+++ b/arch/powerpc/kernel/fadump.c
@@ -29,6 +29,9 @@
 
 #include linux/string.h
 #include linux/memblock.h
+#include linux/delay.h
+#include linux/debugfs.h
+#include linux/seq_file.h
 
 #include asm/page.h
 #include asm/prom.h
@@ -36,6 +39,10 @@
 #include asm/fadump.h
 
 static struct fw_dump fw_dump;
+static struct fadump_mem_struct fdm;
+static const struct fadump_mem_struct *fdm_active;
+
+static DEFINE_MUTEX(fadump_mutex);
 
 /* Scan the Firmware Assisted dump configuration details. */
 int __init early_init_dt_scan_fw_dump(unsigned long node,
@@ -64,7 +71,8 @@ int __init early_init_dt_scan_fw_dump(unsigned long node,
 * The 'ibm,kernel-dump' rtas node is present only if there is
 * dump data waiting for us.
 */
-   if (of_get_flat_dt_prop(node, ibm,kernel-dump, NULL))
+   fdm_active = of_get_flat_dt_prop(node, ibm,kernel-dump, NULL);
+   if (fdm_active)
fw_dump.dump_active = 1;
 
/* Get the sizes required to store dump data for the firmware provided
@@ -98,6 +106,85 @@ int __init early_init_dt_scan_fw_dump(unsigned long node,
return 1;
 }
 
+int is_fadump_active(void)
+{
+   return 

[RFC PATCH v6 04/10] fadump: Initialize elfcore header and add PT_LOAD program headers.

2011-12-09 Thread Mahesh J Salgaonkar
From: Mahesh Salgaonkar mah...@linux.vnet.ibm.com

Build the crash memory range list by traversing through system memory during
the first kernel before we register for firmware-assisted dump. After the
successful dump registration, initialize the elfcore header and populate
PT_LOAD program headers with crash memory ranges. The elfcore header is
saved in the scratch area within the reserved memory. The scratch area starts
at the end of the memory reserved for saving RMR region contents. The
scratch area contains fadump crash info structure that contains magic number
for fadump validation and physical address where the eflcore header can be
found. This structure will also be used to pass some important crash info
data to the second kernel which will help second kernel to populate ELF core
header with correct data before it gets exported through /proc/vmcore. Since
the firmware preserves the entire partition memory at the time of crash the
contents of the scratch area will be preserved till second kernel boot.

NOTE: The current design implementation does not address a possibility of
introducing additional fields (in future) to this structure without affecting
compatibility. It's on TODO list to come up with better approach to
address this.

Reserved dump area start = +-+
|  CPU state dump data|
+-+
|  HPTE region data   |
+-+
|  RMR region data|
Scratch area start   = +-+
|  fadump crash info structure {  |
| magic nummber   |
 +--| elfcorehdr_addr |
 |  |  }  |
 + +-+
|  ELF core header|
Reserved dump area end   = +-+

Signed-off-by: Mahesh Salgaonkar mah...@linux.vnet.ibm.com
---
 arch/powerpc/include/asm/fadump.h |   43 +++
 arch/powerpc/kernel/fadump.c  |  233 +
 2 files changed, 275 insertions(+), 1 deletions(-)

diff --git a/arch/powerpc/include/asm/fadump.h 
b/arch/powerpc/include/asm/fadump.h
index bbaf278..9e172a5 100644
--- a/arch/powerpc/include/asm/fadump.h
+++ b/arch/powerpc/include/asm/fadump.h
@@ -43,6 +43,12 @@
 #define MIN_BOOT_MEM   (((RMA_END  (0x1UL  28)) ? (0x1UL  28) : RMA_END) \
+ (0x1UL  26))
 
+#define memblock_num_regions(memblock_type)(memblock.memblock_type.cnt)
+
+#ifndef ELF_CORE_EFLAGS
+#define ELF_CORE_EFLAGS 0
+#endif
+
 /* Firmware provided dump sections */
 #define FADUMP_CPU_STATE_DATA  0x0001
 #define FADUMP_HPTE_REGION 0x0002
@@ -56,6 +62,9 @@
 #define FADUMP_UNREGISTER  2
 #define FADUMP_INVALIDATE  3
 
+/* Dump status flag */
+#define FADUMP_ERROR_FLAG  0x2000
+
 /* Kernel Dump section info */
 struct fadump_section {
u32 request_flag;
@@ -109,6 +118,7 @@ struct fw_dump {
/* cmd line option during boot */
unsigned long   reserve_bootvar;
 
+   unsigned long   fadumphdr_addr;
int ibm_configure_kernel_dump;
 
unsigned long   fadump_enabled:1;
@@ -117,6 +127,39 @@ struct fw_dump {
unsigned long   dump_registered:1;
 };
 
+/*
+ * Copy the ascii values for first 8 characters from a string into u64
+ * variable at their respective indexes.
+ * e.g.
+ *  The string FADMPINF will be converted into 0x4641444d50494e46
+ */
+static inline u64 str_to_u64(const char *str)
+{
+   u64 val = 0;
+   int i;
+
+   for (i = 0; i  sizeof(val); i++)
+   val = (*str) ? (val  8) | *str++ : val  8;
+   return val;
+}
+#define STR_TO_HEX(x)  str_to_u64(x)
+
+#define FADUMP_CRASH_INFO_MAGICSTR_TO_HEX(FADMPINF)
+
+/* fadump crash info structure */
+struct fadump_crash_info_header {
+   u64 magic_number;
+   u64 elfcorehdr_addr;
+};
+
+/* Crash memory ranges */
+#define INIT_CRASHMEM_RANGES   (INIT_MEMBLOCK_REGIONS + 2)
+
+struct fad_crash_memory_ranges {
+   unsigned long long  base;
+   unsigned long long  size;
+};
+
 extern int early_init_dt_scan_fw_dump(unsigned long node,
const char *uname, int depth, void *data);
 extern int fadump_reserve_mem(void);
diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c
index 13c22cd..f85a63f 100644
--- a/arch/powerpc/kernel/fadump.c
+++ b/arch/powerpc/kernel/fadump.c
@@ -32,6 +32,7 @@
 #include linux/delay.h
 #include linux/debugfs.h
 #include linux/seq_file.h
+#include linux/crash_dump.h
 
 #include asm/page.h
 #include 

[RFC PATCH v6 02/10] fadump: Reserve the memory for firmware assisted dump.

2011-12-09 Thread Mahesh J Salgaonkar
From: Mahesh Salgaonkar mah...@linux.vnet.ibm.com

Reserve the memory during early boot to preserve CPU state data, HPTE region
and RMA (real mode area) region data in case of kernel crash. At the time of
crash, powerpc firmware will store CPU state data, HPTE region data and move
RMA region data to the reserved memory area.

If the firmware-assisted dump fails to reserve the memory, then fallback
to existing kexec-based kdump.

The most of the code implementation to reserve memory has been
adapted from phyp assisted dump implementation written by Linas Vepstas
and Manish Ahuja

This patch also introduces a config option CONFIG_FA_DUMP for firmware
assisted dump feature on Powerpc (ppc64) architecture.

Signed-off-by: Mahesh Salgaonkar mah...@linux.vnet.ibm.com
---
 arch/powerpc/Kconfig  |   13 ++
 arch/powerpc/include/asm/fadump.h |   71 +++
 arch/powerpc/kernel/Makefile  |1 
 arch/powerpc/kernel/fadump.c  |  246 +
 arch/powerpc/kernel/prom.c|   15 ++
 5 files changed, 345 insertions(+), 1 deletions(-)
 create mode 100644 arch/powerpc/include/asm/fadump.h
 create mode 100644 arch/powerpc/kernel/fadump.c

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 951e18f..5a61aaa 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -379,6 +379,19 @@ config PHYP_DUMP
 
  If unsure, say N
 
+config FA_DUMP
+   bool Firmware-assisted dump
+   depends on PPC64  PPC_RTAS  CRASH_DUMP
+   help
+ A robust mechanism to get reliable kernel crash dump with
+ assistance from firmware. This approach does not use kexec,
+ instead firmware assists in booting the kdump kernel
+ while preserving memory contents. Firmware-assisted dump
+ is meant to be a kdump replacement offering robustness and
+ speed not possible without system firmware assistance.
+
+ If unsure, say N
+
 config IRQ_ALL_CPUS
bool Distribute interrupts on all CPUs by default
depends on SMP  !MV64360
diff --git a/arch/powerpc/include/asm/fadump.h 
b/arch/powerpc/include/asm/fadump.h
new file mode 100644
index 000..7be25d3
--- /dev/null
+++ b/arch/powerpc/include/asm/fadump.h
@@ -0,0 +1,71 @@
+/*
+ * Firmware Assisted dump header file.
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Copyright 2011 IBM Corporation
+ * Author: Mahesh Salgaonkar mah...@linux.vnet.ibm.com
+ */
+
+#ifndef __PPC64_FA_DUMP_H__
+#define __PPC64_FA_DUMP_H__
+
+#ifdef CONFIG_FA_DUMP
+
+/*
+ * The RMA region will be saved for later dumping when kernel crashes.
+ * RMA is Real Mode Area, the first block of logical memory address owned
+ * by logical partition, containing the storage that may be accessed with
+ * translate off.
+ */
+#define RMA_START  0x0
+#define RMA_END(ppc64_rma_size)
+
+/*
+ * On some Power systems where RMO is 128MB, it still requires minimum of
+ * 256MB for kernel to boot successfully. When kdump infrastructure is
+ * configured to save vmcore over network, we run into OOM issue while
+ * loading modules related to network setup. Hence we need aditional 64M
+ * of memory to avoid OOM issue.
+ */
+#define MIN_BOOT_MEM   (((RMA_END  (0x1UL  28)) ? (0x1UL  28) : RMA_END) \
+   + (0x1UL  26))
+
+/* Firmware provided dump sections */
+#define FADUMP_CPU_STATE_DATA  0x0001
+#define FADUMP_HPTE_REGION 0x0002
+#define FADUMP_REAL_MODE_REGION0x0011
+
+struct fw_dump {
+   unsigned long   cpu_state_data_size;
+   unsigned long   hpte_region_size;
+   unsigned long   boot_memory_size;
+   unsigned long   reserve_dump_area_start;
+   unsigned long   reserve_dump_area_size;
+   /* cmd line option during boot */
+   unsigned long   reserve_bootvar;
+
+   int ibm_configure_kernel_dump;
+
+   unsigned long   fadump_enabled:1;
+   unsigned long   fadump_supported:1;
+   unsigned long   dump_active:1;
+};
+
+extern int early_init_dt_scan_fw_dump(unsigned long node,
+   const char *uname, int depth, void *data);
+extern int fadump_reserve_mem(void);
+#endif
+#endif
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index ce4f7f1..59b549c 100644
--- a/arch/powerpc/kernel/Makefile

[RFC PATCH v6 06/10] fadump: Add PT_NOTE program header for vmcoreinfo

2011-12-09 Thread Mahesh J Salgaonkar
From: Mahesh Salgaonkar mah...@linux.vnet.ibm.com

Introduce a PT_NOTE program header that points to physical address of
vmcoreinfo_note buffer declared in kernel/kexec.c. The vmcoreinfo
note buffer is populated during crash_fadump() at the time of system
crash.

Signed-off-by: Mahesh Salgaonkar mah...@linux.vnet.ibm.com
---
 arch/powerpc/kernel/fadump.c |   29 +
 1 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c
index cab56e7..5689954 100644
--- a/arch/powerpc/kernel/fadump.c
+++ b/arch/powerpc/kernel/fadump.c
@@ -814,6 +814,19 @@ static void fadump_setup_crash_memory_ranges(void)
}
 }
 
+/*
+ * If the given physical address falls within the boot memory region then
+ * return the relocated address that points to the dump region reserved
+ * for saving initial boot memory contents.
+ */
+static inline unsigned long fadump_relocate(unsigned long paddr)
+{
+   if (paddr  RMA_START  paddr  fw_dump.boot_memory_size)
+   return fdm.rmr_region.destination_address + paddr;
+   else
+   return paddr;
+}
+
 static int fadump_create_elfcore_headers(char *bufp)
 {
struct elfhdr *elf;
@@ -845,6 +858,22 @@ static int fadump_create_elfcore_headers(char *bufp)
 
(elf-e_phnum)++;
 
+   /* setup ELF PT_NOTE for vmcoreinfo */
+   phdr = (struct elf_phdr *)bufp;
+   bufp += sizeof(struct elf_phdr);
+   phdr-p_type= PT_NOTE;
+   phdr-p_flags   = 0;
+   phdr-p_vaddr   = 0;
+   phdr-p_align   = 0;
+
+   phdr-p_paddr   = fadump_relocate(paddr_vmcoreinfo_note());
+   phdr-p_offset  = phdr-p_paddr;
+   phdr-p_memsz   = vmcoreinfo_max_size;
+   phdr-p_filesz  = vmcoreinfo_max_size;
+
+   /* Increment number of program headers. */
+   (elf-e_phnum)++;
+
/* setup PT_LOAD sections. */
 
for (i = 0; i  crash_mem_ranges; i++) {

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[RFC PATCH v6 07/10] fadump: Introduce cleanup routine to invalidate /proc/vmcore.

2011-12-09 Thread Mahesh J Salgaonkar
From: Mahesh Salgaonkar mah...@linux.vnet.ibm.com

With the firmware-assisted dump support we don't require a reboot when we
are in second kernel after crash. The second kernel after crash is a normal
kernel boot and has knowledge about entire system RAM with the page tables
initialized for entire system RAM. Hence once the dump is saved to disk, we
can just release the reserved memory area for general use and continue
with second kernel as production kernel.

Hence when we release the reserved memory that contains dump data, the
'/proc/vmcore' will not be valid anymore. Hence this patch introduces
a cleanup routine that invalidates and removes the /proc/vmcore file. This
routine will be invoked before we release the reserved dump memory area.

Signed-off-by: Mahesh Salgaonkar mah...@linux.vnet.ibm.com
---
 fs/proc/vmcore.c |   23 +++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
index b0f450a..0d5071d 100644
--- a/fs/proc/vmcore.c
+++ b/fs/proc/vmcore.c
@@ -700,3 +700,26 @@ static int __init vmcore_init(void)
return 0;
 }
 module_init(vmcore_init)
+
+/* Cleanup function for vmcore module. */
+void vmcore_cleanup(void)
+{
+   struct list_head *pos, *next;
+
+   if (proc_vmcore) {
+   remove_proc_entry(proc_vmcore-name, proc_vmcore-parent);
+   proc_vmcore = NULL;
+   }
+
+   /* clear the vmcore list. */
+   list_for_each_safe(pos, next, vmcore_list) {
+   struct vmcore *m;
+
+   m = list_entry(pos, struct vmcore, list);
+   list_del(m-list);
+   kfree(m);
+   }
+   kfree(elfcorebuf);
+   elfcorebuf = NULL;
+}
+EXPORT_SYMBOL_GPL(vmcore_cleanup);

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[RFC PATCH v6 05/10] fadump: Convert firmware-assisted cpu state dump data into elf notes.

2011-12-09 Thread Mahesh J Salgaonkar
From: Mahesh Salgaonkar mah...@linux.vnet.ibm.com

When registered for firmware assisted dump on powerpc, firmware preserves
the registers for the active CPUs during a system crash. This patch reads
the cpu register data stored in Firmware-assisted dump format (except for
crashing cpu) and converts it into elf notes and updates the PT_NOTE program
header accordingly. The exact register state for crashing cpu is saved to
fadump crash info structure in scratch area during crash_fadump() and read
during second kernel boot.

Signed-off-by: Mahesh Salgaonkar mah...@linux.vnet.ibm.com
---
 arch/powerpc/include/asm/fadump.h  |   44 +
 arch/powerpc/kernel/fadump.c   |  314 
 arch/powerpc/kernel/setup-common.c |6 +
 arch/powerpc/kernel/traps.c|3 
 4 files changed, 365 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/include/asm/fadump.h 
b/arch/powerpc/include/asm/fadump.h
index 9e172a5..6768195 100644
--- a/arch/powerpc/include/asm/fadump.h
+++ b/arch/powerpc/include/asm/fadump.h
@@ -65,6 +65,18 @@
 /* Dump status flag */
 #define FADUMP_ERROR_FLAG  0x2000
 
+#define FADUMP_CPU_ID_MASK ((1UL  32) - 1)
+
+#define CPU_UNKNOWN(~((u32)0))
+
+/* Utility macros */
+#define SKIP_TO_NEXT_CPU(reg_entry)\
+({ \
+   while (reg_entry-reg_id != REG_ID(CPUEND))   \
+   reg_entry++;\
+   reg_entry++;\
+})
+
 /* Kernel Dump section info */
 struct fadump_section {
u32 request_flag;
@@ -119,6 +131,9 @@ struct fw_dump {
unsigned long   reserve_bootvar;
 
unsigned long   fadumphdr_addr;
+   unsigned long   cpu_notes_buf;
+   unsigned long   cpu_notes_buf_size;
+
int ibm_configure_kernel_dump;
 
unsigned long   fadump_enabled:1;
@@ -143,13 +158,40 @@ static inline u64 str_to_u64(const char *str)
return val;
 }
 #define STR_TO_HEX(x)  str_to_u64(x)
+#define REG_ID(x)  str_to_u64(x)
 
 #define FADUMP_CRASH_INFO_MAGICSTR_TO_HEX(FADMPINF)
+#define REGSAVE_AREA_MAGIC STR_TO_HEX(REGSAVE)
+
+/* The firmware-assisted dump format.
+ *
+ * The register save area is an area in the partition's memory used to preserve
+ * the register contents (CPU state data) for the active CPUs during a firmware
+ * assisted dump. The dump format contains register save area header followed
+ * by register entries. Each list of registers for a CPU starts with
+ * CPUSTRT and ends with CPUEND.
+ */
+
+/* Register save area header. */
+struct fadump_reg_save_area_header {
+   u64 magic_number;
+   u32 version;
+   u32 num_cpu_offset;
+};
+
+/* Register entry. */
+struct fadump_reg_entry {
+   u64 reg_id;
+   u64 reg_value;
+};
 
 /* fadump crash info structure */
 struct fadump_crash_info_header {
u64 magic_number;
u64 elfcorehdr_addr;
+   u32 crashing_cpu;
+   struct pt_regs  regs;
+   struct cpumask  cpu_online_mask;
 };
 
 /* Crash memory ranges */
@@ -165,7 +207,9 @@ extern int early_init_dt_scan_fw_dump(unsigned long node,
 extern int fadump_reserve_mem(void);
 extern int setup_fadump(void);
 extern int is_fadump_active(void);
+extern void crash_fadump(struct pt_regs *, const char *);
 #else  /* CONFIG_FA_DUMP */
 static inline int is_fadump_active(void) { return 0; }
+static inline void crash_fadump(struct pt_regs *regs, const char *str) { }
 #endif
 #endif
diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c
index f85a63f..cab56e7 100644
--- a/arch/powerpc/kernel/fadump.c
+++ b/arch/powerpc/kernel/fadump.c
@@ -240,6 +240,7 @@ static unsigned long get_fadump_area_size(void)
size += fw_dump.boot_memory_size;
size += sizeof(struct fadump_crash_info_header);
size += sizeof(struct elfhdr); /* ELF core header.*/
+   size += sizeof(struct elf_phdr); /* place holder for cpu notes */
/* Program headers for crash memory regions. */
size += sizeof(struct elf_phdr) * (memblock_num_regions(memory) + 2);
 
@@ -393,6 +394,285 @@ static void register_fw_dump(struct fadump_mem_struct 
*fdm)
}
 }
 
+void crash_fadump(struct pt_regs *regs, const char *str)
+{
+   struct fadump_crash_info_header *fdh = NULL;
+
+   if (!fw_dump.dump_registered || !fw_dump.fadumphdr_addr)
+   return;
+
+   fdh = __va(fw_dump.fadumphdr_addr);
+   crashing_cpu = smp_processor_id();
+   fdh-crashing_cpu = crashing_cpu;
+   crash_save_vmcoreinfo();
+
+   if (regs)
+   fdh-regs = *regs;
+   else
+   ppc_save_regs(fdh-regs);
+
+   fdh-cpu_online_mask = *cpu_online_mask;
+
+   /* Call ibm,os-term rtas call to trigger firmware assisted dump */
+   rtas_os_term((char 

[RFC PATCH v6 09/10] fadump: Invalidate the fadump registration during machine shutdown.

2011-12-09 Thread Mahesh J Salgaonkar
From: Mahesh Salgaonkar mah...@linux.vnet.ibm.com

If dump is active during system reboot, shutdown or halt then invalidate
the fadump registration as it does not get invalidated automatically.

Signed-off-by: Mahesh Salgaonkar mah...@linux.vnet.ibm.com
---
 arch/powerpc/kernel/setup-common.c |8 
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/kernel/setup-common.c 
b/arch/powerpc/kernel/setup-common.c
index 4e62a56..b0ebdea 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -110,6 +110,14 @@ EXPORT_SYMBOL(ppc_do_canonicalize_irqs);
 /* also used by kexec */
 void machine_shutdown(void)
 {
+#ifdef CONFIG_FA_DUMP
+   /*
+* if fadump is active, cleanup the fadump registration before we
+* shutdown.
+*/
+   fadump_cleanup();
+#endif
+
if (ppc_md.machine_shutdown)
ppc_md.machine_shutdown();
 }

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[RFC PATCH v6 10/10] fadump: Remove the phyp assisted dump code.

2011-12-09 Thread Mahesh J Salgaonkar
From: Mahesh Salgaonkar mah...@linux.vnet.ibm.com

Remove the phyp assisted dump implementation which is not is use.

Signed-off-by: Mahesh Salgaonkar mah...@linux.vnet.ibm.com
---
 Documentation/powerpc/phyp-assisted-dump.txt |  127 --
 arch/powerpc/Kconfig |   10 -
 arch/powerpc/include/asm/phyp_dump.h |   47 --
 arch/powerpc/kernel/prom.c   |   87 
 arch/powerpc/platforms/pseries/Makefile  |1 
 arch/powerpc/platforms/pseries/phyp_dump.c   |  513 --
 6 files changed, 0 insertions(+), 785 deletions(-)
 delete mode 100644 Documentation/powerpc/phyp-assisted-dump.txt
 delete mode 100644 arch/powerpc/include/asm/phyp_dump.h
 delete mode 100644 arch/powerpc/platforms/pseries/phyp_dump.c

diff --git a/Documentation/powerpc/phyp-assisted-dump.txt 
b/Documentation/powerpc/phyp-assisted-dump.txt
deleted file mode 100644
index ad34020..000
--- a/Documentation/powerpc/phyp-assisted-dump.txt
+++ /dev/null
@@ -1,127 +0,0 @@
-
-   Hypervisor-Assisted Dump
-   
-   November 2007
-
-The goal of hypervisor-assisted dump is to enable the dump of
-a crashed system, and to do so from a fully-reset system, and
-to minimize the total elapsed time until the system is back
-in production use.
-
-As compared to kdump or other strategies, hypervisor-assisted
-dump offers several strong, practical advantages:
-
--- Unlike kdump, the system has been reset, and loaded
-   with a fresh copy of the kernel.  In particular,
-   PCI and I/O devices have been reinitialized and are
-   in a clean, consistent state.
--- As the dump is performed, the dumped memory becomes
-   immediately available to the system for normal use.
--- After the dump is completed, no further reboots are
-   required; the system will be fully usable, and running
-   in its normal, production mode on its normal kernel.
-
-The above can only be accomplished by coordination with,
-and assistance from the hypervisor. The procedure is
-as follows:
-
--- When a system crashes, the hypervisor will save
-   the low 256MB of RAM to a previously registered
-   save region. It will also save system state, system
-   registers, and hardware PTE's.
-
--- After the low 256MB area has been saved, the
-   hypervisor will reset PCI and other hardware state.
-   It will *not* clear RAM. It will then launch the
-   bootloader, as normal.
-
--- The freshly booted kernel will notice that there
-   is a new node (ibm,dump-kernel) in the device tree,
-   indicating that there is crash data available from
-   a previous boot. It will boot into only 256MB of RAM,
-   reserving the rest of system memory.
-
--- Userspace tools will parse /sys/kernel/release_region
-   and read /proc/vmcore to obtain the contents of memory,
-   which holds the previous crashed kernel. The userspace
-   tools may copy this info to disk, or network, nas, san,
-   iscsi, etc. as desired.
-
-   For Example: the values in /sys/kernel/release-region
-   would look something like this (address-range pairs).
-   CPU:0x177fee000-0x1: HPTE:0x177ffe020-0x1000: /
-   DUMP:0x177fff020-0x1000, 0x1000-0x16F1D370A
-
--- As the userspace tools complete saving a portion of
-   dump, they echo an offset and size to
-   /sys/kernel/release_region to release the reserved
-   memory back to general use.
-
-   An example of this is:
- echo 0x4000 0x1000  /sys/kernel/release_region
-   which will release 256MB at the 1GB boundary.
-
-Please note that the hypervisor-assisted dump feature
-is only available on Power6-based systems with recent
-firmware versions.
-
-Implementation details:
---
-
-During boot, a check is made to see if firmware supports
-this feature on this particular machine. If it does, then
-we check to see if a active dump is waiting for us. If yes
-then everything but 256 MB of RAM is reserved during early
-boot. This area is released once we collect a dump from user
-land scripts that are run. If there is dump data, then
-the /sys/kernel/release_region file is created, and
-the reserved memory is held.
-
-If there is no waiting dump data, then only the highest
-256MB of the ram is reserved as a scratch area. This area
-is *not* released: this region will be kept permanently
-reserved, so that it can act as a receptacle for a copy
-of the low 256MB in the case a crash does occur. See,
-however, open issues below, as to whether
-such a reserved region is really needed.
-
-Currently the dump will be copied from /proc/vmcore to a
-a new file upon user intervention. The starting address
-to be read and the range for each data point in provided
-in /sys/kernel/release_region.
-
-The tools to examine the dump will be same as the ones
-used for kdump.
-
-General notes:
---
-Security: please note that there are potential security issues
-with any sort of dump mechanism. In particular, plaintext

[RFC PATCH v6 08/10] fadump: Invalidate registration and release reserved memory for general use.

2011-12-09 Thread Mahesh J Salgaonkar
From: Mahesh Salgaonkar mah...@linux.vnet.ibm.com

This patch introduces an sysfs interface '/sys/kernel/fadump_release_mem' to
invalidate the last fadump registration, invalidate '/proc/vmcore', release
the reserved memory for general use and re-register for future kernel dump.
Once the dump is copied to the disk, the userspace tool will echo 1 to
'/sys/kernel/fadump_release_mem'.

Release the reserved memory region excluding the size of the memory required
for future kernel dump registration.

Signed-off-by: Mahesh Salgaonkar mah...@linux.vnet.ibm.com
---
 arch/powerpc/include/asm/fadump.h |3 +
 arch/powerpc/kernel/fadump.c  |  158 -
 2 files changed, 157 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/include/asm/fadump.h 
b/arch/powerpc/include/asm/fadump.h
index 6768195..88dbf96 100644
--- a/arch/powerpc/include/asm/fadump.h
+++ b/arch/powerpc/include/asm/fadump.h
@@ -208,6 +208,9 @@ extern int fadump_reserve_mem(void);
 extern int setup_fadump(void);
 extern int is_fadump_active(void);
 extern void crash_fadump(struct pt_regs *, const char *);
+extern void fadump_cleanup(void);
+
+extern void vmcore_cleanup(void);
 #else  /* CONFIG_FA_DUMP */
 static inline int is_fadump_active(void) { return 0; }
 static inline void crash_fadump(struct pt_regs *regs, const char *str) { }
diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c
index 5689954..8874d6b 100644
--- a/arch/powerpc/kernel/fadump.c
+++ b/arch/powerpc/kernel/fadump.c
@@ -33,6 +33,8 @@
 #include linux/debugfs.h
 #include linux/seq_file.h
 #include linux/crash_dump.h
+#include linux/kobject.h
+#include linux/sysfs.h
 
 #include asm/page.h
 #include asm/prom.h
@@ -984,6 +986,132 @@ static int fadump_unregister_dump(struct 
fadump_mem_struct *fdm)
return 0;
 }
 
+static int fadump_invalidate_dump(struct fadump_mem_struct *fdm)
+{
+   int rc = 0;
+   unsigned int wait_time;
+
+   pr_debug(Invalidating firmware-assisted dump registration\n);
+
+   /* TODO: Add upper time limit for the delay */
+   do {
+   rc = rtas_call(fw_dump.ibm_configure_kernel_dump, 3, 1, NULL,
+   FADUMP_INVALIDATE, fdm,
+   sizeof(struct fadump_mem_struct));
+
+   wait_time = rtas_busy_delay_time(rc);
+   if (wait_time)
+   mdelay(wait_time);
+   } while (wait_time);
+
+   if (rc) {
+   printk(KERN_ERR Failed to invalidate firmware-assisted dump 
+   rgistration. unexpected error(%d).\n, rc);
+   return rc;
+   }
+   fw_dump.dump_active = 0;
+   fdm_active = NULL;
+   return 0;
+}
+
+void fadump_cleanup(void)
+{
+   /* Invalidate the registration only if dump is active. */
+   if (fw_dump.dump_active) {
+   init_fadump_mem_struct(fdm,
+   fdm_active-cpu_state_data.destination_address);
+   fadump_invalidate_dump(fdm);
+   }
+}
+
+/*
+ * Release the memory that was reserved in early boot to preserve the memory
+ * contents. The released memory will be available for general use.
+ */
+static void fadump_release_memory(unsigned long begin, unsigned long end)
+{
+   unsigned long addr;
+   unsigned long ra_start, ra_end;
+
+   ra_start = fw_dump.reserve_dump_area_start;
+   ra_end = ra_start + fw_dump.reserve_dump_area_size;
+
+   for (addr = begin; addr  end; addr += PAGE_SIZE) {
+   /*
+* exclude the dump reserve area. Will reuse it for next
+* fadump registration.
+*/
+   if (addr = ra_end  ((addr + PAGE_SIZE)  ra_start))
+   continue;
+
+   ClearPageReserved(pfn_to_page(addr  PAGE_SHIFT));
+   init_page_count(pfn_to_page(addr  PAGE_SHIFT));
+   free_page((unsigned long)__va(addr));
+   totalram_pages++;
+   }
+}
+
+static void fadump_invalidate_release_mem(void)
+{
+   unsigned long reserved_area_start, reserved_area_end;
+   unsigned long destination_address;
+
+   mutex_lock(fadump_mutex);
+   if (!fw_dump.dump_active) {
+   mutex_unlock(fadump_mutex);
+   return;
+   }
+
+   destination_address = fdm_active-cpu_state_data.destination_address;
+   fadump_cleanup();
+   mutex_unlock(fadump_mutex);
+
+   /*
+* Save the current reserved memory bounds we will require them
+* later for releasing the memory for general use.
+*/
+   reserved_area_start = fw_dump.reserve_dump_area_start;
+   reserved_area_end = reserved_area_start +
+   fw_dump.reserve_dump_area_size;
+   /*
+* Setup reserve_dump_area_start and its size so that we can
+* reuse this reserved memory for Re-registration.
+*/
+   fw_dump.reserve_dump_area_start = destination_address;
+