All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pranjal Shrivastava <praan@google.com>
To: Samiullah Khawaja <skhawaja@google.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>,
	Nicolin Chen <nicolinc@nvidia.com>,
	iommu@lists.linux.dev, Will Deacon <will@kernel.org>,
	Joerg Roedel <joro@8bytes.org>,
	Robin Murphy <robin.murphy@arm.com>,
	Mostafa Saleh <smostafa@google.com>,
	Daniel Mentz <danielmentz@google.com>,
	Pasha Tatashin <pasha.tatashin@soleen.com>,
	David Matlack <dmatlack@google.com>
Subject: Re: [PATCH rc v2] iommu/arm-smmu-v3: Fix inconsistent ATS state tracking
Date: Thu, 7 May 2026 20:12:14 +0000	[thread overview]
Message-ID: <afzyHk6aQeOiMm88@google.com> (raw)
In-Reply-To: <afu5s1vnmZ2aEev_@google.com>

On Wed, May 06, 2026 at 10:20:15PM +0000, Samiullah Khawaja wrote:
> > 
> > Thus, this sequence occurs:
> > 
> > 1. The Intel quirk sets pdev->ats_cap = 0 for the PF at boot.
> > 2. pci_prepare_ats(PF) fails during arm_smmu_probe_device() as the
> >   quirk causes pci_ats_supported to return false & PF->ats_stu
> >   remains 0. (arm-smmu-v3 ignores the failure)
> 
> Ok that explains how PF stu is zero.
> > 
> > 3. PF attaches to identity domain: pci_enable_ats is skipped
> > 4. VF's arm_smmu_probe_device returns early from pci_prepare_ats() due
> >   to the if (dev->is_virtfn) return 0; check
> > 
> > 5. SMMU calls pci_ats_supported() for the VF in attach_prepare() which
> >   returns true as the quirk hasn't been called for the VF yet.
> >   The SMMU driver sets state->ats_enabled = true
> > 
> > 6. We call pci_enable_ats which hits the STU mismatch (PF never sets it)
> > 7. Later while disabling ATS for VF via pci_disable_ats, we hit the WARN
> > 
> > I guess we must think about the following:
> > 
> > 1. Check return values of pci_enable_ats / pci_prepare_ats in SMMUv3
> > 2. PCIe core to provide a proper ATS flag that iommu driver can rely on
> >   and maybe define a policy around pci_ats_supported() to make sure it
> >   also handles such quirks in pci_ats_supported().
> 
> It seems like that ats_supported() checking only ats_cap of the VF is
> not enough, since ATS can be enabled for a VF only when the stu matches
> with the PF? So even if ats_supported() for the VF returns true, its not
> really supported if the stu doesn't match. And the stu would be set
> properly if the PF had ats_cap. Should the ats_supported() check for
> the ats_cap for the PF also?
> 

I think yes. We should add that OR we should be checking for PF's ATS
cap while probing VFs to handle such quirks. The main problem is that
the quirk isn't applied to the VF *before* the IOMMU attach. 

> We can check the PF ats_cap in the ats_supported() or handle the
> enable_ats() error in arm smmuv3. Intel and AMD drivers seems to be
> handling the error.

I guess if pci_ats_supported() is fixed arm smmuv3 would stop hitting
that warning. Although, I agree that we should be checking the retval of
prepare_ats & enable_ats in arm-smmu-v3.

Thanks,
Praan

      reply	other threads:[~2026-05-07 20:12 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-04 16:38 [PATCH rc v2] iommu/arm-smmu-v3: Fix inconsistent ATS state tracking Pranjal Shrivastava
2026-05-04 18:01 ` Nicolin Chen
2026-05-04 19:33   ` Pranjal Shrivastava
2026-05-04 20:03     ` Pranjal Shrivastava
2026-05-04 20:23     ` Nicolin Chen
2026-05-04 20:29       ` Pranjal Shrivastava
2026-05-04 20:51         ` Nicolin Chen
2026-05-04 20:40       ` Pranjal Shrivastava
2026-05-04 20:54         ` Nicolin Chen
2026-05-05 16:11     ` Jason Gunthorpe
2026-05-05 20:21       ` Nicolin Chen
2026-05-05 21:23         ` Pranjal Shrivastava
2026-05-05 21:44           ` Nicolin Chen
2026-05-05 22:06             ` Pranjal Shrivastava
2026-05-06 20:44         ` Samiullah Khawaja
2026-05-05 21:14       ` Pranjal Shrivastava
2026-05-05 22:32         ` Pranjal Shrivastava
2026-05-06  9:46           ` Jason Gunthorpe
2026-05-06 20:19             ` Pranjal Shrivastava
2026-05-06 22:03               ` Pranjal Shrivastava
2026-05-06 21:57             ` Pranjal Shrivastava
2026-05-06 22:04               ` Pranjal Shrivastava
2026-05-09 17:14                 ` Jason Gunthorpe
2026-05-11 12:07                   ` Pranjal Shrivastava
2026-05-11 14:16                     ` Jason Gunthorpe
2026-05-11 16:07                       ` Pranjal Shrivastava
2026-05-11 16:30                         ` David Matlack
2026-05-11 16:57                           ` Pranjal Shrivastava
2026-05-11 17:03                         ` Jason Gunthorpe
2026-05-06 22:20               ` Samiullah Khawaja
2026-05-07 20:12                 ` Pranjal Shrivastava [this message]

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=afzyHk6aQeOiMm88@google.com \
    --to=praan@google.com \
    --cc=danielmentz@google.com \
    --cc=dmatlack@google.com \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@ziepe.ca \
    --cc=joro@8bytes.org \
    --cc=nicolinc@nvidia.com \
    --cc=pasha.tatashin@soleen.com \
    --cc=robin.murphy@arm.com \
    --cc=skhawaja@google.com \
    --cc=smostafa@google.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.