[RFC PATCH 4/4] powerpc/pseries: Display machine check error details.

2018-06-05 Thread Mahesh J Salgaonkar
From: Mahesh Salgaonkar 

Extract the MCE eror details from RTAS extended log and display it to
console.

With this patch you should now see mce logs like below:

[  822.711745] Severe Machine check interrupt [Recovered]
[  822.711746]   Initiator: CPU
[  822.711747]   Error type: SLB [Multihit]
[  822.711747] Effective address: dc66

Signed-off-by: Mahesh Salgaonkar 
---
 arch/powerpc/include/asm/rtas.h  |5 +
 arch/powerpc/platforms/pseries/ras.c |  116 ++
 2 files changed, 121 insertions(+)

diff --git a/arch/powerpc/include/asm/rtas.h b/arch/powerpc/include/asm/rtas.h
index 3f2fba7ef23b..8100a95c133a 100644
--- a/arch/powerpc/include/asm/rtas.h
+++ b/arch/powerpc/include/asm/rtas.h
@@ -190,6 +190,11 @@ static inline uint8_t rtas_error_extended(const struct 
rtas_error_log *elog)
return (elog->byte1 & 0x04) >> 2;
 }
 
+static inline uint8_t rtas_error_initiator(const struct rtas_error_log *elog)
+{
+   return (elog->byte2 & 0xf0) >> 4;
+}
+
 #define rtas_error_type(x) ((x)->byte3)
 
 static inline
diff --git a/arch/powerpc/platforms/pseries/ras.c 
b/arch/powerpc/platforms/pseries/ras.c
index 7470a216cd6b..09a172bb6fdb 100644
--- a/arch/powerpc/platforms/pseries/ras.c
+++ b/arch/powerpc/platforms/pseries/ras.c
@@ -422,6 +422,121 @@ int pSeries_system_reset_exception(struct pt_regs *regs)
return 0; /* need to perform reset */
 }
 
+#define VAL_TO_STRING(ar, val) ((val < ARRAY_SIZE(ar)) ? ar[val] : "Unknown")
+
+static void pseries_print_mce_info(struct rtas_error_log *errp, int 
disposition)
+{
+   const char *level, *sevstr;
+   struct pseries_errorlog *pseries_log;
+   struct pseries_mc_errorlog *mce_log;
+   uint8_t error_type, err_sub_type;
+   uint8_t initiator = rtas_error_initiator(errp);
+   uint64_t addr;
+
+   static const char * const initiators[] = {
+   "Unknown",
+   "CPU",
+   "PCI",
+   "ISA",
+   "Memory",
+   "Power Mgmt",
+   };
+   static const char * const mc_err_types[] = {
+   "UE",
+   "SLB",
+   "ERAT",
+   "TLB",
+   "D-Cache",
+   "Unknown",
+   "I-Cache",
+   };
+   static const char * const mc_ue_types[] = {
+   "Indeterminate",
+   "Instruction fetch",
+   "Page table walk ifetch",
+   "Load/Store",
+   "Page table walk Load/Store",
+   };
+
+   /* SLB sub errors valid values are 0x0, 0x1, 0x2 */
+   static const char * const mc_slb_types[] = {
+   "Parity",
+   "Multihit",
+   "Indeterminate",
+   };
+
+   /* TLB and ERAT sub errors valid values are 0x1, 0x2, 0x3 */
+   static const char * const mc_soft_types[] = {
+   "Unknown",
+   "Parity",
+   "Multihit",
+   "Indeterminate",
+   };
+
+   pseries_log = get_pseries_errorlog(errp, PSERIES_ELOG_SECT_ID_MCE);
+   if (pseries_log == NULL)
+   return;
+
+   mce_log = (struct pseries_mc_errorlog *)pseries_log->data;
+
+   error_type = rtas_mc_error_type(mce_log);
+   err_sub_type = rtas_mc_error_sub_type(mce_log);
+
+   switch (rtas_error_severity(errp)) {
+   case RTAS_SEVERITY_NO_ERROR:
+   level = KERN_INFO;
+   sevstr = "Harmless";
+   break;
+   case RTAS_SEVERITY_WARNING:
+   level = KERN_WARNING;
+   sevstr = "";
+   break;
+   case RTAS_SEVERITY_ERROR:
+   case RTAS_SEVERITY_ERROR_SYNC:
+   level = KERN_ERR;
+   sevstr = "Severe";
+   break;
+   case RTAS_SEVERITY_FATAL:
+   default:
+   level = KERN_ERR;
+   sevstr = "Fatal";
+   break;
+   }
+
+   printk("%s%s Machine check interrupt [%s]\n", level, sevstr,
+   disposition == RTAS_DISP_FULLY_RECOVERED ?
+   "Recovered" : "Not recovered");
+   printk("%s  Initiator: %s\n", level,
+   VAL_TO_STRING(initiators, initiator));
+
+   switch (error_type) {
+   case PSERIES_MC_ERROR_TYPE_UE:
+   printk("%s  Error type: %s [%s]\n", level,
+   VAL_TO_STRING(mc_err_types, error_type),
+   VAL_TO_STRING(mc_ue_types, err_sub_type));
+   break;
+   case PSERIES_MC_ERROR_TYPE_SLB:
+   printk("%s  Error type: %s [%s]\n", level,
+   VAL_TO_STRING(mc_err_types, error_type),
+   VAL_TO_STRING(mc_slb_types, err_sub_type));
+   break;
+   case PSERIES_MC_ERROR_TYPE_ERAT:
+   case PSERIES_MC_ERROR_TYPE_TLB:
+   printk("%s  Error type: %s [%s]\n", level,
+   VAL_TO_STRING(mc_err_types, error_type),
+  

[RFC PATCH 3/4] powerpc/pseries: Dump and flush SLB contents on SLB MCE errors.

2018-06-05 Thread Mahesh J Salgaonkar
From: Mahesh Salgaonkar 

If we get a machine check exceptions due to SLB errors then dump the
current SLB contents which will be very much helpful in debugging the
root cause of SLB errors. On pseries, as of today system crashes on SLB
errors. These are soft errors and can be fixed by flushing the SLBs so
the kernel can continue to function instead of system crash. This patch
fixes that also.

With this patch the console will log SLB contents like below on SLB MCE
errors:

[  822.711728] slb contents:
[  822.711730] 00 c800 400ea1b217000500
[  822.711731]   1T  ESID=   c0  VSID=  ea1b217 LLP:100
[  822.711732] 01 d800 400d43642f000510
[  822.711733]   1T  ESID=   d0  VSID=  d43642f LLP:110
[  822.711734] 09 f800 400a86c85f000500
[  822.711736]   1T  ESID=   f0  VSID=  a86c85f LLP:100
[  822.711737] 10 7f000800 400d1f26e3000d90
[  822.711738]   1T  ESID=   7f  VSID=  d1f26e3 LLP:110
[  822.711739] 11 1800 000e3615f520fd90
[  822.711740]  256M ESID=1  VSID=   e3615f520f LLP:110
[  822.711740] 12 d800 400d43642f000510
[  822.711741]   1T  ESID=   d0  VSID=  d43642f LLP:110
[  822.711742] 13 d800 400d43642f000510
[  822.711743]   1T  ESID=   d0  VSID=  d43642f LLP:110


Suggested-by: Aneesh Kumar K.V 
Suggested-by: Michael Ellerman 
Signed-off-by: Mahesh Salgaonkar 
---
 arch/powerpc/include/asm/book3s/64/mmu-hash.h |1 +
 arch/powerpc/mm/slb.c |   35 +
 arch/powerpc/platforms/pseries/ras.c  |   29 -
 3 files changed, 64 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/include/asm/book3s/64/mmu-hash.h 
b/arch/powerpc/include/asm/book3s/64/mmu-hash.h
index 50ed64fba4ae..c0da68927235 100644
--- a/arch/powerpc/include/asm/book3s/64/mmu-hash.h
+++ b/arch/powerpc/include/asm/book3s/64/mmu-hash.h
@@ -487,6 +487,7 @@ extern void hpte_init_native(void);
 
 extern void slb_initialize(void);
 extern void slb_flush_and_rebolt(void);
+extern void slb_dump_contents(void);
 
 extern void slb_vmalloc_update(void);
 extern void slb_set_size(u16 size);
diff --git a/arch/powerpc/mm/slb.c b/arch/powerpc/mm/slb.c
index 66577cc66dc9..799aa117cec3 100644
--- a/arch/powerpc/mm/slb.c
+++ b/arch/powerpc/mm/slb.c
@@ -145,6 +145,41 @@ void slb_flush_and_rebolt(void)
get_paca()->slb_cache_ptr = 0;
 }
 
+void slb_dump_contents(void)
+{
+   int i;
+   unsigned long e, v;
+   unsigned long llp;
+
+   pr_err("slb contents:\n");
+   for (i = 0; i < mmu_slb_size; i++) {
+   asm volatile("slbmfee  %0,%1" : "=r" (e) : "r" (i));
+   asm volatile("slbmfev  %0,%1" : "=r" (v) : "r" (i));
+
+   if (!e && !v)
+   continue;
+
+   pr_err("%02d %016lx %016lx", i, e, v);
+
+   if (!(e & SLB_ESID_V)) {
+   pr_err("\n");
+   continue;
+   }
+   llp = v & SLB_VSID_LLP;
+   if (v & SLB_VSID_B_1T) {
+   pr_err("  1T  ESID=%9lx  VSID=%13lx LLP:%3lx\n",
+   GET_ESID_1T(e),
+   (v & ~SLB_VSID_B) >> SLB_VSID_SHIFT_1T,
+   llp);
+   } else {
+   pr_err(" 256M ESID=%9lx  VSID=%13lx LLP:%3lx\n",
+   GET_ESID(e),
+   (v & ~SLB_VSID_B) >> SLB_VSID_SHIFT,
+   llp);
+   }
+   }
+}
+
 void slb_vmalloc_update(void)
 {
unsigned long vflags;
diff --git a/arch/powerpc/platforms/pseries/ras.c 
b/arch/powerpc/platforms/pseries/ras.c
index 5e1ef9150182..7470a216cd6b 100644
--- a/arch/powerpc/platforms/pseries/ras.c
+++ b/arch/powerpc/platforms/pseries/ras.c
@@ -422,6 +422,31 @@ int pSeries_system_reset_exception(struct pt_regs *regs)
return 0; /* need to perform reset */
 }
 
+static int mce_handle_error(struct rtas_error_log *errp)
+{
+   struct pseries_errorlog *pseries_log;
+   struct pseries_mc_errorlog *mce_log;
+   int disposition = rtas_error_disposition(errp);
+   uint8_t error_type;
+
+   pseries_log = get_pseries_errorlog(errp, PSERIES_ELOG_SECT_ID_MCE);
+   if (pseries_log == NULL)
+   goto out;
+
+   mce_log = (struct pseries_mc_errorlog *)pseries_log->data;
+   error_type = rtas_mc_error_type(mce_log);
+
+   if ((disposition == RTAS_DISP_NOT_RECOVERED) &&
+   (error_type == PSERIES_MC_ERROR_TYPE_SLB)) {
+   slb_dump_contents();
+   slb_flush_and_rebolt();
+   disposition = RTAS_DISP_FULLY_RECOVERED;
+   }
+
+out:
+   return disposition;
+}
+
 /*
  * See if we can recover from a machine check exception.
  * This is only called on power4 (or above) and only via
@@ -434,7 +459,9 @@ int 

[RFC PATCH 2/4] powerpc/pseries: Define MCE error event section.

2018-06-05 Thread Mahesh J Salgaonkar
From: Mahesh Salgaonkar 

On pseries, the machine check error details are part of RTAS extended
event log passed under Machine check exception section. This patch adds
the definition of rtas MCE event section and related helper
functions.

Signed-off-by: Mahesh Salgaonkar 
---
 arch/powerpc/include/asm/rtas.h |  104 +++
 1 file changed, 104 insertions(+)

diff --git a/arch/powerpc/include/asm/rtas.h b/arch/powerpc/include/asm/rtas.h
index ec9dd79398ee..3f2fba7ef23b 100644
--- a/arch/powerpc/include/asm/rtas.h
+++ b/arch/powerpc/include/asm/rtas.h
@@ -275,6 +275,7 @@ inline uint32_t rtas_ext_event_company_id(struct 
rtas_ext_event_log_v6 *ext_log)
 #define PSERIES_ELOG_SECT_ID_CALL_HOME (('C' << 8) | 'H')
 #define PSERIES_ELOG_SECT_ID_USER_DEF  (('U' << 8) | 'D')
 #define PSERIES_ELOG_SECT_ID_HOTPLUG   (('H' << 8) | 'P')
+#define PSERIES_ELOG_SECT_ID_MCE   (('M' << 8) | 'C')
 
 /* Vendor specific Platform Event Log Format, Version 6, section header */
 struct pseries_errorlog {
@@ -326,6 +327,109 @@ struct pseries_hp_errorlog {
 #define PSERIES_HP_ELOG_ID_DRC_COUNT   3
 #define PSERIES_HP_ELOG_ID_DRC_IC  4
 
+/* RTAS pseries MCE errorlog section */
+#pragma pack(push, 1)
+struct pseries_mc_errorlog {
+   __be32  fru_id;
+   __be32  proc_id;
+   uint8_t error_type;
+   union {
+   struct {
+   uint8_t ue_err_type;
+   /* 
+* X1: Permanent or Transient UE.
+*  X   1: Effective address provided.
+*   X  1: Logical address provided.
+*XX2: Reserved.
+*  XXX 3: Type of UE error.
+*/
+   uint8_t reserved_1[6];
+   __be64  effective_address;
+   __be64  logical_address;
+   } ue_error;
+   struct {
+   uint8_t soft_err_type;
+   /* 
+* X1: Effective address provided.
+*  X   5: Reserved.
+*   XX 2: Type of SLB/ERAT/TLB error.
+*/
+   uint8_t reserved_1[6];
+   __be64  effective_address;
+   uint8_t reserved_2[8];
+   } soft_error;
+   } u;
+};
+#pragma pack(pop)
+
+/* RTAS pseries MCE error types */
+#define PSERIES_MC_ERROR_TYPE_UE   0x00
+#define PSERIES_MC_ERROR_TYPE_SLB  0x01
+#define PSERIES_MC_ERROR_TYPE_ERAT 0x02
+#define PSERIES_MC_ERROR_TYPE_TLB  0x04
+#define PSERIES_MC_ERROR_TYPE_D_CACHE  0x05
+#define PSERIES_MC_ERROR_TYPE_I_CACHE  0x07
+
+/* RTAS pseries MCE error sub types */
+#define PSERIES_MC_ERROR_UE_INDETERMINATE  0
+#define PSERIES_MC_ERROR_UE_IFETCH 1
+#define PSERIES_MC_ERROR_UE_PAGE_TABLE_WALK_IFETCH 2
+#define PSERIES_MC_ERROR_UE_LOAD_STORE 3
+#define PSERIES_MC_ERROR_UE_PAGE_TABLE_WALK_LOAD_STORE 4
+
+#define PSERIES_MC_ERROR_SLB_PARITY0
+#define PSERIES_MC_ERROR_SLB_MULTIHIT  1
+#define PSERIES_MC_ERROR_SLB_INDETERMINATE 2
+
+#define PSERIES_MC_ERROR_ERAT_PARITY   1
+#define PSERIES_MC_ERROR_ERAT_MULTIHIT 2
+#define PSERIES_MC_ERROR_ERAT_INDETERMINATE3
+
+#define PSERIES_MC_ERROR_TLB_PARITY1
+#define PSERIES_MC_ERROR_TLB_MULTIHIT  2
+#define PSERIES_MC_ERROR_TLB_INDETERMINATE 3
+
+static inline uint8_t rtas_mc_error_type(const struct pseries_mc_errorlog 
*mlog)
+{
+   return mlog->error_type;
+}
+
+static inline uint8_t rtas_mc_error_sub_type(
+   const struct pseries_mc_errorlog *mlog)
+{
+   switch (mlog->error_type) {
+   casePSERIES_MC_ERROR_TYPE_UE:
+   return (mlog->u.ue_error.ue_err_type & 0x07);
+   casePSERIES_MC_ERROR_TYPE_SLB:
+   casePSERIES_MC_ERROR_TYPE_ERAT:
+   casePSERIES_MC_ERROR_TYPE_TLB:
+   return (mlog->u.soft_error.soft_err_type & 0x03);
+   default:
+   return 0;
+   }
+}
+
+static inline uint64_t rtas_mc_get_effective_addr(
+   const struct pseries_mc_errorlog *mlog)
+{
+   uint64_t addr = 0;
+
+   switch (mlog->error_type) {
+   casePSERIES_MC_ERROR_TYPE_UE:
+   if (mlog->u.ue_error.ue_err_type & 0x40)
+   addr = mlog->u.ue_error.effective_address;
+   break;
+   casePSERIES_MC_ERROR_TYPE_SLB:
+   casePSERIES_MC_ERROR_TYPE_ERAT:
+   casePSERIES_MC_ERROR_TYPE_TLB:
+   if (mlog->u.soft_error.soft_err_type & 0x80)
+   addr = 

[RFC PATCH 1/4] powerpc/pseries: convert rtas_log_buf to linear allocation.

2018-06-05 Thread Mahesh J Salgaonkar
From: Mahesh Salgaonkar 

rtas_log_buf is a buffer to hold RTAS event data that are communicated
to kernel by hypervisor. This buffer is then used to pass RTAS event
data to user through proc fs. This buffer is allocated from vmalloc
(non-linear mapping) area.

On Machine check interrupt, register r3 points to RTAS extended event
log passed by hypervisor that contains the MCE event. The pseries
machine check handler then logs this error into rtas_log_buf. The
rtas_log_buf is a vmalloc-ed (non-linear) buffer we end up taking up a
page fault (vector 0x300) while accessing it. Since machine check
interrupt handler runs in NMI context we can not afford to take any
page fault. Page faults are not honored in NMI context and causes
kernel panic. This patch fixes this issue by allocating rtas_log_buf
using kmalloc.

Suggested-by: Aneesh Kumar K.V 
Signed-off-by: Mahesh Salgaonkar 
---
 arch/powerpc/kernel/rtasd.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/rtasd.c b/arch/powerpc/kernel/rtasd.c
index f915db93cd42..3957d4ae2ba2 100644
--- a/arch/powerpc/kernel/rtasd.c
+++ b/arch/powerpc/kernel/rtasd.c
@@ -559,7 +559,7 @@ static int __init rtas_event_scan_init(void)
rtas_error_log_max = rtas_get_error_log_max();
rtas_error_log_buffer_max = rtas_error_log_max + sizeof(int);
 
-   rtas_log_buf = vmalloc(rtas_error_log_buffer_max*LOG_NUMBER);
+   rtas_log_buf = kmalloc(rtas_error_log_buffer_max*LOG_NUMBER, 
GFP_KERNEL);
if (!rtas_log_buf) {
printk(KERN_ERR "rtasd: no memory\n");
return -ENOMEM;



[RFC PATCH 0/4] powerpc/pseries: Machien check handler improvements.

2018-06-05 Thread Mahesh J Salgaonkar
This patch series includes some improvement to Machine check handler
for pseries. Patch 1 fixes an issue where machine check handler crashes
kernel while accessing vmalloc-ed buffer while in nmi context.
Patch 3 dumps the SLB contents on SLB MCE errors to improve the debugability.
Patch 4 display's the MCE error details on console.

---

Mahesh Salgaonkar (4):
  powerpc/pseries: convert rtas_log_buf to linear allocation.
  powerpc/pseries: Define MCE error event section.
  powerpc/pseries: Dump and flush SLB contents on SLB MCE errors.
  powerpc/pseries: Display machine check error details.


 arch/powerpc/include/asm/book3s/64/mmu-hash.h |1 
 arch/powerpc/include/asm/rtas.h   |  109 +++
 arch/powerpc/kernel/rtasd.c   |2 
 arch/powerpc/mm/slb.c |   35 ++
 arch/powerpc/platforms/pseries/ras.c  |  145 +
 5 files changed, 290 insertions(+), 2 deletions(-)

--
Signature



[PATCH V2] crypto/nx: Initialize 842 high and normal RxFIFO control registers

2018-06-05 Thread Haren Myneni


NX increments readOffset by FIFO size in receive FIFO control register
when CRB is read. But the index in RxFIFO has to match with the
corresponding entry in FIFO maintained by VAS in kernel. Otherwise NX
may be processing incorrect CRBs and can cause CRB timeout.

VAS FIFO offset is 0 when the receive window is opened during
initialization. When the module is reloaded or in kexec boot, readOffset
in FIFO control register may not match with VAS entry. This patch adds
nx_coproc_init OPAL call to reset readOffset and queued entries in FIFO
control register for both high and normal FIFOs.

Signed-off-by: Haren Myneni 
---
Changlog:
V2: Execute nx_coproc_init OPAL call per NX without depending on
FIFO priority [Stewart Smith]

diff --git a/arch/powerpc/include/asm/opal-api.h 
b/arch/powerpc/include/asm/opal-api.h
index d886a5b..ff61e4b 100644
--- a/arch/powerpc/include/asm/opal-api.h
+++ b/arch/powerpc/include/asm/opal-api.h
@@ -206,7 +206,8 @@
 #define OPAL_NPU_TL_SET161
 #define OPAL_PCI_GET_PBCQ_TUNNEL_BAR   164
 #define OPAL_PCI_SET_PBCQ_TUNNEL_BAR   165
-#define OPAL_LAST  165
+#defineOPAL_NX_COPROC_INIT 167
+#define OPAL_LAST  167
 
 /* Device tree flags */
 
diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm/opal.h
index 7159e1a..d79eb82 100644
--- a/arch/powerpc/include/asm/opal.h
+++ b/arch/powerpc/include/asm/opal.h
@@ -288,6 +288,7 @@ int64_t opal_imc_counters_init(uint32_t type, uint64_t 
address,
 int opal_get_power_shift_ratio(u32 handle, int token, u32 *psr);
 int opal_set_power_shift_ratio(u32 handle, int token, u32 psr);
 int opal_sensor_group_clear(u32 group_hndl, int token);
+int opal_nx_coproc_init(uint32_t chip_id, uint32_t ct);
 
 s64 opal_signal_system_reset(s32 cpu);
 
diff --git a/arch/powerpc/platforms/powernv/opal-wrappers.S 
b/arch/powerpc/platforms/powernv/opal-wrappers.S
index 3da30c2..c7541a9 100644
--- a/arch/powerpc/platforms/powernv/opal-wrappers.S
+++ b/arch/powerpc/platforms/powernv/opal-wrappers.S
@@ -325,3 +325,4 @@ OPAL_CALL(opal_npu_spa_clear_cache, 
OPAL_NPU_SPA_CLEAR_CACHE);
 OPAL_CALL(opal_npu_tl_set, OPAL_NPU_TL_SET);
 OPAL_CALL(opal_pci_get_pbcq_tunnel_bar,
OPAL_PCI_GET_PBCQ_TUNNEL_BAR);
 OPAL_CALL(opal_pci_set_pbcq_tunnel_bar,
OPAL_PCI_SET_PBCQ_TUNNEL_BAR);
+OPAL_CALL(opal_nx_coproc_init, OPAL_NX_COPROC_INIT);
diff --git a/arch/powerpc/platforms/powernv/opal.c 
b/arch/powerpc/platforms/powernv/opal.c
index 48fbb41..5e13908 100644
--- a/arch/powerpc/platforms/powernv/opal.c
+++ b/arch/powerpc/platforms/powernv/opal.c
@@ -1035,3 +1035,5 @@ void powernv_set_nmmu_ptcr(unsigned long ptcr)
 EXPORT_SYMBOL_GPL(opal_int_set_mfrr);
 EXPORT_SYMBOL_GPL(opal_int_eoi);
 EXPORT_SYMBOL_GPL(opal_error_code);
+/* Export the below symbol for NX compression */
+EXPORT_SYMBOL(opal_nx_coproc_init);
diff --git a/drivers/crypto/nx/nx-842-powernv.c 
b/drivers/crypto/nx/nx-842-powernv.c
index 1e87637..435396b 100644
--- a/drivers/crypto/nx/nx-842-powernv.c
+++ b/drivers/crypto/nx/nx-842-powernv.c
@@ -24,6 +24,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Dan Streetman ");
@@ -753,7 +755,7 @@ static int nx842_open_percpu_txwins(void)
 }
 
 static int __init vas_cfg_coproc_info(struct device_node *dn, int chip_id,
-   int vasid)
+   int vasid, int *ct)
 {
struct vas_window *rxwin = NULL;
struct vas_rx_win_attr rxattr;
@@ -837,6 +839,15 @@ static int __init vas_cfg_coproc_info(struct device_node 
*dn, int chip_id,
coproc->vas.id = vasid;
nx842_add_coprocs_list(coproc, chip_id);
 
+   /*
+* (lpid, pid, tid) combination has to be unique for each
+* coprocessor instance in the system. So to make it
+* unique, skiboot uses coprocessor type such as 842 or
+* GZIP for pid and provides this value to kernel in pid
+* device-tree property.
+*/
+   *ct = pid;
+
return 0;
 
 err_out:
@@ -848,7 +859,7 @@ static int __init vas_cfg_coproc_info(struct device_node 
*dn, int chip_id,
 static int __init nx842_powernv_probe_vas(struct device_node *pn)
 {
struct device_node *dn;
-   int chip_id, vasid, ret = 0;
+   int chip_id, vasid, ct, ret = 0;
int nx_fifo_found = 0;
 
chip_id = of_get_ibm_chip_id(pn);
@@ -865,7 +876,7 @@ static int __init nx842_powernv_probe_vas(struct 
device_node *pn)
 
for_each_child_of_node(pn, dn) {
if (of_device_is_compatible(dn, "ibm,p9-nx-842")) {
-   ret = vas_cfg_coproc_info(dn, chip_id, vasid);
+   ret = vas_cfg_coproc_info(dn, chip_id, vasid, );
if (ret) {
of_node_put(dn);

[PATCH] powerpc/64s/radix: Fix missing ptesync in flush_cache_vmap

2018-06-05 Thread Nicholas Piggin
There is a typo in f1cb8f9beb ("powerpc/64s/radix: avoid ptesync after
set_pte and ptep_set_access_flags") config ifdef, which results in the
necessary ptesync not being issued after vmalloc.

This causes random kernel faults in module load, bpf load, anywhere
that vmalloc mappings are used.

After correcting the code, this survives a guest kernel booting
hundreds of times where previously there would be a crash every few
boots (I haven't noticed the crash on host, perhaps due to different
TLB and page table walking behaviour in hardware).

A memory clobber is also added to the flush, just to be sure it won't
be reordered with the pte set or the subsequent mapping access.

Fixes: f1cb8f9beb ("powerpc/64s/radix: avoid ptesync after set_pte and 
ptep_set_access_flags")
Signed-off-by: Nicholas Piggin 
---
This code obviously can't have been tested properly, I'm sorry about
that. I tested with the ptesync and then "tidied up" the patch by
putting it in ifdef, and didn't test the final patch sufficiently :(

 arch/powerpc/include/asm/cacheflush.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/include/asm/cacheflush.h 
b/arch/powerpc/include/asm/cacheflush.h
index e9662648e72d..0d72ec75da63 100644
--- a/arch/powerpc/include/asm/cacheflush.h
+++ b/arch/powerpc/include/asm/cacheflush.h
@@ -23,10 +23,9 @@
 #define flush_cache_range(vma, start, end) do { } while (0)
 #define flush_cache_page(vma, vmaddr, pfn) do { } while (0)
 #define flush_icache_page(vma, page)   do { } while (0)
-#define flush_cache_vmap(start, end)   do { } while (0)
 #define flush_cache_vunmap(start, end) do { } while (0)
 
-#ifdef CONFIG_BOOK3S_64
+#ifdef CONFIG_PPC_BOOK3S_64
 /*
  * Book3s has no ptesync after setting a pte, so without this ptesync it's
  * possible for a kernel virtual mapping access to return a spurious fault
@@ -34,7 +33,7 @@
  * not expect this type of fault. flush_cache_vmap is not exactly the right
  * place to put this, but it seems to work well enough.
  */
-#define flush_cache_vmap(start, end)   do { asm volatile("ptesync"); } 
while (0)
+#define flush_cache_vmap(start, end)   do { asm volatile("ptesync" ::: 
"memory"); } while (0)
 #else
 #define flush_cache_vmap(start, end)   do { } while (0)
 #endif
-- 
2.17.0



Re: [PATCH QEMU] osdep: powerpc64 align memory to allow 2MB radix THP page tables

2018-06-05 Thread David Gibson
On Sun, May 06, 2018 at 05:29:49PM +1000, Nicholas Piggin wrote:
> This allows KVM with the Book3S radix MMU mode to take advantage of
> THP and install larger pages in the partition scope page tables (the
> host translation).
> 
> Signed-off-by: Nicholas Piggin 

I've applied this to my ppc-for-3.0 tree.  It's not strictly within
the code I maintain, but since it only affects ppc, it seems
reasonable to go through my tree.

> ---
>  include/qemu/osdep.h | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
> index 41658060a7..5910682221 100644
> --- a/include/qemu/osdep.h
> +++ b/include/qemu/osdep.h
> @@ -357,7 +357,8 @@ void qemu_anon_ram_free(void *ptr, size_t size);
>  #endif
>  
>  #if defined(__linux__) && \
> -(defined(__x86_64__) || defined(__arm__) || defined(__aarch64__))
> +(defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) \
> + || defined(__powerpc64__))
> /* Use 2 MiB alignment so transparent hugepages can be used by KVM.
>Valgrind does not support alignments larger than 1 MiB,
>therefore we need special code which handles running on Valgrind. */

-- 
David Gibson| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson


signature.asc
Description: PGP signature


Re: Problems building ppc images in v4.14.y and v4.16.y using gcc 7.3.0 / 8.1.0 from kernel.org

2018-06-05 Thread Arnd Bergmann
On Tue, Jun 5, 2018 at 6:06 PM, Guenter Roeck  wrote:
> On Tue, Jun 05, 2018 at 04:31:00PM +0200, Arnd Bergmann wrote:
>> On Tue, Jun 5, 2018 at 3:52 PM, Guenter Roeck  wrote:
>> > Hi Arnd,
>> >
>> > when using the ppc64 compiler from kernel.org, I see the following problems
>> > when trying to compile ppc:allnoconfig in v4.14.y or v4.16.y.
>> >
>> > gcc 7.3.0: Compilation of kernel.cpu.o hangs
>> >
>> > The problem goes away if I apply the following two patches (tested with
>> > 4.16.y)
>> >
>> > 17a2f1ced028 cpu/hotplug: Merge cpuhp_bp_states and cpuhp_ap_states
>> > fcb3029a8d89 cpu/hotplug: Fix unused function warning
>>
>> This is probably the same as
>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84038
>>
>> I thought I had included the fix in my builds.
>>
> Guess not.

I probably had it in one build and then forgot about it when I did a
rebuild of 7.3 :(

I'm still planning to do a new set of gcc-7.3 binaries (or maybe 7.4
if that gets
released soon) and should try to remember doing that.

>>
> I think it may have cached the flags from the other compiler version.
> "make mrproper" prior to "make defconfig" took care of the issue.
>
> However, that doesn't really help - I get lots of
> error: 'sys_spu_create' alias between functions of incompatible types
> error: 'strncpy' output truncated before terminating nul
> if I try to use gcc 8.1.0.
>
> Oh well. I'll try gcc 6.4.0 next.

On the upside, those two errors are just a result of arch/power/*/*.c getting
built with -Werror, they are warnings that gcc-8 introduced that we should
either shut up or fix.

Arnd


Re: Problems building ppc images in v4.14.y and v4.16.y using gcc 7.3.0 / 8.1.0 from kernel.org

2018-06-05 Thread Guenter Roeck
On Tue, Jun 05, 2018 at 04:31:00PM +0200, Arnd Bergmann wrote:
> On Tue, Jun 5, 2018 at 3:52 PM, Guenter Roeck  wrote:
> > Hi Arnd,
> >
> > when using the ppc64 compiler from kernel.org, I see the following problems
> > when trying to compile ppc:allnoconfig in v4.14.y or v4.16.y.
> >
> > gcc 7.3.0: Compilation of kernel.cpu.o hangs
> >
> > The problem goes away if I apply the following two patches (tested with
> > 4.16.y)
> >
> > 17a2f1ced028 cpu/hotplug: Merge cpuhp_bp_states and cpuhp_ap_states
> > fcb3029a8d89 cpu/hotplug: Fix unused function warning
> 
> This is probably the same as
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84038
> 
> I thought I had included the fix in my builds.
> 
Guess not.

> > gcc 8.1.0: Compilation of kernel/cpu.o results in the following error
> >
> > powerpc64-linux-gcc: error: unrecognized command line option '-mno-spe'; did
> > you mean '-fno-see'?
> > powerpc64-linux-gcc: error: unrecognized command line option '-mspe=no'; did
> > you mean '-misel=no'?
> >
> > This problem is also seen with mainline.
> 
> I've seen it, but couldn't figure out what the right fix is. I ended
> up commenting
> out those two lines in my private builds:
> 
> --- a/arch/powerpc/Makefile
> +++ b/arch/powerpc/Makefile
> @@ -215,8 +215,8 @@ KBUILD_CFLAGS += $(call cc-option,-mno-vsx)
> 
>  # No SPE instruction when building kernel
>  # (We use all available options to help semi-broken compilers)
> -KBUILD_CFLAGS += $(call cc-option,-mno-spe)
> -KBUILD_CFLAGS += $(call cc-option,-mspe=no)
> +#KBUILD_CFLAGS += $(call cc-option,-mno-spe)
> +#KBUILD_CFLAGS += $(call cc-option,-mspe=no)
> 
>  # Enable unit-at-a-time mode when possible. It shrinks the
>  # kernel considerably.
> 
> I think there were some changes in how cc-option gets evaluated, maybe
> those rely on something else to be enabled or disabled first?
> 
I think it may have cached the flags from the other compiler version.
"make mrproper" prior to "make defconfig" took care of the issue.

However, that doesn't really help - I get lots of
error: 'sys_spu_create' alias between functions of incompatible types
error: 'strncpy' output truncated before terminating nul
if I try to use gcc 8.1.0.

Oh well. I'll try gcc 6.4.0 next.

Thanks,
Guenter


Re: [-next] ocxl: Fix missing unlock on error in afu_ioctl_enable_p9_wait()

2018-06-05 Thread Michael Ellerman
On Tue, 2018-06-05 at 09:16:21 UTC, Wei Yongjun wrote:
> Add the missing unlock before return from function
> afu_ioctl_enable_p9_wait() in the error handling case.
> 
> Fixes: e948e06fc63a ("ocxl: Expose the thread_id needed for wait on POWER9")
> Signed-off-by: Wei Yongjun 
> Reviewed-by: Alastair D'Silva 

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/2e5c93d6bb2f7bc17eb82748943a1b

cheers


Re: powerpc: fix build failure by disabling attribute-alias warning in pci_32

2018-06-05 Thread Michael Ellerman
On Tue, 2018-06-05 at 06:57:43 UTC, Christophe Leroy wrote:
> Commit 2479bfc9bc600 ("powerpc: Fix build by disabling attribute-alias
> warning for SYSCALL_DEFINEx") forgot arch/powerpc/kernel/pci_32.c
> 
> Latest GCC version emit the following warnings
> 
> As arch/powerpc code is built with -Werror, this breaks build with
> GCC 8.1
> 
> This patch inhibits this warning
> 
> In file included from arch/powerpc/kernel/pci_32.c:14:
> ./include/linux/syscalls.h:233:18: error: 'sys_pciconfig_iobase' alias 
> between functions of incompatible types 'long int(long int,  long unsigned 
> int,  long unsigned int)' and 'long int(long int,  long int,  long int)' 
> [-Werror=attribute-alias]
>   asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \
>   ^~~
> ./include/linux/syscalls.h:222:2: note: in expansion of macro 
> '__SYSCALL_DEFINEx'
>   __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
>   ^
> 
> Signed-off-by: Christophe Leroy 

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/415520373975d2eba565c256d2cad8

cheers


Re: powerpc/powernv: copy/paste - Mask SO bit in CR

2018-06-05 Thread Michael Ellerman
On Mon, 2018-06-04 at 08:33:38 UTC, Michael Ellerman wrote:
> NX can set the 3rd bit in CR register for XER[SO] (Summary overflow)
> which is not related to paste request. The current paste function
> returns failure for a successful request when this bit is set. So mask
> this bit and check the proper return status.
> 
> Fixes: 2392c8c8c045 ("powerpc/powernv/vas: Define copy/paste interfaces")
> Cc: sta...@vger.kernel.org # v4.14+
> Signed-off-by: Haren Myneni 
> Signed-off-by: Michael Ellerman 

Applied to powerpc next.

https://git.kernel.org/powerpc/c/75743649064ec0cf5ddd69f240ef23

cheers


Re: cpuidle:powernv: Make the snooze timeout dynamic.

2018-06-05 Thread Michael Ellerman
On Thu, 2018-05-31 at 12:15:09 UTC, "Gautham R. Shenoy" wrote:
> From: "Gautham R. Shenoy" 
> 
> The commit 78eaa10f027c ("cpuidle: powernv/pseries: Auto-promotion of
> snooze to deeper idle state") introduced a timeout for the snooze idle
> state so that it could be eventually be promoted to a deeper idle
> state. The snooze timeout value is static and set to the target
> residency of the next idle state, which would train the cpuidle
> governor to pick the next idle state eventually.
> 
> The unfortunate side-effect of this is that if the next idle state(s)
> is disabled, the CPU will forever remain in snooze, despite the fact
> that the system is completely idle, and other deeper idle states are
> available.
> 
> This patch fixes the issue by dynamically setting the snooze timeout
> to the target residency of the next enabled state on the device.
> 
> Before Patch
> Reviewed-by: Balbir Singh 
> 
> ==
> POWER8 : Only nap disabled.
>  $cpupower monitor sleep 30
> sleep took 30.01297 seconds and exited with status 0
>   |Idle_Stats
> PKG |CORE|CPU | snoo | Nap  | Fast
>0|   8|   0| 96.41|  0.00|  0.00
>0|   8|   1| 96.43|  0.00|  0.00
>0|   8|   2| 96.47|  0.00|  0.00
>0|   8|   3| 96.35|  0.00|  0.00
>0|   8|   4| 96.37|  0.00|  0.00
>0|   8|   5| 96.37|  0.00|  0.00
>0|   8|   6| 96.47|  0.00|  0.00
>0|   8|   7| 96.47|  0.00|  0.00
> 
> POWER9: Shallow states (stop0lite, stop1lite, stop2lite, stop0, stop1,
> stop2) disabled:
> $cpupower monitor sleep 30
> sleep took 30.05033 seconds and exited with status 0
>   |Idle_Stats
> PKG |CORE|CPU | snoo | stop | stop | stop | stop | stop | stop | stop | stop
>0|  16|   0| 89.79|  0.00|  0.00|  0.00|  0.00|  0.00|  0.00|  0.00|  0.00
>0|  16|   1| 90.12|  0.00|  0.00|  0.00|  0.00|  0.00|  0.00|  0.00|  0.00
>0|  16|   2| 90.21|  0.00|  0.00|  0.00|  0.00|  0.00|  0.00|  0.00|  0.00
>0|  16|   3| 90.29|  0.00|  0.00|  0.00|  0.00|  0.00|  0.00|  0.00|  0.00
> 
> After Patch
> ==
> POWER8 : Only nap disabled.
> $ cpupower monitor sleep 30
> sleep took 30.01200 seconds and exited with status 0
>   |Idle_Stats
> PKG |CORE|CPU | snoo | Nap  | Fast
>0|   8|   0| 16.58|  0.00| 77.21
>0|   8|   1| 18.42|  0.00| 75.38
>0|   8|   2|  4.70|  0.00| 94.09
>0|   8|   3| 17.06|  0.00| 81.73
>0|   8|   4|  3.06|  0.00| 95.73
>0|   8|   5|  7.00|  0.00| 96.80
>0|   8|   6|  1.00|  0.00| 98.79
>0|   8|   7|  5.62|  0.00| 94.17
> 
> POWER9: Shallow states (stop0lite, stop1lite, stop2lite, stop0, stop1,
> stop2) disabled:
> 
> $cpupower monitor sleep 30
> sleep took 30.02110 seconds and exited with status 0
>   |Idle_Stats
> PKG |CORE|CPU | snoo | stop | stop | stop | stop | stop | stop | stop | stop
>0|   0|   0|  0.69|  0.00|  0.00|  0.00|  0.00|  0.00|  0.00|  9.39| 89.70
>0|   0|   1|  0.00|  0.00|  0.00|  0.00|  0.00|  0.00|  0.00|  0.05| 93.21
>0|   0|   2|  0.00|  0.00|  0.00|  0.00|  0.00|  0.00|  0.00|  0.00| 89.93
>0|   0|   3|  0.00|  0.00|  0.00|  0.00|  0.00|  0.00|  0.00|  0.00| 93.26
> 
> Signed-off-by: Gautham R. Shenoy 

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/0a4ec6aa035a52c422eceb2ed51ed8

cheers


Re: powerpc-opal: fix spelling mistake "Uniterrupted" -> "Uninterrupted"

2018-06-05 Thread Michael Ellerman
On Sat, 2018-05-26 at 15:15:31 UTC, Colin King wrote:
> From: Colin Ian King 
> 
> Trivial fix to spelling mistake in hmi_error_types text
> 
> Signed-off-by: Colin Ian King 
> Reviewed-by: Stewart Smith 

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/b0c4acb1dd7c653f78391661079af5

cheers


Re: powerpc/pkeys: Detach execute_only key on !PROT_EXEC

2018-06-05 Thread Michael Ellerman
On Fri, 2018-05-04 at 20:01:51 UTC, Ram Pai wrote:
> Disassociate the exec_key from a VMA if the VMA permission is not
> PROT_EXEC anymore.  Otherwise the exec_only key continues to be
> associated with the vma, causing unexpected behavior.
> 
> The problem was reported on x86 by Shakeel Butt,
> which is also applicable on powerpc.
> 
> cc: Shakeel Butt 
> Reported-by: Shakeel Butt 
> Fixes 5586cf6 ("powerpc: introduce execute-only pkey")
> Signed-off-by: Ram Pai 
> Reviewed-by: Thiago Jung Bauermann 

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/eabdb8ca8690eedd461e61ea778059

cheers


Re: powerpc: fix spelling mistake: "Usupported" -> "Unsupported"

2018-06-05 Thread Michael Ellerman
On Fri, 2018-03-30 at 15:55:53 UTC, Colin King wrote:
> From: Colin Ian King 
> 
> Trivial fix to spelling mistake in bootx_printf message text
> 
> Signed-off-by: Colin Ian King 

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/e6536a9f94c00a5e1da0a869ccea07

cheers


Re: Problems building ppc images in v4.14.y and v4.16.y using gcc 7.3.0 / 8.1.0 from kernel.org

2018-06-05 Thread Arnd Bergmann
On Tue, Jun 5, 2018 at 3:52 PM, Guenter Roeck  wrote:
> Hi Arnd,
>
> when using the ppc64 compiler from kernel.org, I see the following problems
> when trying to compile ppc:allnoconfig in v4.14.y or v4.16.y.
>
> gcc 7.3.0: Compilation of kernel.cpu.o hangs
>
> The problem goes away if I apply the following two patches (tested with
> 4.16.y)
>
> 17a2f1ced028 cpu/hotplug: Merge cpuhp_bp_states and cpuhp_ap_states
> fcb3029a8d89 cpu/hotplug: Fix unused function warning

This is probably the same as
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84038

I thought I had included the fix in my builds.

> gcc 8.1.0: Compilation of kernel/cpu.o results in the following error
>
> powerpc64-linux-gcc: error: unrecognized command line option '-mno-spe'; did
> you mean '-fno-see'?
> powerpc64-linux-gcc: error: unrecognized command line option '-mspe=no'; did
> you mean '-misel=no'?
>
> This problem is also seen with mainline.

I've seen it, but couldn't figure out what the right fix is. I ended
up commenting
out those two lines in my private builds:

--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -215,8 +215,8 @@ KBUILD_CFLAGS += $(call cc-option,-mno-vsx)

 # No SPE instruction when building kernel
 # (We use all available options to help semi-broken compilers)
-KBUILD_CFLAGS += $(call cc-option,-mno-spe)
-KBUILD_CFLAGS += $(call cc-option,-mspe=no)
+#KBUILD_CFLAGS += $(call cc-option,-mno-spe)
+#KBUILD_CFLAGS += $(call cc-option,-mspe=no)

 # Enable unit-at-a-time mode when possible. It shrinks the
 # kernel considerably.

I think there were some changes in how cc-option gets evaluated, maybe
those rely on something else to be enabled or disabled first?

Arnd


Re: [PATCH 09/10] dpaa_eth: add support for hardware timestamping

2018-06-05 Thread Richard Cochran
On Tue, Jun 05, 2018 at 03:35:28AM +, Y.b. Lu wrote:
> [Y.b. Lu] Actually these timestamping codes affected DPAA networking 
> performance in our previous performance test.
> That's why we used ifdef for it.

How much does time stamping hurt performance?

If the time stamping is compiled in but not enabled at run time, does
it still affect performace?

Thanks,
Richard


Re: [PATCH -next] ocxl: Fix missing unlock on error in afu_ioctl_enable_p9_wait()

2018-06-05 Thread Frederic Barrat




Le 05/06/2018 à 11:16, Wei Yongjun a écrit :

Add the missing unlock before return from function
afu_ioctl_enable_p9_wait() in the error handling case.

Fixes: e948e06fc63a ("ocxl: Expose the thread_id needed for wait on POWER9")
Signed-off-by: Wei Yongjun 
---
  drivers/misc/ocxl/file.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/misc/ocxl/file.c b/drivers/misc/ocxl/file.c
index 33ae46c..e6a6074 100644
--- a/drivers/misc/ocxl/file.c
+++ b/drivers/misc/ocxl/file.c
@@ -139,8 +139,10 @@ static long afu_ioctl_enable_p9_wait(struct ocxl_context 
*ctx,
// Locks both status & tidr
mutex_lock(>status_mutex);
if (!ctx->tidr) {
-   if (set_thread_tidr(current))
+   if (set_thread_tidr(current)) {
+   mutex_unlock(>status_mutex);
return -ENOENT;
+   }


O_o   Thanks for fixing it

Acked-by: Frederic Barrat 



ctx->tidr = current->thread.tidr;
}





Re: [RFC PATCH for 4.18 10/16] powerpc: Wire up restartable sequences system call

2018-06-05 Thread Mathieu Desnoyers
- On Jun 5, 2018, at 1:18 AM, Michael Ellerman m...@ellerman.id.au wrote:

> Mathieu Desnoyers  writes:
> 
>> From: Boqun Feng 
>>
>> Wire up the rseq system call on powerpc.
>>
>> This provides an ABI improving the speed of a user-space getcpu
>> operation on powerpc by skipping the getcpu system call on the fast
>> path, as well as improving the speed of user-space operations on per-cpu
>> data compared to using load-reservation/store-conditional atomics.
>>
>> Signed-off-by: Boqun Feng 
>> Signed-off-by: Mathieu Desnoyers 
>> CC: Benjamin Herrenschmidt 
>> CC: Paul Mackerras 
>> CC: Michael Ellerman 
>> CC: Peter Zijlstra 
>> CC: "Paul E. McKenney" 
>> CC: linuxppc-dev@lists.ozlabs.org
>> ---
>>  arch/powerpc/include/asm/systbl.h  | 1 +
>>  arch/powerpc/include/asm/unistd.h  | 2 +-
>>  arch/powerpc/include/uapi/asm/unistd.h | 1 +
>>  3 files changed, 3 insertions(+), 1 deletion(-)
> 
> Looks fine to me.
> 
> I don't have any other new syscalls in my next, so this should not
> conflict with anything for 4.18.
> 
> Acked-by: Michael Ellerman  (powerpc)

Added your ack to the series, thanks!

Mathieu

-- 
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com


Re: [RFC PATCH for 4.18 09/16] powerpc: Add syscall detection for restartable sequences

2018-06-05 Thread Mathieu Desnoyers
- On Jun 5, 2018, at 1:21 AM, Michael Ellerman m...@ellerman.id.au wrote:

> Mathieu Desnoyers  writes:
>> From: Boqun Feng 
>>
>> Syscalls are not allowed inside restartable sequences, so add a call to
>> rseq_syscall() at the very beginning of system call exiting path for
>> CONFIG_DEBUG_RSEQ=y kernel. This could help us to detect whether there
>> is a syscall issued inside restartable sequences.
>>
>> [ Tested on 64-bit powerpc kernel by Mathieu Desnoyers. Still needs to
>>   be tested on 32-bit powerpc kernel. ]
>>
>> Signed-off-by: Boqun Feng 
>> Signed-off-by: Mathieu Desnoyers 
>> CC: Benjamin Herrenschmidt 
>> CC: Paul Mackerras 
>> CC: Michael Ellerman 
>> CC: Peter Zijlstra 
>> CC: "Paul E. McKenney" 
>> CC: linuxppc-dev@lists.ozlabs.org
>> ---
>>  arch/powerpc/kernel/entry_32.S | 7 +++
>>  arch/powerpc/kernel/entry_64.S | 8 
>>  2 files changed, 15 insertions(+)
> 
> I don't _love_ the #ifdefs in here, but they look correct and there's
> not really a better option until we rewrite the syscall handler in C.
> 
> The rseq selftests passed for me with this applied and enabled. So if
> you like here's some tags:
> 
> Tested-by: Michael Ellerman 
> Acked-by: Michael Ellerman 
> 

Adding you ack to the series.

Thanks!

Mathieu

-- 
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com


Re: [v3] powerpc: fix build failure by disabling attribute-alias warning

2018-06-05 Thread Michael Ellerman
Christophe LEROY  writes:
> Le 04/06/2018 à 16:11, Michael Ellerman a écrit :
>> On Tue, 2018-05-29 at 16:06:41 UTC, Christophe Leroy wrote:
>>> Latest GCC version emit the following warnings
>>>
>>> As arch/powerpc code is built with -Werror, this breaks build with
>>> GCC 8.1
>>>

>>>
>>> Signed-off-by: Christophe Leroy 
>> 
>> Applied to powerpc next, thanks.
>> 
>> https://git.kernel.org/powerpc/c/2479bfc9bc600dcce7f932d52dcfa8
>
> Oops, you didn't take v4 but v3 which was missing the fix into pci_32.c

Yep sorry. I had v3 in my tree since a few days.

If the patch is "Under Review" in patchwork that usually means I have it
applied and am testing it. Although sometimes I forget :)

> I'll send you a patch to add the fix in pci_32.c

Thanks, applied.

cheers


Re: [PATCH] cpuidle:powernv: Make the snooze timeout dynamic.

2018-06-05 Thread Michael Ellerman
Gautham R Shenoy  writes:
> Hello Michael,
>
> On Mon, Jun 04, 2018 at 09:27:40PM +1000, Michael Ellerman wrote:
>> "Gautham R. Shenoy"  writes:
>> 
>> > From: "Gautham R. Shenoy" 
>> >
>> > The commit 78eaa10f027c ("cpuidle: powernv/pseries: Auto-promotion of
>> > snooze to deeper idle state") introduced a timeout for the snooze idle
>> > state so that it could be eventually be promoted to a deeper idle
>> > state. The snooze timeout value is static and set to the target
>> > residency of the next idle state, which would train the cpuidle
>> > governor to pick the next idle state eventually.
>> >
>> > The unfortunate side-effect of this is that if the next idle state(s)
>> > is disabled, the CPU will forever remain in snooze, despite the fact
>> > that the system is completely idle, and other deeper idle states are
>> > available.
>> 
>> That sounds like a bug, I'll add?
>
> Yes, this is a bug-fix for a customer scenario which we encountered
> recently.

OK, the change log could have used some more scary words to make that
clearer ;)

I changed the subject to:

  cpuidle: powernv: Fix promotion from snooze if next state disabled

Which hopefully makes sense.

>> Fixes: 78eaa10f027c ("cpuidle: powernv/pseries: Auto-promotion of snooze to 
>> deeper idle state")
>> Cc: sta...@vger.kernel.org # v4.2+
>
> This patch applies cleanly from v4.13 onwards. Prior to that there are
> some (minor) conflicts.
>
> Should I spin a version separately for the prior stable versions ?

Yes please, that would be great.

You might want to avoid "=" in the change log too, as patchwork and
possibly other tools will think it's part of the diff.

cheers


RE: [PATCH -next] ocxl: Fix missing unlock on error in afu_ioctl_enable_p9_wait()

2018-06-05 Thread Alastair D'Silva
> -Original Message-
> From: Wei Yongjun 
> Sent: Tuesday, 5 June 2018 7:16 PM
> To: Frederic Barrat ; Andrew Donnellan
> ; Arnd Bergmann ;
> Greg Kroah-Hartman ; Alastair D'Silva
> 
> Cc: Wei Yongjun ; linuxppc-
> d...@lists.ozlabs.org; linux-ker...@vger.kernel.org; kernel-
> janit...@vger.kernel.org
> Subject: [PATCH -next] ocxl: Fix missing unlock on error in
> afu_ioctl_enable_p9_wait()
> 
> Add the missing unlock before return from function
> afu_ioctl_enable_p9_wait() in the error handling case.
> 
> Fixes: e948e06fc63a ("ocxl: Expose the thread_id needed for wait on
> POWER9")
> Signed-off-by: Wei Yongjun 
> ---
>  drivers/misc/ocxl/file.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/misc/ocxl/file.c b/drivers/misc/ocxl/file.c index
> 33ae46c..e6a6074 100644
> --- a/drivers/misc/ocxl/file.c
> +++ b/drivers/misc/ocxl/file.c
> @@ -139,8 +139,10 @@ static long afu_ioctl_enable_p9_wait(struct
> ocxl_context *ctx,
>   // Locks both status & tidr
>   mutex_lock(>status_mutex);
>   if (!ctx->tidr) {
> - if (set_thread_tidr(current))
> + if (set_thread_tidr(current)) {
> + mutex_unlock(>status_mutex);
>   return -ENOENT;
> + }
> 
>   ctx->tidr = current->thread.tidr;
>   }


Thanks for picking that up!

Reviewed-by: Alastair D'Silva 

-- 
Alastair D'Silva   mob: 0423 762 819
skype: alastair_dsilva msn: alast...@d-silva.org
blog: http://alastair.d-silva.orgTwitter: @EvilDeece




[PATCH -next] ocxl: Fix missing unlock on error in afu_ioctl_enable_p9_wait()

2018-06-05 Thread Wei Yongjun
Add the missing unlock before return from function
afu_ioctl_enable_p9_wait() in the error handling case.

Fixes: e948e06fc63a ("ocxl: Expose the thread_id needed for wait on POWER9")
Signed-off-by: Wei Yongjun 
---
 drivers/misc/ocxl/file.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/misc/ocxl/file.c b/drivers/misc/ocxl/file.c
index 33ae46c..e6a6074 100644
--- a/drivers/misc/ocxl/file.c
+++ b/drivers/misc/ocxl/file.c
@@ -139,8 +139,10 @@ static long afu_ioctl_enable_p9_wait(struct ocxl_context 
*ctx,
// Locks both status & tidr
mutex_lock(>status_mutex);
if (!ctx->tidr) {
-   if (set_thread_tidr(current))
+   if (set_thread_tidr(current)) {
+   mutex_unlock(>status_mutex);
return -ENOENT;
+   }
 
ctx->tidr = current->thread.tidr;
}



Re: [PATCH v2] cpuidle/powernv : Add Description for cpuidle state

2018-06-05 Thread Akshay Adiga
On Tue, Jun 05, 2018 at 02:24:39PM +0530, Abhishek wrote:
> 
> 
> On 06/04/2018 05:15 PM, Akshay Adiga wrote:
> > On Mon, Jun 04, 2018 at 07:04:14PM +1000, Benjamin Herrenschmidt wrote:
> > > Is this a new property ? I'm not fan of adding yet another of those
> > > silly arrays.
> > > 
> > > I would say this is the right time now to switch over to a node per
> > > state instead, as we discussed with Vaidy.
> 
> It is not a new property. Name was being used for description as description
> was not present in device tree. A skiboot patch adding description to device
> tree have been posted. This patch reads those description instead of copying
> name itself into description. And we fall back to reading name into
> description to not break the comaptibility with older firmware.

>From a cpuidle point of view this is a exisiting property, but for
powernv there was no device-tree property describing this. 

Abhishek has added the following skiboot patch for adding description
for each idle state in device-tree .
https://patchwork.ozlabs.org/patch/924879/

I agree this can go into new device tree format which each idle state
as a node. Probably i will roll this patch into mine in the next
version.


> 
> Thanks
> Abhishek
> 
> > I posted  the node based device tree here :
> > skiboot patch :  https://patchwork.ozlabs.org/patch/923120/
> > kernel patch : https://lkml.org/lkml/2018/5/30/1146
> > 
> > Do you have any inputs for this design ?
> > 
> > > Additionally, while doing that, we can provide the versioning mechanism
> > > I proposed so we can deal with state specific issues and erratas.
> > > 
> > > Cheers,
> > > Ben.
> > > 
> 



Re: [PATCH v2] cpuidle/powernv : Add Description for cpuidle state

2018-06-05 Thread Abhishek




On 06/04/2018 05:15 PM, Akshay Adiga wrote:

On Mon, Jun 04, 2018 at 07:04:14PM +1000, Benjamin Herrenschmidt wrote:

Is this a new property ? I'm not fan of adding yet another of those
silly arrays.

I would say this is the right time now to switch over to a node per
state instead, as we discussed with Vaidy.


It is not a new property. Name was being used for description as 
description was not present in device tree. A skiboot patch adding 
description to device tree have been posted. This patch reads those 
description instead of copying name itself into description. And we fall 
back to reading name into description to not break the comaptibility 
with older firmware.


Thanks
Abhishek


I posted  the node based device tree here :
skiboot patch :  https://patchwork.ozlabs.org/patch/923120/
kernel patch : https://lkml.org/lkml/2018/5/30/1146

Do you have any inputs for this design ?


Additionally, while doing that, we can provide the versioning mechanism
I proposed so we can deal with state specific issues and erratas.

Cheers,
Ben.





Re: [PATCH] cpuidle:powernv: Make the snooze timeout dynamic.

2018-06-05 Thread Gautham R Shenoy
Hello Michael,

On Mon, Jun 04, 2018 at 09:27:40PM +1000, Michael Ellerman wrote:
> "Gautham R. Shenoy"  writes:
> 
> > From: "Gautham R. Shenoy" 
> >
> > The commit 78eaa10f027c ("cpuidle: powernv/pseries: Auto-promotion of
> > snooze to deeper idle state") introduced a timeout for the snooze idle
> > state so that it could be eventually be promoted to a deeper idle
> > state. The snooze timeout value is static and set to the target
> > residency of the next idle state, which would train the cpuidle
> > governor to pick the next idle state eventually.
> >
> > The unfortunate side-effect of this is that if the next idle state(s)
> > is disabled, the CPU will forever remain in snooze, despite the fact
> > that the system is completely idle, and other deeper idle states are
> > available.
> 
> That sounds like a bug, I'll add?
>

Yes, this is a bug-fix for a customer scenario which we encountered
recently.

> Fixes: 78eaa10f027c ("cpuidle: powernv/pseries: Auto-promotion of snooze to 
> deeper idle state")
> Cc: sta...@vger.kernel.org # v4.2+

This patch applies cleanly from v4.13 onwards. Prior to that there are
some (minor) conflicts.

Should I spin a version separately for the prior stable versions ?

> 
> cheers
> 



Re: [v3] powerpc: fix build failure by disabling attribute-alias warning

2018-06-05 Thread Christophe LEROY




Le 04/06/2018 à 16:11, Michael Ellerman a écrit :

On Tue, 2018-05-29 at 16:06:41 UTC, Christophe Leroy wrote:

Latest GCC version emit the following warnings

As arch/powerpc code is built with -Werror, this breaks build with
GCC 8.1

This patch inhibits those warnings

   CC  arch/powerpc/kernel/syscalls.o
In file included from arch/powerpc/kernel/syscalls.c:24:
./include/linux/syscalls.h:233:18: error: 'sys_mmap2' alias between functions 
of incompatible types 'long int(long unsigned int,  size_t,  long unsigned int, 
 long unsigned int,  long unsigned int,  long unsigned int)' {aka 'long 
int(long unsigned int,  long unsigned int,  long unsigned int,  long unsigned 
int,  long unsigned int,  long unsigned int)'} and 'long int(long int,  long 
int,  long int,  long int,  long int,  long int)' [-Werror=attribute-alias]
   asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \
   ^~~
./include/linux/syscalls.h:222:2: note: in expansion of macro 
'__SYSCALL_DEFINEx'
   __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
   ^
./include/linux/syscalls.h:216:36: note: in expansion of macro 'SYSCALL_DEFINEx'
  #define SYSCALL_DEFINE6(name, ...) SYSCALL_DEFINEx(6, _##name, __VA_ARGS__)
 ^~~
arch/powerpc/kernel/syscalls.c:65:1: note: in expansion of macro 
'SYSCALL_DEFINE6'
  SYSCALL_DEFINE6(mmap2, unsigned long, addr, size_t, len,
  ^~~
./include/linux/syscalls.h:238:18: note: aliased declaration here
   asmlinkage long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
   ^~~~
./include/linux/syscalls.h:222:2: note: in expansion of macro 
'__SYSCALL_DEFINEx'
   __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
   ^
./include/linux/syscalls.h:216:36: note: in expansion of macro 'SYSCALL_DEFINEx'
  #define SYSCALL_DEFINE6(name, ...) SYSCALL_DEFINEx(6, _##name, __VA_ARGS__)
 ^~~
arch/powerpc/kernel/syscalls.c:65:1: note: in expansion of macro 
'SYSCALL_DEFINE6'
  SYSCALL_DEFINE6(mmap2, unsigned long, addr, size_t, len,
  ^~~
./include/linux/syscalls.h:233:18: error: 'sys_mmap' alias between functions of 
incompatible types 'long int(long unsigned int,  size_t,  long unsigned int,  
long unsigned int,  long unsigned int,  off_t)' {aka 'long int(long unsigned 
int,  long unsigned int,  long unsigned int,  long unsigned int,  long unsigned 
int,  long int)'} and 'long int(long int,  long int,  long int,  long int,  
long int,  long int)' [-Werror=attribute-alias]
   asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \
   ^~~
./include/linux/syscalls.h:222:2: note: in expansion of macro 
'__SYSCALL_DEFINEx'
   __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
   ^
./include/linux/syscalls.h:216:36: note: in expansion of macro 'SYSCALL_DEFINEx'
  #define SYSCALL_DEFINE6(name, ...) SYSCALL_DEFINEx(6, _##name, __VA_ARGS__)
 ^~~
arch/powerpc/kernel/syscalls.c:72:1: note: in expansion of macro 
'SYSCALL_DEFINE6'
  SYSCALL_DEFINE6(mmap, unsigned long, addr, size_t, len,
  ^~~
./include/linux/syscalls.h:238:18: note: aliased declaration here
   asmlinkage long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
   ^~~~
./include/linux/syscalls.h:222:2: note: in expansion of macro 
'__SYSCALL_DEFINEx'
   __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
   ^
./include/linux/syscalls.h:216:36: note: in expansion of macro 'SYSCALL_DEFINEx'
  #define SYSCALL_DEFINE6(name, ...) SYSCALL_DEFINEx(6, _##name, __VA_ARGS__)
 ^~~
arch/powerpc/kernel/syscalls.c:72:1: note: in expansion of macro 
'SYSCALL_DEFINE6'
  SYSCALL_DEFINE6(mmap, unsigned long, addr, size_t, len,
  ^~~
   CC  arch/powerpc/kernel/signal_32.o
In file included from arch/powerpc/kernel/signal_32.c:31:
./include/linux/compat.h:74:18: error: 'compat_sys_swapcontext' alias between 
functions of incompatible types 'long int(struct ucontext32 *, struct 
ucontext32 *, int)' and 'long int(long int,  long int,  long int)' 
[-Werror=attribute-alias]
   asmlinkage long compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \
   ^~
./include/linux/compat.h:58:2: note: in expansion of macro 
'COMPAT_SYSCALL_DEFINEx'
   COMPAT_SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
   ^~
arch/powerpc/kernel/signal_32.c:1041:1: note: in expansion of macro 
'COMPAT_SYSCALL_DEFINE3'
  COMPAT_SYSCALL_DEFINE3(swapcontext, struct ucontext __user *, old_ctx,
  ^~
./include/linux/compat.h:79:18: note: aliased declaration here
   asmlinkage long __se_compat_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
   ^~~
./include/linux/compat.h:58:2: note: in expansion of macro 
'COMPAT_SYSCALL_DEFINEx'
   COMPAT_SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
   ^~

[PATCH] powerpc: fix build failure by disabling attribute-alias warning in pci_32

2018-06-05 Thread Christophe Leroy
Commit 2479bfc9bc600 ("powerpc: Fix build by disabling attribute-alias
warning for SYSCALL_DEFINEx") forgot arch/powerpc/kernel/pci_32.c

Latest GCC version emit the following warnings

As arch/powerpc code is built with -Werror, this breaks build with
GCC 8.1

This patch inhibits this warning

In file included from arch/powerpc/kernel/pci_32.c:14:
./include/linux/syscalls.h:233:18: error: 'sys_pciconfig_iobase' alias between 
functions of incompatible types 'long int(long int,  long unsigned int,  long 
unsigned int)' and 'long int(long int,  long int,  long int)' 
[-Werror=attribute-alias]
  asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \
  ^~~
./include/linux/syscalls.h:222:2: note: in expansion of macro 
'__SYSCALL_DEFINEx'
  __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
  ^

Signed-off-by: Christophe Leroy 
---
 arch/powerpc/kernel/pci_32.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/powerpc/kernel/pci_32.c b/arch/powerpc/kernel/pci_32.c
index d63b488d34d7..4f861055a852 100644
--- a/arch/powerpc/kernel/pci_32.c
+++ b/arch/powerpc/kernel/pci_32.c
@@ -285,6 +285,9 @@ pci_bus_to_hose(int bus)
  * Note that the returned IO or memory base is a physical address
  */
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpragmas"
+#pragma GCC diagnostic ignored "-Wattribute-alias"
 SYSCALL_DEFINE3(pciconfig_iobase, long, which,
unsigned long, bus, unsigned long, devfn)
 {
@@ -310,3 +313,4 @@ SYSCALL_DEFINE3(pciconfig_iobase, long, which,
 
return result;
 }
+#pragma GCC diagnostic pop
-- 
2.13.3