Add the I3C subsystem
Subsystems (6)
v10 cover Add the I3C subsystem
Hi Greg,
I think we've reached a point where we can eventually consider the I3C framework for inclusion in 4.20 (5.0?). A few more issues were reported on v9 and fixed in v10. I can't guarantee that the implementation is free of bugs but I still think it's worth merging it in v4.20: it's a new subsystem, so we don't risk regressions, and the only way we can detect other issues is by having other people experiment with this implementation.
The only remaining concern raised by Arnd is the fact that both hosts and slaves share the same bus type and are differentiated thanks to their device_type, which IMHO is fine since this is what other subsystems do (plus I don't see other solutions to have both I3C devices and I3C buses represented under /sys/bus/i3c/).
I'd really like to get this series merged in 4.20 so that other contributors can work on top of it to add
1/ new host drivers
2/ support for advanced features
3/ new device drivers
So, unless you have strong reasons to reject this request, and, assuming I get Rob's ack soon enough, I plan to send a PR for this framework next week.
Here is the usual description copy&pasted from the previous versions:
This patch series is adding a new subsystem to support I3C devices.
This is just adding support for basic features. Extra features will be added afterwards.
There are a few design choices that are worth mentioning because they impact the way I3C device drivers can interact with their devices:
- all functions used to send I3C/I2C frames must be called in non-atomic context. Mainly done this way to ease implementation, but this is still open to discussion. Please let me know if you think it's worth considering an asynchronous model here
- the I3C bus and I3C master controller are now tightly coupled even though they're still allocated separately. There's now a 1:1 relationship between these objects, and the I3C master is no longer represented under the I3C bus object.
Arnd, let me know if you had something different in mind, and I'll rework the implementation accordingly.
- I2C backward compatibility has been designed to be transparent to I2C drivers and the I2C subsystem. The I3C master just registers an I2C adapter which creates a new I2C bus. I'd say that, from a representation PoV it's not ideal because what should appear as a single I3C bus exposing I3C and I2C devices here appears as 2 different busses connected to each other through the parenting (the I3C master is the parent of the I2C and I3C busses).
On the other hand, I don't see a better solution if we want something that is not invasive.
Missing features (will be added in separate patch series after initial support has been accepted/merged):
- support for HDR modes (has been removed because of lack of real users)
- no support for multi-master and the associated concepts (mastership handover, support for secondary masters, ...)
- I2C devices can only be described using DT because this is the only use case I have. However, the framework can easily be extended with ACPI and board info support
- I3C slave framework. This has been completely omitted, but shouldn't have a huge impact on the I3C framework because I3C slaves don't see the whole bus, it's only about handling master requests and generating IBIs. Some of the struct, constant and enum definitions could be shared, but most of the I3C slave framework logic will be different
Note that this patchset is available on the linux-i3c repo[1].
Main change between v8 and v9:
- The DT bindings have been simplified to get rid of the I3C/I3C_DEV() macros
Main change between v7 and v8:
- The bus object is now embedded in the master_controller object (as suggested by Arnd)
Main changes between v6 and v7:
- I3C bus/master representations have been reworked to match what other subsystems are doing (master implicitly represented by the bus object)
- I3C dev registration has been fixed
- I3C bus mode selection has been fixed
- Calls to readsl/writesl() in the Cadence I3C master driver have been fixed
Main changes between v5 and v6:
- Introduce {i3c,i2c}_dev_desc structures to better match how I3C master controllers (reservation of one HW slot for each device attached to the bus). With this solution, the resource migration that happens when a device lose its dynamic address and is re-assigned a different address is simplified on the driver side, because most of it is now handled in the core (reserve a new dev slot, reserve IBI resources and free all resources attached to the old slot)
- Add I3C error codes (M0 to M2) so that the core and device drivers can have fine grained information on what caused an EIO error.
Only minor things happened between v3 and v5 (you can go check the changelog in each patch for more details).
Main changes between v2 and v3 are:
- Reworked the DT bindings as suggested by Rob
- Reworked the bus initialization step as suggested by Vitor
- Added a driver for an I3C GPIO expander
Main changes between the initial RFC and this v2 are:
- Add a generic infrastructure to support IBIs. It's worth mentioning that I tried exposing IBIs as a regular IRQs, but after several attempts and a discussion with Mark Zyngier, it appeared that it was not really fitting in the Linux IRQ model (the fact that you have payload attached to IBIs, the fact that most of the time an IBI will generate a transfer on the bus which has to be done in an atomic context, ...)
The counterpart of this decision is the latency induced by the workqueue approach, but since I don't have real use cases, I don't know if this can be a problem or not.
- Add helpers to support Hot Join
- Add support for IBIs and Hot Join in Cadence I3C master driver
- Address several issues in how I was using the device model
Thanks,
Boris
[1]https://git.kernel.org/pub/scm/linux/kernel/git/i3c/linux.git/log/?h=i3c/next
*** BLURB HERE ***
Boris Brezillon (9):
i3c: Add core I3C infrastructure
docs: driver-api: Add I3C documentation
i3c: Add sysfs ABI spec
dt-bindings: i3c: Document core bindings
MAINTAINERS: Add myself as the I3C subsystem maintainer
i3c: master: Add driver for Cadence IP
dt-bindings: i3c: Document Cadence I3C master bindings
gpio: Add a driver for Cadence I3C GPIO expander
dt-bindings: gpio: Add bindings for Cadence I3C gpio expander
Documentation/ABI/testing/sysfs-bus-i3c | 146 + .../bindings/gpio/gpio-cdns-i3c.txt | 39 + .../bindings/i3c/cdns,i3c-master.txt | 44 + Documentation/devicetree/bindings/i3c/i3c.txt | 139 + .../driver-api/i3c/device-driver-api.rst | 9 + Documentation/driver-api/i3c/index.rst | 11 + .../driver-api/i3c/master-driver-api.rst | 10 + Documentation/driver-api/i3c/protocol.rst | 203 ++ Documentation/driver-api/index.rst | 1 + MAINTAINERS | 12 + drivers/Kconfig | 2 + drivers/Makefile | 2 +- drivers/gpio/Kconfig | 11 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-cdns-i3c.c | 411 +++ drivers/i3c/Kconfig | 24 + drivers/i3c/Makefile | 4 + drivers/i3c/device.c | 233 ++ drivers/i3c/internals.h | 26 + drivers/i3c/master.c | 2661 +++++++++++++++++ drivers/i3c/master/Kconfig | 6 + drivers/i3c/master/Makefile | 1 + drivers/i3c/master/i3c-master-cdns.c | 1671 +++++++++++ include/linux/i3c/ccc.h | 385 +++ include/linux/i3c/device.h | 331 ++ include/linux/i3c/master.h | 648 ++++ include/linux/mod_devicetable.h | 17 + 27 files changed, 7047 insertions(+), 1 deletion(-) create mode 100644 Documentation/ABI/testing/sysfs-bus-i3c create mode 100644 Documentation/devicetree/bindings/gpio/gpio-cdns-i3c.txt create mode 100644 Documentation/devicetree/bindings/i3c/cdns,i3c-master.txt create mode 100644 Documentation/devicetree/bindings/i3c/i3c.txt create mode 100644 Documentation/driver-api/i3c/device-driver-api.rst create mode 100644 Documentation/driver-api/i3c/index.rst create mode 100644 Documentation/driver-api/i3c/master-driver-api.rst create mode 100644 Documentation/driver-api/i3c/protocol.rst create mode 100644 drivers/gpio/gpio-cdns-i3c.c create mode 100644 drivers/i3c/Kconfig create mode 100644 drivers/i3c/Makefile create mode 100644 drivers/i3c/device.c create mode 100644 drivers/i3c/internals.h create mode 100644 drivers/i3c/master.c create mode 100644 drivers/i3c/master/Kconfig create mode 100644 drivers/i3c/master/Makefile create mode 100644 drivers/i3c/master/i3c-master-cdns.c create mode 100644 include/linux/i3c/ccc.h create mode 100644 include/linux/i3c/device.h create mode 100644 include/linux/i3c/master.h
Signature · 1 line
2.17.1
PATCH v10 1/9 i3c: Add core I3C infrastructure
Add core infrastructure to support I3C in Linux and document it.
This infrastructure adds basic I3C support. Advanced features will be added afterwards.
There are a few design choices that are worth mentioning because they impact the way I3C device drivers can interact with their devices:
- all functions used to send I3C/I2C frames must be called in non-atomic context. Mainly done this way to ease implementation, but this is not set in stone, and if anyone needs async support, new functions can be added later on.
- the bus element is a separate object, but it's tightly coupled with the master object. We thus have a 1:1 relationship between i3c_bus and i3c_master_controller objects, and if 2 master controllers are connected to the same bus and both exposed to the same Linux instance they will appear as two distinct busses, and devices on this bus will be exposed twice.
- I2C backward compatibility has been designed to be transparent to I2C drivers and the I2C subsystem. The I3C master just registers an I2C adapter which creates a new I2C bus. I'd say that, from a representation PoV it's not ideal because what should appear as a single I3C bus exposing I3C and I2C devices here appears as 2 different buses connected to each other through the parenting (the I3C master is the parent of the I2C and I3C busses).
On the other hand, I don't see a better solution if we want something that is not invasive.
Missing features:
- I3C HDR modes are not supported
- no support for multi-master and the associated concepts (mastership handover, support for secondary masters, ...)
- I2C devices can only be described using DT because this is the only use case I have. However, the framework can easily be extended with ACPI and board info support
- I3C slave framework. This has been completely omitted, but shouldn't have a huge impact on the I3C framework because I3C slaves don't see the whole bus, it's only about handling master requests and generating IBIs. Some of the struct, constant and enum definitions could be shared, but most of the I3C slave framework logic will be different
---
Changes in v10:
- Fix a deadlock (reported by kbuild-robots/Julia Lawall)
- Dynamically allocate CCC payloads
- Mention that buffers attached to i2c transfers are not guaranteed to be DMA-safe and point to the i2c_get/put_dma_safe_msg_buf() helpers
Changes in v9:
- Modify the DT parsing code to match the reg encoding
- Add Arnd's R-b
Changes in v8:
- Embed the i3c_bus object directly in the i3c_master_controller one (suggested by Arnd)
- Move core.c into master.c (suggested by Arnd)
- Replace bool by unsigned int (or u8) in structures (suggested by checkpatch)
Changes in v7:
- Stop representing the I3C master as a device under the I3C bus
- Enforce a 1:1 relationship between i3c_bus and i3c_master_controller objects
- Fix I3C bus mode selection when I2C devices are described in the DT.
- Fix I3C device registration
Changes in v6:
- Add I3C/I2C dev descriptors to simplify I3C driver controllers when migrating resources from on I3C device slot to anoter
- Add I3C error codes and return them when doing SDR/priv and CCC transfers. This allows us to properly detect when no devices acked a CCC command, which in some cases is a valid situation (no I3C devices on the bus)
- Remove __packed specifiers where unneeded
- Allocate all IBI slots in one call using kcalloc()
Changes in v5:
- Rename the address sysfs entry into dynamic_address to clarify things
- Document that we expect buffers passed to i3c_device_do_priv_xfers() to be DMA-able
- Fix DEFSLVS CCC command
- s/2017/2018/ in copyright headers
- Fix SPDX header in internals.h
- Fix coding style issues
Changes in v4:
- none
Changes in v3:
- Fix locking issues
- Explicitly include a bunch of headers (reported by Randy Dunlap)
- Rename {i2c,i3c}-scl-frequency DT prop into {i2c,i3c}-scl-hz
- Do not use BIT() macro in mod_devicetable.h
- Fix typos
- Fix/enhance some kernel doc headers
- Rework the bus initialization code to simplify master drivers
- Assign dynamic address with SETDASA if the device has a static address and the DT has a valid assigned-address property
- Rework the LVR extraction in DT parsing code
- Add code to detect when a device is re-attached to the bus after losing its dynamic address. In this case we know try to re-assign the old address, and most importantly, the I3C device driver sees the same device instance, not a new one
- Add an ->i2c_funcs() hook to let the master declare which I2C features it supports
- Unexport a few functions
- Remove support for HDR mode since we have no real user yet
Changes in v2:
- Fix a bunch of mistake I made with the device model (pointed by GKH)
- Move the documentation out of this commit (pointed by GKH)
- only source drivers/i3c/master/Kconfig when CONFIG_I3C is enabled (pointed by GKH)
- Add IBI infrastructure
- Add helpers to ease support for Hot Join (most of the logic is delegated to I3C controller drivers)
- move the doc out of this commit to improve readability
- Fix a few bugs in device probing/remove (detected after trying to load/unload modules in various orders)
- Add a module_i3c_i2c_driver() macro to ease integration of drivers for devices that support both I3C and I2C mode
--- drivers/Kconfig | 2 + drivers/Makefile | 2 +- drivers/i3c/Kconfig | 24 + drivers/i3c/Makefile | 4 + drivers/i3c/device.c | 233 +++ drivers/i3c/internals.h | 26 + drivers/i3c/master.c | 2661 +++++++++++++++++++++++++++++++ drivers/i3c/master/Kconfig | 0 drivers/i3c/master/Makefile | 0 include/linux/i3c/ccc.h | 385 +++++ include/linux/i3c/device.h | 331 ++++ include/linux/i3c/master.h | 648 ++++++++ include/linux/mod_devicetable.h | 17 + 13 files changed, 4332 insertions(+), 1 deletion(-) create mode 100644 drivers/i3c/Kconfig create mode 100644 drivers/i3c/Makefile create mode 100644 drivers/i3c/device.c create mode 100644 drivers/i3c/internals.h create mode 100644 drivers/i3c/master.c create mode 100644 drivers/i3c/master/Kconfig create mode 100644 drivers/i3c/master/Makefile create mode 100644 include/linux/i3c/ccc.h create mode 100644 include/linux/i3c/device.h create mode 100644 include/linux/i3c/master.h
drivers/Kconfig +2 -0
@@ -57,6 +57,8 @@ source "drivers/char/Kconfig" source "drivers/i2c/Kconfig" +source "drivers/i3c/Kconfig" + source "drivers/spi/Kconfig" source "drivers/spmi/Kconfig"
drivers/Makefile +1 -1
@@ -111,7 +111,7 @@ obj-$(CONFIG_SERIO) += input/serio/ obj-$(CONFIG_GAMEPORT) += input/gameport/ obj-$(CONFIG_INPUT) += input/ obj-$(CONFIG_RTC_LIB) += rtc/ -obj-y += i2c/ media/ +obj-y += i2c/ i3c/ media/ obj-$(CONFIG_PPS) += pps/ obj-y += ptp/ obj-$(CONFIG_W1) += w1/
drivers/i3c/Kconfig new file +24 -0
@@ -0,0 +1,24 @@ +# SPDX-License-Identifier: GPL-2.0 + +menuconfig I3C + tristate "I3C support" + select I2C + help + I3C is a serial protocol standardized by the MIPI alliance. + + It's supposed to be backward compatible with I2C while providing + support for high speed transfers and native interrupt support + without the need for extra pins. + + The I3C protocol also standardizes the slave device types and is + mainly designed to communicate with sensors. + + If you want I3C support, you should say Y here and also to the + specific driver for your bus adapter(s) below. + + This I3C support can also be built as a module. If so, the module + will be called i3c. + +if I3C +source "drivers/i3c/master/Kconfig" +endif # I3C
drivers/i3c/Makefile new file +4 -0
@@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0 +i3c-y := device.o master.o +obj-$(CONFIG_I3C) += i3c.o +obj-$(CONFIG_I3C) += master/
drivers/i3c/device.c new file +233 -0
233 lines not on this page · raw message
drivers/i3c/internals.h new file +26 -0
@@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) 2018 Cadence Design Systems Inc. +* +* Author: Boris Brezillon <[email protected]> +*/ + +#ifndef I3C_INTERNALS_H +#define I3C_INTERNALS_H + +#include <linux/i3c/master.h> + +extern struct bus_type i3c_bus_type; + +void i3c_bus_normaluse_lock (struct i3c_bus *bus); +void i3c_bus_normaluse_unlock (struct i3c_bus *bus); + +int i3c_dev_do_priv_xfers_locked (struct i3c_dev_desc *dev, +struct i3c_priv_xfer *xfers, +int nxfers); +int i3c_dev_disable_ibi_locked (struct i3c_dev_desc *dev); +int i3c_dev_enable_ibi_locked (struct i3c_dev_desc *dev); +int i3c_dev_request_ibi_locked (struct i3c_dev_desc *dev, +const struct i3c_ibi_setup *req); +void i3c_dev_free_ibi_locked (struct i3c_dev_desc *dev); +#endif /* I3C_INTERNAL_H */
drivers/i3c/master.c new file +2661 -0
2,661 lines not on this page · raw message
drivers/i3c/master/Kconfig new file +0 -0
drivers/i3c/master/Makefile new file +0 -0
include/linux/i3c/ccc.h new file +385 -0
36 lines not on this page · raw message
include/linux/i3c/device.h new file +331 -0
331 lines not on this page · raw message
include/linux/i3c/master.h new file +648 -0
648 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.17.1
Part of the diff is not shown here. View the raw message.
PATCH v10 2/9 docs: driver-api: Add I3C documentation
In reply to Boris BrezillonAdd the I3C documentation describing the protocol, the master driver API and the device driver API.
---
Changes in v10:
- None
Changes in v9:
- Add Arnd's R-b
Changes in v8:
- None
Changes in v7:
- None
Changes in v6:
- Fix typos reported by Randy
- Add Randy's R-b
Changes in v5:
- Remove useless conf.py file
- Add SPDX headers
Changes in v2:
- Moved out of patch "i3c: Add core I3C infrastructure"
- Add link to the I3C spec
- Move rst files in Documentation/driver-api/i3c/
--- .../driver-api/i3c/device-driver-api.rst | 9 + Documentation/driver-api/i3c/index.rst | 11 + .../driver-api/i3c/master-driver-api.rst | 10 + Documentation/driver-api/i3c/protocol.rst | 203 ++++++++++++++++++ Documentation/driver-api/index.rst | 1 + 5 files changed, 234 insertions(+) create mode 100644 Documentation/driver-api/i3c/device-driver-api.rst create mode 100644 Documentation/driver-api/i3c/index.rst create mode 100644 Documentation/driver-api/i3c/master-driver-api.rst create mode 100644 Documentation/driver-api/i3c/protocol.rst
Documentation/driver-api/i3c/device-driver-api.rst new file +9 -0
@@ -0,0 +1,9 @@ +.. SPDX-License-Identifier: GPL-2.0 + +===================== +I3C device driver API +===================== + +.. kernel-doc:: include/linux/i3c/device.h + +.. kernel-doc:: drivers/i3c/device.c
Documentation/driver-api/i3c/index.rst new file +11 -0
@@ -0,0 +1,11 @@ +.. SPDX-License-Identifier: GPL-2.0 + +============= +I3C subsystem +============= + +.. toctree:: + + protocol + device-driver-api + master-driver-api
Documentation/driver-api/i3c/master-driver-api.rst new file +10 -0
@@ -0,0 +1,10 @@ +.. SPDX-License-Identifier: GPL-2.0 + +================================ +I3C master controller driver API +================================ + +.. kernel-doc:: drivers/i3c/master.c + +.. kernel-doc:: include/linux/i3c/master.h +
Documentation/driver-api/i3c/protocol.rst new file +203 -0
203 lines not on this page · raw message
Documentation/driver-api/index.rst +1 -0
@@ -32,6 +32,7 @@ available subsections can be seen below. pci spi i2c + i3c/index hsi edac scsi
Signature · 1 line
2.17.1
PATCH v10 3/9 i3c: Add sysfs ABI spec
In reply to Boris BrezillonDocument sysfs files/directories/symlinks exposed by the I3C subsystem.
---
Changes in v10:
- None
Changes in v9:
- Add Arnd's R-b
Changes in v8:
- None
Changes in v7:
- Bump KernelVersion to 4.20
- Add new entries under i3c-<bus-id> now that the master controller is no longer represented as a device under this directory but implicitly represented by the bus object
Changes in v6:
- none
Changes in v5:
- Fix the kernel version
- Rename address into dynamic_address to match changes done in the code
Changes in v4:
- none
Changes in v3:
- none
Changes in v2:
- new patch
--- Documentation/ABI/testing/sysfs-bus-i3c | 146 ++++++++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-bus-i3c
Documentation/ABI/testing/sysfs-bus-i3c new file +146 -0
@@ -0,0 +1,146 @@ +What: /sys/bus/i3c/devices/i3c-<bus-id> +KernelVersion: 4.20 +Contact: [email protected] +Description: + An I3C bus. This directory will contain one sub-directory per + I3C device present on the bus. + +What: /sys/bus/i3c/devices/i3c-<bus-id>/current_master +KernelVersion: 4.20 +Contact: [email protected] +Description: + Expose the master that owns the bus (<bus-id>-<master-pid>) at + the time this file is read. Note that bus ownership can change + overtime, so there's no guarantee that when the read() call + returns, the value returned is still valid. + +What: /sys/bus/i3c/devices/i3c-<bus-id>/mode +KernelVersion: 4.20 +Contact: [email protected] +Description: + I3C bus mode. Can be "pure", "mixed-fast" or "mixed-slow". See + the I3C specification for a detailed description of what each + of these modes implies. + +What: /sys/bus/i3c/devices/i3c-<bus-id>/i3c_scl_frequency +KernelVersion: 4.20 +Contact: [email protected] +Description: + The frequency (expressed in Hz) of the SCL signal when + operating in I3C SDR mode. + +What: /sys/bus/i3c/devices/i3c-<bus-id>/i2c_scl_frequency +KernelVersion: 4.20 +Contact: [email protected] +Description: + The frequency (expressed in Hz) of the SCL signal when + operating in I2C mode. + +What: /sys/bus/i3c/devices/i3c-<bus-id>/dynamic_address +KernelVersion: 4.20 +Contact: [email protected] +Description: + Dynamic address assigned to the master controller. This + address may change if the bus is re-initialized. + +What: /sys/bus/i3c/devices/i3c-<bus-id>/bcr +KernelVersion: 4.20 +Contact: [email protected] +Description: + BCR stands for Bus Characteristics Register and express the + device capabilities in term of speed, maximum read/write + length, etc. See the I3C specification for more details. + This entry describes the BCR of the master controller driving + the bus. + +What: /sys/bus/i3c/devices/i3c-<bus-id>/dcr +KernelVersion: 4.20 +Contact: [email protected] +Description: + DCR stands for Device Characteristics Register and express the + device capabilities in term of exposed features. See the I3C + specification for more details. + This entry describes the DCR of the master controller driving + the bus. + +What: /sys/bus/i3c/devices/i3c-<bus-id>/pid +KernelVersion: 4.20 +Contact: [email protected] +Description: + PID stands for Provisional ID and is used to uniquely identify + a device on a bus. This PID contains information about the + vendor, the part and an instance ID so that several devices of + the same type can be connected on the same bus. + See the I3C specification for more details. + This entry describes the PID of the master controller driving + the bus. + +What: /sys/bus/i3c/devices/i3c-<bus-id>/hdrcap +KernelVersion: 4.20 +Contact: [email protected] +Description: + Expose the HDR (High Data Rate) capabilities of a device. + Returns a list of supported HDR mode, each element is separated + by space. Modes can be "hdr-ddr", "hdr-tsp" and "hdr-tsl". + See the I3C specification for more details about these HDR + modes. + This entry describes the HDRCAP of the master controller + driving the bus. + +What: /sys/bus/i3c/devices/i3c-<bus-id>/<bus-id>-<device-pid> +KernelVersion: 4.20 +Contact: [email protected] +Description: + An I3C device present on I3C bus identified by <bus-id>. Note + that all devices are represented including the master driving + the bus. + +What: /sys/bus/i3c/devices/i3c-<bus-id>/<bus-id>-<device-pid>/dynamic_address +KernelVersion: 4.20 +Contact: [email protected] +Description: + Dynamic address assigned to device <bus-id>-<device-pid>. This + address may change if the bus is re-initialized. + +What: /sys/bus/i3c/devices/i3c-<bus-id>/<bus-id>-<device-pid>/bcr +KernelVersion: 4.20 +Contact: [email protected] +Description: + BCR stands for Bus Characteristics Register and express the + device capabilities in term of speed, maximum read/write + length, etc. See the I3C specification for more details. + +What: /sys/bus/i3c/devices/i3c-<bus-id>/<bus-id>-<device-pid>/dcr +KernelVersion: 4.20 +Contact: [email protected] +Description: + DCR stands for Device Characteristics Register and express the + device capabilities in term of exposed features. See the I3C + specification for more details. + +What: /sys/bus/i3c/devices/i3c-<bus-id>/<bus-id>-<device-pid>/pid +KernelVersion: 4.20 +Contact: [email protected] +Description: + PID stands for Provisional ID and is used to uniquely identify + a device on a bus. This PID contains information about the + vendor, the part and an instance ID so that several devices of + the same type can be connected on the same bus. + See the I3C specification for more details. + +What: /sys/bus/i3c/devices/i3c-<bus-id>/<bus-id>-<device-pid>/hdrcap +KernelVersion: 4.20 +Contact: [email protected] +Description: + Expose the HDR (High Data Rate) capabilities of a device. + Returns a list of supported HDR mode, each element is separated + by space. Modes can be "hdr-ddr", "hdr-tsp" and "hdr-tsl". + See the I3C specification for more details about these HDR + modes. + +What: /sys/bus/i3c/devices/<bus-id>-<device-pid> +KernelVersion: 4.20 +Contact: [email protected] +Description: + These directories are just symbolic links to + /sys/bus/i3c/devices/i3c-<bus-id>/<bus-id>-<device-pid>.
Signature · 1 line
2.17.1
PATCH v10 4/9 dt-bindings: i3c: Document core bindings
In reply to Boris BrezillonA new I3C subsystem has been added and a generic description has been created to represent the I3C bus and the devices connected on it.
Document this generic representation.
---
Changes in v10:
- Fix mistakes in the example (reported by Rob)
Changes in v9:
- Rework the way we encode the I2C vs I3C device in the reg property so that we don't need the funky macros to define and I3C or I2C dev
- Drop Rob's Reviewed-by
Changes in v8:
- None
Changes in v7:
- None
Changes in v6:
- None
Changes in v5:
- Add Rob's R-b
Changes in v4:
- Clarify the fact that static address == I3C address and dynamic address == I3C address
- Use i2c-scl-hz in the example
Changes in v3:
- Rename {i2c,i3c}-scl-frequency DT prop into {i2c,i3c}-scl-hz
- Rework the way we expose the provisional ID and LVR information
- Rename dynamic-address into assigned-address
- Enforce the I3C master node name
Changes in v2:
- Define how to describe I3C devices in the DT and when it should be used. Note that the parsing of I3C devices is not yet implemented in the framework. Will be added when someone really needs it.
--- Documentation/devicetree/bindings/i3c/i3c.txt | 139 ++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 Documentation/devicetree/bindings/i3c/i3c.txt
Documentation/devicetree/bindings/i3c/i3c.txt new file +139 -0
@@ -0,0 +1,139 @@ +Generic device tree bindings for I3C busses +=========================================== + +This document describes generic bindings that should be used to describe I3C +busses in a device tree. + +Required properties +------------------- + +- #address-cells - should be <3>. Read more about addresses below. +- #size-cells - should be <0>. +- compatible - name of the I3C master controller driving the I3C bus + +For other required properties e.g. to describe register sets, +clocks, etc. check the binding documentation of the specific driver. +The node describing an I3C bus should be named i3c-master. + +Optional properties +------------------- + +These properties may not be supported by all I3C master drivers. Each I3C +master bindings should specify which of them are supported. + +- i3c-scl-hz: frequency of the SCL signal used for I3C transfers. + When undefined the core sets it to 12.5MHz. + +- i2c-scl-hz: frequency of the SCL signal used for I2C transfers. + When undefined, the core looks at LVR (Legacy Virtual Register) + values of I2C devices described in the device tree to determine + the maximum I2C frequency. + +I2C devices +=========== + +Each I2C device connected to the bus should be described in a subnode. All +properties described in Documentation/devicetree/bindings/i2c/i2c.txt are +valid here, but several new properties have been added. + +New constraint on existing properties: +-------------------------------------- +- reg: contains 3 cells + + first cell : still encoding the I2C address + + + second cell: shall be 0 + + + third cell: shall encode the I3C LVR (Legacy Virtual Register) + bit[31:8]: unused/ignored + bit[7:5]: I2C device index. Possible values + * 0: I2C device has a 50 ns spike filter + * 1: I2C device does not have a 50 ns spike filter but supports high + frequency on SCL + * 2: I2C device does not have a 50 ns spike filter and is not tolerant + to high frequencies + * 3-7: reserved + + bit[4]: tell whether the device operates in FM (Fast Mode) or FM+ mode + * 0: FM+ mode + * 1: FM mode + + bit[3:0]: device type + * 0-15: reserved + +The I2C node unit-address should always match the first cell of the reg +property: <device-type>@<i2c-address>. + +I3C devices +=========== + +All I3C devices are supposed to support DAA (Dynamic Address Assignment), and +are thus discoverable. So, by default, I3C devices do not have to be described +in the device tree. +This being said, one might want to attach extra resources to these devices, +and those resources may have to be described in the device tree, which in turn +means we have to describe I3C devices. + +Another use case for describing an I3C device in the device tree is when this +I3C device has a static I2C address and we want to assign it a specific I3C +dynamic address before the DAA takes place (so that other devices on the bus +can't take this dynamic address). + +The I3C device should be names <device-type>@<static-i2c-address>,<i3c-pid>, +where device-type is describing the type of device connected on the bus +(gpio-controller, sensor, ...). + +Required properties +------------------- +- reg: contains 3 cells + + first cell : encodes the static I2C address. Should be 0 if the device does + not have one (0 is not a valid I2C address). + + + second and third cells: should encode the ProvisionalID. The second cell + contains the manufacturer ID left-shifted by 1. + The third cell contains ORing of the part ID + left-shifted by 16, the instance ID left-shifted + by 12 and the extra information. This encoding is + following the PID definition provided by the I3C + specification. + +Optional properties +------------------- +- assigned-address: dynamic address to be assigned to this device. This + property is only valid if the I3C device has a static + address (first cell of the reg property != 0). + + +Example: + + i3c-master@d040000 { + compatible = "cdns,i3c-master"; + clocks = <&coreclock>, <&i3csysclock>; + clock-names = "pclk", "sysclk"; + interrupts = <3 0>; + reg = <0x0d040000 0x1000>; + #address-cells = <3>; + #size-cells = <0>; + i2c-scl-hz = <100000>; + + /* I2C device. */ + nunchuk: nunchuk@52 { + compatible = "nintendo,nunchuk"; + reg = <0x52 0x0 0x10>; + }; + + /* I3C device with a static I2C address. */ + thermal_sensor: sensor@68,39200144004 { + reg = <0x68 0x392 0x144004>; + assigned-address = <0xa>; + }; + + /* + * I3C device without a static I2C address but requiring + * resources described in the DT. + */ + sensor@0,39200154004 { + reg = <0x0 0x392 0x154004>; + clocks = <&clock_provider 0>; + }; + }; +
Signature · 1 line
2.17.1
Re: [PATCH v10 4/9] dt-bindings: i3c: Document core bindings
Quoted 39 lines · Boris Brezillon
A new I3C subsystem has been added and a generic description has been created to represent the I3C bus and the devices connected on it.
Document this generic representation.
Cc Rob Herring <[email protected]>Signed-off-by Boris Brezillon <[email protected]>---
Changes in v10:
- Fix mistakes in the example (reported by Rob)Changes in v9:
- Rework the way we encode the I2C vs I3C device in the reg property so that we don't need the funky macros to define and I3C or I2C dev
- Drop Rob's Reviewed-byChanges in v8:
- NoneChanges in v7:
- NoneChanges in v6:
- NoneChanges in v5:
- Add Rob's R-bChanges in v4:
- Clarify the fact that static address == I3C address and dynamic address == I3C address
- Use i2c-scl-hz in the exampleChanges in v3:
- Rename {i2c,i3c}-scl-frequency DT prop into {i2c,i3c}-scl-hz
- Rework the way we expose the provisional ID and LVR information
- Rename dynamic-address into assigned-address
- Enforce the I3C master node name
Quoted 9 lines
Changes in v2:
- Define how to describe I3C devices in the DT and when it should be used. Note that the parsing of I3C devices is not yet implemented in the framework. Will be added when someone really needs it.--- Documentation/devicetree/bindings/i3c/i3c.txt | 139 ++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 Documentation/devicetree/bindings/i3c/i3c.txt
PATCH v10 5/9 MAINTAINERS: Add myself as the I3C subsystem maintainer
In reply to Boris BrezillonCreate an entry for the I3C subsystem and mark it as maintained by me. There's no official git repository, patchwork instance, mailing list or website yet, but this will be added after the subsystem has been accepted.
---
Changes in v10:
- None
Changes in v9:
- None
Changes in v8:
- None
Changes in v7:
- Add a ML (not created yet) and a git repo
Changes in v5:
- Add the sysfs ABI file
--- MAINTAINERS | 12 ++++++++++++ 1 file changed, 12 insertions(+)
MAINTAINERS +12 -0
@@ -6918,6 +6918,18 @@ L: [email protected] S: Maintained F: drivers/i2c/i2c-stub.c +I3C SUBSYSTEM +M: Boris Brezillon <[email protected]> +L: [email protected] +T: git git://git.kernel.org/pub/scm/linux/kernel/git/i3c/linux.git +S: Maintained +F: Documentation/ABI/testing/sysfs-bus-i3c +F: Documentation/devicetree/bindings/i3c/ +F: Documentation/driver-api/i3c +F: drivers/i3c/ +F: include/linux/i3c/ +F: include/dt-bindings/i3c/ + IA64 (Itanium) PLATFORM M: Tony Luck <[email protected]> M: Fenghua Yu <[email protected]>
Signature · 1 line
2.17.1
PATCH v10 6/9 i3c: master: Add driver for Cadence IP
In reply to Boris BrezillonAdd a driver for Cadence I3C master IP.
---
Changes in v10:
- None
Changes in v9:
- Change the 'depends on' rule (suggested by Arnd)
- Use {read,write}sl() instead of __raw_{readl,writem}() (suggested by Arnd)
- Add Arnd's R-b
Changes in v8:
- Adjust code to match changes done in the core (bus embedded in master)
Changes in v7:
- Fix readsl/writesl() usage
- Add a depends on ARM || ARM64 || XTENSA to forbid selection of this driver on platforms that are not implementing readsl/writesl
Changes in v6:
- Rework the attach/detach logic to match the new way of doing things.
- Use kcalloc() where appropriate
- Simplfy access to the RX/TX/IBI_DATA FIFOs
Changes in v5:
- Drop unused len var in cdns_i3c_master_handle_ibi()
- Get IBIR and CMDR depth from CONF_STATUS0
- s/2017/2018/ in copyright header
- Fix coding style issues
Changes in v4:
- Fix potential unsigned integer underflow
- Add missing static specific on IBI related functions
Changes in v3:
- Adjust to match I3C framework changes
- Implement support the CMD RESPONSE QUEUE and IBI QUEUE added in the latest revision of Cadence master IP
- Remove support for HDR modes
Changes in v2:
- Add basic IBI support. Note that the IP is not really reliable with regards to IBI because you can't extract IBI payloads as soon as you have more than one IBI waiting in the HW queue. This is something that will hopefully be addressed in future revisions of this IP
- Add a simple xfer queueing mechanism to optimize message queuing.
- Fix a few bugs
- Add support for Hot Join
--- drivers/i3c/master/Kconfig | 6 + drivers/i3c/master/Makefile | 1 + drivers/i3c/master/i3c-master-cdns.c | 1671 ++++++++++++++++++++++++++ 3 files changed, 1678 insertions(+) create mode 100644 drivers/i3c/master/i3c-master-cdns.c
drivers/i3c/master/Kconfig +6 -0
@@ -0,0 +1,6 @@ +config CDNS_I3C_MASTER + tristate "Cadence I3C master driver" + depends on I3C + depends on !(ALPHA || PARISC) + help + Enable this driver if you want to support Cadence I3C master block.
drivers/i3c/master/Makefile +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_CDNS_I3C_MASTER) += i3c-master-cdns.o
drivers/i3c/master/i3c-master-cdns.c new file +1671 -0
1,671 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v10 7/9 dt-bindings: i3c: Document Cadence I3C master bindings
In reply to Boris BrezillonDocument Cadence I3C master DT bindings.
---
Changes in v10:
- None
Changes in v9:
- Add Arnd's R-b
Changes in v8:
- None
Changes in v7:
- None
Changes in v6:
- None
Changes in v5:
- Add Rob's R-b
Changes in v4:
- Fix example to match the new representation
--- .../bindings/i3c/cdns,i3c-master.txt | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 Documentation/devicetree/bindings/i3c/cdns,i3c-master.txt
Documentation/devicetree/bindings/i3c/cdns,i3c-master.txt new file +44 -0
@@ -0,0 +1,44 @@ +Bindings for cadence I3C master block +===================================== + +Required properties: +-------------------- +- compatible: shall be "cdns,i3c-master" +- clocks: shall reference the pclk and sysclk +- clock-names: shall contain "pclk" and "sysclk" +- interrupts: the interrupt line connected to this I3C master +- reg: I3C master registers + +Mandatory properties defined by the generic binding (see +Documentation/devicetree/bindings/i3c/i3c.txt for more details): + +- #address-cells: shall be set to 1 +- #size-cells: shall be set to 0 + +Optional properties defined by the generic binding (see +Documentation/devicetree/bindings/i3c/i3c.txt for more details): + +- i2c-scl-hz +- i3c-scl-hz + +I3C device connected on the bus follow the generic description (see +Documentation/devicetree/bindings/i3c/i3c.txt for more details). + +Example: + + i3c-master@0d040000 { + compatible = "cdns,i3c-master"; + clocks = <&coreclock>, <&i3csysclock>; + clock-names = "pclk", "sysclk"; + interrupts = <3 0>; + reg = <0x0d040000 0x1000>; + #address-cells = <1>; + #size-cells = <0>; + i2c-scl-hz = <100000>; + + nunchuk: nunchuk@52 { + compatible = "nintendo,nunchuk"; + reg = <0x52 0x80000010 0>; + }; + }; +
Signature · 1 line
2.17.1
PATCH v10 8/9 gpio: Add a driver for Cadence I3C GPIO expander
In reply to Boris BrezillonAdd a driver for Cadence I3C GPIO expander.
---
Changes in v10:
- None
Changes in v9:
- None
Changes in v8:
- None
Changes in v7:
- None
Changes in v6:
- Use kmalloc_array() instead of kmalloc(N * sizeof(X))
- Add Linus' ack
Changes in v5:
- Use the !! operator to return 0 or 1 in cdns_i3c_gpio_get_direction()
- Use a scratch buffer to make sure the buffers passed to i3c_device_do_priv_xfers() are DMA-able
- Fix errors reported by checkpatch
Changes in v4:
- none
Changes in v3:
- new
--- drivers/gpio/Kconfig | 11 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-cdns-i3c.c | 411 +++++++++++++++++++++++++++++++++++ 3 files changed, 423 insertions(+) create mode 100644 drivers/gpio/gpio-cdns-i3c.c
drivers/gpio/Kconfig +11 -0
@@ -908,6 +908,17 @@ config GPIO_TS4900 endmenu +menu "I3C GPIO expanders" + depends on I3C + +config GPIO_CDNS_I3C + tristate "Cadence I3C GPIO expander" + select GPIOLIB_IRQCHIP + help + Say yes here to enabled the driver for Cadence I3C GPIO expander. + +endmenu + menu "MFD GPIO expanders" config GPIO_ADP5520
drivers/gpio/Makefile +1 -0
@@ -37,6 +37,7 @@ obj-$(CONFIG_GPIO_BCM_KONA) += gpio-bcm-kona.o obj-$(CONFIG_GPIO_BD9571MWV) += gpio-bd9571mwv.o obj-$(CONFIG_GPIO_BRCMSTB) += gpio-brcmstb.o obj-$(CONFIG_GPIO_BT8XX) += gpio-bt8xx.o +obj-$(CONFIG_GPIO_CDNS_I3C) += gpio-cdns-i3c.o obj-$(CONFIG_GPIO_CLPS711X) += gpio-clps711x.o obj-$(CONFIG_GPIO_CS5535) += gpio-cs5535.o obj-$(CONFIG_GPIO_CRYSTAL_COVE) += gpio-crystalcove.o
drivers/gpio/gpio-cdns-i3c.c new file +411 -0
411 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v10 9/9 dt-bindings: gpio: Add bindings for Cadence I3C gpio expander
In reply to Boris BrezillonDocument the Cadence I3C gpio expander bindings.
---
Changes in v10:
- None
Changes in v9:
- Add Linus R-b
Changes in v8:
- None
Changes in v7:
- None
Changes in v6:
- None
Changes in v5:
- Add Rob's R-b
Changes in v4:
- Use GPIO_ and IRQ_TYPE_ macros instead of raw numbers
- Fix the unit-address in the example
--- .../bindings/gpio/gpio-cdns-i3c.txt | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/gpio-cdns-i3c.txt
Documentation/devicetree/bindings/gpio/gpio-cdns-i3c.txt new file +39 -0
@@ -0,0 +1,39 @@ +* Cadence I3C GPIO expander + +The Cadence I3C GPIO expander provides 8 GPIOs controllable over I3C. +This GPIOs can be configured in output or input mode and if they are in input +mode they can generate IBIs (In Band Interrupts). + +Required properties for GPIO node: +- reg : 3 cells encoding the I3C static address (none in our case) and the I3C + Provisional ID. See Documentation/devicetree/bindings/i3c/i3c.txt for + more details. + Should be <0x0 0x392 0x0>. +- gpio-controller : Marks the device node as a gpio controller. +- #gpio-cells : Should be two. The first cell is the pin number and + the second cell is used to specify the gpio polarity (GPIO_ACTIVE_HIGH or + GPIO_ACTIVE_LOW) +- interrupt-controller: Marks the device node as an interrupt controller. +- #interrupt-cells : Should be 2. The first cell is the GPIO number. + The second cell is used to specify trigger type and level flags. + The following trigger types are accepted (see + <dt-bindings/interrupt-controller/irq.h> for their definition): + IRQ_TYPE_EDGE_RISING + IRQ_TYPE_EDGE_FALLING + IRQ_TYPE_EDGE_BOTH + IRQ_TYPE_LEVEL_HIGH + IRQ_TYPE_LEVEL_LOW + +Example: + + i3c-master@xxx { + ... + i3c_gpio_expander: gpio@0,39200000000 { + reg = <0 0x392 0x0>; + gpio-controller; + #gpio-cells = <2>; + interrupt-controller; + #interrupt-cells = <2>; + }; + ... + };
Signature · 1 line
2.17.1
Hi Boris,
Quoted 185 lines · Boris Brezillon
Hi Greg,
I think we've reached a point where we can eventually consider the I3C framework for inclusion in 4.20 (5.0?). A few more issues were reported on v9 and fixed in v10. I can't guarantee that the implementation is free of bugs but I still think it's worth merging it in v4.20: it's a new subsystem, so we don't risk regressions, and the only way we can detect other issues is by having other people experiment with this implementation.
The only remaining concern raised by Arnd is the fact that both hosts and slaves share the same bus type and are differentiated thanks to their
device_type, which IMHO is fine since this is what other subsystems do (plus I don't see other solutions to have both I3C devices and I3C buses represented under/sys/bus/i3c/).I'd really like to get this series merged in 4.20 so that other contributors can work on top of it to add
1/ new host drivers
2/ support for advanced features
3/ new device driversSo, unless you have strong reasons to reject this request, and, assuming I get Rob's ack soon enough, I plan to send a PR for this framework next week.
Here is the usual description copy&pasted from the previous versions:
This patch series is adding a new subsystem to support I3C devices.
This is just adding support for basic features. Extra features will be added afterwards.
There are a few design choices that are worth mentioning because they impact the way I3C device drivers can interact with their devices:
- all functions used to send I3C/I2C frames must be called in non-atomic context. Mainly done this way to ease implementation, but this is still open to discussion. Please let me know if you think it's worth considering an asynchronous model here
- the I3C bus and I3C master controller are now tightly coupled even though they're still allocated separately. There's now a 1:1 relationship between these objects, and the I3C master is no longer represented under the I3C bus object.
Arnd, let me know if you had something different in mind, and I'll rework the implementation accordingly.- I2C backward compatibility has been designed to be transparent to I2C drivers and the I2C subsystem. The I3C master just registers an I2C adapter which creates a new I2C bus. I'd say that, from a representation PoV it's not ideal because what should appear as a single I3C bus exposing I3C and I2C devices here appears as 2 different busses connected to each other through the parenting (the I3C master is the parent of the I2C and I3C busses).
On the other hand, I don't see a better solution if we want something that is not invasive.Missing features (will be added in separate patch series after initial support has been accepted/merged):
- support for HDR modes (has been removed because of lack of real users)
- no support for multi-master and the associated concepts (mastership handover, support for secondary masters, ...)
- I2C devices can only be described using DT because this is the only use case I have. However, the framework can easily be extended with ACPI and board info support
- I3C slave framework. This has been completely omitted, but shouldn't have a huge impact on the I3C framework because I3C slaves don't see the whole bus, it's only about handling master requests and generating IBIs. Some of the struct, constant and enum definitions could be shared, but most of the I3C slave framework logic will be differentNote that this patchset is available on the linux-i3c repo[1].
Main change between v8 and v9:
- The DT bindings have been simplified to get rid of the I3C/I3C_DEV() macrosMain change between v7 and v8:
- The bus object is now embedded in themaster_controllerobject (as suggested by Arnd)Main changes between v6 and v7:
- I3C bus/master representations have been reworked to match what other subsystems are doing (master implicitly represented by the bus object)
- I3C dev registration has been fixed
- I3C bus mode selection has been fixed
- Calls to readsl/writesl() in the Cadence I3C master driver have been fixedMain changes between v5 and v6:
- Introduce {i3c,i2c}_dev_desc structures to better match how I3C master controllers (reservation of one HW slot for each device attached to the bus). With this solution, the resource migration that happens when a device lose its dynamic address and is re-assigned a different address is simplified on the driver side, because most of it is now handled in the core (reserve a new dev slot, reserve IBI resources and free all resources attached to the old slot)
- Add I3C error codes (M0 to M2) so that the core and device drivers can have fine grained information on what caused an EIO error.Only minor things happened between v3 and v5 (you can go check the changelog in each patch for more details).
Main changes between v2 and v3 are:
- Reworked the DT bindings as suggested by Rob
- Reworked the bus initialization step as suggested by Vitor
- Added a driver for an I3C GPIO expanderMain changes between the initial RFC and this v2 are:
- Add a generic infrastructure to support IBIs. It's worth mentioning that I tried exposing IBIs as a regular IRQs, but after several attempts and a discussion with Mark Zyngier, it appeared that it was not really fitting in the Linux IRQ model (the fact that you have payload attached to IBIs, the fact that most of the time an IBI will generate a transfer on the bus which has to be done in an atomic context, ...)
The counterpart of this decision is the latency induced by the workqueue approach, but since I don't have real use cases, I don't know if this can be a problem or not.
- Add helpers to support Hot Join
- Add support for IBIs and Hot Join in Cadence I3C master driver
- Address several issues in how I was using the device modelThanks,
Boris
*** BLURB HERE ***
Boris Brezillon (9):
i3c: Add core I3C infrastructure
docs: driver-api: Add I3C documentation
i3c: Add sysfs ABI spec
dt-bindings: i3c: Document core bindings
MAINTAINERS: Add myself as the I3C subsystem maintainer
i3c: master: Add driver for Cadence IP
dt-bindings: i3c: Document Cadence I3C master bindings
gpio: Add a driver for Cadence I3C GPIO expander
dt-bindings: gpio: Add bindings for Cadence I3C gpio expanderDocumentation/ABI/testing/sysfs-bus-i3c | 146 + .../bindings/gpio/gpio-cdns-i3c.txt | 39 + .../bindings/i3c/cdns,i3c-master.txt | 44 + Documentation/devicetree/bindings/i3c/i3c.txt | 139 + .../driver-api/i3c/device-driver-api.rst | 9 + Documentation/driver-api/i3c/index.rst | 11 + .../driver-api/i3c/master-driver-api.rst | 10 + Documentation/driver-api/i3c/protocol.rst | 203 ++ Documentation/driver-api/index.rst | 1 + MAINTAINERS | 12 + drivers/Kconfig | 2 + drivers/Makefile | 2 +- drivers/gpio/Kconfig | 11 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-cdns-i3c.c | 411 +++ drivers/i3c/Kconfig | 24 + drivers/i3c/Makefile | 4 + drivers/i3c/device.c | 233 ++ drivers/i3c/internals.h | 26 + drivers/i3c/master.c | 2661 +++++++++++++++++ drivers/i3c/master/Kconfig | 6 + drivers/i3c/master/Makefile | 1 + drivers/i3c/master/i3c-master-cdns.c | 1671 +++++++++++ include/linux/i3c/ccc.h | 385 +++ include/linux/i3c/device.h | 331 ++ include/linux/i3c/master.h | 648 ++++ include/linux/mod_devicetable.h | 17 + 27 files changed, 7047 insertions(+), 1 deletion(-)create mode 100644
Documentation/ABI/testing/sysfs-bus-i3ccreate mode 100644Documentation/devicetree/bindings/gpio/gpio-cdns-i3c.txtcreate mode 100644Documentation/devicetree/bindings/i3c/cdns,i3c-master.txtcreate mode 100644Documentation/devicetree/bindings/i3c/i3c.txtcreate mode 100644Documentation/driver-api/i3c/device-driver-api.rstcreate mode 100644Documentation/driver-api/i3c/index.rstcreate mode 100644Documentation/driver-api/i3c/master-driver-api.rstcreate mode 100644Documentation/driver-api/i3c/protocol.rstcreate mode 100644drivers/gpio/gpio-cdns-i3c.c
create mode 100644drivers/i3c/Kconfig
create mode 100644drivers/i3c/Makefile
create mode 100644drivers/i3c/device.c
Quoted 9 lines
create mode 100644
drivers/i3c/internals.hcreate mode 100644drivers/i3c/master.c
create mode 100644drivers/i3c/master/Kconfigcreate mode 100644drivers/i3c/master/Makefilecreate mode 100644drivers/i3c/master/i3c-master-cdns.ccreate mode 100644include/linux/i3c/ccc.hcreate mode 100644include/linux/i3c/device.hcreate mode 100644include/linux/i3c/master.h
Can you update the i3c/next tree?
Best regards,
Vitor Soares
Quoted 1 line · On Fri, 26 Oct 2018 16:22:06 +0100 vitor <[email protected]> wrote:
Can you update the i3c/next tree?
Done.
Quoted 5 lines · Boris Brezillon
Quoted 1 line · On Fri, 26 Oct 2018 16:22:06 +0100 vitor <[email protected]> wrote:
Can you update the i3c/next tree?
Done.
Thanks.
I will apply the driver and them I give you feedback.
Quoted 10 lines · On Fri, 26 Oct 2018 17:20:42 +0100 vitor <[email protected]> wrote:
Quoted 5 lines · Boris Brezillon
Quoted 1 line · On Fri, 26 Oct 2018 16:22:06 +0100 vitor <[email protected]> wrote:
Can you update the i3c/next tree?
Done.
Thanks.
I will apply the driver and them I give you feedback.
Great! Note that the bug in the ->send_ccc_cmd() path should be fixed, but you might have issues with i2c transfers as msg->buf is not guaranteed to be aligned on 32-bit.
Don't know if you've followed the discussion with Arnd, but it seems some (most?) archs are making sure writesl()/readsl() work for unaligned bufs. Maybe we should fix that for ARC. The other solution is to use i2c_get_dma_safe_msg_buf() to get something aligned on a cache-line and by extension aligned on 32bits.
Quoted 72 lines · On Fri, 26 Oct 2018 16:43:24 +0200 Boris Brezillon…
Hi Greg,
I think we've reached a point where we can eventually consider the I3C framework for inclusion in 4.20 (5.0?). A few more issues were reported on v9 and fixed in v10. I can't guarantee that the implementation is free of bugs but I still think it's worth merging it in v4.20: it's a new subsystem, so we don't risk regressions, and the only way we can detect other issues is by having other people experiment with this implementation.
The only remaining concern raised by Arnd is the fact that both hosts and slaves share the same bus type and are differentiated thanks to their
device_type, which IMHO is fine since this is what other subsystems do (plus I don't see other solutions to have both I3C devices and I3C buses represented under/sys/bus/i3c/).I'd really like to get this series merged in 4.20 so that other contributors can work on top of it to add
1/ new host drivers
2/ support for advanced features
3/ new device driversSo, unless you have strong reasons to reject this request, and, assuming I get Rob's ack soon enough, I plan to send a PR for this framework next week.
Here is the usual description copy&pasted from the previous versions:
This patch series is adding a new subsystem to support I3C devices.
This is just adding support for basic features. Extra features will be added afterwards.
There are a few design choices that are worth mentioning because they impact the way I3C device drivers can interact with their devices:
- all functions used to send I3C/I2C frames must be called in non-atomic context. Mainly done this way to ease implementation, but this is still open to discussion. Please let me know if you think it's worth considering an asynchronous model here
- the I3C bus and I3C master controller are now tightly coupled even though they're still allocated separately. There's now a 1:1 relationship between these objects, and the I3C master is no longer represented under the I3C bus object.
Arnd, let me know if you had something different in mind, and I'll rework the implementation accordingly.- I2C backward compatibility has been designed to be transparent to I2C drivers and the I2C subsystem. The I3C master just registers an I2C adapter which creates a new I2C bus. I'd say that, from a representation PoV it's not ideal because what should appear as a single I3C bus exposing I3C and I2C devices here appears as 2 different busses connected to each other through the parenting (the I3C master is the parent of the I2C and I3C busses).
On the other hand, I don't see a better solution if we want something that is not invasive.Missing features (will be added in separate patch series after initial support has been accepted/merged):
- support for HDR modes (has been removed because of lack of real users)
- no support for multi-master and the associated concepts (mastership handover, support for secondary masters, ...)
- I2C devices can only be described using DT because this is the only use case I have. However, the framework can easily be extended with ACPI and board info support
- I3C slave framework. This has been completely omitted, but shouldn't have a huge impact on the I3C framework because I3C slaves don't see the whole bus, it's only about handling master requests and generating IBIs. Some of the struct, constant and enum definitions could be shared, but most of the I3C slave framework logic will be different
Quoted 2 lines
Note that this patchset is available on the linux-i3c repo[1].
Forgot to add:
Main changes between v9 and v10:
- Fix the example in the DT bindings file
- Dynamically allocate CCC payloads to make them DMA-safe
- Fix a deadlock
- Mention that i2c bufs are not guaranteed to be DMA-safe
Quoted 120 lines
Main change between v8 and v9:
- The DT bindings have been simplified to get rid of the I3C/I3C_DEV() macrosMain change between v7 and v8:
- The bus object is now embedded in themaster_controllerobject (as suggested by Arnd)Main changes between v6 and v7:
- I3C bus/master representations have been reworked to match what other subsystems are doing (master implicitly represented by the bus object)
- I3C dev registration has been fixed
- I3C bus mode selection has been fixed
- Calls to readsl/writesl() in the Cadence I3C master driver have been fixedMain changes between v5 and v6:
- Introduce {i3c,i2c}_dev_desc structures to better match how I3C master controllers (reservation of one HW slot for each device attached to the bus). With this solution, the resource migration that happens when a device lose its dynamic address and is re-assigned a different address is simplified on the driver side, because most of it is now handled in the core (reserve a new dev slot, reserve IBI resources and free all resources attached to the old slot)
- Add I3C error codes (M0 to M2) so that the core and device drivers can have fine grained information on what caused an EIO error.Only minor things happened between v3 and v5 (you can go check the changelog in each patch for more details).
Main changes between v2 and v3 are:
- Reworked the DT bindings as suggested by Rob
- Reworked the bus initialization step as suggested by Vitor
- Added a driver for an I3C GPIO expanderMain changes between the initial RFC and this v2 are:
- Add a generic infrastructure to support IBIs. It's worth mentioning that I tried exposing IBIs as a regular IRQs, but after several attempts and a discussion with Mark Zyngier, it appeared that it was not really fitting in the Linux IRQ model (the fact that you have payload attached to IBIs, the fact that most of the time an IBI will generate a transfer on the bus which has to be done in an atomic context, ...)
The counterpart of this decision is the latency induced by the workqueue approach, but since I don't have real use cases, I don't know if this can be a problem or not.
- Add helpers to support Hot Join
- Add support for IBIs and Hot Join in Cadence I3C master driver
- Address several issues in how I was using the device modelThanks,
Boris
[1]https://git.kernel.org/pub/scm/linux/kernel/git/i3c/linux.git/log/?h=i3c/next
*** BLURB HERE ***
Boris Brezillon (9):
i3c: Add core I3C infrastructure
docs: driver-api: Add I3C documentation
i3c: Add sysfs ABI spec
dt-bindings: i3c: Document core bindings
MAINTAINERS: Add myself as the I3C subsystem maintainer
i3c: master: Add driver for Cadence IP
dt-bindings: i3c: Document Cadence I3C master bindings
gpio: Add a driver for Cadence I3C GPIO expander
dt-bindings: gpio: Add bindings for Cadence I3C gpio expanderDocumentation/ABI/testing/sysfs-bus-i3c | 146 + .../bindings/gpio/gpio-cdns-i3c.txt | 39 + .../bindings/i3c/cdns,i3c-master.txt | 44 + Documentation/devicetree/bindings/i3c/i3c.txt | 139 + .../driver-api/i3c/device-driver-api.rst | 9 + Documentation/driver-api/i3c/index.rst | 11 + .../driver-api/i3c/master-driver-api.rst | 10 + Documentation/driver-api/i3c/protocol.rst | 203 ++ Documentation/driver-api/index.rst | 1 + MAINTAINERS | 12 + drivers/Kconfig | 2 + drivers/Makefile | 2 +- drivers/gpio/Kconfig | 11 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-cdns-i3c.c | 411 +++ drivers/i3c/Kconfig | 24 + drivers/i3c/Makefile | 4 + drivers/i3c/device.c | 233 ++ drivers/i3c/internals.h | 26 + drivers/i3c/master.c | 2661 +++++++++++++++++ drivers/i3c/master/Kconfig | 6 + drivers/i3c/master/Makefile | 1 + drivers/i3c/master/i3c-master-cdns.c | 1671 +++++++++++ include/linux/i3c/ccc.h | 385 +++ include/linux/i3c/device.h | 331 ++ include/linux/i3c/master.h | 648 ++++ include/linux/mod_devicetable.h | 17 + 27 files changed, 7047 insertions(+), 1 deletion(-) create mode 100644 Documentation/ABI/testing/sysfs-bus-i3c create mode 100644 Documentation/devicetree/bindings/gpio/gpio-cdns-i3c.txt create mode 100644 Documentation/devicetree/bindings/i3c/cdns,i3c-master.txt create mode 100644 Documentation/devicetree/bindings/i3c/i3c.txt create mode 100644 Documentation/driver-api/i3c/device-driver-api.rst create mode 100644 Documentation/driver-api/i3c/index.rst create mode 100644 Documentation/driver-api/i3c/master-driver-api.rst create mode 100644 Documentation/driver-api/i3c/protocol.rst create mode 100644 drivers/gpio/gpio-cdns-i3c.c create mode 100644 drivers/i3c/Kconfig create mode 100644 drivers/i3c/Makefile create mode 100644 drivers/i3c/device.c create mode 100644 drivers/i3c/internals.h create mode 100644 drivers/i3c/master.c create mode 100644 drivers/i3c/master/Kconfig create mode 100644 drivers/i3c/master/Makefile create mode 100644 drivers/i3c/master/i3c-master-cdns.c create mode 100644 include/linux/i3c/ccc.h create mode 100644 include/linux/i3c/device.h create mode 100644 include/linux/i3c/master.h
Quoted 10 lines · Boris Brezillon
Hi Greg,
I think we've reached a point where we can eventually consider the I3C framework for inclusion in 4.20 (5.0?). A few more issues were reported on v9 and fixed in v10. I can't guarantee that the implementation is free of bugs but I still think it's worth merging it in v4.20: it's a new subsystem, so we don't risk regressions, and the only way we can detect other issues is by having other people experiment with this implementation.
Quoted 5 lines
The only remaining concern raised by Arnd is the fact that both hosts and slaves share the same bus type and are differentiated thanks to their
device_type, which IMHO is fine since this is what other subsystems do (plus I don't see other solutions to have both I3C devices and I3C buses represented under/sys/bus/i3c/).
Yeah, it's not the nicest, but it will work, we did it also for USB and greybus and it solves the issue.
This all looks good to me, so I've queued it up. Let's see if linux-next has any problems with it. Thanks for sticking with it, nice work!
greg k-h
Hi Greg,
Quoted 17 lines · On Sun, 11 Nov 2018 09:39:32 -0800 Greg Kroah-Hartman…
Quoted 10 lines · Boris Brezillon
Hi Greg,
I think we've reached a point where we can eventually consider the I3C framework for inclusion in 4.20 (5.0?). A few more issues were reported on v9 and fixed in v10. I can't guarantee that the implementation is free of bugs but I still think it's worth merging it in v4.20: it's a new subsystem, so we don't risk regressions, and the only way we can detect other issues is by having other people experiment with this implementation.
Quoted 5 lines
The only remaining concern raised by Arnd is the fact that both hosts and slaves share the same bus type and are differentiated thanks to their
device_type, which IMHO is fine since this is what other subsystems do (plus I don't see other solutions to have both I3C devices and I3C buses represented under/sys/bus/i3c/).
Quoted 5 lines
Yeah, it's not the nicest, but it will work, we did it also for USB and greybus and it solves the issue.
This all looks good to me, so I've queued it up. Let's see if linux-next has any problems with it.
I recently asked Stephen to add the linux-i3c tree to linux-next, so I'm expecting conflicts :-/. Sorry, I didn't know you were planning to take these patches through your tree.
BTW, I also fixed a couple of things when rebasing on top of 4.20-rc1:
- KernelVersion in the sysfs ABI doc has been updated to 5.0
- Fixed i3c_master_getmxds_locked() (bug reported/fixed by Colin here
https://www.mail-archive.com/[email protected]/msg1799850.html)
- Removed a blank line at the end of master-driver-api.rst
For the record, the i3c/next branch pulled by Stephen is available here [1].
Quoted 1 line
Thanks for sticking with it, nice work!
Thanks for reviewing it! Greg, Stephen, let me know if you want me to reset i3c/next to v4.20-rc1 to avoid conflicts in linux-next.
Regards,
Boris
[1]https://git.kernel.org/pub/scm/linux/kernel/git/i3c/linux.git/log/?h=i3c/next
Quoted 28 lines · Boris Brezillon
Hi Greg,
Quoted 17 lines · On Sun, 11 Nov 2018 09:39:32 -0800 Greg Kroah-Hartman…
Quoted 10 lines · Boris Brezillon
Hi Greg,
I think we've reached a point where we can eventually consider the I3C framework for inclusion in 4.20 (5.0?). A few more issues were reported on v9 and fixed in v10. I can't guarantee that the implementation is free of bugs but I still think it's worth merging it in v4.20: it's a new subsystem, so we don't risk regressions, and the only way we can detect other issues is by having other people experiment with this implementation.
Quoted 5 lines
The only remaining concern raised by Arnd is the fact that both hosts and slaves share the same bus type and are differentiated thanks to their
device_type, which IMHO is fine since this is what other subsystems do (plus I don't see other solutions to have both I3C devices and I3C buses represented under/sys/bus/i3c/).Quoted 5 lines
Yeah, it's not the nicest, but it will work, we did it also for USB and greybus and it solves the issue.
This all looks good to me, so I've queued it up. Let's see if linux-next has any problems with it.
Quoted 7 lines
I recently asked Stephen to add the linux-i3c tree to linux-next, so I'm expecting conflicts :-/. Sorry, I didn't know you were planning to take these patches through your tree.
BTW, I also fixed a couple of things when rebasing on top of 4.20-rc1:
- KernelVersion in the sysfs ABI doc has been updated to 5.0
There is no 5.0 yet :)
Quoted 11 lines
- Fixed
i3c_master_getmxds_locked()(bug reported/fixed by Colin here
https://www.mail-archive.com/[email protected]/msg1799850.html)
- Removed a blank line at the end ofmaster-driver-api.rstFor the record, the i3c/next branch pulled by Stephen is available here [1].
Quoted 1 line
Thanks for sticking with it, nice work!
Thanks for reviewing it! Greg, Stephen, let me know if you want me to reset i3c/next to v4.20-rc1 to avoid conflicts in linux-next.
So do you want me to just drop these patches from my tree? If so, I can, but i have no problem sending these to Linus for the next -rc1 merge window through my tree if that is easier.
It's up to you.
greg k-h
Quoted 33 lines · On Sun, 11 Nov 2018 11:10:20 -0800 Greg Kroah-Hartman…
Quoted 32 lines · Boris Brezillon
Hi Greg,
Quoted 17 lines · On Sun, 11 Nov 2018 09:39:32 -0800 Greg Kroah-Hartman…
Quoted 10 lines · Boris Brezillon
Hi Greg,
I think we've reached a point where we can eventually consider the I3C framework for inclusion in 4.20 (5.0?). A few more issues were reported on v9 and fixed in v10. I can't guarantee that the implementation is free of bugs but I still think it's worth merging it in v4.20: it's a new subsystem, so we don't risk regressions, and the only way we can detect other issues is by having other people experiment with this implementation.
Quoted 5 lines
The only remaining concern raised by Arnd is the fact that both hosts and slaves share the same bus type and are differentiated thanks to their
device_type, which IMHO is fine since this is what other subsystems do (plus I don't see other solutions to have both I3C devices and I3C buses represented under/sys/bus/i3c/).Quoted 5 lines
Yeah, it's not the nicest, but it will work, we did it also for USB and greybus and it solves the issue.
This all looks good to me, so I've queued it up. Let's see if linux-next has any problems with it.
I recently asked Stephen to add the linux-i3c tree to linux-next, so I'm expecting conflicts :-/. Sorry, I didn't know you were planning to take these patches through your tree.
Quoted 5 lines
Quoted 3 lines
BTW, I also fixed a couple of things when rebasing on top of 4.20-rc1:
- KernelVersion in the sysfs ABI doc has been updated to 5.0
There is no 5.0 yet :)
Actually I had a hard time choosing between 4.21 and 5.0, and then I saw Linus' email announcing 4.20-rc1 ;-). But I can change it back to 4.21 if you prefer.
Quoted 4 lines
Quoted 4 lines
- Fixed
i3c_master_getmxds_locked()(bug reported/fixed by Colin here
https://www.mail-archive.com/[email protected]/msg1799850.html)
- Removed a blank line at the end ofmaster-driver-api.rst
One extra thing I didn't mention (and didn't fix yet) is the I3C mailing list. I asked Dave Miller if he'd be okay to create the linux-i3c ML on vger.kernel.org, and he suggested that we use the linux-i2c ML instead which I know Wolfram is not fond of. I might decide to just put [email protected] as the ML to Cc for I3C patches until we settle on something.
Quoted 6 lines
Quoted 6 lines
For the record, the i3c/next branch pulled by Stephen is available here [1].
Quoted 1 line
Thanks for sticking with it, nice work!
Quoted 8 lines
Quoted 2 lines
Thanks for reviewing it! Greg, Stephen, let me know if you want me to reset i3c/next to v4.20-rc1 to avoid conflicts in linux-next.
So do you want me to just drop these patches from my tree? If so, I can, but i have no problem sending these to Linus for the next -rc1 merge window through my tree if that is easier.
It's up to you.
I think that's easier for me and for you if I take them in the i3c tree and then send a PR to Linus myself. This way I won't bother you if fixes are needed or if I decide to apply patches adding support for other I3C controllers (I see you commented on the Synopsys driver already, and I might indeed decide to queue this patchset for this release).
Doing that also allows me to get everything in place since I'll anyway have to send PRs to Linus at some point.
Regards,
Boris
PS: If you're fine with me taking the I3C patches, I'll need your Acked-by.
Greg Kroah-Hartman
Acked-byQuoted 83 lines · Boris Brezillon
Quoted 33 lines · On Sun, 11 Nov 2018 11:10:20 -0800 Greg Kroah-Hartman…
Quoted 32 lines · Boris Brezillon
Hi Greg,
Quoted 17 lines · On Sun, 11 Nov 2018 09:39:32 -0800 Greg Kroah-Hartman…
Quoted 10 lines · Boris Brezillon
Hi Greg,
I think we've reached a point where we can eventually consider the I3C framework for inclusion in 4.20 (5.0?). A few more issues were reported on v9 and fixed in v10. I can't guarantee that the implementation is free of bugs but I still think it's worth merging it in v4.20: it's a new subsystem, so we don't risk regressions, and the only way we can detect other issues is by having other people experiment with this implementation.
Quoted 5 lines
The only remaining concern raised by Arnd is the fact that both hosts and slaves share the same bus type and are differentiated thanks to their
device_type, which IMHO is fine since this is what other subsystems do (plus I don't see other solutions to have both I3C devices and I3C buses represented under/sys/bus/i3c/).Quoted 5 lines
Yeah, it's not the nicest, but it will work, we did it also for USB and greybus and it solves the issue.
This all looks good to me, so I've queued it up. Let's see if linux-next has any problems with it.
I recently asked Stephen to add the linux-i3c tree to linux-next, so I'm expecting conflicts :-/. Sorry, I didn't know you were planning to take these patches through your tree.
Quoted 5 lines
Quoted 3 lines
BTW, I also fixed a couple of things when rebasing on top of 4.20-rc1:
- KernelVersion in the sysfs ABI doc has been updated to 5.0
There is no 5.0 yet :)
Actually I had a hard time choosing between 4.21 and 5.0, and then I saw Linus' email announcing 4.20-rc1 ;-). But I can change it back to 4.21 if you prefer.
Quoted 4 lines
Quoted 4 lines
- Fixed
i3c_master_getmxds_locked()(bug reported/fixed by Colin here
https://www.mail-archive.com/[email protected]/msg1799850.html)
- Removed a blank line at the end ofmaster-driver-api.rstOne extra thing I didn't mention (and didn't fix yet) is the I3C mailing list. I asked Dave Miller if he'd be okay to create the linux-i3c ML on vger.kernel.org, and he suggested that we use the linux-i2c ML instead which I know Wolfram is not fond of. I might decide to just put [email protected] as the ML to Cc for I3C patches until we settle on something.
Quoted 6 lines
Quoted 6 lines
For the record, the i3c/next branch pulled by Stephen is available here [1].
Quoted 1 line
Thanks for sticking with it, nice work!
Quoted 8 lines
Quoted 2 lines
Thanks for reviewing it! Greg, Stephen, let me know if you want me to reset i3c/next to v4.20-rc1 to avoid conflicts in linux-next.
So do you want me to just drop these patches from my tree? If so, I can, but i have no problem sending these to Linus for the next -rc1 merge window through my tree if that is easier.
It's up to you.
I think that's easier for me and for you if I take them in the i3c tree and then send a PR to Linus myself. This way I won't bother you if fixes are needed or if I decide to apply patches adding support for other I3C controllers (I see you commented on the Synopsys driver already, and I might indeed decide to queue this patchset for this release).
Doing that also allows me to get everything in place since I'll anyway have to send PRs to Linus at some point.
Quoted 6 lines
Regards,
Boris
PS: If you're fine with me taking the I3C patches, I'll need your Acked-by.
Sure, feel free to do it all yourself, I do not object to that! :)
Quoted 86 lines · Greg Kroah-Hartman
Quoted 85 lines · Boris Brezillon
Quoted 33 lines · On Sun, 11 Nov 2018 11:10:20 -0800 Greg Kroah-Hartman…
Quoted 32 lines · Boris Brezillon
Hi Greg,
Quoted 17 lines · On Sun, 11 Nov 2018 09:39:32 -0800 Greg Kroah-Hartman…
Quoted 10 lines · Boris Brezillon
Hi Greg,
I think we've reached a point where we can eventually consider the I3C framework for inclusion in 4.20 (5.0?). A few more issues were reported on v9 and fixed in v10. I can't guarantee that the implementation is free of bugs but I still think it's worth merging it in v4.20: it's a new subsystem, so we don't risk regressions, and the only way we can detect other issues is by having other people experiment with this implementation.
Quoted 5 lines
The only remaining concern raised by Arnd is the fact that both hosts and slaves share the same bus type and are differentiated thanks to their
device_type, which IMHO is fine since this is what other subsystems do (plus I don't see other solutions to have both I3C devices and I3C buses represented under/sys/bus/i3c/).Quoted 5 lines
Yeah, it's not the nicest, but it will work, we did it also for USB and greybus and it solves the issue.
This all looks good to me, so I've queued it up. Let's see if linux-next has any problems with it.
I recently asked Stephen to add the linux-i3c tree to linux-next, so I'm expecting conflicts :-/. Sorry, I didn't know you were planning to take these patches through your tree.
Quoted 5 lines
Quoted 3 lines
BTW, I also fixed a couple of things when rebasing on top of 4.20-rc1:
- KernelVersion in the sysfs ABI doc has been updated to 5.0
There is no 5.0 yet :)
Actually I had a hard time choosing between 4.21 and 5.0, and then I saw Linus' email announcing 4.20-rc1 ;-). But I can change it back to 4.21 if you prefer.
Quoted 4 lines
Quoted 4 lines
- Fixed
i3c_master_getmxds_locked()(bug reported/fixed by Colin here
https://www.mail-archive.com/[email protected]/msg1799850.html)
- Removed a blank line at the end ofmaster-driver-api.rstOne extra thing I didn't mention (and didn't fix yet) is the I3C mailing list. I asked Dave Miller if he'd be okay to create the linux-i3c ML on vger.kernel.org, and he suggested that we use the linux-i2c ML instead which I know Wolfram is not fond of. I might decide to just put [email protected] as the ML to Cc for I3C patches until we settle on something.
Quoted 6 lines
Quoted 6 lines
For the record, the i3c/next branch pulled by Stephen is available here [1].
Quoted 1 line
Thanks for sticking with it, nice work!
Quoted 8 lines
Quoted 2 lines
Thanks for reviewing it! Greg, Stephen, let me know if you want me to reset i3c/next to v4.20-rc1 to avoid conflicts in linux-next.
So do you want me to just drop these patches from my tree? If so, I can, but i have no problem sending these to Linus for the next -rc1 merge window through my tree if that is easier.
It's up to you.
I think that's easier for me and for you if I take them in the i3c tree and then send a PR to Linus myself. This way I won't bother you if fixes are needed or if I decide to apply patches adding support for other I3C controllers (I see you commented on the Synopsys driver already, and I might indeed decide to queue this patchset for this release).
Doing that also allows me to get everything in place since I'll anyway have to send PRs to Linus at some point.
Regards,
Quoted 8 lines
Quoted 4 lines
Boris
PS: If you're fine with me taking the I3C patches, I'll need your Acked-by.
Sure, feel free to do it all yourself, I do not object to that! :)
And I've now dropped all of these patches from my tree, so no need to worry about any conflicts.
thanks,
greg k-h
Hi Boris,
Given the current state of the subsystem I think it might worth start to think how to expose the devices under /dev.
My initial thoughts are to do the same think as for i2c, expose the buses or the i3c_devices and use ioctl for private transfers. Some direct CCC commands can be sent through the /sys as you plan for SETNEWDA .
What do you think about this?
Best regards,
Vitor Soares
+Mark Brown for the question about /dev/spidev
Hi Vitor,
Quoted 4 lines · On Thu, 15 Nov 2018 12:14:37 +0000 vitor <[email protected]> wrote:
Hi Boris,
Given the current state of the subsystem I think it might worth start to think how to expose the devices under /dev.
Thanks for starting this discussion. I'm not against the idea in general, we just need to be careful when doing that.
Quoted 2 lines
My initial thoughts are to do the same think as for i2c, expose the buses or the
i3c_devicesand use ioctl for private transfers.
Exposing the bus is dangerous IMO, because an I3C bus is not like an I2C bus:
* I3C device needs to be discovered through DAA
* I2C devices need to be declared ahead of time, and LVR is used to determine the limitations on the bus at runtime
So you'd anyway be able to interact only with devices that have previously been discovered.
Note that the virtual I2C bus is already exposed, but any command targeting an address that is not attached to a registered I2C dev will get a -ENOENT error.
What we could do though, is expose I3C devices that do not have a driver in kernel space, like spidev does.
Quoted 2 lines
Some
direct CCC commands can be sent through the /sys as you plan for SETNEWDA .
Yes, CCC commands that need to be exposed to userspace should be exposed through sysfs, or, if we decide to create a /dev/i3cX device per bus, through ioctls.
Quoted 2 lines
What do you think about this?
I think this request is perfectly valid, we just need to decide how it should be done, and before we take this decision, I'd like to get inputs from other maintainers.
Mark, Wolfram, Arnd, Greg, any opinion?
Regards,
Boris
Quoted 31 lines · Boris Brezillon
+Mark Brown for the question about
/dev/spidevQuoted 2 lines · On Thu, 15 Nov 2018 12:14:37 +0000 vitor <[email protected]> wrote:
My initial thoughts are to do the same think as for i2c, expose the buses or the
i3c_devicesand use ioctl for private transfers.Exposing the bus is dangerous IMO, because an I3C bus is not like an I2C bus:
* I3C device needs to be discovered through DAA
* I2C devices need to be declared ahead of time, and LVR is used to determine the limitations on the bus at runtimeSo you'd anyway be able to interact only with devices that have previously been discovered.
Note that the virtual I2C bus is already exposed, but any command targeting an address that is not attached to a registered I2C dev will get a
-ENOENTerror.What we could do though, is expose I3C devices that do not have a driver in kernel space, like spidev does.
Quoted 2 lines
Some
direct CCC commands can be sent through the /sys as you plan for SETNEWDA .Yes, CCC commands that need to be exposed to userspace should be exposed through sysfs, or, if we decide to create a
/dev/i3cXdevice per bus, through ioctls.Quoted 1 line
Quoted 7 lines
Quoted 1 line
What do you think about this?
I think this request is perfectly valid, we just need to decide how it should be done, and before we take this decision, I'd like to get inputs from other maintainers.
Mark, Wolfram, Arnd, Greg, any opinion?
I think for a new user space interface, it makes sense to explore a number of different options before making the final decision.
I agree about better not exposing the bus as a /dev/i3c* node, and that we probably do need to expose individual devices in some form to allow writing complete user space drivers that can do everything a kernel driver can do.
Can you describe what a low-level interface to the device looks like in the kernel? Can this be abstracted as simply pread()/pwrite() plus an interrupt mechanism, or do we need a set of ioctl() operations as well?
If it can be purely based on a regmap abstraction, a sysfs inteface might be sufficient, though that has some downsides with permission management compared to a /dev/* node.
Another option might be the use of a socket interface, which also has some issues in terms of permission management, but might be a good fit if we could abstract bus transactions as packets that can be queued.
Arnd
Hi Arnd,
Quoted 9 lines · Arnd Bergmann
I agree about better not exposing the bus as a
/dev/i3c*node, and that we probably do need to expose individual devices in some form to allow writing complete user space drivers that can do everything a kernel driver can do.Can you describe what a low-level interface to the device looks like in the kernel? Can this be abstracted as simply pread()/pwrite() plus an interrupt mechanism, or do we need a set of
ioctl()operations as well?
Like in i2c is likely to need the ioctl() too.
Best regards,
Vitor Soares
Quoted 8 lines · On Thu, 15 Nov 2018 15:25:11 +0000 vitor <[email protected]> wrote:
Hi Arnd,
Quoted 5 lines · Arnd Bergmann
I agree about better not exposing the bus as a
/dev/i3c*node, and that we probably do need to expose individual devices in some form to allow writing complete user space drivers that can do everything a kernel driver can do.
Quoted 6 lines
Quoted 4 lines
Can you describe what a low-level interface to the device looks like in the kernel? Can this be abstracted as simply pread()/pwrite() plus an interrupt mechanism, or do we need a set of
ioctl()operations as well?Like in i2c is likely to need the
ioctl()too.
Yep, I think we'll need an ioctl given the various type of transfers one case use to interact with a device.
Hi Boris,
Quoted 2 lines
What we could do though, is expose I3C devices that do not have a driver in kernel space, like spidev does.
...
Quoted 1 line
Mark, Wolfram, Arnd, Greg, any opinion?
Is there a benefit for having drivers in userspace? My gut feeling is to encourage people to write kernel drivers. If this is, for some reason, not possible for some driver, then we have a use case at hand to test the then-to-be-developed userspace interface against. Until then, I personally wouldn't waste effort on designing it without a user in sight.
Dunno if you have that, but a debug interface (exchanging data with clients) on the other hand would be super useful most probably. Maybe you can start having that in debugfs and already learn from it if you ever want to move some interface outside of debugfs?
Kind regards,
Wolfram
Quoted 14 lines · Wolfram Sang
Quoted 2 lines
What we could do though, is expose I3C devices that do not have a driver in kernel space, like spidev does.
...
Quoted 1 line
Mark, Wolfram, Arnd, Greg, any opinion?
Is there a benefit for having drivers in userspace? My gut feeling is to encourage people to write kernel drivers. If this is, for some reason, not possible for some driver, then we have a use case at hand to test the then-to-be-developed userspace interface against. Until then, I personally wouldn't waste effort on designing it without a user in sight.
Quoted 4 lines
Dunno if you have that, but a debug interface (exchanging data with clients) on the other hand would be super useful most probably. Maybe you can start having that in debugfs and already learn from it if you ever want to move some interface outside of debugfs?
I think it may depend a little bit on the complexity we require for a user interface. If it's basically just pread/pwrite, then the debugfs would not look any different from a stable interface, and there is little risk of getting it wrong. The more complex the interface turns out to be, the more cautious we may want to be about declaring it stable.
Other than that, I agree we should encourage users to write kernel drivers, but given the precedent of uio, libusb, spidev, i2c-dev, and vfio, it does seem extremely likely that users will have requirements for it, and I think it's a good idea to start the design discussion before users start building their own interfaces to do the same thing badly.
Arnd
Quoted 7 lines · On Thu, 15 Nov 2018 16:01:37 +0100 Wolfram Sang <[email protected]> wrote:
Hi Boris,
Quoted 2 lines
What we could do though, is expose I3C devices that do not have a driver in kernel space, like spidev does.
...
Quoted 8 lines
Quoted 1 line
Mark, Wolfram, Arnd, Greg, any opinion?
Is there a benefit for having drivers in userspace? My gut feeling is to encourage people to write kernel drivers. If this is, for some reason, not possible for some driver, then we have a use case at hand to test the then-to-be-developed userspace interface against. Until then, I personally wouldn't waste effort on designing it without a user in sight.
I kind of agree with that. Vitor, do you have a use case in mind for such userspace drivers? I don't think it's worth designing an API for something we don't need (yet).
Hi Boris,
Quoted 16 lines · Boris Brezillon
Quoted 6 lines · On Thu, 15 Nov 2018 16:01:37 +0100 Wolfram Sang <[email protected]> wrote:
Hi Boris,
Quoted 2 lines
What we could do though, is expose I3C devices that do not have a driver in kernel space, like spidev does.
...
Quoted 7 lines
Quoted 1 line
Mark, Wolfram, Arnd, Greg, any opinion?
Is there a benefit for having drivers in userspace? My gut feeling is to encourage people to write kernel drivers. If this is, for some reason, not possible for some driver, then we have a use case at hand to test the then-to-be-developed userspace interface against. Until then, I personally wouldn't waste effort on designing it without a user in sight.
Quoted 3 lines
I kind of agree with that. Vitor, do you have a use case in mind for such userspace drivers? I don't think it's worth designing an API for something we don't need (yet).
My use case is a tool for tests, lets say like the i2c tools. There is other subsystems, some of them mentioned on this thread, that have and ioctl system call or other method to change parameters or send data.
I rise this topic because I really think it worth to define now how this should be design (and for me how to do the things right) to avoid future issues.
Best regards,
Vitor Soares
Quoted 20 lines · On Thu, 15 Nov 2018 18:03:47 +0000 vitor <[email protected]> wrote:
Hi Boris,
Quoted 16 lines · Boris Brezillon
Quoted 13 lines · On Thu, 15 Nov 2018 16:01:37 +0100 Wolfram Sang <[email protected]> wrote:
Hi Boris,
Quoted 2 lines
What we could do though, is expose I3C devices that do not have a driver in kernel space, like spidev does.
...
Quoted 1 line
Mark, Wolfram, Arnd, Greg, any opinion?
Is there a benefit for having drivers in userspace? My gut feeling is to encourage people to write kernel drivers. If this is, for some reason, not possible for some driver, then we have a use case at hand to test the then-to-be-developed userspace interface against. Until then, I personally wouldn't waste effort on designing it without a user in sight.
Quoted 5 lines
Quoted 3 lines
I kind of agree with that. Vitor, do you have a use case in mind for such userspace drivers? I don't think it's worth designing an API for something we don't need (yet).
My use case is a tool for tests, lets say like the i2c tools.
What would you like to test exactly?
Quoted 3 lines
There is
other subsystems, some of them mentioned on this thread, that have and ioctl system call or other method to change parameters or send data.
I don't think they added the /dev interface before having a real use case for it.
Quoted 5 lines
I rise this topic because I really think it worth to define now how this should be design (and for me how to do the things right) to avoid future issues.
Actually it should be done the other way around: you should have a real need and the /dev interface should be designed to fulfill this need. Based on this real use case we can discuss other potential usage that might appear in the future and try to design something more future-proof, but clearly, this userspace interface should be driven by a real/well-defined use case.
Also, exposing things to userspace is way more risky than adding a new in-kernel subsystem/framework, because it then becomes part of the stable ABI.
To make things clearer, I'm not against the idea of exposing I3C devices (or I3C buses) to userspace, but I'd like to understand what you plan to do with that. If this is about testing, what kind of tests you'd like to run. If this is about developing drivers in userspace, why can't these be done in kernel space (license issues?), and what would those drivers be allowed to do?
Hi Boris,
Quoted 50 lines · Boris Brezillon
Quoted 20 lines · On Thu, 15 Nov 2018 18:03:47 +0000 vitor <[email protected]> wrote:
Hi Boris,
Quoted 16 lines · Boris Brezillon
Quoted 13 lines · On Thu, 15 Nov 2018 16:01:37 +0100 Wolfram Sang <[email protected]> wrote:
Hi Boris,
Quoted 2 lines
What we could do though, is expose I3C devices that do not have a driver in kernel space, like spidev does.
...
Quoted 1 line
Mark, Wolfram, Arnd, Greg, any opinion?
Is there a benefit for having drivers in userspace? My gut feeling is to encourage people to write kernel drivers. If this is, for some reason, not possible for some driver, then we have a use case at hand to test the then-to-be-developed userspace interface against. Until then, I personally wouldn't waste effort on designing it without a user in sight.
Quoted 4 lines
Quoted 3 lines
I kind of agree with that. Vitor, do you have a use case in mind for such userspace drivers? I don't think it's worth designing an API for something we don't need (yet).
My use case is a tool for tests, lets say like the i2c tools.
What would you like to test exactly?
Quoted 3 lines
There is
other subsystems, some of them mentioned on this thread, that have and ioctl system call or other method to change parameters or send data.I don't think they added the /dev interface before having a real use case for it.
Quoted 4 lines
I rise this topic because I really think it worth to define now how this should be design (and for me how to do the things right) to avoid future issues.
Actually it should be done the other way around: you should have a real need and the /dev interface should be designed to fulfill this need. Based on this real use case we can discuss other potential usage that might appear in the future and try to design something more future-proof, but clearly, this userspace interface should be driven by a real/well-defined use case.
Also, exposing things to userspace is way more risky than adding a new in-kernel subsystem/framework, because it then becomes part of the stable ABI.
Quoted 6 lines
To make things clearer, I'm not against the idea of exposing I3C devices (or I3C buses) to userspace, but I'd like to understand what you plan to do with that. If this is about testing, what kind of tests you'd like to run. If this is about developing drivers in userspace, why can't these be done in kernel space (license issues?), and what would those drivers be allowed to do?
Basically I need a tool that help me during the development and to avoid me to write a dummy driver for each device that I test.
For instances do some read/write, get/set ccc commands, if something goes wrong during the bus initialization have a to debug etc...
For me this is a valid use case and I imagine when people start to develop in i3c this interface will help everyone.
Best regards,
Vitor Soares
Przemyslaw Gaj
maintainerHi Vitor,
On 11/16/18, 1:32 PM, "vitor" <[email protected]> wrote:
EXTERNAL MAIL
Hi Boris,
On 15/11/18 19:00, Boris Brezillon wrote:
> On Thu, 15 Nov 2018 18:03:47 +0000
> vitor <[email protected]> wrote:
>
>> Hi Boris,
>>
>>
>> On 15/11/18 15:28, Boris Brezillon wrote:
>>> On Thu, 15 Nov 2018 16:01:37 +0100
>>> Wolfram Sang <[email protected]> wrote:
>>>
>>>> Hi Boris,
>>>>
>>>>> What we could do though, is expose I3C devices that do not have a >>>>> driver in kernel space, like spidev does.
>>>> ...
>>>>
>>>>> Mark, Wolfram, Arnd, Greg, any opinion?
>>>> Is there a benefit for having drivers in userspace? My gut feeling is to >>>> encourage people to write kernel drivers. If this is, for some reason, >>>> not possible for some driver, then we have a use case at hand to test >>>> the then-to-be-developed userspace interface against. Until then, I >>>> personally wouldn't waste effort on designing it without a user in >>>> sight.
>>> I kind of agree with that. Vitor, do you have a use case in mind for >>> such userspace drivers? I don't think it's worth designing an API for >>> something we don't need (yet).
>> My use case is a tool for tests, lets say like the i2c tools. > What would you like to test exactly?
>
>> There is
>> other subsystems, some of them mentioned on this thread, that have and >> ioctl system call or other method to change parameters or send data. > I don't think they added the /dev interface before having a real use > case for it.
>
>>
>> I rise this topic because I really think it worth to define now how this >> should be design (and for me how to do the things right) to avoid future >> issues.
> Actually it should be done the other way around: you should have a real > need and the /dev interface should be designed to fulfill this need. > Based on this real use case we can discuss other potential usage that > might appear in the future and try to design something more
> future-proof, but clearly, this userspace interface should be driven by > a real/well-defined use case.
>
> Also, exposing things to userspace is way more risky than adding a new > in-kernel subsystem/framework, because it then becomes part of the > stable ABI.
>
> To make things clearer, I'm not against the idea of exposing I3C > devices (or I3C buses) to userspace, but I'd like to understand what you > plan to do with that. If this is about testing, what kind of tests > you'd like to run. If this is about developing drivers in userspace, > why can't these be done in kernel space (license issues?), and what > would those drivers be allowed to do?
Basically I need a tool that help me during the development and to avoid me to write a dummy driver for each device that I test.
For now we are doing it that way. Separate dummy driver for each device.
For instances do some read/write, get/set ccc commands, if something goes wrong during the bus initialization have a to debug etc...
That sounds good to have possibility to make simple reads/writes and send basic ccc commands. But of course keeping in mind that I3C bus is more complicated than I2C, as Boris mentioned before.
For me this is a valid use case and I imagine when people start to develop in i3c this interface will help everyone.
Best regards,
Vitor Soares
Regards,
Przemek
Quoted 62 lines · On Fri, 16 Nov 2018 12:31:42 +0000 vitor <[email protected]> wrote:
Hi Boris,
Quoted 50 lines · Boris Brezillon
Quoted 20 lines · On Thu, 15 Nov 2018 18:03:47 +0000 vitor <[email protected]> wrote:
Hi Boris,
Quoted 16 lines · Boris Brezillon
Quoted 13 lines · On Thu, 15 Nov 2018 16:01:37 +0100 Wolfram Sang <[email protected]> wrote:
Hi Boris,
Quoted 2 lines
What we could do though, is expose I3C devices that do not have a driver in kernel space, like spidev does.
...
Quoted 1 line
Mark, Wolfram, Arnd, Greg, any opinion?
Is there a benefit for having drivers in userspace? My gut feeling is to encourage people to write kernel drivers. If this is, for some reason, not possible for some driver, then we have a use case at hand to test the then-to-be-developed userspace interface against. Until then, I personally wouldn't waste effort on designing it without a user in sight.
Quoted 4 lines
Quoted 3 lines
I kind of agree with that. Vitor, do you have a use case in mind for such userspace drivers? I don't think it's worth designing an API for something we don't need (yet).
My use case is a tool for tests, lets say like the i2c tools.
What would you like to test exactly?
Quoted 3 lines
There is
other subsystems, some of them mentioned on this thread, that have and ioctl system call or other method to change parameters or send data.I don't think they added the /dev interface before having a real use case for it.
Quoted 4 lines
I rise this topic because I really think it worth to define now how this should be design (and for me how to do the things right) to avoid future issues.
Actually it should be done the other way around: you should have a real need and the /dev interface should be designed to fulfill this need. Based on this real use case we can discuss other potential usage that might appear in the future and try to design something more future-proof, but clearly, this userspace interface should be driven by a real/well-defined use case.
Also, exposing things to userspace is way more risky than adding a new in-kernel subsystem/framework, because it then becomes part of the stable ABI.
Quoted 6 lines
To make things clearer, I'm not against the idea of exposing I3C devices (or I3C buses) to userspace, but I'd like to understand what you plan to do with that. If this is about testing, what kind of tests you'd like to run. If this is about developing drivers in userspace, why can't these be done in kernel space (license issues?), and what would those drivers be allowed to do?
Quoted 2 lines
Basically I need a tool that help me during the development and to avoid me to write a dummy driver for each device that I test.
But we want I3C device drivers to be upstreamed, so why not developing a real driver everytime you test a new device and submitting it upstream?
Quoted 2 lines
For instances do some read/write,
Doing SDR/DDR transfers is probably acceptable, but I still think we should push hard to have kernel drivers when that's possible.
Quoted 1 line
get/set ccc commands,
Exposing CCC commands is definitely not a good idea, since they're not even exposed to kernel drivers.
Quoted 2 lines
if something
goes wrong during the bus initialization have a to debug etc...
Can't we add such a debug infrastructure in the kernel. Maybe we can expose debugfs files too if that helps, though if those debugfs files are actually used by userspace libs/tools, it's not any better than ioctls or sysfs files, since they will anyway become a stable ABI.
Quoted 4 lines
For me this is a valid use case and I imagine when people start to develop in i3c this interface will help everyone.
How about you propose an i3cdev driver that allow users to do SDR transfers throuh an ioctl?
Hi Boris,
Quoted 63 lines · Boris Brezillon
Quoted 60 lines · On Fri, 16 Nov 2018 12:31:42 +0000 vitor <[email protected]> wrote:
Hi Boris,
Quoted 55 lines · Boris Brezillon
Quoted 20 lines · On Thu, 15 Nov 2018 18:03:47 +0000 vitor <[email protected]> wrote:
Hi Boris,
Quoted 16 lines · Boris Brezillon
Quoted 13 lines · On Thu, 15 Nov 2018 16:01:37 +0100 Wolfram Sang <[email protected]> wrote:
Hi Boris,
Quoted 2 lines
What we could do though, is expose I3C devices that do not have a driver in kernel space, like spidev does.
...
Quoted 1 line
Mark, Wolfram, Arnd, Greg, any opinion?
Is there a benefit for having drivers in userspace? My gut feeling is to encourage people to write kernel drivers. If this is, for some reason, not possible for some driver, then we have a use case at hand to test the then-to-be-developed userspace interface against. Until then, I personally wouldn't waste effort on designing it without a user in sight.
Quoted 4 lines
Quoted 3 lines
I kind of agree with that. Vitor, do you have a use case in mind for such userspace drivers? I don't think it's worth designing an API for something we don't need (yet).
My use case is a tool for tests, lets say like the i2c tools.
What would you like to test exactly?
Quoted 3 lines
There is
other subsystems, some of them mentioned on this thread, that have and ioctl system call or other method to change parameters or send data.I don't think they added the /dev interface before having a real use case for it.
Quoted 3 lines
I rise this topic because I really think it worth to define now how this should be design (and for me how to do the things right) to avoid future issues.
Actually it should be done the other way around: you should have a real need and the /dev interface should be designed to fulfill this need. Based on this real use case we can discuss other potential usage that might appear in the future and try to design something more future-proof, but clearly, this userspace interface should be driven by a real/well-defined use case.
Also, exposing things to userspace is way more risky than adding a new in-kernel subsystem/framework, because it then becomes part of the stable ABI.
To make things clearer, I'm not against the idea of exposing I3C devices (or I3C buses) to userspace, but I'd like to understand what you plan to do with that. If this is about testing, what kind of tests you'd like to run. If this is about developing drivers in userspace, why can't these be done in kernel space (license issues?), and what would those drivers be allowed to do?
Quoted 4 lines
Quoted 2 lines
Basically I need a tool that help me during the development and to avoid me to write a dummy driver for each device that I test.
But we want I3C device drivers to be upstreamed, so why not developing a real driver everytime you test a new device and submitting it upstream?
Usually the devices that I test aren't the final product so it isn't easy to do the upstream.
But when possible I plan to do that.
Quoted 17 lines
Quoted 2 lines
For instances do some read/write,
Doing SDR/DDR transfers is probably acceptable, but I still think we should push hard to have kernel drivers when that's possible.
Quoted 1 line
get/set ccc commands,
Exposing CCC commands is definitely not a good idea, since they're not even exposed to kernel drivers.
Quoted 2 lines
if something
goes wrong during the bus initialization have a to debug etc...Can't we add such a debug infrastructure in the kernel. Maybe we can expose debugfs files too if that helps, though if those debugfs files are actually used by userspace libs/tools, it's not any better than ioctls or sysfs files, since they will anyway become a stable ABI.
Quoted 1 line
Quoted 4 lines
Quoted 2 lines
For me this is a valid use case and I imagine when people start to develop in i3c this interface will help everyone.
How about you propose an i3cdev driver that allow users to do SDR transfers throuh an ioctl?
I think that was for v6 I started to something to expose the bus like in i2c-dev, but I liked the idea of expose only the device doesn't have a driver. Do you know if there is already something in the kernel doing the same?
Best regards,
Vitor Soares
Quoted 97 lines · On Mon, 19 Nov 2018 12:35:42 +0000 vitor <[email protected]> wrote:
Hi Boris,
Quoted 63 lines · Boris Brezillon
Quoted 60 lines · On Fri, 16 Nov 2018 12:31:42 +0000 vitor <[email protected]> wrote:
Hi Boris,
Quoted 55 lines · Boris Brezillon
Quoted 20 lines · On Thu, 15 Nov 2018 18:03:47 +0000 vitor <[email protected]> wrote:
Hi Boris,
Quoted 16 lines · Boris Brezillon
Quoted 13 lines · On Thu, 15 Nov 2018 16:01:37 +0100 Wolfram Sang <[email protected]> wrote:
Hi Boris,
Quoted 2 lines
What we could do though, is expose I3C devices that do not have a driver in kernel space, like spidev does.
...
Quoted 1 line
Mark, Wolfram, Arnd, Greg, any opinion?
Is there a benefit for having drivers in userspace? My gut feeling is to encourage people to write kernel drivers. If this is, for some reason, not possible for some driver, then we have a use case at hand to test the then-to-be-developed userspace interface against. Until then, I personally wouldn't waste effort on designing it without a user in sight.
Quoted 4 lines
Quoted 3 lines
I kind of agree with that. Vitor, do you have a use case in mind for such userspace drivers? I don't think it's worth designing an API for something we don't need (yet).
My use case is a tool for tests, lets say like the i2c tools.
What would you like to test exactly?
Quoted 3 lines
There is
other subsystems, some of them mentioned on this thread, that have and ioctl system call or other method to change parameters or send data.I don't think they added the /dev interface before having a real use case for it.
Quoted 3 lines
I rise this topic because I really think it worth to define now how this should be design (and for me how to do the things right) to avoid future issues.
Actually it should be done the other way around: you should have a real need and the /dev interface should be designed to fulfill this need. Based on this real use case we can discuss other potential usage that might appear in the future and try to design something more future-proof, but clearly, this userspace interface should be driven by a real/well-defined use case.
Also, exposing things to userspace is way more risky than adding a new in-kernel subsystem/framework, because it then becomes part of the stable ABI.
To make things clearer, I'm not against the idea of exposing I3C devices (or I3C buses) to userspace, but I'd like to understand what you plan to do with that. If this is about testing, what kind of tests you'd like to run. If this is about developing drivers in userspace, why can't these be done in kernel space (license issues?), and what would those drivers be allowed to do?
Quoted 4 lines
Quoted 2 lines
Basically I need a tool that help me during the development and to avoid me to write a dummy driver for each device that I test.
But we want I3C device drivers to be upstreamed, so why not developing a real driver everytime you test a new device and submitting it upstream?
Usually the devices that I test aren't the final product so it isn't easy to do the upstream.
But when possible I plan to do that.
Quoted 19 lines
Quoted 2 lines
For instances do some read/write,
Doing SDR/DDR transfers is probably acceptable, but I still think we should push hard to have kernel drivers when that's possible.
Quoted 1 line
get/set ccc commands,
Exposing CCC commands is definitely not a good idea, since they're not even exposed to kernel drivers.
Quoted 2 lines
if something
goes wrong during the bus initialization have a to debug etc...Can't we add such a debug infrastructure in the kernel. Maybe we can expose debugfs files too if that helps, though if those debugfs files are actually used by userspace libs/tools, it's not any better than ioctls or sysfs files, since they will anyway become a stable ABI.
Quoted 3 lines
For me this is a valid use case and I imagine when people start to develop in i3c this interface will help everyone.
Quoted 7 lines
Quoted 2 lines
How about you propose an i3cdev driver that allow users to do SDR transfers throuh an ioctl?
I think that was for v6 I started to something to expose the bus like in i2c-dev, but I liked the idea of expose only the device doesn't have a driver. Do you know if there is already something in the kernel doing the same?
I know [1], but there might be other subsystems doing the same thing.
[1]https://elixir.bootlin.com/linux/v4.20-rc3/source/drivers/spi/spidev.c
Quoted 3 lines · Boris Brezillon
I know [1], but there might be other subsystems doing the same thing.
Thanks.
Hi,
Quoted 23 lines · Boris Brezillon
+Mark Brown for the question about
/dev/spidevHi Vitor,
Quoted 4 lines · On Thu, 15 Nov 2018 12:14:37 +0000 vitor <[email protected]> wrote:
Hi Boris,
Given the current state of the subsystem I think it might worth start to think how to expose the devices under /dev.
Thanks for starting this discussion. I'm not against the idea in general, we just need to be careful when doing that.
Quoted 2 lines
My initial thoughts are to do the same think as for i2c, expose the buses or the
i3c_devicesand use ioctl for private transfers.Exposing the bus is dangerous IMO, because an I3C bus is not like an I2C bus:
* I3C device needs to be discovered through DAA
* I2C devices need to be declared ahead of time, and LVR is used to determine the limitations on the bus at runtime
Quoted 6 lines
So you'd anyway be able to interact only with devices that have previously been discovered.
Note that the virtual I2C bus is already exposed, but any command targeting an address that is not attached to a registered I2C dev will get a
-ENOENTerror.
I initially thought to do the same thing for the i3c devices adding a routine get_i3c_dev_by_addr()...
Quoted 3 lines
What we could do though, is expose I3C devices that do not have a driver in kernel space, like spidev does.
...but I like more this approach.
Quoted 5 lines
Quoted 2 lines
Some
direct CCC commands can be sent through the /sys as you plan for SETNEWDA .Yes, CCC commands that need to be exposed to userspace should be exposed through sysfs, or, if we decide to create a
/dev/i3cXdevice per bus, through ioctls.
There already some attributes exposed, just need to add the possibility to write to them and off course add some that are missing like GETSTATUS.
Quoted 11 lines
Quoted 2 lines
What do you think about this?
I think this request is perfectly valid, we just need to decide how it should be done, and before we take this decision, I'd like to get inputs from other maintainers.
Mark, Wolfram, Arnd, Greg, any opinion?
Regards,
Boris
Best regards,
Vitor Soares
Quoted 2 lines · Boris Brezillon
What we could do though, is expose I3C devices that do not have a driver in kernel space, like spidev does.
Yes, this is much safer and more robust especially if the bus has enumeration requirements like you're saying it does. It's much easier and more sensible to do this if the bus can be enumerated than it is with SPI, USB would be a good example here I guess (though I've never looked at the details of how USB does this on the implementation side so this may be me speaking in blissful ignorance).
I do agree that there will be use cases that turn up for this.