[v6,12/20] cxl: Add guest-specific code

Michael Ellerman mpe at ellerman.id.au
Wed Mar 9 23:42:38 AEDT 2016


On Fri, 2016-04-03 at 11:26:36 UTC, Frederic Barrat wrote:
> From: Christophe Lombard <clombard at linux.vnet.ibm.com>
> 
> The new of.c file contains code to parse the device tree to find out
> about cxl adapters and AFUs.
> 
> guest.c implements the guest-specific callbacks for the backend API.
> 
> The process element ID is not known until the context is attached, so
> we have to separate the context ID assigned by the cxl driver from the
> process element ID visible to the user applications. In bare-metal,
> the 2 IDs match.
> 
> Co-authored-by: Frederic Barrat <fbarrat at linux.vnet.ibm.com>
> Signed-off-by: Frederic Barrat <fbarrat at linux.vnet.ibm.com>
> Signed-off-by: Christophe Lombard <clombard at linux.vnet.ibm.com>
> Reviewed-by: Manoj Kumar <manoj at linux.vnet.ibm.com>
> Acked-by: Ian Munsie <imunsie at au1.ibm.com>
> ---
>  drivers/misc/cxl/Makefile  |   1 +
>  drivers/misc/cxl/api.c     |   2 +-
>  drivers/misc/cxl/context.c |   6 +-
>  drivers/misc/cxl/cxl.h     |  37 +-
>  drivers/misc/cxl/file.c    |   2 +-
>  drivers/misc/cxl/guest.c   | 950 +++++++++++++++++++++++++++++++++++++++++++++
>  drivers/misc/cxl/main.c    |  18 +-
>  drivers/misc/cxl/of.c      | 513 ++++++++++++++++++++++++
>  8 files changed, 1519 insertions(+), 10 deletions(-)
>  create mode 100644 drivers/misc/cxl/guest.c
>  create mode 100644 drivers/misc/cxl/of.c
> 
> diff --git a/drivers/misc/cxl/Makefile b/drivers/misc/cxl/Makefile
> index be2ac5c..a3d4bef 100644
> --- a/drivers/misc/cxl/Makefile
> +++ b/drivers/misc/cxl/Makefile
> @@ -4,6 +4,7 @@ ccflags-$(CONFIG_PPC_WERROR)	+= -Werror
>  cxl-y				+= main.o file.o irq.o fault.o native.o
>  cxl-y				+= context.o sysfs.o debugfs.o pci.o trace.o
>  cxl-y				+= vphb.o api.o
> +cxl-y				+= guest.o of.o hcalls.o
>  obj-$(CONFIG_CXL)		+= cxl.o
>  obj-$(CONFIG_CXL_BASE)		+= base.o

This breaks the (newly added[1]) powernv_defconfig. ie. CONFIG_POWERNV=y, CONFIG_PPC_PSERIES=n.

  ERROR: "plpar_hcall" [drivers/misc/cxl/cxl.ko] undefined!
  ERROR: "rtas_call" [drivers/misc/cxl/cxl.ko] undefined!
  ERROR: "rtas_data_buf" [drivers/misc/cxl/cxl.ko] undefined!
  ERROR: "rtas_token" [drivers/misc/cxl/cxl.ko] undefined!
  ERROR: "plpar_hcall9" [drivers/misc/cxl/cxl.ko] undefined!
  ERROR: "rtas_data_buf_lock" [drivers/misc/cxl/cxl.ko] undefined!


Which is a show-stopper.

I've applied the following patch, let me know if there's anything wrong with
it. It would be great if we could do something cleaner.

cheers

diff --git a/drivers/misc/cxl/Makefile b/drivers/misc/cxl/Makefile
index 9ab874f83df0..8a55c1aa11aa 100644
--- a/drivers/misc/cxl/Makefile
+++ b/drivers/misc/cxl/Makefile
@@ -4,7 +4,7 @@ ccflags-$(CONFIG_PPC_WERROR)	+= -Werror
 cxl-y				+= main.o file.o irq.o fault.o native.o
 cxl-y				+= context.o sysfs.o debugfs.o pci.o trace.o
 cxl-y				+= vphb.o api.o
-cxl-y				+= flash.o guest.o of.o hcalls.o
+cxl-$(CONFIG_PPC_PSERIES)	+= flash.o guest.o of.o hcalls.o
 obj-$(CONFIG_CXL)		+= cxl.o
 obj-$(CONFIG_CXL_BASE)		+= base.o
 
diff --git a/drivers/misc/cxl/main.c b/drivers/misc/cxl/main.c
index b5eeb71f6a9e..ae68c3201156 100644
--- a/drivers/misc/cxl/main.c
+++ b/drivers/misc/cxl/main.c
@@ -296,10 +296,13 @@ static int __init init_cxl(void)
 	if (cpu_has_feature(CPU_FTR_HVMODE)) {
 		cxl_ops = &cxl_native_ops;
 		rc = pci_register_driver(&cxl_pci_driver);
-	} else {
+	}
+#ifdef CONFIG_PPC_PSERIES
+	else {
 		cxl_ops = &cxl_guest_ops;
 		rc = platform_driver_register(&cxl_of_driver);
 	}
+#endif
 	if (rc)
 		goto err1;
 
@@ -317,8 +320,10 @@ static void exit_cxl(void)
 {
 	if (cpu_has_feature(CPU_FTR_HVMODE))
 		pci_unregister_driver(&cxl_pci_driver);
+#ifdef CONFIG_PPC_PSERIES
 	else
 		platform_driver_unregister(&cxl_of_driver);
+#endif
 
 	cxl_debugfs_exit();
 	cxl_file_exit();


More information about the Linuxppc-dev mailing list