![Page 1: Linux I2C in the 21st century · 2019-10-29 · Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 24/27. lose_arbitration fromthedocs3: “Here,](https://reader033.vdocument.in/reader033/viewer/2022052021/6035fe276776193c225a3b87/html5/thumbnails/1.jpg)
Linux I2C in the 21st century
Wolfram Sang, Renesas / Consultant
29.10.2019, ELCE 2019
Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 1 / 27
![Page 2: Linux I2C in the 21st century · 2019-10-29 · Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 24/27. lose_arbitration fromthedocs3: “Here,](https://reader033.vdocument.in/reader033/viewer/2022052021/6035fe276776193c225a3b87/html5/thumbnails/2.jpg)
1 Workflow
2 Modern complex setups
3 API changes
4 New fault injectors
Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 2 / 27
![Page 3: Linux I2C in the 21st century · 2019-10-29 · Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 24/27. lose_arbitration fromthedocs3: “Here,](https://reader033.vdocument.in/reader033/viewer/2022052021/6035fe276776193c225a3b87/html5/thumbnails/3.jpg)
Workflow
Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 3 / 27
![Page 4: Linux I2C in the 21st century · 2019-10-29 · Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 24/27. lose_arbitration fromthedocs3: “Here,](https://reader033.vdocument.in/reader033/viewer/2022052021/6035fe276776193c225a3b87/html5/thumbnails/4.jpg)
I2C: its simplicity is a problem
What could go wrong?specs didn’t change much since 1982definately not rocket science1
drivers are (relatively) simple
So, do an IP core, dump the driver, move on…
I2C is a good examplea Fly-by subsystemmostly used by embeddedlargely maintained in spare time
1yet, gory details are everywhereWolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 4 / 27
![Page 5: Linux I2C in the 21st century · 2019-10-29 · Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 24/27. lose_arbitration fromthedocs3: “Here,](https://reader033.vdocument.in/reader033/viewer/2022052021/6035fe276776193c225a3b87/html5/thumbnails/5.jpg)
I2C: its simplicity is a problem
What could go wrong?specs didn’t change much since 1982definately not rocket science1
drivers are (relatively) simple
So, do an IP core, dump the driver, move on…
I2C is a good examplea Fly-by subsystemmostly used by embeddedlargely maintained in spare time
1yet, gory details are everywhereWolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 4 / 27
![Page 6: Linux I2C in the 21st century · 2019-10-29 · Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 24/27. lose_arbitration fromthedocs3: “Here,](https://reader033.vdocument.in/reader033/viewer/2022052021/6035fe276776193c225a3b87/html5/thumbnails/6.jpg)
Growth of I2C bus master drivers
0
20
40
60
80
100
120
140
v3.0 v3.5 v3.10 v3.15 v4.0 v4.5 v4.10 v4.15 v4.20
2011 2012 2013 2014 2015 2016 2017 2018 2018
number of files in drivers/i2c/busses
Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 5 / 27
![Page 7: Linux I2C in the 21st century · 2019-10-29 · Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 24/27. lose_arbitration fromthedocs3: “Here,](https://reader033.vdocument.in/reader033/viewer/2022052021/6035fe276776193c225a3b87/html5/thumbnails/7.jpg)
Group maintainership
Which group???
Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 6 / 27
![Page 8: Linux I2C in the 21st century · 2019-10-29 · Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 24/27. lose_arbitration fromthedocs3: “Here,](https://reader033.vdocument.in/reader033/viewer/2022052021/6035fe276776193c225a3b87/html5/thumbnails/8.jpg)
Group maintainership
Which group???
Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 6 / 27
![Page 9: Linux I2C in the 21st century · 2019-10-29 · Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 24/27. lose_arbitration fromthedocs3: “Here,](https://reader033.vdocument.in/reader033/viewer/2022052021/6035fe276776193c225a3b87/html5/thumbnails/9.jpg)
Not that I tried…
From: Wolfram Sang <[email protected]>Subject: I2C delay due to maintainer illness
sadly, I have been tied to bed for a few days now, not in a condition toreally work on I2C...
I think it is annoying, sure, but no catastrophe. However, it shows thatI am the single-point-of-failure for I2C patches, what I don't like.Like I said before, I am open to group maintainership. If you think youare a reliable candidate, please get in touch with me.
“Get well soon!”
Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 7 / 27
![Page 10: Linux I2C in the 21st century · 2019-10-29 · Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 24/27. lose_arbitration fromthedocs3: “Here,](https://reader033.vdocument.in/reader033/viewer/2022052021/6035fe276776193c225a3b87/html5/thumbnails/10.jpg)
Not that I tried…
From: Wolfram Sang <[email protected]>Subject: I2C delay due to maintainer illness
sadly, I have been tied to bed for a few days now, not in a condition toreally work on I2C...
I think it is annoying, sure, but no catastrophe. However, it shows thatI am the single-point-of-failure for I2C patches, what I don't like.Like I said before, I am open to group maintainership. If you think youare a reliable candidate, please get in touch with me.
“Get well soon!”
Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 7 / 27
![Page 11: Linux I2C in the 21st century · 2019-10-29 · Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 24/27. lose_arbitration fromthedocs3: “Here,](https://reader033.vdocument.in/reader033/viewer/2022052021/6035fe276776193c225a3b87/html5/thumbnails/11.jpg)
Divide & conquer to the extreme
I2C SUBSYSTEMM: Wolfram Sang <[email protected]>L: [email protected]: Maintained
I2C SUBSYSTEM HOST DRIVERSL: [email protected]: Odd Fixes
66 drivers have dedicated maintainers now
Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 8 / 27
![Page 12: Linux I2C in the 21st century · 2019-10-29 · Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 24/27. lose_arbitration fromthedocs3: “Here,](https://reader033.vdocument.in/reader033/viewer/2022052021/6035fe276776193c225a3b87/html5/thumbnails/12.jpg)
Divide & conquer to the extreme
I2C SUBSYSTEMM: Wolfram Sang <[email protected]>L: [email protected]: Maintained
I2C SUBSYSTEM HOST DRIVERSL: [email protected]: Odd Fixes
66 drivers have dedicated maintainers now
Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 8 / 27
![Page 13: Linux I2C in the 21st century · 2019-10-29 · Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 24/27. lose_arbitration fromthedocs3: “Here,](https://reader033.vdocument.in/reader033/viewer/2022052021/6035fe276776193c225a3b87/html5/thumbnails/13.jpg)
My companions
I2C ACPI SUPPORTM: Mika Westerberg <[email protected]>S: Maintained
I2C MUXESM: Peter Rosin <[email protected]>S: Maintained
I2C/SMBUS CONTROLLER DRIVERS FOR PCM: Jean Delvare <[email protected]>S: Maintained
Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 9 / 27
![Page 14: Linux I2C in the 21st century · 2019-10-29 · Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 24/27. lose_arbitration fromthedocs3: “Here,](https://reader033.vdocument.in/reader033/viewer/2022052021/6035fe276776193c225a3b87/html5/thumbnails/14.jpg)
THE Linux I2C supporter
Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 10 / 27
![Page 15: Linux I2C in the 21st century · 2019-10-29 · Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 24/27. lose_arbitration fromthedocs3: “Here,](https://reader033.vdocument.in/reader033/viewer/2022052021/6035fe276776193c225a3b87/html5/thumbnails/15.jpg)
Modern complex setups
Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 11 / 27
![Page 16: Linux I2C in the 21st century · 2019-10-29 · Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 24/27. lose_arbitration fromthedocs3: “Here,](https://reader033.vdocument.in/reader033/viewer/2022052021/6035fe276776193c225a3b87/html5/thumbnails/16.jpg)
GMSL
Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 12 / 27
![Page 17: Linux I2C in the 21st century · 2019-10-29 · Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 24/27. lose_arbitration fromthedocs3: “Here,](https://reader033.vdocument.in/reader033/viewer/2022052021/6035fe276776193c225a3b87/html5/thumbnails/17.jpg)
GMSL - the whole truth
Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 13 / 27
![Page 18: Linux I2C in the 21st century · 2019-10-29 · Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 24/27. lose_arbitration fromthedocs3: “Here,](https://reader033.vdocument.in/reader033/viewer/2022052021/6035fe276776193c225a3b87/html5/thumbnails/18.jpg)
API changes
Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 14 / 27
![Page 19: Linux I2C in the 21st century · 2019-10-29 · Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 24/27. lose_arbitration fromthedocs3: “Here,](https://reader033.vdocument.in/reader033/viewer/2022052021/6035fe276776193c225a3b87/html5/thumbnails/19.jpg)
API changes: retval for i2c_new_*
- NULL+ ERR_PTR
Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 15 / 27
![Page 20: Linux I2C in the 21st century · 2019-10-29 · Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 24/27. lose_arbitration fromthedocs3: “Here,](https://reader033.vdocument.in/reader033/viewer/2022052021/6035fe276776193c225a3b87/html5/thumbnails/20.jpg)
API changes: retval conversions
- i2c_new_dummy+ i2c_new_dummy_device (done)
- i2c_new_secondary_device+ i2c_new_ancillary_device(done)
- i2c_new_device+ i2c_new_client_device (WIP)
- i2c_new_probed_device+ ??? (TBD)
Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 16 / 27
![Page 21: Linux I2C in the 21st century · 2019-10-29 · Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 24/27. lose_arbitration fromthedocs3: “Here,](https://reader033.vdocument.in/reader033/viewer/2022052021/6035fe276776193c225a3b87/html5/thumbnails/21.jpg)
API changes: more devm_*
+ devm_i2c_new_client_device (TBD)
+ devm_i2c_new_dummy_device (done)
+ devm_i2c_new_ancillary_device (TBD)
Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 17 / 27
![Page 22: Linux I2C in the 21st century · 2019-10-29 · Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 24/27. lose_arbitration fromthedocs3: “Here,](https://reader033.vdocument.in/reader033/viewer/2022052021/6035fe276776193c225a3b87/html5/thumbnails/22.jpg)
API suggestion
- i2c_new_dummy_device- (client->adapter, addr)
+ i2c_new_ancillary_device+ (client, name, default_addr)
Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 18 / 27
![Page 23: Linux I2C in the 21st century · 2019-10-29 · Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 24/27. lose_arbitration fromthedocs3: “Here,](https://reader033.vdocument.in/reader033/viewer/2022052021/6035fe276776193c225a3b87/html5/thumbnails/23.jpg)
New atomic callbacks
+ int (*master_xfer_atomic)(...)
+ int (*smbus_xfer_atomic)(...)
Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 19 / 27
![Page 24: Linux I2C in the 21st century · 2019-10-29 · Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 24/27. lose_arbitration fromthedocs3: “Here,](https://reader033.vdocument.in/reader033/viewer/2022052021/6035fe276776193c225a3b87/html5/thumbnails/24.jpg)
New fault injectors
Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 20 / 27
![Page 25: Linux I2C in the 21st century · 2019-10-29 · Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 24/27. lose_arbitration fromthedocs3: “Here,](https://reader033.vdocument.in/reader033/viewer/2022052021/6035fe276776193c225a3b87/html5/thumbnails/25.jpg)
incomplete_write_byte
Figure 1: Scoped with sigrok
Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 21 / 27
![Page 26: Linux I2C in the 21st century · 2019-10-29 · Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 24/27. lose_arbitration fromthedocs3: “Here,](https://reader033.vdocument.in/reader033/viewer/2022052021/6035fe276776193c225a3b87/html5/thumbnails/26.jpg)
Dangerous! The unintended write
Figure 2: Scoped with sigrok
Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 22 / 27
![Page 27: Linux I2C in the 21st century · 2019-10-29 · Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 24/27. lose_arbitration fromthedocs3: “Here,](https://reader033.vdocument.in/reader033/viewer/2022052021/6035fe276776193c225a3b87/html5/thumbnails/27.jpg)
much better!
Figure 3: Scoped with sigrok
Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 23 / 27
![Page 28: Linux I2C in the 21st century · 2019-10-29 · Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 24/27. lose_arbitration fromthedocs3: “Here,](https://reader033.vdocument.in/reader033/viewer/2022052021/6035fe276776193c225a3b87/html5/thumbnails/28.jpg)
inject_panic
from the docs2:“This fault injector will create a Kernel panic once the master under teststarted a transfer. This usually means that the state machine of the busmaster driver will be ungracefully interrupted and the bus may end up inan unusual state. Use this to check if your shutdown/reboot/boot codecan handle this scenario.”
Remember the atomic transfers?
2Documentation/i2c/gpio-fault-injection.rstWolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 24 / 27
![Page 29: Linux I2C in the 21st century · 2019-10-29 · Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 24/27. lose_arbitration fromthedocs3: “Here,](https://reader033.vdocument.in/reader033/viewer/2022052021/6035fe276776193c225a3b87/html5/thumbnails/29.jpg)
lose_arbitration
from the docs3:“Here, we want to simulate the condition where the master under testloses the bus arbitration against another master in a multi-master setup.”
As simple as:
$ echo 200 > lose_arbitration &$ i2cget -y <bus_to_test> 0x3f
3Documentation/i2c/gpio-fault-injection.rstWolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 25 / 27
![Page 30: Linux I2C in the 21st century · 2019-10-29 · Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 24/27. lose_arbitration fromthedocs3: “Here,](https://reader033.vdocument.in/reader033/viewer/2022052021/6035fe276776193c225a3b87/html5/thumbnails/30.jpg)
The End
Questions? Comments?Questions?
Right here, right now…At the [email protected]
Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 26 / 27
![Page 31: Linux I2C in the 21st century · 2019-10-29 · Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 24/27. lose_arbitration fromthedocs3: “Here,](https://reader033.vdocument.in/reader033/viewer/2022052021/6035fe276776193c225a3b87/html5/thumbnails/31.jpg)
References
Renesas Electronics Logo
Wolfram Sang, Renesas / Consultant Linux I2C in the 21st century 29.10.2019, ELCE 2019 27 / 27