MCTP I2C driver
Subsystems (5)
Matt Johnston
maintainerv5 cover MCTP I2C driver
Hi,
This patch series adds a netdev driver providing MCTP transport over I2C.
Since the v3 submission I have switched to using I2C transfers which support >32 bytes. It could be switch back to smbus transfers once 255 byte support is ready. It now doesn't require any changes to I2C core.
The dt-bindings patch went through review on the list.
Cheers,
Matt
--
v5:
- Fix incorrect format string
v4:
- Switch to __i2c_transfer() rather than __i2c_smbus_xfer(), drop 255 byte smbus patches
- Use wait_event_idle() for the sleeping TX thread
- Use dev_addr_set()
v3:
- Added Reviewed-bys for npcm7xx
- Resend with net-next open
v2:
- Simpler Kconfig condition for i2c-mux dependency, from Randy Dunlap
Matt Johnston (2):
dt-bindings: net: New binding mctp-i2c-controller mctp i2c: MCTP I2C binding driver
Documentation/devicetree/bindings/i2c/i2c.txt | 4 + .../bindings/net/mctp-i2c-controller.yaml | 92 ++ drivers/net/mctp/Kconfig | 13 + drivers/net/mctp/Makefile | 1 + drivers/net/mctp/mctp-i2c.c | 1002 +++++++++++++++++ 5 files changed, 1112 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/mctp-i2c-controller.yaml create mode 100644 drivers/net/mctp/mctp-i2c.c
Signature · 1 line
2.32.0
Matt Johnston
maintainerPATCH v5 1/2 dt-bindings: net: New binding mctp-i2c-controller
Used to define a local endpoint to communicate with MCTP peripherals attached to an I2C bus. This I2C endpoint can communicate with remote MCTP devices on the I2C bus.
In the example I2C topology below (matching the second yaml example) we have MCTP devices on busses i2c1 and i2c6. MCTP-supporting busses are indicated by the 'mctp-controller' DT property on an I2C bus node.
A mctp-i2c-controller I2C client DT node is placed at the top of the mux topology, since only the root I2C adapter will support I2C slave functionality.
.-------.
|eeprom |
.------------. .------. /'-------'
| adapter | | mux --@0,i2c5------'
| i2c1 ----.*| --@1,i2c6--.--.
|............| \'------' \ \ .........
| mctp-i2c- | \ \ \ .mctpB .
| controller | \ \ '.0x30 .
| | \ ......... \ '.......'
| 0x50 | \ .mctpA . \ .........
'------------' '.0x1d . '.mctpC .
'.......' '.0x31 .
'.......'(mctpX boxes above are remote MCTP devices not included in the DT at present, they can be hotplugged/probed at runtime. A DT binding for specific fixed MCTP devices could be added later if required)
--- Documentation/devicetree/bindings/i2c/i2c.txt | 4 + .../bindings/net/mctp-i2c-controller.yaml | 92 +++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/mctp-i2c-controller.yaml
Documentation/devicetree/bindings/i2c/i2c.txt +4 -0
@@ -95,6 +95,10 @@ wants to support one of the below features, it should adapt these bindings. - smbus-alert states that the optional SMBus-Alert feature apply to this bus. +- mctp-controller + indicates that the system is accessible via this bus as an endpoint for + MCTP over I2C transport. + Required properties (per child device) --------------------------------------
Documentation/devicetree/bindings/net/mctp-i2c-controller.yaml new file +92 -0
92 lines not on this page · raw message
Signature · 1 line
2.32.0
Rob Herring
maintainerRe: [PATCH net-next v5 1/2] dt-bindings: net: New binding mctp-i2c-controller
Quoted 1 line · Matt Johnston
No need to resend, but the DT list should be CCed so that checks run. They do fail sometimes after I've reviewed patches.
Quoted 152 lines
Used to define a local endpoint to communicate with MCTP peripherals attached to an I2C bus. This I2C endpoint can communicate with remote MCTP devices on the I2C bus.
In the example I2C topology below (matching the second yaml example) we have MCTP devices on busses i2c1 and i2c6. MCTP-supporting busses are indicated by the 'mctp-controller' DT property on an I2C bus node.
A mctp-i2c-controller I2C client DT node is placed at the top of the mux topology, since only the root I2C adapter will support I2C slave functionality.
.-------. |eeprom | .------------. .------. /'-------' | adapter | | mux --@0,i2c5------' | i2c1 ----.*| --@1,i2c6--.--. |............| \'------' \ \ ......... | mctp-i2c- | \ \ \ .mctpB . | controller | \ \ '.0x30 . | | \ ......... \ '.......' | 0x50 | \ .mctpA . \ ......... '------------' '.0x1d . '.mctpC . '.......' '.0x31 . '.......'(mctpX boxes above are remote MCTP devices not included in the DT at present, they can be hotplugged/probed at runtime. A DT binding for specific fixed MCTP devices could be added later if required)
Signed-off-by Matt Johnston <[email protected]>Reviewed-by Rob Herring <[email protected]>--- Documentation/devicetree/bindings/i2c/i2c.txt | 4 + .../bindings/net/mctp-i2c-controller.yaml | 92 +++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/mctp-i2c-controller.yamlDocumentation/devicetree/bindings/i2c/i2c.txt +4
-0@@ -95,6 +95,10 @@ wants to support one of the below features, it should adapt these bindings. - smbus-alert states that the optional SMBus-Alert feature apply to this bus. +- mctp-controller + indicates that the system is accessible via this bus as an endpoint for + MCTP over I2C transport. + Required properties (per child device) --------------------------------------Documentation/devicetree/bindings/net/mctp-i2c-controller.yaml new file +92
-1@@ -0,0 +1,92 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/mctp-i2c-controller.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: MCTP I2C transport binding + +maintainers: + - Matt Johnston <[email protected]> + +description: | + An mctp-i2c-controller defines a local MCTP endpoint on an I2C controller. + MCTP I2C is specified by DMTF DSP0237. + + An mctp-i2c-controller must be attached to an I2C adapter which supports + slave functionality. I2C busses (either directly or as subordinate mux + busses) are attached to the mctp-i2c-controller with a 'mctp-controller' + property on each used bus. Each mctp-controller I2C bus will be presented + to the host system as a separate MCTP I2C instance. + +properties: + compatible: + const: mctp-i2c-controller + + reg: + minimum: 0x40000000 + maximum: 0x4000007f + description: | + 7 bit I2C address of the local endpoint. + I2C_OWN_SLAVE_ADDRESS (1<<30) flag must be set. + +additionalProperties: false + +required: + - compatible + - reg + +examples: + - | + // Basic case of a single I2C bus + #include <dt-bindings/i2c/i2c.h> + + i2c { + #address-cells = <1>; + #size-cells = <0>; + mctp-controller; + + mctp@30 { + compatible = "mctp-i2c-controller"; + reg = <(0x30 | I2C_OWN_SLAVE_ADDRESS)>; + }; + }; + + - | + // Mux topology with multiple MCTP-handling busses under + // a single mctp-i2c-controller. + // i2c1 and i2c6 can have MCTP devices, i2c5 does not. + #include <dt-bindings/i2c/i2c.h> + + i2c1: i2c { + #address-cells = <1>; + #size-cells = <0>; + mctp-controller; + + mctp@50 { + compatible = "mctp-i2c-controller"; + reg = <(0x50 | I2C_OWN_SLAVE_ADDRESS)>; + }; + }; + + i2c-mux { + #address-cells = <1>; + #size-cells = <0>; + i2c-parent = <&i2c1>; + + i2c5: i2c@0 { + #address-cells = <1>; + #size-cells = <0>; + reg = <0>; + eeprom@33 { + reg = <0x33>; + }; + }; + + i2c6: i2c@1 { + #address-cells = <1>; + #size-cells = <0>; + reg = <1>; + mctp-controller; + }; + }; --2.32.0
Re: [PATCH net-next v5 1/2] dt-bindings: net: New binding mctp-i2c-controller
In reply to Matt JohnstonQuoted 24 lines · Matt Johnston
Used to define a local endpoint to communicate with MCTP peripherals attached to an I2C bus. This I2C endpoint can communicate with remote MCTP devices on the I2C bus.
In the example I2C topology below (matching the second yaml example) we have MCTP devices on busses i2c1 and i2c6. MCTP-supporting busses are indicated by the 'mctp-controller' DT property on an I2C bus node.
A mctp-i2c-controller I2C client DT node is placed at the top of the mux topology, since only the root I2C adapter will support I2C slave functionality.
.-------. |eeprom | .------------. .------. /'-------' | adapter | | mux --@0,i2c5------' | i2c1 ----.*| --@1,i2c6--.--. |............| \'------' \ \ ......... | mctp-i2c- | \ \ \ .mctpB . | controller | \ \ '.0x30 . | | \ ......... \ '.......' | 0x50 | \ .mctpA . \ ......... '------------' '.0x1d . '.mctpC . '.......' '.0x31 . '.......'
Quoted 6 lines
(mctpX boxes above are remote MCTP devices not included in the DT at present, they can be hotplugged/probed at runtime. A DT binding for specific fixed MCTP devices could be added later if required)
Signed-off-by Matt Johnston <[email protected]>Reviewed-by Rob Herring <[email protected]>
Matt Johnston
maintainerPATCH v5 2/2 mctp i2c: MCTP I2C binding driver
In reply to Matt JohnstonProvides MCTP network transport over an I2C bus, as specified in DMTF DSP0237. All messages between nodes are sent as SMBus Block Writes.
Each I2C bus to be used for MCTP is flagged in devicetree by a 'mctp-controller' property on the bus node. Each flagged bus gets a mctpi2cX net device created based on the bus number. A 'mctp-i2c-controller' I2C client needs to be added under the adapter. In an I2C mux situation the mctp-i2c-controller node must be attached only to the root I2C bus. The I2C client will handle incoming I2C slave block write data for subordinate busses as well as its own bus.
In configurations without devicetree a driver instance can be attached to a bus using the I2C slave new_device mechanism.
The MCTP core will hold/release the MCTP I2C device while responses are pending (a 6 second timeout or once a socket is closed, response received etc). While held the MCTP I2C driver will lock the I2C bus so that the correct I2C mux remains selected while responses are received.
(Ideally we would just lock the mux to keep the current bus selected for the response rather than a full I2C bus lock, but that isn't exposed in the I2C mux API)
--- drivers/net/mctp/Kconfig | 13 + drivers/net/mctp/Makefile | 1 + drivers/net/mctp/mctp-i2c.c | 1002 +++++++++++++++++++++++++++++++++++ 3 files changed, 1016 insertions(+) create mode 100644 drivers/net/mctp/mctp-i2c.c
drivers/net/mctp/Kconfig +13 -0
@@ -3,6 +3,7 @@ if MCTP menu "MCTP Device Drivers" + config MCTP_SERIAL tristate "MCTP serial transport" depends on TTY
@@ -21,6 +22,18 @@ config MCTP_SERIAL Say y here if you need to connect to MCTP endpoints over serial. To compile as a module, use m; the module will be called mctp-serial. +config MCTP_TRANSPORT_I2C + tristate "MCTP SMBus/I2C transport" + # i2c-mux is optional, but we must build as a module if i2c-mux is a module + depends on I2C_MUX || !I2C_MUX + depends on I2C + depends on I2C_SLAVE + select MCTP_FLOWS + help + Provides a driver to access MCTP devices over SMBus/I2C transport, + from DMTF specification DSP0237. A MCTP protocol network device is + created for each I2C bus that has been assigned a mctp-i2c device. + endmenu endif
drivers/net/mctp/Makefile +1 -0
@@ -1 +1,2 @@ obj-$(CONFIG_MCTP_SERIAL) += mctp-serial.o +obj-$(CONFIG_MCTP_TRANSPORT_I2C) += mctp-i2c.o
drivers/net/mctp/mctp-i2c.c new file +1002 -0
1,002 lines not on this page · raw message
Signature · 1 line
2.32.0
Jakub Kicinski
maintainerRe: [PATCH net-next v5 2/2] mctp i2c: MCTP I2C binding driver
Quoted 19 lines · On Thu, 10 Feb 2022 14:36:51 +0800 Matt Johnston wrote:
Provides MCTP network transport over an I2C bus, as specified in DMTF DSP0237. All messages between nodes are sent as SMBus Block Writes.
Each I2C bus to be used for MCTP is flagged in devicetree by a 'mctp-controller' property on the bus node. Each flagged bus gets a mctpi2cX net device created based on the bus number. A 'mctp-i2c-controller' I2C client needs to be added under the adapter. In an I2C mux situation the mctp-i2c-controller node must be attached only to the root I2C bus. The I2C client will handle incoming I2C slave block write data for subordinate busses as well as its own bus.
In configurations without devicetree a driver instance can be attached to a bus using the I2C slave
new_devicemechanism.The MCTP core will hold/release the MCTP I2C device while responses are pending (a 6 second timeout or once a socket is closed, response received etc). While held the MCTP I2C driver will lock the I2C bus so that the correct I2C mux remains selected while responses are received.
Quoted 6 lines
(Ideally we would just lock the mux to keep the current bus selected for the response rather than a full I2C bus lock, but that isn't exposed in the I2C mux API)
Signed-off-by Matt Johnston <[email protected]>Signed-off-by Jeremy Kerr <[email protected]>
The i2c stuff looks quite unfamiliar, can we can an ack for that? Does it look sane to you, Wolfram?
Quoted 3 lines
menu "MCTP Device Drivers"
+
spurious
Quoted 59 lines
config
MCTP_SERIALdrivers/net/mctp/mctp-i2c.c new file +55
-0tristate"MCTP serial transport" depends onTTY +static int mctp_i2c_add_netdev(struct mctp_i2c_client *mcli, + struct i2c_adapter *adap) +{ +unsigned long flags; +struct mctp_i2c_dev *midev =NULL ; +struct net_device *ndev =NULL ; +struct i2c_adapter *root; +char namebuf[30 ]; +int rc; + + root =mux_root_adapter (adap); +if (root != mcli->client->adapter) { +dev_err (&mcli->client->dev, +"I2C adapter %s is not a child bus of %s" , + mcli->client->adapter->name, root->name); +return -EINVAL ; + } + +WARN_ON (!mutex_is_locked (&mi_driver_state.lock)); +snprintf (namebuf,sizeof (namebuf),"mctpi2c%d" , adap->nr); + ndev =alloc_netdev (sizeof (*midev), namebuf,NET_NAME_ENUM , mctp_i2c_net_setup); +if (!ndev) { +dev_err (&mcli->client->dev,"%s alloc netdev failed\n" , __func__); + rc = -ENOMEM ; + goto err; + } +dev_net_set (ndev, current->nsproxy->net_ns); +SET_NETDEV_DEV (ndev, &adap->dev); +dev_addr_set (ndev, &mcli->lladdr); + + midev =netdev_priv (ndev); +skb_queue_head_init (&midev->tx_queue); +INIT_LIST_HEAD (&midev->list); + midev->adapter = adap; + midev->client = mcli; +spin_lock_init (&midev->flow_lock); + midev->i2c_lock_count =0 ; + midev->release_count =0 ; +/* Hold references */ +get_device (&midev->adapter->dev); +get_device (&midev->client->client->dev); + midev->ndev = ndev; +init_waitqueue_head (&midev->tx_wq); + midev->tx_thread =kthread_create (mctp_i2c_tx_thread, midev, +"%s/tx" , namebuf); +if (IS_ERR_OR_NULL (midev->tx_thread)) { + rc = -ENOMEM ; + goto err_free; + } + + rc =mctp_register_netdev (ndev, &mctp_i2c_mctp_ops); +if (rc <0 ) { +dev_err (&mcli->client->dev, +"%s register netdev \"%s\" failed %d\n" , __func__, + ndev->name, rc);
drivers/net/mctp/mctp-i2c.c line 716
Quoted 10 lines
drivers/net/mctp/mctp-i2c.c new file +10
-0+ goto err_stop_kthread; + } +spin_lock_irqsave (&mcli->curr_lock, flags); +list_add (&midev->list, &mcli->devs); +// Select a device by default +if (!mcli->sel) +__mctp_i2c_device_select (mcli, midev); +spin_unlock_irqrestore (&mcli->curr_lock, flags); + +wake_up_process (midev->tx_thread);
Simliar but inverse comment as below...
Quoted 26 lines
drivers/net/mctp/mctp-i2c.c new file +26
-0+return 0 ; + +err_stop_kthread: +kthread_stop (midev->tx_thread); + +err_free: +free_netdev (ndev); + +err: +return rc; +} + +// Removes and unregisters a mctp-i2c netdev +static void mctp_i2c_free_netdev (struct mctp_i2c_dev *midev) +{ +struct mctp_i2c_client *mcli = midev->client; +unsigned long flags; + +netif_stop_queue (midev->ndev); +kthread_stop (midev->tx_thread); +skb_queue_purge (&midev->tx_queue); + +/* Release references, used only for TX which has stopped */ +put_device (&midev->adapter->dev); +put_device (&mcli->client->dev); +
drivers/net/mctp/mctp-i2c.c line 753
Quoted 10 lines
drivers/net/mctp/mctp-i2c.c new file +10
-0+/* Remove it from the parent mcli */ +spin_lock_irqsave (&mcli->curr_lock, flags); +list_del (&midev->list); +if (mcli->sel == midev) { +struct mctp_i2c_dev *first; + + first = list_first_entry_or_null(&mcli->devs, struct mctp_i2c_dev, list); +__mctp_i2c_device_select (mcli, first); + } +spin_unlock_irqrestore (&mcli->curr_lock, flags);
You're doing a lot before the unregister call, this is likely racy. The usual flow is to unregister the netdev, then do uninit, then free. For instance you purge the queue but someone may Tx afterwards. needs_free_netdev is a footgun.
drivers/net/mctp/mctp-i2c.c line 974
Quoted 12 lines
drivers/net/mctp/mctp-i2c.c new file +11
-0+/* Remove netdev. mctp_i2c_slave_cb() takes a dev_hold() so removing +* it now is safe. unregister_netdev() frees ndev and midev. +*/ +mctp_unregister_netdev (midev->ndev); +} +static __init int mctp_i2c_init (void ) +{ +int rc; + +INIT_LIST_HEAD (&mi_driver_state.clients); +mutex_init (&mi_driver_state.lock);
I think there are static initializers for these.
Matt Johnston
maintainerRe: [PATCH net-next v5 2/2] mctp i2c: MCTP I2C binding driver
Quoted 8 lines · Jakub Kicinski
drivers/net/mctp/mctp-i2c.c line 731
Quoted 4 lines
drivers/net/mctp/mctp-i2c.c new file +2
-0+// Removes and unregisters a mctp-i2c netdev +static void mctp_i2c_free_netdev (struct mctp_i2c_dev *midev)You're doing a lot before the unregister call, this is likely racy. The usual flow is to unregister the netdev, then do uninit, then free. For instance you purge the queue but someone may Tx afterwards.
needs_free_netdevis a footgun.
Thanks Jakub. I've reworked it here to do the work before register/after unregister, without needs_free_netdev.
One question, the tx thread calls netif_wake_queue() - is it safe to call that after unregister_netdev()? (before free_netdev)
I've moved the kthread_stop() to the post-unregister cleanup.
static int mctp_i2c_tx_thread(void *data)
{
struct mctp_i2c_dev *midev = data;
struct sk_buff *skb;
unsigned long flags;
for (;;) {
if (kthread_should_stop())
break;
spin_lock_irqsave(&midev->tx_queue.lock, flags);
skb = __skb_dequeue(&midev->tx_queue);
if (netif_queue_stopped(midev->ndev))
netif_wake_queue(midev->ndev); // <-------
spin_unlock_irqrestore(&midev->tx_queue.lock, flags);Quoted 4 lines
drivers/net/mctp/mctp-i2c.c line 974
Quoted 2 lines
drivers/net/mctp/mctp-i2c.c new file +2
-0+INIT_LIST_HEAD (&mi_driver_state.clients); +mutex_init (&mi_driver_state.lock);I think there are static initializers for these.
*nod*
Thanks,
Matt
Jakub Kicinski
maintainerRe: [PATCH net-next v5 2/2] mctp i2c: MCTP I2C binding driver
Quoted 10 lines · On Tue, 15 Feb 2022 12:22:14 +0800 Matt Johnston wrote:
Quoted 8 lines · Jakub Kicinski
drivers/net/mctp/mctp-i2c.c line 731
Quoted 4 lines
drivers/net/mctp/mctp-i2c.c new file +2
-0+// Removes and unregisters a mctp-i2c netdev +static void mctp_i2c_free_netdev (struct mctp_i2c_dev *midev)You're doing a lot before the unregister call, this is likely racy. The usual flow is to unregister the netdev, then do uninit, then free. For instance you purge the queue but someone may Tx afterwards.
needs_free_netdevis a footgun.
Quoted 5 lines
Thanks Jakub. I've reworked it here to do the work before register/after unregister, without
needs_free_netdev.One question, the tx thread calls
netif_wake_queue()- is it safe to call that afterunregister_netdev()? (beforefree_netdev)
I don't think so.
Quoted 1 line
I've moved the
kthread_stop()to the post-unregister cleanup.
The usual way to deal with Tx would be to quiesce the worker in ndo_stop. Maybe keep it simple and add a mutex around the worker? You can then take the same mutex around:
stop queue
purge queue
Thanks to the mutex you'd know the worker is not running and as long as worker does its !skb_queue_empty() under the same mutex it will not wake the queue.
Matt Johnston
maintainerRe: [PATCH net-next v5 2/2] mctp i2c: MCTP I2C binding driver
Quoted 11 lines · Jakub Kicinski
Quoted 3 lines
One question, the tx thread calls
netif_wake_queue()- is it safe to call that afterunregister_netdev()? (beforefree_netdev)I don't think so.
Quoted 1 line
I've moved the
kthread_stop()to the post-unregister cleanup.The usual way to deal with Tx would be to quiesce the worker in
ndo_stop. Maybe keep it simple and add a mutex around the worker? You can then take the same mutex around:
Thanks. I'll just make sure to kthread_stop() prior to calling unregister. It looks like the kthread needs to keep running when the interface is down to handle MCTP release timeouts which unlock the i2c bus, so can't use ndo_stop.
Similarly for the RX path, can I safely call netif_rx(skb) after unregister? It looks like in that case it should be OK, since enqueue_to_backlog() tests for netif_running() and just drops the packet. (It's running from the I2C slave irq so can't just use a mutex).
Thanks,
Matt
Jakub Kicinski
maintainerRe: [PATCH net-next v5 2/2] mctp i2c: MCTP I2C binding driver
Quoted 8 lines · On Tue, 15 Feb 2022 18:01:25 +0800 Matt Johnston wrote:
Thanks. I'll just make sure to
kthread_stop()prior to calling unregister. It looks like the kthread needs to keep running when the interface is down to handle MCTP release timeouts which unlock the i2c bus, so can't usendo_stop.Similarly for the RX path, can I safely call
netif_rx(skb)after unregister? It looks like in that case it should be OK, sinceenqueue_to_backlog()tests fornetif_running()and just drops the packet. (It's running from the I2C slave irq so can't just use a mutex).
I wouldn't do it, using an object after it's unregistered is asking for trouble. RPS seems to happily dereference skb->dev. It may or may not work.
Re: [PATCH net-next v5 2/2] mctp i2c: MCTP I2C binding driver
In reply to Matt JohnstonHi Matt, all,
Quoted 19 lines · Matt Johnston
Provides MCTP network transport over an I2C bus, as specified in DMTF DSP0237. All messages between nodes are sent as SMBus Block Writes.
Each I2C bus to be used for MCTP is flagged in devicetree by a 'mctp-controller' property on the bus node. Each flagged bus gets a mctpi2cX net device created based on the bus number. A 'mctp-i2c-controller' I2C client needs to be added under the adapter. In an I2C mux situation the mctp-i2c-controller node must be attached only to the root I2C bus. The I2C client will handle incoming I2C slave block write data for subordinate busses as well as its own bus.
In configurations without devicetree a driver instance can be attached to a bus using the I2C slave
new_devicemechanism.The MCTP core will hold/release the MCTP I2C device while responses are pending (a 6 second timeout or once a socket is closed, response received etc). While held the MCTP I2C driver will lock the I2C bus so that the correct I2C mux remains selected while responses are received.
Quoted 6 lines
(Ideally we would just lock the mux to keep the current bus selected for the response rather than a full I2C bus lock, but that isn't exposed in the I2C mux API)
Signed-off-by Matt Johnston <[email protected]>Signed-off-by Jeremy Kerr <[email protected]>
So, I did a high level review regardings the I2C stuff. I did not check locking, device lifetime, etc. My biggest general remark is the mixture of multi-comment styles, like C++ style or no empty "/*" at the beginning as per Kernel coding style. Some functions have nice explanations in the header but not proper kdoc formatting. And also on the nitbit side, I don't think '__func__' helps here on the error messages. But that's me, I'll leave it to the netdev maintainers.
Now for the I2C part. It looks good. I have only one remark:
Quoted 5 lines
drivers/net/mctp/mctp-i2c.c new file +5
-0+static const struct i2c_device_id mctp_i2c_id[] = { + {"mctp-i2c" ,0 }, + {}, +}; +MODULE_DEVICE_TABLE (i2c, mctp_i2c_id);
...
drivers/net/mctp/mctp-i2c.c line 967
Quoted 9 lines
drivers/net/mctp/mctp-i2c.c new file +9
-0+static struct i2c_driver mctp_i2c_driver = { + .driver = { + .name ="mctp-i2c" , + .of_match_table = mctp_i2c_of_match, + }, + .probe_new = mctp_i2c_probe, + .remove = mctp_i2c_remove, + .id_table = mctp_i2c_id, +};
I'd suggest to add 'slave' to the 'mctp-i2c' string somewhere to make it easily visible that this driver does not manage a remote device but processes requests to its own address.
Thanks for the work!
Wolfram
Matt Johnston
maintainerRe: [PATCH net-next v5 2/2] mctp i2c: MCTP I2C binding driver
Hi Wolfram,
Quoted 7 lines · Wolfram Sang
So, I did a high level review regardings the I2C stuff. I did not check locking, device lifetime, etc. My biggest general remark is the mixture of multi-comment styles, like C++ style or no empty "/*" at the beginning as per Kernel coding style. Some functions have nice explanations in the header but not proper kdoc formatting. And also on the nitbit side, I don't think '
__func__' helps here on the error messages. But that's me, I'll leave it to the netdev maintainers.
I'll tidy up the comments. A filled /* first line is part of the netdev style.
Quoted 11 lines
Now for the I2C part. It looks good. I have only one remark:
Quoted 5 lines
drivers/net/mctp/mctp-i2c.c new file +5
-0+static const struct i2c_device_id mctp_i2c_id[] = { + {"mctp-i2c" ,0 }, + {}, +}; +MODULE_DEVICE_TABLE (i2c, mctp_i2c_id);...
Quoted 13 lines
drivers/net/mctp/mctp-i2c.c line 967
Quoted 9 lines
drivers/net/mctp/mctp-i2c.c new file +9
-0+static struct i2c_driver mctp_i2c_driver = { + .driver = { + .name ="mctp-i2c" , + .of_match_table = mctp_i2c_of_match, + }, + .probe_new = mctp_i2c_probe, + .remove = mctp_i2c_remove, + .id_table = mctp_i2c_id, +};I'd suggest to add 'slave' to the 'mctp-i2c' string somewhere to make it easily visible that this driver does not manage a remote device but processes requests to its own address.
I think 'slave' might be a bit unclear - the driver's acting as an I2C master too. It also is more baggage moving to inclusive naming. Maybe mctp-i2c- transport or mctp-i2c-interface would suit?
Cheers,
Matt
Re: [PATCH net-next v5 2/2] mctp i2c: MCTP I2C binding driver
Hi Matt,
Quoted 2 lines
I'll tidy up the comments. A filled /* first line is part of the netdev style.
Interesting, I didn't know that.
Quoted 2 lines
I think 'slave' might be a bit unclear - the driver's acting as an I2C master too.
Right. Yet, AFAIU only when sending responses to other nodes, or? It does not drive this one remote device with address 0xNN but acts itself as device 0xMM.
Quoted 2 lines
It also is more baggage moving to inclusive naming. Maybe mctp-i2c- transport or mctp-i2c-interface would suit?
+1 for inclusive naming. I like the "interface" addition.
Oh, and one other question I have meanwhile: do you really need "mctp_current_mux" as a device attribute or is it mere debug and could go away when upstream?
Thanks,
Wolfram
Matt Johnston
maintainerRe: [PATCH net-next v5 2/2] mctp i2c: MCTP I2C binding driver
Quoted 6 lines · Wolfram Sang
Quoted 2 lines
I think 'slave' might be a bit unclear - the driver's acting as an I2C master too.
Right. Yet, AFAIU only when sending responses to other nodes, or? It does not drive this one remote device with address 0xNN but acts itself as device 0xMM.
The Linux mctp-i2c endpoint (0xMM) can send MCTP messages to any I2C node (0xNN), as a block write master->slave. The MCTP I2C transport is bidirectional - either side can send the first message, all messages are block writes. (Hopefully I've understood your question)
Most higher level protocols on top of MCTP are request/response style, though it isn't inherent. The mctp-i2c driver is mostly stateless, but it in order to deal with i2c muxes the MCTP stack has a concept of "flows" so that it will keep a bus locked for replies after sending out a request (with timeout)
- that matches how higher level protocols expect to work.
Quoted 3 lines
Oh, and one other question I have meanwhile: do you really need "
mctp_current_mux" as a device attribute or is it mere debug and could go away when upstream?
Yes, it's really only useful for debugging since it could be outdated by the time it is read. I'll remove it, we could add something more robust if people had a need.
Cheers,
Matt