Skip to contentSkip to conversation

Add Intel Stratix10 service layer driver

PATCH In review [email protected] 4 participants 10 messages Jan 25, 2018 – Feb 22, 2018 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add Intel Stratix10 service layer driver

From: Richard Gong <[email protected]>

Intel Stratix10 SoC is composed of a 64 bit quad-core ARM Cortex A53 hard processor system (HPS) and Secure Device Manager (SDM). SDM is the hardware which does the FPGA configuration, QSPI, Crypto and warm reset.

When the FPGA is configured from HPS, there needs to be a way for HPS to notify SDM the location and size of the configuration data. Then SDM will get the configuration data from that location and perform the FPGA configuration.

To meet the whole system security needs and support virtual machine requesting communication with SDM, only the secure world of software (EL3, Exception Level 3) can interface with SDM. All software entities running on other exception levels must channel through the EL3 software whenever it needs service from SDM.

Intel Stratix10 service layer driver is added to provide the service for FPGA configuration. Running at privileged exception level (EL1, Exception Level 1), Intel Stratix10 service layer driver interfaces with the service provider at EL1 (Intel Stratix10 FPGA Manager) and manages secure monitor call (SMC) to communicate with secure monitor software at secure monitor exception level (EL3).

Later the Intel Stratix10 service layer driver will be extended to provide services for QSPI, Crypto and warm reset.

Richard Gong (1):
driver: misc: add Intel Stratix10 service layer driver

 drivers/misc/Kconfig                       |   3 +-
 drivers/misc/Makefile                      |   3 +-
 drivers/misc/intel-service/Kconfig         |   9 +
 drivers/misc/intel-service/Makefile        |   2 +
 drivers/misc/intel-service/intel_service.c | 703 +++++++++++++++++++++++++++++
 include/linux/intel-service-client.h       | 227 ++++++++++
 include/linux/intel-service.h              | 122 +++++
 include/linux/intel-smc.h                  | 246 ++++++++++
 8 files changed, 1313 insertions(+), 2 deletions(-)
 create mode 100644 drivers/misc/intel-service/Kconfig
 create mode 100644 drivers/misc/intel-service/Makefile
 create mode 100644 drivers/misc/intel-service/intel_service.c
 create mode 100644 include/linux/intel-service-client.h
 create mode 100644 include/linux/intel-service.h
 create mode 100644 include/linux/intel-smc.h
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 driver: misc: add Intel Stratix10 service layer driver

From: Richard Gong <[email protected]>

Intel Stratix10 SoC is composed of a 64 bit quad-core ARM Cortex A53 hard processor system (HPS) and Secure Device Manager (SDM). SDM is the hardware which does the FPGA configuration, QSPI, Crypto and warm reset.

When the FPGA is configured from HPS, there needs to be a way for HPS to notify SDM the location and size of the configuration data. Then SDM will get the configuration data from that location and perform the FPGA configuration.

To meet the whole system security needs and support virtual machine requesting communication with SDM, only the secure world of software (EL3, Exception Level 3) can interface with SDM. All software entities running on other exception levels must channel through the EL3 software whenever it needs service from SDM.

Intel Stratix10 service layer driver is added to provide the service for FPGA configuration. Running at privileged exception level (EL1, Exception Level 1), Intel Stratix10 service layer driver interfaces with the service provider at EL1 (Intel Stratix10 FPGA Manager) and manages secure monitor call (SMC) to communicate with secure monitor software at secure monitor exception level (EL3).

---
 drivers/misc/Kconfig                       |   3 +-
 drivers/misc/Makefile                      |   3 +-
 drivers/misc/intel-service/Kconfig         |   9 +
 drivers/misc/intel-service/Makefile        |   2 +
 drivers/misc/intel-service/intel_service.c | 703 +++++++++++++++++++++++++++++
 include/linux/intel-service-client.h       | 227 ++++++++++
 include/linux/intel-service.h              | 122 +++++
 include/linux/intel-smc.h                  | 246 ++++++++++
 8 files changed, 1313 insertions(+), 2 deletions(-)
 create mode 100644 drivers/misc/intel-service/Kconfig
 create mode 100644 drivers/misc/intel-service/Makefile
 create mode 100644 drivers/misc/intel-service/intel_service.c
 create mode 100644 include/linux/intel-service-client.h
 create mode 100644 include/linux/intel-service.h
 create mode 100644 include/linux/intel-smc.h
drivers/misc/Kconfig +2 -1
index 4c842e8..eaca4bb 100644
@@ -1,4 +1,4 @@
-#
+# SPDX-License-Identifier: GPL-2.0
 # Misc strange devices
 #
 
@@ -528,6 +528,7 @@ source "drivers/misc/eeprom/Kconfig"
 source "drivers/misc/cb710/Kconfig"
 source "drivers/misc/ti-st/Kconfig"
 source "drivers/misc/lis3lv02d/Kconfig"
+source "drivers/misc/intel-service/Kconfig"
 source "drivers/misc/altera-stapl/Kconfig"
 source "drivers/misc/mei/Kconfig"
 source "drivers/misc/vmw_vmci/Kconfig"
drivers/misc/Makefile +2 -1
index e07c116..6ee779d 100644
@@ -1,4 +1,4 @@
-#
+# SPDX-License-Identifier: GPL-2.0
 # Makefile for misc devices that really don't fit anywhere else.
 #
 
@@ -58,6 +58,7 @@ obj-$(CONFIG_CXL_BASE)		+= cxl/
 obj-$(CONFIG_ASPEED_LPC_CTRL)	+= aspeed-lpc-ctrl.o
 obj-$(CONFIG_ASPEED_LPC_SNOOP)	+= aspeed-lpc-snoop.o
 obj-$(CONFIG_PCI_ENDPOINT_TEST)	+= pci_endpoint_test.o
+obj-$(CONFIG_INTEL_SERVICE)    	+= intel-service/
 
 lkdtm-$(CONFIG_LKDTM)		+= lkdtm_core.o
 lkdtm-$(CONFIG_LKDTM)		+= lkdtm_bugs.o
drivers/misc/intel-service/Kconfig new file +9 -0
new file mode 100644
index 0000000..69ce397
@@ -0,0 +1,9 @@
+# SPDX-License-Identifier: GPL-2.0
+config INTEL_SERVICE
+	tristate "Intel Service Controller"
+	default y
+	depends on ARCH_STRATIX10
+	help
+	 An implementation of Intel service controller. It is used to provide service to
+	 FPGA manager on Intel Stratix 10 SOC for FPGA configuration. Say Y here if you
+	 want Intel service controller support
drivers/misc/intel-service/Makefile new file +2 -0
new file mode 100644
index 0000000..9509b91
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0
+obj-y += intel_service.o
drivers/misc/intel-service/intel_service.c new file +703 -0

703 lines not on this page · raw message

include/linux/intel-service-client.h new file +227 -0

227 lines not on this page · raw message

include/linux/intel-service.h new file +122 -0

122 lines not on this page · raw message

include/linux/intel-smc.h new file +246 -0

246 lines not on this page · raw message

Signature · 1 line
2.7.4
maintainer
#2 lore raw

Re: [PATCHv1] driver: misc: add Intel Stratix10 service layer driver

drivers/misc/Kconfig source "drivers/misc/eeprom/Kconfig"

Quoted 11 lines · On Thu, Jan 25, 2018 at 10:39:04AM -0600, [email protected] wrote:
drivers/misc/Kconfig +1 -1
index 4c842e8..eaca4bb 100644
@@ -1,4 +1,4 @@
-#
+# SPDX-License-Identifier: GPL-2.0
 # Misc strange devices
 #
 
@@ -528,6 +528,7 @@ source "drivers/misc/eeprom/Kconfig"

Why do this?

maintainer
#3 lore raw

Re: [PATCHv1] driver: misc: add Intel Stratix10 service layer driver

In reply to [email protected]

drivers/misc/intel-service/Kconfig line 4

Quoted 7 lines · On Thu, Jan 25, 2018 at 10:39:04AM -0600, [email protected] wrote:
drivers/misc/intel-service/Kconfig new file +4 -0
@@ -0,0 +1,9 @@
+# SPDX-License-Identifier: GPL-2.0
+config INTEL_SERVICE
+	tristate "Intel Service Controller"
+	default y

Unless the machine can not boot without it, it needs to be 'default n' or no default at all (which is default n).

drivers/misc/intel-service/Kconfig line 5

Quoted 1 line
drivers/misc/intel-service/Kconfig new file +1 -0
+	depends on ARCH_STRATIX10

Why can this not be built on any other configuration? Why not test built at the least?

drivers/misc/intel-service/Kconfig line 1

Quoted 3 lines
drivers/misc/intel-service/Kconfig new file +2 -0
+++ b/drivers/misc/intel-service/intel_service.c
@@ -0,0 +1,703 @@
+// SPDX-License-Identifier: GPL-2.0

Ok, you use SPDX, but then you do this:

Quoted 4 lines
drivers/misc/intel-service/Kconfig new file +4 -0
+/*
+ * Copyright (C) 2017-2018, Intel Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify

drivers/misc/intel-service/Kconfig line 15

Quoted 10 lines
drivers/misc/intel-service/Kconfig new file +10 -0
+ * it under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see <http://www.gnu.org/licenses/>.

Nothing except that copyright line needs to be there. Please delete the rest of the boilerplate crud.

thanks,

greg k-h

maintainer
#4 lore raw

Re: [PATCHv1] driver: misc: add Intel Stratix10 service layer driver

In reply to [email protected]

drivers/misc/intel-service/intel_service.c line 44

Quoted 5 lines · On Thu, Jan 25, 2018 at 10:39:04AM -0600, [email protected] wrote:
drivers/misc/intel-service/intel_service.c new file +5 -0
+static LIST_HEAD(svc_cons);
+static LIST_HEAD(svc_private_mem);
+static DEFINE_MUTEX(svc_mutex);
+
+svc_invoke_fn *invoke_fn;

A global variable for a single .c file? No.

Quoted 22 lines
drivers/misc/intel-service/intel_service.c new file +22 -0
+
+struct intel_svc_chan *request_svc_channel_byname(
+	struct intel_svc_client *client, const char *name)
+{
+	struct device *dev = client->dev;
+	struct intel_svc_controller *controller;
+	struct intel_svc_chan *chan;
+	unsigned long flag;
+	int i;
+
+	chan = ERR_PTR(-EPROBE_DEFER);
+	controller = list_first_entry(&svc_cons,
+				      struct intel_svc_controller, node);
+	for (i = 0; i < SVC_MAX_CHANNEL; i++) {
+		if (!strcmp(controller->chans[i].name, name)) {
+			chan = &controller->chans[i];
+			break;
+		}
+	}
+
+	if (chan->scl || !try_module_get(controller->dev->driver->owner)) {
+		dev_dbg(dev, "%s: svc not free\n", __func__);

drivers/misc/intel-service/intel_service.c line 76

Quoted 10 lines
drivers/misc/intel-service/intel_service.c new file +10 -0
+		return ERR_PTR(-EBUSY);
+	}
+
+	spin_lock_irqsave(&chan->lock, flag);
+	chan->scl = client;
+	spin_unlock_irqrestore(&chan->lock, flag);
+
+	return chan;
+}
+EXPORT_SYMBOL_GPL(request_svc_channel_byname);

Exporting functions with no users? No.

Please fix up and make this stand-alone. Or, if you are going to have framework that others use, then submit those others at the same time.

I'm stopping reviewing here, sorry.

Please fix up and resend.

Also, please get some signed-off-by: from some internal Intel people. Don't rely on me to do this type of work when you have lots of good people inside that could have told you all of this already. Without other developer's sign-offs, I'm not going to look at future submissions, sorry.

thanks,

greg k-h

#5 lore raw

Re: [PATCHv1] driver: misc: add Intel Stratix10 service layer driver

In reply to [email protected]
Quoted 49 lines · On 01/25/2018 08:39 AM, [email protected] wrote:

From: Richard Gong <[email protected]>

---
 drivers/misc/Kconfig                       |   3 +-
 drivers/misc/Makefile                      |   3 +-
 drivers/misc/intel-service/Kconfig         |   9 +
 drivers/misc/intel-service/Makefile        |   2 +
 drivers/misc/intel-service/intel_service.c | 703 +++++++++++++++++++++++++++++
 include/linux/intel-service-client.h       | 227 ++++++++++
 include/linux/intel-service.h              | 122 +++++
 include/linux/intel-smc.h                  | 246 ++++++++++
 8 files changed, 1313 insertions(+), 2 deletions(-)
 create mode 100644 drivers/misc/intel-service/Kconfig
 create mode 100644 drivers/misc/intel-service/Makefile
 create mode 100644 drivers/misc/intel-service/intel_service.c
 create mode 100644 include/linux/intel-service-client.h
 create mode 100644 include/linux/intel-service.h
 create mode 100644 include/linux/intel-smc.h
drivers/misc/intel-service/intel_service.c new file +21 -0
new file mode 100644
index 0000000..90f883c
@@ -0,0 +1,703 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2017-2018, Intel Corporation
 
+
+#include <linux/bitops.h>
+#include <linux/completion.h>
+#include <linux/delay.h>
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/intel-service.h>
+#include <linux/intel-service-client.h>
+#include <linux/intel-smc.h>
+#include <linux/interrupt.h>
+#include <linux/io.h>
+#include <linux/kthread.h>
+#include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/of_address.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>

drivers/misc/intel-service/intel_service.c line 44

Quoted 10 lines
drivers/misc/intel-service/intel_service.c new file +10 -0
+#include <linux/spinlock.h>
+
+#define SVC_FO_LEN	32
+#define SVC_MAX_CHANNEL	2
+
+static LIST_HEAD(svc_cons);
+static LIST_HEAD(svc_private_mem);
+static DEFINE_MUTEX(svc_mutex);
+
+svc_invoke_fn *invoke_fn;

Is that calling into firmware or what?

drivers/misc/intel-service/intel_service.c line 271

Quoted 3 lines
drivers/misc/intel-service/intel_service.c new file +3 -0
+	/* timeout for polling FPGA configuration status
+	 * it is set to 30 seconds (30 * 1000) at Intel Stratix10 SoC
+	 */

Fix multi-line comment style (several places).

Quoted 6 lines
include/linux/intel-service-client.h new file +0 -0
new file mode 100644
index 0000000..5bb6513

include/linux/intel-service-client.h line 8

Quoted 8 lines
include/linux/intel-service-client.h new file +8 -0
@@ -0,0 +1,227 @@
+
+#ifndef __INTEL_SERVICE_CLIENT_H
+#define __INTEL_SERVICE_CLIENT_H
+
+#include <linux/of.h>
+#include <linux/device.h>
+
+/**

In kernel source files, /** means that the following is a kernel-doc formatted comment. This is close, but not quite. Others also are just close.

include/linux/intel-service-client.h line 32

Quoted 8 lines
include/linux/intel-service-client.h new file +8 -0
+ * Service driver supports client names
+ * @fpga: for FPGA configuration
+ * @dummy: for integration/debug/trouble-shooting
+ */
+#define SVC_CLIENT_FPGA		"fpga"
+#define SVC_CLIENT_DUMMY	"dummy"
+
+/**

Hm, these comments would be close to kernel-doc notation for an enum type, but not for a list of #defines.

Quoted 37 lines
include/linux/intel-service-client.h new file +26 -0
+ * Status of the sent command, in bit number
+ * @SVC_COMMAND_STATUS_RECONFIG_REQUEST_OK
+ *	SDM accepts the request of FPGA reconfiguration
+ * @SVC_STATUS_RECONFIG_BUFFER_SUBMITTED
+ *	Service client successfully submits FPGA configuration
+ *	data buffer to SDM
+ * @SVC_COMMAND_STATUS_RECONFIG_BUFFER_DONE
+ *	SDM completes data process, ready to accept the
+ *      next WRITE transaction
+ * @SVC_COMMAND_STATUS_RECONFIG_COMPLETED
+ *	SDM completes FPGA configuration successfully, FPGA should
+ *	be in user mode
+ * @SVC_COMMAND_STATUS_RECONFIG_BUSY
+ *	FPGA configuration is still in process
+ * @SVC_COMMAND_STATUS_RECONFIG_ERROR
+ *	Error encountered during FPGA configuration
+ */
+#define SVC_STATUS_RECONFIG_REQUEST_OK		0
+#define SVC_STATUS_RECONFIG_BUFFER_SUBMITTED	1
+#define SVC_STATUS_RECONFIG_BUFFER_DONE		2
+#define SVC_STATUS_RECONFIG_COMPLETED		3
+#define SVC_STATUS_RECONFIG_BUSY			4
+#define SVC_STATUS_RECONFIG_ERROR			5
+
+struct intel_svc_chan;
+
include/linux/intel-service.h new file +4 -0
new file mode 100644
index 0000000..fdf21b3
@@ -0,0 +1,122 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef __INTEL_SERVICE_H
+#define __INTEL_SERVICE_H

include/linux/intel-service.h line 14

Quoted 10 lines
include/linux/intel-service.h new file +10 -0
+
+#include <linux/of.h>
+#include <linux/types.h>
+#include <linux/device.h>
+#include <linux/kfifo.h>
+#include <linux/genalloc.h>
+#include <linux/arm-smccc.h>
+
+
+/**

Ah, this one is formatted correctly as kernel-doc.

Quoted 24 lines
include/linux/intel-service.h new file +24 -0
+ * struct intel_svc_sh_memory - service shared memory info
+ *
+ * @sync_complete: maintain state for a completion
+ * @start_addr: starting address of shared memory
+ * @size: size of shared memory
+ */
+struct intel_svc_sh_memory {
+	struct completion sync_complete;
+	unsigned long start_addr;
+	unsigned long size;
+};
+
+/**
+ * struct intel_svc_private_mem - service private memory info
+ *
+ * @kaddr: virtual address
+ * @paddr: physical address
+ * @size: size of memory
+ * @node: link list head node
+ */
+struct intel_svc_private_mem {
+	void *kaddr;
+	phys_addr_t paddr;
+	size_t size;

include/linux/intel-service.h line 70

Quoted 10 lines
include/linux/intel-service.h new file +10 -0
+	struct list_head node;
+};
+
+/**
+ * struct intel_svc_private_data - service private data
+ *
+ * @chan: service channel
+ * @paddr: play-load physical address
+ * @size: play-load size
+ * @ommand: service request command

@command:

Quoted 5 lines
include/linux/intel-service.h new file +5 -0
+ */
+struct intel_svc_private_data {
+	struct intel_svc_chan *chan;
+	phys_addr_t paddr;
+	size_t size;

include/linux/intel-service.h line 85

Quoted 10 lines
include/linux/intel-service.h new file +10 -0
+	u32 command;
+};
+
+/**
+ * struct intel_svc_controller - service controller
+ *
+ * @dev: device backing this controller
+ * @chans: array of service channels
+ * $num_chans: number of channels in 'chans' array
+ * @node: list management

missing 2 entries.

Quoted 14 lines
include/linux/intel-service.h new file +14 -0
+ * @intel_svc_fifo: a queue for storing service message data
+ * @svc_fifo_lock: protect access to service message data queue
+ */
+struct intel_svc_controller {
+	struct device *dev;
+	struct intel_svc_chan *chans;
+	int num_chans;
+
+	struct list_head node;
+
+	struct gen_pool *genpool;
+	struct intel_svc_prviate_mem *private_mem;
+
+	DECLARE_KFIFO_PTR(intel_svc_fifo, struct intel_svc_private_data *);

include/linux/intel-service.h line 109

Quoted 10 lines
include/linux/intel-service.h new file +10 -0
+	/* protect access to the service message data queue*/
+	spinlock_t svc_fifo_lock;
+};
+
+/**
+ * struct intel_svc_chan - service communication channel
+ *
+ * @ctrl: pointer to the provider of this channel
+ * @scl: pointer to service client which owns this channel
+ * $name: name associated with this service channel
      @name:
Quoted 13 lines
include/linux/intel-service.h new file +13 -0
+ * @lock: protect access to the channel
+ */
+struct intel_svc_chan {
+	struct intel_svc_controller *ctrl;
+	struct intel_svc_client *scl;
+	char *name;
+	/* protect access to the channel*/
+	spinlock_t lock;
+};
+
+static int intel_svc_smc_thread(void *data);
+
+#endif
Signature · 1 line
~Randy
maintainer
#6 lore raw
In reply to [email protected]
Quoted 29 lines · On Thu, Jan 25, 2018 at 10:39:03AM -0600, [email protected] wrote:

From: Richard Gong <[email protected]>

Intel Stratix10 SoC is composed of a 64 bit quad-core ARM Cortex A53 hard processor system (HPS) and Secure Device Manager (SDM). SDM is the hardware which does the FPGA configuration, QSPI, Crypto and warm reset.

When the FPGA is configured from HPS, there needs to be a way for HPS to notify SDM the location and size of the configuration data. Then SDM will get the configuration data from that location and perform the FPGA configuration.

To meet the whole system security needs and support virtual machine requesting communication with SDM, only the secure world of software (EL3, Exception Level 3) can interface with SDM. All software entities running on other exception levels must channel through the EL3 software whenever it needs service from SDM.

Intel Stratix10 service layer driver is added to provide the service for FPGA configuration. Running at privileged exception level (EL1, Exception Level 1), Intel Stratix10 service layer driver interfaces with the service provider at EL1 (Intel Stratix10 FPGA Manager) and manages secure monitor call (SMC) to communicate with secure monitor software at secure monitor exception level (EL3).

Later the Intel Stratix10 service layer driver will be extended to provide services for QSPI, Crypto and warm reset.

Richard Gong (1):
driver: misc: add Intel Stratix10 service layer driver

Quoted 8 lines
 drivers/misc/Kconfig                       |   3 +-
 drivers/misc/Makefile                      |   3 +-
 drivers/misc/intel-service/Kconfig         |   9 +
 drivers/misc/intel-service/Makefile        |   2 +
 drivers/misc/intel-service/intel_service.c | 703 +++++++++++++++++++++++++++++
 include/linux/intel-service-client.h       | 227 ++++++++++
 include/linux/intel-service.h              | 122 +++++
 include/linux/intel-smc.h                  | 246 ++++++++++

Simple questions first:
- why do you have 3 different .h files for a single .c file?
- why do you have any public .h files for a single .c file?
- use the correct SPDX markers for your file licenses, Intel legal knows all about this, please follow their rules.
- why is this in a subdirectory for a single .c file?

thanks,

greg k-h

#7 lore raw

Hi Greg,

Many thanks for your reviews.

Quoted 38 lines · Greg KH
Quoted 29 lines · On Thu, Jan 25, 2018 at 10:39:03AM -0600, [email protected] wrote:

From: Richard Gong <[email protected]>

Intel Stratix10 SoC is composed of a 64 bit quad-core ARM Cortex A53 hard processor system (HPS) and Secure Device Manager (SDM). SDM is the hardware which does the FPGA configuration, QSPI, Crypto and warm reset.

When the FPGA is configured from HPS, there needs to be a way for HPS to notify SDM the location and size of the configuration data. Then SDM will get the configuration data from that location and perform the FPGA configuration.

To meet the whole system security needs and support virtual machine requesting communication with SDM, only the secure world of software (EL3, Exception Level 3) can interface with SDM. All software entities running on other exception levels must channel through the EL3 software whenever it needs service from SDM.

Intel Stratix10 service layer driver is added to provide the service for FPGA configuration. Running at privileged exception level (EL1, Exception Level 1), Intel Stratix10 service layer driver interfaces with the service provider at EL1 (Intel Stratix10 FPGA Manager) and manages secure monitor call (SMC) to communicate with secure monitor software at secure monitor exception level (EL3).

Later the Intel Stratix10 service layer driver will be extended to provide services for QSPI, Crypto and warm reset.

Richard Gong (1):
driver: misc: add Intel Stratix10 service layer driver

Quoted 8 lines
  drivers/misc/Kconfig                       |   3 +-
  drivers/misc/Makefile                      |   3 +-
  drivers/misc/intel-service/Kconfig         |   9 +
  drivers/misc/intel-service/Makefile        |   2 +
  drivers/misc/intel-service/intel_service.c | 703 +++++++++++++++++++++++++++++
  include/linux/intel-service-client.h       | 227 ++++++++++
  include/linux/intel-service.h              | 122 +++++
  include/linux/intel-smc.h                  | 246 ++++++++++
Quoted 2 lines

Simple questions first:
- why do you have 3 different .h files for a single .c file?

This is because service layer driver interface with both the service provider and secure monitor SW.
intel-service-client.h is created to define interface between service providers (FPGA manager is one of them) and service layer. Alan Tull's FPGA manager .c file includes this header file
intel-smc.h defines the secure monitor call (SMC) message protocols used for service layer driver in normal world (EL1) to communicate with secure monitor SW in secure monitor exception level 3 (EL3). Also this header file is shared with firmware since both (FW, service layer) utilizes the same SMC message protocol. intel-sevice.h is created to define service layer's own data structures (service controller, channel for communicating with service provider, shared memory region, private data etc)

Quoted 1 line

- why do you have any public .h files for a single .c file?

intel-service-client.h is public .h and should be at include/linux/
intel-service.h and intel-smc.h are private .h files, should be in driver/misc/ (assume I move .c file from driver/misc/intel-service/ to driver/misc/)

Quoted 2 lines

- use the correct SPDX markers for your file licenses, Intel legal knows all about this, please follow their rules.

I will follow those rules.

Quoted 1 line

- why is this in a subdirectory for a single .c file?

Currently service layer is implemented to support FPGA configuration only. We have the new requirements and need to extend service layer to support additional features such as QSPI, Crypto and warm reset. It is expected that a few new files will be added later. For now I can move the single .c file from driver/misc/intel-service/ to driver/misc/.

Regards,
Richard

Quoted 3 lines

thanks,

greg k-h

maintainer
#8 lore raw
Quoted 46 lines · Richard Gong

Hi Greg,

Many thanks for your reviews.

Quoted 38 lines · Greg KH
Quoted 29 lines · On Thu, Jan 25, 2018 at 10:39:03AM -0600, [email protected] wrote:

From: Richard Gong <[email protected]>

Intel Stratix10 SoC is composed of a 64 bit quad-core ARM Cortex A53 hard processor system (HPS) and Secure Device Manager (SDM). SDM is the hardware which does the FPGA configuration, QSPI, Crypto and warm reset.

When the FPGA is configured from HPS, there needs to be a way for HPS to notify SDM the location and size of the configuration data. Then SDM will get the configuration data from that location and perform the FPGA configuration.

To meet the whole system security needs and support virtual machine requesting communication with SDM, only the secure world of software (EL3, Exception Level 3) can interface with SDM. All software entities running on other exception levels must channel through the EL3 software whenever it needs service from SDM.

Intel Stratix10 service layer driver is added to provide the service for FPGA configuration. Running at privileged exception level (EL1, Exception Level 1), Intel Stratix10 service layer driver interfaces with the service provider at EL1 (Intel Stratix10 FPGA Manager) and manages secure monitor call (SMC) to communicate with secure monitor software at secure monitor exception level (EL3).

Later the Intel Stratix10 service layer driver will be extended to provide services for QSPI, Crypto and warm reset.

Richard Gong (1):
driver: misc: add Intel Stratix10 service layer driver

Quoted 8 lines
  drivers/misc/Kconfig                       |   3 +-
  drivers/misc/Makefile                      |   3 +-
  drivers/misc/intel-service/Kconfig         |   9 +
  drivers/misc/intel-service/Makefile        |   2 +
  drivers/misc/intel-service/intel_service.c | 703 +++++++++++++++++++++++++++++
  include/linux/intel-service-client.h       | 227 ++++++++++
  include/linux/intel-service.h              | 122 +++++
  include/linux/intel-smc.h                  | 246 ++++++++++
Quoted 2 lines

Simple questions first:
- why do you have 3 different .h files for a single .c file?

Quoted 13 lines

This is because service layer driver interface with both the service provider and secure monitor SW.
intel-service-client.h is created to define interface between service providers (FPGA manager is one of them) and service layer. Alan Tull's FPGA manager .c file includes this header file
intel-smc.h defines the secure monitor call (SMC) message protocols used for service layer driver in normal world (EL1) to communicate with secure monitor SW in secure monitor exception level 3 (EL3). Also this header file is shared with firmware since both (FW, service layer) utilizes the same SMC message protocol.
intel-sevice.h is created to define service layer's own data structures (service controller, channel for communicating with service provider, shared memory region, private data etc)

That's very complex for a single patch submission, don't you think?

Please do not add new apis / interfaces for code that is not part of your patch series, otherwise we don't know what the future is going to hold :)

This feels like it should be a series of patches, to properly explain this and hook up all of the new interfaces you are adding, right?

thanks,

greg k-h

#9 lore raw
Quoted 61 lines · Greg KH
Quoted 46 lines · Richard Gong

Hi Greg,

Many thanks for your reviews.

Quoted 38 lines · Greg KH
Quoted 29 lines · On Thu, Jan 25, 2018 at 10:39:03AM -0600, [email protected] wrote:

From: Richard Gong <[email protected]>

Intel Stratix10 SoC is composed of a 64 bit quad-core ARM Cortex A53 hard processor system (HPS) and Secure Device Manager (SDM). SDM is the hardware which does the FPGA configuration, QSPI, Crypto and warm reset.

When the FPGA is configured from HPS, there needs to be a way for HPS to notify SDM the location and size of the configuration data. Then SDM will get the configuration data from that location and perform the FPGA configuration.

To meet the whole system security needs and support virtual machine requesting communication with SDM, only the secure world of software (EL3, Exception Level 3) can interface with SDM. All software entities running on other exception levels must channel through the EL3 software whenever it needs service from SDM.

Intel Stratix10 service layer driver is added to provide the service for FPGA configuration. Running at privileged exception level (EL1, Exception Level 1), Intel Stratix10 service layer driver interfaces with the service provider at EL1 (Intel Stratix10 FPGA Manager) and manages secure monitor call (SMC) to communicate with secure monitor software at secure monitor exception level (EL3).

Later the Intel Stratix10 service layer driver will be extended to provide services for QSPI, Crypto and warm reset.

Richard Gong (1):
driver: misc: add Intel Stratix10 service layer driver

Quoted 8 lines
  drivers/misc/Kconfig                       |   3 +-
  drivers/misc/Makefile                      |   3 +-
  drivers/misc/intel-service/Kconfig         |   9 +
  drivers/misc/intel-service/Makefile        |   2 +
  drivers/misc/intel-service/intel_service.c | 703 +++++++++++++++++++++++++++++
  include/linux/intel-service-client.h       | 227 ++++++++++
  include/linux/intel-service.h              | 122 +++++
  include/linux/intel-smc.h                  | 246 ++++++++++
Quoted 2 lines

Simple questions first:
- why do you have 3 different .h files for a single .c file?

Quoted 13 lines

This is because service layer driver interface with both the service provider and secure monitor SW.
intel-service-client.h is created to define interface between service providers (FPGA manager is one of them) and service layer. Alan Tull's FPGA manager .c file includes this header file
intel-smc.h defines the secure monitor call (SMC) message protocols used for service layer driver in normal world (EL1) to communicate with secure monitor SW in secure monitor exception level 3 (EL3). Also this header file is shared with firmware since both (FW, service layer) utilizes the same SMC message protocol.
intel-sevice.h is created to define service layer's own data structures (service controller, channel for communicating with service provider, shared memory region, private data etc)

Quoted 1 line

That's very complex for a single patch submission, don't you think?

Hi Greg,

I'm reviewing this patchset now. v2 will simplify things down and add better documentation. Only 2 headers (one for the client API and one to define the interface with the out of tree code this talks to).

Quoted 4 lines

Please do not add new apis / interfaces for code that is not part of your patch series, otherwise we don't know what the future is going to hold :)

The v2 patch set will include my FPGA manager driver which is the first client of this service. My driver will use all the API functions exported by this service driver.

Quoted 3 lines

This feels like it should be a series of patches, to properly explain this and hook up all of the new interfaces you are adding, right?

There will be other clients, so there will be other patchsets on top of this. We'll be sure to include new API functions and the client that needs them in the same patch set in the future.

Thanks for your feedback, helpful as always!

Alan

Quoted 4 lines

thanks,

greg k-h