Intel Vision Processing base enabling
Subsystems (6)
PATCH v3 27/34 misc: Tsens ARM host thermal driver.
In reply to [email protected]From: "C, Udhayakumar" <[email protected]>
Add tsens ARM host thermal driver for Intel Edge.AI Computer Vision platforms.
About Intel Edge.AI Computer Vision platforms:
---------------------------------------------
The Intel Edge.AI Computer Vision platforms are vision processing systems targeting machine vision applications for connected devices.
They are based on ARM A53 CPU running Linux and acts as a PCIe endpoint device.
High-level architecture:
------------------------
Remote Host IA CPU Local Host ARM CPU
---------------- -------------------------- | Platform | | Thermal Daemon | | Management SW| | | ---------------- -------------------------- | Intel tsens | | intel tsens i2c slave | | i2c client | | and thermal driver | ---------------- -------------------------- | XLINK I2C | | XLINK I2C Slave | | controller | <=========> | controller | ---------------- smbus --------------------------
intel tsens module:
-------------------
The tsens module enables reading of on chip sensors present in the Intel Edge.AI Computer Vision platforms. In the tsens module various junction and SoC temperatures are reported using thermal subsystem and i2c subsystem.
Temperature data reported using thermal subsystem will be used for various cooling agents such as DVFS, fan control and shutdown the system in case of critical temperature.
Temperature data reported using i2c subsystem will be used by platform manageability software running in IA host.
- Local Host driver
* Intended for ARM CPU
* It is based on Thermal and I2C slave Framework
* Driver path:
{tree}/drivers/misc/intel_tsens/intel_tsens_thermal.c
Local host and Remote host drivers communicates using XLINK I2C SMBUS protocol.
--- Documentation/hwmon/index.rst | 1 + Documentation/hwmon/intel_tsens_sensor.rst | 67 ++ MAINTAINERS | 5 + drivers/misc/Kconfig | 1 + drivers/misc/Makefile | 1 + drivers/misc/intel_tsens/Kconfig | 15 + drivers/misc/intel_tsens/Makefile | 7 + .../misc/intel_tsens/intel_tsens_thermal.c | 651 ++++++++++++++++++ .../misc/intel_tsens/intel_tsens_thermal.h | 38 + include/linux/hddl_device.h | 153 ++++ 10 files changed, 939 insertions(+) create mode 100644 Documentation/hwmon/intel_tsens_sensor.rst create mode 100644 drivers/misc/intel_tsens/Kconfig create mode 100644 drivers/misc/intel_tsens/Makefile create mode 100644 drivers/misc/intel_tsens/intel_tsens_thermal.c create mode 100644 drivers/misc/intel_tsens/intel_tsens_thermal.h create mode 100644 include/linux/hddl_device.h
Documentation/hwmon/index.rst +1 -0
@@ -80,6 +80,7 @@ Hardware Monitoring Kernel Drivers ir38064 isl68137 it87 + intel_tsens_sensor.rst jc42 k10temp k8temp
Documentation/hwmon/intel_tsens_sensor.rst new file +67 -0
67 lines not on this page · raw message
MAINTAINERS +5 -0
@@ -1985,6 +1985,11 @@ S: Supported F: drivers/misc/hddl_device/ F: drivers/misc/intel_tsens/ +ARM/INTEL TSENS SUPPORT +M: Udhayakumar C <[email protected]> +S: Supported +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
@@ -485,4 +485,5 @@ source "drivers/misc/xlink-pcie/Kconfig" source "drivers/misc/xlink-ipc/Kconfig" source "drivers/misc/xlink-core/Kconfig" source "drivers/misc/vpumgr/Kconfig" +source "drivers/misc/intel_tsens/Kconfig" endmenu
drivers/misc/Makefile +1 -0
@@ -61,3 +61,4 @@ obj-y += xlink-pcie/ obj-$(CONFIG_XLINK_IPC) += xlink-ipc/ obj-$(CONFIG_XLINK_CORE) += xlink-core/ obj-$(CONFIG_VPUMGR) += vpumgr/ +obj-y += intel_tsens/
drivers/misc/intel_tsens/Kconfig new file +15 -0
@@ -0,0 +1,15 @@ +# Copyright (C) 2020 Intel Corporation +# SPDX-License-Identifier: GPL-2.0-only + +config INTEL_TSENS_LOCAL_HOST + bool "Temperature sensor driver for intel tsens" + select THERMAL + help + This option enables tsens thermal local Host driver. + + This driver is used for reporting thermal data via thermal + framework. + Enable this option if you want to have support for thermal + management controller. + Say Y if using a processor that includes the Intel VPU such as + Keem Bay. If unsure, say N.
drivers/misc/intel_tsens/Makefile new file +7 -0
@@ -0,0 +1,7 @@ +# Copyright (C) 2020 Intel Corporation +# SPDX-License-Identifier: GPL-2.0-only +# +# Makefile for intel tsens Thermal Linux driver +# + +obj-$(CONFIG_INTEL_TSENS_LOCAL_HOST) += intel_tsens_thermal.o
drivers/misc/intel_tsens/intel_tsens_thermal.c new file +651 -0
651 lines not on this page · raw message
drivers/misc/intel_tsens/intel_tsens_thermal.h new file +38 -0
@@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* +* Intel tsens thermal Driver +* +* Copyright (C) 2020 Intel Corporation +* +*/ + +#ifndef _LINUX_INTEL_TSENS_H +#define _LINUX_INTEL_TSENS_H + +#include <linux/platform_device.h> +#include <linux/thermal.h> + +struct intel_tsens_plat_data { +const char *name; +void __iomem *base_addr; +int (*get_temp)(struct platform_device *pdev,int type,int *temp); +void *pdata; +}; + +struct intel_tsens_plat_info { +const char *plat_name; +int id; +struct platform_device *pdev; +void __iomem *base_addr; +}; + +struct intel_tsens_i2c_plat_data { +int (*get_temp)(int type,int *temp,void *pdata); +void *pdata; +}; + +/* TSENS i2c platform data */ +extern struct intel_tsens_i2c_plat_data i2c_plat_data; + +#endif /* _LINUX_INTEL_TSENS_H */
include/linux/hddl_device.h new file +153 -0
153 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v3 16/34 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
@@ -239,4 +239,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
@@ -105,3 +105,20 @@ int xlink_pcie_reset_device(u32 sw_device_id)return intel_xpcie_pci_reset_device (sw_device_id); }EXPORT_SYMBOL_GPL (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_GPL (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_GPL (xlink_pcie_unregister_device_event);
drivers/misc/xlink-pcie/local_host/core.c +11 -0
@@ -804,3 +804,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
@@ -53,6 +53,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; }
@@ -62,6 +64,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
@@ -6,6 +6,7 @@*/ #include <linux/mutex.h> +#include <linux/pci.h> #include <linux/sched.h> #include <linux/wait.h> #include <linux/workqueue.h>
@@ -485,3 +486,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
@@ -36,6 +36,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)
@@ -58,5 +59,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
@@ -42,6 +42,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,
@@ -55,4 +64,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
Rob Herring
maintainerRe: [PATCH v4 26/34] dt-bindings: misc: intel_tsens: Add tsens thermal bindings documentation
In reply to [email protected]Quoted 22 lines · On Fri, 29 Jan 2021 18:21:16 -0800, [email protected] wrote:
From: "C, Udhayakumar" <[email protected]>
Add device tree bindings for local host thermal sensors Intel Edge.AI Computer Vision platforms.
The tsens module enables reading of on chip sensors present in the Intel Bay series SoC. In the tsens module various junction temperature and SoC temperature are reported using thermal subsystem and i2c subsystem.
Temperature data reported using thermal subsystem will be used for various cooling agents such as DVFS, fan control and shutdown the system in case of critical temperature.
Temperature data reported using i2c subsytem will be used by platform manageability software running in remote host.
Cc Rob Herring <[email protected]>Acked-by mark gross <[email protected]>Signed-off-by C Udhayakumar <[email protected]>Signed-off-by Mark Gross <[email protected]>
Quoted 5 lines
--- .../bindings/misc/intel,intel-tsens.yaml | 118 ++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 Documentation/devicetree/bindings/misc/intel,intel-tsens.yaml
My bot found errors running 'make dt_binding_check' on your patch:
yamllint warnings/errors:
dtschema/dtc warnings/errors:
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/misc/intel,intel-tsens.example.dt.yaml: example-0: tsens@20260000:reg:0: [0, 539361280, 0, 256] is too long
From schema: /usr/local/lib/python3.8/dist-packages/dtschema/schemas/reg.yaml
See https://patchwork.ozlabs.org/patch/1433609
This check can fail if there are any dependencies. The base for a patch series is generally the most recent rc1.
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.
Rob Herring
maintainerRe: [PATCH v4 32/34] dt-bindings: misc: hddl_dev: Add hddl device management documentation
In reply to [email protected]Quoted 11 lines · On Fri, 29 Jan 2021 18:21:22 -0800, [email protected] wrote:
From: "C, Udhayakumar" <[email protected]>
Add hddl device management documentation
The HDDL client driver acts as an software RTC to sync with network time. It abstracts xlink protocol to communicate with remote IA host. This driver exports the details about sensors available in the platform to remote IA host as xlink packets.
This driver also handles device connect/disconnect events and identifies board id and soc id using gpio's based on platform configuration.
Quoted 9 lines
Cc Rob Herring <[email protected]>Signed-off-by C Udhayakumar <[email protected]>Signed-off-by Mark Gross <[email protected]>--- .../bindings/misc/intel,hddl-client.yaml | 114 ++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 Documentation/devicetree/bindings/misc/intel,hddl-client.yaml
My bot found errors running 'make dt_binding_check' on your patch:
yamllint warnings/errors:
dtschema/dtc warnings/errors:
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/misc/intel,hddl-client.example.dt.yaml: example-0: hddl@20320000:reg:0: [0, 540147712, 0, 2048] is too long
From schema: /usr/local/lib/python3.8/dist-packages/dtschema/schemas/reg.yaml
See https://patchwork.ozlabs.org/patch/1433603
This check can fail if there are any dependencies. The base for a patch series is generally the most recent rc1.
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.
Randy Dunlap
reviewerRe: [PATCH v3 25/34] misc: Add Keem Bay VPU manager
In reply to [email protected]drivers/misc/vpumgr/Kconfig line 6
Quoted 12 lines · On 1/29/21 6:20 PM, [email protected] wrote:
drivers/misc/vpumgr/Kconfig new file +6
-0@@ -0,0 +1,9 @@ +config VPUMGR + tristate "VPU Manager" + depends on ARM64 && XLINK_CORE + help + VPUMGR manages life-cycle of VPU related resources which were + dynamically allocated on demands of user-space application
End above sentence with a period ('.').
Hm, same as I said the previous round of patches (also v3).
Quoted 3 lines
drivers/misc/vpumgr/Kconfig new file +3
-0+ + Select y or m if you have a processor including the Intel + Vision Processor (VPU) on it.
Signature · 1 line
~Randy
Randy Dunlap
reviewerRe: [PATCH v3 29/34] Intel tsens i2c slave driver.
In reply to [email protected]drivers/misc/intel_tsens/Kconfig config INTEL_TSENS_LOCAL_HOST · line 20
Quoted 12 lines · On 1/29/21 6:20 PM, [email protected] wrote:
drivers/misc/intel_tsens/Kconfig +4
-0@@ -14,6 +14,21 @@ config INTEL_TSENS_LOCAL_HOST Say Y if using a processor that includes the Intel VPU such as Keem Bay. If unsure, say N. +config INTEL_TSENS_I2C_SLAVE + bool "I2C slave driver for intel tsens" + depends on INTEL_TSENS_LOCAL_HOST + select I2C
Repeating:
No, do not select I2C. Use:
depends on I2C
Quoted 10 lines
drivers/misc/intel_tsens/Kconfig +10
-0+ select I2C_SLAVE + help + This option enables tsens I2C slave driver. + + This driver is used for reporting thermal data via I2C + SMBUS to remote host. + Enable this option if you want to have support for thermal + management controller. + Say Y if using a processor that includes the Intel VPU such as + Keem Bay. If unsure, say N.
Signature · 1 line
~Randy
Randy Dunlap
reviewerRe: [PATCH v4 29/34] Intel tsens i2c slave driver.
In reply to [email protected]Quoted 5 lines · On 1/29/21 6:21 PM, [email protected] wrote:
drivers/misc/intel_tsens/Kconfig +0
-0
drivers/misc/intel_tsens/Kconfig config INTEL_TSENS_LOCAL_HOST · line 22
Quoted 9 lines
drivers/misc/intel_tsens/Kconfig +6
-0@@ -14,6 +14,20 @@ config INTEL_TSENS_LOCAL_HOST Say Y if using a processor that includes the Intel VPU such as Keem Bay. If unsure, say N. +config INTEL_TSENS_I2C_SLAVE + bool "I2C slave driver for intel tsens" + depends on INTEL_TSENS_LOCAL_HOST + depends on I2C=y && I2C_SLAVE + help + This option enables tsens I2C slave driver.
Good, it's OK now.
The repeat v3 and then v4 confused me.
Quoted 7 lines
drivers/misc/intel_tsens/Kconfig +7
-0+ + This driver is used for reporting thermal data via I2C + SMBUS to remote host. + Enable this option if you want to have support for thermal + management controller. + Say Y if using a processor that includes the Intel VPU such as + Keem Bay. If unsure, say N.
Signature · 1 line
~Randy
Jassi Brar
maintainerRe: [PATCH v3 03/34] mailbox: vpu-ipc-mailbox: Add support for Intel VPU IPC mailbox
In reply to [email protected]Quoted 36 lines · On Fri, Jan 29, 2021 at 8:21 PM <[email protected]> wrote:
From: Daniele Alessandrelli <[email protected]>
Add mailbox controller enabling inter-processor communication (IPC) between the CPU (aka, the Application Processor - AP) and the VPU on Intel Movidius SoCs like Keem Bay.
The controller uses HW FIFOs to enable such communication. Specifically, there are two FIFOs, one for the CPU and one for VPU. Each FIFO can hold 128 entries (messages) of 32-bit each (but only 26 bits are actually usable, since the 6 least-significant bits are reserved).
When the Linux kernel on the AP needs to send messages to the VPU firmware, it writes them to the VPU FIFO; similarly, when the VPU firmware needs to send messages to the AP, it writes them to the CPU FIFO.
The AP is notified of pending messages in the CPU FIFO by means of the 'FIFO-not-empty' interrupt, which is generated by the CPU FIFO while not empty. This interrupt is cleared automatically once all messages have been read from the FIFO (i.e., the FIFO has been emptied).
The hardware doesn't provide an TX done IRQ (i.e., an IRQ that allows the VPU firmware to notify the AP that the message put into the VPU FIFO has been received); however the AP can ensure that the message has been successfully put into the VPU FIFO (and therefore transmitted) by checking the VPU FIFO status register to ensure that writing the message didn't cause the FIFO to overflow.
Therefore, the mailbox controller is configured as capable of
tx_doneIRQs and a tasklet is used to simulate thetx_doneIRQ. The tasklet is activated bysend_data()right after the message has been put into the VPU FIFO and the VPU FIFO status registers has been checked. If an overflow is reported by the status register, the tasklet passes-EBUSYtombox_chan_txdone(), to notify the mailbox client of the failed TX.
Quoted 6 lines
The client should therefore register a
tx_done()callback to properly handle failed transmissions.Note: the '
txdone_poll' mechanism cannot be used because it doesn't provide a way to report a failed transmission.
txdone means the last submitted transfer has been done with -- successfully or not.
So I think we can do without the tasklet as explained below....
....
drivers/mailbox/vpu-ipc-mailbox.c line 162
Quoted 7 lines
drivers/mailbox/vpu-ipc-mailbox.c new file +7
-0+static int vpu_ipc_mailbox_send_data (struct mbox_chan *chan,void *data) +{ +struct vpu_ipc_mbox *vpu_ipc_mbox = chan->con_priv; +u32 entry, overflow; + + entry = *((u32 *)data); +
Are all messages max 32bits wide?
Usually the controller specifies a packet format (more than just a word but of course that's not mandatory) that a client submits the data to be transmitted in. Esp when it has deep FIFOs.
Quoted 21 lines
drivers/mailbox/vpu-ipc-mailbox.c new file +21
-0+/* Ensure last 6-bits of entry are not used. */ +if (unlikely (entry &IPC_FIFO_ENTRY_RSVD_MASK )) { + vpu_ipc_mbox->txdone_result = -EINVAL ; + goto exit; + } + +/* Add processor ID to entry. */ + entry |=IPC_FIFO_ID_CPU &IPC_FIFO_ENTRY_RSVD_MASK ; + +/* Write entry to VPU FIFO. */ +iowrite32 (entry, vpu_ipc_mbox->vpu_fifo_base +IPC_FIFO ); + +/* Check if we overflew the VPU FIFO. */ + overflow =ioread32 (vpu_ipc_mbox->vpu_fifo_base +IPC_FIFO_OF_FLAG0 ) & +BIT (IPC_FIFO_ID_CPU ); +if (unlikely (overflow)) { +/* Reset overflow register. */ +iowrite32 (BIT (IPC_FIFO_ID_CPU ), + vpu_ipc_mbox->vpu_fifo_base +IPC_FIFO_OF_FLAG0 ); + vpu_ipc_mbox->txdone_result = -EBUSY ; + goto exit;
drivers/mailbox/vpu-ipc-mailbox.c line 193
Quoted 10 lines
drivers/mailbox/vpu-ipc-mailbox.c new file +10
-0+ } + vpu_ipc_mbox->txdone_result =0 ; + +exit: +/* Schedule tasklet to call mbox_chan_txdone(). */ +tasklet_schedule (&vpu_ipc_mbox->txdone_tasklet); + +return 0 ; +} +
Maybe set txdone_poll and implement last_tx_done() where you can wait for FIFO to have enough space for another message, so that the next submitted request will never return -EBUSY.
thanks
RE: [PATCH v4 29/34] Intel tsens i2c slave driver.
In reply to Randy DunlapQuoted 22 lines
-----Original Message-----
From: Randy Dunlap <[email protected]>
Sent: Sunday, January 31, 2021 6:14 PM
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]; C, Udhayakumar <[email protected]>
Subject: Re: [PATCH v4 29/34] Intel tsens i2c slave driver.Quoted 8 lines · On 1/29/21 6:21 PM, [email protected] wrote:
drivers/misc/intel_tsens/Kconfig +0
-0@@ -14,6 +14,20 @@ config INTEL_TSENS_LOCAL_HOST Say Y if using a processor that includes the Intel VPU such as Keem Bay. If unsure, say N.
Quoted 9 lines
drivers/misc/intel_tsens/Kconfig config INTEL_TSENS_LOCAL_HOST · line 22
Quoted 6 lines
drivers/misc/intel_tsens/Kconfig +6
-0+config INTEL_TSENS_I2C_SLAVE + bool "I2C slave driver for intel tsens" + depends on INTEL_TSENS_LOCAL_HOST + depends on I2C=y && I2C_SLAVE + help + This option enables tsens I2C slave driver.Good, it's OK now.
The repeat v3 and then v4 confused me.
Hmm, I'm confused too. I should have only sent v4 on Friday. I'll look over my history and logs to see how I could have sent to blasts one or V3 and then V4. Ugh. Sorry about mixing the V3 and V4 patches in the same batch.
FWIW I make an outgoing directory and forgot to clean out the v3 patches that where there from the earlier posting. Resulting in a mixing of the old and current patch set.
I'll write a script to automate the creation of the outgoing directory for next time that should correct future screw ups.
I'm very sorry for the noise.
--mark
Re: [PATCH v3 03/34] mailbox: vpu-ipc-mailbox: Add support for Intel VPU IPC mailbox
In reply to Jassi BrarHi Jassi,
Thank you very much for your feedback.
Quoted 36 lines · Jassi Brar
Quoted 35 lines · On Fri, Jan 29, 2021 at 8:21 PM <[email protected]> wrote:
From: Daniele Alessandrelli <[email protected]>
Add mailbox controller enabling inter-processor communication (IPC) between the CPU (aka, the Application Processor - AP) and the VPU on Intel Movidius SoCs like Keem Bay.
The controller uses HW FIFOs to enable such communication. Specifically, there are two FIFOs, one for the CPU and one for VPU. Each FIFO can hold 128 entries (messages) of 32-bit each (but only 26 bits are actually usable, since the 6 least-significant bits are reserved).
When the Linux kernel on the AP needs to send messages to the VPU firmware, it writes them to the VPU FIFO; similarly, when the VPU firmware needs to send messages to the AP, it writes them to the CPU FIFO.
The AP is notified of pending messages in the CPU FIFO by means of the 'FIFO-not-empty' interrupt, which is generated by the CPU FIFO while not empty. This interrupt is cleared automatically once all messages have been read from the FIFO (i.e., the FIFO has been emptied).
The hardware doesn't provide an TX done IRQ (i.e., an IRQ that allows the VPU firmware to notify the AP that the message put into the VPU FIFO has been received); however the AP can ensure that the message has been successfully put into the VPU FIFO (and therefore transmitted) by checking the VPU FIFO status register to ensure that writing the message didn't cause the FIFO to overflow.
Therefore, the mailbox controller is configured as capable of
tx_doneIRQs and a tasklet is used to simulate thetx_doneIRQ. The tasklet is activated bysend_data()right after the message has been put into the VPU FIFO and the VPU FIFO status registers has been checked. If an overflow is reported by the status register, the tasklet passes-EBUSYtombox_chan_txdone(), to notify the mailbox client of the failed TX.
Quoted 8 lines
Quoted 6 lines
The client should therefore register a
tx_done()callback to properly handle failed transmissions.Note: the '
txdone_poll' mechanism cannot be used because it doesn't provide a way to report a failed transmission.txdone means the last submitted transfer has been done with -- successfully or not.
Yes, that's usually the case, but not for poll mode (at least from what I can tell).
last_tx_done() can return only true or false, but when true is returned, there is no way to know if the TX was successful or not; the mailbox framework just seems to assume that 'true' means "message successfully transmitted", since 0 is passed to tx_tick() (end eventually to the tx_done() client callback):
https://github.com/torvalds/linux/blob/master/drivers/mailbox/mailbox.c#L131
If 'false' is returned, the polling continues until the timeout is reached.
(please correct me if my above understanding is wrong)
Quoted 4 lines
So I think we can do without the tasklet as explained below....
....
Quoted 11 lines
drivers/mailbox/vpu-ipc-mailbox.c line 162
Quoted 7 lines
drivers/mailbox/vpu-ipc-mailbox.c new file +7
-0+static int vpu_ipc_mailbox_send_data (struct mbox_chan *chan,void *data) +{ +struct vpu_ipc_mbox *vpu_ipc_mbox = chan->con_priv; +u32 entry, overflow; + + entry = *((u32 *)data); +Are all messages max 32bits wide?
Usually the controller specifies a packet format (more than just a word but of course that's not mandatory) that a client submits the data to be transmitted in. Esp when it has deep FIFOs.
It's actually only 26 bits, since the last 6 bits are reserved for the overflow detection mechanism; I should probably have explained this better in the commit message, sorry!
Basically, the AP is not the only one that can write to the VPU FIFO:
other components within the SoC can write to it too. Each of these components has a unique 6-bit processor ID associated to it. The HW FIFO expects that the last 6 bits of each 32-bit FIFO entry contain the processor ID of the sender.
Sending a message works as follows:
1. The message must be a 32-bit value with the last 6-bit set to 0 (in practice, the message is meant to be a 32-bit address value, aligned to 64 bytes).
2. The sender adds its processor ID to the 32-bit message being sent: M = m | ProcID
3. The sender writes the message (M) to the TIM_IPC_FIFO register
4. The HW atomically checks if the FIFO is full and if not it writes it to the actual FIFO; if the FIFO is full, the HW reads the ProcID from M and then sets the corresponding bit of TIM_IPC_FIFO_OF_FLAG0, to signal that the write failed, because the FIFO was full
5. The sender reads the TIM_IPC_FIFO_OF_FLAG0 register and checks if the bit corresponding to its ProcID has been set (in order to know if the TX succeeded or failed); if the bit is set, the sender clears it.
Note: as briefly mentioned above, the 32-bit value is meant to be a 32- bit physical address (64-byte aligned). This address points to a predefined struct (i.e., the IPC packet) in shared memory. However, since this struct is not HW dependent (it's just the struct the VPU firmware expects and in theory it could change if a different VPU FW is used), I didn't define it here, but in the Keem Bay IPC driver (patch 4 and 5), which is the mailbox client of this controller (does this design seem reasonable to you?)
Quoted 27 lines
Quoted 27 lines
drivers/mailbox/vpu-ipc-mailbox.c new file +26
-0+/* Ensure last 6-bits of entry are not used. */ +if (unlikely (entry &IPC_FIFO_ENTRY_RSVD_MASK )) { + vpu_ipc_mbox->txdone_result = -EINVAL ; + goto exit; + } + +/* Add processor ID to entry. */ + entry |=IPC_FIFO_ID_CPU &IPC_FIFO_ENTRY_RSVD_MASK ; + +/* Write entry to VPU FIFO. */ +iowrite32 (entry, vpu_ipc_mbox->vpu_fifo_base +IPC_FIFO ); + +/* Check if we overflew the VPU FIFO. */ + overflow =ioread32 (vpu_ipc_mbox->vpu_fifo_base +IPC_FIFO_OF_FLAG0 ) & +BIT (IPC_FIFO_ID_CPU ); +if (unlikely (overflow)) { +/* Reset overflow register. */ +iowrite32 (BIT (IPC_FIFO_ID_CPU ), + vpu_ipc_mbox->vpu_fifo_base +IPC_FIFO_OF_FLAG0 ); + vpu_ipc_mbox->txdone_result = -EBUSY ; + goto exit; + } + vpu_ipc_mbox->txdone_result =0 ; + +exit: +/* Schedule tasklet to call mbox_chan_txdone(). */
Quoted 8 lines
drivers/mailbox/vpu-ipc-mailbox.c line 193
Quoted 5 lines
drivers/mailbox/vpu-ipc-mailbox.c new file +5
-0+tasklet_schedule (&vpu_ipc_mbox->txdone_tasklet); + +return 0 ; +} +Maybe set
txdone_polland implementlast_tx_done()where you can wait for FIFO to have enough space for another message, so that the next submitted request will never return-EBUSY.
I cannot do that because the AP is not the only one writing to the VPU FIFO (sorry again for not mentioning this in the commit message) and therefore, even if at time 't' there is enough space for another message, at time 't+1' (when the driver actually tries to send the message) the FIFO might be full.
I think that in order for me to avoid using the tasklet we might have to change the mailbox framework itself.
For instance, we could modify the last_tx_done() to return 0 on success and negative error code on failure. Then we can agree that if -EAGAIN is returned, the mailbox framework will keep polling, while if the error is something else, the error will be passed to tx_tick() (and eventually to the tx_done callback).
However, for my specific case, the best solution would probably be to modify how send_data() return values are used (so that I can avoid the polling delay). At the moment, my understanding is that when send_data() reutrn -EBUSY, the message is left into the mailbox channel queue (and will be transmitted at a later stage). While I would probably benefit from having an option to return the error to the client, so that it's up to the client to decide if it's worth trying the re-transmission or not.
Anyway, the current tasklet solution works fine with me, so I'm happy to stick with it if that's fine with you.
Quoted 2 lines
thanks
RE: [PATCH v3 28/34] misc: Intel tsens IA host driver.
In reply to Joe PerchesQuoted 22 lines · On Fri, 2021-01-29 at 18:20 -0800, [email protected] wrote:
Quoted 4 lines
From: "C, Udhayakumar" <[email protected]>
Add Intel tsens IA host driver for Intel Edge.AI Computer Vision platforms.
[]
drivers/misc/intel_tsens/intel_tsens_host.c
Quoted 2 lines
drivers/misc/intel_tsens/intel_tsens_host.c +0
-0[]
Quoted 1 line
+static int tsens_i2c_smbus_read_byte_data(struct
i2c_client*i2c, u8command,
drivers/misc/intel_tsens/intel_tsens_host.c line 52
Quoted 8 lines
drivers/misc/intel_tsens/intel_tsens_host.c +8
-0+ u8 *i2c_val) +{ +union i2c_smbus_data data; +int status; + + status =i2c_smbus_xfer (i2c->adapter, i2c->addr, i2c->flags, +I2C_SMBUS_READ , command, +I2C_SMBUS_BYTE_DATA , &data);this can fail
Quoted 4 lines
drivers/misc/intel_tsens/intel_tsens_host.c line 53
Quoted 1 line
drivers/misc/intel_tsens/intel_tsens_host.c +1
-0+ *i2c_val = data.byte;Is it appropriate to set the value if it failed and data was not initialized?
Thanks for the feedback, I will update as below in next patch version.
if (!status)
*i2c_val = data.byte;
Quoted 7 lines
drivers/misc/intel_tsens/intel_tsens_host.c line 58
Quoted 5 lines
drivers/misc/intel_tsens/intel_tsens_host.c +5
-0+return status; +} + +/** +* intel_tsens_get_temp - get updated temperatue Might want to use codespell on all files.
Yes we have ran codespell before submitting, looks like codespell dictionary doesn't have replacement for ' temperatue'. It has only below words.
temerature->temperaturetempertaure->temperaturetemperture->temperature
--
udhay
Quoted 1 line
RE: [PATCH v4 26/34] dt-bindings: misc: intel_tsens: Add tsens thermal bindings documentation
In reply to Rob HerringQuoted 42 lines · On Fri, 29 Jan 2021 18:21:16 -0800, [email protected] wrote:
Quoted 22 lines
From: "C, Udhayakumar" <[email protected]>
Add device tree bindings for local host thermal sensors Intel Edge.AI Computer Vision platforms.
The tsens module enables reading of on chip sensors present in the Intel Bay series SoC. In the tsens module various junction temperature and SoC temperature are reported using thermal subsystem and i2c subsystem.
Temperature data reported using thermal subsystem will be used for various cooling agents such as DVFS, fan control and shutdown the system in case of critical temperature.
Temperature data reported using i2c subsytem will be used by platform manageability software running in remote host.
Cc Rob Herring <[email protected]>Acked-by mark gross <[email protected]>Signed-off-by C Udhayakumar <[email protected]>Signed-off-by Mark Gross <[email protected]>Quoted 6 lines
--- .../bindings/misc/intel,intel-tsens.yaml | 118 ++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644
Documentation/devicetree/bindings/misc/intel,intel-tsens.yamlMy bot found errors running 'make
dt_binding_check' on your patch:yamllint warnings/errors:
dtschema/dtc warnings/errors:
/builds/robherring/linux-dt- review/Documentation/devicetree/bindings/misc/intel,intel-tsens.example.dt.yaml: example-0: tsens@20260000:reg:0: [0, 539361280, 0, 256] is too long
From schema:/usr/local/lib/python3.8/dist-packages/dtschema/schemas/reg.yaml
Quoted 2 lines
This lint warning is due to missing address-cells and size-cells fields.
make dt_binding_check dtbs_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/misc/intel,intel-tsens.yaml
CHKDT Documentation/devicetree/bindings/misc/intel,intel-tsens.yaml DTC Documentation/devicetree/bindings/misc/intel,intel-tsens.example.dt.yaml CHECK Documentation/devicetree/bindings/misc/intel,intel-tsens.example.dt.yaml
Will update the fix in next patch version.
---
Thanks,
Udhay
Quoted 10 lines
This check can fail if there are any dependencies. The base for a patch series is generally the most recent rc1.
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 v4 32/34] dt-bindings: misc: hddl_dev: Add hddl device management documentation
In reply to Rob HerringQuoted 35 lines · On Fri, 29 Jan 2021 18:21:22 -0800, [email protected] wrote:
Quoted 15 lines
From: "C, Udhayakumar" <[email protected]>
Add hddl device management documentation
The HDDL client driver acts as an software RTC to sync with network time. It abstracts xlink protocol to communicate with remote IA host. This driver exports the details about sensors available in the platform to remote IA host as xlink packets.
This driver also handles device connect/disconnect events and identifies board id and soc id using gpio's based on platform configuration.Cc Rob Herring <[email protected]>Signed-off-by C Udhayakumar <[email protected]>Signed-off-by Mark Gross <[email protected]>Quoted 6 lines
--- .../bindings/misc/intel,hddl-client.yaml | 114 ++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644
Documentation/devicetree/bindings/misc/intel,hddl-client.yamlMy bot found errors running 'make
dt_binding_check' on your patch:yamllint warnings/errors:
dtschema/dtc warnings/errors:
/builds/robherring/linux-dt- review/Documentation/devicetree/bindings/misc/intel,hddl-client.example.dt.yaml: example-0: hddl@20320000:reg:0: [0, 540147712, 0, 2048] is too long
From schema:/usr/local/lib/python3.8/dist-packages/dtschema/schemas/reg.yaml
Quoted 2 lines
This lint warning is due to missing address-cells and size-cells fields.
make dt_binding_check dtbs_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/misc/intel,hddl-client.yaml
SCHEMA Documentation/devicetree/bindings/processed-schema.yaml CHKDT Documentation/devicetree/bindings/misc/intel,hddl-client.yaml DTC Documentation/devicetree/bindings/misc/intel,hddl-client.example.dt.yaml CHECK Documentation/devicetree/bindings/misc/intel,hddl-client.example.dt.yaml
Will update the fix in next patch version.
---
Thanks,
Udhay
Quoted 10 lines
This check can fail if there are any dependencies. The base for a patch series is generally the most recent rc1.
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.