From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 456343A8FE1; Tue, 24 Feb 2026 16:35:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771950928; cv=none; b=AvlIvL7g4Rvmw03C+FfU7PIJh8VuUsMmY+wFBux5mAyqhgO3OO0y9xyIin7C8xyeXDBrmmPXzS6cOY+5K1J+I7xza5d4HSIqTCuJ9QlNdD2cKvcx1VlYD0IVGXVmTffdvhOrqehVOmNLoM7VBZIvU9QV7ByaR7N4DZnwjKQ/C7w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771950928; c=relaxed/simple; bh=OzigO6c+dArWtHRsz+dmj92Kzhjc1yxExDnuGmeqgbU=; h=Mime-Version:Content-Type:Date:Message-Id:Subject:Cc:To:From: References:In-Reply-To; b=N0E2rPm0Su6ddgynA688czIe1729VK9VYa94eyDATvOexKpTqk7+bemCXUTsNTr/ar1Y0V5sWrxPgTKVz+s7Df514GFapLi8E7Pyqf8doix2hggBD0mSLpgxA+Pb7UMhlNEV0bidXRojHGwY8hUC72bzaua0GpJba1ozOafOMLI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jybKs8Q6; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jybKs8Q6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1C561C116D0; Tue, 24 Feb 2026 16:35:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1771950927; bh=OzigO6c+dArWtHRsz+dmj92Kzhjc1yxExDnuGmeqgbU=; h=Date:Subject:Cc:To:From:References:In-Reply-To:From; b=jybKs8Q6AGFvL6l1KQlMjPGeATR1Z42nW3evbAPMII/s0DasJr72DxR0ZlF7AEX8q LucXAw48wFPXZuLSvty6DFPUZiQY9GcobN7PP/cJHB97ZkdWcRVHC9YZfHl85wOO4K KOvngxTdw1/PfuddBug9TEN7DuRfQr8MzYsolTUoPt6e36htnG/D7l3A09MZ/tEtGB JNnScTTlRDTJe5p7jweIonZR4msz32qpkaj1KRtYj8zKZy+A4uHff9HOkSFxW/Hjij hsZDB59n7jS4CzC2g2MmIg8DIheiKFtcP0X0Km+XIa5a5rpLhZPUnbHrTlCQcwdsX2 ybdgfOOevGnew== Precedence: bulk X-Mailing-List: linux-rtc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Tue, 24 Feb 2026 17:35:23 +0100 Message-Id: Subject: Re: [RFC PATCH v3 1/5] rtc: add device selector for rtc_class_ops callbacks Cc: "Rafael J. Wysocki" , "Alvin Sun" , "Miguel Ojeda" , "Boqun Feng" , "Gary Guo" , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , "Benno Lossin" , "Andreas Hindborg" , "Alice Ryhl" , "Trevor Gross" , , , "Greg Kroah-Hartman" To: "Alexandre Belloni" From: "Danilo Krummrich" References: <20260220225341c5eeb835@mail.local> <20260221111619162a41a1@mail.local> <20260222000556ea1938c0@mail.local> <2026022415010804e28202@mail.local> In-Reply-To: <2026022415010804e28202@mail.local> On Tue Feb 24, 2026 at 4:01 PM CET, Alexandre Belloni wrote: > On 24/02/2026 01:12:32+0100, Danilo Krummrich wrote: >> impl pci::Driver for SampleDriver { >> fn probe(pdev: &pci::Device, info: &Self::IdInfo) -> impl Pin= Init { >> let dev =3D pdev.as_ref(); >>=20 >> let rtc_data =3D impl_pin_init!(SampleRtcData { >> io: iomap_region_sized::(0, c"my_rtc/bar0")?, >> hw_variant: VendorVariant::StV1, >> }); >>=20 >> let rtc =3D rtc::Device::new(dev, rtc_data)?; >>=20 >> // Internally calls `devres::register(rtc::Registration::new())= `. >> rtc::Registration::register(rtc)?; >>=20 >> Ok(impl_pin_init!(Self { >> // Give the IRQ handler a reference count of the `rtc::Devi= ce`. >> irq <- irq::Registration::new(..., rtc.clone()), >> rtc, >> }) > > I can't really read rust yet but this seems to open a race condition > with userspace if irq::Registration::new(...) fails, there is an > ordering constraint you missed. (I did not have any specific hardware in mind when sketching this up (e.g. = an IRQ could also only be needed in bus device callbacks, e.g. for loading fir= mware etc.). But for RTC it obviously is common that it is relevant to the class device too.) So, I assume you mean because there could already be an ioctl before the IR= Q has been successfully registered, and this ioctl may wait for an IRQ? In this case the irq::Registration should go into rtc_data instead to accou= nt for this dependency. Unfortunately, this is a semantic dependency that we c= an't always catch at compile time. The reason we sometimes can is because, if you would need access to the irq::Registration from ioctls (e.g. for calling synchronize(), enable(), disable() etc.) it would be caught, because you couldn't access it without = it being in rtc_data in the first place, and being forced to have it in rtc_da= ta guarantees that the ordering can't be wrong.