Intel Vision Processing Unit base enabling part 1
Subsystems (3)
cover Intel Vision Processing Unit base enabling part 1
From: mark gross <[email protected]>
The Intel Vision Processing Unit (VPU) is an IP block that is showing up for the first time as part of the Keem Bay SOC. Keem Bay is a quad core A53 Arm SOC. It is designed to be used as a stand alone SOC as well as in an PCIe Vision Processing accelerator add in card.
This part 1 of the patches make up the base or core of the stack needed to enable both use cases for the VPU.
Part 2 includes 11 more patches that depend on part 1. Those should be ready in a couple of weeks or less.
I am trying something a bit new with this sequence where I've been working with the driver developers as a "pre-maintainer" reviewing and enforcing the kernel expectations as I understand them. Its taken a couple of months to get this code to the point I feel its ready for public posting. My goal is to make sure it meets expectations for quality and compliance with kernel expectations and there will be mostly technical / design issues to talk about.
Thanks for looking at these and providing feedback.
--mark
p.s. I have had a problem my MTA configuration between mutt and git send-email where I was using msmpt to send from mutt (because 15+ years ago its the first way I got to work and never changed) while my worstation MTA that git send-email uses was un-configured resulting in my return-path naming my workstion withing the firewall. I suck at email administration.
I appologies for the multiple copies.
P.p.s. corrected cc listings.
Daniele Alessandrelli (2):
dt-bindings: Add bindings for Keem Bay IPC driver
keembay-ipc: Add Keem Bay IPC module
Paul Murphy (2):
dt-bindings: Add bindings for Keem Bay VPU IPC driver
keembay-vpu-ipc: Add Keem Bay VPU IPC module
Seamus Kelly (8):
xlink-ipc: Add xlink ipc device tree bindings
xlink-ipc: Add xlink ipc driver
xlink-core: Add xlink core device tree bindings
xlink-core: Add xlink core driver xLink
xlink-core: Enable xlink protocol over pcie
xlink-core: Enable VPU IP management and runtime control
xlink-core: add async channel and events
xlink-core: factorize xlink_ioctl function by creating sub-functions
for each ioctl command
Srikanth Thokala (9):
misc: xlink-pcie: Add documentation for XLink PCIe driver
misc: xlink-pcie: lh: Add PCIe EPF driver for Local Host
misc: xlink-pcie: lh: Add PCIe EP DMA functionality
misc: xlink-pcie: lh: Add core communication logic
misc: xlink-pcie: lh: Prepare changes for adding remote host driver
misc: xlink-pcie: rh: Add PCIe EP driver for Remote Host
misc: xlink-pcie: rh: Add core communication logic
misc: xlink-pcie: Add XLink API interface
misc: xlink-pcie: Add asynchronous event notification support for
XLink
mark gross (1):
Add Vision Processing Unit (VPU) documentation.
.../misc/intel,keembay-xlink-ipc.yaml | 49 + .../bindings/misc/intel,keembay-xlink.yaml | 27 + .../bindings/soc/intel/intel,keembay-ipc.yaml | 63 + .../soc/intel/intel,keembay-vpu-ipc.yaml | 151 ++ Documentation/index.rst | 3 +- Documentation/vpu/index.rst | 19 + Documentation/vpu/vpu-stack-overview.rst | 267 +++ Documentation/vpu/xlink-core.rst | 80 + Documentation/vpu/xlink-ipc.rst | 50 + Documentation/vpu/xlink-pcie.rst | 91 + MAINTAINERS | 41 + drivers/misc/Kconfig | 3 + drivers/misc/Makefile | 3 + drivers/misc/xlink-core/Kconfig | 33 + drivers/misc/xlink-core/Makefile | 5 + drivers/misc/xlink-core/xlink-core.c | 1335 +++++++++++ drivers/misc/xlink-core/xlink-core.h | 24 + drivers/misc/xlink-core/xlink-defs.h | 181 ++ drivers/misc/xlink-core/xlink-dispatcher.c | 436 ++++ drivers/misc/xlink-core/xlink-dispatcher.h | 26 + drivers/misc/xlink-core/xlink-ioctl.c | 584 +++++ drivers/misc/xlink-core/xlink-ioctl.h | 36 + drivers/misc/xlink-core/xlink-multiplexer.c | 1164 ++++++++++ drivers/misc/xlink-core/xlink-multiplexer.h | 35 + drivers/misc/xlink-core/xlink-platform.c | 273 +++ drivers/misc/xlink-core/xlink-platform.h | 65 + drivers/misc/xlink-ipc/Kconfig | 7 + drivers/misc/xlink-ipc/Makefile | 4 + drivers/misc/xlink-ipc/xlink-ipc.c | 879 +++++++ drivers/misc/xlink-pcie/Kconfig | 20 + drivers/misc/xlink-pcie/Makefile | 2 + drivers/misc/xlink-pcie/common/core.h | 247 ++ drivers/misc/xlink-pcie/common/interface.c | 126 + drivers/misc/xlink-pcie/common/util.c | 375 +++ drivers/misc/xlink-pcie/common/util.h | 70 + drivers/misc/xlink-pcie/common/xpcie.h | 120 + drivers/misc/xlink-pcie/local_host/Makefile | 6 + drivers/misc/xlink-pcie/local_host/core.c | 905 ++++++++ drivers/misc/xlink-pcie/local_host/dma.c | 577 +++++ drivers/misc/xlink-pcie/local_host/epf.c | 523 +++++ drivers/misc/xlink-pcie/local_host/epf.h | 106 + drivers/misc/xlink-pcie/remote_host/Makefile | 6 + drivers/misc/xlink-pcie/remote_host/core.c | 647 ++++++ drivers/misc/xlink-pcie/remote_host/main.c | 96 + drivers/misc/xlink-pcie/remote_host/pci.c | 525 +++++ drivers/misc/xlink-pcie/remote_host/pci.h | 67 + drivers/soc/Kconfig | 1 + drivers/soc/Makefile | 1 + drivers/soc/intel/Kconfig | 32 + drivers/soc/intel/Makefile | 5 + drivers/soc/intel/keembay-ipc.c | 1669 ++++++++++++++ drivers/soc/intel/keembay-vpu-ipc.c | 2036 +++++++++++++++++ include/linux/soc/intel/keembay-ipc.h | 30 + include/linux/soc/intel/keembay-vpu-ipc.h | 62 + include/linux/xlink-ipc.h | 48 + include/linux/xlink.h | 146 ++ include/linux/xlink_drv_inf.h | 72 + include/uapi/misc/xlink_uapi.h | 145 ++ 58 files changed, 14598 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/misc/intel,keembay-xlink-ipc.yaml create mode 100644 Documentation/devicetree/bindings/misc/intel,keembay-xlink.yaml create mode 100644 Documentation/devicetree/bindings/soc/intel/intel,keembay-ipc.yaml create mode 100644 Documentation/devicetree/bindings/soc/intel/intel,keembay-vpu-ipc.yaml create mode 100644 Documentation/vpu/index.rst create mode 100644 Documentation/vpu/vpu-stack-overview.rst create mode 100644 Documentation/vpu/xlink-core.rst create mode 100644 Documentation/vpu/xlink-ipc.rst create mode 100644 Documentation/vpu/xlink-pcie.rst create mode 100644 drivers/misc/xlink-core/Kconfig create mode 100644 drivers/misc/xlink-core/Makefile create mode 100644 drivers/misc/xlink-core/xlink-core.c create mode 100644 drivers/misc/xlink-core/xlink-core.h create mode 100644 drivers/misc/xlink-core/xlink-defs.h create mode 100644 drivers/misc/xlink-core/xlink-dispatcher.c create mode 100644 drivers/misc/xlink-core/xlink-dispatcher.h create mode 100644 drivers/misc/xlink-core/xlink-ioctl.c create mode 100644 drivers/misc/xlink-core/xlink-ioctl.h create mode 100644 drivers/misc/xlink-core/xlink-multiplexer.c create mode 100644 drivers/misc/xlink-core/xlink-multiplexer.h create mode 100644 drivers/misc/xlink-core/xlink-platform.c create mode 100644 drivers/misc/xlink-core/xlink-platform.h create mode 100644 drivers/misc/xlink-ipc/Kconfig create mode 100644 drivers/misc/xlink-ipc/Makefile create mode 100644 drivers/misc/xlink-ipc/xlink-ipc.c create mode 100644 drivers/misc/xlink-pcie/Kconfig create mode 100644 drivers/misc/xlink-pcie/Makefile create mode 100644 drivers/misc/xlink-pcie/common/core.h create mode 100644 drivers/misc/xlink-pcie/common/interface.c create mode 100644 drivers/misc/xlink-pcie/common/util.c create mode 100644 drivers/misc/xlink-pcie/common/util.h create mode 100644 drivers/misc/xlink-pcie/common/xpcie.h create mode 100644 drivers/misc/xlink-pcie/local_host/Makefile create mode 100644 drivers/misc/xlink-pcie/local_host/core.c create mode 100644 drivers/misc/xlink-pcie/local_host/dma.c create mode 100644 drivers/misc/xlink-pcie/local_host/epf.c create mode 100644 drivers/misc/xlink-pcie/local_host/epf.h create mode 100644 drivers/misc/xlink-pcie/remote_host/Makefile create mode 100644 drivers/misc/xlink-pcie/remote_host/core.c create mode 100644 drivers/misc/xlink-pcie/remote_host/main.c create mode 100644 drivers/misc/xlink-pcie/remote_host/pci.c create mode 100644 drivers/misc/xlink-pcie/remote_host/pci.h create mode 100644 drivers/soc/intel/Kconfig create mode 100644 drivers/soc/intel/Makefile create mode 100644 drivers/soc/intel/keembay-ipc.c create mode 100644 drivers/soc/intel/keembay-vpu-ipc.c create mode 100644 include/linux/soc/intel/keembay-ipc.h create mode 100644 include/linux/soc/intel/keembay-vpu-ipc.h create mode 100644 include/linux/xlink-ipc.h create mode 100644 include/linux/xlink.h create mode 100644 include/linux/xlink_drv_inf.h create mode 100644 include/uapi/misc/xlink_uapi.h
Signature · 1 line
2.17.1
PATCH 1/22 Add Vision Processing Unit (VPU) documentation.
From: mark gross <[email protected]>
The Intel VPU needs a complicated SW stack to make it work. Add a directory to hold VPU related documentation including an architectural overview of the SW stack that the patches implement.
--- Documentation/index.rst | 3 +- Documentation/vpu/index.rst | 16 ++ Documentation/vpu/vpu-stack-overview.rst | 267 +++++++++++++++++++++++ 3 files changed, 285 insertions(+), 1 deletion(-) create mode 100644 Documentation/vpu/index.rst create mode 100644 Documentation/vpu/vpu-stack-overview.rst
Documentation/index.rst +2 -1
@@ -1,4 +1,4 @@ -.. SPDX-License-Identifier: GPL-2.0 +.. SPDX-License-Identifier: GPL-2.0-only .. The Linux Kernel documentation master file, created by
@@ -137,6 +137,7 @@ needed). misc-devices/index scheduler/index mhi/index + vpu/index Architecture-agnostic documentation -----------------------------------
Documentation/vpu/index.rst new file +16 -0
@@ -0,0 +1,16 @@ +.. SPDX-License-Identifier: GPL-2.0-only + +============================================ +Vision Processor Unit Documentation +============================================ + +This documentation contains information for the Intel VPU stack. + +.. class:: toc-title + + Table of contents + +.. toctree:: + :maxdepth: 2 + + vpu-stack-overview
Documentation/vpu/vpu-stack-overview.rst new file +267 -0
267 lines not on this page · raw message
Signature · 1 line
2.17.1
Randy Dunlap
reviewerRe: [PATCH 01/22] Add Vision Processing Unit (VPU) documentation.
Hi--
Quoted 5 lines · On 12/1/20 2:34 PM, [email protected] wrote:
From: mark gross <[email protected]>
Reviewed-by Mark Gross <[email protected]>Signed-off-by Mark Gross <[email protected]>
My reading of submitting-patches.rst seems to indicate that the Reviewer and Submitter are probably not the same person.
Are you sure that you reviewed it?
Quoted 13 lines
--- Documentation/index.rst | 3 +- Documentation/vpu/index.rst | 16 ++ Documentation/vpu/vpu-stack-overview.rst | 267 +++++++++++++++++++++++ 3 files changed, 285 insertions(+), 1 deletion(-) create mode 100644 Documentation/vpu/index.rst create mode 100644 Documentation/vpu/vpu-stack-overview.rstDocumentation/index.rst +0
-0
Documentation/index.rst line 1
Quoted 2 lines
Documentation/index.rst +1
-1@@ -1,4 +1,4 @@ -.. SPDX-License-Identifier: GPL-2.0 +.. SPDX-License-Identifier: GPL-2.0-only
That looks both inappropriate for this patch and incorrect AFAICT.
Quoted 17 lines
Documentation/index.rst +1
-0.. The Linux Kernel documentation master file, created by@@ -137,6 +137,7 @@ needed). misc-devices/index scheduler/index mhi/index + vpu/index Architecture-agnostic documentation -----------------------------------Documentation/vpu/index.rst new file +0
-0
Documentation/vpu/index.rst line 1
Quoted 1 line
Documentation/vpu/index.rst new file +1
-0@@ -0,0 +1,16 @@ +.. SPDX-License-Identifier: GPL-2.0-only
license-rules.rst says:
For 'GNU General Public License (GPL) version 2 only' use:
SPDX-License-Identifier: GPL-2.0
Quoted 21 lines
Documentation/vpu/index.rst new file +15
-0+ +============================================ +Vision Processor Unit Documentation +============================================ + +This documentation contains information for the Intel VPU stack. + +.. class:: toc-title + + Table of contents + +.. toctree:: + :maxdepth: 2 + + vpu-stack-overviewDocumentation/vpu/vpu-stack-overview.rst new file +0
-0
Documentation/vpu/vpu-stack-overview.rst line 1
Quoted 1 line
Documentation/vpu/vpu-stack-overview.rst new file +1
-0@@ -0,0 +1,267 @@ +.. SPDX-License-Identifier: GPL-2.0-only
Nope.
Documentation/vpu/vpu-stack-overview.rst line 11
Quoted 10 lines
Documentation/vpu/vpu-stack-overview.rst new file +10
-0+ +====================== +Intel VPU architecture +====================== + +Overview +======== + +The Intel Movidius acquisition has developed a Vision Processing Unit (VPU) +roadmap of products starting with Keem Bay (KMB). The HW configurations the
s/HW/hardware/
Documentation/vpu/vpu-stack-overview.rst line 14
Quoted 3 lines
Documentation/vpu/vpu-stack-overview.rst new file +3
-0+VPU can support include: + +1. Standalone smart camera that does local CV processing in camera
Tell us what CV is before using it.
Documentation/vpu/vpu-stack-overview.rst line 15
Quoted 1 line
Documentation/vpu/vpu-stack-overview.rst new file +1
-0+2. Standalone appliance or SBC device connected to a network and tethered
Tell us what SBC is before using it. (yeah, I know)
Documentation/vpu/vpu-stack-overview.rst line 18
Quoted 3 lines
Documentation/vpu/vpu-stack-overview.rst new file +3
-0+ cameras doing local CV processing +3. Embedded in a USB dongle or M.2 as an CV accelerator. +4. Multiple VPU enabled SOC's on a PCIE card as a CV accelerator in a larger IA
PCIe (?)
Documentation/vpu/vpu-stack-overview.rst line 22
Quoted 4 lines
Documentation/vpu/vpu-stack-overview.rst new file +4
-0+ box or server. + +Keem Bay is the first instance of this family of products. This document +provides an architectural overview of the SW stack supporting the VPU enabled
s/SW/software/
Quoted 10 lines
Documentation/vpu/vpu-stack-overview.rst new file +10
-0+products. + +Keem Bay (KMB) is a Computer Vision AI processing SoC based on ARM A53 CPU that +provides Edge neural network acceleration (inference) and includes a Vision +Processing Unit (VPU) hardware. The ARM CPU SubSystem (CPUSS) interfaces +locally to the VPU and enables integration/interfacing with a remote host over +PCIe or USB or Ethernet interfaces. The interface between the CPUSS and the VPU +is implemented with HW FIFOs (Control) and coherent memory mapping (Data) such +that zero copy processing can happen within the VPU. +
Documentation/vpu/vpu-stack-overview.rst line 42
Quoted 10 lines
Documentation/vpu/vpu-stack-overview.rst new file +10
-0+The KMB can be used in all 4 of the above classes of designs. + +We refer to the 'local host' as being the ARM part of the SoC, while the +'remote host' as the IA system hosting the KMB device(s). The KMB SoC boots +from an eMMC via uBoot and ARM Linux compatible device tree interface with an +expectation to fully boot within hundreds of milliseconds. There is also +support for downloading the kernel and root file system image from a remote +host. + +The eMMC can be updated with standard mender update process.
Mender
Documentation/vpu/vpu-stack-overview.rst line 46
Quoted 4 lines
Documentation/vpu/vpu-stack-overview.rst new file +4
-0+See https://github.com/mendersoftware/mender + +The VPU is started and controlled from the A53 local host. Its firmware image +is loaded using the drive FW helper KAPI's.
s/FW/firmware/
Documentation/vpu/vpu-stack-overview.rst line 51
Quoted 5 lines
Documentation/vpu/vpu-stack-overview.rst new file +5
-0+ +The VPU IP FW payload consists of a SPARC ISA RTEMS bootloader and/or +application binary. + +The interface allowing (remote or local) host clients to access VPU IP
^^drop one space
Documentation/vpu/vpu-stack-overview.rst line 54
Quoted 3 lines
Documentation/vpu/vpu-stack-overview.rst new file +3
-0+capabilities is realized through an abstracted programming model, which +provides Remote Proxy APIs for a host CPU application to dynamically create and +execute CV and NN workloads on the VPU. All frameworks exposed through
Tell us what NN is.
Documentation/vpu/vpu-stack-overview.rst line 67
Quoted 13 lines
Documentation/vpu/vpu-stack-overview.rst new file +13
-0+programming model’s APIs are contained in the pre-compiled standard firmware +image. + +There is a significant SW stack built up to support KMB and the use cases. The +rest of this documentation provides an overview of the components of the stack. + +Keem Bay IPC +============ + +Directly interfaces with the KMB HW FIFOs to provide zero copy processing from +the VPU. It implements the lowest level protocol for interacting with the VPU. + +The Keem Bay IPC mechanism is based on shared memory and hardware FIFOs,
FIFOs.
Documentation/vpu/vpu-stack-overview.rst line 68
Quoted 1 line
Documentation/vpu/vpu-stack-overview.rst new file +1
-0+specifically there are:
Specifically
Documentation/vpu/vpu-stack-overview.rst line 71
Quoted 3 lines
Documentation/vpu/vpu-stack-overview.rst new file +3
-0+ +* Two 128-entry HW FIFOs, one for the CPU and one for the VPU. +* Two shared memory regions, used as memory pool for allocating IPC buffers
end with a period since the previous line did that.
Documentation/vpu/vpu-stack-overview.rst line 74
Quoted 3 lines
Documentation/vpu/vpu-stack-overview.rst new file +3
-0+ +An IPC channel is a software abstraction allowing communication multiplexing, +so that multiple applications / users can concurrently communicated to the VPU.
communicate
Documentation/vpu/vpu-stack-overview.rst line 77
Quoted 3 lines
Documentation/vpu/vpu-stack-overview.rst new file +3
-0+IPC channels area conceptually similar to socket ports. + +There is a total of 1024 channels, each one identified by a channel ID, ranging
are
Quoted 6 lines
Documentation/vpu/vpu-stack-overview.rst new file +6
-0+from 0 to 1023. + +Channels are divided in two categories: + +* High-Speed (HS) channels, having IDs in the 0-9 range. +* General-Purpose (GP) channels, having IDs in the 10-1023 range.
Documentation/vpu/vpu-stack-overview.rst line 93
Quoted 10 lines
Documentation/vpu/vpu-stack-overview.rst new file +10
-0+ +HS channels have higher priority over GP channels and can be used by +applications requiring higher throughput or lower latency. + +Since all the channels share the same HW resources (i.e., the HW FIFOs and the +IPC memory pools), the Keem Bay IPC driver uses software queues to give a +higher priority to HS channels. + +The driver supports a build-time configurable number of communication channels +defined in a so called Channel Mapping Table.
so-called
Quoted 26 lines
Documentation/vpu/vpu-stack-overview.rst new file +26
-0+ +An IPC channel is full duplex: a pending operation from a certain channel does +not block other operations on the same channel, regardless of their operation +mode (blocking or non-blocking). + +Operation mode is individually selectable for each channel, per operation +direction (read or write). All operations for that direction comply to +selection. + + +Keem Bay-VPU-IPC +================ + +This is the MMIO driver of the VPU IP block inside the SOC. It is a control +driver mapping IPC channel communication to Xlink virtual channels. + +This driver provides the following functionality to other drivers in the +communication stack: + +* VPU IP execution control (firmware load, start, reset) +* VPU IP event notifications (device connected, device disconnected, WDT event) +* VPU IP device status query (OFF, BUSY, READY, ERROR, RECOVERY) +* Communication via the IPC protocol (wrapping the Keem Bay IPC driver and + exposing it to higher level Xlink layer) + +In addition to the above, the driver exposes SoC information (like stepping,
Documentation/vpu/vpu-stack-overview.rst line 129
Quoted 10 lines
Documentation/vpu/vpu-stack-overview.rst new file +10
-0+device ID, etc.) to user-space via sysfs. + +This driver depends on the 'Keem Bay IPC' driver, which enables the Keem Bay +IPC communication protocol. + +The driver uses the Firmware API to load the VPU firmware from user-space. + +Xlink-IPC +========= +This component is implementing the IPC specific Xlink protocol. It maps channel
component implements IPC-specific
Quoted 24 lines
Documentation/vpu/vpu-stack-overview.rst new file +24
-0+IDs to HW FIFO entries, using the Keem Bay VPU IPC driver. + +Some of the main functions this driver provides: + +* establishing a connection with an IPC device +* obtaining a list with the available devices +* obtaining the status for a device +* booting a device +* resetting a device +* opening and closing channels +* issuing read and write operations + +Xlink-core +========== + +This component implements an abstracted set of control and communication APIs +based on channel identification. It is intended to support VPU technology both +at SoC level as well as at IP level, over multiple interfaces. + +It provides symmetrical services, where the producer and the consumer have +the same privileges. + +Xlink driver has the ability to abstract several types of communication +channels underneath, allowing the usage of different interfaces with the same
Documentation/vpu/vpu-stack-overview.rst line 163
Quoted 10 lines
Documentation/vpu/vpu-stack-overview.rst new file +10
-0+function calls. + +Xlink services are available to both kernel and user space clients and include: + +* interface abstract control and communication API +* multi device support +* concurrent communication across 4096 communication channels (from 0 to + 0xFFF), with customizable properties +* full duplex channels with multiprocess and multithread support +* channel IDs can be mapped to desired physical interface (PCIE, USB, ETH, IPC)
PCIe
Documentation/vpu/vpu-stack-overview.rst line 165
Quoted 2 lines
Documentation/vpu/vpu-stack-overview.rst new file +2
-0+ via a Channel Mapping Table +* asynchronous fast pass through mode: remote host data packets are directly
passthrough
Documentation/vpu/vpu-stack-overview.rst line 173
Quoted 8 lines
Documentation/vpu/vpu-stack-overview.rst new file +8
-0+ dispatched using interrupt systems running on local host to IPC calls for low + overhead +* channel handshaking mechanism for peer to peer communication, without the + need of static channel preallocation +* channel resource management +* asynchronous data and device notifications to subscribers + +Xlink transports: PCIe, USB, ETH, IPCXLink-PCIe
IPC,
Documentation/vpu/vpu-stack-overview.rst line 175
Quoted 2 lines
Documentation/vpu/vpu-stack-overview.rst new file +2
-0+ +XLink-PCIE
PCIe
Documentation/vpu/vpu-stack-overview.rst line 177
Quoted 2 lines
Documentation/vpu/vpu-stack-overview.rst new file +2
-0+========== +This is an endpoint driver that is mapping Xlink channel IDs to PCIE channels.
that maps PCIe
Documentation/vpu/vpu-stack-overview.rst line 180
Quoted 3 lines
Documentation/vpu/vpu-stack-overview.rst new file +3
-0+ +This component ensures (remote)host-to-(local)host communication, and VPU IP +communication via an asynchronous pass through mode, where PCIE data loads are
passthrough PCIe
Documentation/vpu/vpu-stack-overview.rst line 183
Quoted 3 lines
Documentation/vpu/vpu-stack-overview.rst new file +3
-0+directly dispatched to Xlink-IPC. + +The component builds and advertises Device IDs that can are used by local host
that are used
Documentation/vpu/vpu-stack-overview.rst line 188
Quoted 5 lines
Documentation/vpu/vpu-stack-overview.rst new file +5
-0+application in case of multi device scenarios. + +XLink-USB +========== +This is an endpoint driver that is mapping Xlink channel IDs to bidirectional
that maps
Documentation/vpu/vpu-stack-overview.rst line 189
Quoted 1 line
Documentation/vpu/vpu-stack-overview.rst new file +1
-0+USB endpoints and supports CDC USB class protocol. More than one Xlink channels
channel
Documentation/vpu/vpu-stack-overview.rst line 193
Quoted 4 lines
Documentation/vpu/vpu-stack-overview.rst new file +4
-0+can be mapped to a single USB endpoint. + +This component ensures host-to-host communication, and, as well, asynchronous +pass through communication, where USB transfer packets are directly dispatched
passthrough
Documentation/vpu/vpu-stack-overview.rst line 196
Quoted 3 lines
Documentation/vpu/vpu-stack-overview.rst new file +3
-0+to Xlink-IPC. + +The component builds and advertises Device IDs that can are used by local host
that are used
Documentation/vpu/vpu-stack-overview.rst line 202
Quoted 6 lines
Documentation/vpu/vpu-stack-overview.rst new file +6
-0+application in case of multi device scenarios. + +XLink-ETH +========= + +This is an endpoint driver that is mapping Xlink channel IDs to Ethernet
that maps
Documentation/vpu/vpu-stack-overview.rst line 206
Quoted 4 lines
Documentation/vpu/vpu-stack-overview.rst new file +4
-0+sockets. + +This component ensures host-to-host communication, and, as well, asynchronous +pass through communication, where Ethernet data loads are directly dispatched to
passthrough
Documentation/vpu/vpu-stack-overview.rst line 209
Quoted 3 lines
Documentation/vpu/vpu-stack-overview.rst new file +3
-0+Xlink-IPC. + +The component builds and advertises Device IDs that can are used by local host
that are used
Documentation/vpu/vpu-stack-overview.rst line 218
Quoted 9 lines
Documentation/vpu/vpu-stack-overview.rst new file +9
-0+application in case of multi device scenarios. + +Assorted drivers that depend on this stack: + +Xlink-SMB +========= +The Intel Edge.AI Computer Vision platforms have to be monitored using platform +devices like sensors, fan controller, IO expander etc. Some of these devices +are memory mapped and some are i2c based. Either of these devices are not
I2C-based. None of these devices is
Documentation/vpu/vpu-stack-overview.rst line 224
Quoted 6 lines
Documentation/vpu/vpu-stack-overview.rst new file +6
-0+directly accessible to the host. + +The host here refers to the server to which the vision accelerators are +connected over PCIe Interface. The Host needs to do a consolidated action based +on the parameters of platform devices. In general, most of the standard devices +(includes sensors, fan controller, IO expander etc) are I2C/SMBus based and are
SMBus-based
Documentation/vpu/vpu-stack-overview.rst line 226
Quoted 2 lines
Documentation/vpu/vpu-stack-overview.rst new file +2
-0+used to provide the status of the accelerator. Standard drivers for these +devices are available based on i2c/smbus APIs.
I2C/SMBus
Documentation/vpu/vpu-stack-overview.rst line 229
Quoted 3 lines
Documentation/vpu/vpu-stack-overview.rst new file +3
-0+ +Instead of changing the sensor drivers to adapt to PCIe interface, a generic +i2c adapter "xlink-smbus" which underneath uses xlink as physical medium is
I2C Xlink
Documentation/vpu/vpu-stack-overview.rst line 230
Quoted 1 line
Documentation/vpu/vpu-stack-overview.rst new file +1
-0+used. With xlink-smbus, the drivers for the platform devices doesn't need to
don't
Documentation/vpu/vpu-stack-overview.rst line 237
Quoted 7 lines
Documentation/vpu/vpu-stack-overview.rst new file +7
-0+undergo any interface change. + +TSEN +==== + +Thermal sensor driver for exporting thermal events to the local Arm64 host as +well as to the remote X86 host if in the PCIe add in CV accelerator
add-in
Documentation/vpu/vpu-stack-overview.rst line 240
Quoted 3 lines
Documentation/vpu/vpu-stack-overview.rst new file +3
-0+configuration. + +The driver receiving the junction temperature from different heating points
receives
Documentation/vpu/vpu-stack-overview.rst line 241
Quoted 1 line
Documentation/vpu/vpu-stack-overview.rst new file +1
-0+inside the SOC. The driver will receive the temperature on SMBUS connection and
SMBus
Documentation/vpu/vpu-stack-overview.rst line 244
Quoted 3 lines
Documentation/vpu/vpu-stack-overview.rst new file +3
-0+forward over xlink-smb when in a remote host configuration. + +In Keem Bay, the four thermal junction temperature points are, Media Subsystem
^no comma
Documentation/vpu/vpu-stack-overview.rst line 245
Quoted 1 line
Documentation/vpu/vpu-stack-overview.rst new file +1
-0+(mss), NN subsystem (nce), Compute subsystem (cse) and SOC(Maximum of mss, nce
and SOC (maximum of mss, nce
Documentation/vpu/vpu-stack-overview.rst line 246
Quoted 1 line
Documentation/vpu/vpu-stack-overview.rst new file +1
-0+and cse)
cse).
Documentation/vpu/vpu-stack-overview.rst line 257
Quoted 11 lines
Documentation/vpu/vpu-stack-overview.rst new file +11
-0+ +HDDL +==== + +- Exports details of temperature sensor, current sensor and fan controller + present in Intel Edge.AI Computer Vision platforms to IA host. +- Enable Time sync of Intel Edge.AI Computer Vision platform with IA host. +- Handles device connect and disconnect events. +- Receives slave address from the IA host for memory mapped thermal sensors + present in SoC (Documentation/hwmon/intel_tsens_sensors.rst). +- Registers i2c slave device for slaves present in Intel Edge.AI Computer
I2C
Quoted 11 lines
Documentation/vpu/vpu-stack-overview.rst new file +10
-0+ Vision platform + + +VPUMGR (VPU Manager) +==================== + +Bridges firmware on VPU side and applications on CPU user-space, it assists +firmware on VPU side serving multiple user space application processes on CPU +side concurrently while also performing necessary data buffer management on +behalf of VPU IP.
Signature · 1 line
~Randy
Re: [PATCH 01/22] Add Vision Processing Unit (VPU) documentation.
Quoted 465 lines · Randy Dunlap
Hi--
Quoted 5 lines · On 12/1/20 2:34 PM, [email protected] wrote:
From: mark gross <[email protected]>
Reviewed-by Mark Gross <[email protected]>Signed-off-by Mark Gross <[email protected]>My reading of
submitting-patches.rstseems to indicate that the Reviewer and Submitter are probably not the same person.Are you sure that you reviewed it?
Quoted 13 lines
--- Documentation/index.rst | 3 +- Documentation/vpu/index.rst | 16 ++ Documentation/vpu/vpu-stack-overview.rst | 267 +++++++++++++++++++++++ 3 files changed, 285 insertions(+), 1 deletion(-) create mode 100644 Documentation/vpu/index.rst create mode 100644 Documentation/vpu/vpu-stack-overview.rstDocumentation/index.rst +0
-0Documentation/index.rst line 1
Quoted 2 lines
Documentation/index.rst +1
-1@@ -1,4 +1,4 @@ -.. SPDX-License-Identifier: GPL-2.0 +.. SPDX-License-Identifier: GPL-2.0-onlyThat looks both inappropriate for this patch and incorrect AFAICT.
Quoted 17 lines
Documentation/index.rst +1
-0.. The Linux Kernel documentation master file, created by@@ -137,6 +137,7 @@ needed). misc-devices/index scheduler/index mhi/index + vpu/index Architecture-agnostic documentation -----------------------------------Documentation/vpu/index.rst new file +0
-0Documentation/vpu/index.rst line 1
Quoted 1 line
Documentation/vpu/index.rst new file +1
-0@@ -0,0 +1,16 @@ +.. SPDX-License-Identifier: GPL-2.0-only
license-rules.rstsays:For 'GNU General Public License (GPL) version 2 only' use:
SPDX-License-Identifier: GPL-2.0Quoted 21 lines
Documentation/vpu/index.rst new file +15
-0+ +============================================ +Vision Processor Unit Documentation +============================================ + +This documentation contains information for the Intel VPU stack. + +.. class:: toc-title + + Table of contents + +.. toctree:: + :maxdepth: 2 + + vpu-stack-overviewDocumentation/vpu/vpu-stack-overview.rst new file +0
-0Documentation/vpu/vpu-stack-overview.rst line 1
Quoted 1 line
Documentation/vpu/vpu-stack-overview.rst new file +1
-0@@ -0,0 +1,267 @@ +.. SPDX-License-Identifier: GPL-2.0-onlyNope.
Documentation/vpu/vpu-stack-overview.rst line 11
Quoted 10 lines
Documentation/vpu/vpu-stack-overview.rst new file +10
-0+ +====================== +Intel VPU architecture +====================== + +Overview +======== + +The Intel Movidius acquisition has developed a Vision Processing Unit (VPU) +roadmap of products starting with Keem Bay (KMB). The HW configurations thes/HW/hardware/
Documentation/vpu/vpu-stack-overview.rst line 14
Quoted 3 lines
Documentation/vpu/vpu-stack-overview.rst new file +3
-0+VPU can support include: + +1. Standalone smart camera that does local CV processing in cameraTell us what CV is before using it.
Documentation/vpu/vpu-stack-overview.rst line 15
Quoted 1 line
Documentation/vpu/vpu-stack-overview.rst new file +1
-0+2. Standalone appliance or SBC device connected to a network and tetheredTell us what SBC is before using it. (yeah, I know)
Documentation/vpu/vpu-stack-overview.rst line 18
Quoted 3 lines
Documentation/vpu/vpu-stack-overview.rst new file +3
-0+ cameras doing local CV processing +3. Embedded in a USB dongle or M.2 as an CV accelerator. +4. Multiple VPU enabled SOC's on a PCIE card as a CV accelerator in a larger IAPCIe (?)Documentation/vpu/vpu-stack-overview.rst line 22
Quoted 4 lines
Documentation/vpu/vpu-stack-overview.rst new file +4
-0+ box or server. + +Keem Bay is the first instance of this family of products. This document +provides an architectural overview of the SW stack supporting the VPU enableds/SW/software/
Quoted 10 lines
Documentation/vpu/vpu-stack-overview.rst new file +10
-0+products. + +Keem Bay (KMB) is a Computer Vision AI processing SoC based on ARM A53 CPU that +provides Edge neural network acceleration (inference) and includes a Vision +Processing Unit (VPU) hardware. The ARM CPU SubSystem (CPUSS) interfaces +locally to the VPU and enables integration/interfacing with a remote host over +PCIe or USB or Ethernet interfaces. The interface between the CPUSS and the VPU +is implemented with HW FIFOs (Control) and coherent memory mapping (Data) such +that zero copy processing can happen within the VPU. +Documentation/vpu/vpu-stack-overview.rst line 42
Quoted 10 lines
Documentation/vpu/vpu-stack-overview.rst new file +10
-0+The KMB can be used in all 4 of the above classes of designs. + +We refer to the 'local host' as being the ARM part of the SoC, while the +'remote host' as the IA system hosting the KMB device(s). The KMB SoC boots +from an eMMC via uBoot and ARM Linux compatible device tree interface with an +expectation to fully boot within hundreds of milliseconds. There is also +support for downloading the kernel and root file system image from a remote +host. + +The eMMC can be updated with standard mender update process.Mender
Documentation/vpu/vpu-stack-overview.rst line 46
Quoted 4 lines
Documentation/vpu/vpu-stack-overview.rst new file +4
-0+See https://github.com/mendersoftware/mender + +The VPU is started and controlled from the A53 local host. Its firmware image +is loaded using the drive FW helper KAPI's.s/FW/firmware/
Documentation/vpu/vpu-stack-overview.rst line 51
Quoted 5 lines
Documentation/vpu/vpu-stack-overview.rst new file +5
-0+ +The VPU IP FW payload consists of a SPARC ISA RTEMS bootloader and/or +application binary. + +The interface allowing (remote or local) host clients to access VPU IP^^drop one space
Documentation/vpu/vpu-stack-overview.rst line 54
Quoted 3 lines
Documentation/vpu/vpu-stack-overview.rst new file +3
-0+capabilities is realized through an abstracted programming model, which +provides Remote Proxy APIs for a host CPU application to dynamically create and +execute CV and NN workloads on the VPU. All frameworks exposed throughTell us what NN is.
Documentation/vpu/vpu-stack-overview.rst line 67
Quoted 13 lines
Documentation/vpu/vpu-stack-overview.rst new file +13
-0+programming model’s APIs are contained in the pre-compiled standard firmware +image. + +There is a significant SW stack built up to support KMB and the use cases. The +rest of this documentation provides an overview of the components of the stack. + +Keem Bay IPC +============ + +Directly interfaces with the KMB HW FIFOs to provide zero copy processing from +the VPU. It implements the lowest level protocol for interacting with the VPU. + +The Keem Bay IPC mechanism is based on shared memory and hardware FIFOs,FIFOs.
Documentation/vpu/vpu-stack-overview.rst line 68
Quoted 1 line
Documentation/vpu/vpu-stack-overview.rst new file +1
-0+specifically there are:Specifically
Documentation/vpu/vpu-stack-overview.rst line 71
Quoted 3 lines
Documentation/vpu/vpu-stack-overview.rst new file +3
-0+ +* Two 128-entry HW FIFOs, one for the CPU and one for the VPU. +* Two shared memory regions, used as memory pool for allocating IPC buffersend with a period since the previous line did that.
Documentation/vpu/vpu-stack-overview.rst line 74
Quoted 3 lines
Documentation/vpu/vpu-stack-overview.rst new file +3
-0+ +An IPC channel is a software abstraction allowing communication multiplexing, +so that multiple applications / users can concurrently communicated to the VPU.communicate
Documentation/vpu/vpu-stack-overview.rst line 77
Quoted 3 lines
Documentation/vpu/vpu-stack-overview.rst new file +3
-0+IPC channels area conceptually similar to socket ports. + +There is a total of 1024 channels, each one identified by a channel ID, rangingare
Quoted 6 lines
Documentation/vpu/vpu-stack-overview.rst new file +6
-0+from 0 to 1023. + +Channels are divided in two categories: + +* High-Speed (HS) channels, having IDs in the 0-9 range. +* General-Purpose (GP) channels, having IDs in the 10-1023 range.Documentation/vpu/vpu-stack-overview.rst line 93
Quoted 10 lines
Documentation/vpu/vpu-stack-overview.rst new file +10
-0+ +HS channels have higher priority over GP channels and can be used by +applications requiring higher throughput or lower latency. + +Since all the channels share the same HW resources (i.e., the HW FIFOs and the +IPC memory pools), the Keem Bay IPC driver uses software queues to give a +higher priority to HS channels. + +The driver supports a build-time configurable number of communication channels +defined in a so called Channel Mapping Table.so-called
Quoted 26 lines
Documentation/vpu/vpu-stack-overview.rst new file +26
-0+ +An IPC channel is full duplex: a pending operation from a certain channel does +not block other operations on the same channel, regardless of their operation +mode (blocking or non-blocking). + +Operation mode is individually selectable for each channel, per operation +direction (read or write). All operations for that direction comply to +selection. + + +Keem Bay-VPU-IPC +================ + +This is the MMIO driver of the VPU IP block inside the SOC. It is a control +driver mapping IPC channel communication to Xlink virtual channels. + +This driver provides the following functionality to other drivers in the +communication stack: + +* VPU IP execution control (firmware load, start, reset) +* VPU IP event notifications (device connected, device disconnected, WDT event) +* VPU IP device status query (OFF, BUSY, READY, ERROR, RECOVERY) +* Communication via the IPC protocol (wrapping the Keem Bay IPC driver and + exposing it to higher level Xlink layer) + +In addition to the above, the driver exposes SoC information (like stepping,Documentation/vpu/vpu-stack-overview.rst line 129
Quoted 10 lines
Documentation/vpu/vpu-stack-overview.rst new file +10
-0+device ID, etc.) to user-space via sysfs. + +This driver depends on the 'Keem Bay IPC' driver, which enables the Keem Bay +IPC communication protocol. + +The driver uses the Firmware API to load the VPU firmware from user-space. + +Xlink-IPC +========= +This component is implementing the IPC specific Xlink protocol. It maps channelcomponent implements IPC-specific
Quoted 24 lines
Documentation/vpu/vpu-stack-overview.rst new file +24
-0+IDs to HW FIFO entries, using the Keem Bay VPU IPC driver. + +Some of the main functions this driver provides: + +* establishing a connection with an IPC device +* obtaining a list with the available devices +* obtaining the status for a device +* booting a device +* resetting a device +* opening and closing channels +* issuing read and write operations + +Xlink-core +========== + +This component implements an abstracted set of control and communication APIs +based on channel identification. It is intended to support VPU technology both +at SoC level as well as at IP level, over multiple interfaces. + +It provides symmetrical services, where the producer and the consumer have +the same privileges. + +Xlink driver has the ability to abstract several types of communication +channels underneath, allowing the usage of different interfaces with the sameDocumentation/vpu/vpu-stack-overview.rst line 163
Quoted 10 lines
Documentation/vpu/vpu-stack-overview.rst new file +10
-0+function calls. + +Xlink services are available to both kernel and user space clients and include: + +* interface abstract control and communication API +* multi device support +* concurrent communication across 4096 communication channels (from 0 to + 0xFFF), with customizable properties +* full duplex channels with multiprocess and multithread support +* channel IDs can be mapped to desired physical interface (PCIE, USB, ETH, IPC)PCIe
Documentation/vpu/vpu-stack-overview.rst line 165
Quoted 2 lines
Documentation/vpu/vpu-stack-overview.rst new file +2
-0+ via a Channel Mapping Table +* asynchronous fast pass through mode: remote host data packets are directlypassthrough
Documentation/vpu/vpu-stack-overview.rst line 173
Quoted 8 lines
Documentation/vpu/vpu-stack-overview.rst new file +8
-0+ dispatched using interrupt systems running on local host to IPC calls for low + overhead +* channel handshaking mechanism for peer to peer communication, without the + need of static channel preallocation +* channel resource management +* asynchronous data and device notifications to subscribers + +Xlink transports: PCIe, USB, ETH, IPCXLink-PCIeIPC,
Documentation/vpu/vpu-stack-overview.rst line 175
Quoted 2 lines
Documentation/vpu/vpu-stack-overview.rst new file +2
-0+ +XLink-PCIEPCIe
Documentation/vpu/vpu-stack-overview.rst line 177
Quoted 2 lines
Documentation/vpu/vpu-stack-overview.rst new file +2
-0+========== +This is an endpoint driver that is mapping Xlink channel IDs to PCIE channels.that maps PCIe
Documentation/vpu/vpu-stack-overview.rst line 180
Quoted 3 lines
Documentation/vpu/vpu-stack-overview.rst new file +3
-0+ +This component ensures (remote)host-to-(local)host communication, and VPU IP +communication via an asynchronous pass through mode, where PCIE data loads arepassthrough PCIe
Documentation/vpu/vpu-stack-overview.rst line 183
Quoted 3 lines
Documentation/vpu/vpu-stack-overview.rst new file +3
-0+directly dispatched to Xlink-IPC. + +The component builds and advertises Device IDs that can are used by local hostthat are used
Documentation/vpu/vpu-stack-overview.rst line 188
Quoted 5 lines
Documentation/vpu/vpu-stack-overview.rst new file +5
-0+application in case of multi device scenarios. + +XLink-USB +========== +This is an endpoint driver that is mapping Xlink channel IDs to bidirectionalthat maps
Documentation/vpu/vpu-stack-overview.rst line 189
Quoted 1 line
Documentation/vpu/vpu-stack-overview.rst new file +1
-0+USB endpoints and supports CDC USB class protocol. More than one Xlink channelschannel
Documentation/vpu/vpu-stack-overview.rst line 193
Quoted 4 lines
Documentation/vpu/vpu-stack-overview.rst new file +4
-0+can be mapped to a single USB endpoint. + +This component ensures host-to-host communication, and, as well, asynchronous +pass through communication, where USB transfer packets are directly dispatchedpassthrough
Documentation/vpu/vpu-stack-overview.rst line 196
Quoted 3 lines
Documentation/vpu/vpu-stack-overview.rst new file +3
-0+to Xlink-IPC. + +The component builds and advertises Device IDs that can are used by local hostthat are used
Documentation/vpu/vpu-stack-overview.rst line 202
Quoted 6 lines
Documentation/vpu/vpu-stack-overview.rst new file +6
-0+application in case of multi device scenarios. + +XLink-ETH +========= + +This is an endpoint driver that is mapping Xlink channel IDs to Ethernetthat maps
Documentation/vpu/vpu-stack-overview.rst line 206
Quoted 4 lines
Documentation/vpu/vpu-stack-overview.rst new file +4
-0+sockets. + +This component ensures host-to-host communication, and, as well, asynchronous +pass through communication, where Ethernet data loads are directly dispatched topassthrough
Documentation/vpu/vpu-stack-overview.rst line 209
Quoted 3 lines
Documentation/vpu/vpu-stack-overview.rst new file +3
-0+Xlink-IPC. + +The component builds and advertises Device IDs that can are used by local hostthat are used
Documentation/vpu/vpu-stack-overview.rst line 218
Quoted 9 lines
Documentation/vpu/vpu-stack-overview.rst new file +9
-0+application in case of multi device scenarios. + +Assorted drivers that depend on this stack: + +Xlink-SMB +========= +The Intel Edge.AI Computer Vision platforms have to be monitored using platform +devices like sensors, fan controller, IO expander etc. Some of these devices +are memory mapped and some are i2c based. Either of these devices are notI2C-based. None of these devices is
Documentation/vpu/vpu-stack-overview.rst line 224
Quoted 6 lines
Documentation/vpu/vpu-stack-overview.rst new file +6
-0+directly accessible to the host. + +The host here refers to the server to which the vision accelerators are +connected over PCIe Interface. The Host needs to do a consolidated action based +on the parameters of platform devices. In general, most of the standard devices +(includes sensors, fan controller, IO expander etc) are I2C/SMBus based and areSMBus-based
Documentation/vpu/vpu-stack-overview.rst line 226
Quoted 2 lines
Documentation/vpu/vpu-stack-overview.rst new file +2
-0+used to provide the status of the accelerator. Standard drivers for these +devices are available based on i2c/smbus APIs.I2C/SMBus
Documentation/vpu/vpu-stack-overview.rst line 229
Quoted 3 lines
Documentation/vpu/vpu-stack-overview.rst new file +3
-0+ +Instead of changing the sensor drivers to adapt to PCIe interface, a generic +i2c adapter "xlink-smbus" which underneath uses xlink as physical medium isI2C Xlink
Documentation/vpu/vpu-stack-overview.rst line 230
Quoted 1 line
Documentation/vpu/vpu-stack-overview.rst new file +1
-0+used. With xlink-smbus, the drivers for the platform devices doesn't need todon't
Documentation/vpu/vpu-stack-overview.rst line 237
Quoted 7 lines
Documentation/vpu/vpu-stack-overview.rst new file +7
-0+undergo any interface change. + +TSEN +==== + +Thermal sensor driver for exporting thermal events to the local Arm64 host as +well as to the remote X86 host if in the PCIe add in CV acceleratoradd-in
Documentation/vpu/vpu-stack-overview.rst line 240
Quoted 3 lines
Documentation/vpu/vpu-stack-overview.rst new file +3
-0+configuration. + +The driver receiving the junction temperature from different heating pointsreceives
Documentation/vpu/vpu-stack-overview.rst line 241
Quoted 1 line
Documentation/vpu/vpu-stack-overview.rst new file +1
-0+inside the SOC. The driver will receive the temperature on SMBUS connection andSMBus
Documentation/vpu/vpu-stack-overview.rst line 244
Quoted 3 lines
Documentation/vpu/vpu-stack-overview.rst new file +3
-0+forward over xlink-smb when in a remote host configuration. + +In Keem Bay, the four thermal junction temperature points are, Media Subsystem^no comma
Documentation/vpu/vpu-stack-overview.rst line 245
Quoted 1 line
Documentation/vpu/vpu-stack-overview.rst new file +1
-0+(mss), NN subsystem (nce), Compute subsystem (cse) and SOC(Maximum of mss, nceand SOC (maximum of mss, nce
Documentation/vpu/vpu-stack-overview.rst line 246
Quoted 1 line
Documentation/vpu/vpu-stack-overview.rst new file +1
-0+and cse)cse).Documentation/vpu/vpu-stack-overview.rst line 257
Quoted 11 lines
Documentation/vpu/vpu-stack-overview.rst new file +11
-0+ +HDDL +==== + +- Exports details of temperature sensor, current sensor and fan controller + present in Intel Edge.AI Computer Vision platforms to IA host. +- Enable Time sync of Intel Edge.AI Computer Vision platform with IA host. +- Handles device connect and disconnect events. +- Receives slave address from the IA host for memory mapped thermal sensors + present in SoC (Documentation/hwmon/intel_tsens_sensors.rst). +- Registers i2c slave device for slaves present in Intel Edge.AI ComputerI2C
Quoted 15 lines
Quoted 11 lines
Documentation/vpu/vpu-stack-overview.rst new file +10
-0+ Vision platform + + +VPUMGR (VPU Manager) +==================== + +Bridges firmware on VPU side and applications on CPU user-space, it assists +firmware on VPU side serving multiple user space application processes on CPU +side concurrently while also performing necessary data buffer management on +behalf of VPU IP.Signature · 1 line
~Randy
Thanks for the great feedback I've just applied it to my tree for the next posting.
--mark
PATCH 2/22 dt-bindings: Add bindings for Keem Bay IPC driver
In reply to [email protected]From: Daniele Alessandrelli <[email protected]>
Add DT binding documentation for the Intel Keem Bay IPC driver, which enables communication between the Computing Sub-System (CSS) and the Multimedia Sub-System (MSS) of the Intel Movidius SoC code named Keem Bay.
--- .../bindings/soc/intel/intel,keembay-ipc.yaml | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/intel/intel,keembay-ipc.yaml
Documentation/devicetree/bindings/soc/intel/intel,keembay-ipc.yaml new file +63 -0
@@ -0,0 +1,63 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +# Copyright (C) 2020 Intel Corporation +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/soc/intel/intel,keembay-ipc.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Keem Bay IPC + +maintainers: + - Daniele Alessandrelli <[email protected]> + +description: + The Keem Bay IPC driver enables Inter-Processor Communication (IPC) with the + Visual Processor Unit (VPU) embedded in the Intel Movidius SoC code named + Keem Bay. + +properties: + compatible: + const: intel,keembay-ipc + + reg: + items: + - description: The CSS (CPU) FIFO registers + - description: The MSS (VPU) FIFO registers + + reg-names: + items: + - const: css_fifo + - const: mss_fifo + + interrupts: + items: + - description: CSS FIFO not-empty interrupt + + interrupt-controller: true + + memory-region: + items: + - description: Reserved memory region used for CSS IPC buffers + - description: Reserved memory region used for MSS IPC buffers + +required: + - compatible + - reg + - reg-names + - interrupts + - memory-region + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + ipc@203300f0 { + compatible = "intel,keembay-ipc"; + reg = <0x203300f0 0x310>, /* CPU TIM FIFO */ + <0x208200f0 0x310>; /* VPU TIM FIFO */ + reg-names = "css_fifo", "mss_fifo"; + interrupts = <GIC_SPI 12 IRQ_TYPE_LEVEL_HIGH>; + memory-region = <&css_ipc_reserved>, <&mss_ipc_reserved>; + };
Signature · 1 line
2.17.1
Rob Herring
maintainerRe: [PATCH 02/22] dt-bindings: Add bindings for Keem Bay IPC driver
Quoted 27 lines · On Tue, Dec 01, 2020 at 02:34:51PM -0800, [email protected] wrote:
From: Daniele Alessandrelli <[email protected]>
Add DT binding documentation for the Intel Keem Bay IPC driver, which enables communication between the Computing Sub-System (CSS) and the Multimedia Sub-System (MSS) of the Intel Movidius SoC code named Keem Bay.
Reviewed-by Mark Gross <[email protected]>Signed-off-by Daniele Alessandrelli <[email protected]>--- .../bindings/soc/intel/intel,keembay-ipc.yaml | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/intel/intel,keembay-ipc.yamlDocumentation/devicetree/bindings/soc/intel/intel,keembay-ipc.yaml new file +6
-0@@ -0,0 +1,63 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +# Copyright (C) 2020 Intel Corporation +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/soc/intel/intel,keembay-ipc.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#"
Documentation/devicetree/bindings/soc/intel/intel,keembay-ipc.yaml line 16
Quoted 10 lines
Documentation/devicetree/bindings/soc/intel/intel,keembay-ipc.yaml new file +10
-0+ +title: Keem Bay IPC + +maintainers: + - Daniele Alessandrelli <[email protected]> + +description: + The Keem Bay IPC driver enables Inter-Processor Communication (IPC) with the + Visual Processor Unit (VPU) embedded in the Intel Movidius SoC code named + Keem Bay.
Sounds like a mailbox.
What's the relationship between this and the xlink thing?
Quoted 50 lines
Documentation/devicetree/bindings/soc/intel/intel,keembay-ipc.yaml new file +47
-0+ +properties: + compatible: + const: intel,keembay-ipc + + reg: + items: + - description: The CSS (CPU) FIFO registers + - description: The MSS (VPU) FIFO registers + + reg-names: + items: + - const: css_fifo + - const: mss_fifo + + interrupts: + items: + - description: CSS FIFO not-empty interrupt + + interrupt-controller: true + + memory-region: + items: + - description: Reserved memory region used for CSS IPC buffers + - description: Reserved memory region used for MSS IPC buffers + +required: + - compatible + - reg + - reg-names + - interrupts + - memory-region + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + ipc@203300f0 { + compatible = "intel,keembay-ipc"; + reg = <0x203300f0 0x310>, /* CPU TIM FIFO */ + <0x208200f0 0x310>; /* VPU TIM FIFO */ + reg-names = "css_fifo", "mss_fifo"; + interrupts = <GIC_SPI 12 IRQ_TYPE_LEVEL_HIGH>; + memory-region = <&css_ipc_reserved>, <&mss_ipc_reserved>; + };Signature · 1 line
2.17.1
Re: [PATCH 02/22] dt-bindings: Add bindings for Keem Bay IPC driver
Quoted 32 lines · Rob Herring
Quoted 31 lines · On Tue, Dec 01, 2020 at 02:34:51PM -0800, [email protected] wrote:
From: Daniele Alessandrelli <[email protected]>
Add DT binding documentation for the Intel Keem Bay IPC driver, which enables communication between the Computing Sub-System (CSS) and the Multimedia Sub-System (MSS) of the Intel Movidius SoC code named Keem Bay.
Reviewed-by Mark Gross <[email protected]>Signed-off-by Daniele Alessandrelli <[email protected]>--- .../bindings/soc/intel/intel,keembay-ipc.yaml | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/intel/intel,keembay-ipc.yamlDocumentation/devicetree/bindings/soc/intel/intel,keembay-ipc.yaml new file +10
-0@@ -0,0 +1,63 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +# Copyright (C) 2020 Intel Corporation +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/soc/intel/intel,keembay-ipc.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Keem Bay IPC + +maintainers:
Quoted 8 lines
Documentation/devicetree/bindings/soc/intel/intel,keembay-ipc.yaml line 16
Quoted 6 lines
Documentation/devicetree/bindings/soc/intel/intel,keembay-ipc.yaml new file +6
-0+ - Daniele Alessandrelli <[email protected]> + +description: + The Keem Bay IPC driver enables Inter-Processor Communication (IPC) with the + Visual Processor Unit (VPU) embedded in the Intel Movidius SoC code named + Keem Bay.Sounds like a mailbox.
Its a multi-channel mailbox like thing with priority channel support.
Quoted 2 lines
What's the relationship between this and the xlink thing?
Xlink is a SW abstraction to allow multiple user access to the VPU as well as enabling use cases where a Keem Bay is used as an accelerator add in card as well as a simple SBC type of design. The xlink stuff sits on top of the IPC stuff.
--mark
Re: [PATCH 02/22] dt-bindings: Add bindings for Keem Bay IPC driver
In reply to Rob HerringHi Rob,
Thanks for the feedback.
Quoted 8 lines · Rob Herring
Quoted 7 lines · On Tue, Dec 01, 2020 at 02:34:51PM -0800, [email protected] wrote:
From: Daniele Alessandrelli <[email protected]>
Add DT binding documentation for the Intel Keem Bay IPC driver, which enables communication between the Computing Sub-System (CSS) and the Multimedia Sub-System (MSS) of the Intel Movidius SoC code named Keem Bay.
[cut]
Quoted 7 lines
Documentation/devicetree/bindings/soc/intel/intel,keembay-ipc.yaml line 16
Quoted 5 lines
Documentation/devicetree/bindings/soc/intel/intel,keembay-ipc.yaml new file +5
-0+ +description: + The Keem Bay IPC driver enables Inter-Processor Communication (IPC) with the + Visual Processor Unit (VPU) embedded in the Intel Movidius SoC code named + Keem Bay.Sounds like a mailbox.
We did consider using the mailbox framework, but eventually decided against it; mainly because of the following two reasons:
1. The channel concept in the Mailbox framework is different than the channel concept in Keem Bay IPC:
a. My understanding is that Mailbox channels are meant to be SW
representation of physical HW channels, while in Keem Bay IPC channels are software abstractions to achieve communication multiplexing over a single HW link
b. Additionally, Keem Bay IPC has two different classes of channels
(high-speed channels and general-purpose channels) that need to access the same HW link with different priorities.
2. The blocking / non-blocking TX behavior of mailbox channels is defined at channel creation time (by the tx_block value of the mailbox client passed to mbox_request_channel(); my understanding is that the tx_block value cannot be modified after the channel is created), while in Keem Bay IPC the same channel can be used for both blocking and non-blocking TX (behavior is controlled by the timeout argument passed to keembay_ipc_send()).
Having said that, I guess that it could be possible to create a Mailbox driver implementing the core communication mechanism used by the Keem Bay IPC and then build our API around it (basically having two drivers). But I'm not sure that would make the code simpler or easier to maintain. Any thoughts on this?
Quoted 4 lines
What's the relationship between this and the xlink thing?
xLink internally uses Keem Bay IPC to communicate with the VPU. Basically, Keem Bay IPC is the lowest layer of the xLink stack.
Re: [PATCH 02/22] dt-bindings: Add bindings for Keem Bay IPC driver
Quoted 28 lines · Daniele Alessandrelli
Hi Rob,
Thanks for the feedback.
Quoted 8 lines · Rob Herring
Quoted 7 lines · On Tue, Dec 01, 2020 at 02:34:51PM -0800, [email protected] wrote:
From: Daniele Alessandrelli <[email protected]>
Add DT binding documentation for the Intel Keem Bay IPC driver, which enables communication between the Computing Sub-System (CSS) and the Multimedia Sub-System (MSS) of the Intel Movidius SoC code named Keem Bay.
[cut]
Quoted 7 lines
Documentation/devicetree/bindings/soc/intel/intel,keembay-ipc.yaml line 16
Quoted 5 lines
Documentation/devicetree/bindings/soc/intel/intel,keembay-ipc.yaml new file +5
-0+ +description: + The Keem Bay IPC driver enables Inter-Processor Communication (IPC) with the + Visual Processor Unit (VPU) embedded in the Intel Movidius SoC code named + Keem Bay.Sounds like a mailbox.
We did consider using the mailbox framework, but eventually decided against it; mainly because of the following two reasons:
Quoted 8 lines
1. The channel concept in the Mailbox framework is different than the channel concept in Keem Bay IPC:
a. My understanding is that Mailbox channels are meant to be SW
representation of physical HW channels, while in Keem Bay IPC channels are software abstractions to achieve communication multiplexing over a single HW link
In mailbox api, that would be a physical channel shared between various clients.
Quoted 4 lines
b. Additionally, Keem Bay IPC has two different classes of channels
(high-speed channels and general-purpose channels) that need to access the same HW link with different priorities.
If the priorities are hard (programmed into some register), you could do that via dt during channel population.
If they are soft, that would be handled in the shared channel implementation.
Quoted 4 lines
2. The blocking / non-blocking TX behavior of mailbox channels is defined at channel creation time (by the
tx_blockvalue of the mailbox client passed tombox_request_channel();
No, that is checked at mbox_send_message()
Quoted 4 lines
my understanding
is that thetx_blockvalue cannot be modified after the channel is created),
Again no. If you don't queue more than one message at any time you can change it between transfers. To be safe you can always change it between channel release - request calls.
Quoted 10 lines
while in Keem Bay IPC the same channel can be used for
both blocking and non-blocking TX (behavior is controlled by the timeout argument passed tokeembay_ipc_send()).Having said that, I guess that it could be possible to create a Mailbox driver implementing the core communication mechanism used by the Keem Bay IPC and then build our API around it (basically having two drivers). But I'm not sure that would make the code simpler or easier to maintain. Any thoughts on this?
I think so. Most of KeemBay specific behaviour would be implemented in the shared channel above the mailbox api.
cheers!
Re: [PATCH 02/22] dt-bindings: Add bindings for Keem Bay IPC driver
Quoted 66 lines · Jassi Brar
Quoted 28 lines · Daniele Alessandrelli
Hi Rob,
Thanks for the feedback.
Quoted 8 lines · Rob Herring
Quoted 7 lines · On Tue, Dec 01, 2020 at 02:34:51PM -0800, [email protected] wrote:
From: Daniele Alessandrelli <[email protected]>
Add DT binding documentation for the Intel Keem Bay IPC driver, which enables communication between the Computing Sub-System (CSS) and the Multimedia Sub-System (MSS) of the Intel Movidius SoC code named Keem Bay.
[cut]
Quoted 7 lines
Documentation/devicetree/bindings/soc/intel/intel,keembay-ipc.yaml line 16
Quoted 5 lines
Documentation/devicetree/bindings/soc/intel/intel,keembay-ipc.yaml new file +5
-0+ +description: + The Keem Bay IPC driver enables Inter-Processor Communication (IPC) with the + Visual Processor Unit (VPU) embedded in the Intel Movidius SoC code named + Keem Bay.Sounds like a mailbox.
We did consider using the mailbox framework, but eventually decided against it; mainly because of the following two reasons:
Quoted 8 lines
1. The channel concept in the Mailbox framework is different than the channel concept in Keem Bay IPC:
a. My understanding is that Mailbox channels are meant to be SW
representation of physical HW channels, while in Keem Bay IPC channels are software abstractions to achieve communication multiplexing over a single HW linkIn mailbox api, that would be a physical channel shared between various clients.
Quoted 4 lines
b. Additionally, Keem Bay IPC has two different classes of channels
(high-speed channels and general-purpose channels) that need to access the same HW link with different priorities.If the priorities are hard (programmed into some register), you could do that via dt during channel population.
If they are soft, that would be handled in the shared channel implementation.Quoted 4 lines
2. The blocking / non-blocking TX behavior of mailbox channels is defined at channel creation time (by the
tx_blockvalue of the mailbox client passed tombox_request_channel();No, that is checked at
mbox_send_message()Quoted 4 lines
my understanding
is that thetx_blockvalue cannot be modified after the channel is created),Again no. If you don't queue more than one message at any time you can change it between transfers. To be safe you can always change it between channel release - request calls.
Quoted 4 lines
while in Keem Bay IPC the same channel can be used for
both blocking and non-blocking TX (behavior is controlled by the timeout argument passed tokeembay_ipc_send()).
Quoted 8 lines
Quoted 6 lines
Having said that, I guess that it could be possible to create a Mailbox driver implementing the core communication mechanism used by the Keem Bay IPC and then build our API around it (basically having two drivers). But I'm not sure that would make the code simpler or easier to maintain. Any thoughts on this?
I think so. Most of KeemBay specific behaviour would be implemented in the shared channel above the mailbox api.
Quick question. By "I think so" do you mean that you feel the keem bay IPC code will be simpler and easier to maintain if we make yet another driver at the Keem Bay IPC driver sits on top off? Or, the current implementation would be simpler if we rework the implementation to use the mailbox api?
I'm just now ramping on the common mailbox framework so that may be a dumb question. I would like to be confident reworking the driver to use the mailbox api will not lead to blocking issues before we start that.
thanks!
--mark
Re: [PATCH 02/22] dt-bindings: Add bindings for Keem Bay IPC driver
Quoted 74 lines · mark gross
Quoted 72 lines · Jassi Brar
Quoted 28 lines · Daniele Alessandrelli
Hi Rob,
Thanks for the feedback.
Quoted 8 lines · Rob Herring
Quoted 7 lines · On Tue, Dec 01, 2020 at 02:34:51PM -0800, [email protected] wrote:
From: Daniele Alessandrelli <[email protected]>
Add DT binding documentation for the Intel Keem Bay IPC driver, which enables communication between the Computing Sub-System (CSS) and the Multimedia Sub-System (MSS) of the Intel Movidius SoC code named Keem Bay.
[cut]
Quoted 7 lines
Documentation/devicetree/bindings/soc/intel/intel,keembay-ipc.yaml line 16
Quoted 5 lines
Documentation/devicetree/bindings/soc/intel/intel,keembay-ipc.yaml new file +5
-0+ +description: + The Keem Bay IPC driver enables Inter-Processor Communication (IPC) with the + Visual Processor Unit (VPU) embedded in the Intel Movidius SoC code named + Keem Bay.Sounds like a mailbox.
We did consider using the mailbox framework, but eventually decided against it; mainly because of the following two reasons:
Quoted 8 lines
1. The channel concept in the Mailbox framework is different than the channel concept in Keem Bay IPC:
a. My understanding is that Mailbox channels are meant to be SW
representation of physical HW channels, while in Keem Bay IPC channels are software abstractions to achieve communication multiplexing over a single HW linkIn mailbox api, that would be a physical channel shared between various clients.
Quoted 4 lines
b. Additionally, Keem Bay IPC has two different classes of channels
(high-speed channels and general-purpose channels) that need to access the same HW link with different priorities.If the priorities are hard (programmed into some register), you could do that via dt during channel population.
If they are soft, that would be handled in the shared channel implementation.Quoted 4 lines
2. The blocking / non-blocking TX behavior of mailbox channels is defined at channel creation time (by the
tx_blockvalue of the mailbox client passed tombox_request_channel();No, that is checked at
mbox_send_message()Quoted 4 lines
my understanding
is that thetx_blockvalue cannot be modified after the channel is created),Again no. If you don't queue more than one message at any time you can change it between transfers. To be safe you can always change it between channel release - request calls.
Quoted 10 lines
while in Keem Bay IPC the same channel can be used for
both blocking and non-blocking TX (behavior is controlled by the timeout argument passed tokeembay_ipc_send()).Having said that, I guess that it could be possible to create a Mailbox driver implementing the core communication mechanism used by the Keem Bay IPC and then build our API around it (basically having two drivers). But I'm not sure that would make the code simpler or easier to maintain. Any thoughts on this?
Quoted 5 lines
Quoted 2 lines
I think so. Most of KeemBay specific behaviour would be implemented in the shared channel above the mailbox api.
Quick question. By "I think so"
From what I have read, it seems it should be doable as a mailbox.
Quoted 5 lines
do you mean that you feel the keem bay IPC
code will be simpler and easier to maintain if we make yet another driver at the Keem Bay IPC driver sits on top off? Or, the current implementation would be simpler if we rework the implementation to use the mailbox api?
Most of the queue management code would be taken over my mailbox api. And you'll have
separated out the pure controller driver from protocol assumptions. So there shouldn't be extra code... just this code reorganised and some reduced.
cheers!
Rob Herring
maintainerRe: [PATCH 02/22] dt-bindings: Add bindings for Keem Bay IPC driver
In reply to Daniele AlessandrelliQuoted 47 lines · Daniele Alessandrelli
Hi Rob,
Thanks for the feedback.
Quoted 8 lines · Rob Herring
Quoted 7 lines · On Tue, Dec 01, 2020 at 02:34:51PM -0800, [email protected] wrote:
From: Daniele Alessandrelli <[email protected]>
Add DT binding documentation for the Intel Keem Bay IPC driver, which enables communication between the Computing Sub-System (CSS) and the Multimedia Sub-System (MSS) of the Intel Movidius SoC code named Keem Bay.
[cut]
Quoted 7 lines
Documentation/devicetree/bindings/soc/intel/intel,keembay-ipc.yaml line 16
Quoted 5 lines
Documentation/devicetree/bindings/soc/intel/intel,keembay-ipc.yaml new file +5
-0+ +description: + The Keem Bay IPC driver enables Inter-Processor Communication (IPC) with the + Visual Processor Unit (VPU) embedded in the Intel Movidius SoC code named + Keem Bay.Sounds like a mailbox.
We did consider using the mailbox framework, but eventually decided against it; mainly because of the following two reasons:
1. The channel concept in the Mailbox framework is different than the channel concept in Keem Bay IPC:
a. My understanding is that Mailbox channels are meant to be SW
representation of physical HW channels, while in Keem Bay IPC channels are software abstractions to achieve communication multiplexing over a single HW linkb. Additionally, Keem Bay IPC has two different classes of channels
(high-speed channels and general-purpose channels) that need to access the same HW link with different priorities.2. The blocking / non-blocking TX behavior of mailbox channels is defined at channel creation time (by the
tx_blockvalue of the mailbox client passed tombox_request_channel(); my understanding is that thetx_blockvalue cannot be modified after the channel is created), while in Keem Bay IPC the same channel can be used for both blocking and non-blocking TX (behavior is controlled by the timeout argument passed tokeembay_ipc_send()).
Quoted 5 lines
Having said that, I guess that it could be possible to create a Mailbox driver implementing the core communication mechanism used by the Keem Bay IPC and then build our API around it (basically having two drivers). But I'm not sure that would make the code simpler or easier to maintain. Any thoughts on this?
The use of the mailbox binding and the kernel's mailbox framework are independent questions. I'm only concerned with the former (for purposes of this review).
Rob
PATCH 3/22 keembay-ipc: Add Keem Bay IPC module
In reply to [email protected]From: Daniele Alessandrelli <[email protected]>
On the Intel Movidius SoC code named Keem Bay, communication between the Computing Sub-System (CSS), i.e., the CPU, and the Multimedia Sub-System (MSS), i.e., the VPU is enabled by the Keem Bay Inter-Processor Communication (IPC) mechanism.
Add the driver for using Keem Bay IPC from within the Linux Kernel.
Keem Bay IPC uses the following terminology:
- Node: A processing entity that can use the IPC to communicate;
currently, we just have two nodes, CPU (CSS) and VPU (MSS).
- Link: Two nodes that can communicate over IPC form an IPC link
(currently, we just have one link, the one between the CPU and VPU).
- Channel: An IPC link can provide multiple IPC channels. IPC channels allow communication multiplexing, i.e., the same IPC link can be used by different applications for different communications. Each channel is identified by a channel ID, which must be unique within a single IPC link. Channels are divided in two categories, High-Speed (HS) channels and General-Purpose (GP) channels. HS channels have higher priority over GP channels.
Keem Bay IPC mechanism is based on shared memory and hardware FIFOs. Both the CPU and the VPU have their own hardware FIFO. When the CPU wants to send an IPC message to the VPU, it writes to the VPU FIFO (MSS FIFO); similarly, when MSS wants to send an IPC message to the CPU, it writes to the CPU FIFO (CSS FIFO).
A FIFO entry is simply a pointer to an IPC buffer (aka IPC header) stored in a portion of memory shared between the CPU and the VPU. Specifically, the FIFO entry contains the (VPU) physical address of the IPC buffer being transferred.
In turn, the IPC buffer contains the (VPU) physical address of the payload (which must be located in shared memory too) as well as other information (payload size, IPC channel ID, etc.).
Each IPC node instantiates a pool of IPC buffers from its own IPC buffer memory region. When instantiated, IPC buffers are marked as free. When the node needs to send an IPC message, it gets the first free buffer it finds (from its own pool), marks it as allocated (used), and puts its physical address into the IPC FIFO of the destination node. The destination node (which is notified by an interrupt when there are entries pending in its FIFO) extract the physical address from the FIFO and process the IPC buffer, marking it as free once done (so that the sender can reuse the buffer).
--- MAINTAINERS | 8 + drivers/soc/Kconfig | 1 + drivers/soc/Makefile | 1 + drivers/soc/intel/Kconfig | 17 + drivers/soc/intel/Makefile | 4 + drivers/soc/intel/keembay-ipc.c | 1669 +++++++++++++++++++++++++ include/linux/soc/intel/keembay-ipc.h | 30 + 7 files changed, 1730 insertions(+) create mode 100644 drivers/soc/intel/Kconfig create mode 100644 drivers/soc/intel/Makefile create mode 100644 drivers/soc/intel/keembay-ipc.c create mode 100644 include/linux/soc/intel/keembay-ipc.h
MAINTAINERS +8 -0
@@ -8955,6 +8955,14 @@ M: Deepak Saxena <[email protected]> S: Maintained F: drivers/char/hw_random/ixp4xx-rng.c +INTEL KEEM BAY IPC DRIVER +M: Daniele Alessandrelli <[email protected]> +M: Mark Gross <[email protected]> +S: Maintained +F: Documentation/devicetree/bindings/soc/intel/intel,keembay-ipc.yaml +F: drivers/soc/intel/keembay-ipc.c +F: include/linux/soc/intel/keembay-ipc.h + INTEL MANAGEMENT ENGINE (mei) M: Tomas Winkler <[email protected]> L: [email protected]
drivers/soc/Kconfig +1 -0
@@ -8,6 +8,7 @@ source "drivers/soc/atmel/Kconfig" source "drivers/soc/bcm/Kconfig" source "drivers/soc/fsl/Kconfig" source "drivers/soc/imx/Kconfig" +source "drivers/soc/intel/Kconfig" source "drivers/soc/ixp4xx/Kconfig" source "drivers/soc/mediatek/Kconfig" source "drivers/soc/qcom/Kconfig"
drivers/soc/Makefile +1 -0
@@ -12,6 +12,7 @@ obj-$(CONFIG_MACH_DOVE) += dove/ obj-y += fsl/ obj-$(CONFIG_ARCH_GEMINI) += gemini/ obj-y += imx/ +obj-y += intel/ obj-$(CONFIG_ARCH_IXP4XX) += ixp4xx/ obj-$(CONFIG_SOC_XWAY) += lantiq/ obj-y += mediatek/
drivers/soc/intel/Kconfig new file +17 -0
@@ -0,0 +1,17 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Keem Bay SoC drivers +# + +menu "Intel SoC drivers" + +config KEEMBAY_IPC + tristate "Support for Intel Keem Bay IPC" + depends on ARCH_KEEMBAY || (ARM64 && COMPILE_TEST) + help + Keem Bay IPC enables communication between the Keem Bay CPU + Sub-System (CSS) and the Keem Bay Media Sub-System (MSS). + + Select this if you are compiling the Kernel for an Intel SoC that + includes the Intel Vision Processing Unit (VPU) such as Keem Bay. +endmenu
drivers/soc/intel/Makefile new file +4 -0
@@ -0,0 +1,4 @@ +# +# Makefile for Keem Bay IPC Linux driver +# +obj-$(CONFIG_KEEMBAY_IPC) += keembay-ipc.o
drivers/soc/intel/keembay-ipc.c new file +1669 -0
1,669 lines not on this page · raw message
include/linux/soc/intel/keembay-ipc.h new file +30 -0
@@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Keem Bay IPC Linux Kernel API +* +* Copyright (C) 2018-2020 Intel Corporation +*/ + +#ifndef __KEEMBAY_IPC_H +#define __KEEMBAY_IPC_H + +#include <linux/types.h> + +/* The possible node IDs. */ +enum { +KMB_IPC_NODE_ARM_CSS =0 , +KMB_IPC_NODE_LEON_MSS , +}; + +int intel_keembay_ipc_open_channel (struct device *dev,u8 node_id,u16 chan_id); + +int intel_keembay_ipc_close_channel (struct device *dev,u8 node_id, +u16 chan_id); + +int intel_keembay_ipc_send (struct device *dev,u8 node_id,u16 chan_id, +u32 vpu_addr,size_t size); + +int intel_keembay_ipc_recv (struct device *dev,u8 node_id,u16 chan_id, +u32 *vpu_addr,size_t *size,u32 timeout); + +#endif /* __KEEMBAY_IPC_H */
Signature · 1 line
2.17.1
Greg KH
maintainerRe: [PATCH 03/22] keembay-ipc: Add Keem Bay IPC module
MAINTAINERS M: Deepak Saxena <[email protected]> · line 8964
Quoted 13 lines · On Tue, Dec 01, 2020 at 02:34:52PM -0800, [email protected] wrote:
MAINTAINERS +7
-0@@ -8955,6 +8955,14 @@ M: Deepak Saxena <[email protected]> S: Maintained F: drivers/char/hw_random/ixp4xx-rng.c +INTEL KEEM BAY IPC DRIVER +M: Daniele Alessandrelli <[email protected]> +M: Mark Gross <[email protected]> +S: Maintained +F: Documentation/devicetree/bindings/soc/intel/intel,keembay-ipc.yaml +F: drivers/soc/intel/keembay-ipc.c +F: include/linux/soc/intel/keembay-ipc.h
Sad that Intel is not going to actually pay you all to do this maintenance work for a brand new subsystem you are wanting to add to the tree :(
Does this mean you all will have to do it on your own time and not as part of your work at Intel? If so, why not just use your personal email addresses instead to make it a bit more obvious?
thanks,
greg k-h
Re: [PATCH 03/22] keembay-ipc: Add Keem Bay IPC module
Quoted 7 lines · Greg KH
Quoted 6 lines · On Tue, Dec 01, 2020 at 02:34:52PM -0800, [email protected] wrote:
MAINTAINERS +0
-0@@ -8955,6 +8955,14 @@ M: Deepak Saxena <[email protected]> S: Maintained F: drivers/char/hw_random/ixp4xx-rng.c
Quoted 11 lines
MAINTAINERS M: Deepak Saxena <[email protected]> · line 8964
Quoted 7 lines
MAINTAINERS +7
-0+INTEL KEEM BAY IPC DRIVER +M: Daniele Alessandrelli <[email protected]> +M: Mark Gross <[email protected]> +S: Maintained +F: Documentation/devicetree/bindings/soc/intel/intel,keembay-ipc.yaml +F: drivers/soc/intel/keembay-ipc.c +F: include/linux/soc/intel/keembay-ipc.hSad that Intel is not going to actually pay you all to do this maintenance work for a brand new subsystem you are wanting to add to the tree :(
I thought adding my name to these maintainer items would help with continuity as the individual engineers tend to move on to other things over time.
While I'm paid for a number of things at intel this is one of them. My role is as stable as I choose it to be at the point I'm at in my Intel career and the business unit I'm now part of. We can leave my name off if that would be better.
Even if I'm not a VPU IP domain expert like Daniele is I can still chase down the experts as needed after Daniele grows into other things over time.
Quoted 4 lines
Does this mean you all will have to do it on your own time and not as part of your work at Intel? If so, why not just use your personal email addresses instead to make it a bit more obvious?
nah, as I've been getting older I've been getting more stingy with my me time with my non-tech hobbies. When I do retire (or whatever) from Intel we'll need to remove my name for the stuff I'll not be getting paid for any more.
--mark
Greg KH
maintainerRe: [PATCH 03/22] keembay-ipc: Add Keem Bay IPC module
Quoted 22 lines · mark gross
Quoted 7 lines · Greg KH
Quoted 6 lines · On Tue, Dec 01, 2020 at 02:34:52PM -0800, [email protected] wrote:
MAINTAINERS +0
-0@@ -8955,6 +8955,14 @@ M: Deepak Saxena <[email protected]> S: Maintained F: drivers/char/hw_random/ixp4xx-rng.cQuoted 11 lines
MAINTAINERS M: Deepak Saxena <[email protected]> · line 8964
Quoted 7 lines
MAINTAINERS +7
-0+INTEL KEEM BAY IPC DRIVER +M: Daniele Alessandrelli <[email protected]> +M: Mark Gross <[email protected]> +S: Maintained +F: Documentation/devicetree/bindings/soc/intel/intel,keembay-ipc.yaml +F: drivers/soc/intel/keembay-ipc.c +F: include/linux/soc/intel/keembay-ipc.hSad that Intel is not going to actually pay you all to do this maintenance work for a brand new subsystem you are wanting to add to the tree :(
I thought adding my name to these maintainer items would help with continuity as the individual engineers tend to move on to other things over time.
Quoted 7 lines
While I'm paid for a number of things at intel this is one of them. My role is as stable as I choose it to be at the point I'm at in my Intel career and the business unit I'm now part of. We can leave my name off if that would be better.
Even if I'm not a VPU IP domain expert like Daniele is I can still chase down the experts as needed after Daniele grows into other things over time.
I'm not objecting to your, or anyone else's name on this at all. I'm just asking about Intel's support for this new codebase being added. Having a new subsystem from a major company and not have someone paid to actually maintain it seems really odd to me.
That's all. If that's Intel's stance, that's fine, just wanted to clarify it is correct as I know some people at Intel have been confused recently about just what the S: field means.
thanks,
greg k-h
Re: [PATCH 03/22] keembay-ipc: Add Keem Bay IPC module
Quoted 31 lines · Greg KH
Quoted 22 lines · mark gross
Quoted 7 lines · Greg KH
Quoted 6 lines · On Tue, Dec 01, 2020 at 02:34:52PM -0800, [email protected] wrote:
MAINTAINERS +0
-0@@ -8955,6 +8955,14 @@ M: Deepak Saxena <[email protected]> S: Maintained F: drivers/char/hw_random/ixp4xx-rng.cQuoted 11 lines
MAINTAINERS M: Deepak Saxena <[email protected]> · line 8964
Quoted 7 lines
MAINTAINERS +7
-0+INTEL KEEM BAY IPC DRIVER +M: Daniele Alessandrelli <[email protected]> +M: Mark Gross <[email protected]> +S: Maintained +F: Documentation/devicetree/bindings/soc/intel/intel,keembay-ipc.yaml +F: drivers/soc/intel/keembay-ipc.c +F: include/linux/soc/intel/keembay-ipc.hSad that Intel is not going to actually pay you all to do this maintenance work for a brand new subsystem you are wanting to add to the tree :(
I thought adding my name to these maintainer items would help with continuity as the individual engineers tend to move on to other things over time.
Quoted 7 lines
While I'm paid for a number of things at intel this is one of them. My role is as stable as I choose it to be at the point I'm at in my Intel career and the business unit I'm now part of. We can leave my name off if that would be better.
Even if I'm not a VPU IP domain expert like Daniele is I can still chase down the experts as needed after Daniele grows into other things over time.
Quoted 8 lines
I'm not objecting to your, or anyone else's name on this at all. I'm just asking about Intel's support for this new codebase being added. Having a new subsystem from a major company and not have someone paid to actually maintain it seems really odd to me.
That's all. If that's Intel's stance, that's fine, just wanted to clarify it is correct as I know some people at Intel have been confused recently about just what the S: field means.
I've been following up on whether the status field should be "Supported" or "Maintained" at this time. For this current instantiation of the VPU enabling under review here I think Maintained most appropriate. There are a good number of people who look after it.
However; I have learned that the instantiations of the VPU after keem bay and its follow on SoC will include an evolution of this stack and between now and when those get close to landing that evolved version will become "Supported".
Given this, would it be more appropriate to put this stack into staging for a while?
--mark
Greg KH
maintainerRe: [PATCH 03/22] keembay-ipc: Add Keem Bay IPC module
Quoted 45 lines · mark gross
Quoted 31 lines · Greg KH
Quoted 22 lines · mark gross
Quoted 7 lines · Greg KH
Quoted 6 lines · On Tue, Dec 01, 2020 at 02:34:52PM -0800, [email protected] wrote:
MAINTAINERS +0
-0@@ -8955,6 +8955,14 @@ M: Deepak Saxena <[email protected]> S: Maintained F: drivers/char/hw_random/ixp4xx-rng.cQuoted 11 lines
MAINTAINERS M: Deepak Saxena <[email protected]> · line 8964
Quoted 7 lines
MAINTAINERS +7
-0+INTEL KEEM BAY IPC DRIVER +M: Daniele Alessandrelli <[email protected]> +M: Mark Gross <[email protected]> +S: Maintained +F: Documentation/devicetree/bindings/soc/intel/intel,keembay-ipc.yaml +F: drivers/soc/intel/keembay-ipc.c +F: include/linux/soc/intel/keembay-ipc.hSad that Intel is not going to actually pay you all to do this maintenance work for a brand new subsystem you are wanting to add to the tree :(
I thought adding my name to these maintainer items would help with continuity as the individual engineers tend to move on to other things over time.
Quoted 7 lines
While I'm paid for a number of things at intel this is one of them. My role is as stable as I choose it to be at the point I'm at in my Intel career and the business unit I'm now part of. We can leave my name off if that would be better.
Even if I'm not a VPU IP domain expert like Daniele is I can still chase down the experts as needed after Daniele grows into other things over time.
Quoted 8 lines
I'm not objecting to your, or anyone else's name on this at all. I'm just asking about Intel's support for this new codebase being added. Having a new subsystem from a major company and not have someone paid to actually maintain it seems really odd to me.
That's all. If that's Intel's stance, that's fine, just wanted to clarify it is correct as I know some people at Intel have been confused recently about just what the S: field means.
I've been following up on whether the status field should be "Supported" or "Maintained" at this time. For this current instantiation of the VPU enabling under review here I think Maintained most appropriate. There are a good number of people who look after it.
Quoted 6 lines
However; I have learned that the instantiations of the VPU after keem bay and its follow on SoC will include an evolution of this stack and between now and when those get close to landing that evolved version will become "Supported".
Given this, would it be more appropriate to put this stack into staging for a while?
drivers/staging/ is for code that for some reason is not good enough to be merged to the "right" place in the kernel tree, and you need community help to get it cleaned up because you can not do it yourself.
Is that the case here? If not, then no, it should not go into drivers/staging/.
thanks,
greg k-h
RE: [PATCH 03/22] keembay-ipc: Add Keem Bay IPC module
Quoted 68 lines
-----Original Message-----
From: Greg KH <[email protected]>
Sent: Saturday, December 5, 2020 12:40 AM
To: mark gross <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Alessandrelli, Daniele <[email protected]>; Iyer, Sundar <[email protected]>
Subject: Re: [PATCH 03/22] keembay-ipc: Add Keem Bay IPC moduleQuoted 10 lines · mark gross
Quoted 9 lines · Greg KH
Quoted 8 lines · mark gross
Quoted 7 lines · Greg KH
Quoted 6 lines · On Tue, Dec 01, 2020 at 02:34:52PM -0800, [email protected] wrote:
MAINTAINERS +0
-0@@ -8955,6 +8955,14 @@ M: Deepak Saxena <[email protected]> S: Maintained F: drivers/char/hw_random/ixp4xx-rng.cQuoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
MAINTAINERS M: Deepak Saxena <[email protected]>
Quoted 5 lines
MAINTAINERS +5
-0+INTEL KEEM BAY IPC DRIVER +M: Daniele Alessandrelli <[email protected]> +M: Mark Gross <[email protected]> +S: Maintained +F: Documentation/devicetree/bindings/soc/intel/intel,keembay-
ipc.yamlQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
MAINTAINERS M: Deepak Saxena <[email protected]> · line 8964
Quoted 2 lines
MAINTAINERS +2
-0+F: drivers/soc/intel/keembay-ipc.c +F: include/linux/soc/intel/keembay-ipc.hSad that Intel is not going to actually pay you all to do this maintenance work for a brand new subsystem you are wanting to add to the tree :(
I thought adding my name to these maintainer items would help with continuity as the individual engineers tend to move on to other things over
time.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
While I'm paid for a number of things at intel this is one of them. My role is as stable as I choose it to be at the point I'm at in my Intel career and the business unit I'm now part of. We can leave my name off if that would be better.
Even if I'm not a VPU IP domain expert like Daniele is I can still chase down the experts as needed after Daniele grows into other things over
time.
Quoted 9 lines
Quoted 9 lines
I'm not objecting to your, or anyone else's name on this at all. I'm just asking about Intel's support for this new codebase being added. Having a new subsystem from a major company and not have someone paid to actually maintain it seems really odd to me.
That's all. If that's Intel's stance, that's fine, just wanted to clarify it is correct as I know some people at Intel have been confused recently about just what the S: field means.
Quoted 8 lines
I've been following up on whether the status field should be "Supported" or "Maintained" at this time. For this current instantiation of the VPU enabling under review here I think Maintained most appropriate. There are a good number of people who look after it.
However; I have learned that the instantiations of the VPU after keem bay and its follow on SoC will include an evolution of this stack and between now and when those get close to landing that evolved version will
become "Supported".
Quoted 1 line
Quoted 8 lines
Quoted 2 lines
Given this, would it be more appropriate to put this stack into staging for a while?
drivers/staging/is for code that for some reason is not good enough to be merged to the "right" place in the kernel tree, and you need community help to get it cleaned up because you can not do it yourself.Is that the case here? If not, then no, it should not go into
drivers/staging/.
That is not the case here. Lets proceed as we are on this then.
Thanks!
--mark
Re: [PATCH 03/22] keembay-ipc: Add Keem Bay IPC module
Quoted 71 lines · Mark
Quoted 71 lines
-----Original Message-----
From: Greg KH <[email protected]>
Sent: Saturday, December 5, 2020 12:40 AM
To: mark gross <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Alessandrelli, Daniele <[email protected]>; Iyer, Sundar <[email protected]>
Subject: Re: [PATCH 03/22] keembay-ipc: Add Keem Bay IPC moduleQuoted 10 lines · mark gross
Quoted 9 lines · Greg KH
Quoted 8 lines · mark gross
Quoted 7 lines · Greg KH
Quoted 6 lines · On Tue, Dec 01, 2020 at 02:34:52PM -0800, [email protected] wrote:
MAINTAINERS +0
-0@@ -8955,6 +8955,14 @@ M: Deepak Saxena <[email protected]> S: Maintained F: drivers/char/hw_random/ixp4xx-rng.cQuoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
MAINTAINERS M: Deepak Saxena <[email protected]> · line 8962
Quoted 5 lines
MAINTAINERS +5
-0+INTEL KEEM BAY IPC DRIVER +M: Daniele Alessandrelli <[email protected]> +M: Mark Gross <[email protected]> +S: Maintained +F: Documentation/devicetree/bindings/soc/intel/intel,keembay-
ipc.yamlQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
MAINTAINERS M: Deepak Saxena <[email protected]> · line 8964
Quoted 2 lines
MAINTAINERS +2
-0+F: drivers/soc/intel/keembay-ipc.c +F: include/linux/soc/intel/keembay-ipc.hSad that Intel is not going to actually pay you all to do this maintenance work for a brand new subsystem you are wanting to add to the tree :(
I thought adding my name to these maintainer items would help with continuity as the individual engineers tend to move on to other things over
time.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
While I'm paid for a number of things at intel this is one of them. My role is as stable as I choose it to be at the point I'm at in my Intel career and the business unit I'm now part of. We can leave my name off if that would be better.
Even if I'm not a VPU IP domain expert like Daniele is I can still chase down the experts as needed after Daniele grows into other things over
time.
Quoted 9 lines
Quoted 9 lines
I'm not objecting to your, or anyone else's name on this at all. I'm just asking about Intel's support for this new codebase being added. Having a new subsystem from a major company and not have someone paid to actually maintain it seems really odd to me.
That's all. If that's Intel's stance, that's fine, just wanted to clarify it is correct as I know some people at Intel have been confused recently about just what the S: field means.
Quoted 8 lines
I've been following up on whether the status field should be "Supported" or "Maintained" at this time. For this current instantiation of the VPU enabling under review here I think Maintained most appropriate. There are a good number of people who look after it.
However; I have learned that the instantiations of the VPU after keem bay and its follow on SoC will include an evolution of this stack and between now and when those get close to landing that evolved version will
become "Supported".
Quoted 3 lines
Given this, would it be more appropriate to put this stack into staging for a while?
Quoted 7 lines
Quoted 5 lines
drivers/staging/is for code that for some reason is not good enough to be merged to the "right" place in the kernel tree, and you need community help to get it cleaned up because you can not do it yourself.Is that the case here? If not, then no, it should not go into
drivers/staging/.That is not the case here. Lets proceed as we are on this then.
I guess technically we have number of engineers paid to look after this version of the VPU enabling. I guess I'm over thinking things. I'll change it S:
record from Maintained to Supported on the next version.
--mark
Greg KH
maintainerRe: [PATCH 03/22] keembay-ipc: Add Keem Bay IPC module
In reply to [email protected]Quoted 42 lines · On Tue, Dec 01, 2020 at 02:34:52PM -0800, [email protected] wrote:
From: Daniele Alessandrelli <[email protected]>
On the Intel Movidius SoC code named Keem Bay, communication between the Computing Sub-System (CSS), i.e., the CPU, and the Multimedia Sub-System (MSS), i.e., the VPU is enabled by the Keem Bay Inter-Processor Communication (IPC) mechanism.
Add the driver for using Keem Bay IPC from within the Linux Kernel.
Keem Bay IPC uses the following terminology:
- Node: A processing entity that can use the IPC to communicate;
currently, we just have two nodes, CPU (CSS) and VPU (MSS).- Link: Two nodes that can communicate over IPC form an IPC link
(currently, we just have one link, the one between the CPU and VPU).- Channel: An IPC link can provide multiple IPC channels. IPC channels allow communication multiplexing, i.e., the same IPC link can be used by different applications for different communications. Each channel is identified by a channel ID, which must be unique within a single IPC link. Channels are divided in two categories, High-Speed (HS) channels and General-Purpose (GP) channels. HS channels have higher priority over GP channels.
Keem Bay IPC mechanism is based on shared memory and hardware FIFOs. Both the CPU and the VPU have their own hardware FIFO. When the CPU wants to send an IPC message to the VPU, it writes to the VPU FIFO (MSS FIFO); similarly, when MSS wants to send an IPC message to the CPU, it writes to the CPU FIFO (CSS FIFO).
A FIFO entry is simply a pointer to an IPC buffer (aka IPC header) stored in a portion of memory shared between the CPU and the VPU. Specifically, the FIFO entry contains the (VPU) physical address of the IPC buffer being transferred.
In turn, the IPC buffer contains the (VPU) physical address of the payload (which must be located in shared memory too) as well as other information (payload size, IPC channel ID, etc.).
Quoted 9 lines
Each IPC node instantiates a pool of IPC buffers from its own IPC buffer memory region. When instantiated, IPC buffers are marked as free. When the node needs to send an IPC message, it gets the first free buffer it finds (from its own pool), marks it as allocated (used), and puts its physical address into the IPC FIFO of the destination node. The destination node (which is notified by an interrupt when there are entries pending in its FIFO) extract the physical address from the FIFO and process the IPC buffer, marking it as free once done (so that the sender can reuse the buffer).
Any reason you can't use the dmabuf interface for these memory buffers you are creating and having to manage "by hand"? I thought that was what the kernel was wanting to unify on such that individual drivers/subsystems didn't have to do this on their own.
thanks,
greg k-h
Re: [PATCH 03/22] keembay-ipc: Add Keem Bay IPC module
Hi Greg,
Thanks for your feedback.
Quoted 53 lines · Greg KH
Quoted 42 lines · On Tue, Dec 01, 2020 at 02:34:52PM -0800, [email protected] wrote:
From: Daniele Alessandrelli <[email protected]>
On the Intel Movidius SoC code named Keem Bay, communication between the Computing Sub-System (CSS), i.e., the CPU, and the Multimedia Sub-System (MSS), i.e., the VPU is enabled by the Keem Bay Inter-Processor Communication (IPC) mechanism.
Add the driver for using Keem Bay IPC from within the Linux Kernel.
Keem Bay IPC uses the following terminology:
- Node: A processing entity that can use the IPC to communicate;
currently, we just have two nodes, CPU (CSS) and VPU (MSS).- Link: Two nodes that can communicate over IPC form an IPC link
(currently, we just have one link, the one between the CPU and VPU).- Channel: An IPC link can provide multiple IPC channels. IPC channels allow communication multiplexing, i.e., the same IPC link can be used by different applications for different communications. Each channel is identified by a channel ID, which must be unique within a single IPC link. Channels are divided in two categories, High-Speed (HS) channels and General-Purpose (GP) channels. HS channels have higher priority over GP channels.
Keem Bay IPC mechanism is based on shared memory and hardware FIFOs. Both the CPU and the VPU have their own hardware FIFO. When the CPU wants to send an IPC message to the VPU, it writes to the VPU FIFO (MSS FIFO); similarly, when MSS wants to send an IPC message to the CPU, it writes to the CPU FIFO (CSS FIFO).
A FIFO entry is simply a pointer to an IPC buffer (aka IPC header) stored in a portion of memory shared between the CPU and the VPU. Specifically, the FIFO entry contains the (VPU) physical address of the IPC buffer being transferred.
In turn, the IPC buffer contains the (VPU) physical address of the payload (which must be located in shared memory too) as well as other information (payload size, IPC channel ID, etc.).
Quoted 9 lines
Each IPC node instantiates a pool of IPC buffers from its own IPC buffer memory region. When instantiated, IPC buffers are marked as free. When the node needs to send an IPC message, it gets the first free buffer it finds (from its own pool), marks it as allocated (used), and puts its physical address into the IPC FIFO of the destination node. The destination node (which is notified by an interrupt when there are entries pending in its FIFO) extract the physical address from the FIFO and process the IPC buffer, marking it as free once done (so that the sender can reuse the buffer).
Quoted 4 lines
Any reason you can't use the dmabuf interface for these memory buffers you are creating and having to manage "by hand"? I thought that was what the kernel was wanting to unify on such that individual
drivers/subsystemsdidn't have to do this on their own.
My understanding is that the dmabuf interface is used to share DMA buffers across different drivers, while these buffers are used only internally to the IPC driver (and exchanged only with the VPU firmware). They basically are packet headers that are sent to the VPU.
So, unless I'm missing something, dmabuf is probably not a good fit here.
However, it could make sense to use dmabuf to share buffers across the drivers in the xLink stack. We'll look into that.
Greg KH
maintainerRe: [PATCH 03/22] keembay-ipc: Add Keem Bay IPC module
Quoted 63 lines · Daniele Alessandrelli
Hi Greg,
Thanks for your feedback.
Quoted 53 lines · Greg KH
Quoted 42 lines · On Tue, Dec 01, 2020 at 02:34:52PM -0800, [email protected] wrote:
From: Daniele Alessandrelli <[email protected]>
On the Intel Movidius SoC code named Keem Bay, communication between the Computing Sub-System (CSS), i.e., the CPU, and the Multimedia Sub-System (MSS), i.e., the VPU is enabled by the Keem Bay Inter-Processor Communication (IPC) mechanism.
Add the driver for using Keem Bay IPC from within the Linux Kernel.
Keem Bay IPC uses the following terminology:
- Node: A processing entity that can use the IPC to communicate;
currently, we just have two nodes, CPU (CSS) and VPU (MSS).- Link: Two nodes that can communicate over IPC form an IPC link
(currently, we just have one link, the one between the CPU and VPU).- Channel: An IPC link can provide multiple IPC channels. IPC channels allow communication multiplexing, i.e., the same IPC link can be used by different applications for different communications. Each channel is identified by a channel ID, which must be unique within a single IPC link. Channels are divided in two categories, High-Speed (HS) channels and General-Purpose (GP) channels. HS channels have higher priority over GP channels.
Keem Bay IPC mechanism is based on shared memory and hardware FIFOs. Both the CPU and the VPU have their own hardware FIFO. When the CPU wants to send an IPC message to the VPU, it writes to the VPU FIFO (MSS FIFO); similarly, when MSS wants to send an IPC message to the CPU, it writes to the CPU FIFO (CSS FIFO).
A FIFO entry is simply a pointer to an IPC buffer (aka IPC header) stored in a portion of memory shared between the CPU and the VPU. Specifically, the FIFO entry contains the (VPU) physical address of the IPC buffer being transferred.
In turn, the IPC buffer contains the (VPU) physical address of the payload (which must be located in shared memory too) as well as other information (payload size, IPC channel ID, etc.).
Quoted 9 lines
Each IPC node instantiates a pool of IPC buffers from its own IPC buffer memory region. When instantiated, IPC buffers are marked as free. When the node needs to send an IPC message, it gets the first free buffer it finds (from its own pool), marks it as allocated (used), and puts its physical address into the IPC FIFO of the destination node. The destination node (which is notified by an interrupt when there are entries pending in its FIFO) extract the physical address from the FIFO and process the IPC buffer, marking it as free once done (so that the sender can reuse the buffer).
Quoted 4 lines
Any reason you can't use the dmabuf interface for these memory buffers you are creating and having to manage "by hand"? I thought that was what the kernel was wanting to unify on such that individual
drivers/subsystemsdidn't have to do this on their own.
Quoted 4 lines
My understanding is that the dmabuf interface is used to share DMA buffers across different drivers, while these buffers are used only internally to the IPC driver (and exchanged only with the VPU firmware). They basically are packet headers that are sent to the VPU.
There's no reason you couldn't use these to share your buffers "internally" as well, because you have the same lifetime rules and accounting and all other sorts of things you have to handle, right? Why rewrite something like this when you should take advantage of common code instead?
thanks,
greg k-h
Re: [PATCH 03/22] keembay-ipc: Add Keem Bay IPC module
Quoted 69 lines · Greg KH
Quoted 63 lines · Daniele Alessandrelli
Hi Greg,
Thanks for your feedback.
Quoted 53 lines · Greg KH
Quoted 42 lines · On Tue, Dec 01, 2020 at 02:34:52PM -0800, [email protected] wrote:
From: Daniele Alessandrelli <[email protected]>
On the Intel Movidius SoC code named Keem Bay, communication between the Computing Sub-System (CSS), i.e., the CPU, and the Multimedia Sub-System (MSS), i.e., the VPU is enabled by the Keem Bay Inter-Processor Communication (IPC) mechanism.
Add the driver for using Keem Bay IPC from within the Linux Kernel.
Keem Bay IPC uses the following terminology:
- Node: A processing entity that can use the IPC to communicate;
currently, we just have two nodes, CPU (CSS) and VPU (MSS).- Link: Two nodes that can communicate over IPC form an IPC link
(currently, we just have one link, the one between the CPU and VPU).- Channel: An IPC link can provide multiple IPC channels. IPC channels allow communication multiplexing, i.e., the same IPC link can be used by different applications for different communications. Each channel is identified by a channel ID, which must be unique within a single IPC link. Channels are divided in two categories, High-Speed (HS) channels and General-Purpose (GP) channels. HS channels have higher priority over GP channels.
Keem Bay IPC mechanism is based on shared memory and hardware FIFOs. Both the CPU and the VPU have their own hardware FIFO. When the CPU wants to send an IPC message to the VPU, it writes to the VPU FIFO (MSS FIFO); similarly, when MSS wants to send an IPC message to the CPU, it writes to the CPU FIFO (CSS FIFO).
A FIFO entry is simply a pointer to an IPC buffer (aka IPC header) stored in a portion of memory shared between the CPU and the VPU. Specifically, the FIFO entry contains the (VPU) physical address of the IPC buffer being transferred.
In turn, the IPC buffer contains the (VPU) physical address of the payload (which must be located in shared memory too) as well as other information (payload size, IPC channel ID, etc.).
Quoted 9 lines
Each IPC node instantiates a pool of IPC buffers from its own IPC buffer memory region. When instantiated, IPC buffers are marked as free. When the node needs to send an IPC message, it gets the first free buffer it finds (from its own pool), marks it as allocated (used), and puts its physical address into the IPC FIFO of the destination node. The destination node (which is notified by an interrupt when there are entries pending in its FIFO) extract the physical address from the FIFO and process the IPC buffer, marking it as free once done (so that the sender can reuse the buffer).
Quoted 4 lines
Any reason you can't use the dmabuf interface for these memory buffers you are creating and having to manage "by hand"? I thought that was what the kernel was wanting to unify on such that individual
drivers/subsystemsdidn't have to do this on their own.Quoted 4 lines
My understanding is that the dmabuf interface is used to share DMA buffers across different drivers, while these buffers are used only internally to the IPC driver (and exchanged only with the VPU firmware). They basically are packet headers that are sent to the VPU.
Quoted 5 lines
There's no reason you couldn't use these to share your buffers "internally" as well, because you have the same lifetime rules and accounting and all other sorts of things you have to handle, right? Why rewrite something like this when you should take advantage of common code instead?
I looked at dma-buf again, but I'm still failing to see how we can use it in this driver :/
The problem I'm not able to solve is exactly how to match the lifetime of this IPC packets (IPC buffers is probably a misleading name, my bad for using it in the code) with the dma-buf lifetime rules.
Basically, these IPC packets are cache-aligned (64 bytes) and have the following fixed structure:
struct kmb_ipc_buf {
u32 data_addr;
u32 data_size;
u16 channel;
u8 src_node;
u8 dst_node;
u8 status;
} __packed __aligned(KMB_IPC_ALIGNMENT);Now, let's ignore the first 5 fields and focus on the last one that controls the lifetime of the packet. The status field can be either FREE or ALLOCATED (perhaps should be renamed to IN_USE).
Basically, during probe, the driver allocates an array (pool) of these packets from its 'local' reserved memory region. This is done using dma_alloc_coherent(). This array remains allocated until remove() is called.
At run-time, every time the driver sends a message to the VPU, the following happens:
1. The IPC driver loops through the array of 'local' packets to find the first one marked as FREE
2. The IPC driver marks the packet as IN_USE and shares it with the VPU by putting its physical address into the VPU HW FIFO.
3. The VPU Firmware processes the packet and, when done with it, it marks it as FREE again so that the IPC driver can use it again.
Please note that the IPC driver is not notified by the VPU when the packet is marked as free (there is no IRQ or other async mechanism to do that). The driver will simply find the message free the next time it loops over the message pool again (i.e., when it is trying to send a new message).
Given that the free operation is silently done by the VPU, I'm failing to see how I can use dmabuf (or gen_pool or dma_pool). Is there anything that I'm missing?
Greg KH
maintainerRe: [PATCH 03/22] keembay-ipc: Add Keem Bay IPC module
Quoted 86 lines · Daniele Alessandrelli
Quoted 69 lines · Greg KH
Quoted 63 lines · Daniele Alessandrelli
Hi Greg,
Thanks for your feedback.
Quoted 53 lines · Greg KH
Quoted 42 lines · On Tue, Dec 01, 2020 at 02:34:52PM -0800, [email protected] wrote:
From: Daniele Alessandrelli <[email protected]>
On the Intel Movidius SoC code named Keem Bay, communication between the Computing Sub-System (CSS), i.e., the CPU, and the Multimedia Sub-System (MSS), i.e., the VPU is enabled by the Keem Bay Inter-Processor Communication (IPC) mechanism.
Add the driver for using Keem Bay IPC from within the Linux Kernel.
Keem Bay IPC uses the following terminology:
- Node: A processing entity that can use the IPC to communicate;
currently, we just have two nodes, CPU (CSS) and VPU (MSS).- Link: Two nodes that can communicate over IPC form an IPC link
(currently, we just have one link, the one between the CPU and VPU).- Channel: An IPC link can provide multiple IPC channels. IPC channels allow communication multiplexing, i.e., the same IPC link can be used by different applications for different communications. Each channel is identified by a channel ID, which must be unique within a single IPC link. Channels are divided in two categories, High-Speed (HS) channels and General-Purpose (GP) channels. HS channels have higher priority over GP channels.
Keem Bay IPC mechanism is based on shared memory and hardware FIFOs. Both the CPU and the VPU have their own hardware FIFO. When the CPU wants to send an IPC message to the VPU, it writes to the VPU FIFO (MSS FIFO); similarly, when MSS wants to send an IPC message to the CPU, it writes to the CPU FIFO (CSS FIFO).
A FIFO entry is simply a pointer to an IPC buffer (aka IPC header) stored in a portion of memory shared between the CPU and the VPU. Specifically, the FIFO entry contains the (VPU) physical address of the IPC buffer being transferred.
In turn, the IPC buffer contains the (VPU) physical address of the payload (which must be located in shared memory too) as well as other information (payload size, IPC channel ID, etc.).
Quoted 9 lines
Each IPC node instantiates a pool of IPC buffers from its own IPC buffer memory region. When instantiated, IPC buffers are marked as free. When the node needs to send an IPC message, it gets the first free buffer it finds (from its own pool), marks it as allocated (used), and puts its physical address into the IPC FIFO of the destination node. The destination node (which is notified by an interrupt when there are entries pending in its FIFO) extract the physical address from the FIFO and process the IPC buffer, marking it as free once done (so that the sender can reuse the buffer).
Quoted 4 lines
Any reason you can't use the dmabuf interface for these memory buffers you are creating and having to manage "by hand"? I thought that was what the kernel was wanting to unify on such that individual
drivers/subsystemsdidn't have to do this on their own.Quoted 4 lines
My understanding is that the dmabuf interface is used to share DMA buffers across different drivers, while these buffers are used only internally to the IPC driver (and exchanged only with the VPU firmware). They basically are packet headers that are sent to the VPU.
Quoted 5 lines
There's no reason you couldn't use these to share your buffers "internally" as well, because you have the same lifetime rules and accounting and all other sorts of things you have to handle, right? Why rewrite something like this when you should take advantage of common code instead?
I looked at dma-buf again, but I'm still failing to see how we can use it in this driver :/
The problem I'm not able to solve is exactly how to match the lifetime of this IPC packets (IPC buffers is probably a misleading name, my bad for using it in the code) with the dma-buf lifetime rules.
Basically, these IPC packets are cache-aligned (64 bytes) and have the following fixed structure:
Quoted 8 lines
struct kmb_ipc_buf {
u32 data_addr;
u32 data_size;
u16 channel;
u8 src_node;
u8 dst_node;
u8 status;
} __packed __aligned(KMB_IPC_ALIGNMENT);If that is shared out of the kernel, please use the proper data types for it.
And it isn't properly padded out? That feels like a hardware design mistake somewhere, anyway...
Quoted 12 lines
Now, let's ignore the first 5 fields and focus on the last one that controls the lifetime of the packet. The status field can be either FREE or ALLOCATED (perhaps should be renamed to
IN_USE).Basically, during probe, the driver allocates an array (pool) of these packets from its 'local' reserved memory region. This is done using
dma_alloc_coherent(). This array remains allocated untilremove()is called.At run-time, every time the driver sends a message to the VPU, the following happens:
Quoted 6 lines
1. The IPC driver loops through the array of 'local' packets to find the first one marked as FREE
2. The IPC driver marks the packet asIN_USEand shares it with the VPU by putting its physical address into the VPU HW FIFO.
3. The VPU Firmware processes the packet and, when done with it, it marks it as FREE again so that the IPC driver can use it again.
How does the firmware "mark it as free"?
Quoted 9 lines
Please note that the IPC driver is not notified by the VPU when the packet is marked as free (there is no IRQ or other async mechanism to do that). The driver will simply find the message free the next time it loops over the message pool again (i.e., when it is trying to send a new message).
Given that the free operation is silently done by the VPU, I'm failing to see how I can use dmabuf (or
gen_poolordma_pool). Is there anything that I'm missing?
So maybe this isn't set up to use the dma buffers, but it still feels really odd. I recommend getting a review by the dmabuf authors before declaring that you really should be rolling your own buffer management logic here, as you can see that it feels like you are doing much the same thing, sharing memory outside of the kernel to something else.
thanks,
greg k-h
RE: [PATCH 03/22] keembay-ipc: Add Keem Bay IPC module
Quoted 148 lines
-----Original Message-----
From: Greg KH <[email protected]>
Sent: Friday, December 11, 2020 12:23 AM
To: Daniele Alessandrelli <[email protected]>
Cc: Alessandrelli, Daniele <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 03/22] keembay-ipc: Add Keem Bay IPC moduleQuoted 8 lines · Daniele Alessandrelli
Quoted 7 lines · Greg KH
Quoted 6 lines · Daniele Alessandrelli
Hi Greg,
Thanks for your feedback.
Quoted 1 line · Greg KH
On Tue, Dec 01, 2020 at 02:34:52PM -0800, [email protected]
Quoted 27 lines · wrote:
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
From: Daniele Alessandrelli <[email protected]>
On the Intel Movidius SoC code named Keem Bay, communication between the Computing Sub-System (CSS), i.e., the CPU, and the Multimedia Sub-System (MSS), i.e., the VPU is enabled by the Keem Bay Inter-Processor Communication (IPC) mechanism.
Add the driver for using Keem Bay IPC from within the Linux Kernel.
Keem Bay IPC uses the following terminology:
- Node: A processing entity that can use the IPC to communicate;
currently, we just have two nodes, CPU (CSS) and VPU (MSS).- Link: Two nodes that can communicate over IPC form an IPC link
(currently, we just have one link, the one between the CPU and VPU).- Channel: An IPC link can provide multiple IPC channels. IPC channels allow communication multiplexing, i.e., the same IPC link can be used by different applications for different communications. Each channel is identified by a channel ID, which must be unique within a single IPC link. Channels are divided in two categories, High-Speed (HS) channels and General-Purpose (GP) channels. HS channels have higher priority over GP channels.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Keem Bay IPC mechanism is based on shared memory and hardware
FIFOs.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Both the CPU and the VPU have their own hardware FIFO. When the CPU wants to send an IPC message to the VPU, it writes to the VPU FIFO (MSS FIFO); similarly, when MSS wants to send an IPC message to the CPU, it writes to the CPU FIFO (CSS FIFO).
A FIFO entry is simply a pointer to an IPC buffer (aka IPC header) stored in a portion of memory shared between the CPU and
the VPU.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Specifically, the FIFO entry contains the (VPU) physical address of the IPC buffer being transferred.
In turn, the IPC buffer contains the (VPU) physical address of the payload (which must be located in shared memory too) as well as other information (payload size, IPC channel ID, etc.).
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Each IPC node instantiates a pool of IPC buffers from its own IPC buffer memory region. When instantiated, IPC buffers are marked as free. When the node needs to send an IPC message, it gets the first free buffer it finds (from its own pool), marks it as allocated (used), and puts its physical address into the IPC FIFO of the destination node. The destination node (which is notified by an interrupt when there are entries pending in its FIFO) extract the physical address from the FIFO and process the IPC buffer, marking it as free once done (so that the sender
can reuse the buffer).
Quoted 27 lines
Quoted 11 lines
Quoted 10 lines
Quoted 5 lines
Any reason you can't use the dmabuf interface for these memory buffers you are creating and having to manage "by hand"? I thought that was what the kernel was wanting to unify on such that individual
drivers/subsystemsdidn't have to do this on their own.My understanding is that the dmabuf interface is used to share DMA buffers across different drivers, while these buffers are used only internally to the IPC driver (and exchanged only with the VPU firmware). They basically are packet headers that are sent to the VPU.
Quoted 5 lines
There's no reason you couldn't use these to share your buffers "internally" as well, because you have the same lifetime rules and accounting and all other sorts of things you have to handle, right? Why rewrite something like this when you should take advantage of common code instead?
I looked at dma-buf again, but I'm still failing to see how we can use it in this driver :/
The problem I'm not able to solve is exactly how to match the lifetime of this IPC packets (IPC buffers is probably a misleading name, my bad for using it in the code) with the dma-buf lifetime rules.
Basically, these IPC packets are cache-aligned (64 bytes) and have the following fixed structure:
Quoted 8 lines
struct kmb_ipc_buf { u32 data_addr; u32 data_size; u16 channel; u8 src_node; u8 dst_node; u8 status; } __packed __aligned(KMB_IPC_ALIGNMENT);If that is shared out of the kernel, please use the proper data types for it.
And it isn't properly padded out? That feels like a hardware design mistake somewhere, anyway...
Quoted 12 lines
Now, let's ignore the first 5 fields and focus on the last one that controls the lifetime of the packet. The status field can be either FREE or ALLOCATED (perhaps should be renamed to
IN_USE).Basically, during probe, the driver allocates an array (pool) of these packets from its 'local' reserved memory region. This is done using
dma_alloc_coherent(). This array remains allocated untilremove()is called.At run-time, every time the driver sends a message to the VPU, the following happens:
Quoted 6 lines
1. The IPC driver loops through the array of 'local' packets to find the first one marked as FREE
2. The IPC driver marks the packet asIN_USEand shares it with the VPU by putting its physical address into the VPU HW FIFO.
3. The VPU Firmware processes the packet and, when done with it, it marks it as FREE again so that the IPC driver can use it again.How does the firmware "mark it as free"?
Quoted 9 lines
Please note that the IPC driver is not notified by the VPU when the packet is marked as free (there is no IRQ or other async mechanism to do that). The driver will simply find the message free the next time it loops over the message pool again (i.e., when it is trying to send a new message).
Given that the free operation is silently done by the VPU, I'm failing to see how I can use dmabuf (or
gen_poolordma_pool). Is there anything that I'm missing?
Quoted 5 lines
So maybe this isn't set up to use the dma buffers, but it still feels really odd. I recommend getting a review by the dmabuf authors before declaring that you really should be rolling your own buffer management logic here, as you can see that it feels like you are doing much the same thing, sharing memory outside of the kernel to something else.
Great idea! I will do this on the V2 posting.
Say, we've gotten some really good feedback so far and I'm thinking about posting an update with most of the issues raised addressed next week. There is one feedback that looks like will take a bit longer to address (splitting out and use of the common mailbox framework in the keembay-ipc driver). Would it be acceptable to post a V2 that has some ToDo's in it to allow for more feedback to get to the rest of the stack or should we hold until we get all the issues address before posting the V2?
Thanks again for your advice and review feedback!
--mark
Quoted 4 lines
thanks,
greg k-h
PATCH 4/22 dt-bindings: Add bindings for Keem Bay VPU IPC driver
In reply to [email protected]From: Paul Murphy <[email protected]>
Add DT bindings documentation for the Keem Bay VPU IPC driver.
--- .../soc/intel/intel,keembay-vpu-ipc.yaml | 151 ++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/intel/intel,keembay-vpu-ipc.yaml
Documentation/devicetree/bindings/soc/intel/intel,keembay-vpu-ipc.yaml new file +151 -0
@@ -0,0 +1,151 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +# Copyright (c) Intel Corporation. All rights reserved. +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/soc/intel/intel,keembay-vpu-ipc.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Intel Keem Bay VPU IPC + +maintainers: + - Paul Murphy <[email protected]> + +description: + The VPU IPC driver facilitates loading of firmware, control, and communication + with the VPU over the IPC FIFO in the Intel Keem Bay SoC. + +properties: + compatible: + oneOf: + - items: + - const: intel,keembay-vpu-ipc + + reg: + items: + - description: NCE WDT registers + - description: NCE TIM_GEN_CONFIG registers + - description: MSS WDT registers + - description: MSS TIM_GEN_CONFIG registers + + reg-names: + items: + - const: nce_wdt + - const: nce_tim_cfg + - const: mss_wdt + - const: mss_tim_cfg + + memory-region: + items: + - description: reference to the VPU reserved memory region + - description: reference to the X509 reserved memory region + - description: reference to the MSS IPC area + + clocks: + items: + - description: cpu clock + - description: pll 0 out 0 rate + - description: pll 0 out 1 rate + - description: pll 0 out 2 rate + - description: pll 0 out 3 rate + - description: pll 1 out 0 rate + - description: pll 1 out 1 rate + - description: pll 1 out 2 rate + - description: pll 1 out 3 rate + - description: pll 2 out 0 rate + - description: pll 2 out 1 rate + - description: pll 2 out 2 rate + - description: pll 2 out 3 rate + + clocks-names: + items: + - const: cpu_clock + - const: pll_0_out_0 + - const: pll_0_out_1 + - const: pll_0_out_2 + - const: pll_0_out_3 + - const: pll_1_out_0 + - const: pll_1_out_1 + - const: pll_1_out_2 + - const: pll_1_out_3 + - const: pll_2_out_0 + - const: pll_2_out_1 + - const: pll_2_out_2 + - const: pll_2_out_3 + + interrupts: + items: + - description: number of NCE sub-system WDT timeout IRQ + - description: number of MSS sub-system WDT timeout IRQ + + interrupt-names: + items: + - const: nce_wdt + - const: mss_wdt + + intel,keembay-vpu-ipc-nce-wdt-redirect: + $ref: "/schemas/types.yaml#/definitions/uint32" + description: + Number to which we will request that the NCE sub-system + re-directs it's WDT timeout IRQ + + intel,keembay-vpu-ipc-mss-wdt-redirect: + $ref: "/schemas/types.yaml#/definitions/uint32" + description: + Number to which we will request that the MSS sub-system + re-directs it's WDT timeout IRQ + + intel,keembay-vpu-ipc-imr: + $ref: "/schemas/types.yaml#/definitions/uint32" + description: + IMR (isolated memory region) number which we will request + the runtime service uses to protect the VPU memory region + before authentication + + intel,keembay-vpu-ipc-id: + $ref: "/schemas/types.yaml#/definitions/uint32" + description: The VPU ID to be passed to the VPU firmware. + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + vpu-ipc@3f00209c { + compatible = "intel,keembay-vpu-ipc"; + reg = <0x3f00209c 0x10>, + <0x3f003008 0x4>, + <0x2082009c 0x10>, + <0x20821008 0x4>; + reg-names = "nce_wdt", + "nce_tim_cfg", + "mss_wdt", + "mss_tim_cfg"; + memory-region = <&vpu_reserved>, + <&vpu_x509_reserved>, + <&mss_ipc_reserved>; + clocks = <&scmi_clk 0>, + <&scmi_clk 0>, + <&scmi_clk 1>, + <&scmi_clk 2>, + <&scmi_clk 3>, + <&scmi_clk 4>, + <&scmi_clk 5>, + <&scmi_clk 6>, + <&scmi_clk 7>, + <&scmi_clk 8>, + <&scmi_clk 9>, + <&scmi_clk 10>, + <&scmi_clk 11>; + clock-names = "cpu_clock", + "pll_0_out_0", "pll_0_out_1", + "pll_0_out_2", "pll_0_out_3", + "pll_1_out_0", "pll_1_out_1", + "pll_1_out_2", "pll_1_out_3", + "pll_2_out_0", "pll_2_out_1", + "pll_2_out_2", "pll_2_out_3"; + interrupts = <GIC_SPI 63 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 47 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "nce_wdt", "mss_wdt"; + intel,keembay-vpu-ipc-nce-wdt-redirect = <63>; + intel,keembay-vpu-ipc-mss-wdt-redirect = <47>; + intel,keembay-vpu-ipc-imr = <9>; + intel,keembay-vpu-ipc-id = <0>; + };
Signature · 1 line
2.17.1
Rob Herring
maintainerRe: [PATCH 04/22] dt-bindings: Add bindings for Keem Bay VPU IPC driver
Quoted 9 lines · On Tue, 01 Dec 2020 14:34:53 -0800, [email protected] wrote:
From: Paul Murphy <[email protected]>
Add DT bindings documentation for the Keem Bay VPU IPC driver.
Reviewed-by Mark Gross <[email protected]>Signed-off-by Paul Murphy <[email protected]>Co-developed-by Daniele Alessandrelli <[email protected]>Signed-off-by Daniele Alessandrelli <[email protected]>
Quoted 5 lines
--- .../soc/intel/intel,keembay-vpu-ipc.yaml | 151 ++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/intel/intel,keembay-vpu-ipc.yaml
My bot found errors running 'make dt_binding_check' on your patch:
yamllint warnings/errors:./Documentation/devicetree/bindings/soc/intel/intel,keembay-vpu-ipc.yaml:21:9: [warning] wrong indentation: expected 10 but found 8 (indentation)
dtschema/dtc warnings/errors:
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/soc/intel/intel,keembay-vpu-ipc.yaml: 'additionalProperties' is a required property /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/soc/intel/intel,keembay-vpu-ipc.yaml: ignoring, error in schema:
warning: no schema found in file: ./Documentation/devicetree/bindings/soc/intel/intel,keembay-vpu-ipc.yaml
See https://patchwork.ozlabs.org/patch/1409183
The base for the patch is generally the last rc1. Any dependencies should be noted.
If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:
pip3 install dtschema --upgrade
Please check and re-submit.
Re: [PATCH 04/22] dt-bindings: Add bindings for Keem Bay VPU IPC driver
Quoted 33 lines · Rob Herring
Quoted 9 lines · On Tue, 01 Dec 2020 14:34:53 -0800, [email protected] wrote:
From: Paul Murphy <[email protected]>
Add DT bindings documentation for the Keem Bay VPU IPC driver.
Reviewed-by Mark Gross <[email protected]>Signed-off-by Paul Murphy <[email protected]>Co-developed-by Daniele Alessandrelli <[email protected]>Signed-off-by Daniele Alessandrelli <[email protected]>Quoted 5 lines
--- .../soc/intel/intel,keembay-vpu-ipc.yaml | 151 ++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/intel/intel,keembay-vpu-ipc.yamlMy bot found errors running 'make
dt_binding_check' on your patch:yamllint warnings/errors:
./Documentation/devicetree/bindings/soc/intel/intel,keembay-vpu-ipc.yaml:21:9: [warning] wrong indentation: expected 10 but found 8 (indentation)dtschema/dtc warnings/errors:
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/soc/intel/intel,keembay-vpu-ipc.yaml: 'additionalProperties' is a required property /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/soc/intel/intel,keembay-vpu-ipc.yaml: ignoring, error in schema:
warning: no schema found in file:./Documentation/devicetree/bindings/soc/intel/intel,keembay-vpu-ipc.yamlSee https://patchwork.ozlabs.org/patch/1409183
The base for the patch is generally the last rc1. Any dependencies should be noted.
Quoted 7 lines
If you already ran 'make
dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:pip3 install dtschema --upgrade
Please check and re-submit.
Thanks! I will fix on the next update.
--mark
PATCH 5/22 keembay-vpu-ipc: Add Keem Bay VPU IPC module
In reply to [email protected]From: Paul Murphy <[email protected]>
Intel Keem Bay SoC contains a Vision Processing Unit (VPU) to enable machine vision and other applications.
Enable Linux to control the VPU processor and provides an interface to the Keem Bay IPC for communicating with the VPU firmware.
Specifically the driver provides the following functionality to other kernel components:
- Starting (including loading the VPU firmware) / Stopping / Rebooting
the VPU.
- Getting notifications of VPU events (e.g., WDT events).
- Communicating with the VPU via the Keem Bay IPC mechanism.
In addition to the above, the driver also exposes SoC information (like stepping, device ID, etc.) to user-space via sysfs. Specifically, the following sysfs files are provided:
- /sys/firmware/keembay-vpu-ipc/device_id
- /sys/firmware/keembay-vpu-ipc/feature_exclusion
- /sys/firmware/keembay-vpu-ipc/hardware_id
- /sys/firmware/keembay-vpu-ipc/sku
- /sys/firmware/keembay-vpu-ipc/stepping
--- MAINTAINERS | 9 + drivers/soc/intel/Kconfig | 15 + drivers/soc/intel/Makefile | 3 +- drivers/soc/intel/keembay-vpu-ipc.c | 2036 +++++++++++++++++++++ include/linux/soc/intel/keembay-vpu-ipc.h | 62 + 5 files changed, 2124 insertions(+), 1 deletion(-) create mode 100644 drivers/soc/intel/keembay-vpu-ipc.c create mode 100644 include/linux/soc/intel/keembay-vpu-ipc.h
MAINTAINERS +9 -0
@@ -8963,6 +8963,15 @@ F: Documentation/devicetree/bindings/soc/intel/intel,keembay-ipc.yaml F: drivers/soc/intel/keembay-ipc.c F: include/linux/soc/intel/keembay-ipc.h +INTEL KEEM BAY VPU IPC DRIVER +M: Paul J Murphy <[email protected]> +M: Daniele Alessandrelli <[email protected]> +M: Mark Gross <[email protected]> +S: Maintained +F: Documentation/devicetree/bindings/soc/intel/intel,keembay-vpu-ipc.yaml +F: drivers/soc/intel/keembay-vpu-ipc.c +F: include/linux/soc/intel/keembay-vpu-ipc.h + INTEL MANAGEMENT ENGINE (mei) M: Tomas Winkler <[email protected]> L: [email protected]
drivers/soc/intel/Kconfig +15 -0
@@ -14,4 +14,19 @@ config KEEMBAY_IPC Select this if you are compiling the Kernel for an Intel SoC that includes the Intel Vision Processing Unit (VPU) such as Keem Bay. + +config KEEMBAY_VPU_IPC + tristate "Intel Keem Bay VPU IPC Driver" + depends on KEEMBAY_IPC + depends on HAVE_ARM_SMCCC + help + This option enables support for loading and communicating with + the firmware on the Vision Processing Unit (VPU) of the Keem Bay + SoC. The driver depends on the Keem Bay IPC driver to do + communication, and it depends on secure world monitor software to + do the control of the VPU state. + + Select this if you are compiling the Kernel for an Intel SoC that + includes the Intel Vision Processing Unit (VPU) such as Keem Bay. + endmenu
drivers/soc/intel/Makefile +2 -1
@@ -1,4 +1,5 @@ # # Makefile for Keem Bay IPC Linux driver # -obj-$(CONFIG_KEEMBAY_IPC) += keembay-ipc.o +obj-$(CONFIG_KEEMBAY_IPC) += keembay-ipc.o +obj-$(CONFIG_KEEMBAY_VPU_IPC) += keembay-vpu-ipc.o
drivers/soc/intel/keembay-vpu-ipc.c new file +2036 -0
2,036 lines not on this page · raw message
include/linux/soc/intel/keembay-vpu-ipc.h new file +62 -0
62 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 6/22 misc: xlink-pcie: Add documentation for XLink PCIe driver
In reply to [email protected]From: Srikanth Thokala <[email protected]>
Provide overview of XLink PCIe driver implementation
--- Documentation/vpu/index.rst | 1 + Documentation/vpu/xlink-pcie.rst | 91 ++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 Documentation/vpu/xlink-pcie.rst
Documentation/vpu/index.rst +1 -0
@@ -14,3 +14,4 @@ This documentation contains information for the Intel VPU stack. :maxdepth: 2 vpu-stack-overview + xlink-pcie
Documentation/vpu/xlink-pcie.rst new file +91 -0
91 lines not on this page · raw message
Signature · 1 line
2.17.1
Randy Dunlap
reviewerRe: [PATCH 06/22] misc: xlink-pcie: Add documentation for XLink PCIe driver
Quoted 4 lines · On 12/1/20 2:34 PM, [email protected] wrote:
From: Srikanth Thokala <[email protected]>
Provide overview of XLink PCIe driver implementation
Quoted 9 lines
Reviewed-by Mark Gross <[email protected]>Signed-off-by Srikanth Thokala <[email protected]>--- Documentation/vpu/index.rst | 1 + Documentation/vpu/xlink-pcie.rst | 91 ++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 Documentation/vpu/xlink-pcie.rst
Hi--
For document, chapter, section, etc., headings, please read & use Documentation/doc-guide/sphinx.rst:
* Please stick to this order of heading adornments:
1. ``=`` with overline for document title::
==============
Document title
==============2. ``=`` for chapters::
Chapters
========3. ``-`` for sections::
Section
-------4. ``~`` for subsections::
Subsection
~~~~~~~~~~Quoted 10 lines
Documentation/vpu/xlink-pcie.rst new file +4
-0@@ -0,0 +1,91 @@ +.. SPDX-License-Identifier: GPL-2.0-only + +Kernel driver: xlink-pcie driver +================================
Documentation/vpu/xlink-pcie.rst line 14
Quoted 10 lines
Documentation/vpu/xlink-pcie.rst new file +10
-0+Supported chips: + * Intel Edge.AI Computer Vision platforms: Keem Bay + Suffix: Bay + Slave address: 6240 + Datasheet: Publicly available at Intel + +Author: Srikanth Thokala [email protected] + +------------- +Introduction:
No colon at end of chapter/section headings.
Documentation/vpu/xlink-pcie.rst line 16
Quoted 2 lines
Documentation/vpu/xlink-pcie.rst new file +2
-0+------------- +The xlink-pcie driver in linux-5.4 provides transport layer implementation for
Linux 5.4 (?)
Documentation/vpu/xlink-pcie.rst line 17
Quoted 1 line
Documentation/vpu/xlink-pcie.rst new file +1
-0+the data transfers to support xlink protocol subsystem communication with the
Xlink
Documentation/vpu/xlink-pcie.rst line 18
Quoted 1 line
Documentation/vpu/xlink-pcie.rst new file +1
-0+peer device. i.e, between remote host system and the local Keem Bay device.
device, i.e., between the remote host system and
Documentation/vpu/xlink-pcie.rst line 20
Quoted 2 lines
Documentation/vpu/xlink-pcie.rst new file +2
-0+ +The Keem Bay device is an ARM based SOC that includes a vision processing
ARM-based
Documentation/vpu/xlink-pcie.rst line 23
Quoted 3 lines
Documentation/vpu/xlink-pcie.rst new file +3
-0+unit (VPU) and deep learning, neural network core in the hardware. +The xlink-pcie driver exports a functional device endpoint to the Keem Bay device +and supports two-way communication with peer device.
with the peer device.
Quoted 35 lines
Documentation/vpu/xlink-pcie.rst new file +35
-0+ +------------------------ +High-level architecture: +------------------------ +Remote Host: IA CPU +Local Host: ARM CPU (Keem Bay):: + + +------------------------------------------------------------------------+ + | Remote Host IA CPU | | Local Host ARM CPU (Keem Bay) | | + +==================================+=+===============================+===+ + | User App | | User App | | + +----------------------------------+-+-------------------------------+---+ + | XLink UAPI | | XLink UAPI | | + +----------------------------------+-+-------------------------------+---+ + | XLink Core | | XLink Core | | + +----------------------------------+-+-------------------------------+---+ + | XLink PCIe | | XLink PCIe | | + +----------------------------------+-+-------------------------------+---+ + | XLink-PCIe Remote Host driver | | XLink-PCIe Local Host driver | | + +----------------------------------+-+-------------------------------+---+ + |-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:|:|:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:| + +----------------------------------+-+-------------------------------+---+ + | PCIe Host Controller | | PCIe Device Controller | HW| + +----------------------------------+-+-------------------------------+---+ + ^ ^ + | | + |------------- PCIe x2 Link -----------------| + +This XLink PCIe driver comprises of two variants: +* Local Host driver + + * Intended for ARM CPU + * It is based on PCI Endpoint Framework + * Driver path: {tree}/drivers/misc/xlink-pcie/local_host +
Documentation/vpu/xlink-pcie.rst line 68
Quoted 10 lines
Documentation/vpu/xlink-pcie.rst new file +10
-0+* Remote Host driver + + * Intended for IA CPU + * It is a PCIe endpoint driver + * Driver path: {tree}/drivers/misc/xlink-pcie/remote_host + +XLink PCIe communication between local host and remote host is achieved through +ring buffer management and MSI/Doorbell interrupts. + +The xlink-pcie driver subsystem registers Keem Bay device as an endpoint driver
registers the
Documentation/vpu/xlink-pcie.rst line 69
Quoted 1 line
Documentation/vpu/xlink-pcie.rst new file +1
-0+and provides standard linux pcie sysfs interface, # /sys/bus/pci/devices/xxxx:xx:xx.0/
Linux PCIe
Documentation/vpu/xlink-pcie.rst line 73
Quoted 4 lines
Documentation/vpu/xlink-pcie.rst new file +4
-0+ + +------------------------- +XLink protocol subsystem:
No colon at end.
Documentation/vpu/xlink-pcie.rst line 75
Quoted 2 lines
Documentation/vpu/xlink-pcie.rst new file +2
-0+------------------------- +xlink is an abstracted control and communication subsystem based on channel
Xlink
Documentation/vpu/xlink-pcie.rst line 79
Quoted 4 lines
Documentation/vpu/xlink-pcie.rst new file +4
-0+identification. It is intended to support VPU technology both at SoC level as +well as at IP level, over multiple interfaces. + +- The xlink subsystem abstracts several types of communication channels
Xlink
Documentation/vpu/xlink-pcie.rst line 84
Quoted 5 lines
Documentation/vpu/xlink-pcie.rst new file +5
-0+ underneath, allowing the usage of different interfaces with the + same function call interface. +- The Communication channels are full-duplex protocol channels allowing + concurrent bidirectional communication. +- The xlink subsystem also supports control operations to VPU either
Xlink
Documentation/vpu/xlink-pcie.rst line 87
Quoted 3 lines
Documentation/vpu/xlink-pcie.rst new file +3
-0+ from standalone local system or from remote system based on communication + interface underneath. +- The xlink subsystem supports following communication interfaces:
Xlink supports the following
Documentation/vpu/xlink-pcie.rst line 91
Quoted 5 lines
Documentation/vpu/xlink-pcie.rst new file +4
-0+ * USB CDC + * Gigabit Ethernet + * PCIe + * IPC
cheers.
Signature · 1 line
~Randy
Re: [PATCH 06/22] misc: xlink-pcie: Add documentation for XLink PCIe driver
Quoted 35 lines · Randy Dunlap
Quoted 4 lines · On 12/1/20 2:34 PM, [email protected] wrote:
From: Srikanth Thokala <[email protected]>
Provide overview of XLink PCIe driver implementation
Quoted 9 lines
Reviewed-by Mark Gross <[email protected]>Signed-off-by Srikanth Thokala <[email protected]>--- Documentation/vpu/index.rst | 1 + Documentation/vpu/xlink-pcie.rst | 91 ++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 Documentation/vpu/xlink-pcie.rstHi--
For document, chapter, section, etc., headings, please read & use
Documentation/doc-guide/sphinx.rst:* Please stick to this order of heading adornments:
1. ``=`` with overline for document title::
============== Document title ==============2. ``=`` for chapters::
Chapters ========3. ``-`` for sections::
Quoted 7 lines
Section -------4. ``~`` for subsections::
Subsection ~~~~~~~~~~
Thanks for the help! I'm new to the sphix markup language and appreciate your advice. I'll reread that doc-guide.
We'll address the issues on our next posting once the marge window closes.
thanks again for the reviews!
--mark
Quoted 145 lines
Quoted 11 lines
Documentation/vpu/xlink-pcie.rst new file +4
-0@@ -0,0 +1,91 @@ +.. SPDX-License-Identifier: GPL-2.0-only + +Kernel driver: xlink-pcie driver +================================Documentation/vpu/xlink-pcie.rst line 14
Quoted 10 lines
Documentation/vpu/xlink-pcie.rst new file +10
-0+Supported chips: + * Intel Edge.AI Computer Vision platforms: Keem Bay + Suffix: Bay + Slave address: 6240 + Datasheet: Publicly available at Intel + +Author: Srikanth Thokala [email protected] + +------------- +Introduction:No colon at end of chapter/section headings.
Documentation/vpu/xlink-pcie.rst line 16
Quoted 2 lines
Documentation/vpu/xlink-pcie.rst new file +2
-0+------------- +The xlink-pcie driver in linux-5.4 provides transport layer implementation forLinux 5.4 (?)Documentation/vpu/xlink-pcie.rst line 17
Quoted 1 line
Documentation/vpu/xlink-pcie.rst new file +1
-0+the data transfers to support xlink protocol subsystem communication with theXlink
Documentation/vpu/xlink-pcie.rst line 18
Quoted 1 line
Documentation/vpu/xlink-pcie.rst new file +1
-0+peer device. i.e, between remote host system and the local Keem Bay device.device, i.e., between the remote host system and
Documentation/vpu/xlink-pcie.rst line 20
Quoted 2 lines
Documentation/vpu/xlink-pcie.rst new file +2
-0+ +The Keem Bay device is an ARM based SOC that includes a vision processingARM-based
Documentation/vpu/xlink-pcie.rst line 23
Quoted 3 lines
Documentation/vpu/xlink-pcie.rst new file +3
-0+unit (VPU) and deep learning, neural network core in the hardware. +The xlink-pcie driver exports a functional device endpoint to the Keem Bay device +and supports two-way communication with peer device.with the peer device.
Quoted 35 lines
Documentation/vpu/xlink-pcie.rst new file +35
-0+ +------------------------ +High-level architecture: +------------------------ +Remote Host: IA CPU +Local Host: ARM CPU (Keem Bay):: + + +------------------------------------------------------------------------+ + | Remote Host IA CPU | | Local Host ARM CPU (Keem Bay) | | + +==================================+=+===============================+===+ + | User App | | User App | | + +----------------------------------+-+-------------------------------+---+ + | XLink UAPI | | XLink UAPI | | + +----------------------------------+-+-------------------------------+---+ + | XLink Core | | XLink Core | | + +----------------------------------+-+-------------------------------+---+ + | XLink PCIe | | XLink PCIe | | + +----------------------------------+-+-------------------------------+---+ + | XLink-PCIe Remote Host driver | | XLink-PCIe Local Host driver | | + +----------------------------------+-+-------------------------------+---+ + |-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:|:|:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:| + +----------------------------------+-+-------------------------------+---+ + | PCIe Host Controller | | PCIe Device Controller | HW| + +----------------------------------+-+-------------------------------+---+ + ^ ^ + | | + |------------- PCIe x2 Link -----------------| + +This XLink PCIe driver comprises of two variants: +* Local Host driver + + * Intended for ARM CPU + * It is based on PCI Endpoint Framework + * Driver path: {tree}/drivers/misc/xlink-pcie/local_host +Documentation/vpu/xlink-pcie.rst line 68
Quoted 10 lines
Documentation/vpu/xlink-pcie.rst new file +10
-0+* Remote Host driver + + * Intended for IA CPU + * It is a PCIe endpoint driver + * Driver path: {tree}/drivers/misc/xlink-pcie/remote_host + +XLink PCIe communication between local host and remote host is achieved through +ring buffer management and MSI/Doorbell interrupts. + +The xlink-pcie driver subsystem registers Keem Bay device as an endpoint driverregisters the
Documentation/vpu/xlink-pcie.rst line 69
Quoted 1 line
Documentation/vpu/xlink-pcie.rst new file +1
-0+and provides standard linux pcie sysfs interface, # /sys/bus/pci/devices/xxxx:xx:xx.0/Linux PCIe
Documentation/vpu/xlink-pcie.rst line 73
Quoted 4 lines
Documentation/vpu/xlink-pcie.rst new file +4
-0+ + +------------------------- +XLink protocol subsystem:No colon at end.
Documentation/vpu/xlink-pcie.rst line 75
Quoted 2 lines
Documentation/vpu/xlink-pcie.rst new file +2
-0+------------------------- +xlink is an abstracted control and communication subsystem based on channelXlink
Documentation/vpu/xlink-pcie.rst line 79
Quoted 4 lines
Documentation/vpu/xlink-pcie.rst new file +4
-0+identification. It is intended to support VPU technology both at SoC level as +well as at IP level, over multiple interfaces. + +- The xlink subsystem abstracts several types of communication channelsXlink
Documentation/vpu/xlink-pcie.rst line 84
Quoted 5 lines
Documentation/vpu/xlink-pcie.rst new file +5
-0+ underneath, allowing the usage of different interfaces with the + same function call interface. +- The Communication channels are full-duplex protocol channels allowing + concurrent bidirectional communication. +- The xlink subsystem also supports control operations to VPU eitherXlink
Documentation/vpu/xlink-pcie.rst line 87
Quoted 3 lines
Documentation/vpu/xlink-pcie.rst new file +3
-0+ from standalone local system or from remote system based on communication + interface underneath. +- The xlink subsystem supports following communication interfaces:Xlink supports the following
Documentation/vpu/xlink-pcie.rst line 91
Quoted 5 lines
Documentation/vpu/xlink-pcie.rst new file +4
-0+ * USB CDC + * Gigabit Ethernet + * PCIe + * IPCcheers.
Signature · 1 line
~Randy
PATCH 7/22 misc: xlink-pcie: lh: Add PCIe EPF driver for Local Host
In reply to [email protected]From: Srikanth Thokala <[email protected]>
Add PCIe EPF driver for local host (lh) to configure BAR's and other HW resources. Underlying PCIe HW controller is a Synopsys DWC PCIe core.
--- MAINTAINERS | 6 + drivers/misc/Kconfig | 1 + drivers/misc/Makefile | 1 + drivers/misc/xlink-pcie/Kconfig | 9 + drivers/misc/xlink-pcie/Makefile | 1 + drivers/misc/xlink-pcie/local_host/Makefile | 2 + drivers/misc/xlink-pcie/local_host/epf.c | 414 ++++++++++++++++++++ drivers/misc/xlink-pcie/local_host/epf.h | 39 ++ drivers/misc/xlink-pcie/local_host/xpcie.h | 54 +++ 9 files changed, 527 insertions(+) create mode 100644 drivers/misc/xlink-pcie/Kconfig create mode 100644 drivers/misc/xlink-pcie/Makefile create mode 100644 drivers/misc/xlink-pcie/local_host/Makefile create mode 100644 drivers/misc/xlink-pcie/local_host/epf.c create mode 100644 drivers/misc/xlink-pcie/local_host/epf.h create mode 100644 drivers/misc/xlink-pcie/local_host/xpcie.h
MAINTAINERS +6 -0
@@ -1952,6 +1952,12 @@ F: Documentation/devicetree/bindings/arm/intel,keembay.yaml F: arch/arm64/boot/dts/intel/keembay-evm.dts F: arch/arm64/boot/dts/intel/keembay-soc.dtsi +ARM KEEMBAY XLINK PCIE SUPPORT +M: Srikanth Thokala <[email protected]> +M: Mark Gross <[email protected]> +S: Maintained +F: drivers/misc/xlink-pcie/ + ARM/INTEL RESEARCH IMOTE/STARGATE 2 MACHINE SUPPORT M: Jonathan Cameron <[email protected]> L: [email protected] (moderated for non-subscribers)
drivers/misc/Kconfig +1 -0
@@ -481,4 +481,5 @@ source "drivers/misc/ocxl/Kconfig" source "drivers/misc/cardreader/Kconfig" source "drivers/misc/habanalabs/Kconfig" source "drivers/misc/uacce/Kconfig" +source "drivers/misc/xlink-pcie/Kconfig" endmenu
drivers/misc/Makefile +1 -0
@@ -57,3 +57,4 @@ obj-$(CONFIG_HABANA_AI) += habanalabs/ obj-$(CONFIG_UACCE) += uacce/ obj-$(CONFIG_XILINX_SDFEC) += xilinx_sdfec.o obj-$(CONFIG_HISI_HIKEY_USB) += hisi_hikey_usb.o +obj-y += xlink-pcie/
drivers/misc/xlink-pcie/Kconfig new file +9 -0
@@ -0,0 +1,9 @@ +config XLINK_PCIE_LH_DRIVER + tristate "XLink PCIe Local Host driver" + depends on PCI_ENDPOINT && ARCH_KEEMBAY + help + This option enables XLink PCIe Local Host driver. + + Choose M here to compile this driver as a module, name is mxlk_ep. + This driver is used for XLink communication over PCIe and is to be + loaded on the Intel Keem Bay platform.
drivers/misc/xlink-pcie/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_XLINK_PCIE_LH_DRIVER) += local_host/
drivers/misc/xlink-pcie/local_host/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +obj-$(CONFIG_XLINK_PCIE_LH_DRIVER) += mxlk_ep.o +mxlk_ep-objs := epf.o
drivers/misc/xlink-pcie/local_host/epf.c new file +414 -0
414 lines not on this page · raw message
drivers/misc/xlink-pcie/local_host/epf.h new file +39 -0
@@ -0,0 +1,39 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/***************************************************************************** +* +* Intel Keem Bay XLink PCIe Driver +* +* Copyright (C) 2020 Intel Corporation +* +****************************************************************************/ + +#ifndef XPCIE_EPF_HEADER_ +#define XPCIE_EPF_HEADER_ + +#include <linux/pci-epc.h> +#include <linux/pci-epf.h> + +#include "xpcie.h" + +#define XPCIE_DRIVER_NAME "mxlk_pcie_epf" +#define XPCIE_DRIVER_DESC "Intel(R) xLink PCIe endpoint function driver" + +#define KEEMBAY_XPCIE_STEPPING_MAXLEN 8 + +struct xpcie_epf { +struct pci_epf *epf; +void *vaddr[BAR_5 +1 ]; +enum pci_barno comm_bar; +enum pci_barno bar4; +const struct pci_epc_features *epc_features; +struct xpcie xpcie; +int irq; +int irq_dma; +int irq_err; +void __iomem *apb_base; +void __iomem *dma_base; +void __iomem *dbi_base; +char stepping[KEEMBAY_XPCIE_STEPPING_MAXLEN ]; +}; + +#endif /* XPCIE_EPF_HEADER_ */
drivers/misc/xlink-pcie/local_host/xpcie.h new file +54 -0
54 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 8/22 misc: xlink-pcie: lh: Add PCIe EP DMA functionality
In reply to [email protected]From: Srikanth Thokala <[email protected]>
Add Synopsys PCIe DWC core embedded-DMA functionality for local host
--- drivers/misc/xlink-pcie/local_host/Makefile | 1 + drivers/misc/xlink-pcie/local_host/dma.c | 577 ++++++++++++++++++++ drivers/misc/xlink-pcie/local_host/epf.c | 15 +- drivers/misc/xlink-pcie/local_host/epf.h | 41 ++ 4 files changed, 631 insertions(+), 3 deletions(-) create mode 100644 drivers/misc/xlink-pcie/local_host/dma.c
drivers/misc/xlink-pcie/local_host/Makefile +1 -0
@@ -1,2 +1,3 @@ obj-$(CONFIG_XLINK_PCIE_LH_DRIVER) += mxlk_ep.o mxlk_ep-objs := epf.o +mxlk_ep-objs += dma.o
drivers/misc/xlink-pcie/local_host/dma.c new file +577 -0
577 lines not on this page · raw message
drivers/misc/xlink-pcie/local_host/epf.c +12 -3
@@ -45,6 +45,8 @@ static irqreturn_t intel_xpcie_err_interrupt(int irq, void *args) xpcie_epf = container_of(xpcie, struct xpcie_epf, xpcie); val =ioread32 (xpcie_epf->apb_base +PCIE_REGS_PCIE_ERR_INTR_FLAGS ); +if (val &LINK_REQ_RST_FLG ) +intel_xpcie_ep_dma_reset (xpcie_epf->epf);iowrite32 (val, xpcie_epf->apb_base +PCIE_REGS_PCIE_ERR_INTR_FLAGS );
@@ -325,8 +327,17 @@ static int intel_xpcie_epf_bind(struct pci_epf *epf) goto err_cleanup_bars; } + ret =intel_xpcie_ep_dma_init (epf); +if (ret) { +dev_err (&epf->dev,"DMA initialization failed\n" ); + goto err_free_err_irq; + } +return 0 ; +err_free_err_irq: +free_irq (xpcie_epf->irq_err, &xpcie_epf->xpcie); + err_cleanup_bars:intel_xpcie_cleanup_bars (epf);
@@ -335,11 +346,9 @@ static int intel_xpcie_epf_bind(struct pci_epf *epf)static void intel_xpcie_epf_unbind (struct pci_epf *epf) { -struct xpcie_epf *xpcie_epf =epf_get_drvdata (epf);struct pci_epc *epc = epf->epc; -free_irq (xpcie_epf->irq, &xpcie_epf->xpcie); -free_irq (xpcie_epf->irq_err, &xpcie_epf->xpcie); +intel_xpcie_ep_dma_uninit (epf);pci_epc_stop (epc);
drivers/misc/xlink-pcie/local_host/epf.h +41 -0
53 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 9/22 misc: xlink-pcie: lh: Add core communication logic
In reply to [email protected]From: Srikanth Thokala <[email protected]>
Add logic to establish communication with the remote host which is through ring buffer management and MSI/Doorbell interrupts
--- drivers/misc/xlink-pcie/local_host/Makefile | 2 + drivers/misc/xlink-pcie/local_host/core.c | 894 ++++++++++++++++++++ drivers/misc/xlink-pcie/local_host/core.h | 247 ++++++ drivers/misc/xlink-pcie/local_host/epf.c | 116 ++- drivers/misc/xlink-pcie/local_host/epf.h | 26 + drivers/misc/xlink-pcie/local_host/util.c | 375 ++++++++ drivers/misc/xlink-pcie/local_host/util.h | 70 ++ drivers/misc/xlink-pcie/local_host/xpcie.h | 65 ++ include/linux/xlink_drv_inf.h | 60 ++ 9 files changed, 1847 insertions(+), 8 deletions(-) create mode 100644 drivers/misc/xlink-pcie/local_host/core.c create mode 100644 drivers/misc/xlink-pcie/local_host/core.h create mode 100644 drivers/misc/xlink-pcie/local_host/util.c create mode 100644 drivers/misc/xlink-pcie/local_host/util.h create mode 100644 include/linux/xlink_drv_inf.h
drivers/misc/xlink-pcie/local_host/Makefile +2 -0
@@ -1,3 +1,5 @@ obj-$(CONFIG_XLINK_PCIE_LH_DRIVER) += mxlk_ep.o mxlk_ep-objs := epf.o mxlk_ep-objs += dma.o +mxlk_ep-objs += core.o +mxlk_ep-objs += util.o
drivers/misc/xlink-pcie/local_host/core.c new file +894 -0
894 lines not on this page · raw message
drivers/misc/xlink-pcie/local_host/core.h new file +247 -0
247 lines not on this page · raw message
drivers/misc/xlink-pcie/local_host/epf.c +108 -8
185 lines not on this page · raw message
drivers/misc/xlink-pcie/local_host/epf.h +26 -0
@@ -14,6 +14,7 @@#include <linux/pci-epf.h> #include "xpcie.h" +#include "util.h" #define XPCIE_DRIVER_NAME "mxlk_pcie_epf"#define XPCIE_DRIVER_DESC "Intel(R) xLink PCIe endpoint function driver"
@@ -26,6 +27,7 @@#define XPCIE_NUM_RX_DESCS (64)extern bool dma_ll_mode; +extern u32 xlink_sw_id;struct xpcie_dma_ll_desc {u32 dma_ch_control1;
@@ -67,14 +69,38 @@ struct xpcie_epf {void __iomem *dbi_base;char stepping[KEEMBAY_XPCIE_STEPPING_MAXLEN ]; +irq_handler_t core_irq_callback; +dma_addr_t tx_phys; +void *tx_virt; +size_t tx_size; +dma_addr_t rx_phys; +void *rx_virt; +size_t rx_size; +struct xpcie_dma_ll_desc_buf tx_desc_buf[DMA_CHAN_NUM ];struct xpcie_dma_ll_desc_buf rx_desc_buf[DMA_CHAN_NUM ]; }; +static inline struct device *xpcie_to_dev (struct xpcie *xpcie) +{ +struct xpcie_epf *xpcie_epf =container_of (xpcie, + struct xpcie_epf, xpcie); + +return &xpcie_epf->epf->dev; +} +int intel_xpcie_ep_dma_init (struct pci_epf *epf);int intel_xpcie_ep_dma_uninit (struct pci_epf *epf);int intel_xpcie_ep_dma_reset (struct pci_epf *epf);int intel_xpcie_ep_dma_read_ll (struct pci_epf *epf,int chan,int descs_num);int intel_xpcie_ep_dma_write_ll (struct pci_epf *epf,int chan,int descs_num); +void intel_xpcie_register_host_irq (struct xpcie *xpcie, +irq_handler_t func); +int intel_xpcie_raise_irq (struct xpcie *xpcie, +enum xpcie_doorbell_type type); +int intel_xpcie_copy_from_host_ll (struct xpcie *xpcie, +int chan,int descs_num); +int intel_xpcie_copy_to_host_ll (struct xpcie *xpcie, +int chan,int descs_num);#endif /* XPCIE_EPF_HEADER_ */
drivers/misc/xlink-pcie/local_host/util.c new file +375 -0
375 lines not on this page · raw message
drivers/misc/xlink-pcie/local_host/util.h new file +70 -0
70 lines not on this page · raw message
drivers/misc/xlink-pcie/local_host/xpcie.h +65 -0
91 lines not on this page · raw message
include/linux/xlink_drv_inf.h new file +60 -0
60 lines not on this page · raw message
Signature · 1 line
2.17.1
Greg KH
maintainerRe: [PATCH 09/22] misc: xlink-pcie: lh: Add core communication logic
Quoted 68 lines · On Tue, Dec 01, 2020 at 02:34:58PM -0800, [email protected] wrote:
From: Srikanth Thokala <[email protected]>
Add logic to establish communication with the remote host which is through ring buffer management and MSI/Doorbell interrupts
Reviewed-by Mark Gross <[email protected]>Signed-off-by Srikanth Thokala <[email protected]>--- drivers/misc/xlink-pcie/local_host/Makefile | 2 + drivers/misc/xlink-pcie/local_host/core.c | 894 ++++++++++++++++++++ drivers/misc/xlink-pcie/local_host/core.h | 247 ++++++ drivers/misc/xlink-pcie/local_host/epf.c | 116 ++- drivers/misc/xlink-pcie/local_host/epf.h | 26 + drivers/misc/xlink-pcie/local_host/util.c | 375 ++++++++ drivers/misc/xlink-pcie/local_host/util.h | 70 ++ drivers/misc/xlink-pcie/local_host/xpcie.h | 65 ++ include/linux/xlink_drv_inf.h | 60 ++ 9 files changed, 1847 insertions(+), 8 deletions(-) create mode 100644 drivers/misc/xlink-pcie/local_host/core.c create mode 100644 drivers/misc/xlink-pcie/local_host/core.h create mode 100644 drivers/misc/xlink-pcie/local_host/util.c create mode 100644 drivers/misc/xlink-pcie/local_host/util.h create mode 100644 include/linux/xlink_drv_inf.hdrivers/misc/xlink-pcie/local_host/Makefile +2
-0@@ -1,3 +1,5 @@ obj-$(CONFIG_XLINK_PCIE_LH_DRIVER) += mxlk_ep.o mxlk_ep-objs := epf.o mxlk_ep-objs += dma.o +mxlk_ep-objs += core.o +mxlk_ep-objs += util.odrivers/misc/xlink-pcie/local_host/core.c new file +28
-0@@ -0,0 +1,894 @@ +// SPDX-License-Identifier: GPL-2.0-only +/***************************************************************************** +* +* Intel Keem Bay XLink PCIe Driver +* +* Copyright (C) 2020 Intel Corporation +* +****************************************************************************/ + +#include <linux/of_reserved_mem.h> + +#include "epf.h" +#include "core.h" +#include "util.h" + +static struct xpcie *global_xpcie; + +static int rx_pool_size =SZ_32M ; +module_param (rx_pool_size, int,0664 ); +MODULE_PARM_DESC (rx_pool_size,"receiving pool size (default 32 MiB)" ); + +static int tx_pool_size =SZ_32M ; +module_param (tx_pool_size, int,0664 ); +MODULE_PARM_DESC (tx_pool_size,"transmitting pool size (default 32 MiB)" ); + +static int fragment_size =XPCIE_FRAGMENT_SIZE ; +module_param (fragment_size, int,0664 ); +MODULE_PARM_DESC (fragment_size,"transfer descriptor size (default 128 KiB)" );
drivers/misc/xlink-pcie/local_host/core.c line 38
Quoted 10 lines
drivers/misc/xlink-pcie/local_host/core.c new file +10
-0+ +static bool tx_pool_coherent = true; +module_param (tx_pool_coherent, bool,0664 ); +MODULE_PARM_DESC (tx_pool_coherent, +"transmitting pool using coherent memory (default true)" ); + +static bool rx_pool_coherent; +module_param (rx_pool_coherent, bool,0664 ); +MODULE_PARM_DESC (rx_pool_coherent, +"receiving pool using coherent memory (default false)" );
This isn't the 1990's anymore. Please make these dynamic such that they are never needed (the code figures out the best values), or on some per-device basis using configfs or sysfs.
thanks,
greg k-h
RE: [PATCH 09/22] misc: xlink-pcie: lh: Add core communication logic
Hi Greg,
Quoted 91 lines
-----Original Message-----
From: Greg KH <[email protected]>
Sent: Wednesday, December 2, 2020 11:48 AM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Thokala, Srikanth <[email protected]>
Subject: Re: [PATCH 09/22] misc: xlink-pcie: lh: Add core communication logicQuoted 3 lines · On Tue, Dec 01, 2020 at 02:34:58PM -0800, [email protected] wrote:
From: Srikanth Thokala <[email protected]>
Add logic to establish communication with the remote host which is
through
Quoted 21 lines
ring buffer management and MSI/Doorbell interrupts
Reviewed-by Mark Gross <[email protected]>Signed-off-by Srikanth Thokala <[email protected]>--- drivers/misc/xlink-pcie/local_host/Makefile | 2 + drivers/misc/xlink-pcie/local_host/core.c | 894 ++++++++++++++++++++ drivers/misc/xlink-pcie/local_host/core.h | 247 ++++++ drivers/misc/xlink-pcie/local_host/epf.c | 116 ++- drivers/misc/xlink-pcie/local_host/epf.h | 26 + drivers/misc/xlink-pcie/local_host/util.c | 375 ++++++++ drivers/misc/xlink-pcie/local_host/util.h | 70 ++ drivers/misc/xlink-pcie/local_host/xpcie.h | 65 ++ include/linux/xlink_drv_inf.h | 60 ++ 9 files changed, 1847 insertions(+), 8 deletions(-) create mode 100644 drivers/misc/xlink-pcie/local_host/core.c create mode 100644 drivers/misc/xlink-pcie/local_host/core.h create mode 100644 drivers/misc/xlink-pcie/local_host/util.c create mode 100644 drivers/misc/xlink-pcie/local_host/util.h create mode 100644 include/linux/xlink_drv_inf.hReview
Quoted 1 line
(quoted diff) +0
-0b/drivers/misc/xlink-pcie/local_host/Makefile
Review
Quoted 10 lines
index
54fc118e2dd1..28761751d43b100644drivers/misc/xlink-pcie/local_host/Makefile +2
-0@@ -1,3 +1,5 @@ obj-$(CONFIG_XLINK_PCIE_LH_DRIVER) += mxlk_ep.o mxlk_ep-objs := epf.o mxlk_ep-objs += dma.o +mxlk_ep-objs += core.o +mxlk_ep-objs += util.o(quoted diff) +0
-0
b/drivers/misc/xlink-pcie/local_host/core.cdrivers/misc/xlink-pcie/local_host/core.c line 1
Quoted 7 lines
new file mode 100644
index 000000000000..aecaaa783153drivers/misc/xlink-pcie/local_host/core.c new file +1
-0@@ -0,0 +1,894 @@ +// SPDX-License-Identifier: GPL-2.0-only +/************************************************************************
*****drivers/misc/xlink-pcie/local_host/core.c line 9
Quoted 6 lines
drivers/misc/xlink-pcie/local_host/core.c new file +6
-0+* +* Intel Keem Bay XLink PCIe Driver +* +* Copyright (C) 2020 Intel Corporation +* +**************************************************************************
**/Quoted 6 lines
drivers/misc/xlink-pcie/local_host/core.c new file +6
-0+ +#include <linux/of_reserved_mem.h> + +#include "epf.h" +#include "core.h" +#include "util.h" drivers/misc/xlink-pcie/local_host/core.c
Quoted 10 lines
drivers/misc/xlink-pcie/local_host/core.c new file +10
-0+ +static struct xpcie *global_xpcie; + +static int rx_pool_size =SZ_32M ; +module_param (rx_pool_size, int,0664 ); +MODULE_PARM_DESC (rx_pool_size,"receiving pool size (default 32 MiB)" ); + +static int tx_pool_size =SZ_32M ; +module_param (tx_pool_size, int,0664 ); +MODULE_PARM_DESC(tx_pool_size, "transmitting pool size (default 32MiB)");
drivers/misc/xlink-pcie/local_host/core.c
Quoted 4 lines
drivers/misc/xlink-pcie/local_host/core.c new file +4
-0+ +static int fragment_size =XPCIE_FRAGMENT_SIZE ; +module_param (fragment_size, int,0664 ); +MODULE_PARM_DESC(fragment_size, "transfer descriptor size (default 128KiB)");
Quoted 14 lines
drivers/misc/xlink-pcie/local_host/core.c line 38
Quoted 10 lines
drivers/misc/xlink-pcie/local_host/core.c new file +10
-0+ +static bool tx_pool_coherent = true; +module_param (tx_pool_coherent, bool,0664 ); +MODULE_PARM_DESC (tx_pool_coherent, +"transmitting pool using coherent memory (default true)" ); + +static bool rx_pool_coherent; +module_param (rx_pool_coherent, bool,0664 ); +MODULE_PARM_DESC (rx_pool_coherent, +"receiving pool using coherent memory (default false)" );This isn't the 1990's anymore. Please make these dynamic such that they are never needed (the code figures out the best values), or on some per-device basis using configfs or sysfs.
Sure, I will fix it in my v2.
thanks!
Srikanth
Quoted 3 lines
thanks,
greg k-h
PATCH 10/22 misc: xlink-pcie: lh: Prepare changes for adding remote host driver
In reply to [email protected]From: Srikanth Thokala <[email protected]>
Move logic that can be reused between local host and remote host to common/ folder
---
drivers/misc/xlink-pcie/{local_host => common}/core.h | 0
drivers/misc/xlink-pcie/{local_host => common}/util.c | 0
drivers/misc/xlink-pcie/{local_host => common}/util.h | 0
drivers/misc/xlink-pcie/{local_host => common}/xpcie.h | 0
drivers/misc/xlink-pcie/local_host/Makefile | 2 +-
drivers/misc/xlink-pcie/local_host/core.c | 4 ++--
drivers/misc/xlink-pcie/local_host/epf.h | 4 ++--
7 files changed, 5 insertions(+), 5 deletions(-)
rename drivers/misc/xlink-pcie/{local_host => common}/core.h (100%)
rename drivers/misc/xlink-pcie/{local_host => common}/util.c (100%)
rename drivers/misc/xlink-pcie/{local_host => common}/util.h (100%)
rename drivers/misc/xlink-pcie/{local_host => common}/xpcie.h (100%)drivers/misc/xlink-pcie/common/core.h renamed from drivers/misc/xlink-pcie/local_host/core.h +0 -0
drivers/misc/xlink-pcie/common/util.c renamed from drivers/misc/xlink-pcie/local_host/util.c +0 -0
drivers/misc/xlink-pcie/common/util.h renamed from drivers/misc/xlink-pcie/local_host/util.h +0 -0
drivers/misc/xlink-pcie/common/xpcie.h renamed from drivers/misc/xlink-pcie/local_host/xpcie.h +0 -0
drivers/misc/xlink-pcie/local_host/Makefile +1 -1
@@ -2,4 +2,4 @@ obj-$(CONFIG_XLINK_PCIE_LH_DRIVER) += mxlk_ep.o mxlk_ep-objs := epf.o mxlk_ep-objs += dma.o mxlk_ep-objs += core.o -mxlk_ep-objs += util.o +mxlk_ep-objs += ../common/util.o
drivers/misc/xlink-pcie/local_host/core.c +2 -2
@@ -10,8 +10,8 @@#include <linux/of_reserved_mem.h> #include "epf.h" -#include "core.h" -#include "util.h" +#include "../common/core.h" +#include "../common/util.h" static struct xpcie *global_xpcie;
drivers/misc/xlink-pcie/local_host/epf.h +2 -2
@@ -13,8 +13,8 @@#include <linux/pci-epc.h> #include <linux/pci-epf.h> -#include "xpcie.h" -#include "util.h" +#include "../common/xpcie.h" +#include "../common/util.h" #define XPCIE_DRIVER_NAME "mxlk_pcie_epf"#define XPCIE_DRIVER_DESC "Intel(R) xLink PCIe endpoint function driver"
Signature · 1 line
2.17.1
PATCH 11/22 misc: xlink-pcie: rh: Add PCIe EP driver for Remote Host
In reply to [email protected]From: Srikanth Thokala <[email protected]>
Add PCIe Endpoint driver that configures PCIe BARs and MSIs on the Remote Host
--- MAINTAINERS | 2 +- drivers/misc/xlink-pcie/Kconfig | 11 + drivers/misc/xlink-pcie/Makefile | 1 + drivers/misc/xlink-pcie/common/xpcie.h | 1 + drivers/misc/xlink-pcie/remote_host/Makefile | 3 + drivers/misc/xlink-pcie/remote_host/main.c | 93 ++++ drivers/misc/xlink-pcie/remote_host/pci.c | 451 +++++++++++++++++++ drivers/misc/xlink-pcie/remote_host/pci.h | 64 +++ 8 files changed, 625 insertions(+), 1 deletion(-) create mode 100644 drivers/misc/xlink-pcie/remote_host/Makefile create mode 100644 drivers/misc/xlink-pcie/remote_host/main.c create mode 100644 drivers/misc/xlink-pcie/remote_host/pci.c create mode 100644 drivers/misc/xlink-pcie/remote_host/pci.h
MAINTAINERS +1 -1
@@ -1952,7 +1952,7 @@ F: Documentation/devicetree/bindings/arm/intel,keembay.yaml F: arch/arm64/boot/dts/intel/keembay-evm.dts F: arch/arm64/boot/dts/intel/keembay-soc.dtsi -ARM KEEMBAY XLINK PCIE SUPPORT +ARM/INTEL KEEMBAY XLINK PCIE SUPPORT M: Srikanth Thokala <[email protected]> M: Mark Gross <[email protected]> S: Maintained
drivers/misc/xlink-pcie/Kconfig +11 -0
@@ -1,3 +1,14 @@ +config XLINK_PCIE_RH_DRIVER + tristate "XLink PCIe Remote Host driver" + depends on PCI && X86_64 + help + This option enables XLink PCIe Remote Host driver. + + Choose M here to compile this driver as a module, name is mxlk. + This driver is used for XLink communication over PCIe, + and is to be loaded on the IA host which is connected to + the Intel Keem Bay. + config XLINK_PCIE_LH_DRIVER tristate "XLink PCIe Local Host driver" depends on PCI_ENDPOINT && ARCH_KEEMBAY
drivers/misc/xlink-pcie/Makefile +1 -0
@@ -1 +1,2 @@ +obj-$(CONFIG_XLINK_PCIE_RH_DRIVER) += remote_host/ obj-$(CONFIG_XLINK_PCIE_LH_DRIVER) += local_host/
drivers/misc/xlink-pcie/common/xpcie.h +1 -0
@@ -89,6 +89,7 @@ struct xpcie_mmio {struct xpcie {u32 status;bool legacy_a0; +void *bar0;void *mmio;void *bar4;
drivers/misc/xlink-pcie/remote_host/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +obj-$(CONFIG_XLINK_PCIE_RH_DRIVER) += mxlk.o +mxlk-objs := main.o +mxlk-objs += pci.o
drivers/misc/xlink-pcie/remote_host/main.c new file +93 -0
93 lines not on this page · raw message
drivers/misc/xlink-pcie/remote_host/pci.c new file +451 -0
451 lines not on this page · raw message
drivers/misc/xlink-pcie/remote_host/pci.h new file +64 -0
64 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 12/22 misc: xlink-pcie: rh: Add core communication logic
In reply to [email protected]From: Srikanth Thokala <[email protected]>
Add logic to establish communication with the local host which is through ring buffer management and MSI/Doorbell interrupts
--- drivers/misc/xlink-pcie/common/core.h | 11 +- drivers/misc/xlink-pcie/remote_host/Makefile | 2 + drivers/misc/xlink-pcie/remote_host/core.c | 647 +++++++++++++++++++ drivers/misc/xlink-pcie/remote_host/pci.c | 48 +- 4 files changed, 696 insertions(+), 12 deletions(-) create mode 100644 drivers/misc/xlink-pcie/remote_host/core.c
drivers/misc/xlink-pcie/common/core.h +4 -7
@@ -10,15 +10,11 @@#ifndef XPCIE_CORE_HEADER_ #define XPCIE_CORE_HEADER_ -#include <linux/io.h> -#include <linux/types.h> -#include <linux/workqueue.h> -#include <linux/slab.h> -#include <linux/mutex.h> -#include <linux/mempool.h> #include <linux/dma-mapping.h> -#include <linux/cache.h> +#include <linux/mutex.h> +#include <linux/slab.h> #include <linux/wait.h> +#include <linux/workqueue.h> #include <linux/xlink_drv_inf.h>
@@ -64,6 +60,7 @@ struct xpcie_buf_desc {struct xpcie_stream {size_t frag;struct xpcie_pipe pipe; +struct xpcie_buf_desc **ddr; };struct xpcie_list {
drivers/misc/xlink-pcie/remote_host/Makefile +2 -0
@@ -1,3 +1,5 @@ obj-$(CONFIG_XLINK_PCIE_RH_DRIVER) += mxlk.o mxlk-objs := main.o mxlk-objs += pci.o +mxlk-objs += core.o +mxlk-objs += ../common/util.o
drivers/misc/xlink-pcie/remote_host/core.c new file +647 -0
647 lines not on this page · raw message
drivers/misc/xlink-pcie/remote_host/pci.c +43 -5
81 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 13/22 misc: xlink-pcie: Add XLink API interface
In reply to [email protected]From: Srikanth Thokala <[email protected]>
Provide interface for XLink layer to interact with XLink PCIe transport layer on both local host and remote host.
--- drivers/misc/xlink-pcie/common/interface.c | 109 +++++++++++++++++++ drivers/misc/xlink-pcie/local_host/Makefile | 1 + drivers/misc/xlink-pcie/remote_host/Makefile | 1 + 3 files changed, 111 insertions(+) create mode 100644 drivers/misc/xlink-pcie/common/interface.c
drivers/misc/xlink-pcie/common/interface.c new file +109 -0
@@ -0,0 +1,109 @@ +// SPDX-License-Identifier: GPL-2.0-only +/***************************************************************************** +* +* Intel Keem Bay XLink PCIe Driver +* +* Copyright (C) 2020 Intel Corporation +* +****************************************************************************/ + +#include <linux/xlink_drv_inf.h> + +#include "core.h" +#include "xpcie.h" + +/* Define xpcie driver interface API */ +int xlink_pcie_get_device_list (u32 *sw_device_id_list,u32 *num_devices) +{ +if (!sw_device_id_list || !num_devices) +return -EINVAL ; + + *num_devices =intel_xpcie_get_device_num (sw_device_id_list); + +return 0 ; +} +EXPORT_SYMBOL (xlink_pcie_get_device_list); + +int xlink_pcie_get_device_name (u32 sw_device_id,char *device_name, +size_t name_size) +{ +if (!device_name) +return -EINVAL ; + +return intel_xpcie_get_device_name_by_id (sw_device_id, + device_name, name_size); +} +EXPORT_SYMBOL (xlink_pcie_get_device_name); + +int xlink_pcie_get_device_status (u32 sw_device_id,u32 *device_status) +{ +u32 status; +int rc; + +if (!device_status) +return -EINVAL ; + + rc =intel_xpcie_get_device_status_by_id (sw_device_id, &status); +if (rc) +return rc; + +switch (status) { +case XPCIE_STATUS_READY : +case XPCIE_STATUS_RUN : + *device_status = _XLINK_DEV_READY; +break ; +case XPCIE_STATUS_ERROR : + *device_status = _XLINK_DEV_ERROR; +break ; +case XPCIE_STATUS_RECOVERY : + *device_status = _XLINK_DEV_RECOVERY; +break ; +case XPCIE_STATUS_OFF : + *device_status = _XLINK_DEV_OFF; +break ; +default : + *device_status = _XLINK_DEV_BUSY; +break ; + } + +return 0 ; +} +EXPORT_SYMBOL (xlink_pcie_get_device_status); + +int xlink_pcie_boot_device (u32 sw_device_id,const char *binary_name) +{ +return 0 ; +} +EXPORT_SYMBOL (xlink_pcie_boot_device); + +int xlink_pcie_connect (u32 sw_device_id) +{ +return intel_xpcie_pci_connect_device (sw_device_id); +} +EXPORT_SYMBOL (xlink_pcie_connect); + +int xlink_pcie_read (u32 sw_device_id,void *data,size_t *const size, +u32 timeout) +{ +if (!data || !size) +return -EINVAL ; + +return intel_xpcie_pci_read (sw_device_id, data, size, timeout); +} +EXPORT_SYMBOL (xlink_pcie_read); + +int xlink_pcie_write (u32 sw_device_id,void *data,size_t *const size, +u32 timeout) +{ +if (!data || !size) +return -EINVAL ; + +return intel_xpcie_pci_write (sw_device_id, data, size, timeout); +} +EXPORT_SYMBOL (xlink_pcie_write); + +int xlink_pcie_reset_device (u32 sw_device_id) +{ +return intel_xpcie_pci_reset_device (sw_device_id); +} +EXPORT_SYMBOL (xlink_pcie_reset_device);
drivers/misc/xlink-pcie/local_host/Makefile +1 -0
@@ -3,3 +3,4 @@ mxlk_ep-objs := epf.o mxlk_ep-objs += dma.o mxlk_ep-objs += core.o mxlk_ep-objs += ../common/util.o +mxlk_ep-objs += ../common/interface.o
drivers/misc/xlink-pcie/remote_host/Makefile +1 -0
@@ -3,3 +3,4 @@ mxlk-objs := main.o mxlk-objs += pci.o mxlk-objs += core.o mxlk-objs += ../common/util.o +mxlk-objs += ../common/interface.o
Signature · 1 line
2.17.1
PATCH 14/22 misc: xlink-pcie: Add asynchronous event notification support for XLink
In reply to [email protected]From: Srikanth Thokala <[email protected]>
Add support to notify XLink layer upon PCIe link UP/DOWN events
--- drivers/misc/xlink-pcie/common/core.h | 3 ++ drivers/misc/xlink-pcie/common/interface.c | 17 ++++++++++ drivers/misc/xlink-pcie/local_host/core.c | 11 +++++++ drivers/misc/xlink-pcie/remote_host/main.c | 3 ++ drivers/misc/xlink-pcie/remote_host/pci.c | 36 ++++++++++++++++++++++ drivers/misc/xlink-pcie/remote_host/pci.h | 3 ++ include/linux/xlink_drv_inf.h | 12 ++++++++ 7 files changed, 85 insertions(+)
drivers/misc/xlink-pcie/common/core.h +3 -0
@@ -241,4 +241,7 @@ int intel_xpcie_pci_connect_device(u32 id);int intel_xpcie_pci_read (u32 id,void *data,size_t *size,u32 timeout);int intel_xpcie_pci_write (u32 id,void *data,size_t *size,u32 timeout);int intel_xpcie_pci_reset_device (u32 id); +int intel_xpcie_pci_register_device_event (u32 sw_device_id, +xlink_device_event event_notif_fn); +int intel_xpcie_pci_unregister_device_event (u32 sw_device_id);#endif /* XPCIE_CORE_HEADER_ */
drivers/misc/xlink-pcie/common/interface.c +17 -0
@@ -107,3 +107,20 @@ int xlink_pcie_reset_device(u32 sw_device_id)return intel_xpcie_pci_reset_device (sw_device_id); }EXPORT_SYMBOL (xlink_pcie_reset_device); + +int xlink_pcie_register_device_event (u32 sw_device_id, +xlink_device_event event_notif_fn) +{ +if (!event_notif_fn) +return -EINVAL ; + +return intel_xpcie_pci_register_device_event (sw_device_id, + event_notif_fn); +} +EXPORT_SYMBOL (xlink_pcie_register_device_event); + +int xlink_pcie_unregister_device_event (u32 sw_device_id) +{ +return intel_xpcie_pci_unregister_device_event (sw_device_id); +} +EXPORT_SYMBOL (xlink_pcie_unregister_device_event);
drivers/misc/xlink-pcie/local_host/core.c +11 -0
@@ -892,3 +892,14 @@ int intel_xpcie_pci_reset_device(u32 id) {return 0 ; } + +int intel_xpcie_pci_register_device_event (u32 sw_device_id, +xlink_device_event event_notif_fn) +{ +return 0 ; +} + +int intel_xpcie_pci_unregister_device_event (u32 sw_device_id) +{ +return 0 ; +}
drivers/misc/xlink-pcie/remote_host/main.c +3 -0
@@ -55,6 +55,8 @@ static int intel_xpcie_probe(struct pci_dev *pdev,if (new_device)intel_xpcie_list_add_device (xdev); +intel_xpcie_pci_notify_event (xdev,NOTIFY_DEVICE_CONNECTED ); +return ret; }
@@ -64,6 +66,7 @@ static void intel_xpcie_remove(struct pci_dev *pdev)if (xdev) {intel_xpcie_pci_cleanup (xdev); +intel_xpcie_pci_notify_event (xdev,NOTIFY_DEVICE_DISCONNECTED );intel_xpcie_remove_device (xdev); } }
drivers/misc/xlink-pcie/remote_host/pci.c +36 -0
@@ -8,6 +8,7 @@****************************************************************************/ #include <linux/mutex.h> +#include <linux/pci.h> #include <linux/sched.h> #include <linux/wait.h> #include <linux/workqueue.h>
@@ -487,3 +488,38 @@ int intel_xpcie_pci_reset_device(u32 id)return intel_xpcie_pci_prepare_dev_reset (xdev, true); } + +int intel_xpcie_pci_register_device_event (u32 sw_device_id, +xlink_device_event event_notif_fn) +{ +struct xpcie_dev *xdev =intel_xpcie_get_device_by_id (sw_device_id); + +if (!xdev) +return -ENOMEM ; + + xdev->event_fn = event_notif_fn; + +return 0 ; +} + +int intel_xpcie_pci_unregister_device_event (u32 sw_device_id) +{ +struct xpcie_dev *xdev =intel_xpcie_get_device_by_id (sw_device_id); + +if (!xdev) +return -ENOMEM ; + + xdev->event_fn =NULL ; + +return 0 ; +} + +void intel_xpcie_pci_notify_event (struct xpcie_dev *xdev, +enum xlink_device_event_type event_type) +{ +if (event_type >=NUM_EVENT_TYPE ) +return ; + +if (xdev->event_fn) + xdev->event_fn (xdev->devid, event_type); +}
drivers/misc/xlink-pcie/remote_host/pci.h +3 -0
@@ -38,6 +38,7 @@ struct xpcie_dev {irq_handler_t core_irq_callback;struct xpcie xpcie; +xlink_device_event event_fn; };static inline struct device *xpcie_to_dev (struct xpcie *xpcie)
@@ -60,5 +61,7 @@ struct xpcie_dev *intel_xpcie_create_device(u32 sw_device_id,void intel_xpcie_remove_device (struct xpcie_dev *xdev);void intel_xpcie_list_add_device (struct xpcie_dev *xdev);void intel_xpcie_list_del_device (struct xpcie_dev *xdev); +void intel_xpcie_pci_notify_event (struct xpcie_dev *xdev, +enum xlink_device_event_type event_type);#endif /* XPCIE_PCI_HEADER_ */
include/linux/xlink_drv_inf.h +12 -0
@@ -44,6 +44,15 @@ enum _xlink_device_status {_XLINK_DEV_READY }; +enum xlink_device_event_type { +NOTIFY_DEVICE_DISCONNECTED , +NOTIFY_DEVICE_CONNECTED , +NUM_EVENT_TYPE +}; + +typedef int (*xlink_device_event )(u32 sw_device_id, +enum xlink_device_event_type event_type); +int xlink_pcie_get_device_list (u32 *sw_device_id_list,u32 *num_devices); int xlink_pcie_get_device_name(u32 sw_device_id, char *device_name,
@@ -57,4 +66,7 @@ int xlink_pcie_read(u32 sw_device_id, void *data, size_t *const size,int xlink_pcie_write (u32 sw_device_id,void *data,size_t *const size,u32 timeout);int xlink_pcie_reset_device (u32 sw_device_id); +int xlink_pcie_register_device_event (u32 sw_device_id, +xlink_device_event event_notif_fn); +int xlink_pcie_unregister_device_event (u32 sw_device_id);#endif
Signature · 1 line
2.17.1
PATCH 15/22 xlink-ipc: Add xlink ipc device tree bindings
In reply to [email protected]From: Seamus Kelly <[email protected]>
Add device tree bindings for the xLink IPC driver which enables xLink to control and communicate with the VPU IP present on the Intel Keem Bay SoC.
--- .../misc/intel,keembay-xlink-ipc.yaml | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Documentation/devicetree/bindings/misc/intel,keembay-xlink-ipc.yaml
Documentation/devicetree/bindings/misc/intel,keembay-xlink-ipc.yaml new file +49 -0
@@ -0,0 +1,49 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +# Copyright (c) Intel Corporation. All rights reserved. +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/misc/intel,keembay-xlink-ipc.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Intel Keem Bay xlink IPC + +maintainers: + - Kelly Seamus <[email protected]> + +description: | + The Keem Bay xlink IPC driver enables the communication/control sub-system + for internal IPC communications within the Intel Keem Bay SoC. + +properties: + compatible: + oneOf: + - items: + - const: intel,keembay-xlink-ipc + + memory-region: + items: + - description: reference to the CSS xlink IPC reserved memory region. + - description: reference to the MSS xlink IPC reserved memory region. + + intel,keembay-vpu-ipc-id: + $ref: "/schemas/types.yaml#/definitions/uint32" + description: The numeric ID identifying the VPU within the xLink stack. + + intel,keembay-vpu-ipc-name: + $ref: "/schemas/types.yaml#/definitions/string" + description: User-friendly name for the VPU within the xLink stack. + + intel,keembay-vpu-ipc: + $ref: "/schemas/types.yaml#/definitions/phandle" + description: reference to the corresponding intel,keembay-vpu-ipc node. + +examples: + - | + xlink-ipc { + compatible = "intel,keembay-xlink-ipc"; + memory-region = <&css_xlink_reserved>, + <&mss_xlink_reserved>; + intel,keembay-vpu-ipc-id = <0x0>; + intel,keembay-vpu-ipc-name = "vpu-slice-0"; + intel,keembay-vpu-ipc = <&vpuipc>; + };
Signature · 1 line
2.17.1
Rob Herring
maintainerRe: [PATCH 15/22] xlink-ipc: Add xlink ipc device tree bindings
Quoted 6 lines · On Tue, 01 Dec 2020 14:35:04 -0800, [email protected] wrote:
From: Seamus Kelly <[email protected]>
Add device tree bindings for the xLink IPC driver which enables xLink to control and communicate with the VPU IP present on the Intel Keem Bay SoC.
Quoted 9 lines
Reviewed-by Mark Gross <[email protected]>Signed-off-by Seamus Kelly <[email protected]>Signed-off-by Ryan Carnaghi <[email protected]>--- .../misc/intel,keembay-xlink-ipc.yaml | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Documentation/devicetree/bindings/misc/intel,keembay-xlink-ipc.yaml
My bot found errors running 'make dt_binding_check' on your patch:
yamllint warnings/errors:./Documentation/devicetree/bindings/misc/intel,keembay-xlink-ipc.yaml:21:9: [warning] wrong indentation: expected 10 but found 8 (indentation)
dtschema/dtc warnings/errors:
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/misc/intel,keembay-xlink-ipc.yaml: 'additionalProperties' is a required property /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/misc/intel,keembay-xlink-ipc.yaml: ignoring, error in schema:
warning: no schema found in file: ./Documentation/devicetree/bindings/misc/intel,keembay-xlink-ipc.yaml
See https://patchwork.ozlabs.org/patch/1409186
The base for the patch is generally the last rc1. Any dependencies should be noted.
If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:
pip3 install dtschema --upgrade
Please check and re-submit.
Re: [PATCH 15/22] xlink-ipc: Add xlink ipc device tree bindings
Quoted 34 lines · Rob Herring
Quoted 6 lines · On Tue, 01 Dec 2020 14:35:04 -0800, [email protected] wrote:
From: Seamus Kelly <[email protected]>
Add device tree bindings for the xLink IPC driver which enables xLink to control and communicate with the VPU IP present on the Intel Keem Bay SoC.
Quoted 9 lines
Reviewed-by Mark Gross <[email protected]>Signed-off-by Seamus Kelly <[email protected]>Signed-off-by Ryan Carnaghi <[email protected]>--- .../misc/intel,keembay-xlink-ipc.yaml | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Documentation/devicetree/bindings/misc/intel,keembay-xlink-ipc.yamlMy bot found errors running 'make
dt_binding_check' on your patch:yamllint warnings/errors:
./Documentation/devicetree/bindings/misc/intel,keembay-xlink-ipc.yaml:21:9: [warning] wrong indentation: expected 10 but found 8 (indentation)dtschema/dtc warnings/errors:
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/misc/intel,keembay-xlink-ipc.yaml: 'additionalProperties' is a required property /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/misc/intel,keembay-xlink-ipc.yaml: ignoring, error in schema:
warning: no schema found in file:./Documentation/devicetree/bindings/misc/intel,keembay-xlink-ipc.yamlSee https://patchwork.ozlabs.org/patch/1409186
The base for the patch is generally the last rc1. Any dependencies should be noted.
Quoted 7 lines
If you already ran 'make
dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:pip3 install dtschema --upgrade
Please check and re-submit.
Thank you! will do.
--mark
PATCH 16/22 xlink-ipc: Add xlink ipc driver
In reply to [email protected]From: Seamus Kelly <[email protected]>
Add xLink driver, which interfaces the xLink Core driver with the Keem Bay VPU IPC driver, thus enabling xLink to control and communicate with the VPU IP present on the Intel Keem Bay SoC.
Specifically the driver enables xLink Core to:
* Boot / Reset the VPU IP
* Register to VPU IP event notifications (device connected, device disconnected, WDT event)
* Query the status of the VPU IP (OFF, BUSY, READY, ERROR, RECOVERY)
* Exchange data with the VPU IP, using the Keem Bay IPC mechanism
- Including the ability to send 'volatile' data (i.e., small amount of data, up to 128-bytes that was not allocated in the CPU/VPU shared memory region)
--- Documentation/vpu/index.rst | 1 + Documentation/vpu/xlink-ipc.rst | 50 ++ MAINTAINERS | 6 + drivers/misc/Kconfig | 1 + drivers/misc/Makefile | 1 + drivers/misc/xlink-ipc/Kconfig | 7 + drivers/misc/xlink-ipc/Makefile | 4 + drivers/misc/xlink-ipc/xlink-ipc.c | 879 +++++++++++++++++++++++++++++ include/linux/xlink-ipc.h | 48 ++ 9 files changed, 997 insertions(+) create mode 100644 Documentation/vpu/xlink-ipc.rst create mode 100644 drivers/misc/xlink-ipc/Kconfig create mode 100644 drivers/misc/xlink-ipc/Makefile create mode 100644 drivers/misc/xlink-ipc/xlink-ipc.c create mode 100644 include/linux/xlink-ipc.h
Documentation/vpu/index.rst +1 -0
@@ -15,3 +15,4 @@ This documentation contains information for the Intel VPU stack. vpu-stack-overview xlink-pcie + xlink-ipc
Documentation/vpu/xlink-ipc.rst new file +50 -0
50 lines not on this page · raw message
MAINTAINERS +6 -0
@@ -1952,6 +1952,12 @@ F: Documentation/devicetree/bindings/arm/intel,keembay.yaml F: arch/arm64/boot/dts/intel/keembay-evm.dts F: arch/arm64/boot/dts/intel/keembay-soc.dtsi +ARM/INTEL XLINK IPC SUPPORT +M: Seamus Kelly <[email protected]> +M: Mark Gross <[email protected]> +S: Maintained +F: drivers/misc/xlink-ipc/ + ARM/INTEL KEEMBAY XLINK PCIE SUPPORT M: Srikanth Thokala <[email protected]> M: Mark Gross <[email protected]>
drivers/misc/Kconfig +1 -0
@@ -482,4 +482,5 @@ source "drivers/misc/cardreader/Kconfig" source "drivers/misc/habanalabs/Kconfig" source "drivers/misc/uacce/Kconfig" source "drivers/misc/xlink-pcie/Kconfig" +source "drivers/misc/xlink-ipc/Kconfig" endmenu
drivers/misc/Makefile +1 -0
@@ -58,3 +58,4 @@ obj-$(CONFIG_UACCE) += uacce/ obj-$(CONFIG_XILINX_SDFEC) += xilinx_sdfec.o obj-$(CONFIG_HISI_HIKEY_USB) += hisi_hikey_usb.o obj-y += xlink-pcie/ +obj-$(CONFIG_XLINK_IPC) += xlink-ipc/
drivers/misc/xlink-ipc/Kconfig new file +7 -0
@@ -0,0 +1,7 @@ +config XLINK_IPC + tristate "Support for XLINK IPC" + depends on KEEMBAY_VPU_IPC + help + XLINK IPC enables the communication/control IPC Sub-System. + + Select M if you have an Intel SoC with a Vision Processing Unit (VPU)
drivers/misc/xlink-ipc/Makefile new file +4 -0
@@ -0,0 +1,4 @@ +# +# Makefile for xlink IPC Linux driver +# +obj-$(CONFIG_XLINK_IPC) += xlink-ipc.o
drivers/misc/xlink-ipc/xlink-ipc.c new file +879 -0
879 lines not on this page · raw message
include/linux/xlink-ipc.h new file +48 -0
48 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [PATCH 16/22] xlink-ipc: Add xlink ipc driver
Quoted 5 lines · On Tue, 2020-12-01 at 14:35 -0800, [email protected] wrote:
From: Seamus Kelly <[email protected]>
Add xLink driver, which interfaces the xLink Core driver with the Keem Bay VPU IPC driver, thus enabling xLink to control and communicate with the VPU IP present on the Intel Keem Bay SoC.
Trivial style comments:
drivers/misc/xlink-ipc/xlink-ipc.c
Quoted 1 line
drivers/misc/xlink-ipc/xlink-ipc.c +0
-0
[]
Quoted 6 lines
drivers/misc/xlink-ipc/xlink-ipc.c +6
-0+/* +* xlink_reserved_memory_init() - Initialize reserved memory for the device. +* +* @xlink_dev: [in] The xlink ipc device the reserved memory is allocated to. +* +* Return: 0 on success, negative error code otherwise.
drivers/misc/xlink-ipc/xlink-ipc.c line 216
Quoted 10 lines
drivers/misc/xlink-ipc/xlink-ipc.c +10
-0+*/ +static int xlink_reserved_memory_init (struct xlink_ipc_dev *xlink_dev) +{ +struct device *dev = &xlink_dev->pdev->dev; + + xlink_dev->local_xlink_mem.dev =init_xlink_reserved_mem_dev (dev, +"xlink_local_reserved" , +LOCAL_XLINK_IPC_BUFFER_IDX ); +if (!xlink_dev->local_xlink_mem.dev) +return -ENOMEM ;
This sort of code, with a repeated struct dereference, generally reads better using a temporary and is also less prone to typo use.
struct device *dev = &xlink_dev->pdev->dev; struct xlink_buf_mem *lxm = &xlink_dev->local_xlink_mem; lxm->dev = init_xlink_reserved_mem_dev(dev, "xlink_local_reserved", LOCAL_XLINK_IPC_BUFFER_IDX); if (!lxm->dev) return -ENOMEM;
drivers/misc/xlink-ipc/xlink-ipc.c line 219
Quoted 2 lines
drivers/misc/xlink-ipc/xlink-ipc.c +2
-0+ xlink_dev->local_xlink_mem.size =get_xlink_reserved_mem_size (dev, +LOCAL_XLINK_IPC_BUFFER_IDX );
lxm->size = get_xlink_reserved_mem_size(dev, LOCAL_XLINK_IPC_BUFFER_IDX);
etc...
RE: [PATCH 16/22] xlink-ipc: Add xlink ipc driver
From: Joe Perches <[email protected]>
Sent: Monday, December 7, 2020 2:33 AM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; Kelly, Seamus <[email protected]>; [email protected]; Ryan Carnaghi <[email protected]>
Subject: Re: [PATCH 16/22] xlink-ipc: Add xlink ipc driver
Quoted 5 lines · On Tue, 2020-12-01 at 14:35 -0800, [email protected] wrote:
From: Seamus Kelly <[email protected]>
Add xLink driver, which interfaces the xLink Core driver with the Keem Bay VPU IPC driver, thus enabling xLink to control and communicate with the VPU IP present on the Intel Keem Bay SoC.
Trivial style comments:
drivers/misc/xlink-ipc/xlink-ipc.c
Quoted 2 lines
drivers/misc/xlink-ipc/xlink-ipc.c +0
-0
[]
Quoted 6 lines
drivers/misc/xlink-ipc/xlink-ipc.c +6
-0+/* +* xlink_reserved_memory_init() - Initialize reserved memory for the device. +* +* @xlink_dev: [in] The xlink ipc device the reserved memory is allocated to. +* +* Return: 0 on success, negative error code otherwise.
drivers/misc/xlink-ipc/xlink-ipc.c line 216
Quoted 10 lines
drivers/misc/xlink-ipc/xlink-ipc.c +10
-0+*/ +static int xlink_reserved_memory_init (struct xlink_ipc_dev +*xlink_dev) { +struct device *dev = &xlink_dev->pdev->dev; + + xlink_dev->local_xlink_mem.dev =init_xlink_reserved_mem_dev (dev, +"xlink_local_reserved" , +LOCAL_XLINK_IPC_BUFFER_IDX ); +if (!xlink_dev->local_xlink_mem.dev) +return -ENOMEM ;
This sort of code, with a repeated struct dereference, generally reads better using a temporary and is also less prone to typo use.
struct device *dev = &xlink_dev->pdev->dev; struct xlink_buf_mem *lxm = &xlink_dev->local_xlink_mem; lxm->dev = init_xlink_reserved_mem_dev(dev, "xlink_local_reserved", LOCAL_XLINK_IPC_BUFFER_IDX); if (!lxm->dev) return -ENOMEM;
drivers/misc/xlink-ipc/xlink-ipc.c line 219
Quoted 2 lines
drivers/misc/xlink-ipc/xlink-ipc.c +2
-0+ xlink_dev->local_xlink_mem.size =get_xlink_reserved_mem_size (dev, +LOCAL_XLINK_IPC_BUFFER_IDX );
lxm->size = get_xlink_reserved_mem_size(dev, LOCAL_XLINK_IPC_BUFFER_IDX);
etc...
[Kelly, Seamus] Thank you! will do.
--------------------------------------------------------------
Intel Research and Development Ireland Limited
Registered in Ireland
Registered Office: Collinstown Industrial Park, Leixlip, County Kildare Registered Number: 308263
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
[email protected]
maintainerRe: [PATCH 16/22] xlink-ipc: Add xlink ipc driver
Quoted 4 lines · Seamus
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
Now deleted!
This footer is incompatible with Linux kernel development, please remove it in order for us to read your emails and do anything with them.
I can't believe that Intel still has this problem, after all of these years...
greg k-h
RE: [PATCH 16/22] xlink-ipc: Add xlink ipc driver
Quoted 15 lines
-----Original Message-----
From: [email protected] <[email protected]>
Sent: Friday, December 11, 2020 4:14 AM
To: Kelly, Seamus <[email protected]>
Cc: Joe Perches <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]; Ryan Carnaghi <[email protected]>
Subject: Re: [PATCH 16/22] xlink-ipc: Add xlink ipc driver
Quoted 5 lines
Quoted 4 lines · Seamus
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
Must be something Seamus is using that knows when emails go outside. I would have caught this on our internal mock reviews otherwise.
Quoted 5 lines
Now deleted!
This footer is incompatible with Linux kernel development, please remove it in order for us to read your emails and do anything with them.
Yes, I know.
Quoted 2 lines
I can't believe that Intel still has this problem, after all of these years...
I'll add a warning about this in my training collateral and have all engineers I work with on this type of upstreaming send a test email to [email protected] so I can see if they have such legal clauses appended to out-bound email that is not visible to internal recipients. I'll fix this.
Sorry,
--mark
Randy Dunlap
reviewerRe: [PATCH 16/22] xlink-ipc: Add xlink ipc driver
In reply to [email protected]Ahoy--
Quoted 70 lines · On 12/1/20 2:35 PM, [email protected] wrote:
From: Seamus Kelly <[email protected]>
Add xLink driver, which interfaces the xLink Core driver with the Keem Bay VPU IPC driver, thus enabling xLink to control and communicate with the VPU IP present on the Intel Keem Bay SoC.
Specifically the driver enables xLink Core to:
* Boot / Reset the VPU IP
* Register to VPU IP event notifications (device connected, device disconnected, WDT event)
* Query the status of the VPU IP (OFF, BUSY, READY, ERROR, RECOVERY)
* Exchange data with the VPU IP, using the Keem Bay IPC mechanism
- Including the ability to send 'volatile' data (i.e., small amount of data, up to 128-bytes that was not allocated in the CPU/VPU shared memory region)Reviewed-by Mark Gross <[email protected]>Signed-off-by Seamus Kelly <[email protected]>Signed-off-by Ryan Carnaghi <[email protected]>--- Documentation/vpu/index.rst | 1 + Documentation/vpu/xlink-ipc.rst | 50 ++ MAINTAINERS | 6 + drivers/misc/Kconfig | 1 + drivers/misc/Makefile | 1 + drivers/misc/xlink-ipc/Kconfig | 7 + drivers/misc/xlink-ipc/Makefile | 4 + drivers/misc/xlink-ipc/xlink-ipc.c | 879 +++++++++++++++++++++++++++++ include/linux/xlink-ipc.h | 48 ++ 9 files changed, 997 insertions(+) create mode 100644 Documentation/vpu/xlink-ipc.rst create mode 100644 drivers/misc/xlink-ipc/Kconfig create mode 100644 drivers/misc/xlink-ipc/Makefile create mode 100644 drivers/misc/xlink-ipc/xlink-ipc.c create mode 100644 include/linux/xlink-ipc.hDocumentation/vpu/xlink-ipc.rst new file +26
-0@@ -0,0 +1,50 @@ +.. SPDX-License-Identifier: GPL-2.0-only + +Kernel driver: xLink IPC driver +================================= +Supported chips: + +* | Intel Edge.AI Computer Vision platforms: Keem Bay + | Suffix: Bay + | Datasheet: (not yet publicly available) + +------------ +Introduction +------------ + +The xLink IPC driver interfaces the xLink Core driver with the Keem Bay VPU IPC +driver, thus enabling xLink to control and communicate with the VPU IP present +on the Intel Keem Bay SoC. + +Specifically the driver enables xLink Core to: + +* Boot / Reset the VPU IP +* Register to VPU IP event notifications (device connected, device disconnected, + WDT event) +* Query the status of the VPU IP (OFF, BUSY, READY, ERROR, RECOVERY) +* Exchange data with the VPU IP, using the Keem Bay IPC mechanism +
Documentation/vpu/xlink-ipc.rst line 36
Quoted 10 lines
Documentation/vpu/xlink-ipc.rst new file +10
-0+ * Including the ability to send 'volatile' data (i.e., small amount of data, + up to 128-bytes that was not allocated in the CPU/VPU shared memory region) + +Sending / Receiving 'volatile' data +----------------------------------- + +Data to be exchanged with Keem Bay IPC needs to be allocated in the portion of +DDR shared between the CPU and VPU. + +This can be impractical for small amount of data that user code can allocate
amounts
Documentation/vpu/xlink-ipc.rst line 45
Quoted 9 lines
Documentation/vpu/xlink-ipc.rst new file +9
-0+on the stack. + +To reduce the burden on user code, xLink Core provides special send / receive +functions to send up to 128 bytes of 'volatile data', i.e., data that is not +allocated in the shared memory and that might also disappear after the xLink +API is called (e.g., because allocated on the stack). + +The xLink IPC driver implements support for transferring such 'volatile data' +to the VPU using Keem Bay IPC. To this end, the driver reserved some memory in
better: reserves
Quoted 12 lines
Documentation/vpu/xlink-ipc.rst new file +5
-0+the shared memory region. + +When volatile data is to be sent, xLink IPC allocates a buffer from the +reserved memory region and copies the volatile data to the buffer. The buffer +is then transferred to the VPU using Keem Bay IPC.drivers/misc/xlink-ipc/Kconfig new file +0
-0
drivers/misc/xlink-ipc/Kconfig line 7
Quoted 7 lines
drivers/misc/xlink-ipc/Kconfig new file +7
-0@@ -0,0 +1,7 @@ +config XLINK_IPC + tristate "Support for XLINK IPC" + depends on KEEMBAY_VPU_IPC + help + XLINK IPC enables the communication/control IPC Sub-System. + + Select M if you have an Intel SoC with a Vision Processing Unit (VPU)
End that sentence with a '.', please.
Signature · 1 line
~Randy
PATCH 17/22 xlink-core: Add xlink core device tree bindings
In reply to [email protected]From: Seamus Kelly <[email protected]>
Add device tree bindings for keembay-xlink.
--- .../bindings/misc/intel,keembay-xlink.yaml | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Documentation/devicetree/bindings/misc/intel,keembay-xlink.yaml
Documentation/devicetree/bindings/misc/intel,keembay-xlink.yaml new file +27 -0
@@ -0,0 +1,27 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +# Copyright (c) Intel Corporation. All rights reserved. +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/misc/intel,keembay-xlink.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Intel Keem Bay xlink + +maintainers: + - Seamus Kelly <[email protected]> + +description: | + The Keem Bay xlink driver enables the communication/control sub-system + for internal and external communications to the Intel Keem Bay SoC. + +properties: + compatible: + oneOf: + - items: + - const: intel,keembay-xlink + +examples: + - | + xlink { + compatible = "intel,keembay-xlink"; + };
Signature · 1 line
2.17.1
Rob Herring
maintainerRe: [PATCH 17/22] xlink-core: Add xlink core device tree bindings
Quoted 4 lines · On Tue, 01 Dec 2020 14:35:06 -0800, [email protected] wrote:
From: Seamus Kelly <[email protected]>
Add device tree bindings for keembay-xlink.
Quoted 9 lines
Reviewed-by Mark Gross <[email protected]>Signed-off-by Seamus Kelly <[email protected]>Signed-off-by Ryan Carnaghi <[email protected]>--- .../bindings/misc/intel,keembay-xlink.yaml | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Documentation/devicetree/bindings/misc/intel,keembay-xlink.yaml
My bot found errors running 'make dt_binding_check' on your patch:
yamllint warnings/errors:./Documentation/devicetree/bindings/misc/intel,keembay-xlink.yaml:21:9: [warning] wrong indentation: expected 10 but found 8 (indentation)
dtschema/dtc warnings/errors:
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/misc/intel,keembay-xlink.yaml: 'additionalProperties' is a required property /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/misc/intel,keembay-xlink.yaml: ignoring, error in schema:
warning: no schema found in file: ./Documentation/devicetree/bindings/misc/intel,keembay-xlink.yaml
See https://patchwork.ozlabs.org/patch/1409184
The base for the patch is generally the last rc1. Any dependencies should be noted.
If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:
pip3 install dtschema --upgrade
Please check and re-submit.
PATCH 18/22 xlink-core: Add xlink core driver xLink
In reply to [email protected]From: Seamus Kelly <[email protected]>
Add xLink driver, which provides an abstracted control and communication subsystem based on channel identification.
It is intended to support VPU technology both at SoC level as well as at IP level, over multiple interfaces. This initial patch enables local host user mode to open/close/read/write via IOCTLs.
Specifically the driver enables application/process to:
* Access a common xLink API across all interfaces from both kernel and user space.
* Call typical APIs types (open, close, read, write) that you would associate with a communication interface.
* Call other APIs that are related to other functions that the device can perform e.g. boot, reset get/set device mode. Device mode refers to the power load of the VPU and an API can be used to read and control it.
* Use multiple commnication channels that the driver manages from one interface to another, providing routing of data through these multiple channels across a single physical interface.
xLink: Add xLink Core device tree bindings
Add device tree bindings for the xLink Core driver which enables xLink to control and communicate with the VPU IP present on the Intel Keem Bay SoC.
--- Documentation/vpu/index.rst | 1 + Documentation/vpu/xlink-core.rst | 80 ++ MAINTAINERS | 12 + drivers/misc/Kconfig | 1 + drivers/misc/Makefile | 1 + drivers/misc/xlink-core/Kconfig | 33 + drivers/misc/xlink-core/Makefile | 5 + drivers/misc/xlink-core/xlink-core.c | 870 ++++++++++++++++++++ drivers/misc/xlink-core/xlink-defs.h | 175 ++++ drivers/misc/xlink-core/xlink-multiplexer.c | 534 ++++++++++++ drivers/misc/xlink-core/xlink-multiplexer.h | 35 + drivers/misc/xlink-core/xlink-platform.c | 160 ++++ drivers/misc/xlink-core/xlink-platform.h | 65 ++ include/linux/xlink.h | 108 +++ include/uapi/misc/xlink_uapi.h | 145 ++++ 15 files changed, 2225 insertions(+) create mode 100644 Documentation/vpu/xlink-core.rst create mode 100644 drivers/misc/xlink-core/Kconfig create mode 100644 drivers/misc/xlink-core/Makefile create mode 100644 drivers/misc/xlink-core/xlink-core.c create mode 100644 drivers/misc/xlink-core/xlink-defs.h create mode 100644 drivers/misc/xlink-core/xlink-multiplexer.c create mode 100644 drivers/misc/xlink-core/xlink-multiplexer.h create mode 100644 drivers/misc/xlink-core/xlink-platform.c create mode 100644 drivers/misc/xlink-core/xlink-platform.h create mode 100644 include/linux/xlink.h create mode 100644 include/uapi/misc/xlink_uapi.h
Documentation/vpu/index.rst +1 -0
@@ -16,3 +16,4 @@ This documentation contains information for the Intel VPU stack. vpu-stack-overview xlink-pcie xlink-ipc + xlink-core
Documentation/vpu/xlink-core.rst new file +80 -0
80 lines not on this page · raw message
MAINTAINERS +12 -0
@@ -1952,6 +1952,12 @@ F: Documentation/devicetree/bindings/arm/intel,keembay.yaml F: arch/arm64/boot/dts/intel/keembay-evm.dts F: arch/arm64/boot/dts/intel/keembay-soc.dtsi +ARM/INTEL XLINK CORE SUPPORT +M: Seamus Kelly <[email protected]> +M: Mark Gross <[email protected]> +S: Maintained +F: drivers/misc/xlink-core/ + ARM/INTEL XLINK IPC SUPPORT M: Seamus Kelly <[email protected]> M: Mark Gross <[email protected]>
@@ -1964,6 +1970,12 @@ M: Mark Gross <[email protected]> S: Maintained F: drivers/misc/xlink-pcie/ +ARM/INTEL TSENS SUPPORT +M: Udhayakumar C <[email protected]> +S: Maintained +F: drivers/misc/hddl_device/ +F: drivers/misc/intel_tsens/ + ARM/INTEL RESEARCH IMOTE/STARGATE 2 MACHINE SUPPORT M: Jonathan Cameron <[email protected]> L: [email protected] (moderated for non-subscribers)
drivers/misc/Kconfig +1 -0
@@ -483,4 +483,5 @@ source "drivers/misc/habanalabs/Kconfig" source "drivers/misc/uacce/Kconfig" source "drivers/misc/xlink-pcie/Kconfig" source "drivers/misc/xlink-ipc/Kconfig" +source "drivers/misc/xlink-core/Kconfig" endmenu
drivers/misc/Makefile +1 -0
@@ -59,3 +59,4 @@ obj-$(CONFIG_XILINX_SDFEC) += xilinx_sdfec.o obj-$(CONFIG_HISI_HIKEY_USB) += hisi_hikey_usb.o obj-y += xlink-pcie/ obj-$(CONFIG_XLINK_IPC) += xlink-ipc/ +obj-$(CONFIG_XLINK_CORE) += xlink-core/
drivers/misc/xlink-core/Kconfig new file +33 -0
@@ -0,0 +1,33 @@ +config XLINK_CORE + tristate "Support for XLINK CORE" + depends on ((XLINK_PCIE_RH_DRIVER || XBAY_XLINK_PCIE_RH_DRIVER) || (XLINK_LOCAL_HOST && (XLINK_PCIE_LH_DRIVER || XBAY_XLINK_PCIE_RH_DRIVER))) + help + XLINK CORE enables the communication/control Sub-System. + + If unsure, say N. + + To compile this driver as a module, choose M here: the + module will be called xlink.ko. + +config XLINK_LOCAL_HOST + tristate "Support for XLINK LOCAL HOST" + depends on XLINK_IPC + help + XLINK LOCAL HOST enables local host functionality for + the communication/control Sub-System. + + Enable this config when building the kernel for the Inel Vision + Processing Unit (VPU) Local Host core. + + If building for a Remote Host kernel, say N. + +config XLINK_PSS + tristate "Support for XLINK PSS" + depends on XLINK_LOCAL_HOST + help + XLINK PSS enables the communication/control Sub-System on a PSS platform. + + Enable this config when building the kernel for the Intel Vision + Processing Unit (VPU) in a simulated env. + + If building for a VPU silicon, say N.
drivers/misc/xlink-core/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# +# Makefile for KeemBay xlink Linux driver +# +obj-$(CONFIG_XLINK_CORE) += xlink.o +xlink-objs += xlink-core.o xlink-multiplexer.o xlink-platform.o
drivers/misc/xlink-core/xlink-core.c new file +870 -0
870 lines not on this page · raw message
drivers/misc/xlink-core/xlink-defs.h new file +175 -0
175 lines not on this page · raw message
drivers/misc/xlink-core/xlink-multiplexer.c new file +534 -0
534 lines not on this page · raw message
drivers/misc/xlink-core/xlink-multiplexer.h new file +35 -0
@@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* xlink Multiplexer. +* +* Copyright (C) 2018-2019 Intel Corporation +* +*/ +#ifndef __XLINK_MULTIPLEXER_H +#define __XLINK_MULTIPLEXER_H + +#include "xlink-defs.h" + +enum xlink_error xlink_multiplexer_init (void *dev); + +enum xlink_error xlink_multiplexer_connect (u32 link_id); + +enum xlink_error xlink_multiplexer_disconnect (u32 link_id); + +enum xlink_error xlink_multiplexer_destroy (void ); + +enum xlink_error xlink_multiplexer_tx (struct xlink_event *event, +int *event_queued); + +enum xlink_error xlink_multiplexer_rx (struct xlink_event *event); + +enum xlink_error xlink_passthrough (struct xlink_event *event); + +void *find_allocated_buffer (dma_addr_t paddr); + +int unregister_allocated_buffer (void *buf,dma_addr_t paddr); + +int core_release_packet_from_channel (u32 link_id,uint16_t chan, +uint8_t *const addr); + +#endif /* __XLINK_MULTIPLEXER_H */
drivers/misc/xlink-core/xlink-platform.c new file +160 -0
160 lines not on this page · raw message
drivers/misc/xlink-core/xlink-platform.h new file +65 -0
65 lines not on this page · raw message
include/linux/xlink.h new file +108 -0
108 lines not on this page · raw message
include/uapi/misc/xlink_uapi.h new file +145 -0
145 lines not on this page · raw message
Signature · 1 line
2.17.1
Randy Dunlap
reviewerRe: [PATCH 18/22] xlink-core: Add xlink core driver xLink
Hi--
Quoted 41 lines · On 12/1/20 2:35 PM, [email protected] wrote:
From: Seamus Kelly <[email protected]>
Reviewed-by Mark Gross <[email protected]>Signed-off-by Seamus Kelly <[email protected]>--- Documentation/vpu/index.rst | 1 + Documentation/vpu/xlink-core.rst | 80 ++ MAINTAINERS | 12 + drivers/misc/Kconfig | 1 + drivers/misc/Makefile | 1 + drivers/misc/xlink-core/Kconfig | 33 + drivers/misc/xlink-core/Makefile | 5 + drivers/misc/xlink-core/xlink-core.c | 870 ++++++++++++++++++++ drivers/misc/xlink-core/xlink-defs.h | 175 ++++ drivers/misc/xlink-core/xlink-multiplexer.c | 534 ++++++++++++ drivers/misc/xlink-core/xlink-multiplexer.h | 35 + drivers/misc/xlink-core/xlink-platform.c | 160 ++++ drivers/misc/xlink-core/xlink-platform.h | 65 ++ include/linux/xlink.h | 108 +++ include/uapi/misc/xlink_uapi.h | 145 ++++ 15 files changed, 2225 insertions(+) create mode 100644 Documentation/vpu/xlink-core.rst create mode 100644 drivers/misc/xlink-core/Kconfig create mode 100644 drivers/misc/xlink-core/Makefile create mode 100644 drivers/misc/xlink-core/xlink-core.c create mode 100644 drivers/misc/xlink-core/xlink-defs.h create mode 100644 drivers/misc/xlink-core/xlink-multiplexer.c create mode 100644 drivers/misc/xlink-core/xlink-multiplexer.h create mode 100644 drivers/misc/xlink-core/xlink-platform.c create mode 100644 drivers/misc/xlink-core/xlink-platform.h create mode 100644 include/linux/xlink.h create mode 100644 include/uapi/misc/xlink_uapi.hDocumentation/vpu/xlink-core.rst new file +0
-0
Documentation/vpu/xlink-core.rst line 3
Quoted 3 lines
Documentation/vpu/xlink-core.rst new file +3
-0@@ -0,0 +1,80 @@ +.. SPDX-License-Identifier: GPL-2.0-only + +xLink-core software sub-system
subsystem
Documentation/vpu/xlink-core.rst line 6
Quoted 3 lines
Documentation/vpu/xlink-core.rst new file +3
-0+============================== + +The purpose of the xLink software sub-system is to facilitate communication
subsystem {throughout/everywhere}Quoted 10 lines
Documentation/vpu/xlink-core.rst new file +10
-0+between multiple users on multiple nodes in the system. + +There are three types of xLink nodes: + +1. Remote Host: this is an external IA/x86 host system that is only capable of + communicating directly to the Local Host node on VPU 2.x products. +2. Local Host: this is the ARM core within the VPU 2.x SoC. The Local Host can + communicate upstream to the Remote Host node, and downstream to the VPU IP + node. +3. VPU IP: this is the Leon RT core within the VPU 2.x SoC. The VPU IP can only
Documentation/vpu/xlink-core.rst line 26
Quoted 10 lines
Documentation/vpu/xlink-core.rst new file +10
-0+ communicate upstream to the Local Host node. + +xLink provides a common API across all interfaces for users to access xLink +functions and provides user space APIs via an IOCTL interface implemented in +the xLink core. + +xLink manages communications from one interface to another and provides routing +of data through multiple channels across a single physical interface. + +It exposes a common API across all interfaces at both kernel and user level for
levels
Documentation/vpu/xlink-core.rst line 29
Quoted 3 lines
Documentation/vpu/xlink-core.rst new file +3
-0+processes/applications to access. + +It has typical APIs types (open, close, read, write) that you would associate
API types
Documentation/vpu/xlink-core.rst line 33
Quoted 4 lines
Documentation/vpu/xlink-core.rst new file +4
-0+with a communication interface. + +It also has other APIs that are related to other functions that the device can +perform e.g. boot, reset get/set device mode.
perform,
Quoted 11 lines
Documentation/vpu/xlink-core.rst new file +11
-0+The driver is broken down into 4 source files. + +xlink-core: +Contains driver initialization, driver API and IOCTL interface (for user +space). + +xlink-multiplexer: +The Multiplexer component is responsible for securely routing messages through +multiple communication channels over a single physical interface. + +xlink-dispatcher:
Documentation/vpu/xlink-core.rst line 54
Quoted 10 lines
Documentation/vpu/xlink-core.rst new file +10
-0+The Dispatcher component is responsible for queueing and handling xLink +communication requests from all users in the system and invoking the underlying +platform interface drivers. + +xlink-platform: +provides abstraction to each interface supported (PCIe, USB, IPC, etc). + +Typical xLink transaction (simplified): +When a user wants to send data across an interface via xLink it firstly calls +xlink connect which connects to the relevant interface (PCIe, USB,IPC,etc) and
USB, IPC, etc.) and
Documentation/vpu/xlink-core.rst line 57
Quoted 3 lines
Documentation/vpu/xlink-core.rst new file +3
-0+then xlink open channel. + +Then it calls xlink write function, this takes the data passes it to the kernel
data, passes
Documentation/vpu/xlink-core.rst line 58
Quoted 1 line
Documentation/vpu/xlink-core.rst new file +1
-0+which packages up the data and channel and then adds it to a tx transaction
s/tx/transmit/
Quoted 4 lines
Documentation/vpu/xlink-core.rst new file +4
-0+queue. + +A separate thread reads this transaction queue and pops off data if available +and passes the data to the underlying interface (e.g. PCIe) write function.
Documentation/vpu/xlink-core.rst line 72
Quoted 10 lines
Documentation/vpu/xlink-core.rst new file +10
-0+Using this thread provides serialization of transactions and decouples the user +write from the platform write. + +On the other side of the interface, a thread is continually reading the +interface (e.g. PCIe) via the platform interface read function and if it reads +any data it adds it to channel packet container. + +The application at this side of the interface will have called xlink connect, +opened the channel and called xlink read function to read data from the +interface and if any exists for that channel , the data gets popped from the
channel,
Documentation/vpu/xlink-core.rst line 79
Quoted 7 lines
Documentation/vpu/xlink-core.rst new file +7
-0+channel packet container and copied from kernel space to user space buffer +provided by the call. + +xLink can handle API requests from multi-process and multi-threaded +application/processes. + +xLink maintains 4096 channels per device connected ( via xlink connect ) and
(via xlink connect) and
drivers/misc/xlink-core/Kconfig line 5
Quoted 13 lines
Documentation/vpu/xlink-core.rst new file +1
-0+maintains a separate channel infrastructure for each device.drivers/misc/xlink-core/Kconfig new file +5
-0@@ -0,0 +1,33 @@ +config XLINK_CORE + tristate "Support for XLINK CORE" + depends on ((XLINK_PCIE_RH_DRIVER || XBAY_XLINK_PCIE_RH_DRIVER) || (XLINK_LOCAL_HOST && (XLINK_PCIE_LH_DRIVER || XBAY_XLINK_PCIE_RH_DRIVER))) + help + XLINK CORE enables the communication/control Sub-System.
subsystem {no hyphen]
drivers/misc/xlink-core/Kconfig line 17
Quoted 12 lines
drivers/misc/xlink-core/Kconfig new file +12
-0+ + If unsure, say N. + + To compile this driver as a module, choose M here: the + module will be called xlink.ko. + +config XLINK_LOCAL_HOST + tristate "Support for XLINK LOCAL HOST" + depends on XLINK_IPC + help + XLINK LOCAL HOST enables local host functionality for + the communication/control Sub-System.
subsystem.
drivers/misc/xlink-core/Kconfig line 19
Quoted 2 lines
drivers/misc/xlink-core/Kconfig new file +2
-0+ + Enable this config when building the kernel for the Inel Vision
Intel
drivers/misc/xlink-core/Kconfig line 28
Quoted 9 lines
drivers/misc/xlink-core/Kconfig new file +9
-0+ Processing Unit (VPU) Local Host core. + + If building for a Remote Host kernel, say N. + +config XLINK_PSS + tristate "Support for XLINK PSS" + depends on XLINK_LOCAL_HOST + help + XLINK PSS enables the communication/control Sub-System on a PSS platform.
subsystem
Where is PSS defined?
Please spell out that acronym somewhere, e.g.:
tristate "Support for XLINK PSS (Please Say Something)"
Quoted 5 lines
drivers/misc/xlink-core/Kconfig new file +5
-0+ + Enable this config when building the kernel for the Intel Vision + Processing Unit (VPU) in a simulated env. + + If building for a VPU silicon, say N.
Signature · 1 line
~Randy
PATCH 19/22 xlink-core: Enable xlink protocol over pcie
In reply to [email protected]From: Seamus Kelly <[email protected]>
Enable host system access to the VPU over the xlink protocol over PCIe by enabling channel multiplexing and dispatching. This allows for remote host communication channels across pcie links.
add dispatcher
update multiplexer to utilise dispatcher
xlink-core: Patch set 2
Add xlink-dispatcher
creates tx and rx threads
enables queueing of messages for transmission and on reception
Update multiplexer to utilise dispatcher:
handle multiplexing channels over single interface link e.g. PCIe process messages received by dispatcher
pass messages created by API calls to dispatcher for transmission
--- drivers/misc/xlink-core/Makefile | 2 +- drivers/misc/xlink-core/xlink-core.c | 38 +- drivers/misc/xlink-core/xlink-dispatcher.c | 441 +++++++++++++++++ drivers/misc/xlink-core/xlink-dispatcher.h | 26 + drivers/misc/xlink-core/xlink-multiplexer.c | 498 +++++++++++++++++++- 5 files changed, 1001 insertions(+), 4 deletions(-) create mode 100644 drivers/misc/xlink-core/xlink-dispatcher.c create mode 100644 drivers/misc/xlink-core/xlink-dispatcher.h
drivers/misc/xlink-core/Makefile +1 -1
@@ -2,4 +2,4 @@ # Makefile for KeemBay xlink Linux driver # obj-$(CONFIG_XLINK_CORE) += xlink.o -xlink-objs += xlink-core.o xlink-multiplexer.o xlink-platform.o +xlink-objs += xlink-core.o xlink-multiplexer.o xlink-dispatcher.o xlink-platform.o
drivers/misc/xlink-core/xlink-core.c +36 -2
@@ -20,6 +20,7 @@#endif #include "xlink-defs.h" +#include "xlink-dispatcher.h" #include "xlink-multiplexer.h" #include "xlink-platform.h"
@@ -159,6 +160,12 @@ static int kmb_xlink_probe(struct platform_device *pdev) goto r_multiplexer; } +// initialize dispatcher + rc =xlink_dispatcher_init (xlink_dev->pdev); +if (rc !=X_LINK_SUCCESS ) { +pr_err ("Dispatcher initialization failed\n" ); + goto r_dispatcher; + }// initialize xlink data structure xlink_dev->nmb_connected_links =0 ;mutex_init (&xlink_dev->lock);
@@ -176,7 +183,7 @@ static int kmb_xlink_probe(struct platform_device *pdev)/*Allocating Major number*/ if ((alloc_chrdev_region (&xdev,0 ,1 ,"xlinkdev" )) <0 ) {dev_info (&pdev->dev,"Cannot allocate major number\n" ); - goto r_multiplexer; + goto r_dispatcher; }dev_info (&pdev->dev,"Major = %d Minor = %d\n" ,MAJOR (xdev),MINOR (xdev));
@@ -213,6 +220,8 @@ static int kmb_xlink_probe(struct platform_device *pdev)class_destroy (dev_class); r_class:unregister_chrdev_region (xdev,1 ); +r_dispatcher: +xlink_dispatcher_destroy (); r_multiplexer:xlink_multiplexer_destroy ();return -1 ;
@@ -228,6 +237,10 @@ static int kmb_xlink_remove(struct platform_device *pdev) rc =xlink_multiplexer_destroy ();if (rc !=X_LINK_SUCCESS )pr_err ("Multiplexer destroy failed\n" ); +// stop dispatchers and destroy + rc =xlink_dispatcher_destroy (); +if (rc !=X_LINK_SUCCESS ) +pr_err ("Dispatcher destroy failed\n" );mutex_unlock (&xlink->lock);mutex_destroy (&xlink->lock);
@@ -436,6 +449,14 @@ enum xlink_error xlink_connect(struct xlink_handle *handle) link->handle = *handle; xlink->nmb_connected_links++;kref_init (&link->refcount); +if (interface !=IPC_INTERFACE ) { +// start dispatcher + rc =xlink_dispatcher_start (link->id, &link->handle); +if (rc) { +pr_err ("dispatcher start failed\n" ); + goto r_cleanup; + } + }// initialize multiplexer connection rc =xlink_multiplexer_connect (link->id);if (rc) {
@@ -629,7 +650,8 @@ static enum xlink_error xlink_write_data_user(struct xlink_handle *handle, }static enum xlink_error xlink_write_volatile_user (struct xlink_handle *handle, -u16 chan,u8 const *message,u32 size) +u16 chan,u8 const *message, +u32 size) {enum xlink_error rc =0 ;
@@ -781,6 +803,7 @@ EXPORT_SYMBOL(xlink_release_data);enum xlink_error xlink_disconnect (struct xlink_handle *handle) {struct xlink_link *link; +int interface =NULL_INTERFACE ;enum xlink_error rc =X_LINK_ERROR ;if (!xlink || !handle)
@@ -793,6 +816,17 @@ enum xlink_error xlink_disconnect(struct xlink_handle *handle)// decrement refcount, if count is 0 lock mutex and disconnect if (kref_put_mutex (&link->refcount, release_after_kref_put, &xlink->lock)) { +// stop dispatcher + interface =get_interface_from_sw_device_id (link->handle.sw_device_id); +if (interface !=IPC_INTERFACE ) { +// stop dispatcher + rc =xlink_dispatcher_stop (link->id); +if (rc !=X_LINK_SUCCESS ) { +pr_err ("dispatcher stop failed\n" ); +mutex_unlock (&xlink->lock); +return X_LINK_ERROR ; + } + }// deinitialize multiplexer connection rc =xlink_multiplexer_disconnect (link->id);if (rc) {
drivers/misc/xlink-core/xlink-dispatcher.c new file +441 -0
441 lines not on this page · raw message
drivers/misc/xlink-core/xlink-dispatcher.h new file +26 -0
@@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* xlink Dispatcher. +* +* Copyright (C) 2018-2019 Intel Corporation +* +*/ +#ifndef __XLINK_DISPATCHER_H +#define __XLINK_DISPATCHER_H + +#include "xlink-defs.h" + +enum xlink_error xlink_dispatcher_init (void *dev); + +enum xlink_error xlink_dispatcher_start (int id,struct xlink_handle *handle); + +enum xlink_error xlink_dispatcher_event_add (enum xlink_event_origin origin, +struct xlink_event *event); + +enum xlink_error xlink_dispatcher_stop (int id); + +enum xlink_error xlink_dispatcher_destroy (void ); + +enum xlink_error xlink_dispatcher_ipc_passthru_event_add (struct xlink_event *event); + +#endif /* __XLINK_DISPATCHER_H */
drivers/misc/xlink-core/xlink-multiplexer.c +497 -1
539 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 20/22 xlink-core: Enable VPU IP management and runtime control
In reply to [email protected]From: Seamus Kelly <[email protected]>
Enable VPU management including, enumeration, boot and runtime control.
Add APIs:
write control data:
used to transmit small, local data
start vpu:
calls boot_device API ( soon to be deprecated )
stop vpu
calls reset_device API ( soon to be deprecated )
reset vpu
calls reset_device API ( soon to be deprecated )
get device name:
Returns the device name for the input device id
This could be a char device path, for example "/dev/ttyUSB0" for a serial device; or it could be a device string description, for example, for PCIE "00:00.0 Host bridge: Intel Corporation 440BX/ZX/DX - 82443BX/ZX/DX Host bridge (rev 01)"
get device list:
Returns the list of software device IDs for all connected physical devices
get device status:
returns the current state of the input device
OFF - The device is off (D3cold/Slot power removed). BUSY - device is busy and not available (device is booting) READY - device is available for use
ERROR - device HW failure is detected
RECOVERY - device is in recovery mode, waiting for recovery operations
boot device:
When used on the remote host - starts the SOC device by calling corresponding function from VPU Driver.
Takes firmware's 'binary_name' as input.
For Linux, the firmware image is expected to be located in '/lib/firmware' folder or its subfolders.
For Linux, 'binary_name' is not a path but an image name that will be searched in the default Linux search paths ('/lib/firmware'). When used on the local host - triggers the booting of VPUIP device.
reset device:
When used on the remote host - resets the device by calling corresponding VPU Driver function.
When used on the local host - resets the VPUIP device
get device mode:
query and returns the current device power mode
set device mode:
used for device throttling or entering various power modes
--- drivers/misc/xlink-core/xlink-core.c | 408 +++++++++++++++++++- drivers/misc/xlink-core/xlink-defs.h | 2 + drivers/misc/xlink-core/xlink-multiplexer.c | 56 +++ drivers/misc/xlink-core/xlink-platform.c | 86 +++++ include/linux/xlink.h | 27 ++ 5 files changed, 573 insertions(+), 6 deletions(-)
drivers/misc/xlink-core/xlink-core.c +402 -6
@@ -81,6 +81,8 @@ struct keembay_xlink_dev {struct mutex lock;// protect access to xlink_dev }; +static u8 volbuf[XLINK_MAX_BUF_SIZE ];// buffer for volatile transactions +/* * global variable pointing to our xlink device. *
@@ -260,14 +262,27 @@ static int kmb_xlink_remove(struct platform_device *pdev)static long xlink_ioctl (struct file *file,unsigned int cmd,unsigned long arg) { -int interface =NULL_INTERFACE ;struct xlink_handle devh = {0 };struct xlinkopenchannel op = {0 };struct xlinkwritedata wr = {0 };struct xlinkreaddata rd = {0 }; +struct xlinkreadtobuffer rdtobuf = {0 };struct xlinkconnect con = {0 };struct xlinkrelease rel = {0 }; -u8 volbuf[XLINK_MAX_BUF_SIZE ]; +struct xlinkstartvpu startvpu = {0 }; +struct xlinkgetdevicename devn = {0 }; +struct xlinkgetdevicelist devl = {0 }; +struct xlinkgetdevicestatus devs = {0 }; +struct xlinkbootdevice boot = {0 }; +struct xlinkresetdevice res = {0 }; +struct xlinkdevmode devm = {0 }; +u32 sw_device_id_list[XLINK_MAX_DEVICE_LIST_SIZE ]; +char name[XLINK_MAX_DEVICE_NAME_SIZE ]; +int interface =NULL_INTERFACE ; +u32 device_status =0 ; +u32 num_devices =0 ; +u32 device_mode =0 ; +char filename[64 ];u8 reladdr;u8 *rdaddr;u32 size;
@@ -328,6 +343,26 @@ static long xlink_ioctl(struct file *file, unsigned int cmd, unsigned long arg)if (copy_to_user ((void __user *)rd.return_code, (void *)&rc,sizeof (rc)))return -EFAULT ;break ; +case XL_READ_TO_BUFFER : +if (copy_from_user (&rdtobuf, (void __user *)arg, +sizeof (struct xlinkreadtobuffer ))) +return -EFAULT ; +if (copy_from_user (&devh, (void __user *)rdtobuf.handle, +sizeof (struct xlink_handle ))) +return -EFAULT ; + rc =xlink_read_data_to_buffer (&devh, rdtobuf.chan, + (u8 *)volbuf, &size); +if (!rc) { +if (copy_to_user ((void __user *)rdtobuf.pmessage, (void *)volbuf, + size)) +return -EFAULT ; +if (copy_to_user ((void __user *)rdtobuf.size, (void *)&size, +sizeof (size))) +return -EFAULT ; + } +if (copy_to_user ((void __user *)rdtobuf.return_code, (void *)&rc,sizeof (rc))) +return -EFAULT ; +break ;case XL_WRITE_DATA :if (copy_from_user (&wr, (void __user *)arg,sizeof (struct xlinkwritedata )))
@@ -346,16 +381,40 @@ static long xlink_ioctl(struct file *file, unsigned int cmd, unsigned long arg) }break ;case XL_WRITE_VOLATILE : -if (copy_from_user (&wr, (void __user *)arg,sizeof (struct xlinkwritedata ))) +if (copy_from_user (&wr, (void __user *)arg, +sizeof (struct xlinkwritedata )))return -EFAULT ;if (copy_from_user (&devh, (void __user *)wr.handle,sizeof (struct xlink_handle )))return -EFAULT ;if (wr.size <=XLINK_MAX_BUF_SIZE ) { -if (copy_from_user (volbuf, (void __user *)wr.pmessage, wr.size)) +if (copy_from_user (volbuf, (void __user *)wr.pmessage, + wr.size))return -EFAULT ; - rc =xlink_write_volatile_user (&devh, wr.chan, volbuf, wr.size); -if (copy_to_user ((void __user *)wr.return_code, (void *)&rc,sizeof (rc))) + rc =xlink_write_volatile_user (&devh, wr.chan, volbuf, + wr.size); +if (copy_to_user ((void __user *)wr.return_code, (void *)&rc, +sizeof (rc))) +return -EFAULT ; + }else { +return -EFAULT ; + } +break ; +case XL_WRITE_CONTROL_DATA : +if (copy_from_user (&wr, (void __user *)arg, +sizeof (struct xlinkwritedata ))) +return -EFAULT ; +if (copy_from_user (&devh, (void __user *)wr.handle, +sizeof (struct xlink_handle ))) +return -EFAULT ; +if (wr.size <=XLINK_MAX_CONTROL_DATA_SIZE ) { +if (copy_from_user (volbuf, (void __user *)wr.pmessage, + wr.size)) +return -EFAULT ; + rc =xlink_write_control_data (&devh, wr.chan, volbuf, + wr.size); +if (copy_to_user ((void __user *)wr.return_code, + (void *)&rc,sizeof (rc)))return -EFAULT ; }else {return -EFAULT ;
@@ -390,6 +449,26 @@ static long xlink_ioctl(struct file *file, unsigned int cmd, unsigned long arg)if (copy_to_user ((void __user *)op.return_code, (void *)&rc,sizeof (rc)))return -EFAULT ;break ; +case XL_START_VPU : +if (copy_from_user (&startvpu, (void __user *)arg, +sizeof (struct xlinkstartvpu ))) +return -EFAULT ; +if (startvpu.namesize >sizeof (filename)) +return -EINVAL ; +memset (filename,0 ,sizeof (filename)); +if (copy_from_user (filename, (void __user *)startvpu.filename, + startvpu.namesize)) +return -EFAULT ; + rc =xlink_start_vpu (filename); +if (copy_to_user ((void __user *)startvpu.return_code, (void *)&rc,sizeof (rc))) +return -EFAULT ; +break ; +case XL_STOP_VPU : + rc =xlink_stop_vpu (); +break ; +case XL_RESET_VPU : + rc =xlink_stop_vpu (); +break ;case XL_DISCONNECT :if (copy_from_user (&con, (void __user *)arg,sizeof (struct xlinkconnect )))
@@ -401,6 +480,124 @@ static long xlink_ioctl(struct file *file, unsigned int cmd, unsigned long arg)if (copy_to_user ((void __user *)con.return_code, (void *)&rc,sizeof (rc)))return -EFAULT ;break ; +case XL_GET_DEVICE_NAME : +if (copy_from_user (&devn, (void __user *)arg, +sizeof (struct xlinkgetdevicename ))) +return -EFAULT ; +if (copy_from_user (&devh, (void __user *)devn.handle, +sizeof (struct xlink_handle ))) +return -EFAULT ; +if (devn.name_size <=XLINK_MAX_DEVICE_NAME_SIZE ) { + rc =xlink_get_device_name (&devh, name, devn.name_size); +if (!rc) { +if (copy_to_user ((void __user *)devn.name, (void *)name, + devn.name_size)) +return -EFAULT ; + } + }else { + rc =X_LINK_ERROR ; + } +if (copy_to_user ((void __user *)devn.return_code, (void *)&rc,sizeof (rc))) +return -EFAULT ; +break ; +case XL_GET_DEVICE_LIST : +if (copy_from_user (&devl, (void __user *)arg, +sizeof (struct xlinkgetdevicelist ))) +return -EFAULT ; + rc =xlink_get_device_list (sw_device_id_list, &num_devices); +if (!rc && num_devices <=XLINK_MAX_DEVICE_LIST_SIZE ) { +/* TODO: this next copy is dangerous! we have no idea +* how large the devl.sw_device_id_list buffer is +* provided by the user. if num_devices is too large, +* the copy will overflow the buffer. +*/ +if (copy_to_user ((void __user *)devl.sw_device_id_list, + (void *)sw_device_id_list, + (sizeof (*sw_device_id_list) + * num_devices))) +return -EFAULT ; +if (copy_to_user ((void __user *)devl.num_devices, (void *)&num_devices, + (sizeof (num_devices)))) +return -EFAULT ; + } +if (copy_to_user ((void __user *)devl.return_code, (void *)&rc,sizeof (rc))) +return -EFAULT ; +break ; +case XL_GET_DEVICE_STATUS : +if (copy_from_user (&devs, (void __user *)arg, +sizeof (struct xlinkgetdevicestatus ))) +return -EFAULT ; +if (copy_from_user (&devh, (void __user *)devs.handle, +sizeof (struct xlink_handle ))) +return -EFAULT ; + rc =xlink_get_device_status (&devh, &device_status); +if (!rc) { +if (copy_to_user ((void __user *)devs.device_status, + (void *)&device_status, +sizeof (device_status))) +return -EFAULT ; + } +if (copy_to_user ((void __user *)devs.return_code, (void *)&rc,sizeof (rc))) +return -EFAULT ; +break ; +case XL_BOOT_DEVICE : +if (copy_from_user (&boot, (void __user *)arg, +sizeof (struct xlinkbootdevice ))) +return -EFAULT ; +if (copy_from_user (&devh, (void __user *)boot.handle, +sizeof (struct xlink_handle ))) +return -EFAULT ; +if (boot.binary_name_size >sizeof (filename)) +return -EINVAL ; +memset (filename,0 ,sizeof (filename)); +if (copy_from_user (filename, (void __user *)boot.binary_name, + boot.binary_name_size)) +return -EFAULT ; + rc =xlink_boot_device (&devh, filename); +if (copy_to_user ((void __user *)boot.return_code, (void *)&rc,sizeof (rc))) +return -EFAULT ; +break ; +case XL_RESET_DEVICE : +if (copy_from_user (&res, (void __user *)arg, +sizeof (struct xlinkresetdevice ))) +return -EFAULT ; +if (copy_from_user (&devh, (void __user *)res.handle, +sizeof (struct xlink_handle ))) +return -EFAULT ; + rc =xlink_reset_device (&devh); +if (copy_to_user ((void __user *)res.return_code, (void *)&rc,sizeof (rc))) +return -EFAULT ; +break ; +case XL_GET_DEVICE_MODE : +if (copy_from_user (&devm, (void __user *)arg, +sizeof (struct xlinkdevmode ))) +return -EFAULT ; +if (copy_from_user (&devh, (void __user *)devm.handle, +sizeof (struct xlink_handle ))) +return -EFAULT ; + rc =xlink_get_device_mode (&devh, &device_mode); +if (!rc) { +if (copy_to_user ((void __user *)devm.device_mode, (void *)&device_mode, +sizeof (device_mode))) +return -EFAULT ; + } +if (copy_to_user ((void __user *)devm.return_code, (void *)&rc,sizeof (rc))) +return -EFAULT ; +break ; +case XL_SET_DEVICE_MODE : +if (copy_from_user (&devm, (void __user *)arg, +sizeof (struct xlinkdevmode ))) +return -EFAULT ; +if (copy_from_user (&devh, (void __user *)devm.handle, +sizeof (struct xlink_handle ))) +return -EFAULT ; +if (copy_from_user (&device_mode, (void __user *)devm.device_mode, +sizeof (device_mode))) +return -EFAULT ; + rc =xlink_set_device_mode (&devh, device_mode); +if (copy_to_user ((void __user *)devm.return_code, (void *)&rc,sizeof (rc))) +return -EFAULT ; +break ; }if (rc)return -EIO ;
@@ -411,6 +608,30 @@ static long xlink_ioctl(struct file *file, unsigned int cmd, unsigned long arg)/* * xlink Kernel API. */ +enum xlink_error xlink_stop_vpu (void ) +{ +#ifdef CONFIG_XLINK_LOCAL_HOST +int rc; + + rc =xlink_ipc_reset_device (0x0 );// stop vpu slice 0 +if (rc) +return X_LINK_ERROR ; +#endif +return X_LINK_SUCCESS ; +} +EXPORT_SYMBOL (xlink_stop_vpu); +enum xlink_error xlink_start_vpu (char *filename) +{ +#ifdef CONFIG_XLINK_LOCAL_HOST +int rc; + + rc =xlink_ipc_boot_device (0x0 , filename);// start vpu slice 0 +if (rc) +return X_LINK_ERROR ; +#endif +return X_LINK_SUCCESS ; +} +EXPORT_SYMBOL (xlink_start_vpu);enum xlink_error xlink_initialize (void ) {
@@ -649,6 +870,33 @@ static enum xlink_error xlink_write_data_user(struct xlink_handle *handle,return rc; } +enum xlink_error xlink_write_control_data (struct xlink_handle *handle, +u16 chan,u8 const *pmessage, +u32 size) +{ +struct xlink_event *event; +struct xlink_link *link; +int event_queued =0 ; +enum xlink_error rc; + +if (!xlink || !handle) +return X_LINK_ERROR ; +if (size >XLINK_MAX_CONTROL_DATA_SIZE ) +return X_LINK_ERROR ;// TODO: XLink Parameter Error + link =get_link_by_sw_device_id (handle->sw_device_id); +if (!link) +return X_LINK_ERROR ; + event =xlink_create_event (link->id,XLINK_WRITE_CONTROL_REQ , + &link->handle, chan, size,0 ); +if (!event) +return X_LINK_ERROR ; +memcpy (event->header.control_data, pmessage, size); + rc =xlink_multiplexer_tx (event, &event_queued); +if (!event_queued) +xlink_destroy_event (event); +return rc; +} +EXPORT_SYMBOL (xlink_write_control_data);static enum xlink_error xlink_write_volatile_user (struct xlink_handle *handle,u16 chan,u8 const *message,u32 size)
@@ -844,6 +1092,154 @@ enum xlink_error xlink_disconnect(struct xlink_handle *handle) }EXPORT_SYMBOL (xlink_disconnect); +enum xlink_error xlink_get_device_list (u32 *sw_device_id_list, +u32 *num_devices) +{ +u32 interface_nmb_devices =0 ; +enum xlink_error rc; +int i; + +if (!xlink) +return X_LINK_ERROR ; +if (!sw_device_id_list || !num_devices) +return X_LINK_ERROR ; +/* loop through each interface and combine the lists */ +for (i =0 ; i <NMB_OF_INTERFACES ; i++) { + rc =xlink_platform_get_device_list (i, sw_device_id_list, + &interface_nmb_devices); +if (!rc) { + *num_devices += interface_nmb_devices; + sw_device_id_list += interface_nmb_devices; + } + interface_nmb_devices =0 ; + } +return X_LINK_SUCCESS ; +} +EXPORT_SYMBOL (xlink_get_device_list); +enum xlink_error xlink_get_device_name (struct xlink_handle *handle,char *name, +size_t name_size) +{ +enum xlink_error rc; +int interface; + +if (!xlink || !handle) +return X_LINK_ERROR ; +if (!name || !name_size) +return X_LINK_ERROR ; + interface =get_interface_from_sw_device_id (handle->sw_device_id); +if (interface ==NULL_INTERFACE ) +return X_LINK_ERROR ; + rc =xlink_platform_get_device_name (interface, handle->sw_device_id, + name, name_size); +if (rc) + rc =X_LINK_ERROR ; +else + rc =X_LINK_SUCCESS ; +return rc; +} +EXPORT_SYMBOL (xlink_get_device_name); +enum xlink_error xlink_get_device_status (struct xlink_handle *handle, +u32 *device_status) +{ +enum xlink_error rc; +u32 interface; + +if (!xlink) +return X_LINK_ERROR ; +if (!device_status) +return X_LINK_ERROR ; + interface =get_interface_from_sw_device_id (handle->sw_device_id); +if (interface ==NULL_INTERFACE ) +return X_LINK_ERROR ; + rc =xlink_platform_get_device_status (interface, handle->sw_device_id, + device_status); +if (rc) + rc =X_LINK_ERROR ; +else + rc =X_LINK_SUCCESS ; +return rc; +} +EXPORT_SYMBOL (xlink_get_device_status); +enum xlink_error xlink_boot_device (struct xlink_handle *handle, +const char *binary_name) +{ +enum xlink_error rc; +u32 interface; + +if (!xlink || !handle) +return X_LINK_ERROR ; +if (!binary_name) +return X_LINK_ERROR ; + interface =get_interface_from_sw_device_id (handle->sw_device_id); +if (interface ==NULL_INTERFACE ) +return X_LINK_ERROR ; + rc =xlink_platform_boot_device (interface, handle->sw_device_id, + binary_name); +if (rc) + rc =X_LINK_ERROR ; +else + rc =X_LINK_SUCCESS ; +return rc; +} +EXPORT_SYMBOL (xlink_boot_device); +enum xlink_error xlink_reset_device (struct xlink_handle *handle) +{ +enum xlink_error rc; +u32 interface; + +if (!xlink || !handle) +return X_LINK_ERROR ; + interface =get_interface_from_sw_device_id (handle->sw_device_id); +if (interface ==NULL_INTERFACE ) +return X_LINK_ERROR ; + rc =xlink_platform_reset_device (interface, handle->sw_device_id); +if (rc) + rc =X_LINK_ERROR ; +else + rc =X_LINK_SUCCESS ; +return rc; +} +EXPORT_SYMBOL (xlink_reset_device); +enum xlink_error xlink_set_device_mode (struct xlink_handle *handle, +enum xlink_device_power_mode power_mode) +{ +enum xlink_error rc; +u32 interface; + +if (!xlink || !handle) +return X_LINK_ERROR ; + interface =get_interface_from_sw_device_id (handle->sw_device_id); +if (interface ==NULL_INTERFACE ) +return X_LINK_ERROR ; + rc =xlink_platform_set_device_mode (interface, handle->sw_device_id, + power_mode); +if (rc) + rc =X_LINK_ERROR ; +else + rc =X_LINK_SUCCESS ; +return rc; +} +EXPORT_SYMBOL (xlink_set_device_mode); +enum xlink_error xlink_get_device_mode (struct xlink_handle *handle, +enum xlink_device_power_mode *power_mode) +{ +enum xlink_error rc; +u32 interface; + +if (!xlink || !handle) +return X_LINK_ERROR ; + interface =get_interface_from_sw_device_id (handle->sw_device_id); +if (interface ==NULL_INTERFACE ) +return X_LINK_ERROR ; + rc =xlink_platform_get_device_mode (interface, handle->sw_device_id, + power_mode); +if (rc) + rc =X_LINK_ERROR ; +else + rc =X_LINK_SUCCESS ; +return rc; +} +EXPORT_SYMBOL (xlink_get_device_mode);/* Device tree driver match. */ static const struct of_device_id kmb_xlink_of_match[] = { {
drivers/misc/xlink-core/xlink-defs.h +2 -0
@@ -101,6 +101,7 @@ enum xlink_event_type {XLINK_OPEN_CHANNEL_REQ ,XLINK_CLOSE_CHANNEL_REQ ,XLINK_PING_REQ , +XLINK_WRITE_CONTROL_REQ ,XLINK_REQ_LAST ,// response events XLINK_WRITE_RESP = 0x10,
@@ -111,6 +112,7 @@ enum xlink_event_type {XLINK_OPEN_CHANNEL_RESP ,XLINK_CLOSE_CHANNEL_RESP ,XLINK_PING_RESP , +XLINK_WRITE_CONTROL_RESP , XLINK_RESP_LAST, };
drivers/misc/xlink-core/xlink-multiplexer.c +56 -0
92 lines not on this page · raw message
drivers/misc/xlink-core/xlink-platform.c +86 -0
104 lines not on this page · raw message
include/linux/xlink.h +27 -0
@@ -78,6 +78,10 @@ enum xlink_error xlink_write_data(struct xlink_handle *handle,enum xlink_error xlink_write_volatile (struct xlink_handle *handle,u16 chan,u8 const *message,u32 size); +enum xlink_error xlink_write_control_data (struct xlink_handle *handle, +u16 chan,u8 const *message, +u32 size); +enum xlink_error xlink_read_data (struct xlink_handle *handle,u16 chan,u8 **message,u32 *size);
@@ -90,6 +94,29 @@ enum xlink_error xlink_release_data(struct xlink_handle *handle,enum xlink_error xlink_disconnect (struct xlink_handle *handle); +enum xlink_error xlink_get_device_list (u32 *sw_device_id_list,u32 *num_devices); + +enum xlink_error xlink_get_device_name (struct xlink_handle *handle,char *name, +size_t name_size); + +enum xlink_error xlink_get_device_status (struct xlink_handle *handle, +u32 *device_status); + +enum xlink_error xlink_boot_device (struct xlink_handle *handle, +const char *binary_name); + +enum xlink_error xlink_reset_device (struct xlink_handle *handle); + +enum xlink_error xlink_set_device_mode (struct xlink_handle *handle, +enum xlink_device_power_mode power_mode); + +enum xlink_error xlink_get_device_mode (struct xlink_handle *handle, +enum xlink_device_power_mode *power_mode); + +enum xlink_error xlink_start_vpu (char *filename);/* depreciated */ + +enum xlink_error xlink_stop_vpu (void );/* depreciated */ +/* API functions to be implemented * * enum xlink_error xlink_write_crc_data(struct xlink_handle *handle,
Signature · 1 line
2.17.1
PATCH 21/22 xlink-core: add async channel and events
In reply to [email protected]From: Seamus Kelly <[email protected]>
Enable asynchronous channel and event communication.
Add APIs:
data ready callback:
The xLink Data Ready Callback function is used to register a callback function that is invoked when data is ready to be read from a channel
data consumed callback:
The xLink Data Consumed Callback function is used to register a callback function that is invoked when data is consumed by the peer node on a channel
Add event notification handling including APIs:
register device event:
The xLink Register Device Event function is used to register a callback for notification of certain system events. Currently XLink supports 4 such events [0-3] whose meaning is system dependent. Registering for an event means that the callback will be called when the event occurs with 2 parameters the sw_device_id of the device that triggered the event and the event number [0-3]
unregister device event
The xLink Unregister Device Event function is used to unregister events that have previously been registered by register device event API
--- drivers/misc/xlink-core/xlink-core.c | 422 +++++++++++++++++++- drivers/misc/xlink-core/xlink-defs.h | 4 + drivers/misc/xlink-core/xlink-dispatcher.c | 53 ++- drivers/misc/xlink-core/xlink-multiplexer.c | 176 +++++--- drivers/misc/xlink-core/xlink-platform.c | 27 ++ include/linux/xlink.h | 15 +- 6 files changed, 609 insertions(+), 88 deletions(-)
drivers/misc/xlink-core/xlink-core.c +414 -8
@@ -62,6 +62,16 @@ static enum xlink_error xlink_write_volatile_user(struct xlink_handle *handle,static enum xlink_error do_xlink_write_volatile (struct xlink_handle *handle,u16 chan,u8 const *message,u32 size,u32 user_flag); +static enum xlink_error xlink_register_device_event_user (struct xlink_handle *handle, +u32 *event_list, +u32 num_events, +xlink_device_event_cb event_notif_fn); +static enum xlink_error do_xlink_register_device_event (struct xlink_handle *handle, +u32 *event_list, +u32 num_events, +xlink_device_event_cb event_notif_fn, +u32 user_flag); +static struct mutex dev_event_lock;static const struct file_operations fops = { .owner =THIS_MODULE ,
@@ -74,14 +84,81 @@ struct xlink_link {struct kref refcount; }; +struct xlink_attr { +unsigned long value; +u32 sw_dev_id; +}; +struct keembay_xlink_dev {struct platform_device *pdev;struct xlink_link links[XLINK_MAX_CONNECTIONS ];u32 nmb_connected_links;struct mutex lock;// protect access to xlink_dev +struct xlink_attr eventx[4 ]; +}; + +struct event_info { +struct list_head list; +u32 sw_device_id; +u32 event_type; +u32 user_flag; +xlink_device_event_cb event_notif_fn; };static u8 volbuf[XLINK_MAX_BUF_SIZE ];// buffer for volatile transactions +#define NUM_REG_EVENTS 4 + +// sysfs attribute functions + +static ssize_t event0_show (struct device *dev,struct device_attribute *attr,char *buf) +{ +struct keembay_xlink_dev *xlink_dev =dev_get_drvdata (dev); +struct xlink_attr *a = &xlink_dev->eventx[0 ]; + +return scnprintf (buf,PAGE_SIZE ,"0x%x 0x%lx\n" , a->sw_dev_id, a->value); +} + +static ssize_t event1_show (struct device *dev,struct device_attribute *attr,char *buf) +{ +struct keembay_xlink_dev *xlink_dev =dev_get_drvdata (dev); +struct xlink_attr *a = &xlink_dev->eventx[1 ]; + +return scnprintf (buf,PAGE_SIZE ,"0x%x 0x%lx\n" , a->sw_dev_id, a->value); +} + +static ssize_t event2_show (struct device *dev,struct device_attribute *attr,char *buf) +{ +struct keembay_xlink_dev *xlink_dev =dev_get_drvdata (dev); +struct xlink_attr *a = &xlink_dev->eventx[2 ]; + +return scnprintf (buf,PAGE_SIZE ,"0x%x 0x%lx\n" , a->sw_dev_id, a->value); +} + +static ssize_t event3_show (struct device *dev,struct device_attribute *attr,char *buf) +{ +struct keembay_xlink_dev *xlink_dev =dev_get_drvdata (dev); +struct xlink_attr *a = &xlink_dev->eventx[3 ]; + +return scnprintf (buf,PAGE_SIZE ,"0x%x 0x%lx\n" , a->sw_dev_id, a->value); +} + +static DEVICE_ATTR_RO (event0); +static DEVICE_ATTR_RO (event1); +static DEVICE_ATTR_RO (event2); +static DEVICE_ATTR_RO (event3); +static struct attribute *xlink_sysfs_entries[] = { + &dev_attr_event0.attr, + &dev_attr_event1.attr, + &dev_attr_event2.attr, + &dev_attr_event3.attr, +NULL , +}; + +static const struct attribute_group xlink_sysfs_group = { + .attrs = xlink_sysfs_entries, +}; + +static struct event_info ev_info;/* * global variable pointing to our xlink device.
@@ -215,7 +292,14 @@ static int kmb_xlink_probe(struct platform_device *pdev)dev_info (&pdev->dev,"Cannot add the device to the system\n" ); goto r_class; } +INIT_LIST_HEAD (&ev_info.list); + rc =devm_device_add_group (&pdev->dev, &xlink_sysfs_group); +if (rc) { +dev_err (&pdev->dev,"failed to create sysfs entries: %d\n" , rc); +return rc; + } +mutex_init (&dev_event_lock);return 0 ; r_device:
@@ -239,7 +323,6 @@ static int kmb_xlink_remove(struct platform_device *pdev) rc =xlink_multiplexer_destroy ();if (rc !=X_LINK_SUCCESS )pr_err ("Multiplexer destroy failed\n" ); -// stop dispatchers and destroy rc =xlink_dispatcher_destroy ();if (rc !=X_LINK_SUCCESS )pr_err ("Dispatcher destroy failed\n" );
@@ -270,19 +353,23 @@ static long xlink_ioctl(struct file *file, unsigned int cmd, unsigned long arg)struct xlinkconnect con = {0 };struct xlinkrelease rel = {0 };struct xlinkstartvpu startvpu = {0 }; +struct xlinkcallback cb = {0 };struct xlinkgetdevicename devn = {0 };struct xlinkgetdevicelist devl = {0 };struct xlinkgetdevicestatus devs = {0 };struct xlinkbootdevice boot = {0 };struct xlinkresetdevice res = {0 };struct xlinkdevmode devm = {0 }; +struct xlinkregdevevent regdevevent = {0 };u32 sw_device_id_list[XLINK_MAX_DEVICE_LIST_SIZE ];char name[XLINK_MAX_DEVICE_NAME_SIZE ];int interface =NULL_INTERFACE ;u32 device_status =0 ;u32 num_devices =0 ;u32 device_mode =0 ; +u32 num_events =0 ;char filename[64 ]; +u32 *ev_list;u8 reladdr;u8 *rdaddr;u32 size;
@@ -318,6 +405,30 @@ static long xlink_ioctl(struct file *file, unsigned int cmd, unsigned long arg)if (copy_to_user ((void __user *)op.return_code, (void *)&rc,sizeof (rc)))return -EFAULT ;break ; +case XL_DATA_READY_CALLBACK : +if (copy_from_user (&cb, (void __user *)arg, +sizeof (struct xlinkcallback ))) +return -EFAULT ; +if (copy_from_user (&devh, (void __user *)cb.handle, +sizeof (struct xlink_handle ))) +return -EFAULT ; +CHANNEL_SET_USER_BIT (cb.chan);// set MSbit for user space call + rc =xlink_data_available_event (&devh, cb.chan, cb.callback); +if (copy_to_user ((void __user *)cb.return_code, (void *)&rc,sizeof (rc))) +return -EFAULT ; +break ; +case XL_DATA_CONSUMED_CALLBACK : +if (copy_from_user (&cb, (void __user *)arg, +sizeof (struct xlinkcallback ))) +return -EFAULT ; +if (copy_from_user (&devh, (void __user *)cb.handle, +sizeof (struct xlink_handle ))) +return -EFAULT ; +CHANNEL_SET_USER_BIT (cb.chan);// set MSbit for user space call + rc =xlink_data_consumed_event (&devh, cb.chan, cb.callback); +if (copy_to_user ((void __user *)cb.return_code, (void *)&rc,sizeof (rc))) +return -EFAULT ; +break ;case XL_READ_DATA :if (copy_from_user (&rd, (void __user *)arg,sizeof (struct xlinkreaddata )))
@@ -598,6 +709,61 @@ static long xlink_ioctl(struct file *file, unsigned int cmd, unsigned long arg)if (copy_to_user ((void __user *)devm.return_code, (void *)&rc,sizeof (rc)))return -EFAULT ;break ; +case XL_REGISTER_DEV_EVENT : +if (copy_from_user (®devevent, (void __user *)arg, +sizeof (struct xlinkregdevevent ))) +return -EFAULT ; +if (copy_from_user (&devh, (void __user *)regdevevent.handle, +sizeof (struct xlink_handle ))) +return -EFAULT ; + num_events = regdevevent.num_events; +if (num_events >0 && num_events <=NUM_REG_EVENTS ) { + ev_list =kzalloc ((num_events *sizeof (u32)),GFP_KERNEL ); +if (ev_list) { +if (copy_from_user (ev_list, + (void __user *)regdevevent.event_list, + (num_events *sizeof (u32)))) { +kfree (ev_list); +return -EFAULT ; + } + rc =xlink_register_device_event_user (&devh, + ev_list, + num_events, +NULL ); +kfree (ev_list); + }else { + rc =X_LINK_ERROR ; + } + }else { + rc =X_LINK_ERROR ; + } +if (copy_to_user ((void __user *)regdevevent.return_code, (void *)&rc,sizeof (rc))) +return -EFAULT ; +break ; +case XL_UNREGISTER_DEV_EVENT : +if (copy_from_user (®devevent, (void __user *)arg, +sizeof (struct xlinkregdevevent ))) +return -EFAULT ; +if (copy_from_user (&devh, (void __user *)regdevevent.handle, +sizeof (struct xlink_handle ))) +return -EFAULT ; + num_events = regdevevent.num_events; +if (num_events <=NUM_REG_EVENTS ) { + ev_list =kzalloc ((num_events *sizeof (u32)),GFP_KERNEL ); +if (copy_from_user (ev_list, + (void __user *)regdevevent.event_list, + (num_events *sizeof (u32)))) { +kfree (ev_list); +return -EFAULT ; + } + rc =xlink_unregister_device_event (&devh, ev_list, num_events); +kfree (ev_list); + }else { + rc =X_LINK_ERROR ; + } +if (copy_to_user ((void __user *)regdevevent.return_code, (void *)&rc,sizeof (rc))) +return -EFAULT ; +break ; }if (rc)return -EIO ;
@@ -671,14 +837,12 @@ enum xlink_error xlink_connect(struct xlink_handle *handle) xlink->nmb_connected_links++;kref_init (&link->refcount);if (interface !=IPC_INTERFACE ) { -// start dispatcher rc =xlink_dispatcher_start (link->id, &link->handle);if (rc) {pr_err ("dispatcher start failed\n" ); goto r_cleanup; } } -// initialize multiplexer connection rc =xlink_multiplexer_connect (link->id);if (rc) {pr_err ("multiplexer connect failed\n" );
@@ -689,7 +853,6 @@ enum xlink_error xlink_connect(struct xlink_handle *handle) link->handle.dev_type, xlink->nmb_connected_links); }else { -// already connected pr_info ("dev 0x%x ALREADY connected - dev_type %d\n" , link->handle.sw_device_id, link->handle.dev_type);
@@ -697,7 +860,6 @@ enum xlink_error xlink_connect(struct xlink_handle *handle) *handle = link->handle; }mutex_unlock (&xlink->lock); -// TODO: implement ping return X_LINK_SUCCESS ; r_cleanup:
@@ -707,6 +869,78 @@ enum xlink_error xlink_connect(struct xlink_handle *handle) }EXPORT_SYMBOL (xlink_connect); +enum xlink_error xlink_data_available_event (struct xlink_handle *handle, +u16 chan, +xlink_event data_available_event) +{ +struct xlink_event *event; +struct xlink_link *link; +enum xlink_error rc; +int event_queued =0 ; +char origin ='K' ; + +if (!xlink || !handle) +return X_LINK_ERROR ; + +if (CHANNEL_USER_BIT_IS_SET (chan)) + origin ='U' ;// function called from user space +CHANNEL_CLEAR_USER_BIT (chan);// restore proper channel value + + link =get_link_by_sw_device_id (handle->sw_device_id); +if (!link) +return X_LINK_ERROR ; + event =xlink_create_event (link->id,XLINK_DATA_READY_CALLBACK_REQ , + &link->handle, chan,0 ,0 ); +if (!event) +return X_LINK_ERROR ; + event->data = data_available_event; + event->callback_origin = origin; +if (!data_available_event) + event->calling_pid =NULL ;// disable callbacks on this channel +else + event->calling_pid = current; + rc =xlink_multiplexer_tx (event, &event_queued); +if (!event_queued) +xlink_destroy_event (event); +return rc; +} +EXPORT_SYMBOL (xlink_data_available_event); +enum xlink_error xlink_data_consumed_event (struct xlink_handle *handle, +u16 chan, +xlink_event data_consumed_event) +{ +struct xlink_event *event; +struct xlink_link *link; +enum xlink_error rc; +int event_queued =0 ; +char origin ='K' ; + +if (!xlink || !handle) +return X_LINK_ERROR ; + +if (CHANNEL_USER_BIT_IS_SET (chan)) + origin ='U' ;// function called from user space +CHANNEL_CLEAR_USER_BIT (chan);// restore proper channel value + + link =get_link_by_sw_device_id (handle->sw_device_id); +if (!link) +return X_LINK_ERROR ; + event =xlink_create_event (link->id,XLINK_DATA_CONSUMED_CALLBACK_REQ , + &link->handle, chan,0 ,0 ); +if (!event) +return X_LINK_ERROR ; + event->data = data_consumed_event; + event->callback_origin = origin; +if (!data_consumed_event) + event->calling_pid =NULL ;// disable callbacks on this channel +else + event->calling_pid = current; + rc =xlink_multiplexer_tx (event, &event_queued); +if (!event_queued) +xlink_destroy_event (event); +return rc; +} +EXPORT_SYMBOL (xlink_data_consumed_event);enum xlink_error xlink_open_channel (struct xlink_handle *handle,u16 chan,enum xlink_opmode mode,u32 data_size,u32 timeout)
@@ -1051,8 +1285,8 @@ EXPORT_SYMBOL(xlink_release_data);enum xlink_error xlink_disconnect (struct xlink_handle *handle) {struct xlink_link *link; -int interface =NULL_INTERFACE ; -enum xlink_error rc =X_LINK_ERROR ; +int interface; +enum xlink_error rc =0 ;if (!xlink || !handle)return X_LINK_ERROR ;
@@ -1061,7 +1295,6 @@ enum xlink_error xlink_disconnect(struct xlink_handle *handle)if (!link)return X_LINK_ERROR ; -// decrement refcount, if count is 0 lock mutex and disconnect if (kref_put_mutex (&link->refcount, release_after_kref_put, &xlink->lock)) {// stop dispatcher
@@ -1240,6 +1473,179 @@ enum xlink_error xlink_get_device_mode(struct xlink_handle *handle,return rc; }EXPORT_SYMBOL (xlink_get_device_mode); + +static int xlink_device_event_handler (u32 sw_device_id,u32 event_type) +{ +struct event_info *events =NULL ; +xlink_device_event_cb event_cb; +bool found = false; +char event_attr[7 ]; + +mutex_lock (&dev_event_lock); +// find sw_device_id, event_type in list +list_for_each_entry (events, &ev_info.list, list) { +if (events) { +if (events->sw_device_id == sw_device_id && + events->event_type == event_type) { + event_cb = events->event_notif_fn; + found = true; +break ; + } + } + } +if (found) { +if (events->user_flag) { + xlink->eventx[events->event_type].value = events->event_type; + xlink->eventx[events->event_type].sw_dev_id = sw_device_id; +sprintf (event_attr,"event%d" , events->event_type); +sysfs_notify (&xlink->pdev->dev.kobj,NULL , event_attr); + }else { +if (event_cb) { +event_cb (sw_device_id, event_type); + }else { +pr_info ("No callback found for sw_device_id : 0x%x event type %d\n" , + sw_device_id, event_type); +mutex_unlock (&dev_event_lock); +return X_LINK_ERROR ; + } + } +pr_info ("sysfs_notify event %d swdev_id %xs\n" , + events->event_type, sw_device_id); + } +mutex_unlock (&dev_event_lock); +return X_LINK_SUCCESS ; +} + +static bool event_registered (u32 sw_dev_id,u32 event) +{ +struct event_info *events =NULL ; + +list_for_each_entry (events, &ev_info.list, list) { +if (events) { +if (events->sw_device_id == sw_dev_id && + events->event_type == event) { +return true; + } + } + } +return false; +} + +static enum xlink_error xlink_register_device_event_user (struct xlink_handle *handle, +u32 *event_list,u32 num_events, +xlink_device_event_cb event_notif_fn) +{ +enum xlink_error rc; + + rc =do_xlink_register_device_event (handle, event_list, num_events, + event_notif_fn,1 ); +return rc; +} + +enum xlink_error xlink_register_device_event (struct xlink_handle *handle, +u32 *event_list,u32 num_events, +xlink_device_event_cb event_notif_fn) +{ +enum xlink_error rc; + + rc =do_xlink_register_device_event (handle, event_list, num_events, + event_notif_fn,0 ); +return rc; +} +EXPORT_SYMBOL (xlink_register_device_event); + +static enum xlink_error do_xlink_register_device_event (struct xlink_handle *handle, +u32 *event_list, +u32 num_events, +xlink_device_event_cb event_notif_fn, +u32 user_flag) +{ +struct event_info *events; +u32 interface; +u32 event; +int i; + +if (num_events <0 || num_events >=NUM_REG_EVENTS ) +return X_LINK_ERROR ; +for (i =0 ; i < num_events; i++) { + events =kzalloc (sizeof (*events),GFP_KERNEL ); +if (!events) +return X_LINK_ERROR ; + event = *event_list; + events->sw_device_id = handle->sw_device_id; + events->event_notif_fn = event_notif_fn; + events->event_type = *event_list++; + events->user_flag = user_flag; +if (user_flag) { +/* only add to list once if userspace */ +/* xlink userspace handles multi process callbacks */ +if (event_registered (handle->sw_device_id, event)) { +pr_info ("xlink-core: Event 0x%x - %d already registered\n" , + handle->sw_device_id, event); +kfree (events); +continue ; + } + } +pr_info ("xlink-core:Events: sw_device_id 0x%x event %d fn %p user_flag %d\n" , + events->sw_device_id, events->event_type, + events->event_notif_fn, events->user_flag); +list_add_tail (&events->list, &ev_info.list); + } + interface =get_interface_from_sw_device_id (handle->sw_device_id); +if (interface ==NULL_INTERFACE ) +return X_LINK_ERROR ; +xlink_platform_register_for_events (interface, handle->sw_device_id, + xlink_device_event_handler); +return X_LINK_SUCCESS ; +} + +enum xlink_error xlink_unregister_device_event (struct xlink_handle *handle, +u32 *event_list, +u32 num_events) +{ +struct event_info *events =NULL ; +u32 interface; +int found =0 ; +int count =0 ; +int i; + +if (num_events <0 || num_events >=NUM_REG_EVENTS ) +return X_LINK_ERROR ; +for (i =0 ; i < num_events; i++) { +list_for_each_entry (events, &ev_info.list, list) { +if (events->sw_device_id == handle->sw_device_id && + events->event_type == event_list[i]) { + found =1 ; +break ; + } + } +if (!events || !found) +return X_LINK_ERROR ; +pr_info ("removing event %d for sw_device_id 0x%x\n" , + events->event_type, events->sw_device_id); +list_del (&events->list); +kfree (events); + } +// check if any events left for this sw_device_id +// are still registered ( in list ) +list_for_each_entry (events, &ev_info.list, list) { +if (events) { +if (events->sw_device_id == handle->sw_device_id) { + count++; +break ; + } + } + } +if (count ==0 ) { + interface =get_interface_from_sw_device_id (handle->sw_device_id); +if (interface ==NULL_INTERFACE ) +return X_LINK_ERROR ; +xlink_platform_unregister_for_events (interface, handle->sw_device_id); + } +return X_LINK_SUCCESS ; +} +EXPORT_SYMBOL (xlink_unregister_device_event); +/* Device tree driver match. */ static const struct of_device_id kmb_xlink_of_match[] = { {
drivers/misc/xlink-core/xlink-defs.h +4 -0
@@ -102,6 +102,8 @@ enum xlink_event_type {XLINK_CLOSE_CHANNEL_REQ ,XLINK_PING_REQ ,XLINK_WRITE_CONTROL_REQ , +XLINK_DATA_READY_CALLBACK_REQ , +XLINK_DATA_CONSUMED_CALLBACK_REQ ,XLINK_REQ_LAST ,// response events XLINK_WRITE_RESP = 0x10,
@@ -113,6 +115,8 @@ enum xlink_event_type {XLINK_CLOSE_CHANNEL_RESP ,XLINK_PING_RESP ,XLINK_WRITE_CONTROL_RESP , +XLINK_DATA_READY_CALLBACK_RESP , +XLINK_DATA_CONSUMED_CALLBACK_RESP , XLINK_RESP_LAST, };
drivers/misc/xlink-core/xlink-dispatcher.c +24 -29
148 lines not on this page · raw message
drivers/misc/xlink-core/xlink-multiplexer.c +127 -49
257 lines not on this page · raw message
drivers/misc/xlink-core/xlink-platform.c +27 -0
@@ -56,6 +56,11 @@ static inline int xlink_ipc_close_channel(u32 sw_device_id, u32 channel) {return -1 ; } +static inline int xlink_ipc_register_for_events (u32 sw_device_id, +int (*callback)(u32 sw_device_id,u32 event)) +{return -1 ; } +static inline int xlink_ipc_unregister_for_events (u32 sw_device_id) +{return -1 ; }#endif /* CONFIG_XLINK_LOCAL_HOST */ /*
@@ -95,6 +100,13 @@ static int (*open_chan_fcts[NMB_OF_INTERFACES])(u32, u32) = {static int (*close_chan_fcts[NMB_OF_INTERFACES ])(u32 ,u32 ) = { xlink_ipc_close_channel,NULL ,NULL ,NULL }; +static int (*register_for_events_fcts[NMB_OF_INTERFACES ])(u32 , +int (*callback)(u32 sw_device_id,u32 event)) = { + xlink_ipc_register_for_events, + xlink_pcie_register_device_event, +NULL ,NULL }; +static int (*unregister_for_events_fcts[NMB_OF_INTERFACES ])(u32 ) = { + xlink_ipc_unregister_for_events, xlink_pcie_unregister_device_event,NULL ,NULL };/* * xlink low-level driver interface
@@ -207,6 +219,21 @@ int xlink_platform_close_channel(u32 interface, u32 sw_device_id,return close_chan_fcts[interface](sw_device_id, channel); } +int xlink_platform_register_for_events (u32 interface,u32 sw_device_id, +xlink_device_event_cb event_notif_fn) +{ +if (interface >=NMB_OF_INTERFACES || !register_for_events_fcts[interface]) +return -1 ; +return register_for_events_fcts[interface](sw_device_id, event_notif_fn); +} + +int xlink_platform_unregister_for_events (u32 interface,u32 sw_device_id) +{ +if (interface >=NMB_OF_INTERFACES || !unregister_for_events_fcts[interface]) +return -1 ; +return unregister_for_events_fcts[interface](sw_device_id); +} +void *xlink_platform_allocate (struct device *dev,dma_addr_t *handle,u32 size,u32 alignment,enum xlink_memory_region region)
include/linux/xlink.h +13 -2
@@ -70,6 +70,12 @@ enum xlink_error xlink_open_channel(struct xlink_handle *handle, u16 chan, enum xlink_opmode mode, u32 data_size, u32 timeout); +enum xlink_error xlink_data_available_event (struct xlink_handle *handle, +u16 chan, +xlink_event data_available_event); +enum xlink_error xlink_data_consumed_event (struct xlink_handle *handle, +u16 chan, +xlink_event data_consumed_event);enum xlink_error xlink_close_channel (struct xlink_handle *handle,u16 chan); enum xlink_error xlink_write_data(struct xlink_handle *handle,
@@ -113,9 +119,14 @@ enum xlink_error xlink_set_device_mode(struct xlink_handle *handle,enum xlink_error xlink_get_device_mode (struct xlink_handle *handle,enum xlink_device_power_mode *power_mode); -enum xlink_error xlink_start_vpu (char *filename);/* depreciated */ +enum xlink_error xlink_register_device_event (struct xlink_handle *handle, +u32 *event_list,u32 num_events, +xlink_device_event_cb event_notif_fn); +enum xlink_error xlink_unregister_device_event (struct xlink_handle *handle, +u32 *event_list,u32 num_events); +enum xlink_error xlink_start_vpu (char *filename);/* deprecated */ -enum xlink_error xlink_stop_vpu (void );/* depreciated */ +enum xlink_error xlink_stop_vpu (void );/* deprecated */ /* API functions to be implemented *
Signature · 1 line
2.17.1
Re: [PATCH 21/22] xlink-core: add async channel and events
Quoted 1 line · On Tue, 2020-12-01 at 14:35 -0800, [email protected] wrote:
Enable asynchronous channel and event communication.
[]
drivers/misc/xlink-core/xlink-core.c
Quoted 1 line
drivers/misc/xlink-core/xlink-core.c +0
-0
[]
Quoted 24 lines
drivers/misc/xlink-core/xlink-core.c +24
-0+ +// sysfs attribute functions + +static ssize_t event0_show (struct device *dev,struct device_attribute *attr,char *buf) +{ +struct keembay_xlink_dev *xlink_dev =dev_get_drvdata (dev); +struct xlink_attr *a = &xlink_dev->eventx[0 ]; + +return scnprintf (buf,PAGE_SIZE ,"0x%x 0x%lx\n" , a->sw_dev_id, a->value); +} + +static ssize_t event1_show (struct device *dev,struct device_attribute *attr,char *buf) +{ +struct keembay_xlink_dev *xlink_dev =dev_get_drvdata (dev); +struct xlink_attr *a = &xlink_dev->eventx[1 ]; + +return scnprintf (buf,PAGE_SIZE ,"0x%x 0x%lx\n" , a->sw_dev_id, a->value); +} + +static ssize_t event2_show (struct device *dev,struct device_attribute *attr,char *buf) +{ +struct keembay_xlink_dev *xlink_dev =dev_get_drvdata (dev); +struct xlink_attr *a = &xlink_dev->eventx[2 ]; +
drivers/misc/xlink-core/xlink-core.c struct xlink_link { · line 143
Quoted 10 lines
drivers/misc/xlink-core/xlink-core.c +10
-0+return scnprintf (buf,PAGE_SIZE ,"0x%x 0x%lx\n" , a->sw_dev_id, a->value); +} + +static ssize_t event3_show (struct device *dev,struct device_attribute *attr,char *buf) +{ +struct keembay_xlink_dev *xlink_dev =dev_get_drvdata (dev); +struct xlink_attr *a = &xlink_dev->eventx[3 ]; + +return scnprintf (buf,PAGE_SIZE ,"0x%x 0x%lx\n" , a->sw_dev_id, a->value); +}
These could use the sysfs_emit function and not scnprintf and as well could use a single shared function with an index.
Something like:
static ssize_t eventx_show(struct device *dev, struct device_attr *attr, int index, char *buf)
{
struct keembay_xlink_dev *xlink_dev = dev_get_drvdata(dev);
struct xlink_attr *a = &xlink_dev->eventx[index];
return sysfs_emit(buf, "0x%x 0x%lx\n", a->sw_dev_id, a->value);
}static ssize_t event0_show(struct device *dev, struct device_attribute *attr, char *buf)
{
return eventx_show(dev, attr, 0, buf);
}etc...
drivers/misc/xlink-core/xlink-core.c static long xlink_ioctl(struct file *file, unsigned int cmd, unsigned long arg) · line 363
Quoted 12 lines
drivers/misc/xlink-core/xlink-core.c +2
-0@@ -270,19 +353,23 @@ static long xlink_ioctl(struct file *file, unsigned int cmd, unsigned long arg) struct xlinkconnect con = {0}; struct xlinkrelease rel = {0}; struct xlinkstartvpu startvpu = {0}; +struct xlinkcallback cb = {0 }; struct xlinkgetdevicename devn = {0}; struct xlinkgetdevicelist devl = {0}; struct xlinkgetdevicestatus devs = {0}; struct xlinkbootdevice boot = {0}; struct xlinkresetdevice res = {0}; struct xlinkdevmode devm = {0}; +struct xlinkregdevevent regdevevent = {0 };
Perhaps significantly less stack would be used if these declarations were moved into the case blocks where used. Less initialization would be done per ioctl too.
Quoted 6 lines
drivers/misc/xlink-core/xlink-core.c +2
-0@@ -318,6 +405,30 @@ static long xlink_ioctl(struct file *file, unsigned int cmd, unsigned long arg) if (copy_to_user((void __user *)op.return_code, (void *)&rc, sizeof(rc))) return -EFAULT; break; +case XL_DATA_READY_CALLBACK : + if (copy_from_user(&cb, (void __user *)arg,
drivers/misc/xlink-core/xlink-core.c static long xlink_ioctl(struct file *file, unsigned int cmd, unsigned long arg) · line 419
Quoted 10 lines
drivers/misc/xlink-core/xlink-core.c +10
-0+ sizeof(struct xlinkcallback))) +return -EFAULT ; +if (copy_from_user (&devh, (void __user *)cb.handle, +sizeof (struct xlink_handle ))) +return -EFAULT ; +CHANNEL_SET_USER_BIT (cb.chan);// set MSbit for user space call + rc =xlink_data_available_event (&devh, cb.chan, cb.callback); +if (copy_to_user ((void __user *)cb.return_code, (void *)&rc,sizeof (rc))) +return -EFAULT ; +break ;
case XL_DATA_READY_CALLBACK: {
struct xlinkcallback cb = {};
etc...
break;
}RE: [PATCH 21/22] xlink-core: add async channel and events
-----Original Message-----
From: Joe Perches <[email protected]>
Sent: Monday, December 7, 2020 2:55 AM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; Kelly, Seamus <[email protected]>
Subject: Re: [PATCH 21/22] xlink-core: add async channel and events
Quoted 1 line · On Tue, 2020-12-01 at 14:35 -0800, [email protected] wrote:
Enable asynchronous channel and event communication.
[]
drivers/misc/xlink-core/xlink-core.c
Quoted 2 lines
drivers/misc/xlink-core/xlink-core.c +0
-0
[]
Quoted 24 lines
drivers/misc/xlink-core/xlink-core.c +24
-0+ +// sysfs attribute functions + +static ssize_t event0_show (struct device *dev,struct +device_attribute *attr,char *buf) { +struct keembay_xlink_dev *xlink_dev =dev_get_drvdata (dev); +struct xlink_attr *a = &xlink_dev->eventx[0 ]; + +return scnprintf (buf,PAGE_SIZE ,"0x%x 0x%lx\n" , a->sw_dev_id, +a->value); } + +static ssize_t event1_show (struct device *dev,struct +device_attribute *attr,char *buf) { +struct keembay_xlink_dev *xlink_dev =dev_get_drvdata (dev); +struct xlink_attr *a = &xlink_dev->eventx[1 ]; + +return scnprintf (buf,PAGE_SIZE ,"0x%x 0x%lx\n" , a->sw_dev_id, +a->value); } + +static ssize_t event2_show (struct device *dev,struct +device_attribute *attr,char *buf) { +struct keembay_xlink_dev *xlink_dev =dev_get_drvdata (dev); +struct xlink_attr *a = &xlink_dev->eventx[2 ]; +
drivers/misc/xlink-core/xlink-core.c struct xlink_link {
Quoted 10 lines
drivers/misc/xlink-core/xlink-core.c +10
-0+return scnprintf (buf,PAGE_SIZE ,"0x%x 0x%lx\n" , a->sw_dev_id, +a->value); } + +static ssize_t event3_show (struct device *dev,struct +device_attribute *attr,char *buf) { +struct keembay_xlink_dev *xlink_dev =dev_get_drvdata (dev); +struct xlink_attr *a = &xlink_dev->eventx[3 ]; + +return scnprintf (buf,PAGE_SIZE ,"0x%x 0x%lx\n" , a->sw_dev_id, +a->value); }
These could use the sysfs_emit function and not scnprintf and as well could use a single shared function with an index.
Something like:
static ssize_t eventx_show(struct device *dev, struct device_attr *attr, int index, char *buf) {
struct keembay_xlink_dev *xlink_dev = dev_get_drvdata(dev);
struct xlink_attr *a = &xlink_dev->eventx[index];
return sysfs_emit(buf, "0x%x 0x%lx\n", a->sw_dev_id, a->value); }static ssize_t event0_show(struct device *dev, struct device_attribute *attr, char *buf) {
return eventx_show(dev, attr, 0, buf);
}etc...
[Kelly, Seamus] Thank you! will do.
drivers/misc/xlink-core/xlink-core.c static long xlink_ioctl(struct file *file, unsigned int cmd, unsigned long arg) · line 363
Quoted 12 lines
drivers/misc/xlink-core/xlink-core.c +2
-0@@ -270,19 +353,23 @@ static long xlink_ioctl(struct file *file, unsigned int cmd, unsigned long arg) struct xlinkconnect con = {0}; struct xlinkrelease rel = {0}; struct xlinkstartvpu startvpu = {0}; +struct xlinkcallback cb = {0 }; struct xlinkgetdevicename devn = {0}; struct xlinkgetdevicelist devl = {0}; struct xlinkgetdevicestatus devs = {0}; struct xlinkbootdevice boot = {0}; struct xlinkresetdevice res = {0}; struct xlinkdevmode devm = {0}; +struct xlinkregdevevent regdevevent = {0 };
Perhaps significantly less stack would be used if these declarations were moved into the case blocks where used. Less initialization would be done per ioctl too.
[Kelly, Seamus] This has changed significantly In next patch and I take your comments ( on next patch also ) Thanks
Quoted 6 lines
drivers/misc/xlink-core/xlink-core.c +2
-0@@ -318,6 +405,30 @@ static long xlink_ioctl(struct file *file, unsigned int cmd, unsigned long arg) if (copy_to_user((void __user *)op.return_code, (void *)&rc, sizeof(rc))) return -EFAULT; break; +case XL_DATA_READY_CALLBACK : + if (copy_from_user(&cb, (void __user *)arg,
drivers/misc/xlink-core/xlink-core.c static long xlink_ioctl(struct file *file, unsigned int cmd, unsigned long arg) · line 419
Quoted 10 lines
drivers/misc/xlink-core/xlink-core.c +10
-0+ sizeof(struct xlinkcallback))) +return -EFAULT ; +if (copy_from_user (&devh, (void __user *)cb.handle, +sizeof (struct xlink_handle ))) +return -EFAULT ; +CHANNEL_SET_USER_BIT (cb.chan);// set MSbit for user space call + rc =xlink_data_available_event (&devh, cb.chan, cb.callback); +if (copy_to_user ((void __user *)cb.return_code, (void *)&rc,sizeof (rc))) +return -EFAULT ; +break ;
case XL_DATA_READY_CALLBACK: {
struct xlinkcallback cb = {};
etc...
break;
}--------------------------------------------------------------
Intel Research and Development Ireland Limited
Registered in Ireland
Registered Office: Collinstown Industrial Park, Leixlip, County Kildare Registered Number: 308263
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
PATCH 22/22 xlink-core: factorize xlink_ioctl function by creating sub-functions for each ioctl command
In reply to [email protected]From: Seamus Kelly <[email protected]>
Refactor the too large IOCTL function to call helper functions.
--- drivers/misc/xlink-core/Makefile | 2 +- drivers/misc/xlink-core/xlink-core.c | 625 ++++++-------------------- drivers/misc/xlink-core/xlink-core.h | 24 + drivers/misc/xlink-core/xlink-defs.h | 2 +- drivers/misc/xlink-core/xlink-ioctl.c | 584 ++++++++++++++++++++++++ drivers/misc/xlink-core/xlink-ioctl.h | 36 ++ 6 files changed, 773 insertions(+), 500 deletions(-) create mode 100644 drivers/misc/xlink-core/xlink-core.h create mode 100644 drivers/misc/xlink-core/xlink-ioctl.c create mode 100644 drivers/misc/xlink-core/xlink-ioctl.h
drivers/misc/xlink-core/Makefile +1 -1
@@ -2,4 +2,4 @@ # Makefile for KeemBay xlink Linux driver # obj-$(CONFIG_XLINK_CORE) += xlink.o -xlink-objs += xlink-core.o xlink-multiplexer.o xlink-dispatcher.o xlink-platform.o +xlink-objs += xlink-core.o xlink-multiplexer.o xlink-dispatcher.o xlink-platform.o xlink-ioctl.o
drivers/misc/xlink-core/xlink-core.c +127 -498
764 lines not on this page · raw message
drivers/misc/xlink-core/xlink-core.h new file +24 -0
@@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* xlink core header file. +* +* Copyright (C) 2018-2019 Intel Corporation +* +*/ + +#ifndef XLINK_CORE_H_ +#define XLINK_CORE_H_ +#include "xlink-defs.h" + +#define NUM_REG_EVENTS 4 + +enum xlink_error xlink_write_data_user (struct xlink_handle *handle, +u16 chan,u8 const *pmessage, +u32 size); +enum xlink_error xlink_register_device_event_user (struct xlink_handle *handle, +u32 *event_list,u32 num_events, +xlink_device_event_cb event_notif_fn); +enum xlink_error xlink_write_volatile_user (struct xlink_handle *handle, +u16 chan,u8 const *message, +u32 size); +#endif /* XLINK_CORE_H_ */
drivers/misc/xlink-core/xlink-defs.h +1 -1
@@ -35,7 +35,7 @@#define CONTROL_CHANNEL_TIMEOUT_MS 0U // wait indefinitely#define SIGXLNK 44 // signal XLink uses for callback signalling -#define UNUSED (x) (void)(x) +#define UNUSED (x) ((void)(x))// the end of the IPC channel range (starting at zero) #define XLINK_IPC_MAX_CHANNELS 1024
drivers/misc/xlink-core/xlink-ioctl.c new file +584 -0
584 lines not on this page · raw message
drivers/misc/xlink-core/xlink-ioctl.h new file +36 -0
@@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* xlink ioctl header files. +* +* Copyright (C) 2018-2019 Intel Corporation +* +*/ + +#ifndef XLINK_IOCTL_H_ +#define XLINK_IOCTL_H_ + +int ioctl_connect (unsigned long arg); +int ioctl_open_channel (unsigned long arg); +int ioctl_read_data (unsigned long arg); +int ioctl_read_to_buffer (unsigned long arg); +int ioctl_write_data (unsigned long arg); +int ioctl_write_control_data (unsigned long arg); +int ioctl_write_volatile_data (unsigned long arg); +int ioctl_release_data (unsigned long arg); +int ioctl_close_channel (unsigned long arg); +int ioctl_start_vpu (unsigned long arg); +int ioctl_stop_vpu (void ); +int ioctl_disconnect (unsigned long arg); +int ioctl_get_device_name (unsigned long arg); +int ioctl_get_device_list (unsigned long arg); +int ioctl_get_device_status (unsigned long arg); +int ioctl_boot_device (unsigned long arg); +int ioctl_reset_device (unsigned long arg); +int ioctl_get_device_mode (unsigned long arg); +int ioctl_set_device_mode (unsigned long arg); +int ioctl_register_device_event (unsigned long arg); +int ioctl_unregister_device_event (unsigned long arg); +int ioctl_data_ready_callback (unsigned long arg); +int ioctl_data_consumed_callback (unsigned long arg); + +#endif /* XLINK_IOCTL_H_ */
Signature · 1 line
2.17.1
Re: [PATCH 22/22] xlink-core: factorize xlink_ioctl function by creating sub-functions for each ioctl command
Quoted 3 lines · On Tue, 2020-12-01 at 14:35 -0800, [email protected] wrote:
From: Seamus Kelly <[email protected]>
Refactor the too large IOCTL function to call helper functions.
This should not be sent as a known poor patch as patch 21 of 22 and then updated in patch 22 of 22 with a better style.
This should be sent in the as desired final form the first time so that people don't give you useless notes.
Quoted 58 lines
drivers/misc/xlink-core/xlink-core.c +1
-0@@ -342,427 +323,84 @@ static int kmb_xlink_remove(struct platform_device *pdev)* IOCTL function for User Space access to xlink kernel functions * */ +int ioctl_connect (unsigned long arg);static long
xlink_ioctl(struct file *file, unsigned int cmd, unsigned long arg){drivers/misc/xlink-core/xlink-core.c +0
-28-struct xlink_handle devh = {0 }; -struct xlinkopenchannel op = {0 }; -struct xlinkwritedata wr = {0 }; -struct xlinkreaddata rd = {0 }; -struct xlinkreadtobuffer rdtobuf = {0 }; -struct xlinkconnect con = {0 }; -struct xlinkrelease rel = {0 }; -struct xlinkstartvpu startvpu = {0 }; -struct xlinkcallback cb = {0 }; -struct xlinkgetdevicename devn = {0 }; -struct xlinkgetdevicelist devl = {0 }; -struct xlinkgetdevicestatus devs = {0 }; -struct xlinkbootdevice boot = {0 }; -struct xlinkresetdevice res = {0 }; -struct xlinkdevmode devm = {0 }; -struct xlinkregdevevent regdevevent = {0 }; -u32 sw_device_id_list[XLINK_MAX_DEVICE_LIST_SIZE ]; -char name[XLINK_MAX_DEVICE_NAME_SIZE ]; -int interface =NULL_INTERFACE ; -u32 device_status =0 ; -u32 num_devices =0 ; -u32 device_mode =0 ; -u32 num_events =0 ; -char filename[64 ]; -u32 *ev_list; -u8 reladdr; -u8 *rdaddr; -u32 size;int rc;
switch (cmd) {
caseXL_CONNECT:drivers/misc/xlink-core/xlink-core.c +1
-15-if (copy_from_user (&con, (void __user *)arg, -sizeof (struct xlinkconnect ))) -return -EFAULT ; -if (copy_from_user (&devh, (void __user *)con.handle, -sizeof (struct xlink_handle ))) -return -EFAULT ; - rc =xlink_connect (&devh); -if (rc ==X_LINK_SUCCESS ) { -if (copy_to_user ((void __user *)con.handle, - &devh,sizeof (struct xlink_handle ))) -return -EFAULT ; - } -if (copy_to_user ((void __user *)con.return_code, (void *)&rc, -sizeof (rc))) -return -EFAULT ; + rc =ioctl_connect (arg);
Quoted 1 line
break;
etc...
Re: [PATCH 22/22] xlink-core: factorize xlink_ioctl function by creating sub-functions for each ioctl command
Quoted 10 lines · Joe Perches
Quoted 3 lines · On Tue, 2020-12-01 at 14:35 -0800, [email protected] wrote:
From: Seamus Kelly <[email protected]>
Refactor the too large IOCTL function to call helper functions.
This should not be sent as a known poor patch as patch 21 of 22 and then updated in patch 22 of 22 with a better style.
This should be sent in the as desired final form the first time so that people don't give you useless notes.
We will re-work the changes to better integrate this one in the earlier changes.
--mark
Quoted 63 lines
Quoted 59 lines
drivers/misc/xlink-core/xlink-core.c +1
-0@@ -342,427 +323,84 @@ static int kmb_xlink_remove(struct platform_device *pdev)* IOCTL function for User Space access to xlink kernel functions * */ +int ioctl_connect (unsigned long arg);static long
xlink_ioctl(struct file *file, unsigned int cmd, unsigned long arg){drivers/misc/xlink-core/xlink-core.c +0
-28-struct xlink_handle devh = {0 }; -struct xlinkopenchannel op = {0 }; -struct xlinkwritedata wr = {0 }; -struct xlinkreaddata rd = {0 }; -struct xlinkreadtobuffer rdtobuf = {0 }; -struct xlinkconnect con = {0 }; -struct xlinkrelease rel = {0 }; -struct xlinkstartvpu startvpu = {0 }; -struct xlinkcallback cb = {0 }; -struct xlinkgetdevicename devn = {0 }; -struct xlinkgetdevicelist devl = {0 }; -struct xlinkgetdevicestatus devs = {0 }; -struct xlinkbootdevice boot = {0 }; -struct xlinkresetdevice res = {0 }; -struct xlinkdevmode devm = {0 }; -struct xlinkregdevevent regdevevent = {0 }; -u32 sw_device_id_list[XLINK_MAX_DEVICE_LIST_SIZE ]; -char name[XLINK_MAX_DEVICE_NAME_SIZE ]; -int interface =NULL_INTERFACE ; -u32 device_status =0 ; -u32 num_devices =0 ; -u32 device_mode =0 ; -u32 num_events =0 ; -char filename[64 ]; -u32 *ev_list; -u8 reladdr; -u8 *rdaddr; -u32 size;int rc;
switch (cmd) {
caseXL_CONNECT:drivers/misc/xlink-core/xlink-core.c +1
-15-if (copy_from_user (&con, (void __user *)arg, -sizeof (struct xlinkconnect ))) -return -EFAULT ; -if (copy_from_user (&devh, (void __user *)con.handle, -sizeof (struct xlink_handle ))) -return -EFAULT ; - rc =xlink_connect (&devh); -if (rc ==X_LINK_SUCCESS ) { -if (copy_to_user ((void __user *)con.handle, - &devh,sizeof (struct xlink_handle ))) -return -EFAULT ; - } -if (copy_to_user ((void __user *)con.return_code, (void *)&rc, -sizeof (rc))) -return -EFAULT ; + rc =ioctl_connect (arg);Quoted 1 line
break;
etc...
Re: [PATCH 22/22] xlink-core: factorize xlink_ioctl function by creating sub-functions for each ioctl command
In reply to [email protected]Quoted 1 line · On Tue, 2020-12-01 at 14:35 -0800, [email protected] wrote:
Refactor the too large IOCTL function to call helper functions.
[]
drivers/misc/xlink-core/xlink-ioctl.c
Quoted 1 line
drivers/misc/xlink-core/xlink-ioctl.c +0
-0
[]
Quoted 11 lines
drivers/misc/xlink-core/xlink-ioctl.c +11
-0+int ioctl_write_data (unsigned long arg) +{ +struct xlink_handle devh = {0 }; +struct xlinkwritedata wr = {0 }; +int rc =0 ; + +if (copy_from_user (&wr, (void __user *)arg, +sizeof (struct xlinkwritedata ))) +return -EFAULT ; +if (copy_from_user (&devh, (void __user *)wr.handle, +sizeof (struct xlink_handle )))
drivers/misc/xlink-core/xlink-ioctl.c line 151
Quoted 10 lines
drivers/misc/xlink-core/xlink-ioctl.c +10
-0+return -EFAULT ; +if (wr.size <=XLINK_MAX_DATA_SIZE ) { + rc =xlink_write_data_user (&devh, wr.chan, wr.pmessage, + wr.size); +if (copy_to_user ((void __user *)wr.return_code, (void *)&rc, +sizeof (rc))) +return -EFAULT ; + }else { +return -EFAULT ; + }
Please reverse the test to reduce indentation
if (wr.size > XLINK_MAX_DATA_SIZE) return -EFAULT; rc = xlink_write_data_user(&devh, wr.chan, wr.pmessage, wr.size); if (copy_to_user((void __user *)wr.return_code, (void *)&rc, sizeof(rc))) return -EFAULT; return rc;
The last 3 lines here are repeated multiple times in many functions. It might be sensible to add something like:
int copy_result_to_user(u32 *where, int rc)
{
if (copy_to_user((void __user *)where, &rc, sizeof(rc)))
return -EFAULT;
return rc;
}so this could be written
rc = xlink_write_data_user(&devh, wr.chan, wr.pmessage, wr.size); return copy_result_to_user(wr.return_code, rc);
IMO: return_code isn't a great name for a pointer as it rather indicates a value not an address and there's an awful lot of casting to __user in all this code that perhaps should be marked in the struct definitions rather than inside the function uses.
drivers/misc/xlink-core/xlink-ioctl.c line 157
Quoted 5 lines
drivers/misc/xlink-core/xlink-ioctl.c +5
-0+} + +int ioctl_write_control_data (unsigned long arg) +{ +struct xlink_handle devh = {0 };
All of these initializations with {0} should use {} instead as the first element of whatever struct is not guaranteed to be assignable as an int and gcc/clang guarantee 0 initialization
Quoted 11 lines
drivers/misc/xlink-core/xlink-ioctl.c +11
-0+struct xlinkwritedata wr = {0 }; +u8 volbuf[XLINK_MAX_BUF_SIZE ]; +int rc =0 ; + +if (copy_from_user (&wr, (void __user *)arg, +sizeof (struct xlinkwritedata ))) +return -EFAULT ; +if (copy_from_user (&devh, (void __user *)wr.handle, +sizeof (struct xlink_handle ))) +return -EFAULT ; +if (wr.size <=XLINK_MAX_CONTROL_DATA_SIZE ) {
drivers/misc/xlink-core/xlink-ioctl.c line 178
Quoted 10 lines
drivers/misc/xlink-core/xlink-ioctl.c +10
-0+if (copy_from_user (volbuf, (void __user *)wr.pmessage, + wr.size)) +return -EFAULT ; + rc =xlink_write_control_data (&devh, wr.chan, volbuf, + wr.size); +if (copy_to_user ((void __user *)wr.return_code, + (void *)&rc,sizeof (rc))) +return -EFAULT ; + }else { +return -EFAULT ;
Same test reversal and deindentation please.
Quoted 4 lines
drivers/misc/xlink-core/xlink-ioctl.c +4
-0+ } +return rc; +} +
RE: [PATCH 22/22] xlink-core: factorize xlink_ioctl function by creating sub-functions for each ioctl command
-----Original Message-----
From: Joe Perches <[email protected]>
Sent: Wednesday, December 9, 2020 8:31 AM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; Kelly, Seamus <[email protected]>
Subject: Re: [PATCH 22/22] xlink-core: factorize xlink_ioctl function by creating sub-functions for each ioctl command
Quoted 1 line · On Tue, 2020-12-01 at 14:35 -0800, [email protected] wrote:
Refactor the too large IOCTL function to call helper functions.
[]
drivers/misc/xlink-core/xlink-ioctl.c
Quoted 2 lines
drivers/misc/xlink-core/xlink-ioctl.c +0
-0
[]
Quoted 10 lines
drivers/misc/xlink-core/xlink-ioctl.c +10
-0+int ioctl_write_data (unsigned long arg) { +struct xlink_handle devh = {0 }; +struct xlinkwritedata wr = {0 }; +int rc =0 ; + +if (copy_from_user (&wr, (void __user *)arg, +sizeof (struct xlinkwritedata ))) +return -EFAULT ; +if (copy_from_user (&devh, (void __user *)wr.handle, +sizeof (struct xlink_handle )))
drivers/misc/xlink-core/xlink-ioctl.c line 151
Quoted 10 lines
drivers/misc/xlink-core/xlink-ioctl.c +10
-0+return -EFAULT ; +if (wr.size <=XLINK_MAX_DATA_SIZE ) { + rc =xlink_write_data_user (&devh, wr.chan, wr.pmessage, + wr.size); +if (copy_to_user ((void __user *)wr.return_code, (void *)&rc, +sizeof (rc))) +return -EFAULT ; + }else { +return -EFAULT ; + }
Please reverse the test to reduce indentation
[Kelly, Seamus] Thank you! will do.
if (wr.size > XLINK_MAX_DATA_SIZE) return -EFAULT; rc = xlink_write_data_user(&devh, wr.chan, wr.pmessage, wr.size); if (copy_to_user((void __user *)wr.return_code, (void *)&rc, sizeof(rc))) return -EFAULT; return rc;
The last 3 lines here are repeated multiple times in many functions. It might be sensible to add something like:
int copy_result_to_user(u32 *where, int rc) {
if (copy_to_user((void __user *)where, &rc, sizeof(rc)))
return -EFAULT;
return rc;
}so this could be written
rc = xlink_write_data_user(&devh, wr.chan, wr.pmessage, wr.size); return copy_result_to_user(wr.return_code, rc);
[Kelly, Seamus] Thank you! will do.
IMO: return_code isn't a great name for a pointer as it rather indicates a value not an address and there's an awful lot of casting to __user in all this code that perhaps should be marked in the struct definitions rather than inside the function uses.
[Kelly, Seamus] Thank you! will do.
drivers/misc/xlink-core/xlink-ioctl.c line 50
Quoted 4 lines
drivers/misc/xlink-core/xlink-ioctl.c +4
-0+} + +int ioctl_write_control_data (unsigned long arg) { +struct xlink_handle devh = {0 };
All of these initializations with {0} should use {} instead as the first element of whatever struct is not guaranteed to be assignable as an int and gcc/clang guarantee 0 initialization [Kelly, Seamus] Thank you! will do.
Quoted 11 lines
drivers/misc/xlink-core/xlink-ioctl.c +11
-0+struct xlinkwritedata wr = {0 }; +u8 volbuf[XLINK_MAX_BUF_SIZE ]; +int rc =0 ; + +if (copy_from_user (&wr, (void __user *)arg, +sizeof (struct xlinkwritedata ))) +return -EFAULT ; +if (copy_from_user (&devh, (void __user *)wr.handle, +sizeof (struct xlink_handle ))) +return -EFAULT ; +if (wr.size <=XLINK_MAX_CONTROL_DATA_SIZE ) {
drivers/misc/xlink-core/xlink-ioctl.c line 178
Quoted 10 lines
drivers/misc/xlink-core/xlink-ioctl.c +10
-0+if (copy_from_user (volbuf, (void __user *)wr.pmessage, + wr.size)) +return -EFAULT ; + rc =xlink_write_control_data (&devh, wr.chan, volbuf, + wr.size); +if (copy_to_user ((void __user *)wr.return_code, + (void *)&rc,sizeof (rc))) +return -EFAULT ; + }else { +return -EFAULT ;
Same test reversal and deindentation please.
[Kelly, Seamus] Thank you! will do.
drivers/misc/xlink-core/xlink-ioctl.c
Quoted 4 lines
drivers/misc/xlink-core/xlink-ioctl.c +4
-0+ } +return rc; +} +
--------------------------------------------------------------
Intel Research and Development Ireland Limited
Registered in Ireland
Registered Office: Collinstown Industrial Park, Leixlip, County Kildare Registered Number: 308263
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.