From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-182.mta0.migadu.com (out-182.mta0.migadu.com [91.218.175.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C65563358B1 for ; Sun, 8 Feb 2026 12:34:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770554099; cv=none; b=D1L/F7pma16UWUpNUJaPNyZJCjNZic5N0LiAAkhV4XryBSLEhOcjoEX3gAOEWherlUyx7HZLoX1OOmcbM3Cg4xX4xMHFL46JD2viCs8tKvsDOCFHcz7O80i7n5M8clINDU2A/deCL3FOAKOtWHuEuYLrNlu/SdBJtDGnJBo81aw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770554099; c=relaxed/simple; bh=juguovnNh5Dyvmv7EuaALJ6VLYEM93Of1tPlNEETgPY=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=R9kfeIi2VbP2lU5LKTLDlO4eFzkGoTL0MB1lNxWmXLc2rs8R9MQHJGsbuIvjY2wWA5UbYG0Y3LLYQVuDSzQHbpL8U62FcfA3WseMjCS7FL7jo+thQEULZr89HHbB96XQo6zQygKpWvsJxTDxzmFwYME9IxaCSPCbneHjZdJQ+N8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=Z5ZEDnby; arc=none smtp.client-ip=91.218.175.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="Z5ZEDnby" Message-ID: <70302f35-918e-4dc8-b4f4-30b86064251c@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1770554096; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5TQyY62mNFaoAbw8K8f9cLsQDP0nS5guZ05j72G3wQM=; b=Z5ZEDnbyEthFJv1Cd2qyVLTaRevsYYIR7T6PuG+KvaIb/hsHF/q+5uVYypHvtakASn2TU/ Y9z2a8+oGx/O7wZ/f570iZZo5JbsJzzjwNJAMxn3x2ZHTaBpA+4rEjw2KwV8z+pL0E2o9E k+FA5wkeDVa8/mqQTkMUlj0z6Zp83v8= Date: Sun, 8 Feb 2026 12:34:46 +0000 Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH 0/5] rust: extend I2C functionality To: Danilo Krummrich , Igor Korotin via B4 Relay Cc: igor.korotin.linux@gmail.com, Daniel Almeida , Miguel Ojeda , Boqun Feng , Gary Guo , =?UTF-8?Q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Wolfram Sang , 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 References: <20260131-i2c-adapter-v1-0-5a436e34cd1a@gmail.com> Content-Language: en-US X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Igor Korotin In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT 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. 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? Cheers Igor