[PATCH 1/6] rust: iommu: move the protection flags to the module root

From: Daniel Almeida

Date: Thu Nov 12 2026 - 12:03:47 EST


The protection flags are the IOMMU_* flags from include/linux/iommu.h,
and are not specific to io-pgtable. Domain::map(), added later in this
series, takes them too.

Move them to kernel::iommu and re-export them from the pgtable module,
so that existing users do not need to change.

Signed-off-by: Daniel Almeida <daniel.almeida@xxxxxxxxxxxxx>
---
rust/kernel/iommu/mod.rs | 16 ++++++++++++++++
rust/kernel/iommu/pgtable.rs | 16 +---------------
2 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/rust/kernel/iommu/mod.rs b/rust/kernel/iommu/mod.rs
index 1423d7b19b57..afc9cfffb656 100644
--- a/rust/kernel/iommu/mod.rs
+++ b/rust/kernel/iommu/mod.rs
@@ -3,3 +3,19 @@
//! Rust support related to IOMMU.

pub mod pgtable;
+
+/// Protection flags used with IOMMU mappings.
+pub mod prot {
+ /// Read access.
+ pub const READ: u32 = bindings::IOMMU_READ;
+ /// Write access.
+ pub const WRITE: u32 = bindings::IOMMU_WRITE;
+ /// Request cache coherency.
+ pub const CACHE: u32 = bindings::IOMMU_CACHE;
+ /// Request no-execute permission.
+ pub const NOEXEC: u32 = bindings::IOMMU_NOEXEC;
+ /// MMIO peripheral mapping.
+ pub const MMIO: u32 = bindings::IOMMU_MMIO;
+ /// Privileged mapping.
+ pub const PRIVILEGED: u32 = bindings::IOMMU_PRIV;
+}
diff --git a/rust/kernel/iommu/pgtable.rs b/rust/kernel/iommu/pgtable.rs
index 5f9b42ca92c2..695b62eb4835 100644
--- a/rust/kernel/iommu/pgtable.rs
+++ b/rust/kernel/iommu/pgtable.rs
@@ -23,21 +23,7 @@

use bindings::io_pgtable_fmt;

-/// Protection flags used with IOMMU mappings.
-pub mod prot {
- /// Read access.
- pub const READ: u32 = bindings::IOMMU_READ;
- /// Write access.
- pub const WRITE: u32 = bindings::IOMMU_WRITE;
- /// Request cache coherency.
- pub const CACHE: u32 = bindings::IOMMU_CACHE;
- /// Request no-execute permission.
- pub const NOEXEC: u32 = bindings::IOMMU_NOEXEC;
- /// MMIO peripheral mapping.
- pub const MMIO: u32 = bindings::IOMMU_MMIO;
- /// Privileged mapping.
- pub const PRIVILEGED: u32 = bindings::IOMMU_PRIV;
-}
+pub use super::prot;

/// Represents a requested `io_pgtable` configuration.
pub struct Config {

--
2.56.0