[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <762360b8-57ca-ab48-c454-25b9c0aec5de@linux.intel.com>
Date: Tue, 8 Feb 2022 12:38:32 +0800
From: Lu Baolu <baolu.lu@...ux.intel.com>
To: Christoph Hellwig <hch@....de>
Cc: baolu.lu@...ux.intel.com, 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>,
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
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
Powered by blists - more mailing lists