From: Jason Gunthorpe via iommu <iommu@lists.linux-foundation.org>
To: Baolu Lu <baolu.lu@linux.intel.com>
Cc: will@kernel.org, linux-kernel@vger.kernel.org,
iommu@lists.linux-foundation.org, dwmw2@infradead.org
Subject: Re: [PATCH] iommu/vt-d: Try info->iommu in device_to_iommu()
Date: Fri, 13 May 2022 08:50:32 -0300 [thread overview]
Message-ID: <20220513115032.GM1343366@nvidia.com> (raw)
In-Reply-To: <6da2adf4-6717-b562-5ee3-7e28447aa65b@linux.intel.com>
On Fri, May 13, 2022 at 11:32:11AM +0800, Baolu Lu wrote:
> 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
> > +++ 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).
Those are in the info too..
> 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?
This design makes the most sense to me... Nicolin you said there was a
case where attach was happening before probe though??
Jasno
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
WARNING: multiple messages have this Message-ID (diff)
From: Jason Gunthorpe <jgg@nvidia.com>
To: Baolu Lu <baolu.lu@linux.intel.com>
Cc: Nicolin Chen <nicolinc@nvidia.com>,
dwmw2@infradead.org, joro@8bytes.org, will@kernel.org,
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 08:50:32 -0300 [thread overview]
Message-ID: <20220513115032.GM1343366@nvidia.com> (raw)
In-Reply-To: <6da2adf4-6717-b562-5ee3-7e28447aa65b@linux.intel.com>
On Fri, May 13, 2022 at 11:32:11AM +0800, Baolu Lu wrote:
> 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
> > +++ 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).
Those are in the info too..
> 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?
This design makes the most sense to me... Nicolin you said there was a
case where attach was happening before probe though??
Jasno
next prev parent reply other threads:[~2022-05-13 11:50 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
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 [this message]
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=20220513115032.GM1343366@nvidia.com \
--to=iommu@lists.linux-foundation.org \
--cc=baolu.lu@linux.intel.com \
--cc=dwmw2@infradead.org \
--cc=jgg@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--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.