Re: [PATCH v2 2/4] iommufd: Move iommufd_sw_msi and related functions to driver.c
From: Nicolin Chen
Date: Fri Feb 28 2025 - 12:54:57 EST
On Fri, Feb 28, 2025 at 01:32:12PM -0400, Jason Gunthorpe wrote:
> On Thu, Feb 27, 2025 at 05:31:16PM -0800, Nicolin Chen wrote:
> > @@ -187,6 +188,8 @@ struct iommufd_object *_iommufd_object_alloc(struct iommufd_ctx *ictx,
> > enum iommufd_object_type type);
> > struct device *iommufd_viommu_find_dev(struct iommufd_viommu *viommu,
> > unsigned long vdev_id);
> > +int iommufd_sw_msi(struct iommu_domain *domain, struct msi_desc *desc,
> > + phys_addr_t msi_addr);
>
> This should probably go into drivers/iommu/iommu-priv.h ?
Oh right, I forgot we had that.
> > +int iommufd_sw_msi_install(struct iommufd_ctx *ictx,
> > + struct iommufd_hwpt_paging *hwpt_paging,
> > + struct iommufd_sw_msi_map *msi_map)
> > +{
> > + unsigned long iova;
> > +
> > + lockdep_assert_held(&ictx->sw_msi_lock);
> > +
> > + iova = msi_map->sw_msi_start + msi_map->pgoff * PAGE_SIZE;
> > + if (!test_bit(msi_map->id, hwpt_paging->present_sw_msi.bitmap)) {
> > + int rc;
> > +
> > + rc = iommu_map(hwpt_paging->common.domain, iova,
> > + msi_map->msi_addr, PAGE_SIZE,
> > + IOMMU_WRITE | IOMMU_READ | IOMMU_MMIO,
> > + GFP_KERNEL_ACCOUNT);
> > + if (rc)
> > + return rc;
> > + __set_bit(msi_map->id, hwpt_paging->present_sw_msi.bitmap);
> > + }
> > + return 0;
> > +}
> > +EXPORT_SYMBOL_NS_GPL(iommufd_sw_msi_install, "IOMMUFD");
>
> Stubbed out too if CONFIG_IRQ_MSI_IOMMU ?
In that case, the other caller iommufd_group_setup_msi() could be
{
#if IS_ENABLED(CONFIG_IRQ_MSI_IOMMU)
....
iommufd_sw_msi_install();
...
#endif
return 0;
}
?
> I'm still wondering if we should use a function pointer, how big was
> this compiled anyhow?
Hmm, you mean the size of driver.o? It's 192K (before) vs 212K
(after).
Thanks
Nicolin