[PATCH v8 3/6] genirq/msi: Add msi_msg_set_addr_iova_offset()
From: Andrew Jones
Date: Fri Dec 04 2026 - 08:32:30 EST
IMSIC's MSI targets are mapped into one contiguous IOVA range and only
the base IOVA is cached in the MSI descriptor. Add a variant of
msi_msg_set_addr() that takes the target's offset from that base.
Signed-off-by: Andrew Jones <andrew.jones@xxxxxxxxx>
---
include/linux/msi.h | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/include/linux/msi.h b/include/linux/msi.h
index a4613de11960..2f672a58bed8 100644
--- a/include/linux/msi.h
+++ b/include/linux/msi.h
@@ -303,22 +303,25 @@ static inline void msi_desc_set_iommu_msi_iova(struct msi_desc *desc, u64 msi_io
}
/**
- * msi_msg_set_addr() - Set MSI address in an MSI message
+ * msi_msg_set_addr_iova_offset() - Set MSI address in an MSI message
*
- * @desc: MSI descriptor that may carry an IOVA base address for MSI via @iommu_msi_iova/shift
- * @msg: Target MSI message to set its address_hi and address_lo
- * @msi_addr: Physical address to set the MSI message
+ * @desc: MSI descriptor that may carry an IOVA base address for MSI via
+ * @iommu_msi_iova/shift
+ * @msg: Target MSI message to set its address_hi and address_lo
+ * @msi_addr: Physical address to set the MSI message
+ * @iova_offset: Offset of the target's page from the IOVA base address in the @desc
*
* Notes:
- * - Override @msi_addr using the IOVA base address in the @desc if @iommu_msi_shift is set
+ * - Override @msi_addr using the IOVA base address in the @desc plus @iova_offset
+ * if @iommu_msi_shift is set
* - Otherwise, simply set @msi_addr to @msg
*/
-static inline void msi_msg_set_addr(struct msi_desc *desc, struct msi_msg *msg,
- phys_addr_t msi_addr)
+static inline void msi_msg_set_addr_iova_offset(struct msi_desc *desc, struct msi_msg *msg,
+ phys_addr_t msi_addr, u64 iova_offset)
{
#ifdef CONFIG_IRQ_MSI_IOMMU
if (desc->iommu_msi_shift) {
- u64 msi_iova = desc->iommu_msi_iova << desc->iommu_msi_shift;
+ u64 msi_iova = (desc->iommu_msi_iova << desc->iommu_msi_shift) + iova_offset;
msg->address_hi = upper_32_bits(msi_iova);
msg->address_lo = lower_32_bits(msi_iova) |
@@ -330,6 +333,12 @@ static inline void msi_msg_set_addr(struct msi_desc *desc, struct msi_msg *msg,
msg->address_lo = lower_32_bits(msi_addr);
}
+static inline void msi_msg_set_addr(struct msi_desc *desc, struct msi_msg *msg,
+ phys_addr_t msi_addr)
+{
+ msi_msg_set_addr_iova_offset(desc, msg, msi_addr, 0);
+}
+
int msi_domain_insert_msi_desc(struct device *dev, unsigned int domid,
struct msi_desc *init_desc);
/**
--
2.56.1