Re: [PATCH 2/3] of/fdt: introduce of_scan_flat_dt_subnodes and of_get_flat_dt_phandle

2017-04-09 Thread Nicholas Piggin
On Thu, 6 Apr 2017 09:09:41 -0500
Rob Herring  wrote:

> On Wed, Apr 5, 2017 at 7:38 PM, Nicholas Piggin  wrote:
> > Given that it's quite a small addition to of/fdt code, hopefully
> > that gives you a reasonable justification to accept it.
> >
> > If you prefer not to, that's okay, but I think we would have to carry
> > it in arch/powerpc at least for a time, because of the schedule we're
> > working to for POWER9 enablement. As a longer term item I agree with you
> > and Ben, it would be worth considering unflattening earlier.  
> 
> As I mentioned, keeping it in arch/powerpc I like even less. So this is fine.

Here is the patch with the change you suggested. Can I add your
ack and send it via the powerpc tree with the change that uses
these interfaces?

Thanks,
Nick

---
 drivers/of/fdt.c   | 38 ++
 include/linux/of_fdt.h |  6 ++
 2 files changed, 44 insertions(+)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index e5ce4b59e162..961ca97072a9 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -754,6 +754,36 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node,
 }
 
 /**
+ * of_scan_flat_dt_subnodes - scan sub-nodes of a node call callback on each.
+ * @it: callback function
+ * @data: context data pointer
+ *
+ * This function is used to scan sub-nodes of a node.
+ */
+int __init of_scan_flat_dt_subnodes(unsigned long parent,
+   int (*it)(unsigned long node,
+ const char *uname,
+ void *data),
+   void *data)
+{
+   const void *blob = initial_boot_params;
+   int node;
+
+   fdt_for_each_subnode(node, blob, parent) {
+   const char *pathp;
+   int rc;
+
+   pathp = fdt_get_name(blob, node, NULL);
+   if (*pathp == '/')
+   pathp = kbasename(pathp);
+   rc = it(node, pathp, data);
+   if (rc)
+   return rc;
+   }
+   return 0;
+}
+
+/**
  * of_get_flat_dt_subnode_by_name - get the subnode by given name
  *
  * @node: the parent node
@@ -812,6 +842,14 @@ int __init of_flat_dt_match(unsigned long node, const char 
*const *compat)
return of_fdt_match(initial_boot_params, node, compat);
 }
 
+/**
+ * of_get_flat_dt_prop - Given a node in the flat blob, return the phandle
+ */
+uint32_t __init of_get_flat_dt_phandle(unsigned long node)
+{
+   return fdt_get_phandle(initial_boot_params, node);
+}
+
 struct fdt_scan_status {
const char *name;
int namelen;
diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h
index 271b3fdf0070..1dfbfd0d8040 100644
--- a/include/linux/of_fdt.h
+++ b/include/linux/of_fdt.h
@@ -54,6 +54,11 @@ extern char __dtb_end[];
 extern int of_scan_flat_dt(int (*it)(unsigned long node, const char *uname,
 int depth, void *data),
   void *data);
+extern int of_scan_flat_dt_subnodes(unsigned long node,
+   int (*it)(unsigned long node,
+ const char *uname,
+ void *data),
+   void *data);
 extern int of_get_flat_dt_subnode_by_name(unsigned long node,
  const char *uname);
 extern const void *of_get_flat_dt_prop(unsigned long node, const char *name,
@@ -62,6 +67,7 @@ extern int of_flat_dt_is_compatible(unsigned long node, const 
char *name);
 extern int of_flat_dt_match(unsigned long node, const char *const *matches);
 extern unsigned long of_get_flat_dt_root(void);
 extern int of_get_flat_dt_size(void);
+extern uint32_t of_get_flat_dt_phandle(unsigned long node);
 
 extern int early_init_dt_scan_chosen(unsigned long node, const char *uname,
 int depth, void *data);
-- 
2.11.0



Re: [PATCH V4 3/7] cxl: Keep track of mm struct associated with a context

2017-04-09 Thread Andrew Donnellan

On 08/04/17 00:11, Christophe Lombard wrote:

The mm_struct corresponding to the current task is acquired each time
an interrupt is raised. So to simplify the code, we only get the
mm_struct when attaching an AFU context to the process.
The mm_count reference is increased to ensure that the mm_struct can't
be freed. The mm_struct will be released when the context is detached.
A reference on mm_users is not kept to avoid a circular dependency if
the process mmaps its cxl mmio and forget to unmap before exiting.
The field glpid (pid of the group leader associated with the pid), of
the structure cxl_context, is removed because it's no longer useful.

Signed-off-by: Christophe Lombard 


Reviewed-by: Andrew Donnellan 


---
 drivers/misc/cxl/api.c | 17 +--
 drivers/misc/cxl/context.c | 21 +++--
 drivers/misc/cxl/cxl.h | 10 --
 drivers/misc/cxl/fault.c   | 76 --
 drivers/misc/cxl/file.c| 15 +++--
 drivers/misc/cxl/main.c| 12 ++--
 6 files changed, 61 insertions(+), 90 deletions(-)

diff --git a/drivers/misc/cxl/api.c b/drivers/misc/cxl/api.c
index bcc030e..1a138c8 100644
--- a/drivers/misc/cxl/api.c
+++ b/drivers/misc/cxl/api.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 

 #include "cxl.h"

@@ -321,19 +322,29 @@ int cxl_start_context(struct cxl_context *ctx, u64 wed,

if (task) {
ctx->pid = get_task_pid(task, PIDTYPE_PID);
-   ctx->glpid = get_task_pid(task->group_leader, PIDTYPE_PID);
kernel = false;
ctx->real_mode = false;
+
+   /* acquire a reference to the task's mm */
+   ctx->mm = get_task_mm(current);
+
+   /* ensure this mm_struct can't be freed */
+   cxl_context_mm_count_get(ctx);
+
+   /* decrement the use count */
+   if (ctx->mm)
+   mmput(ctx->mm);
}

cxl_ctx_get();

if ((rc = cxl_ops->attach_process(ctx, kernel, wed, 0))) {
-   put_pid(ctx->glpid);
put_pid(ctx->pid);
-   ctx->glpid = ctx->pid = NULL;
+   ctx->pid = NULL;
cxl_adapter_context_put(ctx->afu->adapter);
cxl_ctx_put();
+   if (task)
+   cxl_context_mm_count_put(ctx);
goto out;
}

diff --git a/drivers/misc/cxl/context.c b/drivers/misc/cxl/context.c
index 062bf6c..2e935ea 100644
--- a/drivers/misc/cxl/context.c
+++ b/drivers/misc/cxl/context.c
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -41,7 +42,7 @@ int cxl_context_init(struct cxl_context *ctx, struct cxl_afu 
*afu, bool master)
spin_lock_init(>sste_lock);
ctx->afu = afu;
ctx->master = master;
-   ctx->pid = ctx->glpid = NULL; /* Set in start work ioctl */
+   ctx->pid = NULL; /* Set in start work ioctl */
mutex_init(>mapping_lock);
ctx->mapping = NULL;

@@ -242,12 +243,16 @@ int __detach_context(struct cxl_context *ctx)

/* release the reference to the group leader and mm handling pid */
put_pid(ctx->pid);
-   put_pid(ctx->glpid);

cxl_ctx_put();

/* Decrease the attached context count on the adapter */
cxl_adapter_context_put(ctx->afu->adapter);
+
+   /* Decrease the mm count on the context */
+   cxl_context_mm_count_put(ctx);
+   ctx->mm = NULL;
+
return 0;
 }

@@ -325,3 +330,15 @@ void cxl_context_free(struct cxl_context *ctx)
mutex_unlock(>afu->contexts_lock);
call_rcu(>rcu, reclaim_ctx);
 }
+
+void cxl_context_mm_count_get(struct cxl_context *ctx)
+{
+   if (ctx->mm)
+   atomic_inc(>mm->mm_count);
+}
+
+void cxl_context_mm_count_put(struct cxl_context *ctx)
+{
+   if (ctx->mm)
+   mmdrop(ctx->mm);
+}
diff --git a/drivers/misc/cxl/cxl.h b/drivers/misc/cxl/cxl.h
index 36bc213..4bcbf7a 100644
--- a/drivers/misc/cxl/cxl.h
+++ b/drivers/misc/cxl/cxl.h
@@ -482,8 +482,6 @@ struct cxl_context {
unsigned int sst_size, sst_lru;

wait_queue_head_t wq;
-   /* pid of the group leader associated with the pid */
-   struct pid *glpid;
/* use mm context associated with this pid for ds faults */
struct pid *pid;
spinlock_t lock; /* Protects pending_irq_mask, pending_fault and 
fault_addr */
@@ -551,6 +549,8 @@ struct cxl_context {
 * CX4 only:
 */
struct list_head extra_irq_contexts;
+
+   struct mm_struct *mm;
 };

 struct cxl_service_layer_ops {
@@ -1012,4 +1012,10 @@ int cxl_adapter_context_lock(struct cxl *adapter);
 /* Unlock the contexts-lock if taken. Warn and force unlock otherwise */
 void cxl_adapter_context_unlock(struct cxl *adapter);

+/* Increases the reference count to "struct mm_struct" */
+void 

Re: [v8] powerpc/powernv: add 'firmware/exports' attributes to sysfs

2017-04-09 Thread Joel Stanley
On Thu, Apr 6, 2017 at 4:37 PM, Oliver O'Halloran  wrote:
> On Thu, Mar 30, 2017 at 10:28 AM, Matt Brown
>  wrote:
>> The HDAT data area is consumed by skiboot and turned into a device-tree. In
>> some cases we would like to look directly at the HDAT. This is not possible
>> through /dev/mem as it is reserved memory which is stopped by the /dev/mem
>> filter. There are also other memory areas which are reserved but could be
>> useful to view for debugging purposes.
>>
>> This patch adds sysfs nodes to allow specified memory areas to be viewed.
>> sysfs nodes are created for each property in the device-tree under
>> /ibm,opal/firmware/exports/, and adds them to /sys/firmware/opal/exports/
>> with root read-only permissions.
>>
>> Signed-off-by: Matt Brown 

Thanks. I took the version that mpe put in the powerpc tree. It is
part of the 4.10.9-openpower1 kernel.

  https://github.com/open-power/op-build/pull/1016

Cheers,

Joel

>> ---
>> Changelog
>> v8
>> - fixed error handling
>> - added dynamic allocation of attributes
>> - using of_property_read_u64_array for reading attr vals
>> - reordered vars
>> - renaming vars
>> ---
>>  arch/powerpc/platforms/powernv/opal.c | 81 
>> +++
>>  1 file changed, 81 insertions(+)
>>
>> diff --git a/arch/powerpc/platforms/powernv/opal.c 
>> b/arch/powerpc/platforms/powernv/opal.c
>> index 2822935..232f94e 100644
>> --- a/arch/powerpc/platforms/powernv/opal.c
>> +++ b/arch/powerpc/platforms/powernv/opal.c
>> @@ -604,6 +604,84 @@ static void opal_export_symmap(void)
>> pr_warn("Error %d creating OPAL symbols file\n", rc);
>>  }
>>
>> +static ssize_t export_attr_read(struct file *fp, struct kobject *kobj,
>> +struct bin_attribute *bin_attr, char *buf,
>> +loff_t off, size_t count)
>> +{
>> +   return memory_read_from_buffer(buf, count, , bin_attr->private,
>> +  bin_attr->size);
>> +}
>> +
>> +/*
>> + * opal_export_attrs: creates a sysfs node for each property listed in
>> + * the device-tree under /ibm,opal/firmware/exports/
>> + * All new sysfs nodes are created under /opal/exports/.
>> + * This allows for reserved memory regions (e.g. HDAT) to be read.
>> + * The new sysfs nodes are only readable by root.
>> + */
>> +static void opal_export_attrs(void)
>> +{
>> +   struct bin_attribute *attr_tmp;
>> +   struct device_node *np;
>> +   struct property *prop;
>> +   struct kobject *kobj;
>> +   u64 vals[2];
>> +   int rc, n;
>> +
>> +   /* Create new 'exports' directory - /sys/firmware/opal/exports */
>> +   kobj = kobject_create_and_add("exports", opal_kobj);
>> +   if (!kobj) {
>> +   pr_warn("kobject_create_and_add exports failed\n");
>> +   return;
>> +   }
>> +
>> +   np = of_find_node_by_path("/ibm,opal/firmware/exports");
>> +   if (!np)
>> +   return;
>> +
>> +   n = 0;
>> +   for (prop = np->properties; prop != NULL; prop = prop->next)
>> +   n++;
>> +
>> +   if (n < 2)
>> +   goto cleanup;
>> +
>> +   for_each_property_of_node(np, prop) {
>> +   if (!strcmp(prop->name, "name") ||
>> +   !strcmp(prop->name, "phandle"))
>> +   continue;
>> +
>> +   if (of_property_read_u64_array(np, prop->name, [0], 2))
>> +   continue;
>> +
>> +   attr_tmp = kmalloc(sizeof(*attr_tmp), GFP_KERNEL);
>> +
>> +   if (attr_tmp == NULL) {
>> +   pr_warn("Failed kmalloc for bin_attribute attr_tmp");
>> +   continue;
>> +   }
>> +
>> +   attr_tmp->attr.name = kstrdup(prop->name, GFP_KERNEL);
>> +   attr_tmp->attr.mode = 0400;
>> +   attr_tmp->read = export_attr_read;
>> +   attr_tmp->private = __va(vals[0]);
>> +   attr_tmp->size = vals[1];
>> +
>> +   if (attr_tmp->attr.name == NULL) {
>> +   pr_warn("Failed kstrdup for bin_attribute 
>> attr.name");
>> +   kfree(attr_tmp);
>> +   continue;
>> +   }
>> +   rc = sysfs_create_bin_file(kobj, attr_tmp);
>> +   if (rc)
>> +   pr_warn("Error %d creating OPAL sysfs exports/%s 
>> file\n",
>> + rc, prop->name);
>> +   }
>> +
>> +cleanup:
>> +   of_node_put(np);
>> +}
>> +
>>  static void __init opal_dump_region_init(void)
>>  {
>> void *addr;
>> @@ -742,6 +820,9 @@ static int __init opal_init(void)
>> opal_msglog_sysfs_init();
>> }
>>
>> +   /* Export all properties */
>> +   opal_export_attrs();
>> +
>> /* Initialize platform 

Re: [PATCH V4 2/7] cxl: Remove unused values in bare-metal environment.

2017-04-09 Thread Andrew Donnellan

On 08/04/17 00:11, Christophe Lombard wrote:

The two previously fields pid and tid, located in the structure
cxl_irq_info, are only used in the guest environment. To avoid confusion,
it's not necessary to fill the fields in the bare-metal environment.
Pid_tid is now renamed to 'reserved' to avoid undefined behavior on
bare-metal. The PSL Process and Thread Identification Register
(CXL_PSL_PID_TID_An) is only used when attaching a dedicated process
for PSL8 only. This register goes away in CAIA2.

Signed-off-by: Christophe Lombard 


Reviewed-by: Andrew Donnellan 


---
 drivers/misc/cxl/cxl.h| 20 
 drivers/misc/cxl/hcalls.c |  6 +++---
 drivers/misc/cxl/native.c |  5 -
 3 files changed, 7 insertions(+), 24 deletions(-)

diff --git a/drivers/misc/cxl/cxl.h b/drivers/misc/cxl/cxl.h
index 79e60ec..36bc213 100644
--- a/drivers/misc/cxl/cxl.h
+++ b/drivers/misc/cxl/cxl.h
@@ -888,27 +888,15 @@ int __detach_context(struct cxl_context *ctx);
 /*
  * This must match the layout of the H_COLLECT_CA_INT_INFO retbuf defined
  * in PAPR.
- * A word about endianness: a pointer to this structure is passed when
- * calling the hcall. However, it is not a block of memory filled up by
- * the hypervisor. The return values are found in registers, and copied
- * one by one when returning from the hcall. See the end of the call to
- * plpar_hcall9() in hvCall.S
- * As a consequence:
- * - we don't need to do any endianness conversion
- * - the pid and tid are an exception. They are 32-bit values returned in
- *   the same 64-bit register. So we do need to worry about byte ordering.
+ * Field pid_tid is now 'reserved' because it's no more used on bare-metal.
+ * On a guest environment, PSL_PID_An is located on the upper 32 bits and
+ * PSL_TID_An register in the lower 32 bits.
  */
 struct cxl_irq_info {
u64 dsisr;
u64 dar;
u64 dsr;
-#ifndef CONFIG_CPU_LITTLE_ENDIAN
-   u32 pid;
-   u32 tid;
-#else
-   u32 tid;
-   u32 pid;
-#endif
+   u64 reserved;
u64 afu_err;
u64 errstat;
u64 proc_handle;
diff --git a/drivers/misc/cxl/hcalls.c b/drivers/misc/cxl/hcalls.c
index d6d11f4..9b8bb0f 100644
--- a/drivers/misc/cxl/hcalls.c
+++ b/drivers/misc/cxl/hcalls.c
@@ -413,9 +413,9 @@ long cxl_h_collect_int_info(u64 unit_address, u64 
process_token,

switch (rc) {
case H_SUCCESS: /* The interrupt info is returned in return 
registers. */
-   pr_devel("dsisr:%#llx, dar:%#llx, dsr:%#llx, pid:%u, tid:%u, 
afu_err:%#llx, errstat:%#llx\n",
-   info->dsisr, info->dar, info->dsr, info->pid,
-   info->tid, info->afu_err, info->errstat);
+   pr_devel("dsisr:%#llx, dar:%#llx, dsr:%#llx, pid_tid:%#llx, 
afu_err:%#llx, errstat:%#llx\n",
+   info->dsisr, info->dar, info->dsr, info->reserved,
+   info->afu_err, info->errstat);
return 0;
case H_PARAMETER:   /* An incorrect parameter was supplied. */
return -EINVAL;
diff --git a/drivers/misc/cxl/native.c b/drivers/misc/cxl/native.c
index 7ae7105..7257e8b 100644
--- a/drivers/misc/cxl/native.c
+++ b/drivers/misc/cxl/native.c
@@ -859,8 +859,6 @@ static int native_detach_process(struct cxl_context *ctx)

 static int native_get_irq_info(struct cxl_afu *afu, struct cxl_irq_info *info)
 {
-   u64 pidtid;
-
/* If the adapter has gone away, we can't get any meaningful
 * information.
 */
@@ -870,9 +868,6 @@ static int native_get_irq_info(struct cxl_afu *afu, struct 
cxl_irq_info *info)
info->dsisr = cxl_p2n_read(afu, CXL_PSL_DSISR_An);
info->dar = cxl_p2n_read(afu, CXL_PSL_DAR_An);
info->dsr = cxl_p2n_read(afu, CXL_PSL_DSR_An);
-   pidtid = cxl_p2n_read(afu, CXL_PSL_PID_TID_An);
-   info->pid = pidtid >> 32;
-   info->tid = pidtid & 0x;
info->afu_err = cxl_p2n_read(afu, CXL_AFU_ERR_An);
info->errstat = cxl_p2n_read(afu, CXL_PSL_ErrStat_An);
info->proc_handle = 0;



--
Andrew Donnellan  OzLabs, ADL Canberra
andrew.donnel...@au1.ibm.com  IBM Australia Limited



[PATCH] powerpc/powernv: Fix powernv Kconfig dependencies

2017-04-09 Thread Alistair Popple
The patch to introduce address translation services for Nvlink2 uses
MMU notifiers. However usage of MMU notifiers requires a Kconfig
option which is not selected by default on powerpc so add it to the
powernv Kconfig.

Signed-off-by: Alistair Popple 
---
 arch/powerpc/platforms/powernv/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/powerpc/platforms/powernv/Kconfig 
b/arch/powerpc/platforms/powernv/Kconfig
index 3a07e4d..76b8eca 100644
--- a/arch/powerpc/platforms/powernv/Kconfig
+++ b/arch/powerpc/platforms/powernv/Kconfig
@@ -19,6 +19,7 @@ config PPC_POWERNV
select CPU_FREQ_GOV_ONDEMAND
select CPU_FREQ_GOV_CONSERVATIVE
select PPC_DOORBELL
+   select MMU_NOTIFIER
default y
 
 config OPAL_PRD
-- 
2.1.4



Re: [PATCH] powerpc/mm: Dump hash table

2017-04-09 Thread RashmicaGupta



On 10/04/17 14:02, Anshuman Khandual wrote:

On 04/10/2017 07:34 AM, Rashmica Gupta wrote:

Current behaviour assumes that memory in RAM is contiguous and
iterates from the start of RAM to (start + size of memory). When the
memory isn't physically contiguous, this approach doesn't work.

In dis contiguous platform, we just finish up walking linear
mapping prematurely before the end of the RAM ?

Yes, that is what the following example explains.



If memory exists at 0-5 GB and 6-10 GB then the current approach will
check if entries exist in the hash table from 0GB to 9GB. This patch
changes the behaviour to iterate up to the end of RAM.

So it fixes the commit which added memblock_phys_mem_size().
Hence needs "Fixes: " tag as well.


Woops, will add that!



Re: [PATCH 1/5] powerpc/pseries: do not use msgsndp doorbells on POWER9 guests

2017-04-09 Thread Nicholas Piggin
On Mon, 10 Apr 2017 14:07:38 +1000
Benjamin Herrenschmidt  wrote:

> On Mon, 2017-04-10 at 13:22 +1000, Nicholas Piggin wrote:
> > On Sun, 09 Apr 2017 18:03:35 +1000  
> > > Benjamin Herrenschmidt  wrote:  
> >   
> > > On Fri, 2017-04-07 at 22:55 +1000, Nicholas Piggin wrote:  
> > > > POWER9 hypervisors will not necessarily run guest threads together on
> > > > the same core at the same time, so msgsndp should not be used.    
> > > 
> > > Maybe we shouldn't advertise doorbells at all ?  
> > 
> > Possibly not. I don't know if there is a good way to switch it off
> > in the guest from the host with device tree currently. Might be better
> > to clear it early in the guest rather than test it here though?  
> 
> Sure for now. Long term a separate DT entry would be good.

cpufeatures will do that, but I wonder if some hypervisors won't implement
that binding then might be worth getting into an existing one in PAPR.

Anyway for now I'll make the change and have P9 guest clear the feature
themselves if you like.

> Might be
> worth re-enabling one day if we have HW virtualization of geust
> doorbells.

Yes. Also some hypervisor might run in a virtual sibling = physical
sibling mode on P9 too where it could still work.

Thanks,
Nick


Re: [PATCH 1/5] powerpc/pseries: do not use msgsndp doorbells on POWER9 guests

2017-04-09 Thread Benjamin Herrenschmidt
On Mon, 2017-04-10 at 13:22 +1000, Nicholas Piggin wrote:
> On Sun, 09 Apr 2017 18:03:35 +1000
> > Benjamin Herrenschmidt  wrote:
> 
> > On Fri, 2017-04-07 at 22:55 +1000, Nicholas Piggin wrote:
> > > POWER9 hypervisors will not necessarily run guest threads together on
> > > the same core at the same time, so msgsndp should not be used.  
> > 
> > Maybe we shouldn't advertise doorbells at all ?
> 
> Possibly not. I don't know if there is a good way to switch it off
> in the guest from the host with device tree currently. Might be better
> to clear it early in the guest rather than test it here though?

Sure for now. Long term a separate DT entry would be good. Might be
worth re-enabling one day if we have HW virtualization of geust
doorbells.

Cheers,
Ben



Re: [PATCH] powerpc/mm: Dump hash table

2017-04-09 Thread Anshuman Khandual
On 04/10/2017 07:34 AM, Rashmica Gupta wrote:
> Current behaviour assumes that memory in RAM is contiguous and
> iterates from the start of RAM to (start + size of memory). When the
> memory isn't physically contiguous, this approach doesn't work.

In dis contiguous platform, we just finish up walking linear
mapping prematurely before the end of the RAM ?

> 
> If memory exists at 0-5 GB and 6-10 GB then the current approach will
> check if entries exist in the hash table from 0GB to 9GB. This patch
> changes the behaviour to iterate up to the end of RAM.

So it fixes the commit which added memblock_phys_mem_size().
Hence needs "Fixes: " tag as well.



Re: [PATCH V4 1/7] cxl: Read vsec perst load image

2017-04-09 Thread Andrew Donnellan

Reviewed-by: Andrew Donnellan 

On 08/04/17 00:11, Christophe Lombard wrote:

This bit is used to cause a flash image load for programmable
CAIA-compliant implementation. If this bit is set to ‘0’, a power
cycle of the adapter is required to load a programmable CAIA-com-
pliant implementation from flash.
This field will be used by the following patches.

Signed-off-by: Christophe Lombard 
---
 drivers/misc/cxl/pci.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/misc/cxl/pci.c b/drivers/misc/cxl/pci.c
index b27ea98..1f4c351 100644
--- a/drivers/misc/cxl/pci.c
+++ b/drivers/misc/cxl/pci.c
@@ -1332,6 +1332,7 @@ static int cxl_read_vsec(struct cxl *adapter, struct 
pci_dev *dev)
CXL_READ_VSEC_IMAGE_STATE(dev, vsec, _state);
adapter->user_image_loaded = !!(image_state & 
CXL_VSEC_USER_IMAGE_LOADED);
adapter->perst_select_user = !!(image_state & 
CXL_VSEC_USER_IMAGE_LOADED);
+   adapter->perst_loads_image = !!(image_state & 
CXL_VSEC_PERST_LOADS_IMAGE);

CXL_READ_VSEC_NAFUS(dev, vsec, >slices);
CXL_READ_VSEC_AFU_DESC_OFF(dev, vsec, _desc_off);



--
Andrew Donnellan  OzLabs, ADL Canberra
andrew.donnel...@au1.ibm.com  IBM Australia Limited



Re: kselftest:lost_exception_test failure with 4.11.0-rc5

2017-04-09 Thread Madhavan Srinivasan



On Friday 07 April 2017 06:06 PM, Michael Ellerman wrote:

Sachin Sant  writes:


I have run into few instances where the lost_exception_test from
powerpc kselftest fails with SIGABRT. Following o/p is against
4.11.0-rc5. The failure is intermittent.

What hardware are you on?

How long does it take to run when it fails? I assume ~2 minutes?


Started a run in power8 host (habanero) and it is more than 24hrs and
havent failed yet. So this should be guest/VM scenario then?




When the test fails it is killed due to SIGABRT.
# ./lost_exception_test
test: lost_exception
tags: git_version:unknown
Binding to cpu 8
main test running as pid 9208
EBB Handler is at 0x10003dcc
!! killing lost_exception

This is the parent (test harness saying) it's about to kill the child,
because it took too long.

It sends SIGTERM, but the child catches that, prints all this info, and
then aborts() - so that's why you're seeing SIGABRT.


ebb_state):
   ebb_count= 191529

The test usually runs until it's taken 1,000,000 EBBs, so it looks like
we got stuck.


   spurious = 0
   negative = 0
   no_overflow  = 0
   pmc[1] count = 0x0
   pmc[2] count = 0x0
   pmc[3] count = 0x0
   pmc[4] count = 0x4c1b707

We use a varying sample period of between 400 and 600, and from above
we've taken 191,529 EBBs.

0x4c1b707 / 191,529 ~= 416

So that looks reasonable.


   pmc[5] count = 0x0
   pmc[6] count = 0x0
HW state:
MMCR0 0x8080 FC PMAO

But this says we're stopped with counters frozen and an event pending.


MMCR2 0x
EBBHR 0x10003dcc
BESCR 0x8001 GE PMAE

And that says we have global enable set and events enabled.


So I think there is a bug here somewhere. I don't really have time to
dig into it now, neither does Maddy I think. But we should try and get
to it at some point.

cheers





Re: [PATCH 1/5] powerpc/pseries: do not use msgsndp doorbells on POWER9 guests

2017-04-09 Thread Nicholas Piggin
On Sun, 09 Apr 2017 18:03:35 +1000
Benjamin Herrenschmidt  wrote:

> On Fri, 2017-04-07 at 22:55 +1000, Nicholas Piggin wrote:
> > POWER9 hypervisors will not necessarily run guest threads together on
> > the same core at the same time, so msgsndp should not be used.  
> 
> Maybe we shouldn't advertise doorbells at all ?

Possibly not. I don't know if there is a good way to switch it off
in the guest from the host with device tree currently. Might be better
to clear it early in the guest rather than test it here though?

Thanks,
Nick


Re: [PATCH 1/2] powerpc/mm/radix: Don't do page walk cache flush when doing full mm flush

2017-04-09 Thread Anton Blanchard
On Sat,  1 Apr 2017 20:11:47 +0530
"Aneesh Kumar K.V"  wrote:

> For fullmm tlb flush, we do a flush with RIC_FLUSH_ALL which will
> invalidate all related caches (radix__tlb_flush()). Hence the pwc
> flush is not needed.

Thanks Aneesh. I see a 3x improvement in exec performance with these
2 patches.

Acked-by: Anton Blanchard 

Anton

> 
> Signed-off-by: Aneesh Kumar K.V 
> ---
>  arch/powerpc/mm/tlb-radix.c | 12 
>  1 file changed, 12 insertions(+)
> 
> diff --git a/arch/powerpc/mm/tlb-radix.c b/arch/powerpc/mm/tlb-radix.c
> index 83dc1ccc2fa1..f3e58bd60d1a 100644
> --- a/arch/powerpc/mm/tlb-radix.c
> +++ b/arch/powerpc/mm/tlb-radix.c
> @@ -129,6 +129,12 @@ void radix__local_flush_tlb_pwc(struct
> mmu_gather *tlb, unsigned long addr) {
>   unsigned long pid;
>   struct mm_struct *mm = tlb->mm;
> + /*
> +  * If we are doing a full mm flush, we will do a tlb flush
> +  * with RIC_FLUSH_ALL later.
> +  */
> + if (tlb->fullmm)
> + return;
>  
>   preempt_disable();
>  
> @@ -195,6 +201,12 @@ void radix__flush_tlb_pwc(struct mmu_gather
> *tlb, unsigned long addr) unsigned long pid;
>   struct mm_struct *mm = tlb->mm;
>  
> + /*
> +  * If we are doing a full mm flush, we will do a tlb flush
> +  * with RIC_FLUSH_ALL later.
> +  */
> + if (tlb->fullmm)
> + return;
>   preempt_disable();
>  
>   pid = mm->context.id;



Re: [PATCH 2/2] powerpc/mm/radix: Remove unnecessary ptesync

2017-04-09 Thread Anton Blanchard
On Sat,  1 Apr 2017 20:11:48 +0530
"Aneesh Kumar K.V"  wrote:

> For a tlbiel with pid, we need to issue tlbiel with set number
> encoded. We don't need to do ptesync for each of those. Instead we
> need one for the entire tlbiel pid operation.
> 
> Signed-off-by: Benjamin Herrenschmidt 
> Signed-off-by: Aneesh Kumar K.V 

Thanks Aneesh.

Acked-by: Anton Blanchard 

Anton

> ---
>  arch/powerpc/mm/tlb-radix.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/powerpc/mm/tlb-radix.c b/arch/powerpc/mm/tlb-radix.c
> index f3e58bd60d1a..b68b5219cf45 100644
> --- a/arch/powerpc/mm/tlb-radix.c
> +++ b/arch/powerpc/mm/tlb-radix.c
> @@ -34,10 +34,8 @@ static inline void __tlbiel_pid(unsigned long pid,
> int set, prs = 1; /* process scoped */
>   r = 1;   /* raidx format */
>  
> - asm volatile("ptesync": : :"memory");
>   asm volatile(PPC_TLBIEL(%0, %4, %3, %2, %1)
>: : "r"(rb), "i"(r), "i"(prs), "i"(ric),
> "r"(rs) : "memory");
> - asm volatile("ptesync": : :"memory");
>  }
>  
>  /*
> @@ -47,9 +45,11 @@ static inline void _tlbiel_pid(unsigned long pid,
> unsigned long ric) {
>   int set;
>  
> + asm volatile("ptesync": : :"memory");
>   for (set = 0; set < POWER9_TLB_SETS_RADIX ; set++) {
>   __tlbiel_pid(pid, set, ric);
>   }
> + asm volatile("ptesync": : :"memory");
>   asm volatile(PPC_INVALIDATE_ERAT "; isync" : : :"memory");
>  }
>  



[PATCH] scsi: ibmvfc: don't check for failure from mempool_alloc()

2017-04-09 Thread NeilBrown

mempool_alloc() cannot fail when passed GFP_NOIO or any
other gfp setting that is permitted to sleep.
So remove this pointless code.

Signed-off-by: NeilBrown 
---
 drivers/scsi/ibmvscsi/ibmvfc.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c
index 2c92dabb55f6..26cd3c28186a 100644
--- a/drivers/scsi/ibmvscsi/ibmvfc.c
+++ b/drivers/scsi/ibmvscsi/ibmvfc.c
@@ -3910,12 +3910,6 @@ static int ibmvfc_alloc_target(struct ibmvfc_host 
*vhost, u64 scsi_id)
spin_unlock_irqrestore(vhost->host->host_lock, flags);
 
tgt = mempool_alloc(vhost->tgt_pool, GFP_NOIO);
-   if (!tgt) {
-   dev_err(vhost->dev, "Target allocation failure for scsi id 
%08llx\n",
-   scsi_id);
-   return -ENOMEM;
-   }
-
memset(tgt, 0, sizeof(*tgt));
tgt->scsi_id = scsi_id;
tgt->new_scsi_id = scsi_id;
-- 
2.12.2



signature.asc
Description: PGP signature


[PATCH] powerpc/mm: Dump hash table

2017-04-09 Thread Rashmica Gupta
Current behaviour assumes that memory in RAM is contiguous and
iterates from the start of RAM to (start + size of memory). When the
memory isn't physically contiguous, this approach doesn't work.

If memory exists at 0-5 GB and 6-10 GB then the current approach will
check if entries exist in the hash table from 0GB to 9GB. This patch
changes the behaviour to iterate up to the end of RAM.

Signed-off-by: Rashmica Gupta 
---
 arch/powerpc/mm/dump_hashpagetable.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/mm/dump_hashpagetable.c 
b/arch/powerpc/mm/dump_hashpagetable.c
index d979709..ee07398 100644
--- a/arch/powerpc/mm/dump_hashpagetable.c
+++ b/arch/powerpc/mm/dump_hashpagetable.c
@@ -468,7 +468,7 @@ static void walk_linearmapping(struct pg_state *st)
unsigned long psize = 1 << mmu_psize_defs[mmu_linear_psize].shift;
 
for (addr = PAGE_OFFSET; addr < PAGE_OFFSET +
-   memblock_phys_mem_size(); addr += psize)
+   memblock_end_of_DRAM(); addr += psize)
hpte_find(st, addr, mmu_linear_psize);
 }
 
-- 
2.9.3



Re: Linux 4.11: Reported regressions as of Sunday, 2017-04-09

2017-04-09 Thread Chris Wilson
On Sun, Apr 09, 2017 at 07:15:49PM +0200, Thorsten Leemhuis wrote:
> Desc: i915 gpu hangs under load
> Repo: 2017-03-22 
> https://www.mail-archive.com/intel-gfx@lists.freedesktop.org/msg116227.html 
> https://bugs.freedesktop.org/show_bug.cgi?id=100181 
> https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1372182.html
> Stat: 2017-04-07 
> https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1372182.html
> Note: A few patches from Andrea (who's seeing problems as well) are being 
> discussed

Note, Andrea saw a completely different problem unrelated to the GPU
hang and date back to ~4.9. Both reported issues have been fixed, with
the earlier report already in mainline but Andrea's fix is not yet in a
PR.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


Linux 4.11: Reported regressions as of Sunday, 2017-04-09

2017-04-09 Thread Thorsten Leemhuis
Hi! Find below my third regression report for Linux 4.11. It lists 15
regressions I'm currently aware of. 5 regressions mentioned in last
weeks report got fixed.

As always: Are you aware of any other regressions? Then please let me
know (simply CC regressi...@leemhuis.info). And please tell me if there
is anything in the report that shouldn't be there.

Ciao, Thorsten

P.S.: Thx to all those that CCed me on regression reports or provided
other input, as that makes compiling these reports a whole lot easier!

== Current regressions ==

Desc: Problems since 5b52330bbfe6 "audit: fix auditd/kernel connection state 
tracking"
Repo: 2017-04-09 
https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1373243.html
Stat: 2017-04-09 
https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1373315.html
Note: solution discussed

Desc: "Synaptics Touch Digitizer V04" no longer working
Repo: 2017-04-08 https://bugzilla.kernel.org/show_bug.cgi?id=195287
Stat: n/a 
Note: brand new

Desc: crash since 617f01211baf ("8139too: use napi_complete_done()")
Repo: 2017-04-07 
https://www.mail-archive.com/netdev@vger.kernel.org/msg162162.html
Stat: 2017-04-08 
https://www.mail-archive.com/netdev@vger.kernel.org/msg162285.html
Note: quite new, people are looking into it

Desc: Warning since RC4: sed_opal:OPAL: Error on step function: 0 with error 
-95: Unknown Error
Repo: 2017-04-07 https://bugzilla.kernel.org/show_bug.cgi?id=195277
Stat: 2017-04-07 https://bugzilla.kernel.org/show_bug.cgi?id=195277#c1
Note: patch submitted

Desc: networking/softirq performance regression due to a part of 374ad05ab64d
Repo: 2017-03-29 https://lkml.org/lkml/2017/3/29/758
Stat: 2017-04-05 https://lkml.org/lkml/2017/4/5/553
Note: might be stalled

Desc: 4.11 PowerMac G5 970MP: [drm:.r600_ring_test [radeon]] *ERROR* radeon: 
ring 0 test failed (scratch(0x8504)=0xCAFEDEAD
Repo: 2017-03-24  https://bugs.freedesktop.org/show_bug.cgi?id=99851#c26
Stat: n/a 
Note: looks like reporter (who does not see the problem in 4.10) could need 
some help bisecting

Desc: Commit d8514d8edb5b ("ovl: copy up regular file using O_TMPFILE") breaks 
ubifs
Repo: 2017-03-28 
https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1363879.html
Stat: 2017-03-30 
https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1366190.html 
https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1366208.html
Note: looks stalled after patches to fix issue seemed to do well in tests

Desc: 07ec51480b5e  ("virtio_pci: use shared interrupts for virtqueues") causes 
some kworker grief in -rt too
Repo: 2017-03-27 
https://www.mail-archive.com/search?l=mid=1490605644.14634.50.ca...@gmx.de
Stat: 2017-04-07 
https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1372848.html
Note: WIP

Desc: pine64 defconfig: WARNING: CPU: 0 PID: 86 at drivers/base/dd.c:349 
driver_probe_device+0x258/0x2c0
Repo: 2017-03-25 https://bugzilla.kernel.org/show_bug.cgi?id=195037 
https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1368488.html
Stat: 2017-03-28 https://bugzilla.kernel.org/show_bug.cgi?id=195037#c2
Note: André doesnt have a clue and needs someone with insights devm and devres

Desc: NVMe APST? Samsung PM951 NVMe sudden controller death
Repo: 2017-03-25 https://bugzilla.kernel.org/show_bug.cgi?id=195039
Stat: 2017-03-29 
Note: Poked luto, as it looked stalled; maybe a blacklist update is needed;  
issue might be related to https://bugzilla.kernel.org/show_bug.cgi?id=194921 
(see below)

Desc: NVMe APST? NVMe resets leads to capacity change to 0, leading to panics; 
Samsung SSD as well
Repo: 2017-03-18 https://bugzilla.kernel.org/show_bug.cgi?id=194921
Stat: 2017-03-28 
Note: Poked luto, as it looked stalled; maybe a blacklist update is needed;  
issue might be related to https://bugzilla.kernel.org/show_bug.cgi?id=195039 
(see above)

Desc: Perf regression after enabling nvme APST
Repo: 2017-03-17 https://lkml.org/lkml/2017/3/17/177
Stat: 2017-03-20 https://lkml.org/lkml/2017/3/20/998
Note: stalled

Desc: i915 gpu hangs under load
Repo: 2017-03-22 
https://www.mail-archive.com/intel-gfx@lists.freedesktop.org/msg116227.html 
https://bugs.freedesktop.org/show_bug.cgi?id=100181 
https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1372182.html
Stat: 2017-04-07 
https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1372182.html
Note: A few patches from Andrea (who's seeing problems as well) are being 
discussed

Desc: Synaptics RMI4 touchpad regression in 4.11-rc1: pointer jumps
Repo: 2017-03-11 
https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1351561.html
Stat: 2017-03-31 
https://www.mail-archive.com/search?l=mid=20170331085751.gf22...@mail.corp.redhat.com
Note: stalled; two patched to improve the situation available;

Desc: Synaptics RMI4 touchpad regression in 4.11-rc1: palm detection
Repo: 2017-03-11 
https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1351561.html
Stat: 2017-03-19 

Re: [PATCH 1/5] powerpc/pseries: do not use msgsndp doorbells on POWER9 guests

2017-04-09 Thread Benjamin Herrenschmidt
On Fri, 2017-04-07 at 22:55 +1000, Nicholas Piggin wrote:
> POWER9 hypervisors will not necessarily run guest threads together on
> the same core at the same time, so msgsndp should not be used.

Maybe we shouldn't advertise doorbells at all ?

> Signed-off-by: Nicholas Piggin 
> ---
>  arch/powerpc/platforms/pseries/smp.c | 7 ++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/platforms/pseries/smp.c
> b/arch/powerpc/platforms/pseries/smp.c
> index f6f83aeccaaa..1fa08155206b 100644
> --- a/arch/powerpc/platforms/pseries/smp.c
> +++ b/arch/powerpc/platforms/pseries/smp.c
> @@ -200,7 +200,12 @@ static __init void pSeries_smp_probe(void)
>  {
>   xics_smp_probe();
>  
> - if (cpu_has_feature(CPU_FTR_DBELL)) {
> + /*
> +  * POWER9 can not use msgsndp doorbells for IPI because
> thread
> +  * siblings do not necessarily run on physical cores at the
> same
> +  * time. This could be enabled for pHyp.
> +  */
> + if (cpu_has_feature(CPU_FTR_DBELL) &&
> !cpu_has_feature(CPU_FTR_ARCH_300)) {
>   xics_cause_ipi = smp_ops->cause_ipi;
>   smp_ops->cause_ipi = pSeries_cause_ipi_mux;
>   }