[PATCH V4] powerpc, powernv: Add OPAL platform event driver

2015-02-05 Thread Vipin K Parashar
This patch creates a new OPAL platform event character driver
which will give userspace clients the access to these events
and process them effectively. Following platforms events are
currently supported with this platform driver.

(1) Environmental and Power Warning (EPOW)
(2) Delayed Power Off (DPO)

The user interface for this driver is /dev/opal_event character
device file where the user space clients can poll and read for
new opal platform events. The expected sequence of events driven
from user space should be like the following.

(1) Open the character device file
(2) Poll on the file for POLLIN event
(3) When unblocked, must attempt to read OPAL_PLAT_EVENT_MAX_SIZE size
(4) Kernel driver will pass at most one opal_plat_event structure
(5) Poll again for more new events

The driver registers for OPAL messages notifications corresponding to
individual OPAL events. When any of those event messages arrive in the
kernel, the callbacks are called to process them which in turn unblocks
the polling thread on the character device file. The driver also registers
a timer function which will be called after a threshold amount of time to
shutdown the system. The user space client receives the timeout value for
all individual OPAL platform events and hence must prepare the system and
eventually shutdown. In case the user client does not shutdown the system,
the timer function will be called after the threshold and shutdown the
system explicitly.

Signed-off-by: Vipin K Parashar vi...@linux.vnet.ibm.com
Signed-off-by: Anshuman Khandual khand...@linux.vnet.ibm.com
---
Changes in V4:
- Used miscdev in place of chardev
- Used module_platform_driver macro for registering platform driver
- Added endianness conversions before and after making OPAL calls
- Changed events data structure in opal_platform_events.h to use bitmask
  for various events in each event class
- Added some info prints
- Added code changes to return remaining time for DPO event for user space query
- Made O_NONBLOCK unsupported for file open call
- Changed actionable_epow function to exclude events and purged epow_exclude 
function

Changes in V3:
- Rebased the patch against the mainline

Changes in V2:
- Changed the function fetch_dpo_timeout
- Export opal_platform_events.h for user space consumption
- Posted here https://patchwork.ozlabs.org/patch/396725/

Original V1:
- Original patch
- Posted here http://patchwork.ozlabs.org/patch/394340/

 arch/powerpc/include/asm/opal.h|  45 +-
 arch/powerpc/include/uapi/asm/Kbuild   |   1 +
 .../include/uapi/asm/opal_platform_events.h|  90 +++
 arch/powerpc/platforms/powernv/Makefile|   2 +-
 .../platforms/powernv/opal-platform-events.c   | 663 +
 arch/powerpc/platforms/powernv/opal-wrappers.S |   1 +
 arch/powerpc/platforms/powernv/opal.c  |   8 +-
 7 files changed, 807 insertions(+), 3 deletions(-)
 create mode 100644 arch/powerpc/include/uapi/asm/opal_platform_events.h
 create mode 100644 arch/powerpc/platforms/powernv/opal-platform-events.c

diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm/opal.h
index eb95b67..950839c 100644
--- a/arch/powerpc/include/asm/opal.h
+++ b/arch/powerpc/include/asm/opal.h
@@ -166,6 +166,7 @@ struct opal_sg_list {
 #define OPAL_UNREGISTER_DUMP_REGION102
 #define OPAL_WRITE_TPO 103
 #define OPAL_READ_TPO  104
+#define OPAL_GET_DPO_STATUS105
 #define OPAL_IPMI_SEND 107
 #define OPAL_IPMI_RECV 108
 #define OPAL_I2C_REQUEST   109
@@ -306,6 +307,7 @@ enum OpalMessageType {
OPAL_MSG_EPOW,
OPAL_MSG_SHUTDOWN,
OPAL_MSG_HMI_EVT,
+   OPAL_MSG_DPO,
OPAL_MSG_TYPE_MAX,
 };
 
@@ -421,6 +423,46 @@ struct opal_msg {
__be64 params[8];
 };
 
+/*
+ * EPOW status sharing (OPAL and the host)
+ *
+ * The host will pass on OPAL, a buffer of length OPAL_SYSEPOW_MAX
+ * with individual elements being 16 bits wide to fetch the system
+ * wide EPOW status. Each element in the buffer will contain the
+ * EPOW status in it's bit representation for a particular EPOW sub
+ * class as defiend here. So multiple detailed EPOW status bits
+ * specific for any sub class can be represented in a single buffer
+ * element as it's bit representation.
+ */
+
+/* System EPOW type */
+enum OpalSysEpow {
+   OPAL_SYSEPOW_POWER  = 0,/* Power EPOW */
+   OPAL_SYSEPOW_TEMP   = 1,/* Temperature EPOW */
+   OPAL_SYSEPOW_COOLING= 2,/* Cooling EPOW */
+   OPAL_SYSEPOW_MAX= 3,/* Max EPOW categories */
+};
+
+/* Power EPOW */
+enum OpalSysPower {
+   OPAL_SYSPOWER_UPS   = 0x0001, /* System on UPS power */
+   OPAL_SYSPOWER_CHNG  = 0x0002, /* System power config change */
+   OPAL_SYSPOWER_FAIL  = 

Re: [PATCH 12/15] mtd: kconfig: replace PPC_OF with PPC

2015-02-05 Thread Brian Norris
On Sat, Jan 31, 2015 at 09:47:42PM +0800, Kevin Hao wrote:
 The PPC_OF is a ppc specific option which is used to mean that the
 firmware device tree access functions are available. Since all the
 ppc platforms have a device tree, it is aways set to 'y' for ppc.
 So it makes no sense to keep a such option in the current kernel.
 Replace it with PPC.
 
 Signed-off-by: Kevin Hao haoke...@gmail.com

Pushed to l2-mtd.git. Thanks.

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

Re: [RFC 00/10] Freescale DPAA B/QMan drivers

2015-02-05 Thread Emil Medve
Hello Dan,


Thanks for the reply

On 02/05/2015 02:41 AM, Dan Carpenter wrote:
 Normally, for staging drivers we just require the TODO and a maintainer
 and we merge things as-is.  There isn't really much review of the code.

I think I'll go for drivers/soc as we have quite a handful of other
drivers using this code that already decided not to be located into staging


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

Re: [RFC 00/10] Freescale DPAA B/QMan drivers

2015-02-05 Thread Emil Medve
Hello Bob,


On 02/05/2015 09:48 AM, Bob Cochran wrote:
 On 02/04/2015 09:48 AM, Emil Medve wrote:

 Hello,


 This is the first attempt to publish the Freescale DPAA B/QMan
 drivers. They are
 not to be applied yet.  At this stage, this is more or less the
 drivers from the
 Freescale PowerPC SDK roughly squashed and split in a sequence of
 component
 patches. They still needs some work and cleanup before we expect to
 have them
 applied, but we appreciate early feedback
 
 
 Hi Emil,
 
 I had thought to try to apply these patches and build it, but I won't
 get very far using it without FMAN (on my t1040).   I searched through
 the mail archives and didn't find FMAN patches other than for the device
 tree.   I also don't see it in the mainline tree.
 
 If FMAN patches have already been submitted, please point me to it.
 
 If not, then please let me know when we will see code to support FMAN.

Let me inquire with the FMan guy here. I'll get back to you on this,
however, don't hold your breath. There might be some weeks before the
FMan driver will hit the e-mail lists

 Also, is it your intention for the same QMAN/BMAN drivers to be used
 with both FMAN and the LS AIOP?

These drivers (with some upcoming updates) are expected to be use on all
QorIQ and LS1 devices. The programming model for LS2 (which includes the
AIOP and friends) seems to have a different programming model and these
drivers will not be usable there


Cheers,


 Thank you,
 
 Bob
 
 
 
 
 


 Cheers,


 Geoff Thorpe (8):
fsl_bman: Add drivers for the Freescale DPAA BMan
fsl_qman: Add drivers for the Freescale DPAA QMan
powerpc/mpc85xx: Add platform support for the Freescale DPAA BMan
powerpc/mpc85xx: Add platform support for the Freescale DPAA QMan
fsl_bman: Add self-tester
fsl_qman: Add self-tester
fsl_bman: Add debugfs support
fsl_qman: Add debugfs support

 Hai-Ying Wang (2):
fsl_bman: Add HOTPLUG_CPU support
fsl_qman: Add HOTPLUG_CPU support

   arch/powerpc/Kconfig|   33 +-
   arch/powerpc/platforms/85xx/Kconfig |   11 +-
   arch/powerpc/platforms/85xx/corenet_generic.c   |   26 +-
   arch/powerpc/platforms/85xx/p1023_rdb.c |   26 +-
   drivers/staging/Kconfig |4 +-
   drivers/staging/Makefile|1 +
   drivers/staging/fsl_qbman/Kconfig   |  188 ++
   drivers/staging/fsl_qbman/Makefile  |   23 +
   drivers/staging/fsl_qbman/bman_config.c |  611 ++
   drivers/staging/fsl_qbman/bman_debugfs.c|  119 +
   drivers/staging/fsl_qbman/bman_driver.c |  373 
   drivers/staging/fsl_qbman/bman_high.c   | 1055 +
   drivers/staging/fsl_qbman/bman_low.h|  524 +
   drivers/staging/fsl_qbman/bman_private.h|  149 ++
   drivers/staging/fsl_qbman/bman_test.c   |   56 +
   drivers/staging/fsl_qbman/bman_test.h   |   44 +
   drivers/staging/fsl_qbman/bman_test_high.c  |  181 ++
   drivers/staging/fsl_qbman/bman_test_thresh.c|  196 ++
   drivers/staging/fsl_qbman/dpa_alloc.c   |  573 +
   drivers/staging/fsl_qbman/dpa_sys.h |  294 +++
   drivers/staging/fsl_qbman/qbman_driver.c|   85 +
   drivers/staging/fsl_qbman/qman_config.c |  991 +
   drivers/staging/fsl_qbman/qman_debugfs.c| 1326 
   drivers/staging/fsl_qbman/qman_driver.c |  548 +
   drivers/staging/fsl_qbman/qman_high.c   | 2624
 +++
   drivers/staging/fsl_qbman/qman_low.h| 1302 +++
   drivers/staging/fsl_qbman/qman_private.h|  283 +++
   drivers/staging/fsl_qbman/qman_test.c   |   57 +
   drivers/staging/fsl_qbman/qman_test.h   |   43 +
   drivers/staging/fsl_qbman/qman_test_high.c  |  213 ++
   drivers/staging/fsl_qbman/qman_test_hotpotato.c |  497 +
   drivers/staging/fsl_qbman/qman_utility.c|  129 ++
   include/linux/fsl_bman.h|  517 +
   include/linux/fsl_qman.h| 1955
 +
   34 files changed, 15032 insertions(+), 25 deletions(-)
   create mode 100644 drivers/staging/fsl_qbman/Kconfig
   create mode 100644 drivers/staging/fsl_qbman/Makefile
   create mode 100644 drivers/staging/fsl_qbman/bman_config.c
   create mode 100644 drivers/staging/fsl_qbman/bman_debugfs.c
   create mode 100644 drivers/staging/fsl_qbman/bman_driver.c
   create mode 100644 drivers/staging/fsl_qbman/bman_high.c
   create mode 100644 drivers/staging/fsl_qbman/bman_low.h
   create mode 100644 drivers/staging/fsl_qbman/bman_private.h
   create mode 100644 drivers/staging/fsl_qbman/bman_test.c
   create mode 100644 drivers/staging/fsl_qbman/bman_test.h
   create mode 100644 drivers/staging/fsl_qbman/bman_test_high.c
   create mode 100644 drivers/staging/fsl_qbman/bman_test_thresh.c
   create mode 100644 drivers/staging/fsl_qbman/dpa_alloc.c

Re: [RFC 00/10] Freescale DPAA B/QMan drivers

2015-02-05 Thread Bob Cochran

On 02/04/2015 09:48 AM, Emil Medve wrote:


Hello,


This is the first attempt to publish the Freescale DPAA B/QMan drivers. They are
not to be applied yet.  At this stage, this is more or less the drivers from the
Freescale PowerPC SDK roughly squashed and split in a sequence of component
patches. They still needs some work and cleanup before we expect to have them
applied, but we appreciate early feedback



Hi Emil,

I had thought to try to apply these patches and build it, but I won't 
get very far using it without FMAN (on my t1040).   I searched through 
the mail archives and didn't find FMAN patches other than for the device 
tree.   I also don't see it in the mainline tree.


If FMAN patches have already been submitted, please point me to it.

If not, then please let me know when we will see code to support FMAN.

Also, is it your intention for the same QMAN/BMAN drivers to be used 
with both FMAN and the LS AIOP?


Thank you,

Bob








Cheers,


Geoff Thorpe (8):
   fsl_bman: Add drivers for the Freescale DPAA BMan
   fsl_qman: Add drivers for the Freescale DPAA QMan
   powerpc/mpc85xx: Add platform support for the Freescale DPAA BMan
   powerpc/mpc85xx: Add platform support for the Freescale DPAA QMan
   fsl_bman: Add self-tester
   fsl_qman: Add self-tester
   fsl_bman: Add debugfs support
   fsl_qman: Add debugfs support

Hai-Ying Wang (2):
   fsl_bman: Add HOTPLUG_CPU support
   fsl_qman: Add HOTPLUG_CPU support

  arch/powerpc/Kconfig|   33 +-
  arch/powerpc/platforms/85xx/Kconfig |   11 +-
  arch/powerpc/platforms/85xx/corenet_generic.c   |   26 +-
  arch/powerpc/platforms/85xx/p1023_rdb.c |   26 +-
  drivers/staging/Kconfig |4 +-
  drivers/staging/Makefile|1 +
  drivers/staging/fsl_qbman/Kconfig   |  188 ++
  drivers/staging/fsl_qbman/Makefile  |   23 +
  drivers/staging/fsl_qbman/bman_config.c |  611 ++
  drivers/staging/fsl_qbman/bman_debugfs.c|  119 +
  drivers/staging/fsl_qbman/bman_driver.c |  373 
  drivers/staging/fsl_qbman/bman_high.c   | 1055 +
  drivers/staging/fsl_qbman/bman_low.h|  524 +
  drivers/staging/fsl_qbman/bman_private.h|  149 ++
  drivers/staging/fsl_qbman/bman_test.c   |   56 +
  drivers/staging/fsl_qbman/bman_test.h   |   44 +
  drivers/staging/fsl_qbman/bman_test_high.c  |  181 ++
  drivers/staging/fsl_qbman/bman_test_thresh.c|  196 ++
  drivers/staging/fsl_qbman/dpa_alloc.c   |  573 +
  drivers/staging/fsl_qbman/dpa_sys.h |  294 +++
  drivers/staging/fsl_qbman/qbman_driver.c|   85 +
  drivers/staging/fsl_qbman/qman_config.c |  991 +
  drivers/staging/fsl_qbman/qman_debugfs.c| 1326 
  drivers/staging/fsl_qbman/qman_driver.c |  548 +
  drivers/staging/fsl_qbman/qman_high.c   | 2624 +++
  drivers/staging/fsl_qbman/qman_low.h| 1302 +++
  drivers/staging/fsl_qbman/qman_private.h|  283 +++
  drivers/staging/fsl_qbman/qman_test.c   |   57 +
  drivers/staging/fsl_qbman/qman_test.h   |   43 +
  drivers/staging/fsl_qbman/qman_test_high.c  |  213 ++
  drivers/staging/fsl_qbman/qman_test_hotpotato.c |  497 +
  drivers/staging/fsl_qbman/qman_utility.c|  129 ++
  include/linux/fsl_bman.h|  517 +
  include/linux/fsl_qman.h| 1955 +
  34 files changed, 15032 insertions(+), 25 deletions(-)
  create mode 100644 drivers/staging/fsl_qbman/Kconfig
  create mode 100644 drivers/staging/fsl_qbman/Makefile
  create mode 100644 drivers/staging/fsl_qbman/bman_config.c
  create mode 100644 drivers/staging/fsl_qbman/bman_debugfs.c
  create mode 100644 drivers/staging/fsl_qbman/bman_driver.c
  create mode 100644 drivers/staging/fsl_qbman/bman_high.c
  create mode 100644 drivers/staging/fsl_qbman/bman_low.h
  create mode 100644 drivers/staging/fsl_qbman/bman_private.h
  create mode 100644 drivers/staging/fsl_qbman/bman_test.c
  create mode 100644 drivers/staging/fsl_qbman/bman_test.h
  create mode 100644 drivers/staging/fsl_qbman/bman_test_high.c
  create mode 100644 drivers/staging/fsl_qbman/bman_test_thresh.c
  create mode 100644 drivers/staging/fsl_qbman/dpa_alloc.c
  create mode 100644 drivers/staging/fsl_qbman/dpa_sys.h
  create mode 100644 drivers/staging/fsl_qbman/qbman_driver.c
  create mode 100644 drivers/staging/fsl_qbman/qman_config.c
  create mode 100644 drivers/staging/fsl_qbman/qman_debugfs.c
  create mode 100644 drivers/staging/fsl_qbman/qman_driver.c
  create mode 100644 drivers/staging/fsl_qbman/qman_high.c
  create mode 100644 drivers/staging/fsl_qbman/qman_low.h
  create mode 100644 drivers/staging/fsl_qbman/qman_private.h
  create mode 100644 drivers/staging/fsl_qbman/qman_test.c
  create mode 100644 

Re: [PATCH v5 0/4] powerpc/pstore: Add pstore support for nvram partitions

2015-02-05 Thread Kees Cook
On Thu, Feb 5, 2015 at 11:35 AM, Hari Bathini
hbath...@linux.vnet.ibm.com wrote:
 This patch series adds pstore support on powernv platform to
 read different nvram partitions and write compressed data to
 oops-log nvram partition. As pseries platform already has
 pstore support, this series moves most of the common code
 for pseries and powernv platforms to a common file. Tested
 the patches successfully on both pseries and powernv
 platforms. Also, tested the patches successfully, on a kernel
 compiled with both CONFIG_PPC_PSERIES=y  CONFIG_PPC_POWERNV=y.

 Changes from v4:
 1. Added a patch for y2038-safe code changes

 ---

 Hari Bathini (4):
   powerpc/nvram: move generic code for nvram and pstore
   pstore: Add pstore type id for PPC64 opal nvram partition
   pstore: add pstore support on powernv
   powerpc: make timestamp related code y2038-safe

Thanks! I skimmed this, and it looks good to me.

Reviewed-by: Kees Cook keesc...@chromium.org

-Kees



  arch/powerpc/include/asm/nvram.h|   50 ++
  arch/powerpc/include/asm/rtas.h |5
  arch/powerpc/kernel/nvram_64.c  |  677 
 +++
  arch/powerpc/platforms/powernv/opal-nvram.c |   10
  arch/powerpc/platforms/pseries/nvram.c  |  673 
 ---
  fs/pstore/inode.c   |3
  include/linux/pstore.h  |1
  7 files changed, 754 insertions(+), 665 deletions(-)

 --
 -Hari




-- 
Kees Cook
Chrome OS Security
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [RFC 00/10] Freescale DPAA B/QMan drivers

2015-02-05 Thread Dan Carpenter
Normally, for staging drivers we just require the TODO and a maintainer
and we merge things as-is.  There isn't really much review of the code.

regards,
dan carpenter

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

Re: [PATCH v4 1/3] powerpc/nvram: move generic code for nvram and pstore

2015-02-05 Thread Hari Bathini

On 01/30/2015 10:12 PM, Arnd Bergmann wrote:

On Friday 30 January 2015 20:44:00 Hari Bathini wrote:

With minor checks, we can move most of the code for nvram
under pseries to a common place to be re-used by other
powerpc platforms like powernv. This patch moves such
common code to arch/powerpc/kernel/nvram_64.c file.

Signed-off-by: Hari Bathini hbath...@linux.vnet.ibm.com

Can you make this y2038-safe in the process, possibly as a
follow-up patch?


Arnd, sorry for the delayed response.
I will add these changes to this patch-set and re-spin..

Thanks
Hari


+extern unsigned long last_rtas_event;

time64_t


+   }
+   oops_hdr-version = cpu_to_be16(OOPS_HDR_VERSION);
+   oops_hdr-report_length = cpu_to_be16(zipped_len);
+   oops_hdr-timestamp = cpu_to_be64(get_seconds());
+   return 0;

ktime_get_real_seconds()


+static ssize_t nvram_pstore_read(u64 *id, enum pstore_type_id *type,
+   int *count, struct timespec *time, char **buf,
+   bool *compressed, struct pstore_info *psi)

This has to remain timespec for now but can later be changed to timespec64
when the API gets changed.


+   oops_hdr-version = cpu_to_be16(OOPS_HDR_VERSION);
+   oops_hdr-report_length = cpu_to_be16(text_len);
+   oops_hdr-timestamp = cpu_to_be64(get_seconds());

ktime_get_real_seconds()

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


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

Re: [PATCH] i2c/mpc: Fix ISR return value

2015-02-05 Thread Wolfram Sang
On Fri, Jan 30, 2015 at 10:24:10AM +, Amit Tomar wrote:
 ISR should not return IRQ_HANDLED for not handling anything. 
 This patch fixes the return value of ISR for the same case.
 
 
 Signed-off-by: Amit Singh Tomar amit.to...@freescale.com

I can't apply the patch. There seem to be whitespace problems. Please
fix the patch or your mail sending.


 ---
 drivers/i2c/busses/i2c-mpc.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
 
 diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c 
 index 0edf630..7a3136f 100644
 --- a/drivers/i2c/busses/i2c-mpc.c
 +++ b/drivers/i2c/busses/i2c-mpc.c
 @@ -95,8 +95,9 @@ static irqreturn_t mpc_i2c_isr(int irq, void *dev_id)
     i2c-interrupt = readb(i2c-base + MPC_I2C_SR);
     writeb(0, i2c-base + MPC_I2C_SR);
     wake_up(i2c-queue);
 +       return IRQ_HANDLED;
     }
 -  return IRQ_HANDLED;
 +  return IRQ_NONE;
 }
 
 /* Sometimes 9th clock pulse isn't generated, and slave doesn't release
 --
 1.7.9.5
  
 --
 To unsubscribe from this list: send the line unsubscribe linux-i2c in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

[PATCH v5 2/4] pstore: Add pstore type id for PPC64 opal nvram partition

2015-02-05 Thread Hari Bathini
This patch adds a new PPC64 partition type to be used for opal
specific nvram partition. A new partition type is needed as none
of the existing type matches this partition type.

Signed-off-by: Hari Bathini hbath...@linux.vnet.ibm.com
---
 fs/pstore/inode.c  |3 +++
 include/linux/pstore.h |1 +
 2 files changed, 4 insertions(+)

diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c
index 5041660..8e0c009 100644
--- a/fs/pstore/inode.c
+++ b/fs/pstore/inode.c
@@ -359,6 +359,9 @@ int pstore_mkfile(enum pstore_type_id type, char *psname, 
u64 id, int count,
case PSTORE_TYPE_PPC_COMMON:
sprintf(name, powerpc-common-%s-%lld, psname, id);
break;
+   case PSTORE_TYPE_PPC_OPAL:
+   sprintf(name, powerpc-opal-%s-%lld, psname, id);
+   break;
case PSTORE_TYPE_UNKNOWN:
sprintf(name, unknown-%s-%lld, psname, id);
break;
diff --git a/include/linux/pstore.h b/include/linux/pstore.h
index ece0c6b..af44980 100644
--- a/include/linux/pstore.h
+++ b/include/linux/pstore.h
@@ -39,6 +39,7 @@ enum pstore_type_id {
PSTORE_TYPE_PPC_RTAS= 4,
PSTORE_TYPE_PPC_OF  = 5,
PSTORE_TYPE_PPC_COMMON  = 6,
+   PSTORE_TYPE_PPC_OPAL= 7,
PSTORE_TYPE_UNKNOWN = 255
 };
 

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

[PATCH v5 4/4] powerpc: make timestamp related code y2038-safe

2015-02-05 Thread Hari Bathini
While we are here, let us make timestamp related code
y2038-safe.

Suggested-by: Arnd Bergmann a...@arndb.de
Signed-off-by: Hari Bathini hbath...@linux.vnet.ibm.com
---
 arch/powerpc/include/asm/rtas.h|3 ++-
 arch/powerpc/kernel/nvram_64.c |6 +++---
 arch/powerpc/platforms/pseries/nvram.c |   10 +-
 3 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/arch/powerpc/include/asm/rtas.h b/arch/powerpc/include/asm/rtas.h
index 123d7ff..efa9152 100644
--- a/arch/powerpc/include/asm/rtas.h
+++ b/arch/powerpc/include/asm/rtas.h
@@ -4,6 +4,7 @@
 
 #include linux/spinlock.h
 #include asm/page.h
+#include linux/time.h
 
 /*
  * Definitions for talking to the RTAS on CHRP machines.
@@ -343,7 +344,7 @@ extern int early_init_dt_scan_rtas(unsigned long node,
 extern void pSeries_log_error(char *buf, unsigned int err_type, int fatal);
 
 #ifdef CONFIG_PPC_PSERIES
-extern unsigned long last_rtas_event;
+extern time64_t last_rtas_event;
 extern int clobbering_unread_rtas_event(void);
 extern int pseries_devicetree_update(s32 scope);
 extern void post_mobility_fixup(void);
diff --git a/arch/powerpc/kernel/nvram_64.c b/arch/powerpc/kernel/nvram_64.c
index 293da88..1e703f8 100644
--- a/arch/powerpc/kernel/nvram_64.c
+++ b/arch/powerpc/kernel/nvram_64.c
@@ -376,7 +376,7 @@ static int zip_oops(size_t text_len)
}
oops_hdr-version = cpu_to_be16(OOPS_HDR_VERSION);
oops_hdr-report_length = cpu_to_be16(zipped_len);
-   oops_hdr-timestamp = cpu_to_be64(get_seconds());
+   oops_hdr-timestamp = cpu_to_be64(ktime_get_real_seconds());
return 0;
 }
 
@@ -423,7 +423,7 @@ static int nvram_pstore_write(enum pstore_type_id type,
 
oops_hdr-version = cpu_to_be16(OOPS_HDR_VERSION);
oops_hdr-report_length = cpu_to_be16(size);
-   oops_hdr-timestamp = cpu_to_be64(get_seconds());
+   oops_hdr-timestamp = cpu_to_be64(ktime_get_real_seconds());
 
if (compressed)
err_type = ERR_TYPE_KERNEL_PANIC_GZ;
@@ -721,7 +721,7 @@ static void oops_to_nvram(struct kmsg_dumper *dumper,
err_type = ERR_TYPE_KERNEL_PANIC;
oops_hdr-version = cpu_to_be16(OOPS_HDR_VERSION);
oops_hdr-report_length = cpu_to_be16(text_len);
-   oops_hdr-timestamp = cpu_to_be64(get_seconds());
+   oops_hdr-timestamp = cpu_to_be64(ktime_get_real_seconds());
}
 
(void) nvram_write_os_partition(oops_log_partition, oops_buf,
diff --git a/arch/powerpc/platforms/pseries/nvram.c 
b/arch/powerpc/platforms/pseries/nvram.c
index 97b8fc6..d77713b 100644
--- a/arch/powerpc/platforms/pseries/nvram.c
+++ b/arch/powerpc/platforms/pseries/nvram.c
@@ -37,10 +37,10 @@ static DEFINE_SPINLOCK(nvram_lock);
 
 /* See clobbering_unread_rtas_event() */
 #define NVRAM_RTAS_READ_TIMEOUT 5  /* seconds */
-static unsigned long last_unread_rtas_event;   /* timestamp */
+static time64_t last_unread_rtas_event;/* timestamp */
 
 #ifdef CONFIG_PSTORE
-unsigned long last_rtas_event;
+time64_t last_rtas_event;
 #endif
 
 static ssize_t pSeries_nvram_read(char *buf, size_t count, loff_t *index)
@@ -145,9 +145,9 @@ int nvram_write_error_log(char * buff, int length,
int rc = nvram_write_os_partition(rtas_log_partition, buff, length,
err_type, error_log_cnt);
if (!rc) {
-   last_unread_rtas_event = get_seconds();
+   last_unread_rtas_event = ktime_get_real_seconds();
 #ifdef CONFIG_PSTORE
-   last_rtas_event = get_seconds();
+   last_rtas_event = ktime_get_real_seconds();
 #endif
}
 
@@ -201,7 +201,7 @@ int clobbering_unread_rtas_event(void)
 {
return (oops_log_partition.index == rtas_log_partition.index
 last_unread_rtas_event
-get_seconds() - last_unread_rtas_event =
+ktime_get_real_seconds() - last_unread_rtas_event =
NVRAM_RTAS_READ_TIMEOUT);
 }
 

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

[PATCH v5 0/4] powerpc/pstore: Add pstore support for nvram partitions

2015-02-05 Thread Hari Bathini
This patch series adds pstore support on powernv platform to
read different nvram partitions and write compressed data to
oops-log nvram partition. As pseries platform already has
pstore support, this series moves most of the common code
for pseries and powernv platforms to a common file. Tested
the patches successfully on both pseries and powernv
platforms. Also, tested the patches successfully, on a kernel
compiled with both CONFIG_PPC_PSERIES=y  CONFIG_PPC_POWERNV=y.

Changes from v4:
1. Added a patch for y2038-safe code changes

---

Hari Bathini (4):
  powerpc/nvram: move generic code for nvram and pstore
  pstore: Add pstore type id for PPC64 opal nvram partition
  pstore: add pstore support on powernv
  powerpc: make timestamp related code y2038-safe


 arch/powerpc/include/asm/nvram.h|   50 ++
 arch/powerpc/include/asm/rtas.h |5 
 arch/powerpc/kernel/nvram_64.c  |  677 +++
 arch/powerpc/platforms/powernv/opal-nvram.c |   10 
 arch/powerpc/platforms/pseries/nvram.c  |  673 ---
 fs/pstore/inode.c   |3 
 include/linux/pstore.h  |1 
 7 files changed, 754 insertions(+), 665 deletions(-)

--
-Hari

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

[PATCH v5 1/4] powerpc/nvram: move generic code for nvram and pstore

2015-02-05 Thread Hari Bathini
With minor checks, we can move most of the code for nvram
under pseries to a common place to be re-used by other
powerpc platforms like powernv. This patch moves such
common code to arch/powerpc/kernel/nvram_64.c file.

Signed-off-by: Hari Bathini hbath...@linux.vnet.ibm.com
---
 arch/powerpc/include/asm/nvram.h   |   50 ++
 arch/powerpc/include/asm/rtas.h|4 
 arch/powerpc/kernel/nvram_64.c |  656 
 arch/powerpc/platforms/pseries/nvram.c |  665 
 4 files changed, 714 insertions(+), 661 deletions(-)

diff --git a/arch/powerpc/include/asm/nvram.h b/arch/powerpc/include/asm/nvram.h
index b0fe0fe..09a518b 100644
--- a/arch/powerpc/include/asm/nvram.h
+++ b/arch/powerpc/include/asm/nvram.h
@@ -9,12 +9,43 @@
 #ifndef _ASM_POWERPC_NVRAM_H
 #define _ASM_POWERPC_NVRAM_H
 
-
+#include linux/types.h
 #include linux/errno.h
 #include linux/list.h
 #include uapi/asm/nvram.h
 
+/*
+ * Set oops header version to distinguish between old and new format header.
+ * lnx,oops-log partition max size is 4000, header version  4000 will
+ * help in identifying new header.
+ */
+#define OOPS_HDR_VERSION 5000
+
+struct err_log_info {
+   __be32 error_type;
+   __be32 seq_num;
+};
+
+struct nvram_os_partition {
+   const char *name;
+   int req_size;   /* desired size, in bytes */
+   int min_size;   /* minimum acceptable size (0 means req_size) */
+   long size;  /* size of data portion (excluding err_log_info) */
+   long index; /* offset of data portion of partition */
+   bool os_partition; /* partition initialized by OS, not FW */
+};
+
+struct oops_log_info {
+   __be16 version;
+   __be16 report_length;
+   __be64 timestamp;
+} __attribute__((packed));
+
+extern struct nvram_os_partition oops_log_partition;
+
 #ifdef CONFIG_PPC_PSERIES
+extern struct nvram_os_partition rtas_log_partition;
+
 extern int nvram_write_error_log(char * buff, int length,
 unsigned int err_type, unsigned int 
err_seq);
 extern int nvram_read_error_log(char * buff, int length,
@@ -50,6 +81,23 @@ extern void  pmac_xpram_write(int xpaddr, u8 data);
 /* Synchronize NVRAM */
 extern voidnvram_sync(void);
 
+/* Initialize NVRAM OS partition */
+extern int __init nvram_init_os_partition(struct nvram_os_partition *part);
+
+/* Initialize NVRAM oops partition */
+extern void __init nvram_init_oops_partition(int rtas_partition_exists);
+
+/* Read a NVRAM partition */
+extern int nvram_read_partition(struct nvram_os_partition *part, char *buff,
+   int length, unsigned int *err_type,
+   unsigned int *error_log_cnt);
+
+/* Write to NVRAM OS partition */
+extern int nvram_write_os_partition(struct nvram_os_partition *part,
+   char *buff, int length,
+   unsigned int err_type,
+   unsigned int error_log_cnt);
+
 /* Determine NVRAM size */
 extern ssize_t nvram_get_size(void);
 
diff --git a/arch/powerpc/include/asm/rtas.h b/arch/powerpc/include/asm/rtas.h
index b390f55..123d7ff 100644
--- a/arch/powerpc/include/asm/rtas.h
+++ b/arch/powerpc/include/asm/rtas.h
@@ -343,8 +343,12 @@ extern int early_init_dt_scan_rtas(unsigned long node,
 extern void pSeries_log_error(char *buf, unsigned int err_type, int fatal);
 
 #ifdef CONFIG_PPC_PSERIES
+extern unsigned long last_rtas_event;
+extern int clobbering_unread_rtas_event(void);
 extern int pseries_devicetree_update(s32 scope);
 extern void post_mobility_fixup(void);
+#else
+static inline int clobbering_unread_rtas_event(void) { return 0; }
 #endif
 
 #ifdef CONFIG_PPC_RTAS_DAEMON
diff --git a/arch/powerpc/kernel/nvram_64.c b/arch/powerpc/kernel/nvram_64.c
index 34f7c9b..42e5c6a 100644
--- a/arch/powerpc/kernel/nvram_64.c
+++ b/arch/powerpc/kernel/nvram_64.c
@@ -26,6 +26,9 @@
 #include linux/init.h
 #include linux/slab.h
 #include linux/spinlock.h
+#include linux/kmsg_dump.h
+#include linux/pstore.h
+#include linux/zlib.h
 #include asm/uaccess.h
 #include asm/nvram.h
 #include asm/rtas.h
@@ -54,6 +57,659 @@ struct nvram_partition {
 
 static LIST_HEAD(nvram_partitions);
 
+#ifdef CONFIG_PPC_PSERIES
+struct nvram_os_partition rtas_log_partition = {
+   .name = ibm,rtas-log,
+   .req_size = 2079,
+   .min_size = 1055,
+   .index = -1,
+   .os_partition = true
+};
+#endif
+
+struct nvram_os_partition oops_log_partition = {
+   .name = lnx,oops-log,
+   .req_size = 4000,
+   .min_size = 2000,
+   .index = -1,
+   .os_partition = true
+};
+
+static const char *nvram_os_partitions[] = {
+#ifdef CONFIG_PPC_PSERIES
+   ibm,rtas-log,
+#endif
+   lnx,oops-log,
+   NULL
+};
+
+static void oops_to_nvram(struct kmsg_dumper *dumper,
+ enum kmsg_dump_reason reason);
+
+static struct kmsg_dumper nvram_kmsg_dumper = {
+   

[PATCH v5 3/4] pstore: add pstore support on powernv

2015-02-05 Thread Hari Bathini
This patch extends pstore, a generic interface to platform dependent
persistent storage, support for powernv  platform to capture certain
useful information, during dying moments. Such support is already in
place for  pseries platform. This patch re-uses most of that code.

It is a common practice to compile kernels with both CONFIG_PPC_PSERIES=y
and CONFIG_PPC_POWERNV=y. The code in nvram_init_oops_partition() routine
still works as intended, as the caller is platform specific code which
passes the appropriate value for rtas_partition_exists parameter.
In all other places, where CONFIG_PPC_PSERIES or CONFIG_PPC_POWERNV
flag is used in this patchset, it is to reduce the kernel size in cases
where this flag is not set and doesn't have any impact logic wise.

Signed-off-by: Hari Bathini hbath...@linux.vnet.ibm.com
---
 arch/powerpc/kernel/nvram_64.c  |   25 +++--
 arch/powerpc/platforms/powernv/opal-nvram.c |   10 ++
 2 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/nvram_64.c b/arch/powerpc/kernel/nvram_64.c
index 42e5c6a..293da88 100644
--- a/arch/powerpc/kernel/nvram_64.c
+++ b/arch/powerpc/kernel/nvram_64.c
@@ -127,6 +127,14 @@ static size_t oops_data_sz;
 static struct z_stream_s stream;
 
 #ifdef CONFIG_PSTORE
+#ifdef CONFIG_PPC_POWERNV
+static struct nvram_os_partition skiboot_partition = {
+   .name = ibm,skiboot,
+   .index = -1,
+   .os_partition = false
+};
+#endif
+
 #ifdef CONFIG_PPC_PSERIES
 static struct nvram_os_partition of_config_partition = {
.name = of-config,
@@ -477,6 +485,16 @@ static ssize_t nvram_pstore_read(u64 *id, enum 
pstore_type_id *type,
time-tv_nsec = 0;
break;
 #endif
+#ifdef CONFIG_PPC_POWERNV
+   case PSTORE_TYPE_PPC_OPAL:
+   sig = NVRAM_SIG_FW;
+   part = skiboot_partition;
+   *type = PSTORE_TYPE_PPC_OPAL;
+   *id = PSTORE_TYPE_PPC_OPAL;
+   time-tv_sec = 0;
+   time-tv_nsec = 0;
+   break;
+#endif
default:
return 0;
}
@@ -552,8 +570,11 @@ static int nvram_pstore_init(void)
 {
int rc = 0;
 
-   nvram_type_ids[2] = PSTORE_TYPE_PPC_RTAS;
-   nvram_type_ids[3] = PSTORE_TYPE_PPC_OF;
+   if (machine_is(pseries)) {
+   nvram_type_ids[2] = PSTORE_TYPE_PPC_RTAS;
+   nvram_type_ids[3] = PSTORE_TYPE_PPC_OF;
+   } else
+   nvram_type_ids[2] = PSTORE_TYPE_PPC_OPAL;
 
nvram_pstore_info.buf = oops_data;
nvram_pstore_info.bufsize = oops_data_sz;
diff --git a/arch/powerpc/platforms/powernv/opal-nvram.c 
b/arch/powerpc/platforms/powernv/opal-nvram.c
index f9896fd..9db4398 100644
--- a/arch/powerpc/platforms/powernv/opal-nvram.c
+++ b/arch/powerpc/platforms/powernv/opal-nvram.c
@@ -16,6 +16,7 @@
 #include linux/of.h
 
 #include asm/opal.h
+#include asm/nvram.h
 #include asm/machdep.h
 
 static unsigned int nvram_size;
@@ -62,6 +63,15 @@ static ssize_t opal_nvram_write(char *buf, size_t count, 
loff_t *index)
return count;
 }
 
+static int __init opal_nvram_init_log_partitions(void)
+{
+   /* Scan nvram for partitions */
+   nvram_scan_partitions();
+   nvram_init_oops_partition(0);
+   return 0;
+}
+machine_arch_initcall(powernv, opal_nvram_init_log_partitions);
+
 void __init opal_nvram_init(void)
 {
struct device_node *np;

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