Re: [PATCH v12 8/8] vfio/type1: return MSI geometry through VFIO_IOMMU_GET_INFO capability chains

2016-08-03 Thread kbuild test robot
Hi Eric,

[auto build test ERROR on vfio/next]
[also build test ERROR on v4.7]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Eric-Auger/KVM-PCIe-MSI-passthrough-on-ARM-ARM64-kernel-part-3-3-vfio-changes/20160803-122924
base:   https://github.com/awilliam/linux-vfio.git next
config: x86_64-randconfig-s1-08031247 (attached as .config)
compiler: gcc-4.4 (Debian 4.4.7-8) 4.4.7
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

All errors (new ones prefixed by >>):

   drivers/vfio/vfio_iommu_type1.c:39:29: error: linux/msi-iommu.h: No such 
file or directory
   drivers/vfio/vfio_iommu_type1.c:40:32: error: linux/msi-doorbell.h: No such 
file or directory
   drivers/vfio/vfio_iommu_type1.c: In function 'vfio_set_msi_aperture':
   drivers/vfio/vfio_iommu_type1.c:455: error: implicit declaration of function 
'iommu_msi_set_aperture'
   drivers/vfio/vfio_iommu_type1.c: In function 'vfio_iommu_type1_attach_group':
   drivers/vfio/vfio_iommu_type1.c:935: error: implicit declaration of function 
'msi_doorbell_safe'
   drivers/vfio/vfio_iommu_type1.c: In function 'compute_msi_geometry_caps':
   drivers/vfio/vfio_iommu_type1.c:1113: error: storage size of 'msi_geometry' 
isn't known
   drivers/vfio/vfio_iommu_type1.c:1122: error: 'DOMAIN_ATTR_MSI_GEOMETRY' 
undeclared (first use in this function)
   drivers/vfio/vfio_iommu_type1.c:1122: error: (Each undeclared identifier is 
reported only once
   drivers/vfio/vfio_iommu_type1.c:1122: error: for each function it appears 
in.)
>> drivers/vfio/vfio_iommu_type1.c:1152: error: implicit declaration of 
>> function 'msi_doorbell_calc_pages'
   drivers/vfio/vfio_iommu_type1.c:1113: warning: unused variable 'msi_geometry'
   At top level:
   cc1: warning: unrecognized command line option "-Wno-maybe-uninitialized"

vim +/msi_doorbell_calc_pages +1152 drivers/vfio/vfio_iommu_type1.c

  1146  vfio_msi_geometry->order = order;
  1147  /*
  1148   * we compute a system-wide requirement based on all the 
registered
  1149   * doorbells
  1150   */
  1151  vfio_msi_geometry->size =
> 1152  msi_doorbell_calc_pages(order) * ((uint64_t) 1 << 
> order);
  1153  
  1154  return 0;
  1155  }

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data
___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

[PATCH v12 8/8] vfio/type1: return MSI geometry through VFIO_IOMMU_GET_INFO capability chains

2016-08-02 Thread Eric Auger
This patch allows the user-space to retrieve the MSI geometry. The
implementation is based on capability chains, now also added to
VFIO_IOMMU_GET_INFO.

The returned info comprise:
- whether the MSI IOVA are constrained to a reserved range (x86 case) and
  in the positive, the start/end of the aperture,
- or whether the IOVA aperture need to be set by the userspace. In that
  case, the size and alignment of the IOVA window to be provided are
  returned.

In case the userspace must provide the IOVA aperture, we currently report
a size/alignment based on all the doorbells registered by the host kernel.
This may exceed the actual needs.

Signed-off-by: Eric Auger 

---
v11 -> v11:
- msi_doorbell_pages was renamed msi_doorbell_calc_pages

v9 -> v10:
- move cap_offset after iova_pgsizes
- replace __u64 alignment by __u32 order
- introduce __u32 flags in vfio_iommu_type1_info_cap_msi_geometry and
  fix alignment
- call msi-doorbell API to compute the size/alignment

v8 -> v9:
- use iommu_msi_supported flag instead of programmable
- replace IOMMU_INFO_REQUIRE_MSI_MAP flag by a more sophisticated
  capability chain, reporting the MSI geometry

v7 -> v8:
- use iommu_domain_msi_geometry

v6 -> v7:
- remove the computation of the number of IOVA pages to be provisionned.
  This number depends on the domain/group/device topology which can
  dynamically change. Let's rely instead rely on an arbitrary max depending
  on the system

v4 -> v5:
- move msi_info and ret declaration within the conditional code

v3 -> v4:
- replace former vfio_domains_require_msi_mapping by
  more complex computation of MSI mapping requirements, especially the
  number of pages to be provided by the user-space.
- reword patch title

RFC v1 -> v1:
- derived from
  [RFC PATCH 3/6] vfio: Extend iommu-info to return MSIs automap state
- renamed allow_msi_reconfig into require_msi_mapping
- fixed VFIO_IOMMU_GET_INFO
---
 drivers/vfio/vfio_iommu_type1.c | 78 -
 include/uapi/linux/vfio.h   | 32 -
 2 files changed, 108 insertions(+), 2 deletions(-)

diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index 7daab53..3aa628d 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -38,6 +38,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #define DRIVER_VERSION  "0.2"
 #define DRIVER_AUTHOR   "Alex Williamson "
@@ -1103,6 +1105,55 @@ static int vfio_domains_have_iommu_cache(struct 
vfio_iommu *iommu)
return ret;
 }
 
+static int compute_msi_geometry_caps(struct vfio_iommu *iommu,
+struct vfio_info_cap *caps)
+{
+   struct vfio_iommu_type1_info_cap_msi_geometry *vfio_msi_geometry;
+   unsigned long order = __ffs(vfio_pgsize_bitmap(iommu));
+   struct iommu_domain_msi_geometry msi_geometry;
+   struct vfio_info_cap_header *header;
+   struct vfio_domain *d;
+   bool reserved;
+   size_t size;
+
+   mutex_lock(>lock);
+   /* All domains have same require_msi_map property, pick first */
+   d = list_first_entry(>domain_list, struct vfio_domain, next);
+   iommu_domain_get_attr(d->domain, DOMAIN_ATTR_MSI_GEOMETRY,
+ _geometry);
+   reserved = !msi_geometry.iommu_msi_supported;
+
+   mutex_unlock(>lock);
+
+   size = sizeof(*vfio_msi_geometry);
+   header = vfio_info_cap_add(caps, size,
+  VFIO_IOMMU_TYPE1_INFO_CAP_MSI_GEOMETRY, 1);
+
+   if (IS_ERR(header))
+   return PTR_ERR(header);
+
+   vfio_msi_geometry = container_of(header,
+   struct vfio_iommu_type1_info_cap_msi_geometry,
+   header);
+
+   vfio_msi_geometry->flags = reserved;
+   if (reserved) {
+   vfio_msi_geometry->aperture_start = msi_geometry.aperture_start;
+   vfio_msi_geometry->aperture_end = msi_geometry.aperture_end;
+   return 0;
+   }
+
+   vfio_msi_geometry->order = order;
+   /*
+* we compute a system-wide requirement based on all the registered
+* doorbells
+*/
+   vfio_msi_geometry->size =
+   msi_doorbell_calc_pages(order) * ((uint64_t) 1 << order);
+
+   return 0;
+}
+
 static long vfio_iommu_type1_ioctl(void *iommu_data,
   unsigned int cmd, unsigned long arg)
 {
@@ -1124,8 +1175,10 @@ static long vfio_iommu_type1_ioctl(void *iommu_data,
}
} else if (cmd == VFIO_IOMMU_GET_INFO) {
struct vfio_iommu_type1_info info;
+   struct vfio_info_cap caps = { .buf = NULL, .size = 0 };
+   int ret;
 
-   minsz = offsetofend(struct vfio_iommu_type1_info, iova_pgsizes);
+   minsz = offsetofend(struct vfio_iommu_type1_info, cap_offset);
 
if