The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Nicolin Chen <nicolinc@nvidia.com>
To: Robin Murphy <robin.murphy@arm.com>
Cc: "Pranjal Shrivastava" <praan@google.com>,
	"Jason Gunthorpe" <jgg@nvidia.com>,
	"Will Deacon" <will@kernel.org>, "Joerg Roedel" <joro@8bytes.org>,
	"Jean-Philippe Brucker" <jpb@kernel.org>,
	"Catalin Marinas" <catalin.marinas@arm.com>,
	"Mikołaj Lenczewski" <miko.lenczewski@arm.com>,
	linux-arm-kernel@lists.infradead.org, iommu@lists.linux.dev,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iommu/arm-smmu-v3-sva: Enable Hardware Access and Hardware Dirty bits
Date: Sat, 9 May 2026 00:56:57 -0700	[thread overview]
Message-ID: <af7oyeleKFXpcIKu@nvidia.com> (raw)
In-Reply-To: <4e129891-2f52-4bac-8e33-1fdde42fd29a@arm.com>

On Fri, May 08, 2026 at 03:24:32PM +0100, Robin Murphy wrote:
> On 2026-05-08 2:57 pm, Pranjal Shrivastava wrote:
> > I see, so IIUC, you mean if IS_ENABLED(CONFIG_ARM64_HW_AFDBM) but CPU
> > doesn't enable HTTU, it is perfectly safe to let the SMMU do HTT updates,
> > Since the fault handlers are already expecting HW-triggered updates?
> > 
> > Which means our check would be something like:
> > 
> >     if (IS_ENABLED(CONFIG_ARM64_HW_AFDBM) {
> >     	if (smmu->features & FEAT_HA)
> > 	 ...
> >     }
> > 
> > instead of cpu_has_hw_af()?
> 
> Hmm, looking closer, cpu_has_hw_af() is the thing which actually influences
> mm behaviour (via arch_has_hw_pte_young and arch_wants_old_prefaulted_pte),
> and that can still be false at runtime if ARM64_HW_AFDBM is enabled but any
> CPU doesn't support HAFDBS, so perhaps you were right the first time :)

IIUIC, v2 should be:

+		/*
+		 * Enable Hardware Access and Dirty updates (DBM) if supported by
+		 * both the SMMU and the CPU. It is unsafe to enable SMMU's HTTU,
+		 * if the CPU does not support it as it bypasses mm page aging.
+		 */
+		if (cpu_has_hw_af()) {
+			if (master->smmu->features & ARM_SMMU_FEAT_HA)
+				target->data[0] |= cpu_to_le64(CTXDESC_CD_0_TCR_HA);
+			if (master->smmu->features & ARM_SMMU_FEAT_HD)
+				target->data[0] |= cpu_to_le64(CTXDESC_CD_0_TCR_HD);
+		}

Thanks
Nicolin

  reply	other threads:[~2026-05-09  7:57 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260503135413.1108138-1-nicolinc@nvidia.com>
2026-05-07 22:30 ` [PATCH] iommu/arm-smmu-v3-sva: Enable Hardware Access and Hardware Dirty bits Pranjal Shrivastava
2026-05-08 12:35   ` Jason Gunthorpe
2026-05-08 13:12     ` Pranjal Shrivastava
2026-05-08 13:27       ` Jason Gunthorpe
2026-05-08 13:31       ` Robin Murphy
2026-05-08 13:57         ` Pranjal Shrivastava
2026-05-08 14:24           ` Robin Murphy
2026-05-09  7:56             ` Nicolin Chen [this message]
2026-05-11 13:22               ` Pranjal Shrivastava
2026-05-11 13:21             ` Pranjal Shrivastava

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=af7oyeleKFXpcIKu@nvidia.com \
    --to=nicolinc@nvidia.com \
    --cc=catalin.marinas@arm.com \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@nvidia.com \
    --cc=joro@8bytes.org \
    --cc=jpb@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miko.lenczewski@arm.com \
    --cc=praan@google.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox