Add the I3C subsystem
Subsystems (6)
v5 cover Add the I3C subsystem
This patch series is a proposal for a new I3C subsystem.
This infrastructure is not complete yet and will be extended over time.
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 bus element is a separate object and is not implicitly described by the master (as done in I2C). The reason is that I want to be able to handle multiple master connected to the same bus and visible to Linux.
In this situation, we should only have one instance of the device and not one per master, and sharing the bus object would be part of the solution to gracefully handle this case.
I'm not sure if we will ever need to deal with multiple masters controlling the same bus and exposed under Linux, but separating the bus and master concept is pretty easy, hence the decision to do it now, just in case we need it some day.
The other benefit of separating the bus and master concepts is that master devices appear under the bus directory in sysfs.
- 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 in this preliminary version:
- 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
Only minor things have changes since v3, 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
Boris Brezillon (10):
i3c: Add core I3C infrastructure
docs: driver-api: Add I3C documentation
i3c: Add sysfs ABI spec
dt-bindings: i3c: Document core bindings
dt-bindings: i3c: Add macros to help fill I3C/I2C device's reg
property
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 | 95 ++ .../devicetree/bindings/gpio/gpio-cdns-i3c.txt | 39 + .../devicetree/bindings/i3c/cdns,i3c-master.txt | 44 + Documentation/devicetree/bindings/i3c/i3c.txt | 140 ++ Documentation/driver-api/i3c/device-driver-api.rst | 9 + Documentation/driver-api/i3c/index.rst | 11 + Documentation/driver-api/i3c/master-driver-api.rst | 10 + Documentation/driver-api/i3c/protocol.rst | 203 +++ Documentation/driver-api/index.rst | 1 + MAINTAINERS | 10 + 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/core.c | 620 +++++++ drivers/i3c/device.c | 294 ++++ drivers/i3c/internals.h | 28 + drivers/i3c/master.c | 1722 ++++++++++++++++++++ drivers/i3c/master/Kconfig | 5 + drivers/i3c/master/Makefile | 1 + drivers/i3c/master/i3c-master-cdns.c | 1651 +++++++++++++++++++ include/dt-bindings/i3c/i3c.h | 28 + include/linux/i3c/ccc.h | 382 +++++ include/linux/i3c/device.h | 307 ++++ include/linux/i3c/master.h | 587 +++++++ include/linux/mod_devicetable.h | 17 + 29 files changed, 6658 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/core.c 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/dt-bindings/i3c/i3c.h 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.14.1
PATCH v5 1/10 i3c: Add core I3C infrastructure
Add core infrastructure to support I3C in Linux and document it.
This infrastructure is not complete yet and will be extended over time.
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 bus element is a separate object and is not implicitly described by the master (as done in I2C). The reason is that I want to be able to handle multiple master connected to the same bus and visible to Linux.
In this situation, we should only have one instance of the device and not one per master, and sharing the bus object would be part of the solution to gracefully handle this case.
I'm not sure we will ever need to deal with multiple masters controlling the same bus and exposed under Linux, but separating the bus and master concept is pretty easy, hence the decision to do it like that.
The other benefit of separating the bus and master concepts is that master devices appear under the bus directory in sysfs.
- 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 in this preliminary version:
- 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 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/core.c | 620 ++++++++++++++ drivers/i3c/device.c | 294 +++++++ drivers/i3c/internals.h | 28 + drivers/i3c/master.c | 1722 +++++++++++++++++++++++++++++++++++++++ drivers/i3c/master/Kconfig | 0 drivers/i3c/master/Makefile | 0 include/linux/i3c/ccc.h | 382 +++++++++ include/linux/i3c/device.h | 307 +++++++ include/linux/i3c/master.h | 587 +++++++++++++ include/linux/mod_devicetable.h | 17 + 14 files changed, 3988 insertions(+), 1 deletion(-) create mode 100644 drivers/i3c/Kconfig create mode 100644 drivers/i3c/Makefile create mode 100644 drivers/i3c/core.c 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
@@ -55,6 +55,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 := core.o device.o master.o +obj-$(CONFIG_I3C) += i3c.o +obj-$(CONFIG_I3C) += master/
drivers/i3c/core.c new file +620 -0
620 lines not on this page · raw message
drivers/i3c/device.c new file +294 -0
294 lines not on this page · raw message
drivers/i3c/internals.h new file +28 -0
@@ -0,0 +1,28 @@ +/* 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; +extern const struct device_type i3c_master_type; +extern const struct device_type i3c_device_type; + +void i3c_bus_unref (struct i3c_bus *bus); +struct i3c_bus *i3c_bus_create (struct device *parent); +void i3c_bus_unregister (struct i3c_bus *bus); +int i3c_bus_register (struct i3c_bus *i3cbus); +int i3c_bus_get_free_addr (struct i3c_bus *bus,u8 start_addr); +bool i3c_bus_dev_addr_is_avail (struct i3c_bus *bus,u8 addr); +void i3c_bus_set_addr_slot_status (struct i3c_bus *bus,u16 addr, +enum i3c_addr_slot_status status); +enum i3c_addr_slot_status i3c_bus_get_addr_slot_status (struct i3c_bus *bus, +u16 addr); + +#endif /* I3C_INTERNAL_H */
drivers/i3c/master.c new file +1722 -0
1,722 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 +382 -0
292 lines not on this page · raw message
include/linux/i3c/device.h new file +307 -0
307 lines not on this page · raw message
include/linux/i3c/master.h new file +587 -0
587 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.14.1
Part of the diff is not shown here. View the raw message.
Re: [PATCH v5 01/10] i3c: Add core I3C infrastructure
Quoted 17 lines · Boris Brezillon
Add core infrastructure to support I3C in Linux and document it.
This infrastructure is not complete yet and will be extended over time.
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 bus element is a separate object and is not implicitly described by the master (as done in I2C). The reason is that I want to be able to handle multiple master connected to the same bus and visible to Linux.
In this situation, we should only have one instance of the device and
Quoted 8 lines
not one per master, and sharing the bus object would be part of the solution to gracefully handle this case.
I'm not sure we will ever need to deal with multiple masters controlling the same bus and exposed under Linux, but separating the bus and master concept is pretty easy, hence the decision to do it like that.
The other benefit of separating the bus and master concepts is that master devices appear under the bus directory in sysfs.
Are bus multiplexers relevant to I3C? The locking needed for handling muxes for I2C is, well, convoluted...
Cheers,
Peter
Re: [PATCH v5 01/10] i3c: Add core I3C infrastructure
Hi Peter,
Quoted 27 lines · On Fri, 22 Jun 2018 23:35:34 +0200 Peter Rosin <[email protected]> wrote:
Quoted 17 lines · Boris Brezillon
Add core infrastructure to support I3C in Linux and document it.
This infrastructure is not complete yet and will be extended over time.
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 bus element is a separate object and is not implicitly described by the master (as done in I2C). The reason is that I want to be able to handle multiple master connected to the same bus and visible to Linux.
In this situation, we should only have one instance of the device andQuoted 8 lines
not one per master, and sharing the bus object would be part of the solution to gracefully handle this case.
I'm not sure we will ever need to deal with multiple masters controlling the same bus and exposed under Linux, but separating the bus and master concept is pretty easy, hence the decision to do it like that.
The other benefit of separating the bus and master concepts is that master devices appear under the bus directory in sysfs.
Quoted 1 line
Are bus multiplexers relevant to I3C?
Not yet, but who knows.
Quoted 2 lines
The locking needed for handling
muxes for I2C is, well, convoluted...
Do you remember what was the problem?
Anyway, I'd really like to have basic support upstreamed before we start considering advanced use cases that do not exist yet. Don't get me wrong, I'm not against having the multiplexer/locking discussion, but it should not block inclusion of the I3C subsystem.
Regards,
Boris
Re: [PATCH v5 01/10] i3c: Add core I3C infrastructure
Quoted 39 lines · Boris Brezillon
Hi Peter,
Quoted 27 lines · On Fri, 22 Jun 2018 23:35:34 +0200 Peter Rosin <[email protected]> wrote:
Quoted 17 lines · Boris Brezillon
Add core infrastructure to support I3C in Linux and document it.
This infrastructure is not complete yet and will be extended over time.
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 bus element is a separate object and is not implicitly described by the master (as done in I2C). The reason is that I want to be able to handle multiple master connected to the same bus and visible to Linux.
In this situation, we should only have one instance of the device andQuoted 8 lines
not one per master, and sharing the bus object would be part of the solution to gracefully handle this case.
I'm not sure we will ever need to deal with multiple masters controlling the same bus and exposed under Linux, but separating the bus and master concept is pretty easy, hence the decision to do it like that.
The other benefit of separating the bus and master concepts is that master devices appear under the bus directory in sysfs.Quoted 1 line
Are bus multiplexers relevant to I3C?
Not yet, but who knows.
Quoted 2 lines
The locking needed for handling
muxes for I2C is, well, convoluted...
Quoted 6 lines
Do you remember what was the problem?
Anyway, I'd really like to have basic support upstreamed before we start considering advanced use cases that do not exist yet. Don't get me wrong, I'm not against having the multiplexer/locking discussion, but it should not block inclusion of the I3C subsystem.
I'm trying to avoid the unfortunate situation in I2C where there are two slightly incompatible locking schemes for muxes. There's probably nothing to worry about until the first I3C mux is added though. But since I2C devices are supposedly compatible with I3C that might be the case from day one?
---
If I read your code right, I3C client drivers will typically call i3c_device_do_priv_xfer (instead of i2c_transfer/i2c_smbus_xfer) and i3c_device_do_prov_xfer will grab the i3c_bus_normaluse_lock during the transfer. This seems equivalent to normal use in I2C with i2c_transfer/i2c_smbus_xfer.
When muxes are thrown into the mix, you find yourself needing to do more than the "real" transfer with some lock held. In I2C there is an unlocked __i2c_transfer, and locking/unlocking is exposed. Muxes typically grab the lock, set the mux in the appropriate position, do an unlocked __i2c_transfer, optionally sets the mux in some default position and then lets go of the lock. See e.g. i2c/muxes/i2c-mux-pca954x.c
However, that is the simple case. There are also muxes that are controlled with GPIO pins, and that gets hairy if the GPIO pins are controlled from the same I2C bus that is muxed. The GPIO driver would have to know that some GPIO pins need to use unlocked I2C transfers for that to work with the above locking scheme. And no GPIO driver does not want to know about that at all. I.e. you have two fundamentally different requirement depending on if the GPIO pins controlling the mux are controlled using the muxed bus or if the pins are controlled in some completely unrelated way. The latter case is probably the normal case, with the GPIO mux controlled directly from some SoC pins. In the latter case you also want to prevent any transfer on the bus while the GPIO pins for the mux are changing, i.e. the total opposite of the former case. It gets really really hairy if you have multiple levels of muxes...
There are a some old drivers (e.g. i2c/busses/i2c-amd756-s4882.c) that handles this by simply bypassing the GPIO subsystem, but that is not really an option if some pins are used to mux the I2C bus while some pins are used for other things.
I don't know if this affects I3C before muxes are added, but I suspect muxes will happen sooner rather than later, since the spec mentions that the bus only support 11 devices maximum. 11 don't seem like a lot, and it seems likely that there will be a need to have more devices somehow...
But just maybe, in order to not run into the above situation, it needs to be handled right from the start with preparatory and cleanup stages of each transfers, or something?
Cheers,
Peter
Re: [PATCH v5 01/10] i3c: Add core I3C infrastructure
Quoted 47 lines · On Sat, 23 Jun 2018 23:40:36 +0200 Peter Rosin <[email protected]> wrote:
Quoted 39 lines · Boris Brezillon
Hi Peter,
Quoted 27 lines · On Fri, 22 Jun 2018 23:35:34 +0200 Peter Rosin <[email protected]> wrote:
Quoted 17 lines · Boris Brezillon
Add core infrastructure to support I3C in Linux and document it.
This infrastructure is not complete yet and will be extended over time.
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 bus element is a separate object and is not implicitly described by the master (as done in I2C). The reason is that I want to be able to handle multiple master connected to the same bus and visible to Linux.
In this situation, we should only have one instance of the device andQuoted 8 lines
not one per master, and sharing the bus object would be part of the solution to gracefully handle this case.
I'm not sure we will ever need to deal with multiple masters controlling the same bus and exposed under Linux, but separating the bus and master concept is pretty easy, hence the decision to do it like that.
The other benefit of separating the bus and master concepts is that master devices appear under the bus directory in sysfs.Quoted 1 line
Are bus multiplexers relevant to I3C?
Not yet, but who knows.
Quoted 2 lines
The locking needed for handling
muxes for I2C is, well, convoluted...Quoted 6 lines
Do you remember what was the problem?
Anyway, I'd really like to have basic support upstreamed before we start considering advanced use cases that do not exist yet. Don't get me wrong, I'm not against having the multiplexer/locking discussion, but it should not block inclusion of the I3C subsystem.
Quoted 5 lines
I'm trying to avoid the unfortunate situation in I2C where there are two slightly incompatible locking schemes for muxes. There's probably nothing to worry about until the first I3C mux is added though. But since I2C devices are supposedly compatible with I3C that might be the case from day one?
The I²C backward compatibility is implemented in a pretty simple way, so I don't think you'll have problems coming from the I3C part on this (unless it needs special hooks in i2c_adapter to work properly). This being said, if the I2C framework is already not able to properly handle the cases you describe below, the I3C layer won't solve that :-P.
Quoted 8 lines
---
If I read your code right, I3C client drivers will typically call
i3c_device_do_priv_xfer(instead of i2c_transfer/i2c_smbus_xfer) andi3c_device_do_prov_xferwill grab thei3c_bus_normaluse_lockduring the transfer. This seems equivalent to normal use in I2C with i2c_transfer/i2c_smbus_xfer.
Note that the bus lock is a read/write lock which is mostly taken in read mode (AKA normaluse mode). The only situation where it's taken in write mode (AKA maintenance mode) is when a bus maintenance operation is done. In this case, we need to block all future transfers, because maintenance operations might change dynamic device addresses, which would make future transfers irrelevant if they were queued before the maintenance operation is finished.
The bus lock does not guarantee proper serialization of bus accesses. This task is left to the controller drivers, since this is what they tend to optimize (by queuing transfers at the HW level).
Quoted 25 lines
When muxes are thrown into the mix, you find yourself needing to do more than the "real" transfer with some lock held. In I2C there is an unlocked
__i2c_transfer, and locking/unlocking is exposed. Muxes typically grab the lock, set the mux in the appropriate position, do an unlocked__i2c_transfer, optionally sets the mux in some default position and then lets go of the lock. See e.g.i2c/muxes/i2c-mux-pca954x.cHowever, that is the simple case. There are also muxes that are controlled with GPIO pins, and that gets hairy if the GPIO pins are controlled from the same I2C bus that is muxed. The GPIO driver would have to know that some GPIO pins need to use unlocked I2C transfers for that to work with the above locking scheme. And no GPIO driver does not want to know about that at all. I.e. you have two fundamentally different requirement depending on if the GPIO pins controlling the mux are controlled using the muxed bus or if the pins are controlled in some completely unrelated way. The latter case is probably the normal case, with the GPIO mux controlled directly from some SoC pins. In the latter case you also want to prevent any transfer on the bus while the GPIO pins for the mux are changing, i.e. the total opposite of the former case. It gets really really hairy if you have multiple levels of muxes...
Quoted 4 lines
There are a some old drivers (e.g.
i2c/busses/i2c-amd756-s4882.c) that handles this by simply bypassing the GPIO subsystem, but that is not really an option if some pins are used to mux the I2C bus while some pins are used for other things.
I see.
Quoted 6 lines
I don't know if this affects I3C before muxes are added, but I suspect muxes will happen sooner rather than later, since the spec mentions that the bus only support 11 devices maximum. 11 don't seem like a lot, and it seems likely that there will be a need to have more devices somehow...
I can't tell, and that's the whole problem here. How can you design a solution for something that does not exist yet? Fixing the I2C muxing logic, if it needs to be, is something I can understand. But how can you envision what I3C muxes (if they ever exist) will look like?
Quoted 4 lines
But just maybe, in order to not run into the above situation, it needs to be handled right from the start with preparatory and cleanup stages of each transfers, or something?
How about applying this approach to I2C first and see how it flies. Changing the I3C framework afterwards (when I3C muxes come in) shouldn't be that complicated.
Re: [PATCH v5 01/10] i3c: Add core I3C infrastructure
Quoted 80 lines · Boris Brezillon
Quoted 47 lines · On Sat, 23 Jun 2018 23:40:36 +0200 Peter Rosin <[email protected]> wrote:
Quoted 39 lines · Boris Brezillon
Hi Peter,
Quoted 27 lines · On Fri, 22 Jun 2018 23:35:34 +0200 Peter Rosin <[email protected]> wrote:
Quoted 17 lines · Boris Brezillon
Add core infrastructure to support I3C in Linux and document it.
This infrastructure is not complete yet and will be extended over time.
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 bus element is a separate object and is not implicitly described by the master (as done in I2C). The reason is that I want to be able to handle multiple master connected to the same bus and visible to Linux.
In this situation, we should only have one instance of the device andQuoted 8 lines
not one per master, and sharing the bus object would be part of the solution to gracefully handle this case.
I'm not sure we will ever need to deal with multiple masters controlling the same bus and exposed under Linux, but separating the bus and master concept is pretty easy, hence the decision to do it like that.
The other benefit of separating the bus and master concepts is that master devices appear under the bus directory in sysfs.Quoted 1 line
Are bus multiplexers relevant to I3C?
Not yet, but who knows.
Quoted 2 lines
The locking needed for handling
muxes for I2C is, well, convoluted...Quoted 6 lines
Do you remember what was the problem?
Anyway, I'd really like to have basic support upstreamed before we start considering advanced use cases that do not exist yet. Don't get me wrong, I'm not against having the multiplexer/locking discussion, but it should not block inclusion of the I3C subsystem.
Quoted 5 lines
I'm trying to avoid the unfortunate situation in I2C where there are two slightly incompatible locking schemes for muxes. There's probably nothing to worry about until the first I3C mux is added though. But since I2C devices are supposedly compatible with I3C that might be the case from day one?
The I²C backward compatibility is implemented in a pretty simple way, so I don't think you'll have problems coming from the I3C part on this (unless it needs special hooks in
i2c_adapterto work properly). This being said, if the I2C framework is already not able to properly handle the cases you describe below, the I3C layer won't solve that :-P.Quoted 8 lines
---
If I read your code right, I3C client drivers will typically call
i3c_device_do_priv_xfer(instead of i2c_transfer/i2c_smbus_xfer) andi3c_device_do_prov_xferwill grab thei3c_bus_normaluse_lockduring the transfer. This seems equivalent to normal use in I2C with i2c_transfer/i2c_smbus_xfer.Note that the bus lock is a read/write lock which is mostly taken in read mode (AKA normaluse mode). The only situation where it's taken in write mode (AKA maintenance mode) is when a bus maintenance operation is done. In this case, we need to block all future transfers, because maintenance operations might change dynamic device addresses, which would make future transfers irrelevant if they were queued before the maintenance operation is finished.
Quoted 3 lines
The bus lock does not guarantee proper serialization of bus accesses. This task is left to the controller drivers, since this is what they tend to optimize (by queuing transfers at the HW level).
Oh. Will that design decision (localized serialization) not make it extremely hard to implement muxing (and gating and other stuff that you need, at least for I2C) that is controller independent?
Quoted 38 lines
Quoted 24 lines
When muxes are thrown into the mix, you find yourself needing to do more than the "real" transfer with some lock held. In I2C there is an unlocked
__i2c_transfer, and locking/unlocking is exposed. Muxes typically grab the lock, set the mux in the appropriate position, do an unlocked__i2c_transfer, optionally sets the mux in some default position and then lets go of the lock. See e.g.i2c/muxes/i2c-mux-pca954x.cHowever, that is the simple case. There are also muxes that are controlled with GPIO pins, and that gets hairy if the GPIO pins are controlled from the same I2C bus that is muxed. The GPIO driver would have to know that some GPIO pins need to use unlocked I2C transfers for that to work with the above locking scheme. And no GPIO driver does not want to know about that at all. I.e. you have two fundamentally different requirement depending on if the GPIO pins controlling the mux are controlled using the muxed bus or if the pins are controlled in some completely unrelated way. The latter case is probably the normal case, with the GPIO mux controlled directly from some SoC pins. In the latter case you also want to prevent any transfer on the bus while the GPIO pins for the mux are changing, i.e. the total opposite of the former case. It gets really really hairy if you have multiple levels of muxes...
Quoted 4 lines
There are a some old drivers (e.g.
i2c/busses/i2c-amd756-s4882.c) that handles this by simply bypassing the GPIO subsystem, but that is not really an option if some pins are used to mux the I2C bus while some pins are used for other things.I see.
Quoted 6 lines
I don't know if this affects I3C before muxes are added, but I suspect muxes will happen sooner rather than later, since the spec mentions that the bus only support 11 devices maximum. 11 don't seem like a lot, and it seems likely that there will be a need to have more devices somehow...
Quoted 4 lines
I can't tell, and that's the whole problem here. How can you design a solution for something that does not exist yet? Fixing the I2C muxing logic, if it needs to be, is something I can understand. But how can you envision what I3C muxes (if they ever exist) will look like?
Yeah, you have a point there. One problem is that I don't even see how the situation can be unified for I2C...
Quoted 8 lines
Quoted 4 lines
But just maybe, in order to not run into the above situation, it needs to be handled right from the start with preparatory and cleanup stages of each transfers, or something?
How about applying this approach to I2C first and see how it flies. Changing the I3C framework afterwards (when I3C muxes come in) shouldn't be that complicated.
That would require more thinking first, and I fear that the overhaul will be bigger than what is called for given the rather fringe cases that cause problems.
Note that I'm not trying to block I3C, I'm just trying to trigger some thinking before the fact...
Cheers,
Peter
Re: [PATCH v5 01/10] i3c: Add core I3C infrastructure
Quoted 81 lines · On Sun, 24 Jun 2018 23:55:34 +0200 Peter Rosin <[email protected]> wrote:
Quoted 80 lines · Boris Brezillon
Quoted 47 lines · On Sat, 23 Jun 2018 23:40:36 +0200 Peter Rosin <[email protected]> wrote:
Quoted 39 lines · Boris Brezillon
Hi Peter,
Quoted 27 lines · On Fri, 22 Jun 2018 23:35:34 +0200 Peter Rosin <[email protected]> wrote:
Quoted 17 lines · Boris Brezillon
Add core infrastructure to support I3C in Linux and document it.
This infrastructure is not complete yet and will be extended over time.
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 bus element is a separate object and is not implicitly described by the master (as done in I2C). The reason is that I want to be able to handle multiple master connected to the same bus and visible to Linux.
In this situation, we should only have one instance of the device andQuoted 8 lines
not one per master, and sharing the bus object would be part of the solution to gracefully handle this case.
I'm not sure we will ever need to deal with multiple masters controlling the same bus and exposed under Linux, but separating the bus and master concept is pretty easy, hence the decision to do it like that.
The other benefit of separating the bus and master concepts is that master devices appear under the bus directory in sysfs.Quoted 1 line
Are bus multiplexers relevant to I3C?
Not yet, but who knows.
Quoted 2 lines
The locking needed for handling
muxes for I2C is, well, convoluted...Quoted 6 lines
Do you remember what was the problem?
Anyway, I'd really like to have basic support upstreamed before we start considering advanced use cases that do not exist yet. Don't get me wrong, I'm not against having the multiplexer/locking discussion, but it should not block inclusion of the I3C subsystem.
Quoted 5 lines
I'm trying to avoid the unfortunate situation in I2C where there are two slightly incompatible locking schemes for muxes. There's probably nothing to worry about until the first I3C mux is added though. But since I2C devices are supposedly compatible with I3C that might be the case from day one?
The I²C backward compatibility is implemented in a pretty simple way, so I don't think you'll have problems coming from the I3C part on this (unless it needs special hooks in
i2c_adapterto work properly). This being said, if the I2C framework is already not able to properly handle the cases you describe below, the I3C layer won't solve that :-P.Quoted 8 lines
---
If I read your code right, I3C client drivers will typically call
i3c_device_do_priv_xfer(instead of i2c_transfer/i2c_smbus_xfer) andi3c_device_do_prov_xferwill grab thei3c_bus_normaluse_lockduring the transfer. This seems equivalent to normal use in I2C with i2c_transfer/i2c_smbus_xfer.Note that the bus lock is a read/write lock which is mostly taken in read mode (AKA normaluse mode). The only situation where it's taken in write mode (AKA maintenance mode) is when a bus maintenance operation is done. In this case, we need to block all future transfers, because maintenance operations might change dynamic device addresses, which would make future transfers irrelevant if they were queued before the maintenance operation is finished.
Quoted 7 lines
Quoted 3 lines
The bus lock does not guarantee proper serialization of bus accesses. This task is left to the controller drivers, since this is what they tend to optimize (by queuing transfers at the HW level).
Oh. Will that design decision (localized serialization) not make it extremely hard to implement muxing (and gating and other stuff that you need, at least for I2C) that is controller independent?
The I²C framework has its own set of locks, and as I said earlier, I'm just implementing an i2c_adapter, so every I²C transfer will go through the standard I²C stack before being passed to the I3C framework (and then the I3C controller driver). I3C transfers going on the bus should have no impact here since they don't change the I2C mux state.
Regarding the fact that we might need a lock to get exclusive access on the I3C bus, it might become true at some point, but it clearly isn't right now. So instead of adding complexity for something we don't need, I decided to only add the locking that I knew was required.
Anyway, we're making assumptions on things we're not able to test or even validate based on a specification for a potential I3C mux, so I really think we should wait for the problem to actually appear instead of trying to fix it now.
Also, I have the feeling that I3C muxes will be closer to routers/bridges in their approach (the master bus would encapsulate frames that it wants to send on the sub-bus and the bridge would extract those frames and forward them). Also, dummy muxing is a hard thing to do in I3C because of the IBI stuff. If you really mux the bus in HW, you'll lose the ability of receiving IBIs on the non-active buses.
Of course, these are just speculations, but I don't see how dummy I3C muxes could work.
Quoted 39 lines
Quoted 39 lines
Quoted 25 lines
When muxes are thrown into the mix, you find yourself needing to do more than the "real" transfer with some lock held. In I2C there is an unlocked
__i2c_transfer, and locking/unlocking is exposed. Muxes typically grab the lock, set the mux in the appropriate position, do an unlocked__i2c_transfer, optionally sets the mux in some default position and then lets go of the lock. See e.g.i2c/muxes/i2c-mux-pca954x.cHowever, that is the simple case. There are also muxes that are controlled with GPIO pins, and that gets hairy if the GPIO pins are controlled from the same I2C bus that is muxed. The GPIO driver would have to know that some GPIO pins need to use unlocked I2C transfers for that to work with the above locking scheme. And no GPIO driver does not want to know about that at all. I.e. you have two fundamentally different requirement depending on if the GPIO pins controlling the mux are controlled using the muxed bus or if the pins are controlled in some completely unrelated way. The latter case is probably the normal case, with the GPIO mux controlled directly from some SoC pins. In the latter case you also want to prevent any transfer on the bus while the GPIO pins for the mux are changing, i.e. the total opposite of the former case. It gets really really hairy if you have multiple levels of muxes...
Quoted 4 lines
There are a some old drivers (e.g.
i2c/busses/i2c-amd756-s4882.c) that handles this by simply bypassing the GPIO subsystem, but that is not really an option if some pins are used to mux the I2C bus while some pins are used for other things.I see.
Quoted 6 lines
I don't know if this affects I3C before muxes are added, but I suspect muxes will happen sooner rather than later, since the spec mentions that the bus only support 11 devices maximum. 11 don't seem like a lot, and it seems likely that there will be a need to have more devices somehow...
Quoted 7 lines
Quoted 4 lines
I can't tell, and that's the whole problem here. How can you design a solution for something that does not exist yet? Fixing the I2C muxing logic, if it needs to be, is something I can understand. But how can you envision what I3C muxes (if they ever exist) will look like?
Yeah, you have a point there. One problem is that I don't even see how the situation can be unified for I2C...
That's a problem, indeed. I guess there was discussion with the I²C maintainers in the past, what was the outcome?
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
But just maybe, in order to not run into the above situation, it needs to be handled right from the start with preparatory and cleanup stages of each transfers, or something?
Quoted 7 lines
Quoted 3 lines
How about applying this approach to I2C first and see how it flies. Changing the I3C framework afterwards (when I3C muxes come in) shouldn't be that complicated.
That would require more thinking first, and I fear that the overhaul will be bigger than what is called for given the rather fringe cases that cause problems.
Ok.
Quoted 3 lines
Note that I'm not trying to block I3C, I'm just trying to trigger some thinking before the fact...
Just because the I3C framework is upstreamed doesn't mean everything is set in stone. If we need to change the locking-scheme because a new use case forces us to rework it, I'll be the first one to push for it, but right now, I don't see what we can do given the information we have.
Regards,
Boris
Re: [PATCH v5 01/10] i3c: Add core I3C infrastructure
In reply to Boris BrezillonHi Boris,
Quoted 36 lines · Boris Brezillon
drivers/i3c/master.c new file +36
-0+static int of_i3c_master_add_i3c_dev (struct i3c_master_controller *master, +struct device_node *node,u32 *reg) +{ +struct i3c_device_info info = { }; +enum i3c_addr_slot_status addrstatus; +struct i3c_device *i3cdev; +u32 init_dyn_addr =0 ; + +if (reg[0 ]) { +if (reg[0 ] >I3C_MAX_ADDR ) +return -EINVAL ; + + addrstatus =i3c_bus_get_addr_slot_status (master->bus, reg[0 ]); +if (addrstatus !=I3C_ADDR_SLOT_FREE ) +return -EINVAL ; + } + + info.static_addr = reg[0 ]; + +if (!of_property_read_u32 (node,"assigned-address" , &init_dyn_addr)) { +if (init_dyn_addr >I3C_MAX_ADDR ) +return -EINVAL ; + + addrstatus =i3c_bus_get_addr_slot_status (master->bus, + init_dyn_addr); +if (addrstatus !=I3C_ADDR_SLOT_FREE ) +return -EINVAL ; + } + + info.pid = ((u64 )reg[1 ] <<32 ) | reg[2 ]; + +if ((info.pid &GENMASK_ULL (63 ,48 )) || +I3C_PID_RND_LOWER_32BITS (info.pid)) +return -EINVAL ; + + i3cdev =i3c_master_alloc_i3c_dev (master, &info, &i3c_device_type);
drivers/i3c/master.c line 1243
Quoted 10 lines
drivers/i3c/master.c new file +10
-0+if (IS_ERR (i3cdev)) +return PTR_ERR (i3cdev); + + i3cdev->init_dyn_addr = init_dyn_addr; + i3cdev->dev.of_node = node; +list_add_tail (&i3cdev->common.node, &master->bus->devs.i3c); + +return 0 ; +} +
I'm writing the driver for the Synopsys master and but now I getting an issue.
I use the "slot" of the device to do all transfers, something like you use in DAA. I using the master_priv to save the "slot" per device but the problem is when I call the i3c_master_add_i3c_dev_locked() to retrieve the info I don't have it yet.
From my analysis this can be solve with:
- send PID, BCR and DCR when I call i3c_master_add_i3c_dev_locked() or similar function.
- Pre-allocate an i3c_device -> attach it (slot data goes to master_priv) -> retrieve info -> if there is already an i3c_device with same PID destroy the pre-allocated one.
- Replace the info.dyn_address with a structure with dyn_address and slot and use it in CCC structure.
This is something that will need to be supported for I3C HCI spec too. Do you have any suggestion?
Best regards,
Vitor Soares
Re: [PATCH v5 01/10] i3c: Add core I3C infrastructure
Hi Vitor,
Quoted 54 lines · On Thu, 28 Jun 2018 16:38:56 +0100 vitor <[email protected]> wrote:
Hi Boris,
Quoted 36 lines · Boris Brezillon
drivers/i3c/master.c new file +36
-0+static int of_i3c_master_add_i3c_dev (struct i3c_master_controller *master, +struct device_node *node,u32 *reg) +{ +struct i3c_device_info info = { }; +enum i3c_addr_slot_status addrstatus; +struct i3c_device *i3cdev; +u32 init_dyn_addr =0 ; + +if (reg[0 ]) { +if (reg[0 ] >I3C_MAX_ADDR ) +return -EINVAL ; + + addrstatus =i3c_bus_get_addr_slot_status (master->bus, reg[0 ]); +if (addrstatus !=I3C_ADDR_SLOT_FREE ) +return -EINVAL ; + } + + info.static_addr = reg[0 ]; + +if (!of_property_read_u32 (node,"assigned-address" , &init_dyn_addr)) { +if (init_dyn_addr >I3C_MAX_ADDR ) +return -EINVAL ; + + addrstatus =i3c_bus_get_addr_slot_status (master->bus, + init_dyn_addr); +if (addrstatus !=I3C_ADDR_SLOT_FREE ) +return -EINVAL ; + } + + info.pid = ((u64 )reg[1 ] <<32 ) | reg[2 ]; + +if ((info.pid &GENMASK_ULL (63 ,48 )) || +I3C_PID_RND_LOWER_32BITS (info.pid)) +return -EINVAL ; + + i3cdev =i3c_master_alloc_i3c_dev (master, &info, &i3c_device_type);drivers/i3c/master.c line 1243
Quoted 10 lines
drivers/i3c/master.c new file +10
-0+if (IS_ERR (i3cdev)) +return PTR_ERR (i3cdev); + + i3cdev->init_dyn_addr = init_dyn_addr; + i3cdev->dev.of_node = node; +list_add_tail (&i3cdev->common.node, &master->bus->devs.i3c); + +return 0 ; +} +I'm writing the driver for the Synopsys master and but now I getting an issue.
Quoted 4 lines
I use the "slot" of the device to do all transfers, something like you use in DAA. I using the
master_privto save the "slot" per device but the problem is when I call thei3c_master_add_i3c_dev_locked()to retrieve the info I don't have it yet.
Hm, I knew that might become a problem at some point. The Cadence IP does not need the slot index because it works with addresses and figure the device slot out of this address, but it looks like others don't go this road.
Quoted 4 lines
From my analysis this can be solve with:
- send PID, BCR and DCR when I calli3c_master_add_i3c_dev_locked()
or similar function.
Except these are not the only thing we retrieve before attaching the device. Also, if we go this road, that means we don't have the same path for devices whose dynamic address is assigned through SETDASA, and those that are discovered using DAA.
Quoted 3 lines
- Pre-allocate an
i3c_device-> attach it (slot data goes tomaster_priv) -> retrieve info -> if there is already ani3c_devicewith same PID destroy the pre-allocated one.
That's the very reason I didn't go this road. It gets messy if we already know this device. This being said, among all the options you list here, this is the one I prefer. Let's see if we can standardize the resource allocation/free process and let ->attach/detach() only take care of the device/bus configuration.
Quoted 2 lines
- Replace the info.dyn_address with a structure with
dyn_address
and slot and use it in CCC structure.
I'd really like to keep the device-slot-id a priv information, because we don't know how other IPs will deal with I3C device resources.
Quoted 2 lines
This is something that will need to be supported for I3C HCI spec too.
I agree.
Quoted 1 line
Do you have any suggestion?
I'll try to come up with something. Need to think a bit more about it.
Thanks,
Boris
Re: [PATCH v5 01/10] i3c: Add core I3C infrastructure
In reply to Boris BrezillonQuoted 7 lines · Boris Brezillon
Add core infrastructure to support I3C in Linux and document it.
This infrastructure is not complete yet and will be extended over time.
There are a few design choices that are worth mentioning because they impact the way I3C device drivers can interact with their devices..
I just realized I replied to the wrong version when I reviewed v4 of this patch. I think most of my comments still apply, so please see
https://lore.kernel.org/lkml/CAK8P3a1aZXf2sQW2mgwJScycKPhdoOAwxRjm5cQG83513uc3fg@mail.gmail.com/T/#u
and ignore anything that has changed in the meantime.
Arnd
PATCH v5 2/10 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 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/
--- Documentation/driver-api/i3c/device-driver-api.rst | 9 + Documentation/driver-api/i3c/index.rst | 11 ++ Documentation/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.14.1
Re: [PATCH v5 02/10] docs: driver-api: Add I3C documentation
Hi,
Quoted 37 lines · Boris Brezillon
Add the I3C documentation describing the protocol, the master driver API and the device driver API.
Signed-off-by Boris Brezillon <[email protected]>---
Changes in v5:
- Remove uselessconf.pyfile
- Add SPDX headersChanges in v2:
- Moved out of patch "i3c: Add core I3C infrastructure"
- Add link to the I3C spec
- Move rst files inDocumentation/driver-api/i3c/--- Documentation/driver-api/i3c/device-driver-api.rst | 9 + Documentation/driver-api/i3c/index.rst | 11 ++ Documentation/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.rstDocumentation/driver-api/i3c/protocol.rst new file +5
-0@@ -0,0 +1,203 @@ +.. SPDX-License-Identifier: GPL-2.0 + +============ +I3C protocol +============
Documentation/driver-api/i3c/protocol.rst line 15
Quoted 10 lines
Documentation/driver-api/i3c/protocol.rst new file +10
-0+ +Disclaimer +========== + +This chapter will focus on aspects that matter to software developers. For +everything hardware related (like how things are transmitted on the bus, how +collisions are prevented, ...) please have a look at the I3C specification. + +This document is just a brief introduction to the I3C protocol and the concepts +it brings on the table. If you need more information, please refer to the MIPI
brings to the table.
Quoted 67 lines
Documentation/driver-api/i3c/protocol.rst new file +67
-0+I3C specification (can be downloaded here +http://resources.mipi.org/mipi-i3c-v1-download). + +Introduction +============ + +The I3C (pronounced 'eye-three-see') is a MIPI standardized protocol designed +to overcome I2C limitations (limited speed, external signals needed for +interrupts, no automatic detection of the devices connected to the bus, ...) +while remaining power-efficient. + +I3C Bus +======= + +An I3C bus is made of several I3C devices and possibly some I2C devices as +well, but let's focus on I3C devices for now. + +An I3C device on the I3C bus can have one of the following roles: + +* Master: the device is driving the bus. It's the one in charge of initiating + transactions or deciding who is allowed to talk on the bus (slave generated + events are possible in I3C, see below). +* Slave: the device acts as a slave, and is not able to send frames to another + slave on the bus. The device can still send events to the master on + its own initiative if the master allowed it. + +I3C is a multi-master protocol, so there might be several masters on a bus, +though only one device can act as a master at a given time. In order to gain +bus ownership, a master has to follow a specific procedure. + +Each device on the I3C bus has to be assigned a dynamic address to be able to +communicate. Until this is done, the device should only respond to a limited +set of commands. If it has a static address (also called legacy I2C address), +the device can reply to I2C transfers. + +In addition to these per-device addresses, the protocol defines a broadcast +address in order to address all devices on the bus. + +Once a dynamic address has been assigned to a device, this address will be used +for any direct communication with the device. Note that even after being +assigned a dynamic address, the device should still process broadcast messages. + +I3C Device discovery +==================== + +The I3C protocol defines a mechanism to automatically discover devices present +on the bus, their capabilities and the functionalities they provide. In this +regard I3C is closer to a discoverable bus like USB than it is to I2C or SPI. + +The discovery mechanism is called DAA (Dynamic Address Assignment), because it +not only discovers devices but also assigns them a dynamic address. + +During DAA, each I3C device reports 3 important things: + +* BCR: Bus Characteristic Register. This 8-bit register describes the device bus + related capabilities +* DCR: Device Characteristic Register. This 8-bit register describes the + functionalities provided by the device +* Provisional ID: A 48-bit unique identifier. On a given bus there should be no + Provisional ID collision, otherwise the discovery mechanism may fail. + +I3C slave events +================ + +The I3C protocol allows slaves to generate events on their own, and thus allows +them to take temporary control of the bus. +
Documentation/driver-api/i3c/protocol.rst line 92
Quoted 10 lines
Documentation/driver-api/i3c/protocol.rst new file +10
-0+This mechanism is called IBI for In Band Interrupts, and as stated in the name, +it allows devices to generate interrupts without requiring an external signal. + +During DAA, each device on the bus has been assigned an address, and this +address will serve as a priority identifier to determine who wins if 2 different +devices are generating an interrupt at the same moment on the bus (the lower the +dynamic address the higher the priority). + +Masters are allowed to inhibit interrupts if they want to. This inhibition +request can be broadcasted (applies to all devices) or sent to a specific
can be broadcast
Documentation/driver-api/i3c/protocol.rst line 98
Quoted 6 lines
Documentation/driver-api/i3c/protocol.rst new file +6
-0+device. + +I3C Hot-Join +============ + +The Hot-Join mechanism is similart to USB hotplug. This mechanism allows
similar
Quoted 19 lines
Documentation/driver-api/i3c/protocol.rst new file +19
-0+slaves to join the bus after it has been initialized by the master. + +This covers the following use cases: + +* the device is not powered when the bus is probed +* the device is hotplugged on the bus through an extension board + +This mechanism is relying on slave events to inform the master that a new +device joined the bus and is waiting for a dynamic address. + +The master is then free to address the request as it wishes: ignore it or +assign a dynamic address to the slave. + +I3C transfer types +================== + +If you omit SMBus (which is just a standardization on how to access registers +exposed by I2C devices), I2C has only one transfer type. +
Documentation/driver-api/i3c/protocol.rst line 127
Quoted 10 lines
Documentation/driver-api/i3c/protocol.rst new file +10
-0+I3C defines 3 different classes of transfer in addition to I2C transfers which +are here for backward compatibility with I2C devices. + +I3C CCC commands +---------------- + +CCC (Common Command Code) commands are meant to be used for anything that is +related to bus management and all features that are common to a set of devices. + +CCC commands contain an 8-bit CCC id describing the command that is executed.
preferably s/id/ID/
Documentation/driver-api/i3c/protocol.rst line 128
Quoted 1 line
Documentation/driver-api/i3c/protocol.rst new file +1
-0+The MSB of this id specifies whether this is a broadcast command (bit7 = 0) or a
ditto, s/id/ID/
Documentation/driver-api/i3c/protocol.rst line 139
Quoted 11 lines
Documentation/driver-api/i3c/protocol.rst new file +11
-0+unicast one (bit7 = 1). + +The command ID can be followed by a payload. Depending on the command, this +payload is either sent by the master sending the command (write CCC command), +or sent by the slave receiving the command (read CCC command). Of course, read +accesses only apply to unicast commands. +Note that, when sending a CCC command to a specific device, the device address +is passed in the first byte of the payload. + +The payload length is not explicitly passed on the bus, and should be extracted +from the CCC id.
s/id/ID/
Documentation/driver-api/i3c/protocol.rst line 141
Quoted 2 lines
Documentation/driver-api/i3c/protocol.rst new file +2
-0+ +Note that vendors can use a dedicated range of CCC ids for their own commands
IDs
Documentation/driver-api/i3c/protocol.rst line 154
Quoted 13 lines
Documentation/driver-api/i3c/protocol.rst new file +13
-0+(0x61-0x7f and 0xe0-0xef). + +I3C Private SDR transfers +------------------------- + +Private SDR (Single Data Rate) transfers should be used for anything that is +device specific and does not require high transfer speed. + +It is the equivalent of I2C transfers but in the I3C world. Each transfer is +passed the device address (dynamic address assigned during DAA), a payload +and a direction. + +The only difference with I2C is that the transfer is much faster (typical SCL
what is SCL? It's not used anywhere else in this doc.
Quoted 13 lines
Documentation/driver-api/i3c/protocol.rst new file +13
-0+frequency is 12.5MHz). + +I3C HDR commands +---------------- + +HDR commands should be used for anything that is device specific and requires +high transfer speed. + +The first thing attached to an HDR command is the HDR mode. There are currently +3 different modes defined by the I3C specification (refer to the specification +for more details): + +* HDR-DDR: Double Data Rate mode
Documentation/driver-api/i3c/protocol.rst line 177
Quoted 10 lines
Documentation/driver-api/i3c/protocol.rst new file +10
-0+* HDR-TSP: Ternary Symbol Pure. Only usable on busses with no I2C devices +* HDR-TSL: Ternary Symbol Legacy. Usable on busses with I2C devices + +When sending an HDR command, the whole bus has to enter HDR mode, which is done +using a broadcast CCC command. +Once the bus has entered a specific HDR mode, the master sends the HDR command. +An HDR command is made of: + +* one 16-bits command word +* N 16-bits data words
I supposed the I3C spec will tell me the byte order of these words on the bus? or this doc could tell us here.
Documentation/driver-api/i3c/protocol.rst line 185
Quoted 8 lines
Documentation/driver-api/i3c/protocol.rst new file +8
-0+ +Those words may be wrapped with specific preambles/post-ambles which depend on +the chosen HDR mode and are detailed here (see the specification for more +details). + +The 16-bits command word is made of: + +* bit[15]: direction bit, read is 1 write is 0
read is 1, write is 0
Quoted 8 lines
Documentation/driver-api/i3c/protocol.rst new file +8
-0+* bit[14:8]: command code. Identifies the command being executed, the amount of + data words and their meaning +* bit[7:1]: I3C address of the device this command is addressed to +* bit[0]: reserved/parity-bit + +Backward compatibility with I2C devices +======================================= +
Documentation/driver-api/i3c/protocol.rst line 203
Quoted 10 lines
Documentation/driver-api/i3c/protocol.rst new file +10
-0+The I3C protocol has been designed to be backward compatible with I2C devices. +This backward compatibility allows one to connect a mix of I2C and I3C devices +on the same bus, though, in order to be really efficient, I2C devices should +be equipped with 50 ns spike filters. + +I2C devices can't be discovered like I3C ones and have to be statically +declared. In order to let the master know what these devices are capable of +(both in terms of bus related limitations and functionalities), the software +has to provide some information, which is done through the LVR (Legacy I2C +Virtual Register).
and you can add (if you want to):
thanks,
Signature · 1 line
~Randy
Re: [PATCH v5 02/10] docs: driver-api: Add I3C documentation
Hi Randy,
Quoted 6 lines · On Tue, 26 Jun 2018 14:07:49 -0700 Randy Dunlap <[email protected]> wrote:
Quoted 6 lines
Documentation/driver-api/i3c/protocol.rst new file +6
-0+ +I3C Private SDR transfers +------------------------- + +Private SDR (Single Data Rate) transfers should be used for anything that is +device specific and does not require high transfer speed.
Quoted 8 lines
Documentation/driver-api/i3c/protocol.rst line 154
Quoted 6 lines
Documentation/driver-api/i3c/protocol.rst new file +6
-0+ +It is the equivalent of I2C transfers but in the I3C world. Each transfer is +passed the device address (dynamic address assigned during DAA), a payload +and a direction. + +The only difference with I2C is that the transfer is much faster (typical SCLwhat is SCL? It's not used anywhere else in this doc.
It's an acronym used by I²C, it means Serial Clock Line. I'll just replace that by "typical clock frequency is 12.5MHz".
Quoted 19 lines
Quoted 19 lines
Documentation/driver-api/i3c/protocol.rst new file +18
-0+frequency is 12.5MHz). + +I3C HDR commands +---------------- + +HDR commands should be used for anything that is device specific and requires +high transfer speed. + +The first thing attached to an HDR command is the HDR mode. There are currently +3 different modes defined by the I3C specification (refer to the specification +for more details): + +* HDR-DDR: Double Data Rate mode +* HDR-TSP: Ternary Symbol Pure. Only usable on busses with no I2C devices +* HDR-TSL: Ternary Symbol Legacy. Usable on busses with I2C devices + +When sending an HDR command, the whole bus has to enter HDR mode, which is done +using a broadcast CCC command.
Quoted 8 lines
Documentation/driver-api/i3c/protocol.rst line 177
Quoted 5 lines
Documentation/driver-api/i3c/protocol.rst new file +5
-0+Once the bus has entered a specific HDR mode, the master sends the HDR command. +An HDR command is made of: + +* one 16-bits command word +* N 16-bits data wordsI supposed the I3C spec will tell me the byte order of these words on the bus? or this doc could tell us here.
It's big endian. I'll make it clear in this doc.
I'll also fix all the other mistakes you pointed out.
Quoted 3 lines
and you can add (if you want to):
Reviewed-by Randy Dunlap <[email protected]>
I'll definitely add your R-b. Thanks for the review.
Boris
PATCH v5 3/10 i3c: Add sysfs ABI spec
In reply to Boris BrezillonDocument sysfs files/directories/symlinks exposed by the I3C subsystem.
---
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 | 95 +++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-bus-i3c
Documentation/ABI/testing/sysfs-bus-i3c new file +95 -0
@@ -0,0 +1,95 @@ +What: /sys/bus/i3c/devices/i3c-<bus-id> +KernelVersion: 4.19 +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.19 +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.19 +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.19 +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.19 +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>/<bus-id>-<device-pid> +KernelVersion: 4.19 +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.19 +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.19 +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.19 +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.19 +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.19 +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.19 +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.14.1
PATCH v5 4/10 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 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 | 140 ++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 Documentation/devicetree/bindings/i3c/i3c.txt
Documentation/devicetree/bindings/i3c/i3c.txt new file +140 -0
@@ -0,0 +1,140 @@ +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: should have bit 31 set to 1 to signify that this is an I2C + device. Bits 0 to 7 encode the I3C LVR (Legacy Virtual + Register): + + 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 + + + third cell: should be 0 + +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>; + + status = "okay"; + i2c-scl-hz = <100000>; + + /* I2C device. */ + nunchuk: nunchuk@52 { + compatible = "nintendo,nunchuk"; + reg = <0x52 0x80000010 0x0>; + }; + + /* 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.14.1
Re: [PATCH v5 04/10] dt-bindings: i3c: Document core bindings
Quoted 13 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.
Documentation/devicetree/bindings/i3c/i3c.txt new file +9
-0+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: +--------------------------------------
...
Quoted 1 line
+ + third cell: should be 0
What for? Just to be future-proof, or do you have something specific in mind here?
Arnd
Re: [PATCH v5 04/10] dt-bindings: i3c: Document core bindings
Quoted 16 lines · On Wed, 11 Jul 2018 16:10:10 +0200 Arnd Bergmann <[email protected]> wrote:
Quoted 13 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.
Documentation/devicetree/bindings/i3c/i3c.txt new file +9
-0+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: +--------------------------------------...
Quoted 4 lines
Quoted 1 line
+ + third cell: should be 0
What for? Just to be future-proof, or do you have something specific in mind here?
Even if I2C devices only need 1 cell, I3C devices need 3 (1 for the static address and 2 for the PID). Since both type of devices are described under the same bus node, and we can have different #address-cells, I had to put 0-padding in the last cell.
Re: [PATCH v5 04/10] dt-bindings: i3c: Document core bindings
Quoted 21 lines · Boris Brezillon
Quoted 18 lines · On Wed, 11 Jul 2018 16:10:10 +0200 Arnd Bergmann <[email protected]> wrote:
Quoted 13 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.
Documentation/devicetree/bindings/i3c/i3c.txt new file +9
-0+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: +--------------------------------------...
Quoted 1 line
+ + third cell: should be 0
Quoted 7 lines
Quoted 2 lines
What for? Just to be future-proof, or do you have something specific in mind here?
Even if I2C devices only need 1 cell, I3C devices need 3 (1 for the static address and 2 for the PID). Since both type of devices are described under the same bus node, and we can have different #address-cells, I had to put 0-padding in the last cell.
Ok, got it.
Arnd
PATCH v5 5/10 dt-bindings: i3c: Add macros to help fill I3C/I2C device's reg property
In reply to Boris BrezillonThe reg property of devices connected to an I3C bus have 3 cells, and filling them manually is not trivial. Provides macros to help doing that.
---
Changes in v5:
- none
--- include/dt-bindings/i3c/i3c.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 include/dt-bindings/i3c/i3c.h
include/dt-bindings/i3c/i3c.h new file +28 -0
@@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) 2017 Cadence Design Systems Inc. +* +* Author: Boris Brezillon <[email protected]> +*/ + +#ifndef _DT_BINDINGS_I3C_I3C_H +#define _DT_BINDINGS_I3C_I3C_H + +#define IS_I2C_DEV 0x80000000 + +#define I2C_DEV (addr, lvr) \ + (addr) (IS_I2C_DEV | (lvr)) 0x0 + +#define I3C_PID (manufid, partid, instid, extrainfo) \ + ((manufid) << 1) \ + (((partid) << 16) | ((instid) << 12) | (extrainfo)) + +#define I3C_DEV_WITH_STATIC_ADDR (addr, manufid, partid, \ + instid, extrainfo) \ + (addr) I3C_PID(manufid, partid, instid, extrainfo) + +#define I3C_DEV (manufid, partid, instid, extrainfo) \ + I3C_DEV_WITH_STATIC_ADDR(0x0, manufid, partid, \ + instid, extrainfo) + +#endif
Signature · 1 line
2.14.1
PATCH v5 6/10 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 v5:
- Add the sysfs ABI file
--- MAINTAINERS | 10 ++++++++++ 1 file changed, 10 insertions(+)
MAINTAINERS +10 -0
@@ -6764,6 +6764,16 @@ L: [email protected] S: Maintained F: drivers/i2c/i2c-stub.c +I3C SUBSYSTEM +M: Boris Brezillon <[email protected]> +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.14.1
PATCH v5 7/10 i3c: master: Add driver for Cadence IP
In reply to Boris BrezillonAdd a driver for Cadence I3C master IP.
---
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 | 5 + drivers/i3c/master/Makefile | 1 + drivers/i3c/master/i3c-master-cdns.c | 1651 ++++++++++++++++++++++++++++++++++ 3 files changed, 1657 insertions(+) create mode 100644 drivers/i3c/master/i3c-master-cdns.c
drivers/i3c/master/Kconfig +5 -0
@@ -0,0 +1,5 @@ +config CDNS_I3C_MASTER + tristate "Cadence I3C master driver" + depends on I3C + 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 +1651 -0
1,651 lines not on this page · raw message
Signature · 1 line
2.14.1
Re: [PATCH v5 07/10] i3c: master: Add driver for Cadence IP
Quoted 1 line · Boris Brezillon
Add a driver for Cadence I3C master IP.
The driver seems very well-written and shows that the framework got that side of the interface right. Just one thing I noticed:
drivers/i3c/master/i3c-master-cdns.c line 1307
Quoted 11 lines
drivers/i3c/master/i3c-master-cdns.c new file +10
-0+ +static void cdns_i3c_master_handle_ibi (struct cdns_i3c_master *master, +u32 ibir) + + for (i = 0; i < IBIR_XFER_BYTES(ibir); i += 4) { +u32 tmp =readl (master->regs +IBI_DATA_FIFO ); + +for (j =0 ; j <4 && i + j < dev->ibi->max_payload_len; j++) + buf[i + j] = tmp >> (j *8 ); + }
This seems to be a rather inefficient way to open-code a readsl(). I suppose you need to handle length that is not a multiple of 4, right?
Maybe do it like
size_t length = IBIR_XFER_BYTES(ibir);
readsl(master->regs + IBI_DATA_FIFO, buf, length & ~3);
if (length & 3) {
u32 tmp = __raw_readl(master->regs + IBI_DATA_FIFO);
memcpy(buf + length & ~3, length & 3);
}
ArndPATCH v5 8/10 dt-bindings: i3c: Document Cadence I3C master bindings
In reply to Boris BrezillonDocument Cadence I3C master DT bindings.
---
Changes in v5:
- Add Rob's R-b
Changes in v4:
- Fix example to match the new representation
--- .../devicetree/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.14.1
PATCH v5 9/10 gpio: Add a driver for Cadence I3C GPIO expander
In reply to Boris BrezillonAdd a driver for Cadence I3C GPIO expander.
---
Hi Linus,
I intentionally did not report your Acked-by because of the scract buffer changes I added in this version (needed to follow the "buffer should be DMA-able" rule)
Feel free to add it back if you're okay with this version.
Regards,
Boris
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
@@ -898,6 +898,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.14.1
Randy Dunlap
reviewerRe: [PATCH v5 09/10] gpio: Add a driver for Cadence I3C GPIO expander
Hi,
Quoted 6 lines · Boris Brezillon
drivers/gpio/Kconfig +0
-0@@ -898,6 +898,17 @@ config GPIO_TS4900
drivers/gpio/Kconfig config GPIO_TS4900 · line 908
Quoted 10 lines
drivers/gpio/Kconfig +8
-0endmenu +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.
to enable the driver
Quoted 2 lines
drivers/gpio/Kconfig +2
-0+ +endmenu
Signature · 1 line
~Randy
Re: [PATCH v5 09/10] gpio: Add a driver for Cadence I3C GPIO expander
Quoted 11 lines · On Fri, 22 Jun 2018 09:04:47 -0700 Randy Dunlap <[email protected]> wrote:
Hi,
Quoted 8 lines · Boris Brezillon
drivers/gpio/Kconfig +0
-0@@ -898,6 +898,17 @@ config GPIO_TS4900 endmenu
Quoted 10 lines
drivers/gpio/Kconfig config GPIO_TS4900 · line 908
Quoted 8 lines
drivers/gpio/Kconfig +8
-0+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.to enable the driver
I'll fix this typo
Thanks,
Boris
Re: [PATCH v5 09/10] gpio: Add a driver for Cadence I3C GPIO expander
In reply to Boris BrezillonQuoted 5 lines · Boris Brezillon
Add a driver for Cadence I3C GPIO expander.
Signed-off-by Boris Brezillon <[email protected]>+ scratchbuf =
kmalloc(sizeof(*scratchbuf) * 2, GFP_KERNEL);
kmalloc_array() ?
Review
Quoted 2 lines
(quoted diff) +2
-0+ ret = i3c_device_do_priv_xfers(gpioc->i3cdev, xfers, + ARRAY_SIZE(xfers));
One line?
Quoted 5 lines
drivers/gpio/gpio-cdns-i3c.c new file +5
-0+static void cdns_i3c_gpio_set_multiple (struct gpio_chip *g, +unsigned long *mask, +unsigned long *bits) +{ +struct cdns_i3c_gpio *gpioc =gpioc_to_cdns_gpioc (g);
drivers/gpio/gpio-cdns-i3c.c line 123
Quoted 10 lines
drivers/gpio/gpio-cdns-i3c.c new file +10
-0+u8 newovr; +int ret; + + newovr = (gpioc->ovr & ~(*mask)) | (*bits & *mask); +if (newovr == gpioc->ovr) +return ; + + ret =cdns_i3c_gpio_write_reg (gpioc,OVR , newovr); +if (!ret) + gpioc->ovr = newovr;
You don't change mask here, why do you need a pointer to it?
Quoted 6 lines
drivers/gpio/gpio-cdns-i3c.c new file +5
-0+} +static int cdns_i3c_gpio_get_multiple (struct gpio_chip *g, +unsigned long *mask, +unsigned long *bits) +{
drivers/gpio/gpio-cdns-i3c.c line 187
Quoted 10 lines
drivers/gpio/gpio-cdns-i3c.c new file +10
-0+struct cdns_i3c_gpio *gpioc =gpioc_to_cdns_gpioc (g); +int ret; +u8 ivr; + + ret =cdns_i3c_gpio_read_reg (gpioc,IVR , &ivr); +if (ret) +return ret; + + *bits = ivr & *mask & gpioc->dir; + *bits |= gpioc->ovr & *mask & ~gpioc->dir;
Ditto.
drivers/gpio/gpio-cdns-i3c.c line 208
Quoted 10 lines
drivers/gpio/gpio-cdns-i3c.c new file +8
-0+ +return 0 ; +} +static void cdns_i3c_gpio_ibi_handler (struct i3c_device *i3cdev, +const struct i3c_ibi_payload *payload) +{ +struct cdns_i3c_gpio *gpioc =i3cdev_get_drvdata (i3cdev); +u8 isr =0 ;
Perhaps you need to check the result of _read_reg() below instead of dummy assignment?
drivers/gpio/gpio-cdns-i3c.c line 216
Quoted 9 lines
drivers/gpio/gpio-cdns-i3c.c new file +8
-0+int i; + +cdns_i3c_gpio_read_reg (gpioc,ISR , &isr); +for (i =0 ; i <8 ; i++) { +unsigned int irq; + +if (!(BIT (i) & isr & gpioc->imr)) +continue ;
for_each_set_bit() ?
drivers/gpio/gpio-cdns-i3c.c line 397
Quoted 10 lines
drivers/gpio/gpio-cdns-i3c.c new file +8
-0+ + irq =irq_find_mapping (gpioc->gpioc.irq.domain, i); +handle_nested_irq (irq); + } +} +static const struct i3c_device_id cdns_i3c_gpio_ids[] = { +I3C_DEVICE (0x1c9 ,0x0 ,NULL ), + {/* sentinel */ },
Slightly better without comma.
Quoted 2 lines
drivers/gpio/gpio-cdns-i3c.c new file +2
-0+}; +MODULE_DEVICE_TABLE (i3c, cdns_i3c_gpio_ids);
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v5 09/10] gpio: Add a driver for Cadence I3C GPIO expander
Hi Andy,
Quoted 25 lines · On Tue, 26 Jun 2018 22:07:03 +0300 Andy Shevchenko <[email protected]>…
Quoted 5 lines · Boris Brezillon
Add a driver for Cadence I3C GPIO expander.
Signed-off-by Boris Brezillon <[email protected]>+ scratchbuf =
kmalloc(sizeof(*scratchbuf) * 2, GFP_KERNEL);
kmalloc_array()?Review
Quoted 2 lines
(quoted diff) +2
-0+ ret = i3c_device_do_priv_xfers(gpioc->i3cdev, xfers, + ARRAY_SIZE(xfers));One line?
Quoted 9 lines
drivers/gpio/gpio-cdns-i3c.c new file +9
-0+static void cdns_i3c_gpio_set_multiple (struct gpio_chip *g, +unsigned long *mask, +unsigned long *bits) +{ +struct cdns_i3c_gpio *gpioc =gpioc_to_cdns_gpioc (g); +u8 newovr; +int ret; + + newovr = (gpioc->ovr & ~(*mask)) | (*bits & *mask);
Quoted 8 lines
drivers/gpio/gpio-cdns-i3c.c line 123
Quoted 6 lines
drivers/gpio/gpio-cdns-i3c.c new file +6
-0+if (newovr == gpioc->ovr) +return ; + + ret =cdns_i3c_gpio_write_reg (gpioc,OVR , newovr); +if (!ret) + gpioc->ovr = newovr;You don't change mask here, why do you need a pointer to it?
What are you talking about??!!! This is part of the gpio_chip interface that drivers have to implement. You can't decide that mask should not be a pointer. And if you actually look at the code, you'll probably see that the reason we're passed a pointer here is that the GPIO chip might expose more GPIOs than can be represented by an unsigned long, hence the array of unsigned long.
I'll say it here because this is not the first time I'm pissed off by one of your review. You seem to review everything that is posted on the LKML, and most of the time your reviews are superficial (focused on tiny details or coding style issues). Don't you have better things to do?
I mean, I'm fine when I get such comments from people that also do useful comments, but yours are most of the time useless and sometime even wrong because you didn't time to look at the code in details.
Quoted 62 lines
Quoted 7 lines
drivers/gpio/gpio-cdns-i3c.c new file +5
-0+} +static int cdns_i3c_gpio_get_multiple (struct gpio_chip *g, +unsigned long *mask, +unsigned long *bits) +{drivers/gpio/gpio-cdns-i3c.c line 187
Quoted 10 lines
drivers/gpio/gpio-cdns-i3c.c new file +10
-0+struct cdns_i3c_gpio *gpioc =gpioc_to_cdns_gpioc (g); +int ret; +u8 ivr; + + ret =cdns_i3c_gpio_read_reg (gpioc,IVR , &ivr); +if (ret) +return ret; + + *bits = ivr & *mask & gpioc->dir; + *bits |= gpioc->ovr & *mask & ~gpioc->dir;Ditto.
drivers/gpio/gpio-cdns-i3c.c line 208
Quoted 10 lines
drivers/gpio/gpio-cdns-i3c.c new file +8
-0+ +return 0 ; +} +static void cdns_i3c_gpio_ibi_handler (struct i3c_device *i3cdev, +const struct i3c_ibi_payload *payload) +{ +struct cdns_i3c_gpio *gpioc =i3cdev_get_drvdata (i3cdev); +u8 isr =0 ;Perhaps you need to check the result of
_read_reg()below instead of dummy assignment?drivers/gpio/gpio-cdns-i3c.c line 216
Quoted 9 lines
drivers/gpio/gpio-cdns-i3c.c new file +8
-0+int i; + +cdns_i3c_gpio_read_reg (gpioc,ISR , &isr); +for (i =0 ; i <8 ; i++) { +unsigned int irq; + +if (!(BIT (i) & isr & gpioc->imr)) +continue ;
for_each_set_bit()?drivers/gpio/gpio-cdns-i3c.c line 397
Quoted 10 lines
drivers/gpio/gpio-cdns-i3c.c new file +8
-0+ + irq =irq_find_mapping (gpioc->gpioc.irq.domain, i); +handle_nested_irq (irq); + } +} +static const struct i3c_device_id cdns_i3c_gpio_ids[] = { +I3C_DEVICE (0x1c9 ,0x0 ,NULL ), + {/* sentinel */ },Slightly better without comma.
Quoted 2 lines
drivers/gpio/gpio-cdns-i3c.c new file +2
-0+}; +MODULE_DEVICE_TABLE (i3c, cdns_i3c_gpio_ids);
Re: [PATCH v5 09/10] gpio: Add a driver for Cadence I3C GPIO expander
Quoted 28 lines · Boris Brezillon
Quoted 10 lines · On Tue, 26 Jun 2018 22:07:03 +0300 Andy Shevchenko <[email protected]>…
Quoted 5 lines · Boris Brezillon
Add a driver for Cadence I3C GPIO expander.
Signed-off-by Boris Brezillon <[email protected]>+ scratchbuf =
kmalloc(sizeof(*scratchbuf) * 2, GFP_KERNEL);
kmalloc_array()?Quoted 7 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ ret = i3c_device_do_priv_xfers(gpioc->i3cdev, xfers, + ARRAY_SIZE(xfers));One line?
You don't change mask here, why do you need a pointer to it?
What are you talking about??!!! This is part of the
gpio_chipinterface that drivers have to implement. You can't decide that mask should not be a pointer. And if you actually look at the code, you'll probably see that the reason we're passed a pointer here is that the GPIO chip might expose more GPIOs than can be represented by an unsigned long, hence the array of unsigned long.
Quoted 2 lines
I'll say it here because this is not the first time I'm pissed off by one of your review.
Like 'I like offending people, because I think people who get offended should be offended.' ?
I'm not that guy, relax.
Quoted 1 line
You seem to review everything that is posted on the LKML,
That's not true.
Quoted 2 lines
and most of the time your reviews are superficial (focused on tiny details or coding style issues). Don't you have better things to do?
If your code is written using ancient style and / or API it's not good to start with.
Isn't it? Otherwise, why we do introduce new internal APIs, for what purpose?
On top of that you might find more interesting reviews where I pointed out to a memory leak or other nasty stuff. But of course you prefer not to norice that.
I understand you.
Quoted 3 lines
I mean, I'm fine when I get such comments from people that also do useful comments, but yours are most of the time useless and sometime even wrong because you didn't time to look at the code in details.
Calm down, please.
You would simple ignore them. Your choice.
But okay, I would try to avoid your stuff to make you happier. Sorry for disturbing.
Quoted 1 line
Quoted 1 line
Ditto.
In these two comments I'm indeed wrong.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v5 09/10] gpio: Add a driver for Cadence I3C GPIO expander
Quoted 30 lines · On Tue, 26 Jun 2018 23:44:36 +0300 Andy Shevchenko <[email protected]>…
Quoted 27 lines · Boris Brezillon
Quoted 10 lines · On Tue, 26 Jun 2018 22:07:03 +0300 Andy Shevchenko <[email protected]>…
Quoted 5 lines · Boris Brezillon
Add a driver for Cadence I3C GPIO expander.
Signed-off-by Boris Brezillon <[email protected]>+ scratchbuf =
kmalloc(sizeof(*scratchbuf) * 2, GFP_KERNEL);
kmalloc_array()?Quoted 7 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ ret = i3c_device_do_priv_xfers(gpioc->i3cdev, xfers, + ARRAY_SIZE(xfers));One line?
You don't change mask here, why do you need a pointer to it?
What are you talking about??!!! This is part of the
gpio_chipinterface that drivers have to implement. You can't decide that mask should not be a pointer. And if you actually look at the code, you'll probably see that the reason we're passed a pointer here is that the GPIO chip might expose more GPIOs than can be represented by an unsigned long, hence the array of unsigned long.
Quoted 6 lines
Quoted 2 lines
I'll say it here because this is not the first time I'm pissed off by one of your review.
Like 'I like offending people, because I think people who get offended should be offended.' ?
I'm not that guy, relax.
I'm not offended, just annoyed, and not because I have things to change in my patchset (I'm used to that and that's something I comply with most of the time), but because the only reviews I had from you were of this kind (nitpicking on minor stuff).
Quoted 11 lines
Quoted 2 lines
You seem to review everything that is posted on the LKML,
That's not true.
Quoted 2 lines
and most of the time your reviews are superficial (focused on tiny details or coding style issues). Don't you have better things to do?
If your code is written using ancient style and / or API it's not good to start with.
Isn't it? Otherwise, why we do introduce new internal APIs, for what purpose?
Come on!
- kzalloc() vs kmalloc_array()
- for (i = 0; i < n, i++) { if (BIT(x) & var) ... }
vs
for_each_bit_set() (which is not even applicable here because I'm not manipulating an unsigned long)
Where do you see ancient style APIs here?
And that's not even the problem. I'm okay to fix those things, but you only ever do these kind of reviews, and sometime you even act like you know better than the developer or the maintainer how the code should be organized without even digging enough to have a clue (your comment on the fact that mask should not be a pointer is a good example of such situations).
Quoted 4 lines
On top of that you might find more interesting reviews where I pointed out to a memory leak or other nasty stuff. But of course you prefer not to norice that.
Yes, sometime you have valid point, but it gets lost in all the noise.
Quoted 7 lines
I understand you.
Quoted 3 lines
I mean, I'm fine when I get such comments from people that also do useful comments, but yours are most of the time useless and sometime even wrong because you didn't time to look at the code in details.
Calm down, please.
Why? Because I say you didn't look at the code in details? Isn't it true? Did you look at what I3C is, how it works or how the I3C framework is architectured? Because that's the kind of reviews I'd love to have on this series.
Quoted 1 line
You would simple ignore them. Your choice.
That's not my point. My point is, maybe you should do less reviews but spend more time on each of them so you don't just scratch the surface with comments I could get from a tool like checkpatch.
Re: [PATCH v5 09/10] gpio: Add a driver for Cadence I3C GPIO expander
Quoted 12 lines · Boris Brezillon
Quoted 10 lines · On Tue, 26 Jun 2018 23:44:36 +0300 Andy Shevchenko <[email protected]>…
Quoted 7 lines · Boris Brezillon
Quoted 2 lines · On Tue, 26 Jun 2018 22:07:03 +0300 Andy Shevchenko <[email protected]>…
On Fri, Jun 22, 2018 at 1:49 PM, Boris Brezillon
<[email protected]> wrote:I'll say it here because this is not the first time I'm pissed off by one of your review.
Quoted 8 lines
Quoted 3 lines
Like 'I like offending people, because I think people who get offended should be offended.' ?
I'm not that guy, relax.I'm not offended, just annoyed, and not because I have things to change in my patchset (I'm used to that and that's something I comply with most of the time), but because the only reviews I had from you were of this kind (nitpicking on minor stuff).
OK, point taken.
Quoted 9 lines
Quoted 6 lines
Quoted 2 lines
and most of the time your reviews are superficial (focused on tiny details or coding style issues). Don't you have better things to do?
If your code is written using ancient style and / or API it's not good to start with.
Isn't it? Otherwise, why we do introduce new internal APIs, for what purpose?Come on!
Quoted 7 lines
-
kzalloc()vskmalloc_array()
- for (i = 0; i < n, i++) { if (BIT(x) & var) ... }
vs
for_each_bit_set()(which is not even applicable here because I'm not manipulating an unsigned long)Where do you see ancient style APIs here?
Both. kmalloc_array() and for_each_set_bit() were introduced quite long time ago.
On top of that you are open coding, if I'm not mistaken, cpu_to_be32() and be32_to_cpu().
...and more I believe.
Quoted 6 lines
And that's not even the problem. I'm okay to fix those things, but you only ever do these kind of reviews, and sometime you even act like you know better than the developer or the maintainer how the code should be organized without even digging enough to have a clue (your comment on the fact that mask should not be a pointer is a good example of such situations).
"sometime". Yes, I admit my mistakes.
Quoted 5 lines
Quoted 3 lines
On top of that you might find more interesting reviews where I pointed out to a memory leak or other nasty stuff. But of course you prefer not to norice that.
Yes, sometime you have valid point, but it gets lost in all the noise.
Btw, you forgot to call of_node_put() on error path in one case. Did I again missed the details?
Quoted 10 lines
Quoted 5 lines
Quoted 3 lines
I mean, I'm fine when I get such comments from people that also do useful comments, but yours are most of the time useless and sometime even wrong because you didn't time to look at the code in details.
Calm down, please.
Why? Because I say you didn't look at the code in details? Isn't it true? Did you look at what I3C is, how it works or how the I3C framework is architectured? Because that's the kind of reviews I'd love to have on this series.
You got me.
I have a copy of the spec, this require a bit of time to go through.
For now I can offer you to consider IBI implementation using IRQ chip framework. It would give few advantages (like we do this for GPIO), such as IRQ statistics or wake up capabilities.
Quoted 4 lines
Quoted 1 line
You would simple ignore them. Your choice.
That's not my point. My point is, maybe you should do less reviews but spend more time on each of them
Good point.
Quoted 2 lines
so you don't just scratch the surface
with comments I could get from a tool like checkpatch.
Perhaps you should run checkpatch yourself then?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v5 09/10] gpio: Add a driver for Cadence I3C GPIO expander
Hi Andy,
Quoted 40 lines · On Wed, 27 Jun 2018 20:53:51 +0300 Andy Shevchenko <[email protected]>…
Quoted 12 lines · Boris Brezillon
Quoted 10 lines · On Tue, 26 Jun 2018 23:44:36 +0300 Andy Shevchenko <[email protected]>…
Quoted 7 lines · Boris Brezillon
Quoted 2 lines · On Tue, 26 Jun 2018 22:07:03 +0300 Andy Shevchenko <[email protected]>…
On Fri, Jun 22, 2018 at 1:49 PM, Boris Brezillon
<[email protected]> wrote:I'll say it here because this is not the first time I'm pissed off by one of your review.
Quoted 8 lines
Quoted 3 lines
Like 'I like offending people, because I think people who get offended should be offended.' ?
I'm not that guy, relax.I'm not offended, just annoyed, and not because I have things to change in my patchset (I'm used to that and that's something I comply with most of the time), but because the only reviews I had from you were of this kind (nitpicking on minor stuff).
OK, point taken.
Quoted 15 lines
Quoted 6 lines
Quoted 2 lines
and most of the time your reviews are superficial (focused on tiny details or coding style issues). Don't you have better things to do?
If your code is written using ancient style and / or API it's not good to start with.
Isn't it? Otherwise, why we do introduce new internal APIs, for what purpose?Come on!
-
kzalloc()vskmalloc_array()
- for (i = 0; i < n, i++) { if (BIT(x) & var) ... }
vs
for_each_bit_set()(which is not even applicable here because I'm not manipulating an unsigned long)
Quoted 4 lines
Quoted 1 line
Where do you see ancient style APIs here?
Both.
kmalloc_array()andfor_each_set_bit()were introduced quite long time ago.
I mean, kzalloc() is not deprecated AFAIK and I don't really see the benefit of using kmalloc_array(), but if that makes you happy, let's go for kmalloc_array().
For for_each_bit_set() it would require changing the type of isr + having a temporary variable to get the reg value into an u8. Again, I can do the change, but I don't really see how it improves the code.
Quoted 3 lines
On top of that you are open coding, if I'm not mistaken,
cpu_to_be32()andbe32_to_cpu().
Care to point where?
Quoted 1 line
...and more I believe.
Care to point what?
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
On top of that you might find more interesting reviews where I pointed out to a memory leak or other nasty stuff. But of course you prefer not to norice that.
Yes, sometime you have valid point, but it gets lost in all the noise.
Btw, you forgot to call
of_node_put()on error path in one case.
In this driver or another patch of the series? I don't see any of_node_get() call in this GPIO driver, but maybe it's something done in one of the GPIO helper.
Quoted 9 lines
Did I
again missed the details?Quoted 6 lines
Quoted 5 lines
Quoted 3 lines
I mean, I'm fine when I get such comments from people that also do useful comments, but yours are most of the time useless and sometime even wrong because you didn't time to look at the code in details.
Calm down, please.
Quoted 7 lines
Quoted 4 lines
Why? Because I say you didn't look at the code in details? Isn't it true? Did you look at what I3C is, how it works or how the I3C framework is architectured? Because that's the kind of reviews I'd love to have on this series.
You got me.
I have a copy of the spec, this require a bit of time to go through.
Cool!
Quoted 4 lines
For now I can offer you to consider IBI implementation using IRQ chip framework. It would give few advantages (like we do this for GPIO), such as IRQ statistics or wake up capabilities.
Just pasting the comment I made in my cover letter:
"
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.
"
To sum-up, yes I tried implementing what you suggest, and it ended being messy for 2 main reasons:
1/ IBIs have payload attached to them, and exposing IBIs are regular IRQs meant adding a payload queuing mechanism to the i3c_device so that the I3C device driver could dequeue each payload independently. Clearly not impossible to deal with, but conceptually far from the concept of IRQs we have in Linux.
2/ The I3C APIs are meant to be used in non-atomic context, but if you expose IBIs are regular IRQs, the irqchip will have to mask/unmask the IRQs from an atomic context, and masking/unmasking IRQs almost always implies doing a CCC or priv SDR transfer. Plus, most of the time you'll have to retrieve extra info from the IRQ handler, which again means sending frames on the I3C bus. We could make that work by either supporting async transfers or having the irq chip handle the IRQ handlers from a thread. But both options add extra complexity for no real benefit given that IBIs are already not exactly fitting in the Linux IRQ model.
The discussion I had with Mark Zyngier finished convincing me that IBIs would be better exposed with their own API.
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines
You would simple ignore them. Your choice.
That's not my point. My point is, maybe you should do less reviews but spend more time on each of them
Quoted 7 lines
Good point.
Quoted 2 lines
so you don't just scratch the surface
with comments I could get from a tool like checkpatch.Perhaps you should run checkpatch yourself then?
I do run checkpatch --strict and fix most of the thing reported except those hurting readability. I don't remember seeing checkpatch complain about kzalloc() usage, and I guess it's not smart enough to detect that for_each_bit_set() can be used to replace the "for() if (BIT(x) & val)" pattern.
Anyway, thanks for having a look at the I3C spec and starting the discussion on IBIs. I guess I owe you an apology.
Regards,
Boris
Re: [PATCH v5 09/10] gpio: Add a driver for Cadence I3C GPIO expander
Quoted 3 lines · Boris Brezillon
I mean,
kzalloc()is not deprecated AFAIK and I don't really see the benefit of usingkmalloc_array(), but if that makes you happy, let's go forkmalloc_array().
kcalloc
Quoted 5 lines
I do run checkpatch --strict and fix most of the thing reported except those hurting readability. I don't remember seeing checkpatch complain about
kzalloc()usage, and I guess it's not smart enough to detect thatfor_each_bit_set()can be used to replace the "for()if (BIT(x) & val)" pattern.
That would not an appropriate conversion suggestion in any case. coccinelle could at least look at whether or not x is allocated as a bitmap via DECLARE_BITMAP or bitmap_alloc
Re: [PATCH v5 09/10] gpio: Add a driver for Cadence I3C GPIO expander
Quoted 6 lines · Joe Perches
Quoted 3 lines · Boris Brezillon
I mean,
kzalloc()is not deprecated AFAIK and I don't really see the benefit of usingkmalloc_array(), but if that makes you happy, let's go forkmalloc_array().kcalloc
IIRC in the original code kmalloc(x*y) is used.
Quoted 9 lines
Quoted 5 lines
I do run checkpatch --strict and fix most of the thing reported except those hurting readability. I don't remember seeing checkpatch complain about
kzalloc()usage, and I guess it's not smart enough to detect thatfor_each_bit_set()can be used to replace the "for()if (BIT(x) & val)" pattern.That would not an appropriate conversion suggestion in any case. coccinelle could at least look at whether or not x is allocated as a bitmap via
DECLARE_BITMAPorbitmap_alloc
Huh?!
bitmap operations are working against unsigned long *. one long is also a bitmap.
So, that coccinelle scripts must be fixed accordingly.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v5 09/10] gpio: Add a driver for Cadence I3C GPIO expander
Quoted 2 lines · Andy Shevchenko
bitmap operations are working against unsigned long *. one long is also a bitmap.
Should only be so if declared via DECLARE_BITMAP
Quoted 1 line
So, that coccinelle scripts must be fixed accordingly.
We disagree about a non-existent script.
Re: [PATCH v5 09/10] gpio: Add a driver for Cadence I3C GPIO expander
In reply to Boris BrezillonQuoted 3 lines · Boris Brezillon
Add a driver for Cadence I3C GPIO expander.
Signed-off-by Boris Brezillon <[email protected]>
If you need to merge this through the subsystem merge.
I see there was some heat in this discussion between you and Andy, and it seems to be resolved. Which is good because you are both senior contributors that I value a lot.
Yours,
Linus Walleij
Re: [PATCH v5 09/10] gpio: Add a driver for Cadence I3C GPIO expander
Quoted 5 lines
I see there was some heat in this discussion between you and Andy, and it seems to be resolved. Which is good because you are both senior contributors that I value a lot.
+1
PATCH v5 10/10 dt-bindings: gpio: Add bindings for Cadence I3C gpio expander
In reply to Boris BrezillonDocument the Cadence I3C gpio expander bindings.
---
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
--- .../devicetree/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.14.1