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 581B71E22E9; Mon, 16 Jun 2025 15:45:39 +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=1750088739; cv=none; b=Ph8Om0TZAdtnJ3VD2Cb2JW18J1Ils69XdPGigrLo0hUCbxAfkTQEHoN48rDtjxHbifXR16XbgS4qUkhVsoUvAXmAT/VleTZ35HEBxMQk9MqVRW9sjeoXGZ0T6KBJyNPreKZ33ll2lm1PuVw2zbYW6G/TII5q2sH1OORkbtswhGA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750088739; c=relaxed/simple; bh=Phz8r6X/1/Hfio3qW3aeXo0QdX243igoFLB5Ql8EyIc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=oKQRdCGlAmfV44XUUNT+ix4My3xFWrxtvmokhOmPlzkx7/UNm+rjgI5QYdeKe/Bef33TslqA2azznUAOhcuaIK91NDPD98OYf7VwwgecBq9jLp9e1z8YgIlEKGSs+BQ+ellByj8eSJ7BJdgtv6ldgBwUWfZGny9lH1FZn+stgGk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RsE/rIpQ; 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="RsE/rIpQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A0BE0C4CEEA; Mon, 16 Jun 2025 15:45:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750088739; bh=Phz8r6X/1/Hfio3qW3aeXo0QdX243igoFLB5Ql8EyIc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=RsE/rIpQgQubD9FD467llyTDjelw55TPUcdwrb3S1TXpCpXXNI43yrGPqDiR5nlqa 5TaebA2IEx6SuLpxCLrzK+vChFuXE6GGqpTKbGmHVpDela40oSWhU99OzwUu1A8U2p ptnhDotPAzF1Irh4PN/v4rJURVqJYGkmrRRKP13lds41ykDKZgf4r7gi5Do6PdPXbD rfZacp+1dtK5Uq27l+OehTp3KZCDFi28e/6Zpha8lBtamt2+AJrZaCD4bHD0MrHjNc TNeuHUOHVTlHxeZz+OPK3UblpI1OCqbhTFAGFfeO+J7ndKOXZ1MeId9BrdXbWcoK4j DiE9RKF5pKoEg== Date: Mon, 16 Jun 2025 17:45:32 +0200 From: Danilo Krummrich To: Daniel Almeida Cc: Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , Andreas Hindborg , Alice Ryhl , Trevor Gross , Greg Kroah-Hartman , "Rafael J. Wysocki" , Thomas Gleixner , Benno Lossin , Bjorn Helgaas , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-pci@vger.kernel.org Subject: Re: [PATCH v4 4/6] rust: irq: add support for threaded IRQs and handlers Message-ID: References: <20250608-topics-tyr-request_irq-v4-0-81cb81fb8073@collabora.com> <20250608-topics-tyr-request_irq-v4-4-81cb81fb8073@collabora.com> <5B3865E5-E343-4B5D-9BF7-7B9086AA9857@collabora.com> Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Mon, Jun 16, 2025 at 10:48:37AM -0300, Daniel Almeida wrote: > Hi Danilo, > > > On 9 Jun 2025, at 13:24, Daniel Almeida wrote: > > > > Hi Danilo, > > > >> On 9 Jun 2025, at 09:27, Danilo Krummrich wrote: > >> > >> On Sun, Jun 08, 2025 at 07:51:09PM -0300, Daniel Almeida wrote: > >>> +/// Callbacks for a threaded IRQ handler. > >>> +pub trait ThreadedHandler: Sync { > >>> + /// The actual handler function. As usual, sleeps are not allowed in IRQ > >>> + /// context. > >>> + fn handle_irq(&self) -> ThreadedIrqReturn; > >>> + > >>> + /// The threaded handler function. This function is called from the irq > >>> + /// handler thread, which is automatically created by the system. > >>> + fn thread_fn(&self) -> IrqReturn; > >>> +} > >>> + > >>> +impl ThreadedHandler for Arc { > >>> + fn handle_irq(&self) -> ThreadedIrqReturn { > >>> + T::handle_irq(self) > >>> + } > >>> + > >>> + fn thread_fn(&self) -> IrqReturn { > >>> + T::thread_fn(self) > >>> + } > >>> +} > >> > >> In case you intend to be consistent with the function pointer names in > >> request_threaded_irq(), it'd need to be handler() and thread_fn(). But I don't > >> think there's a need for that, both aren't really nice for names of trait > >> methods. > >> > >> What about irq::Handler::handle() and irq::Handler::handle_threaded() for > >> instance? > >> > >> Alternatively, why not just > >> > >> trait Handler { > >> fn handle(&self); > >> } > >> > >> trait ThreadedHandler { > >> fn handle(&self); > >> } > >> > >> and then we ask for `T: Handler + ThreadedHandler`. > > > > Sure, I am totally OK with renaming things, but IIRC I've tried Handler + > > ThreadedHandler in the past and found it to be problematic. I don't recall why, > > though, so maybe it's worth another attempt. > > Handler::handle() returns IrqReturn and ThreadedHandler::handle() returns > ThreadedIrqReturn, which includes WakeThread, so these had to be separate > traits. Ok, that fine then. But I'd still prefer the better naming as mentioned above.