Re: [PATCH v5 10/18] cxl: New hcalls to support cxl adapters

2016-03-02 Thread Ian Munsie
> +#define H_CONTROL_CA_FUNCTION_SUSPEND_PROCESS 2 /* suspend a process 
> from being executed */
> +#define H_CONTROL_CA_FUNCTION_RESUME_PROCESS  3 /* resume a process 
> to be executed */

Thanks for fixing that :)

> +static char *afu_op_names[] = {
...

Much nicer, thanks :)

> +/*
> + * We want to regroup up to 4 integers per line, which means they
> + * need to be in the same pr_devel() statement
> + */

OK

Acked-by: Ian Munsie 

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

Re: [PATCH v5 10/18] cxl: New hcalls to support cxl adapters

2016-02-23 Thread Manoj Kumar

Fred: Thanks for correcting those spellings.

Reviewed-by: Manoj Kumar 

---
Manoj Kumar


On 2/23/2016 10:21 AM, Frederic Barrat wrote:

From: Christophe Lombard 

The hypervisor calls provide an interface with a coherent platform
facility and function. It matches version 0.16 of the 'PAPR changes'
document.

The following hcalls are supported:
H_ATTACH_CA_PROCESSAttach a process element to a coherent platform
function.
H_DETACH_CA_PROCESSDetach a process element from a coherent
platform function.
H_CONTROL_CA_FUNCTION  Allow the partition to manipulate or query
certain coherent platform function behaviors.
H_COLLECT_CA_INT_INFO  Collect interrupt info about a coherent.
platform function after an interrupt occurred
H_CONTROL_CA_FAULTSControl the operation of a coherent platform
function after a fault occurs.
H_DOWNLOAD_CA_FACILITY Support for downloading a base adapter image to
the coherent platform facility, and for
validating the entire image after the download.
H_CONTROL_CA_FACILITY  Allow the partition to manipulate or query
certain coherent platform facility behaviors.

Co-authored-by: Frederic Barrat 
Signed-off-by: Frederic Barrat 
Signed-off-by: Christophe Lombard 
---
  drivers/misc/cxl/cxl.h|  23 +-
  drivers/misc/cxl/hcalls.c | 639 ++
  drivers/misc/cxl/hcalls.h | 203 +++
  drivers/misc/cxl/main.c   |  26 ++
  drivers/misc/cxl/native.c |   1 +
  5 files changed, 890 insertions(+), 2 deletions(-)
  create mode 100644 drivers/misc/cxl/hcalls.c
  create mode 100644 drivers/misc/cxl/hcalls.h

diff --git a/drivers/misc/cxl/cxl.h b/drivers/misc/cxl/cxl.h
index c7ed265..ac655a6 100644
--- a/drivers/misc/cxl/cxl.h
+++ b/drivers/misc/cxl/cxl.h
@@ -688,6 +688,7 @@ void cxl_prefault(struct cxl_context *ctx, u64 wed);

  struct cxl *get_cxl_adapter(int num);
  int cxl_alloc_sst(struct cxl_context *ctx);
+void cxl_dump_debug_buffer(void *addr, size_t size);

  void init_cxl_native(void);

@@ -701,16 +702,34 @@ unsigned int cxl_map_irq(struct cxl *adapter, 
irq_hw_number_t hwirq,
  void cxl_unmap_irq(unsigned int virq, void *cookie);
  int __detach_context(struct cxl_context *ctx);

-/* This matches the layout of the H_COLLECT_CA_INT_INFO retbuf */
+/*
+ * 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.
+ */
  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 afu_err;
u64 errstat;
-   u64 padding[3]; /* to match the expected retbuf size for plpar_hcall9 */
+   u64 proc_handle;
+   u64 padding[2]; /* to match the expected retbuf size for plpar_hcall9 */
  };

  void cxl_assign_psn_space(struct cxl_context *ctx);
diff --git a/drivers/misc/cxl/hcalls.c b/drivers/misc/cxl/hcalls.c
new file mode 100644
index 000..7e4c517
--- /dev/null
+++ b/drivers/misc/cxl/hcalls.c
@@ -0,0 +1,639 @@
+/*
+ * Copyright 2015 IBM Corp.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "hcalls.h"
+
+#define CXL_HCALL_TIMEOUT 6
+#define CXL_HCALL_TIMEOUT_DOWNLOAD 12
+
+#define H_ATTACH_CA_PROCESS0x344
+#define H_CONTROL_CA_FUNCTION  0x348
+#define H_DETACH_CA_PROCESS0x34C
+#define H_COLLECT_CA_INT_INFO  0x350
+#define H_CONTROL_CA_FAULTS0x354
+#define H_DOWNLOAD_CA_FUNCTION 0x35C
+#define H_DOWNLOAD_CA_FACILITY 0x364
+#define H_CONTROL_CA_FACILITY  0x368
+
+#define H_CONTROL_CA_FUNCTION_RESET   1 /* perform a reset */
+#define H_CONTROL_CA_FUNCTION_SUSPEND_PROCESS 2 /* suspend a process 
from being executed */
+#define H_CONTROL_CA_FUNCTION_RESUME_PROCESS  3 /* resume a process to 
be executed */
+#define H_CONTROL_CA_FUNCTION_READ_ERR_STATE  4 /* read 

[PATCH v5 10/18] cxl: New hcalls to support cxl adapters

2016-02-23 Thread Frederic Barrat
From: Christophe Lombard 

The hypervisor calls provide an interface with a coherent platform
facility and function. It matches version 0.16 of the 'PAPR changes'
document.

The following hcalls are supported:
H_ATTACH_CA_PROCESSAttach a process element to a coherent platform
   function.
H_DETACH_CA_PROCESSDetach a process element from a coherent
   platform function.
H_CONTROL_CA_FUNCTION  Allow the partition to manipulate or query
   certain coherent platform function behaviors.
H_COLLECT_CA_INT_INFO  Collect interrupt info about a coherent.
   platform function after an interrupt occurred
H_CONTROL_CA_FAULTSControl the operation of a coherent platform
   function after a fault occurs.
H_DOWNLOAD_CA_FACILITY Support for downloading a base adapter image to
   the coherent platform facility, and for
   validating the entire image after the download.
H_CONTROL_CA_FACILITY  Allow the partition to manipulate or query
   certain coherent platform facility behaviors.

Co-authored-by: Frederic Barrat 
Signed-off-by: Frederic Barrat 
Signed-off-by: Christophe Lombard 
---
 drivers/misc/cxl/cxl.h|  23 +-
 drivers/misc/cxl/hcalls.c | 639 ++
 drivers/misc/cxl/hcalls.h | 203 +++
 drivers/misc/cxl/main.c   |  26 ++
 drivers/misc/cxl/native.c |   1 +
 5 files changed, 890 insertions(+), 2 deletions(-)
 create mode 100644 drivers/misc/cxl/hcalls.c
 create mode 100644 drivers/misc/cxl/hcalls.h

diff --git a/drivers/misc/cxl/cxl.h b/drivers/misc/cxl/cxl.h
index c7ed265..ac655a6 100644
--- a/drivers/misc/cxl/cxl.h
+++ b/drivers/misc/cxl/cxl.h
@@ -688,6 +688,7 @@ void cxl_prefault(struct cxl_context *ctx, u64 wed);
 
 struct cxl *get_cxl_adapter(int num);
 int cxl_alloc_sst(struct cxl_context *ctx);
+void cxl_dump_debug_buffer(void *addr, size_t size);
 
 void init_cxl_native(void);
 
@@ -701,16 +702,34 @@ unsigned int cxl_map_irq(struct cxl *adapter, 
irq_hw_number_t hwirq,
 void cxl_unmap_irq(unsigned int virq, void *cookie);
 int __detach_context(struct cxl_context *ctx);
 
-/* This matches the layout of the H_COLLECT_CA_INT_INFO retbuf */
+/*
+ * 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.
+ */
 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 afu_err;
u64 errstat;
-   u64 padding[3]; /* to match the expected retbuf size for plpar_hcall9 */
+   u64 proc_handle;
+   u64 padding[2]; /* to match the expected retbuf size for plpar_hcall9 */
 };
 
 void cxl_assign_psn_space(struct cxl_context *ctx);
diff --git a/drivers/misc/cxl/hcalls.c b/drivers/misc/cxl/hcalls.c
new file mode 100644
index 000..7e4c517
--- /dev/null
+++ b/drivers/misc/cxl/hcalls.c
@@ -0,0 +1,639 @@
+/*
+ * Copyright 2015 IBM Corp.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "hcalls.h"
+
+#define CXL_HCALL_TIMEOUT 6
+#define CXL_HCALL_TIMEOUT_DOWNLOAD 12
+
+#define H_ATTACH_CA_PROCESS0x344
+#define H_CONTROL_CA_FUNCTION  0x348
+#define H_DETACH_CA_PROCESS0x34C
+#define H_COLLECT_CA_INT_INFO  0x350
+#define H_CONTROL_CA_FAULTS0x354
+#define H_DOWNLOAD_CA_FUNCTION 0x35C
+#define H_DOWNLOAD_CA_FACILITY 0x364
+#define H_CONTROL_CA_FACILITY  0x368
+
+#define H_CONTROL_CA_FUNCTION_RESET   1 /* perform a reset */
+#define H_CONTROL_CA_FUNCTION_SUSPEND_PROCESS 2 /* suspend a process 
from being executed */
+#define H_CONTROL_CA_FUNCTION_RESUME_PROCESS  3 /* resume a process to 
be executed */
+#define H_CONTROL_CA_FUNCTION_READ_ERR_STATE  4 /* read the error 
state */
+#define H_CONTROL_CA_FUNCTION_GET_AFU_ERR 5 /* collect the AFU 
error buffer */
+#define H_CONTROL_CA_FUNCTION_GET_CONFIG  6 /* collect