All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Tian, Kevin" <kevin.tian@intel.com>
To: Baolu Lu <baolu.lu@linux.intel.com>,
	Joerg Roedel <joro@8bytes.org>, "Will Deacon" <will@kernel.org>,
	Robin Murphy <robin.murphy@arm.com>,
	"Jason Gunthorpe" <jgg@ziepe.ca>
Cc: "iommu@lists.linux.dev" <iommu@lists.linux.dev>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH 1/1] iommu/vt-d: Disable PCI ATS in legacy passthrough mode
Date: Thu, 16 Nov 2023 08:24:23 +0000	[thread overview]
Message-ID: <BN9PR11MB52761B8ECFC7A5724A61894E8CB0A@BN9PR11MB5276.namprd11.prod.outlook.com> (raw)
In-Reply-To: <0f8c95f3-c16e-497e-9734-85936ae08f82@linux.intel.com>

> From: Baolu Lu <baolu.lu@linux.intel.com>
> Sent: Thursday, November 16, 2023 3:35 PM
> 
> On 2023/11/14 9:10, Lu Baolu wrote:
> > When IOMMU hardware operates in legacy mode, the TT field of the
> context
> > entry determines the translation type, with three supported types (Section
> > 9.3 Context Entry):
> >
> > - DMA translation without device TLB support
> > - DMA translation with device TLB support
> > - Passthrough mode with translated and translation requests blocked
> >
> > Device TLB support is absent when hardware is configured in passthrough
> > mode.
> >
> > Disable the PCI ATS feature when IOMMU is configured for passthrough
> > translation type in legacy (non-scalable) mode.
> >
> > Fixes: 0faa19a1515f ("iommu/vt-d: Decouple PASID & PRI enabling from
> SVA")
> > Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
> > ---
> >   drivers/iommu/intel/iommu.c | 4 ++++
> >   1 file changed, 4 insertions(+)
> >
> > diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
> > index 11670cd812a3..c3ec09118ab1 100644
> > --- a/drivers/iommu/intel/iommu.c
> > +++ b/drivers/iommu/intel/iommu.c
> > @@ -1413,6 +1413,10 @@ static void iommu_enable_pci_caps(struct
> device_domain_info *info)
> >   	if (!dev_is_pci(info->dev))
> >   		return;
> >
> > +	if (!sm_supported(info->iommu) && info->domain &&
> > +	    domain_type_is_si(info->domain))
> > +		return;
> > +
> >   	pdev = to_pci_dev(info->dev);
> >
> >   	/* The PCIe spec, in its wisdom, declares that the behaviour of
> 
> Perhaps we could move the check into the caller and make this helper
> transparent to the iommu mode and domain type?
> 
> diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
> index 11670cd812a3..9bddd4fbbdf8 100644
> --- a/drivers/iommu/intel/iommu.c
> +++ b/drivers/iommu/intel/iommu.c
> @@ -2492,7 +2492,8 @@ static int dmar_domain_attach_device(struct
> dmar_domain *domain,
>                  return ret;
>          }
> 
> -       iommu_enable_pci_caps(info);
> +       if (sm_supported(info->iommu) || !domain_type_is_si(info->domain))
> +               iommu_enable_pci_caps(info);
> 

IMHO both old and this new version are confusing regarding to that
the commit msg talks only about ATS but the actual code disable all
pci caps. It's correct, being that only ATS is relevant in legacy mode,
but the readability is not good.

what about introducing a helper e.g. device_domain_ats_supported(info)
which includes above checks plus info->ats_supported and then use it
to replace info->ats_supported in iommu_enable_pci_caps()?


  reply	other threads:[~2023-11-16  8:24 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-14  1:10 [PATCH 1/1] iommu/vt-d: Support enforce_cache_coherency only for empty domains Lu Baolu
2023-11-14  1:10 ` [PATCH 1/1] iommu/vt-d: Omit devTLB invalidation requests when TES=0 Lu Baolu
2023-11-14  3:14   ` Tian, Kevin
2023-11-14  3:13     ` Baolu Lu
2023-11-14  4:45       ` Tian, Kevin
2023-11-14  4:54         ` Baolu Lu
2023-11-14  5:31           ` Tian, Kevin
2023-11-29 20:10   ` Jason Gunthorpe
2023-11-30  4:06     ` Baolu Lu
2023-11-30 12:15       ` Jason Gunthorpe
2023-11-14  1:10 ` [PATCH 1/1] iommu/vt-d: Disable PCI ATS in legacy passthrough mode Lu Baolu
2023-11-14  3:14   ` Tian, Kevin
2023-11-16  7:35   ` Baolu Lu
2023-11-16  8:24     ` Tian, Kevin [this message]
2023-11-17  1:09       ` Baolu Lu
2023-11-17  2:22         ` Tian, Kevin
2023-11-29 20:13   ` Jason Gunthorpe
2023-11-30  5:44     ` Baolu Lu
2023-11-30 16:18       ` Jason Gunthorpe
2023-11-14  1:10 ` [PATCH 1/1] iommu/vt-d: Make context clearing consistent with context mapping Lu Baolu
2023-11-14  3:20   ` Tian, Kevin
2023-11-14  3:22     ` Baolu Lu
2023-11-14  4:46       ` Tian, Kevin
2023-11-14  3:16 ` [PATCH 1/1] iommu/vt-d: Support enforce_cache_coherency only for empty domains Tian, Kevin
2023-11-29 20:08 ` Jason Gunthorpe
2023-11-30  3:48   ` Baolu Lu

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=BN9PR11MB52761B8ECFC7A5724A61894E8CB0A@BN9PR11MB5276.namprd11.prod.outlook.com \
    --to=kevin.tian@intel.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@ziepe.ca \
    --cc=joro@8bytes.org \
    --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.