All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: Ryan Roberts <ryan.roberts@arm.com>
Cc: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>,
	iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
	joro@8bytes.org, kevin.tian@intel.com, nicolinc@nvidia.com,
	mshavit@google.com, robin.murphy@arm.com, will@kernel.org,
	joao.m.martins@oracle.com, jiangkunkun@huawei.com,
	zhukeqian1@huawei.com, linuxarm@huawei.com
Subject: Re: [PATCH v2 4/4] iommu/arm-smmu-v3: Enable HTTU for stage1 with io-pgtable mapping
Date: Tue, 23 Apr 2024 14:32:02 -0300	[thread overview]
Message-ID: <20240423173202.GB941030@nvidia.com> (raw)
In-Reply-To: <364b6a6f-048c-426c-a9c4-aabef551e0c0@arm.com>

On Tue, Apr 23, 2024 at 05:45:16PM +0100, Ryan Roberts wrote:
> On 22/02/2024 09:49, Shameer Kolothum wrote:
> > From: Kunkun Jiang <jiangkunkun@huawei.com>
> > 
> > If io-pgtable quirk flag indicates support for hardware update of
> > dirty state, enable HA/HD bits in the SMMU CD and also set the DBM
> > bit in the page descriptor.
> > 
> > And now report the dirty page tracking capability of SMMUv3.
> > 
> > Co-developed-by: Keqian Zhu <zhukeqian1@huawei.com>
> > Signed-off-by: Keqian Zhu <zhukeqian1@huawei.com>
> > Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
> > Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
> > Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
> 
> Section 3.13 of the spec states: "Where translation tables are shared between
> CDs that contain the same ASID (within a translation regime), the CD HA and HD
> fields must be identical."
> 
> I don't think the way that smmu domains work, its possible to end up with a
> single pgtable shared between multiple CDs? 

It is possible. iommufd can link a single hwpt -> iommu_domain ->
smmu_domain to many different RIDs and to different PASIDs each with
their own CD.

> So the driver should be able to guarantee this constraint is met?

It is expected to be done by this:

> > @@ -1271,6 +1271,12 @@ void arm_smmu_make_s1_cd(struct arm_smmu_cd *target,
> >  		CTXDESC_CD_0_ASET |
> >  		FIELD_PREP(CTXDESC_CD_0_ASID, smmu_domain->asid)
> >  		);
> > +
> > +	/* To enable dirty flag update, set both Access flag and dirty state update */
> > +	if (pgtbl_cfg->quirks & IO_PGTABLE_QUIRK_ARM_HD)
> > +		target->data[0] |= cpu_to_le64(CTXDESC_CD_0_TCR_HA |
> > +					       CTXDESC_CD_0_TCR_HD);
> > +

This function is the only place that programs the ASID into a CD entry
for the domain, and it always derives the HA/HD bits in the same way
from some immutable value stored in the iommu_domain structure.

Jason

WARNING: multiple messages have this Message-ID (diff)
From: Jason Gunthorpe <jgg@nvidia.com>
To: Ryan Roberts <ryan.roberts@arm.com>
Cc: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>,
	iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
	joro@8bytes.org, kevin.tian@intel.com, nicolinc@nvidia.com,
	mshavit@google.com, robin.murphy@arm.com, will@kernel.org,
	joao.m.martins@oracle.com, jiangkunkun@huawei.com,
	zhukeqian1@huawei.com, linuxarm@huawei.com
Subject: Re: [PATCH v2 4/4] iommu/arm-smmu-v3: Enable HTTU for stage1 with io-pgtable mapping
Date: Tue, 23 Apr 2024 14:32:02 -0300	[thread overview]
Message-ID: <20240423173202.GB941030@nvidia.com> (raw)
In-Reply-To: <364b6a6f-048c-426c-a9c4-aabef551e0c0@arm.com>

On Tue, Apr 23, 2024 at 05:45:16PM +0100, Ryan Roberts wrote:
> On 22/02/2024 09:49, Shameer Kolothum wrote:
> > From: Kunkun Jiang <jiangkunkun@huawei.com>
> > 
> > If io-pgtable quirk flag indicates support for hardware update of
> > dirty state, enable HA/HD bits in the SMMU CD and also set the DBM
> > bit in the page descriptor.
> > 
> > And now report the dirty page tracking capability of SMMUv3.
> > 
> > Co-developed-by: Keqian Zhu <zhukeqian1@huawei.com>
> > Signed-off-by: Keqian Zhu <zhukeqian1@huawei.com>
> > Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
> > Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
> > Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
> 
> Section 3.13 of the spec states: "Where translation tables are shared between
> CDs that contain the same ASID (within a translation regime), the CD HA and HD
> fields must be identical."
> 
> I don't think the way that smmu domains work, its possible to end up with a
> single pgtable shared between multiple CDs? 

It is possible. iommufd can link a single hwpt -> iommu_domain ->
smmu_domain to many different RIDs and to different PASIDs each with
their own CD.

> So the driver should be able to guarantee this constraint is met?

It is expected to be done by this:

> > @@ -1271,6 +1271,12 @@ void arm_smmu_make_s1_cd(struct arm_smmu_cd *target,
> >  		CTXDESC_CD_0_ASET |
> >  		FIELD_PREP(CTXDESC_CD_0_ASID, smmu_domain->asid)
> >  		);
> > +
> > +	/* To enable dirty flag update, set both Access flag and dirty state update */
> > +	if (pgtbl_cfg->quirks & IO_PGTABLE_QUIRK_ARM_HD)
> > +		target->data[0] |= cpu_to_le64(CTXDESC_CD_0_TCR_HA |
> > +					       CTXDESC_CD_0_TCR_HD);
> > +

This function is the only place that programs the ASID into a CD entry
for the domain, and it always derives the HA/HD bits in the same way
from some immutable value stored in the iommu_domain structure.

Jason

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2024-04-23 17:32 UTC|newest]

Thread overview: 72+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-22  9:49 [PATCH v2 0/4] iommu/smmuv3: Add IOMMUFD dirty tracking support for SMMUv3 Shameer Kolothum
2024-02-22  9:49 ` Shameer Kolothum
2024-02-22  9:49 ` [PATCH v2 1/4] iommu/arm-smmu-v3: Add feature detection for HTTU Shameer Kolothum
2024-02-22  9:49   ` Shameer Kolothum
2024-04-23 14:41   ` Ryan Roberts
2024-04-23 14:41     ` Ryan Roberts
2024-04-23 14:52     ` Jason Gunthorpe
2024-04-23 14:52       ` Jason Gunthorpe
2024-04-24 10:04       ` Ryan Roberts
2024-04-24 10:04         ` Ryan Roberts
2024-04-24 12:23         ` Jason Gunthorpe
2024-04-24 12:23           ` Jason Gunthorpe
2024-04-24 12:59           ` Ryan Roberts
2024-04-24 12:59             ` Ryan Roberts
2024-04-24 13:20           ` Shameerali Kolothum Thodi
2024-04-24 13:20             ` Shameerali Kolothum Thodi
2024-04-24 13:32             ` Jason Gunthorpe
2024-04-24 13:32               ` Jason Gunthorpe
2024-04-24 13:43               ` Shameerali Kolothum Thodi
2024-04-24 13:43                 ` Shameerali Kolothum Thodi
2024-04-24 14:21                 ` Jason Gunthorpe
2024-04-24 14:21                   ` Jason Gunthorpe
2024-04-24  8:01     ` Shameerali Kolothum Thodi
2024-04-24  8:01       ` Shameerali Kolothum Thodi
2024-04-24  8:28       ` Ryan Roberts
2024-04-24  8:28         ` Ryan Roberts
2024-02-22  9:49 ` [PATCH v2 2/4] iommu/io-pgtable-arm: Add read_and_clear_dirty() support Shameer Kolothum
2024-02-22  9:49   ` Shameer Kolothum
2024-04-23 15:56   ` Ryan Roberts
2024-04-23 15:56     ` Ryan Roberts
2024-04-24  8:01     ` Shameerali Kolothum Thodi
2024-04-24  8:01       ` Shameerali Kolothum Thodi
2024-04-24  8:36       ` Ryan Roberts
2024-04-24  8:36         ` Ryan Roberts
2024-02-22  9:49 ` [PATCH v2 3/4] iommu/arm-smmu-v3: Add support for dirty tracking in domain alloc Shameer Kolothum
2024-02-22  9:49   ` Shameer Kolothum
2024-02-22 11:04   ` Joao Martins
2024-02-22 11:04     ` Joao Martins
2024-02-22 11:31     ` Shameerali Kolothum Thodi
2024-02-22 11:31       ` Shameerali Kolothum Thodi
2024-02-22 11:37       ` Joao Martins
2024-02-22 11:37         ` Joao Martins
2024-02-22 12:24         ` Shameerali Kolothum Thodi
2024-02-22 12:24           ` Shameerali Kolothum Thodi
2024-02-22 13:11           ` Jason Gunthorpe
2024-02-22 13:11             ` Jason Gunthorpe
2024-02-22 13:23           ` Joao Martins
2024-02-22 13:23             ` Joao Martins
2024-03-08 14:31   ` Jason Gunthorpe
2024-03-08 14:31     ` Jason Gunthorpe
2024-04-23 16:27   ` Ryan Roberts
2024-04-23 16:27     ` Ryan Roberts
2024-04-23 16:39     ` Jason Gunthorpe
2024-04-23 16:39       ` Jason Gunthorpe
2024-04-23 16:50       ` Ryan Roberts
2024-04-23 16:50         ` Ryan Roberts
2024-04-24  8:27     ` Shameerali Kolothum Thodi
2024-04-24  8:27       ` Shameerali Kolothum Thodi
2024-02-22  9:49 ` [PATCH v2 4/4] iommu/arm-smmu-v3: Enable HTTU for stage1 with io-pgtable mapping Shameer Kolothum
2024-02-22  9:49   ` Shameer Kolothum
2024-03-08 14:32   ` Jason Gunthorpe
2024-03-08 14:32     ` Jason Gunthorpe
2024-04-23 16:45   ` Ryan Roberts
2024-04-23 16:45     ` Ryan Roberts
2024-04-23 17:32     ` Jason Gunthorpe [this message]
2024-04-23 17:32       ` Jason Gunthorpe
2024-04-24  7:58       ` Ryan Roberts
2024-04-24  7:58         ` Ryan Roberts
2024-04-24 12:15         ` Jason Gunthorpe
2024-04-24 12:15           ` Jason Gunthorpe
2024-04-24 12:45           ` Ryan Roberts
2024-04-24 12:45             ` Ryan Roberts

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=20240423173202.GB941030@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=iommu@lists.linux.dev \
    --cc=jiangkunkun@huawei.com \
    --cc=joao.m.martins@oracle.com \
    --cc=joro@8bytes.org \
    --cc=kevin.tian@intel.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linuxarm@huawei.com \
    --cc=mshavit@google.com \
    --cc=nicolinc@nvidia.com \
    --cc=robin.murphy@arm.com \
    --cc=ryan.roberts@arm.com \
    --cc=shameerali.kolothum.thodi@huawei.com \
    --cc=will@kernel.org \
    --cc=zhukeqian1@huawei.com \
    /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.