Commit 0851d34a authored by Daniel Almeida's avatar Daniel Almeida Committed by Danilo Krummrich
Browse files

rust: irq: add support for non-threaded IRQs and handlers



This patch adds support for non-threaded IRQs and handlers through
irq::Registration and the irq::Handler trait.

Registering an irq is dependent upon having a IrqRequest that was
previously allocated by a given device. This will be introduced in
subsequent patches.

Tested-by: default avatarJoel Fernandes <joelagnelf@nvidia.com>
Tested-by: default avatarDirk Behme <dirk.behme@de.bosch.com>
Reviewed-by: default avatarAlice Ryhl <aliceryhl@google.com>
Signed-off-by: default avatarDaniel Almeida <daniel.almeida@collabora.com>
Link: https://lore.kernel.org/r/20250811-topics-tyr-request_irq2-v9-3-0485dcd9bcbf@collabora.com


[ Remove expect(dead_code) from Flags::into_inner(), add
  expect(dead_code) to IrqRequest::new(), fix intra-doc links. - Danilo ]
Signed-off-by: default avatarDanilo Krummrich <dakr@kernel.org>
parent 746680ec
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@
#include <linux/ethtool.h>
#include <linux/file.h>
#include <linux/firmware.h>
#include <linux/interrupt.h>
#include <linux/fs.h>
#include <linux/ioport.h>
#include <linux/jiffies.h>
+1 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include "dma.c"
#include "drm.c"
#include "err.c"
#include "irq.c"
#include "fs.c"
#include "io.c"
#include "jump_label.c"

rust/helpers/irq.c

0 → 100644
+9 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0

#include <linux/interrupt.h>

int rust_helper_request_irq(unsigned int irq, irq_handler_t handler,
			    unsigned long flags, const char *name, void *dev)
{
	return request_irq(irq, handler, flags, name, dev);
}
+5 −0
Original line number Diff line number Diff line
@@ -13,4 +13,9 @@
/// Flags to be used when registering IRQ handlers.
mod flags;

/// IRQ allocation and handling.
mod request;

pub use flags::Flags;

pub use request::{Handler, IrqRequest, IrqReturn, Registration};
+1 −2
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@
/// If an invalid combination of flags is provided, the system will refuse to
/// register the handler, and lower layers will enforce certain flags when
/// necessary. This means, for example, that all the
/// `crate::irq::Registration` for a shared interrupt have to agree on
/// [`crate::irq::Registration`] for a shared interrupt have to agree on
/// [`Flags::SHARED`] and on the same trigger type, if set.
#[derive(Clone, Copy, PartialEq, Eq)]
pub struct Flags(c_ulong);
@@ -92,7 +92,6 @@ impl Flags {
    /// `PERCPU`.
    pub const NO_DEBUG: Flags = Flags::new(bindings::IRQF_NO_DEBUG);

    #[expect(dead_code)]
    pub(crate) fn into_inner(self) -> c_ulong {
        self.0
    }
Loading