Commit Graph
4 Commits
Author SHA1 Message Date
Alice Ryhl 29e16fcd67 rust: irq: add &Device<Bound> argument to irq callbacks
When working with a bus device, many operations are only possible while
the device is still bound. The &Device<Bound> type represents a proof in
the type system that you are in a scope where the device is guaranteed
to still be bound. Since we deregister irq callbacks when unbinding a
device, if an irq callback is running, that implies that the device has
not yet been unbound.

To allow drivers to take advantage of that, add an additional argument
to irq callbacks.

Signed-off-by: Alice Ryhl <[email protected]>
Reviewed-by: Boqun Feng <[email protected]>
Signed-off-by: Daniel Almeida <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Danilo Krummrich <[email protected]>
2025-08-12 20:33:33 +02:00
Daniel Almeida 17e70f0c54 rust: platform: add irq accessors
These accessors can be used to retrieve a irq::Registration and
irq::ThreadedRegistration from a platform device by
index or name. Alternatively, drivers can retrieve an IrqRequest from a
bound platform device for later use.

These accessors ensure that only valid IRQ lines can ever be registered.

Reviewed-by: Alice Ryhl <[email protected]>
Tested-by: Joel Fernandes <[email protected]>
Tested-by: Dirk Behme <[email protected]>
Signed-off-by: Daniel Almeida <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
[ Remove expect(dead_code) from IrqRequest::new(), re-format macros and
  macro invocations to not exceed 100 characters line length. - Danilo ]
Signed-off-by: Danilo Krummrich <[email protected]>
2025-08-12 20:32:24 +02:00
Daniel Almeida 135d405232 rust: irq: add support for threaded IRQs and handlers
This patch adds support for threaded IRQs and handlers through
irq::ThreadedRegistration and the irq::ThreadedHandler trait.

Threaded interrupts are more permissive in the sense that further
processing is possible in a kthread. This means that said execution takes
place outside of interrupt context, which is rather restrictive in many
ways.

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

Tested-by: Joel Fernandes <[email protected]>
Tested-by: Dirk Behme <[email protected]>
Reviewed-by: Alice Ryhl <[email protected]>
Signed-off-by: Daniel Almeida <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
[ Add now available intra-doc links back in. - Danilo ]
Signed-off-by: Danilo Krummrich <[email protected]>
2025-08-12 20:22:09 +02:00
Daniel Almeida 0851d34a8c 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: Joel Fernandes <[email protected]>
Tested-by: Dirk Behme <[email protected]>
Reviewed-by: Alice Ryhl <[email protected]>
Signed-off-by: Daniel Almeida <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
[ Remove expect(dead_code) from Flags::into_inner(), add
  expect(dead_code) to IrqRequest::new(), fix intra-doc links. - Danilo ]
Signed-off-by: Danilo Krummrich <[email protected]>
2025-08-12 20:22:00 +02:00