From: Andrew Jones <andrew.jones@linux.dev>
To: linux-riscv@lists.infradead.org, iommu@lists.linux.dev
Cc: linux-kernel@vger.kernel.org, tomasz.jeznach@linux.dev,
jgg@ziepe.ca, jgg@nvidia.com, joro@8bytes.org, will@kernel.org,
robin.murphy@arm.com, pjw@kernel.org, palmer@dabbelt.com,
anup@brainfault.org, tglx@kernel.org, kevin.tian@intel.com,
fangyu.yu@linux.alibaba.com, nutty.liu@hotmail.com
Subject: [PATCH v8 3/6] genirq/msi: Add msi_msg_set_addr_iova_offset()
Date: Fri, 4 Dec 2026 14:31:03 +0100 [thread overview]
Message-ID: <20261204133106.664239-4-andrew.jones@linux.dev> (raw)
In-Reply-To: <20261204133106.664239-1-andrew.jones@linux.dev>
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@linux.dev>
---
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
WARNING: multiple messages have this Message-ID (diff)
From: Andrew Jones <andrew.jones@linux.dev>
To: linux-riscv@lists.infradead.org, iommu@lists.linux.dev
Cc: linux-kernel@vger.kernel.org, tomasz.jeznach@linux.dev,
jgg@ziepe.ca, jgg@nvidia.com, joro@8bytes.org, will@kernel.org,
robin.murphy@arm.com, pjw@kernel.org, palmer@dabbelt.com,
anup@brainfault.org, tglx@kernel.org, kevin.tian@intel.com,
fangyu.yu@linux.alibaba.com, nutty.liu@hotmail.com
Subject: [PATCH v8 3/6] genirq/msi: Add msi_msg_set_addr_iova_offset()
Date: Fri, 4 Dec 2026 14:31:03 +0100 [thread overview]
Message-ID: <20261204133106.664239-4-andrew.jones@linux.dev> (raw)
In-Reply-To: <20261204133106.664239-1-andrew.jones@linux.dev>
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@linux.dev>
---
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
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2026-12-04 13:32 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 13:31 [PATCH v8 0/6] iommu/riscv: Enable MSI remapping and IOMMU_DMA Andrew Jones
2026-12-04 13:31 ` Andrew Jones
2026-12-04 13:31 ` [PATCH v8 1/6] iommu/dma: Prepare MSI physical address lists Andrew Jones
2026-12-04 13:31 ` Andrew Jones
2026-12-04 13:31 ` [PATCH v8 2/6] iommu/dma: Introduce iommu_dma_prepare_msi_list() Andrew Jones
2026-12-04 13:31 ` Andrew Jones
2026-12-04 13:31 ` Andrew Jones [this message]
2026-12-04 13:31 ` [PATCH v8 3/6] genirq/msi: Add msi_msg_set_addr_iova_offset() Andrew Jones
2026-12-04 13:31 ` [PATCH v8 4/6] irqchip/riscv-imsic: Add MSI address list Andrew Jones
2026-12-04 13:31 ` Andrew Jones
2026-12-04 13:31 ` [PATCH v8 5/6] irqchip/riscv-imsic: Support IOMMU MSI address lists Andrew Jones
2026-12-04 13:31 ` Andrew Jones
2026-12-04 13:31 ` [PATCH v8 6/6] iommu/dma: Enable IOMMU_DMA for 64-bit RISC-V Andrew Jones
2026-12-04 13:31 ` Andrew Jones
2026-12-04 14:14 ` [PATCH v8 0/6] iommu/riscv: Enable MSI remapping and IOMMU_DMA Robin Murphy
2026-12-04 14:14 ` Robin Murphy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261204133106.664239-4-andrew.jones@linux.dev \
--to=andrew.jones@linux.dev \
--cc=anup@brainfault.org \
--cc=fangyu.yu@linux.alibaba.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@nvidia.com \
--cc=jgg@ziepe.ca \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=nutty.liu@hotmail.com \
--cc=palmer@dabbelt.com \
--cc=pjw@kernel.org \
--cc=robin.murphy@arm.com \
--cc=tglx@kernel.org \
--cc=tomasz.jeznach@linux.dev \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.