From: "Danilo Krummrich" <dakr@kernel.org>
To: "Igor Korotin" <igor.korotin@linux.dev>
Cc: "Igor Korotin via B4 Relay"
<devnull+igor.korotin.linux.gmail.com@kernel.org>,
igor.korotin.linux@gmail.com,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Wolfram Sang" <wsa+renesas@sang-engineering.com>,
linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org,
linux-i2c@vger.kernel.org, markus.probst@posteo.de,
brgl@kernel.org, gregkh@linuxfoundation.org, rafael@kernel.org,
driver-core@lists.linux.dev
Subject: Re: [PATCH 0/5] rust: extend I2C functionality
Date: Sun, 08 Feb 2026 18:07:19 +0100 [thread overview]
Message-ID: <DG9QU6ZMT9B8.HYIDD2GJGZUH@kernel.org> (raw)
In-Reply-To: <70302f35-918e-4dc8-b4f4-30b86064251c@linux.dev>
On Sun Feb 8, 2026 at 1:34 PM CET, Igor Korotin wrote:
> Hello Danilo
>
> On 1/31/2026 2:26 PM, Danilo Krummrich wrote:
>> (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.
>>
>> This violates struct device reference counts.
>>
>> Until this is fixed, the Rust abstractions should probably work around this, to
>> subsequent painful rework.
>
> just to clarify what is currently implemented on the Rust side.
>
> The Rust I2cAdapter is required to be bound to a parent Device<Bound>.
> The implementation keeps a reference to the embedded struct device
> inside struct i2c_adapter for the entire lifetime of the Rust adapter,
> so its lifetime is tied to the device model.
>
> I am not entirely sure which specific lifetime or refcounting scenario
> you are referring to. If you have a concrete case in mind where this
> would still be problematic, could you please point it out?
The implementation on the C side does not consider the reference count of the
embedded struct device, which is not correct.
next prev parent reply other threads:[~2026-02-08 17:07 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-31 14:12 [PATCH 0/5] rust: extend I2C functionality Igor Korotin via B4 Relay
2026-01-31 14:12 ` [PATCH 1/5] rust: i2c: split client and adapter code into separate files Igor Korotin via B4 Relay
2026-01-31 14:12 ` [PATCH 2/5] rust: bits: add define_flags macro Igor Korotin via B4 Relay
2026-02-08 13:56 ` Daniel Almeida
2026-01-31 14:12 ` [PATCH 3/5] rust: i2c: Add I2C Adapter registration abstractions Igor Korotin via B4 Relay
2026-01-31 14:12 ` [PATCH 4/5] rust: i2c: add I2C wrappers Igor Korotin via B4 Relay
2026-01-31 14:28 ` Markus Probst
2026-02-04 16:49 ` Igor Korotin
2026-02-04 16:59 ` Danilo Krummrich
2026-02-08 12:44 ` Igor Korotin
2026-02-04 17:03 ` Danilo Krummrich
2026-01-31 14:12 ` [PATCH 5/5] samples: rust: add Rust I2C adapter registration sample Igor Korotin via B4 Relay
2026-01-31 14:26 ` [PATCH 0/5] rust: extend I2C functionality Danilo Krummrich
2026-02-08 12:34 ` Igor Korotin
2026-02-08 17:07 ` Danilo Krummrich [this message]
2026-02-09 11:31 ` Bartosz Golaszewski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DG9QU6ZMT9B8.HYIDD2GJGZUH@kernel.org \
--to=dakr@kernel.org \
--cc=a.hindborg@kernel.org \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=brgl@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=devnull+igor.korotin.linux.gmail.com@kernel.org \
--cc=driver-core@lists.linux.dev \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=igor.korotin.linux@gmail.com \
--cc=igor.korotin@linux.dev \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=markus.probst@posteo.de \
--cc=ojeda@kernel.org \
--cc=rafael@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
--cc=wsa+renesas@sang-engineering.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox