Skip to contentSkip to conversation

Add Intel Stratix10 FPGA manager and service layer

PATCH New [email protected] 1 participant 9 messages Nov 13, 2018

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

v11 cover Add Intel Stratix10 FPGA manager and service layer

From: Richard Gong <[email protected]>

This is the 11th submission of Intel Stratix10 service layer and FPGA manager driver patches. Starting from 10th submission Stratix10 service layer driver .c file is moved to drivers/firmware, header files is moved to include/linux/firmware/intel. And other firmware interface includes Stratix10 service layer document.

Stratix10 service layer patches have been reviewed internally by Alan Tull and other colleagues at Intel.

Some features of the Intel Stratix10 SoC require a level of privilege higher than the kernel is granted. Such secure features include FPGA programming, remote status update, read and write the secure registers. In terms of the ARMv8 architecture, the kernel runs at Exception Level 1 (EL1), access to the features requires Exception Level 3 (EL3).

The Intel Stratix10 service layer provides kernel APIs for drivers to request access to the secure features. The requests are queued and processed one by one. ARM’s SMCCC is used to pass the execution of the requests on to a secure monitor (EL3).

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

v2: add patches for FPGA manager, FPGA manager binding, dts and defconfig
remove intel-service subdirectory and intel-service.h, move intel-smc.h and intel-service.c to driver/misc subdirectory.
remove global variables.
change service layer driver be 'default n'.
correct SPDX markers.
add timeout for do..while() loop.
add kernel-doc for the functions and structs, correct multiline comments.
replace kfifo_in and kfifo_out with kfifo_in_spinlocked and kfifo_out_spinlocked.
rename struct intel_svc_data (at client header) to intel_svc_client_msg.
rename struct intel_svc_private_mem to intel_svc_data. other corrections/changes from Intel internal code reviews.
v3: change all exported functions with "intel_svc_" as the prefix.
increase timeout values for claiming back submitted buffer(s). rename struct intel_command_reconfig_payload to
struct intel_svc_command_reconfig_payload.
add pr_err() to provide the error return value.
change to put fpga_mgr node under firmware/svc node.
change to FPGA manager to align the update of service client APIs, and the update of fpga_mgr device node.
Other corrections/changes.
v4: s/intel/stratix10/ on some variables, structs, functions, and file
names intel-service.c -> stratix10-svc.c
intel-smc.h -> stratix10-smc.h
intel-service-client.h -> stratix10-svc-client.h.
remove non-kernel-doc formatting.
s/fpga-mgr@0/fpga-mgr/ to remove unit_address at fpga_mgr node. add Rob's Reviewed-by.
add Richard's signed-off-by.
v5: add a new API statix10_svc_done() which is called by service client
when client request is completed or error occurs during request process. Which allows service layer to free its resources. remove dummy client from service layer client header and service layer source file.
add Rob's Reviewed-by.
add a new file stratix10-svc.rst and add that to driver-api/index.rst. kernel-doc fixes.
v6: replace kthread_create_on_cpu() with kthread_create_on_node().
extend stratix_svc_send() to support service client which doesn't use memory allocated by service layer.
add S10_RECONFIG_TIMEOUT.
rename s/S10_BUF_TIMEOUT/S10_BUFFER_TIMEOUT/.
fix service layer and FPGA manager Klocwork errors.
v7: add remote status update client support.
s/pr_debug/dev_dbg, s/dev_info/dev_dbg.
add unlock buffer if s10_svc_send_msg() fails.
add release channel if fpga_mgr_create() fails.
handle invalid pointer at svc if the client passed an invalid name.
v8: move stratix10-smc.h to include/linux from driver/misc.
revert version 7 error code & smc function ID value changes at stratix10-smc.h.
add a goto and common error handling at the end of fpga driver's. probe function.
v9: remove a patch on defconfig for enable service layer and FPGA manager.
resolve a issue found at git-bisect test.
remove kernel-doc markups that aren't being built.
v10:move stratix10-smc.h and stratix10-svc-client.h to
include/linux/firmware/intel.
move stratix10-svc.c to drivers/firmware. s/STRATIX10_SERVICE/INTEL_STRATIX10_SERVICE, fix a Klocwork error at service layer driver. s/stratix10_svc_command_reconfig_payload/ stratix10_svc_command_config_type.
add stratix10 service layer document to other firmware interface. update path for the included header in Stratix10 FPGA manager driver.
v11:add Acked-by Moritz Fischer
add additional space at Kconfig file's help text
fix a type in commit message from patch #8

Alan Tull (3):
dt-bindings: fpga: add Stratix10 SoC FPGA manager binding
arm64: dts: stratix10: add fpga manager and region
fpga: add intel stratix10 soc fpga manager driver

Richard Gong (5):
dt-bindings, firmware: add Intel Stratix10 service layer binding
arm64: dts: stratix10: add stratix10 service driver binding to base
dtsi
firmware: add Intel Stratix10 service layer driver
Documentation: driver-api: add stratix10 service layer
firmware: add remote status update client support

 .../bindings/firmware/intel,stratix10-svc.txt      |   57 ++
 .../bindings/fpga/intel-stratix10-soc-fpga-mgr.txt |   17 +
 .../driver-api/firmware/other_interfaces.rst       |   30 +
 arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi  |   33 +
 drivers/firmware/Kconfig                           |   12 +
 drivers/firmware/Makefile                          |    1 +
 drivers/firmware/stratix10-svc.c                   | 1044 ++++++++++++++++++++
 drivers/fpga/Kconfig                               |    6 +
 drivers/fpga/Makefile                              |    1 +
 drivers/fpga/stratix10-soc.c                       |  535 ++++++++++
 include/linux/firmware/intel/stratix10-smc.h       |  312 ++++++
 .../linux/firmware/intel/stratix10-svc-client.h    |  217 ++++
 12 files changed, 2265 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/firmware/intel,stratix10-svc.txt
 create mode 100644 Documentation/devicetree/bindings/fpga/intel-stratix10-soc-fpga-mgr.txt
 create mode 100644 drivers/firmware/stratix10-svc.c
 create mode 100644 drivers/fpga/stratix10-soc.c
 create mode 100644 include/linux/firmware/intel/stratix10-smc.h
 create mode 100644 include/linux/firmware/intel/stratix10-svc-client.h
Signature · 1 line
2.7.4
#1 lore raw

PATCH v11 1/8 dt-bindings, firmware: add Intel Stratix10 service layer binding

From: Richard Gong <[email protected]>

Add a device tree binding for the Intel Stratix10 service layer driver

---
v2: change to put service layer driver node under the firmware node
change compatible to "intel, stratix10-svc"
v3: no change
v4: add Rob's Reviewed-by
v5: no change
v6: add Moritz's Acked-by
v7: no change
v8: no change
v9: no chnage
v10: no change
v11: no change

---
 .../bindings/firmware/intel,stratix10-svc.txt      | 57 ++++++++++++++++++++++
 1 file changed, 57 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/firmware/intel,stratix10-svc.txt
Documentation/devicetree/bindings/firmware/intel,stratix10-svc.txt new file +57 -0
new file mode 100644
index 0000000..1fa6606
@@ -0,0 +1,57 @@
+Intel Service Layer Driver for Stratix10 SoC
+============================================
+Intel Stratix10 SoC is composed of a 64 bit quad-core ARM Cortex A53 hard
+processor system (HPS) and Secure Device Manager (SDM). 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
+Layer 3) can interface with SDM. All software entities running on other
+exception layers must channel through the EL3 software whenever it needs
+service from SDM.
+
+Intel Stratix10 service layer driver, running at privileged exception level
+(EL1, Exception Layer 1), interfaces with the service providers and provides
+the services for FPGA configuration, QSPI, Crypto and warm reset. Service layer
+driver also manages secure monitor call (SMC) to communicate with secure monitor
+code running in EL3.
+
+Required properties:
+-------------------
+The svc node has the following mandatory properties, must be located under
+the firmware node.
+
+- compatible: "intel,stratix10-svc"
+- method: smc or hvc
+        smc - Secure Monitor Call
+        hvc - Hypervisor Call
+- memory-region:
+	phandle to the reserved memory node. See
+	Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt
+	for details
+
+Example:
+-------
+
+	reserved-memory {
+                #address-cells = <2>;
+                #size-cells = <2>;
+                ranges;
+
+                service_reserved: svcbuffer@0 {
+                        compatible = "shared-dma-pool";
+                        reg = <0x0 0x0 0x0 0x1000000>;
+                        alignment = <0x1000>;
+                        no-map;
+                };
+        };
+
+	firmware {
+		svc {
+			compatible = "intel,stratix10-svc";
+			method = "smc";
+			memory-region = <&service_reserved>;
+		};
+	};
Signature · 1 line
2.7.4
#2 lore raw

PATCH v11 2/8 arm64: dts: stratix10: add stratix10 service driver binding to base dtsi

In reply to [email protected]

From: Richard Gong <[email protected]>

Add Intel Stratix10 service layer to the device tree

---
v2: change to put service layer driver node under the firmware node
change compatible to "intel, stratix10-svc"
v3: no change
v4: s/service driver/stratix10 service driver/ in subject line
v5: no change
v6: add Moritz's Acked-by
v7: no change
v8: no change
v9: no change
v10: no change
v11: no change

---
 arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi +21 -0
index fef7351..519b16e 100644
@@ -24,6 +24,19 @@
 	#address-cells = <2>;
 	#size-cells = <2>;
 
+	reserved-memory {
+		#address-cells = <2>;
+		#size-cells = <2>;
+		ranges;
+
+		service_reserved: svcbuffer@0 {
+			compatible = "shared-dma-pool";
+			reg = <0x0 0x0 0x0 0x1000000>;
+			alignment = <0x1000>;
+			no-map;
+		};
+	};
+
 	cpus {
 		#address-cells = <1>;
 		#size-cells = <0>;
@@ -537,5 +550,13 @@
 
 			status = "disabled";
 		};
+
+		firmware {
+			svc {
+				compatible = "intel,stratix10-svc";
+				method = "smc";
+				memory-region = <&service_reserved>;
+			};
+		};
 	};
 };
Signature · 1 line
2.7.4
#3 lore raw

PATCH v11 3/8 firmware: add Intel Stratix10 service layer driver

In reply to [email protected]

From: Richard Gong <[email protected]>

Some features of the Intel Stratix10 SoC require a level of privilege higher than the kernel is granted. Such secure features include FPGA programming. In terms of the ARMv8 architecture, the kernel runs at Exception Level 1 (EL1), access to the features requires Exception Level 3 (EL3).

The Intel Stratix10 SoC service layer provides an in kernel API for drivers to request access to the secure features. The requests are queued and processed one by one. ARM’s SMCCC is used to pass the execution of the requests on to a secure monitor (EL3).

The header file stratix10-sve-client.h defines the interface between service providers (FPGA manager is one of them) and service layer.

The header file stratix10-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).

---
v2: remove intel-service subdirectory and intel-service.h, move
intel-smc.h and intel-service.c to driver/misc subdirectory correct SPDX markers
change service layer driver be 'default n'
remove global variables
add timeout for do..while() loop
add kernel-doc for the functions and structs, correct multiline comments replace kfifo_in/kfifo_out with kfifo_in_spinlocked/kfifo_out_spinlocked rename struct intel_svc_data (at client header) to intel_svc_client_msg rename struct intel_svc_private_mem to intel_svc_data
Other corrections/changes from Intel internal code reviews
v3: change all exported functions with "intel_svc_" as the prefix
increase timeout values for claiming back submitted buffer(s) rename struct intel_command_reconfig_payload to
struct intel_svc_command_reconfig_payload
add pr_err() to provide the error return value
other corrections/changes
v4: s/intel/stratix10/ on some variables, structs, functions, and file names

    intel-service.c -> stratix10-svc.c
    intel-smc.h -> stratix10-smc.h
    intel-service-client.h -> stratix10-svc-client.h
    remove non-kernel-doc formatting

v5: add a new API statix10_svc_done() which is called by service client
when client request is completed or error occurs during request process. Which allows service layer to free its resources. remove dummy client from service layer client header and service layer source file.
kernel-doc fixes
v6: replace kthread_create_on_cpu() with kthread_create_on_node()
extend stratix_svc_send() to support service client which doesn't use memory allocated by service layer
fix several Klocwork errors
v7: handle invalid pointer if the client passed an invalid name
v8: move stratix10-smc.h to include/linux
revert version 7 error code & smc function ID value changes
at stratix10-smc.h
v9: remove handle for COMMAND_RSU_UPDATE at stratix10-svc.c
remove RSU related definitions at stratix10-smc.h
v10: s/stratix10_svc_command_reconfig_payload/stratix10_svc_command_config_type
move stratix10-smc.h and stratix10-svc-client.h to include/linux/firmware/intel
move stratix10-svc.c to drivers/firmware s/STRATIX10_SERVICE/INTEL_STRATIX10_SERVICE
fix a Klocwork error
v11: add additional space at Kconfig file's help text

---
 drivers/firmware/Kconfig                           |   12 +
 drivers/firmware/Makefile                          |    1 +
 drivers/firmware/stratix10-svc.c                   | 1013 ++++++++++++++++++++
 include/linux/firmware/intel/stratix10-smc.h       |  265 +++++
 .../linux/firmware/intel/stratix10-svc-client.h    |  201 ++++
 5 files changed, 1492 insertions(+)
 create mode 100644 drivers/firmware/stratix10-svc.c
 create mode 100644 include/linux/firmware/intel/stratix10-smc.h
 create mode 100644 include/linux/firmware/intel/stratix10-svc-client.h
drivers/firmware/Kconfig +12 -0
index 7273e50..f754578 100644
@@ -216,6 +216,18 @@ config FW_CFG_SYSFS_CMDLINE
 	  WARNING: Using incorrect parameters (base address in particular)
 	  may crash your system.
 
+config INTEL_STRATIX10_SERVICE
+	tristate "Intel Stratix10 Service Layer"
+	depends on HAVE_ARM_SMCCC
+	default n
+	help
+	  Intel Stratix10 service layer runs at privileged exception level,
+	  interfaces with the service providers (FPGA manager is one of them)
+	  and manages secure monitor call to communicate with secure monitor
+	  software at secure monitor exception level.
+
+	  Say Y here if you want Stratix10 service layer support.
+
 config QCOM_SCM
 	bool
 	depends on ARM || ARM64
drivers/firmware/Makefile +1 -0
index 3158dff..80feb63 100644
@@ -12,6 +12,7 @@ obj-$(CONFIG_DMI_SYSFS)		+= dmi-sysfs.o
 obj-$(CONFIG_EDD)		+= edd.o
 obj-$(CONFIG_EFI_PCDP)		+= pcdp.o
 obj-$(CONFIG_DMIID)		+= dmi-id.o
+obj-$(CONFIG_INTEL_STRATIX10_SERVICE) += stratix10-svc.o
 obj-$(CONFIG_ISCSI_IBFT_FIND)	+= iscsi_ibft_find.o
 obj-$(CONFIG_ISCSI_IBFT)	+= iscsi_ibft.o
 obj-$(CONFIG_FIRMWARE_MEMMAP)	+= memmap.o
drivers/firmware/stratix10-svc.c new file +1013 -0

1,013 lines not on this page · raw message

include/linux/firmware/intel/stratix10-smc.h new file +265 -0

265 lines not on this page · raw message

include/linux/firmware/intel/stratix10-svc-client.h new file +201 -0

201 lines not on this page · raw message

Signature · 1 line
2.7.4
#4 lore raw

PATCH v11 4/8 dt-bindings: fpga: add Stratix10 SoC FPGA manager binding

In reply to [email protected]

From: Alan Tull <[email protected]>

Add a Device Tree binding for the Intel Stratix10 SoC FPGA manager.

---
v2: this patch is added in patch set version 2
v3: change to put fpga_mgr node under firmware/svc node
v4: s/fpga-mgr@0/fpga-mgr/ to remove unit_address
add Richard's signed-off-by
v5: add Reviewed-by Rob Herring
v6: no change
v7: no change
v8: no change
v9: no change
v10: no change
v11: add Moritz Fischer's Acked-by

---
 .../bindings/fpga/intel-stratix10-soc-fpga-mgr.txt      | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/fpga/intel-stratix10-soc-fpga-mgr.txt
Documentation/devicetree/bindings/fpga/intel-stratix10-soc-fpga-mgr.txt new file +17 -0
new file mode 100644
index 0000000..6e03f79
@@ -0,0 +1,17 @@
+Intel Stratix10 SoC FPGA Manager
+
+Required properties:
+The fpga_mgr node has the following mandatory property, must be located under
+firmware/svc node.
+
+- compatible : should contain "intel,stratix10-soc-fpga-mgr"
+
+Example:
+
+	firmware {
+		svc {
+			fpga_mgr: fpga-mgr {
+				compatible = "intel,stratix10-soc-fpga-mgr";
+			};
+		};
+	};
Signature · 1 line
2.7.4
#5 lore raw

PATCH v11 5/8 arm64: dts: stratix10: add fpga manager and region

In reply to [email protected]

From: Alan Tull <[email protected]>

Add the Stratix10 FPGA manager and a FPGA region to the device tree.

---
v2: this patch is added in patch set version 2
v3: change to put fpga_mgr node under firmware/svc node
v4: s/fpga-mgr@0/fpga-mgr/ to remove unit_address
add Richard's signed-off-by
v5: no change
v6: no change
v7: no change
v8: no change
v9: no change
v10: no change
v11: no change

---
 arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi | 12 ++++++++++++
 1 file changed, 12 insertions(+)
arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi +12 -0
index 519b16e..a20df0d 100644
@@ -106,6 +106,14 @@
 		interrupt-parent = <&intc>;
 		ranges = <0 0 0 0xffffffff>;
 
+		base_fpga_region {
+			#address-cells = <0x1>;
+			#size-cells = <0x1>;
+
+			compatible = "fpga-region";
+			fpga-mgr = <&fpga_mgr>;
+		};
+
 		clkmgr: clock-controller@ffd10000 {
 			compatible = "intel,stratix10-clkmgr";
 			reg = <0xffd10000 0x1000>;
@@ -556,6 +564,10 @@
 				compatible = "intel,stratix10-svc";
 				method = "smc";
 				memory-region = <&service_reserved>;
+
+				fpga_mgr: fpga-mgr {
+					compatible = "intel,stratix10-soc-fpga-mgr";
+				};
 			};
 		};
 	};
Signature · 1 line
2.7.4
#6 lore raw

PATCH v11 6/8 fpga: add intel stratix10 soc fpga manager driver

In reply to [email protected]

From: Alan Tull <[email protected]>

Add driver for reconfiguring Intel Stratix10 SoC FPGA devices. This driver communicates through the Intel service layer driver which does communication with privileged hardware (that does the FPGA programming) through a secure mailbox.

---
v2: this patch is added in patch set version 2
v3: change to align to the update of service client APIs, and the
update of fpga_mgr device node
v4: changes to align with stratix10-svc-client API updates
add Richard's signed-off-by
v5: update to align changes at service layer to minimize service
layer thread usages
v6: add S10_RECONFIG_TIMEOUT
rename s/S10_BUF_TIMEOUT/S10_BUFFER_TIMEOUT/
fix klocwork errors
v7: s/pr_debug/dev_dbg, s/dev_info/dev_dbg
add unlock buffer if s10_svc_send_msg() fails
add release channel if fpga_mgr_create() fails
v8: add a goto and common error handling at the end of s10_probe
function
add Moritz's Acked-by
v9: remove kernel-doc markups that aren't being built
v10: s/STRATIX10_SERVICE/INTEL_STRATIX10_SERVICE
s/stratix10_svc_command_reconfig_payload/stratix10_svc_command_config_type update path for the included header file stratix10-svc-client.h
v11: no change

---
 drivers/fpga/Kconfig         |   6 +
 drivers/fpga/Makefile        |   1 +
 drivers/fpga/stratix10-soc.c | 535 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 542 insertions(+)
 create mode 100644 drivers/fpga/stratix10-soc.c
drivers/fpga/Kconfig +6 -0
index 1ebcef4..0bb7b5c 100644
@@ -56,6 +56,12 @@ config FPGA_MGR_ZYNQ_FPGA
 	help
 	  FPGA manager driver support for Xilinx Zynq FPGAs.
 
+config FPGA_MGR_STRATIX10_SOC
+	tristate "Intel Stratix10 SoC FPGA Manager"
+	depends on (ARCH_STRATIX10 && INTEL_STRATIX10_SERVICE)
+	help
+	  FPGA manager driver support for the Intel Stratix10 SoC.
+
 config FPGA_MGR_XILINX_SPI
 	tristate "Xilinx Configuration over Slave Serial (SPI)"
 	depends on SPI
drivers/fpga/Makefile +1 -0
index 7a2d73b..c0dd4c8 100644
@@ -13,6 +13,7 @@ obj-$(CONFIG_FPGA_MGR_ICE40_SPI)	+= ice40-spi.o
 obj-$(CONFIG_FPGA_MGR_MACHXO2_SPI)	+= machxo2-spi.o
 obj-$(CONFIG_FPGA_MGR_SOCFPGA)		+= socfpga.o
 obj-$(CONFIG_FPGA_MGR_SOCFPGA_A10)	+= socfpga-a10.o
+obj-$(CONFIG_FPGA_MGR_STRATIX10_SOC)	+= stratix10-soc.o
 obj-$(CONFIG_FPGA_MGR_TS73XX)		+= ts73xx-fpga.o
 obj-$(CONFIG_FPGA_MGR_XILINX_SPI)	+= xilinx-spi.o
 obj-$(CONFIG_FPGA_MGR_ZYNQ_FPGA)	+= zynq-fpga.o
drivers/fpga/stratix10-soc.c new file +535 -0

535 lines not on this page · raw message

Signature · 1 line
2.7.4
#7 lore raw

PATCH v11 7/8 Documentation: driver-api: add stratix10 service layer

In reply to [email protected]

From: Richard Gong <[email protected]>

Add Intel Stratix10 service layer driver document

---
v5: this patch is added in patch set version 5,
add new file stratix10-svc.rst
add stratix10-svc.rst to driver-api/index.rst
v6: no change
v7: no change
v8: no change
v9: no change
v10: add stratix10 service layer document to other firmware
interface, and then remove stratix10-svc.rst file
v11: no change

---
 .../driver-api/firmware/other_interfaces.rst       | 30 ++++++++++++++++++++++
 1 file changed, 30 insertions(+)
Documentation/driver-api/firmware/other_interfaces.rst +30 -0
index 36c47b1..a4ac54b 100644
@@ -13,3 +13,33 @@ EDD Interfaces
 .. kernel-doc:: drivers/firmware/edd.c
    :internal:
 
+Intel Stratix10 SoC Service Layer
+---------------------------------
+Some features of the Intel Stratix10 SoC require a level of privilege
+higher than the kernel is granted. Such secure features include
+FPGA programming. In terms of the ARMv8 architecture, the kernel runs
+at Exception Level 1 (EL1), access to the features requires
+Exception Level 3 (EL3).
+
+The Intel Stratix10 SoC service layer provides an in kernel API for
+drivers to request access to the secure features. The requests are queued
+and processed one by one. ARM’s SMCCC is used to pass the execution
+of the requests on to a secure monitor (EL3).
+
+.. kernel-doc:: include/linux/firmware/intel/stratix10-svc-client.h
+   :functions: stratix10_svc_command_code
+
+.. kernel-doc:: include/linux/firmware/intel/stratix10-svc-client.h
+   :functions: stratix10_svc_client_msg
+
+.. kernel-doc:: include/linux/firmware/intel/stratix10-svc-client.h
+   :functions: stratix10_svc_command_reconfig_payload
+
+.. kernel-doc:: include/linux/firmware/intel/stratix10-svc-client.h
+   :functions: stratix10_svc_cb_data
+
+.. kernel-doc:: include/linux/firmware/intel/stratix10-svc-client.h
+   :functions: stratix10_svc_client
+
+.. kernel-doc:: drivers/firmware/stratix10-svc.c
+   :export:
Signature · 1 line
2.7.4
#8 lore raw

PATCH v11 8/8 firmware: add remote status update client support

In reply to [email protected]

From: Richard Gong <[email protected]>

Extend Intel Stratix10 service layer to support the second service layer client, Remote Status Update (RSU).

RSU is used to provide our customers with protection against loading bad bitstreams onto their devices when those devices are booting from flash.

---
v7: this patch is added in patch set version 7
v8: no change
v9: add case for COMMAND_RSU_UPDATE at svc_thread_recv_status_ok() at
stratix10-svc.c file
add RSU related definitions at stratix10-smc.h file
v10: s/misc/firmware at commit header
v11: correct a typo in commit message

---
 drivers/firmware/stratix10-svc.c                   | 35 +++++++++++++++-
 include/linux/firmware/intel/stratix10-smc.h       | 47 ++++++++++++++++++++++
 .../linux/firmware/intel/stratix10-svc-client.h    | 20 ++++++++-
 3 files changed, 98 insertions(+), 4 deletions(-)
drivers/firmware/stratix10-svc.c +33 -2
index 168f523..81f3182 100644
@@ -34,7 +34,7 @@
  * timeout is set to 30 seconds (30 * 1000) at Intel Stratix10 SoC.
  */
 #define SVC_NUM_DATA_IN_FIFO			32
-#define SVC_NUM_CHANNEL				1
+#define SVC_NUM_CHANNEL				2
 #define FPGA_CONFIG_DATA_CLAIM_TIMEOUT_MS	200
 #define FPGA_CONFIG_STATUS_TIMEOUT_SEC		30
 
@@ -271,7 +271,7 @@ static void svc_thread_cmd_config_status(struct stratix10_svc_controller *ctrl,
  * @cb_data: pointer to callback data structure to service client
  * @res: result from SMC or HVC call
  *
- * Send back the correspond status to the service client (FPGA manager etc).
+ * Send back the correspond status to the service clients.
  */
 static void svc_thread_recv_status_ok(struct stratix10_svc_data *p_data,
 				      struct stratix10_svc_cb_data *cb_data,
@@ -295,6 +295,9 @@ static void svc_thread_recv_status_ok(struct stratix10_svc_data *p_data,
 	case COMMAND_RECONFIG_STATUS:
 		cb_data->status = BIT(SVC_STATUS_RECONFIG_COMPLETED);
 		break;
+	case COMMAND_RSU_UPDATE:
+		cb_data->status = BIT(SVC_STATUS_RSU_OK);
+		break;
 	default:
 		pr_warn("it shouldn't happen\n");
 		break;
@@ -373,6 +376,16 @@ static int svc_normal_to_secure_thread(void *data)
 			a1 = 0;
 			a2 = 0;
 			break;
+		case COMMAND_RSU_STATUS:
+			a0 = INTEL_SIP_SMC_RSU_STATUS;
+			a1 = 0;
+			a2 = 0;
+			break;
+		case COMMAND_RSU_UPDATE:
+			a0 = INTEL_SIP_SMC_RSU_UPDATE;
+			a1 = pdata->arg[0];
+			a2 = 0;
+			break;
 		default:
 			pr_warn("it shouldn't happen\n");
 			break;
@@ -389,6 +402,19 @@ static int svc_normal_to_secure_thread(void *data)
 			 (unsigned int)res.a1, (unsigned int)res.a2);
 		pr_debug(" res.a3=0x%016x\n", (unsigned int)res.a3);
 
+		if (pdata->command == COMMAND_RSU_STATUS) {
+			if (res.a0 == INTEL_SIP_SMC_RSU_ERROR)
+				cbdata->status = BIT(SVC_STATUS_RSU_ERROR);
+			else
+				cbdata->status = BIT(SVC_STATUS_RSU_OK);
+
+			cbdata->kaddr1 = &res;
+			cbdata->kaddr2 = NULL;
+			cbdata->kaddr3 = NULL;
+			pdata->chan->scl->receive_cb(pdata->chan->scl, cbdata);
+			continue;
+		}
+
 		switch (res.a0) {
 		case INTEL_SIP_SMC_STATUS_OK:
 			svc_thread_recv_status_ok(pdata, cbdata, res);
@@ -941,6 +967,11 @@ static int stratix10_svc_drv_probe(struct platform_device *pdev)
 	chans[0].name = SVC_CLIENT_FPGA;
 	spin_lock_init(&chans[0].lock);
 
+	chans[1].scl = NULL;
+	chans[1].ctrl = controller;
+	chans[1].name = SVC_CLIENT_RSU;
+	spin_lock_init(&chans[1].lock);
+
 	list_add_tail(&controller->node, &svc_ctrl);
 	platform_set_drvdata(pdev, controller);
 
include/linux/firmware/intel/stratix10-smc.h +47 -0

63 lines not on this page · raw message

include/linux/firmware/intel/stratix10-svc-client.h +18 -2
index f2fda7e..e521f17 100644
@@ -10,8 +10,10 @@
  * Service layer driver supports client names
  *
  * fpga: for FPGA configuration
+ * rsu: for remote status update
  */
 #define SVC_CLIENT_FPGA			"fpga"
+#define SVC_CLIENT_RSU			"rsu"
 
 /**
  * Status of the sent command, in bit number
@@ -36,6 +38,9 @@
  *
  * SVC_COMMAND_STATUS_RECONFIG_ERROR:
  * Error encountered during FPGA configuration.
+ *
+ * SVC_STATUS_RSU_OK:
+ * Secure firmware accepts the request of remote status update (RSU).
  */
 #define SVC_STATUS_RECONFIG_REQUEST_OK		0
 #define SVC_STATUS_RECONFIG_BUFFER_SUBMITTED	1
@@ -43,7 +48,8 @@
 #define SVC_STATUS_RECONFIG_COMPLETED		3
 #define SVC_STATUS_RECONFIG_BUSY		4
 #define SVC_STATUS_RECONFIG_ERROR		5
-
+#define SVC_STATUS_RSU_OK			6
+#define SVC_STATUS_RSU_ERROR			7
 /**
  * Flag bit for COMMAND_RECONFIG
  *
@@ -56,9 +62,11 @@
 /**
  * Timeout settings for service clients:
  * timeout value used in Stratix10 FPGA manager driver.
+ * timeout value used in RSU driver
  */
 #define SVC_RECONFIG_REQUEST_TIMEOUT_MS         100
 #define SVC_RECONFIG_BUFFER_TIMEOUT_MS          240
+#define SVC_RSU_REQUEST_TIMEOUT_MS              300
 
 struct stratix10_svc_chan;
 
@@ -81,13 +89,21 @@ struct stratix10_svc_chan;
  * @COMMAND_RECONFIG_STATUS: check the status of the configuration, return
  * status is SVC_STATUS_RECONFIG_COMPLETED, or  SVC_STATUS_RECONFIG_BUSY, or
  * SVC_STATUS_RECONFIG_ERROR
+ *
+ * @COMMAND_RSU_STATUS: request remote system update boot log, return status
+ * is log data or SVC_STATUS_RSU_ERROR
+ *
+ * @COMMAND_RSU_UPDATE: set the offset of the bitstream to boot after reboot,
+ * return status is SVC_STATUS_RSU_OK or SVC_STATUS_RSU_ERROR
  */
 enum stratix10_svc_command_code {
 	COMMAND_NOOP = 0,
 	COMMAND_RECONFIG,
 	COMMAND_RECONFIG_DATA_SUBMIT,
 	COMMAND_RECONFIG_DATA_CLAIM,
-	COMMAND_RECONFIG_STATUS
+	COMMAND_RECONFIG_STATUS,
+	COMMAND_RSU_STATUS,
+	COMMAND_RSU_UPDATE
 };
 
 /**
Signature · 1 line
2.7.4