RDMA/usnic: Refactor usnic_uiom_alloc_pd()

Rather than hard-coding pci_bus_type, pass the PF device through to
usnic_uiom_alloc_pd() and retrieve its bus there. This prepares for
iommu_domain_alloc() changing to take a device rather than a bus_type.

Link: https://lore.kernel.org/r/ef607cb3f5a09920b86971b8c8e60af8c647457e.1649169359.git.robin.murphy@arm.com
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
This commit is contained in:
Robin Murphy 2022-04-05 15:35:59 +01:00 committed by Jason Gunthorpe
parent d9539fb7c2
commit cc97c6d94e
3 changed files with 4 additions and 6 deletions

View file

@ -443,7 +443,7 @@ int usnic_ib_alloc_pd(struct ib_pd *ibpd, struct ib_udata *udata)
{ {
struct usnic_ib_pd *pd = to_upd(ibpd); struct usnic_ib_pd *pd = to_upd(ibpd);
pd->umem_pd = usnic_uiom_alloc_pd(); pd->umem_pd = usnic_uiom_alloc_pd(ibpd->device->dev.parent);
if (IS_ERR(pd->umem_pd)) if (IS_ERR(pd->umem_pd))
return PTR_ERR(pd->umem_pd); return PTR_ERR(pd->umem_pd);
@ -707,4 +707,3 @@ int usnic_ib_mmap(struct ib_ucontext *context,
usnic_err("No VF %u found\n", vfid); usnic_err("No VF %u found\n", vfid);
return -EINVAL; return -EINVAL;
} }

View file

@ -40,7 +40,6 @@
#include <linux/iommu.h> #include <linux/iommu.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/pci.h>
#include <rdma/ib_verbs.h> #include <rdma/ib_verbs.h>
#include "usnic_log.h" #include "usnic_log.h"
@ -439,7 +438,7 @@ void usnic_uiom_reg_release(struct usnic_uiom_reg *uiomr)
__usnic_uiom_release_tail(uiomr); __usnic_uiom_release_tail(uiomr);
} }
struct usnic_uiom_pd *usnic_uiom_alloc_pd(void) struct usnic_uiom_pd *usnic_uiom_alloc_pd(struct device *dev)
{ {
struct usnic_uiom_pd *pd; struct usnic_uiom_pd *pd;
void *domain; void *domain;
@ -448,7 +447,7 @@ struct usnic_uiom_pd *usnic_uiom_alloc_pd(void)
if (!pd) if (!pd)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
pd->domain = domain = iommu_domain_alloc(&pci_bus_type); pd->domain = domain = iommu_domain_alloc(dev->bus);
if (!domain) { if (!domain) {
usnic_err("Failed to allocate IOMMU domain"); usnic_err("Failed to allocate IOMMU domain");
kfree(pd); kfree(pd);

View file

@ -80,7 +80,7 @@ struct usnic_uiom_chunk {
struct scatterlist page_list[]; struct scatterlist page_list[];
}; };
struct usnic_uiom_pd *usnic_uiom_alloc_pd(void); struct usnic_uiom_pd *usnic_uiom_alloc_pd(struct device *dev);
void usnic_uiom_dealloc_pd(struct usnic_uiom_pd *pd); void usnic_uiom_dealloc_pd(struct usnic_uiom_pd *pd);
int usnic_uiom_attach_dev_to_pd(struct usnic_uiom_pd *pd, struct device *dev); int usnic_uiom_attach_dev_to_pd(struct usnic_uiom_pd *pd, struct device *dev);
void usnic_uiom_detach_dev_from_pd(struct usnic_uiom_pd *pd, void usnic_uiom_detach_dev_from_pd(struct usnic_uiom_pd *pd,