All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Lu Baolu <baolu.lu@linux.intel.com>
Cc: Kevin Tian <kevin.tian@intel.com>,
	Ashok Raj <ashok.raj@intel.com>,
	linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org,
	Jason Gunthorpe <jgg@nvidia.com>,
	Robin Murphy <robin.murphy@arm.com>,
	Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH v1 07/10] iommu/vt-d: Use an xarray for global device_domain_info
Date: Mon, 7 Feb 2022 08:14:20 +0100	[thread overview]
Message-ID: <20220207071420.GG23941@lst.de> (raw)
In-Reply-To: <20220207064142.1092846-8-baolu.lu@linux.intel.com>

> + #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?
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

WARNING: multiple messages have this Message-ID (diff)
From: Christoph Hellwig <hch@lst.de>
To: Lu Baolu <baolu.lu@linux.intel.com>
Cc: Joerg Roedel <joro@8bytes.org>, Kevin Tian <kevin.tian@intel.com>,
	Ashok Raj <ashok.raj@intel.com>, Liu Yi L <yi.l.liu@intel.com>,
	Jacob Pan <jacob.jun.pan@linux.intel.com>,
	Robin Murphy <robin.murphy@arm.com>,
	Jason Gunthorpe <jgg@nvidia.com>, Christoph Hellwig <hch@lst.de>,
	iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 07/10] iommu/vt-d: Use an xarray for global device_domain_info
Date: Mon, 7 Feb 2022 08:14:20 +0100	[thread overview]
Message-ID: <20220207071420.GG23941@lst.de> (raw)
In-Reply-To: <20220207064142.1092846-8-baolu.lu@linux.intel.com>

> + #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?

  reply	other threads:[~2022-02-07  7:14 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-07  6:41 [PATCH v1 00/10] iommu/vt-d: Some Intel IOMMU cleanups Lu Baolu
2022-02-07  6:41 ` Lu Baolu
2022-02-07  6:41 ` [PATCH v1 01/10] iommu/vt-d: Move DMAR specific helpers into dmar.c Lu Baolu
2022-02-07  6:41   ` Lu Baolu
2022-02-07  7:08   ` Christoph Hellwig
2022-02-07  7:08     ` Christoph Hellwig
2022-02-08  4:27     ` Lu Baolu
2022-02-08  4:27       ` Lu Baolu
2022-02-07  6:41 ` [PATCH v1 02/10] iommu/vt-d: Remove intel_iommu::domains Lu Baolu
2022-02-07  6:41   ` Lu Baolu
2022-02-07  7:09   ` Christoph Hellwig
2022-02-07  7:09     ` Christoph Hellwig
2022-02-07  6:41 ` [PATCH v1 03/10] iommu/vt-d: Remove finding domain in dmar_insert_one_dev_info() Lu Baolu
2022-02-07  6:41   ` Lu Baolu
2022-02-07  7:10   ` Christoph Hellwig
2022-02-07  7:10     ` Christoph Hellwig
2022-02-07  6:41 ` [PATCH v1 04/10] iommu/vt-d: Remove iova_cache_get/put() Lu Baolu
2022-02-07  6:41   ` Lu Baolu
2022-02-07  7:10   ` Christoph Hellwig
2022-02-07  7:10     ` Christoph Hellwig
2022-02-07 10:39   ` John Garry via iommu
2022-02-07 10:39     ` John Garry
2022-02-08  4:29     ` Lu Baolu
2022-02-08  4:29       ` Lu Baolu
2022-02-07  6:41 ` [PATCH v1 05/10] iommu/vt-d: Remove domain and devinfo mempool Lu Baolu
2022-02-07  6:41   ` Lu Baolu
2022-02-07  7:10   ` Christoph Hellwig
2022-02-07  7:10     ` Christoph Hellwig
2022-02-07  6:41 ` [PATCH v1 06/10] iommu/vt-d: Remove DEFER_DEVICE_DOMAIN_INFO Lu Baolu
2022-02-07  6:41   ` Lu Baolu
2022-02-07  7:12   ` Christoph Hellwig
2022-02-07  7:12     ` Christoph Hellwig
2022-02-08  4:31     ` Lu Baolu
2022-02-08  4:31       ` Lu Baolu
2022-02-07  6:41 ` [PATCH v1 07/10] iommu/vt-d: Use an xarray for global device_domain_info Lu Baolu
2022-02-07  6:41   ` Lu Baolu
2022-02-07  7:14   ` Christoph Hellwig [this message]
2022-02-07  7:14     ` Christoph Hellwig
2022-02-08  4:38     ` Lu Baolu
2022-02-08  4:38       ` Lu Baolu
2022-02-07  6:41 ` [PATCH v1 08/10] iommu/vt-d: Use rculist for dmar_domain::devices Lu Baolu
2022-02-07  6:41   ` Lu Baolu
2022-02-07  6:41 ` [PATCH v1 09/10] iommu/vt-d: Refactor dmar_insert_one_dev_info() Lu Baolu
2022-02-07  6:41   ` Lu Baolu
2022-02-07 18:27   ` Jacob Pan
2022-02-07 18:27     ` Jacob Pan
2022-02-08  4:55     ` Lu Baolu
2022-02-08  4:55       ` Lu Baolu
2022-02-25 22:09   ` Jacob Pan
2022-02-25 22:09     ` Jacob Pan
2022-02-07  6:41 ` [PATCH v1 10/10] iommu/vt-d: Some cleanups in iommu.c Lu Baolu
2022-02-07  6:41   ` Lu Baolu
2022-02-07  7:15   ` Christoph Hellwig
2022-02-07  7:15     ` Christoph Hellwig
2022-02-08  4:58     ` Lu Baolu
2022-02-08  4:58       ` Lu Baolu
2022-02-11 13:01 ` [PATCH v1 00/10] iommu/vt-d: Some Intel IOMMU cleanups Jason Gunthorpe via iommu
2022-02-11 13:01   ` Jason Gunthorpe
2022-02-14  0:26   ` Lu Baolu
2022-02-14  0:26     ` Lu Baolu
2022-02-14  2:59 ` Lu Baolu
2022-02-14  2:59   ` Lu Baolu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220207071420.GG23941@lst.de \
    --to=hch@lst.de \
    --cc=ashok.raj@intel.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=iommu@lists.linux-foundation.org \
    --cc=jgg@nvidia.com \
    --cc=kevin.tian@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robin.murphy@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.