diff mbox series

RDMA/usnic: Refactor usnic_uiom_alloc_pd()

Message ID ef607cb3f5a09920b86971b8c8e60af8c647457e.1649169359.git.robin.murphy@arm.com (mailing list archive)
State Accepted
Delegated to: Jason Gunthorpe
Headers show
Series RDMA/usnic: Refactor usnic_uiom_alloc_pd() | expand

Commit Message

Robin Murphy April 5, 2022, 2:35 p.m. UTC
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.

Signed-off-by: Robin Murphy <robin.murphy@arm.com>
---
 drivers/infiniband/hw/usnic/usnic_ib_verbs.c | 3 +--
 drivers/infiniband/hw/usnic/usnic_uiom.c     | 5 ++---
 drivers/infiniband/hw/usnic/usnic_uiom.h     | 2 +-
 3 files changed, 4 insertions(+), 6 deletions(-)

Comments

kernel test robot April 6, 2022, 7:54 p.m. UTC | #1
Hi Robin,

I love your patch! Yet something to improve:

[auto build test ERROR on rdma/for-next]
[also build test ERROR on v5.18-rc1 next-20220406]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/intel-lab-lkp/linux/commits/Robin-Murphy/RDMA-usnic-Refactor-usnic_uiom_alloc_pd/20220406-133657
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma.git for-next
config: i386-allyesconfig (https://download.01.org/0day-ci/archive/20220407/202204070316.vOzwORw5-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.2.0-19) 11.2.0
reproduce (this is a W=1 build):
        # https://github.com/intel-lab-lkp/linux/commit/0aa6215010a083081b26ccb23d0aa2b4089bbbfd
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Robin-Murphy/RDMA-usnic-Refactor-usnic_uiom_alloc_pd/20220406-133657
        git checkout 0aa6215010a083081b26ccb23d0aa2b4089bbbfd
        # save the config file to linux build tree
        mkdir build_dir
        make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/infiniband/hw/usnic/usnic_uiom.c: In function 'usnic_uiom_init':
>> drivers/infiniband/hw/usnic/usnic_uiom.c:561:29: error: 'pci_bus_type' undeclared (first use in this function); did you mean 'bus_type'?
     561 |         if (!iommu_present(&pci_bus_type)) {
         |                             ^~~~~~~~~~~~
         |                             bus_type
   drivers/infiniband/hw/usnic/usnic_uiom.c:561:29: note: each undeclared identifier is reported only once for each function it appears in


vim +561 drivers/infiniband/hw/usnic/usnic_uiom.c

e3cf00d0a87f02 Upinder Malhi 2013-09-10  558  
e3cf00d0a87f02 Upinder Malhi 2013-09-10  559  int usnic_uiom_init(char *drv_name)
e3cf00d0a87f02 Upinder Malhi 2013-09-10  560  {
e3cf00d0a87f02 Upinder Malhi 2013-09-10 @561  	if (!iommu_present(&pci_bus_type)) {
Robin Murphy April 6, 2022, 9:39 p.m. UTC | #2
On 2022-04-06 20:54, kernel test robot wrote:
> Hi Robin,
> 
> I love your patch! Yet something to improve:
> 
> [auto build test ERROR on rdma/for-next]
> [also build test ERROR on v5.18-rc1 next-20220406]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch]

Oops, I failed to notice that this does actually depend on the other 
patch I sent cleaning up iommu_present()[1] - I should have sent them 
together as a series, sorry about that.

Thanks,
Robin.

[1] 
https://lore.kernel.org/linux-iommu/f707b4248e1d33b6d2c7f1d7c94febb802cf9890.1649161199.git.robin.murphy@arm.com/
> 
> url:    https://github.com/intel-lab-lkp/linux/commits/Robin-Murphy/RDMA-usnic-Refactor-usnic_uiom_alloc_pd/20220406-133657
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma.git for-next
> config: i386-allyesconfig (https://download.01.org/0day-ci/archive/20220407/202204070316.vOzwORw5-lkp@intel.com/config)
> compiler: gcc-11 (Debian 11.2.0-19) 11.2.0
> reproduce (this is a W=1 build):
>          # https://github.com/intel-lab-lkp/linux/commit/0aa6215010a083081b26ccb23d0aa2b4089bbbfd
>          git remote add linux-review https://github.com/intel-lab-lkp/linux
>          git fetch --no-tags linux-review Robin-Murphy/RDMA-usnic-Refactor-usnic_uiom_alloc_pd/20220406-133657
>          git checkout 0aa6215010a083081b26ccb23d0aa2b4089bbbfd
>          # save the config file to linux build tree
>          mkdir build_dir
>          make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash
> 
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
> 
> All errors (new ones prefixed by >>):
> 
>     drivers/infiniband/hw/usnic/usnic_uiom.c: In function 'usnic_uiom_init':
>>> drivers/infiniband/hw/usnic/usnic_uiom.c:561:29: error: 'pci_bus_type' undeclared (first use in this function); did you mean 'bus_type'?
>       561 |         if (!iommu_present(&pci_bus_type)) {
>           |                             ^~~~~~~~~~~~
>           |                             bus_type
>     drivers/infiniband/hw/usnic/usnic_uiom.c:561:29: note: each undeclared identifier is reported only once for each function it appears in
> 
> 
> vim +561 drivers/infiniband/hw/usnic/usnic_uiom.c
> 
> e3cf00d0a87f02 Upinder Malhi 2013-09-10  558
> e3cf00d0a87f02 Upinder Malhi 2013-09-10  559  int usnic_uiom_init(char *drv_name)
> e3cf00d0a87f02 Upinder Malhi 2013-09-10  560  {
> e3cf00d0a87f02 Upinder Malhi 2013-09-10 @561  	if (!iommu_present(&pci_bus_type)) {
>
Jason Gunthorpe April 6, 2022, 9:53 p.m. UTC | #3
On Wed, Apr 06, 2022 at 10:39:47PM +0100, Robin Murphy wrote:
> On 2022-04-06 20:54, kernel test robot wrote:
> > Hi Robin,
> > 
> > I love your patch! Yet something to improve:
> > 
> > [auto build test ERROR on rdma/for-next]
> > [also build test ERROR on v5.18-rc1 next-20220406]
> > [If your patch is applied to the wrong git tree, kindly drop us a note.
> > And when submitting patch, we suggest to use '--base' as documented in
> > https://git-scm.com/docs/git-format-patch]
> 
> Oops, I failed to notice that this does actually depend on the other patch I
> sent cleaning up iommu_present()[1] - I should have sent them together as a
> series, sorry about that.

No worries, I'll take care to order it right

Jason
Jason Gunthorpe April 8, 2022, 5:23 p.m. UTC | #4
On Tue, Apr 05, 2022 at 03:35:59PM +0100, Robin Murphy wrote:
> 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.
> 
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
> Reported-by: kernel test robot <lkp@intel.com>
> ---
>  drivers/infiniband/hw/usnic/usnic_ib_verbs.c | 3 +--
>  drivers/infiniband/hw/usnic/usnic_uiom.c     | 5 ++---
>  drivers/infiniband/hw/usnic/usnic_uiom.h     | 2 +-
>  3 files changed, 4 insertions(+), 6 deletions(-)

Applied to for-next, thanks

Jason
diff mbox series

Patch

diff --git a/drivers/infiniband/hw/usnic/usnic_ib_verbs.c b/drivers/infiniband/hw/usnic/usnic_ib_verbs.c
index d3a9670bf971..06aae6a79c3d 100644
--- a/drivers/infiniband/hw/usnic/usnic_ib_verbs.c
+++ b/drivers/infiniband/hw/usnic/usnic_ib_verbs.c
@@ -442,7 +442,7 @@  int usnic_ib_alloc_pd(struct ib_pd *ibpd, struct ib_udata *udata)
 {
 	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))
 		return PTR_ERR(pd->umem_pd);
 
@@ -706,4 +706,3 @@  int usnic_ib_mmap(struct ib_ucontext *context,
 	usnic_err("No VF %u found\n", vfid);
 	return -EINVAL;
 }
-
diff --git a/drivers/infiniband/hw/usnic/usnic_uiom.c b/drivers/infiniband/hw/usnic/usnic_uiom.c
index 8c48027614a1..e212929369df 100644
--- a/drivers/infiniband/hw/usnic/usnic_uiom.c
+++ b/drivers/infiniband/hw/usnic/usnic_uiom.c
@@ -40,7 +40,6 @@ 
 #include <linux/iommu.h>
 #include <linux/workqueue.h>
 #include <linux/list.h>
-#include <linux/pci.h>
 #include <rdma/ib_verbs.h>
 
 #include "usnic_log.h"
@@ -439,7 +438,7 @@  void usnic_uiom_reg_release(struct usnic_uiom_reg *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;
 	void *domain;
@@ -448,7 +447,7 @@  struct usnic_uiom_pd *usnic_uiom_alloc_pd(void)
 	if (!pd)
 		return ERR_PTR(-ENOMEM);
 
-	pd->domain = domain = iommu_domain_alloc(&pci_bus_type);
+	pd->domain = domain = iommu_domain_alloc(dev->bus);
 	if (!domain) {
 		usnic_err("Failed to allocate IOMMU domain");
 		kfree(pd);
diff --git a/drivers/infiniband/hw/usnic/usnic_uiom.h b/drivers/infiniband/hw/usnic/usnic_uiom.h
index 9407522179e9..5a9acf941510 100644
--- a/drivers/infiniband/hw/usnic/usnic_uiom.h
+++ b/drivers/infiniband/hw/usnic/usnic_uiom.h
@@ -80,7 +80,7 @@  struct usnic_uiom_chunk {
 	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);
 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,