All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Joerg Roedel <joro@8bytes.org>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Robin Murphy <robin.murphy@arm.com>,
	Thierry Reding <treding@nvidia.com>,
	Jonathan Hunter <jonathanh@nvidia.com>,
	Prathamesh Shete <pshete@nvidia.com>,
	Will Deacon <will@kernel.org>,
	iommu@lists.linux-foundation.org, linux-mmc@vger.kernel.org,
	linux-tegra@vger.kernel.org
Subject: Re: [PATCH v11 2/6] iommu/tegra: Add tegra_dev_iommu_get_stream_id() helper
Date: Fri, 2 Dec 2022 11:31:27 +0100	[thread overview]
Message-ID: <Y4nT/+M4QKLSDLVC@orome> (raw)
In-Reply-To: <CAPDyKFpGs4TvkV5FKnfpQH45qAiwhJfSiP60P2vMSX30GsMkQQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2342 bytes --]

On Fri, Nov 18, 2022 at 09:08:17AM +0100, Ulf Hansson wrote:
> On Thu, 17 Nov 2022 at 19:27, Thierry Reding <thierry.reding@gmail.com> wrote:
> >
> > From: Thierry Reding <treding@nvidia.com>
> >
> > Access to the internals of struct iommu_fwspec by non-IOMMU drivers is
> > discouraged. Many drivers for Tegra SoCs, however, need access to their
> > IOMMU stream IDs so that they can be programmed into various hardware
> > registers.
> >
> > Formalize this access into a common helper to make it easier to audit
> > and maintain.
> >
> > Signed-off-by: Thierry Reding <treding@nvidia.com>
> > ---
> >  include/linux/iommu.h | 21 +++++++++++++++++++++
> >  1 file changed, 21 insertions(+)
> >
> > diff --git a/include/linux/iommu.h b/include/linux/iommu.h
> > index dc5e6f5c14fc..f0d72acad7db 100644
> > --- a/include/linux/iommu.h
> > +++ b/include/linux/iommu.h
> > @@ -1186,4 +1186,25 @@ static inline u32 iommu_sva_get_pasid(struct iommu_sva *handle)
> >  }
> >  #endif /* CONFIG_IOMMU_SVA */
> >
> > +/*
> > + * Newer generations of Tegra SoCs require devices' stream IDs to be directly programmed into
> > + * some registers. These are always paired with a Tegra SMMU or ARM SMMU, for which the contents
> > + * of the struct iommu_fwspec are known. Use this helper to formalize access to these internals.
> > + */
> > +#define TEGRA_STREAM_ID_BYPASS 0x7f
> > +
> > +static inline bool tegra_dev_iommu_get_stream_id(struct device *dev, u32 *stream_id)
> > +{
> > +#ifdef CONFIG_IOMMU_API
> > +       struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
> > +
> > +       if (fwspec && fwspec->num_ids == 1) {
> > +               *stream_id = fwspec->ids[0] & 0xffff;
> > +               return true;
> > +       }
> > +#endif
> 
> It's totally up to iommu maintainers to decide, but I personally would
> prefer to replace the below part with a stub function, defined when
> CONFIG_IOMMU_API is unset.

Yeah, that's what I had done originally, but then it felt a bit at odds
with Robin's request to move this into a central location. Ultimately
the result is the same and this has the benefit of standing out a bit
more as unusual.

I don't feel strongly, though, so if Joerg and/or Robin want to see this
split up into an implementation and a stub, I can do that.

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2022-12-02 10:31 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-17 18:27 [PATCH v11 0/6] mmc: sdhci: Add Tegra234 support Thierry Reding
2022-11-17 18:27 ` [PATCH v11 1/6] iommu: Add note about struct iommu_fwspec usage Thierry Reding
2022-11-19  9:51   ` Joerg Roedel
2022-11-17 18:27 ` [PATCH v11 2/6] iommu/tegra: Add tegra_dev_iommu_get_stream_id() helper Thierry Reding
2022-11-18  8:08   ` Ulf Hansson
2022-12-02 10:31     ` Thierry Reding [this message]
2022-11-17 18:27 ` [PATCH v11 3/6] mmc: sdhci-tegra: Sort includes alphabetically Thierry Reding
2022-11-18  7:32   ` Adrian Hunter
2022-11-18  8:01     ` Ulf Hansson
2022-11-17 18:27 ` [PATCH v11 4/6] mmc: sdhci-tegra: Separate Tegra194 and Tegra234 SoC data Thierry Reding
2022-11-17 18:27 ` [PATCH v11 5/6] mmc: sdhci-tegra: Add support to program MC stream ID Thierry Reding
2022-11-17 18:27 ` [PATCH v11 6/6] mmc: sdhci-tegra: Issue CMD and DAT resets together Thierry Reding

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=Y4nT/+M4QKLSDLVC@orome \
    --to=thierry.reding@gmail.com \
    --cc=adrian.hunter@intel.com \
    --cc=iommu@lists.linux-foundation.org \
    --cc=jonathanh@nvidia.com \
    --cc=joro@8bytes.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=pshete@nvidia.com \
    --cc=robin.murphy@arm.com \
    --cc=treding@nvidia.com \
    --cc=ulf.hansson@linaro.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.