[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAMRc=Mc8x4gZu-ALA_c85djWHT6TinBK3KuLGQqMALWA477bMg@mail.gmail.com>
Date: Mon, 9 Feb 2026 05:31:11 -0600
From: Bartosz Golaszewski <brgl@...nel.org>
To: Danilo Krummrich <dakr@...nel.org>
Cc: igor.korotin.linux@...il.com,
Daniel Almeida <daniel.almeida@...labora.com>, Miguel Ojeda <ojeda@...nel.org>,
Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <lossin@...nel.org>, Andreas Hindborg <a.hindborg@...nel.org>,
Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>,
Wolfram Sang <wsa+renesas@...g-engineering.com>, linux-kernel@...r.kernel.org,
rust-for-linux@...r.kernel.org, linux-i2c@...r.kernel.org,
markus.probst@...teo.de, brgl@...nel.org, gregkh@...uxfoundation.org,
rafael@...nel.org, driver-core@...ts.linux.dev,
Igor Korotin via B4 Relay <devnull+igor.korotin.linux.gmail.com@...nel.org>
Subject: Re: [PATCH 0/5] rust: extend I2C functionality
On Sat, 31 Jan 2026 15:26:22 +0100, Danilo Krummrich <dakr@...nel.org> said:
> (Cc: Bartosz, Greg, Rafael, driver-core)
>
> On Sat Jan 31, 2026 at 3:12 PM CET, Igor Korotin via B4 Relay wrote:
>> This patch series extend the existing I2C functionality with:
>> - Abstractions allowing to implement I2C algorithms used by I2C adapters;
>> - Abstractions allowing to create and add new I2C adapters;
>> - Safe wrappers upon I2C and SMbus transferring C API: read/write
>> bytes/words/byte arrays.
>>
>> The patch series contains additional new sample driver `rust_i2c_adapter`
>> presenting the new functionality.
>
> The i2c_adapter code on the C side has some lifetime issues, Bartosz looks into
> resolving.
>
> My biggest concern is that struct i2c_adapter is a bus device implementation,
> but does not use the reference count of the embedded struct device.
>
> Instead, I2C bus drivers embedd the i2c_adapter in their driver specific
> structure, which is typically freed in the I2C bus driver's remove() callback.
>
Correct.
> This violates struct device reference counts.
>
What's currently done in order to not crash is: we wait forever until all users
release their references[1].
> Until this is fixed, the Rust abstractions should probably work around this, to
> subsequent painful rework.
>
The rework of the C part will be long an painful already. I estimated the work
will take at least a year. More info here[2].
Bart
[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/i2c/i2c-core-base.c#n1814
[2] https://lore.kernel.org/all/aWYYZEPX-_1GfQtL@ninjato/
Powered by blists - more mailing lists