All of lore.kernel.org
 help / color / mirror / Atom feed
From: Baolu Lu <baolu.lu@linux.intel.com>
To: Nicolin Chen <nicolinc@nvidia.com>,
	dwmw2@infradead.org, joro@8bytes.org,  will@kernel.org
Cc: iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org,
	jgg@nvidia.com
Subject: Re: [PATCH] iommu/vt-d: Try info->iommu in device_to_iommu()
Date: Fri, 13 May 2022 11:32:11 +0800	[thread overview]
Message-ID: <6da2adf4-6717-b562-5ee3-7e28447aa65b@linux.intel.com> (raw)
In-Reply-To: <20220513003233.4442-1-nicolinc@nvidia.com>

On 2022/5/13 08:32, Nicolin Chen wrote:
> Local boot test and VFIO sanity test show that info->iommu can be
> used in device_to_iommu() as a fast path. So this patch adds it.
> 
> Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
> ---
>   drivers/iommu/intel/iommu.c | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
> index 2990f80c5e08..412fca5ab9cd 100644
> --- a/drivers/iommu/intel/iommu.c
> +++ b/drivers/iommu/intel/iommu.c
> @@ -777,6 +777,7 @@ static bool iommu_is_dummy(struct intel_iommu *iommu, struct device *dev)
>   struct intel_iommu *device_to_iommu(struct device *dev, u8 *bus, u8 *devfn)
>   {
>   	struct dmar_drhd_unit *drhd = NULL;
> +	struct device_domain_info *info;
>   	struct pci_dev *pdev = NULL;
>   	struct intel_iommu *iommu;
>   	struct device *tmp;
> @@ -786,6 +787,10 @@ struct intel_iommu *device_to_iommu(struct device *dev, u8 *bus, u8 *devfn)
>   	if (!dev)
>   		return NULL;
>   
> +	info = dev_iommu_priv_get(dev);
> +	if (info)
> +		return info->iommu;

device_to_iommu() also returns device source id (@bus, @devfn).

Perhaps, we can make device_to_iommu() only for probe_device() where the
per-device info data is not initialized yet. After probe_device(), iommu
and sid are retrieved through other helpers by looking up the device
info directly?

Best regards,
baolu

> +
>   	if (dev_is_pci(dev)) {
>   		struct pci_dev *pf_pdev;
>   

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

WARNING: multiple messages have this Message-ID (diff)
From: Baolu Lu <baolu.lu@linux.intel.com>
To: Nicolin Chen <nicolinc@nvidia.com>,
	dwmw2@infradead.org, joro@8bytes.org, will@kernel.org
Cc: baolu.lu@linux.intel.com, jgg@nvidia.com,
	iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iommu/vt-d: Try info->iommu in device_to_iommu()
Date: Fri, 13 May 2022 11:32:11 +0800	[thread overview]
Message-ID: <6da2adf4-6717-b562-5ee3-7e28447aa65b@linux.intel.com> (raw)
In-Reply-To: <20220513003233.4442-1-nicolinc@nvidia.com>

On 2022/5/13 08:32, Nicolin Chen wrote:
> Local boot test and VFIO sanity test show that info->iommu can be
> used in device_to_iommu() as a fast path. So this patch adds it.
> 
> Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
> ---
>   drivers/iommu/intel/iommu.c | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
> index 2990f80c5e08..412fca5ab9cd 100644
> --- a/drivers/iommu/intel/iommu.c
> +++ b/drivers/iommu/intel/iommu.c
> @@ -777,6 +777,7 @@ static bool iommu_is_dummy(struct intel_iommu *iommu, struct device *dev)
>   struct intel_iommu *device_to_iommu(struct device *dev, u8 *bus, u8 *devfn)
>   {
>   	struct dmar_drhd_unit *drhd = NULL;
> +	struct device_domain_info *info;
>   	struct pci_dev *pdev = NULL;
>   	struct intel_iommu *iommu;
>   	struct device *tmp;
> @@ -786,6 +787,10 @@ struct intel_iommu *device_to_iommu(struct device *dev, u8 *bus, u8 *devfn)
>   	if (!dev)
>   		return NULL;
>   
> +	info = dev_iommu_priv_get(dev);
> +	if (info)
> +		return info->iommu;

device_to_iommu() also returns device source id (@bus, @devfn).

Perhaps, we can make device_to_iommu() only for probe_device() where the
per-device info data is not initialized yet. After probe_device(), iommu
and sid are retrieved through other helpers by looking up the device
info directly?

Best regards,
baolu

> +
>   	if (dev_is_pci(dev)) {
>   		struct pci_dev *pf_pdev;
>   


  reply	other threads:[~2022-05-13  3:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-13  0:32 [PATCH] iommu/vt-d: Try info->iommu in device_to_iommu() Nicolin Chen via iommu
2022-05-13  0:32 ` Nicolin Chen
2022-05-13  3:32 ` Baolu Lu [this message]
2022-05-13  3:32   ` Baolu Lu
2022-05-13  3:59   ` Nicolin Chen via iommu
2022-05-13  3:59     ` Nicolin Chen
2022-05-13 11:50   ` Jason Gunthorpe via iommu
2022-05-13 11:50     ` Jason Gunthorpe
2022-05-13 16:48     ` Nicolin Chen via iommu
2022-05-13 16:48       ` Nicolin Chen

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=6da2adf4-6717-b562-5ee3-7e28447aa65b@linux.intel.com \
    --to=baolu.lu@linux.intel.com \
    --cc=dwmw2@infradead.org \
    --cc=iommu@lists.linux-foundation.org \
    --cc=jgg@nvidia.com \
    --cc=joro@8bytes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nicolinc@nvidia.com \
    --cc=will@kernel.org \
    /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.