[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220207071420.GG23941@lst.de>
Date: Mon, 7 Feb 2022 08:14:20 +0100
From: Christoph Hellwig <hch@....de>
To: Lu Baolu <baolu.lu@...ux.intel.com>
Cc: Joerg Roedel <joro@...tes.org>, Kevin Tian <kevin.tian@...el.com>,
Ashok Raj <ashok.raj@...el.com>, Liu Yi L <yi.l.liu@...el.com>,
Jacob Pan <jacob.jun.pan@...ux.intel.com>,
Robin Murphy <robin.murphy@....com>,
Jason Gunthorpe <jgg@...dia.com>,
Christoph Hellwig <hch@....de>,
iommu@...ts.linux-foundation.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v1 07/10] iommu/vt-d: Use an xarray for global
device_domain_info
> + #define DEVI_IDX(seg, bus, devfn) ((((u16)(seg)) << 16) | PCI_DEVID(bus, devfn))
Please turn this into an real function.
> /*
> - * 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?
> 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?
Powered by blists - more mailing lists