On 2/7/22 3:14 PM, Christoph Hellwig wrote:
+ #define DEVI_IDX(seg, bus, devfn) ((((u16)(seg)) << 16) | PCI_DEVID(bus, 
devfn))

Please turn this into an real function.

Sure.

  /*
- * Iterate over elements in device_domain_list and call the specified
+ * Iterate over elements in device_domain_array and call the specified
   * callback @fn against each element.
   */
  int for_each_device_domain(int (*fn)(struct device_domain_info *info,
                                     void *data), void *data)
  {
        struct device_domain_info *info;
+       unsigned long index;
+       int ret = 0;
+ rcu_read_lock();
+       xa_for_each(&device_domain_array, index, info) {
                ret = fn(info, data);
+               if (ret)
+                       break;
        }
+       rcu_read_unlock();

Can't we just open code this in the caller now?

That's better. I will remove this helper and make iteration in the only
caller.


  const struct iommu_ops intel_iommu_ops;
@@ -900,7 +898,8 @@ static void pgtable_walk(struct intel_iommu *iommu, 
unsigned long pfn, u8 bus, u
        struct dmar_domain *domain;
        int offset, level;
- info = dmar_search_domain_by_dev_info(iommu->segment, bus, devfn);
+       info = xa_load(&device_domain_array,
+                      DEVI_IDX(iommu->segment, bus, devfn));
        if (!info || !info->domain) {
                pr_info("device [%02x:%02x.%d] not probed\n",
                        bus, PCI_SLOT(devfn), PCI_FUNC(devfn));

Is there any refcounting or other life time protection for the info
structures?

The info structure's life is managed by iommu_probe/release_device(). It
is created in probe() and freed in release().

Best regards,
baolu
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

Reply via email to