From: Nicolin Chen <nicolinc@nvidia.com>
To: <jgg@nvidia.com>, <kevin.tian@intel.com>
Cc: <robin.murphy@arm.com>, <joro@8bytes.org>, <will@kernel.org>,
<iommu@lists.linux.dev>, <linux-kernel@vger.kernel.org>,
<shuah@kernel.org>, <linux-kselftest@vger.kernel.org>,
<shyamsaini@linux.microsoft.com>
Subject: [PATCH v2 2/7] iommufd: Pass in idev to iopt_table_enforce_dev_resv_regions
Date: Tue, 14 Oct 2025 17:29:34 -0700 [thread overview]
Message-ID: <3b472e5f2b3c69ef2ff3aaf1d41532400aa5cf28.1760487869.git.nicolinc@nvidia.com> (raw)
In-Reply-To: <cover.1760487869.git.nicolinc@nvidia.com>
The per-device sw_msi window, defined by sw_msi_start and a size, is from
the IOMMU driver where a static IOMMU_RESV_SW_MSI region is defined.
But soon user space will be allowed to configure the sw_msi window, via a
new SET_OPTION uAPI.
On the other hand, the iopt_table_enforce_dev_resv_regions() will need to
access the sw_msi_start and sw_msi_size stored in the idev struct.
So, pass in idev pointer instead to prepare for the new uAPI.
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
---
drivers/iommu/iommufd/iommufd_private.h | 2 +-
drivers/iommu/iommufd/device.c | 5 ++---
drivers/iommu/iommufd/io_pagetable.c | 3 ++-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/iommu/iommufd/iommufd_private.h b/drivers/iommu/iommufd/iommufd_private.h
index 73e5cddad24e9..cc758610b9f7c 100644
--- a/drivers/iommu/iommufd/iommufd_private.h
+++ b/drivers/iommu/iommufd/iommufd_private.h
@@ -132,7 +132,7 @@ int iopt_table_add_domain(struct io_pagetable *iopt,
void iopt_table_remove_domain(struct io_pagetable *iopt,
struct iommu_domain *domain);
int iopt_table_enforce_dev_resv_regions(struct io_pagetable *iopt,
- struct device *dev,
+ struct iommufd_device *idev,
phys_addr_t *sw_msi_start);
int iopt_set_allow_iova(struct io_pagetable *iopt,
struct rb_root_cached *allowed_iova);
diff --git a/drivers/iommu/iommufd/device.c b/drivers/iommu/iommufd/device.c
index ea7ed32bbaede..2a816533dc10e 100644
--- a/drivers/iommu/iommufd/device.c
+++ b/drivers/iommu/iommufd/device.c
@@ -418,8 +418,7 @@ iommufd_device_attach_reserved_iova(struct iommufd_device *idev,
lockdep_assert_held(&igroup->lock);
- rc = iopt_table_enforce_dev_resv_regions(&hwpt_paging->ioas->iopt,
- idev->dev,
+ rc = iopt_table_enforce_dev_resv_regions(&hwpt_paging->ioas->iopt, idev,
&idev->sw_msi_start);
if (rc)
return rc;
@@ -762,7 +761,7 @@ iommufd_device_do_replace_reserved_iova(struct iommufd_device *idev,
if (!old_hwpt_paging || hwpt_paging->ioas != old_hwpt_paging->ioas) {
xa_for_each(&attach->device_array, index, cur) {
rc = iopt_table_enforce_dev_resv_regions(
- &hwpt_paging->ioas->iopt, cur->dev, NULL);
+ &hwpt_paging->ioas->iopt, cur, NULL);
if (rc)
goto err_unresv;
}
diff --git a/drivers/iommu/iommufd/io_pagetable.c b/drivers/iommu/iommufd/io_pagetable.c
index c0360c450880b..dee0aa3e7cb4a 100644
--- a/drivers/iommu/iommufd/io_pagetable.c
+++ b/drivers/iommu/iommufd/io_pagetable.c
@@ -1440,9 +1440,10 @@ void iopt_remove_access(struct io_pagetable *iopt,
/* Narrow the valid_iova_itree to include reserved ranges from a device. */
int iopt_table_enforce_dev_resv_regions(struct io_pagetable *iopt,
- struct device *dev,
+ struct iommufd_device *idev,
phys_addr_t *sw_msi_start)
{
+ struct device *dev = idev->dev;
struct iommu_resv_region *resv;
LIST_HEAD(resv_regions);
unsigned int num_hw_msi = 0;
--
2.43.0
next prev parent reply other threads:[~2025-10-15 0:31 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-15 0:29 [PATCH v2 0/7] iommufd: Add MSI mapping support with nested SMMU (Part-2 RMR) Nicolin Chen
2025-10-15 0:29 ` [PATCH v2 1/7] iommufd/device: Move sw_msi_start from igroup to idev Nicolin Chen
2025-10-15 0:29 ` Nicolin Chen [this message]
2025-10-15 0:29 ` [PATCH v2 3/7] iommufd/device: Make iommufd_device_is_attached non-static Nicolin Chen
2025-10-15 0:29 ` [PATCH v2 4/7] iommufd: Add IOMMU_OPTION_SW_MSI_START/SIZE ioctls Nicolin Chen
2025-10-15 11:58 ` kernel test robot
2025-10-15 17:20 ` Nicolin Chen
2025-10-15 0:29 ` [PATCH v2 5/7] iommufd/selftest: Add MOCK_FLAGS_DEVICE_NO_ATTACH Nicolin Chen
2025-10-15 0:29 ` [PATCH v2 6/7] iommufd/selftest: Add a testing reserved region Nicolin Chen
2025-10-15 0:29 ` [PATCH v2 7/7] iommufd/selftest: Add coverage for IOMMU_OPTION_SW_MSI_START/SIZE Nicolin Chen
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=3b472e5f2b3c69ef2ff3aaf1d41532400aa5cf28.1760487869.git.nicolinc@nvidia.com \
--to=nicolinc@nvidia.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@nvidia.com \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=robin.murphy@arm.com \
--cc=shuah@kernel.org \
--cc=shyamsaini@linux.microsoft.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®