From: Jacob Pan <jacob.jun.pan@linux.intel.com>
To: Baolu Lu <baolu.lu@linux.intel.com>
Cc: Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
Robin Murphy <robin.murphy@arm.com>,
Jason Gunthorpe <jgg@ziepe.ca>, Kevin Tian <kevin.tian@intel.com>,
iommu@lists.linux.dev, linux-kernel@vger.kernel.org,
jacob.jun.pan@linux.intel.com
Subject: Re: [PATCH v3 1/2] iommu/vt-d: Add helper to flush caches for context change
Date: Tue, 2 Jul 2024 08:57:49 -0700 [thread overview]
Message-ID: <20240702085749.2e2bbea5@jacob-builder> (raw)
In-Reply-To: <28ade99a-13ad-4b01-aff2-711c006856fd@linux.intel.com>
On Tue, 2 Jul 2024 12:43:41 +0800, Baolu Lu <baolu.lu@linux.intel.com>
wrote:
> On 2024/7/2 12:41, Jacob Pan wrote:
> > On Mon, 1 Jul 2024 19:23:16 +0800, Lu Baolu<baolu.lu@linux.intel.com>
> > wrote:
> >
> >> + if (flush_domains) {
> >> + /*
> >> + * If the IOMMU is running in scalable mode and there
> >> might
> >> + * be potential PASID translations, the caller should
> >> hold
> >> + * the lock to ensure that context changes and cache
> >> flushes
> >> + * are atomic.
> >> + */
> >> + assert_spin_locked(&iommu->lock);
> >> + for (i = 0; i < info->pasid_table->max_pasid; i++) {
> >> + pte = intel_pasid_get_entry(info->dev, i);
> >> + if (!pte || !pasid_pte_is_present(pte))
> >> + continue;
> > Is it worth going through 1M PASIDs just to skip the PASID cache
> > invalidation? Or just do the flush on all used DIDs unconditionally.
>
> Currently we don't track all domains attached to a device. If such
> optimization is necessary, perhaps we can add it later.
I think it is necessary, because without tracking domain IDs, the code
above would have duplicated invalidations.
For example: a device PASID table has the following entries
PASID DomainID
-------------------------
100 1
200 1
300 2
-------------------------
When a present context entry changes, we need to do:
qi_flush_pasid_cache(iommu, 1, QI_PC_ALL_PASIDS, 0);
qi_flush_pasid_cache(iommu, 2, QI_PC_ALL_PASIDS, 0);
With this code, we do
qi_flush_pasid_cache(iommu, 1, QI_PC_ALL_PASIDS, 0);
qi_flush_pasid_cache(iommu, 1, QI_PC_ALL_PASIDS, 0);//duplicated!
qi_flush_pasid_cache(iommu, 2, QI_PC_ALL_PASIDS, 0);
Thanks,
Jacob
next prev parent reply other threads:[~2024-07-02 15:52 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-01 11:23 [PATCH v3 0/2] iommu/vt-d: Refactor PRI enable/disable steps Lu Baolu
2024-07-01 11:23 ` [PATCH v3 1/2] iommu/vt-d: Add helper to flush caches for context change Lu Baolu
2024-07-02 1:11 ` Tian, Kevin
2024-07-02 1:47 ` Baolu Lu
2024-07-02 2:43 ` Baolu Lu
2024-07-02 4:51 ` Baolu Lu
2024-07-02 6:25 ` Yi Liu
2024-07-02 6:39 ` Tian, Kevin
2024-07-02 8:03 ` Baolu Lu
2024-07-02 4:41 ` Jacob Pan
2024-07-02 4:43 ` Baolu Lu
2024-07-02 15:57 ` Jacob Pan [this message]
2024-07-03 2:49 ` Baolu Lu
2024-07-03 21:35 ` Jacob Pan
2024-07-01 11:23 ` [PATCH v3 2/2] iommu/vt-d: Refactor PCI PRI enabling/disabling callbacks Lu Baolu
2024-07-02 1:11 ` Tian, Kevin
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=20240702085749.2e2bbea5@jacob-builder \
--to=jacob.jun.pan@linux.intel.com \
--cc=baolu.lu@linux.intel.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@ziepe.ca \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=robin.murphy@arm.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.