mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Muhammad Usama Anjum <usama.anjum@arm.com>
To: Dimitri Sivanich <dimitri.sivanich@hpe.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-kernel@vger.kernel.org
Cc: Muhammad Usama Anjum <usama.anjum@arm.com>
Subject: [PATCH 2/3] misc: sgi-gru: remove obsolete atomic fault-handling state
Date: Thu, 30 Jul 2026 12:12:51 +0100	[thread overview]
Message-ID: <20260730111316.3672672-3-usama.anjum@arm.com> (raw)
In-Reply-To: <20260730111316.3672672-1-usama.anjum@arm.com>

After interrupt faults are sent directly to user polling mode, only the
process-context call path remains. Remove the atomic flag passed through
the fault-handling interfaces and the related dead code.

No functional change.

Signed-off-by: Muhammad Usama Anjum <usama.anjum@arm.com>
---
Only build tested.
---
 drivers/misc/sgi-gru/grufault.c | 68 +++++++++++++--------------------
 1 file changed, 26 insertions(+), 42 deletions(-)

diff --git a/drivers/misc/sgi-gru/grufault.c b/drivers/misc/sgi-gru/grufault.c
index 5a87c12f444a3..e43fdea01cb6f 100644
--- a/drivers/misc/sgi-gru/grufault.c
+++ b/drivers/misc/sgi-gru/grufault.c
@@ -31,7 +31,6 @@
 /* Return codes for vtop functions */
 #define VTOP_SUCCESS               0
 #define VTOP_INVALID               -1
-#define VTOP_RETRY                 -2
 
 
 /*
@@ -188,7 +187,7 @@ static int non_atomic_pte_lookup(struct vm_area_struct *vma,
 }
 
 static int gru_vtop(struct gru_thread_state *gts, unsigned long vaddr,
-		    int write, int atomic, unsigned long *gpa, int *pageshift)
+		    int write, unsigned long *gpa, int *pageshift)
 {
 	struct mm_struct *mm = gts->ts_mm;
 	struct vm_area_struct *vma;
@@ -199,9 +198,6 @@ static int gru_vtop(struct gru_thread_state *gts, unsigned long vaddr,
 	if (!vma)
 		goto inval;
 
-	if (atomic)
-		goto upm;
-
 	/* Order the caller's ms_range_active check before loading PTEs. */
 	rmb();
 	if (non_atomic_pte_lookup(vma, vaddr, write, &paddr, &ps))
@@ -215,8 +211,6 @@ static int gru_vtop(struct gru_thread_state *gts, unsigned long vaddr,
 
 inval:
 	return VTOP_INVALID;
-upm:
-	return VTOP_RETRY;
 }
 
 
@@ -240,7 +234,7 @@ static void gru_flush_cache_cbe(struct gru_control_block_extended *cbe)
  * the end of the bcopy tranfer, whichever is smaller.
  */
 static void gru_preload_tlb(struct gru_state *gru,
-			struct gru_thread_state *gts, int atomic,
+			struct gru_thread_state *gts,
 			unsigned long fault_vaddr, int asid, int write,
 			unsigned char tlb_preload_count,
 			struct gru_tlb_fault_handle *tfh,
@@ -262,13 +256,13 @@ static void gru_preload_tlb(struct gru_state *gru,
 	vaddr = min(vaddr, fault_vaddr + tlb_preload_count * PAGE_SIZE);
 
 	while (vaddr > fault_vaddr) {
-		ret = gru_vtop(gts, vaddr, write, atomic, &gpa, &pageshift);
+		ret = gru_vtop(gts, vaddr, write, &gpa, &pageshift);
 		if (ret || tfh_write_only(tfh, gpa, GAA_RAM, vaddr, asid, write,
 					  GRU_PAGESIZE(pageshift)))
 			return;
 		gru_dbg(grudev,
-			"%s: gid %d, gts 0x%p, tfh 0x%p, vaddr 0x%lx, asid 0x%x, rw %d, ps %d, gpa 0x%lx\n",
-			atomic ? "atomic" : "non-atomic", gru->gs_gid, gts, tfh,
+			"gid %d, gts 0x%p, tfh 0x%p, vaddr 0x%lx, asid 0x%x, rw %d, ps %d, gpa 0x%lx\n",
+			gru->gs_gid, gts, tfh,
 			vaddr, asid, write, pageshift, gpa);
 		vaddr -= PAGE_SIZE;
 		STAT(tlb_preload_page);
@@ -276,13 +270,13 @@ static void gru_preload_tlb(struct gru_state *gru,
 }
 
 /*
- * Drop a TLB entry into the GRU. The fault is described by info in an TFH.
- *	Input:
- *		cb    Address of user CBR. Null if not running in user context
- * 	Return:
- * 		  0 = dropin, exception, or switch to UPM successful
- * 		  1 = range invalidate active
- * 		< 0 = error code
+ * Drop a TLB entry into the GRU. The fault is described by info in a TFH.
+ * Input:
+ *	cbk	Address of the user CBR
+ * Return:
+ *	  0 = dropin, exception, or switch to UPM successful
+ *	  1 = retry required
+ *	< 0 = error code
  *
  */
 static int gru_try_dropin(struct gru_state *gru,
@@ -292,7 +286,7 @@ static int gru_try_dropin(struct gru_state *gru,
 {
 	struct gru_control_block_extended *cbe = NULL;
 	unsigned char tlb_preload_count = gts->ts_tlb_preload_count;
-	int pageshift = 0, asid, write, ret, atomic = !cbk, indexway;
+	int pageshift = 0, asid, write, ret, indexway;
 	unsigned long gpa = 0, vaddr = 0;
 
 	/*
@@ -324,7 +318,7 @@ static int gru_try_dropin(struct gru_state *gru,
 	}
 	if (tfh->state == TFHSTATE_IDLE)
 		goto failidle;
-	if (tfh->state == TFHSTATE_MISS_FMM && cbk)
+	if (tfh->state == TFHSTATE_MISS_FMM)
 		goto failfmm;
 
 	write = (tfh->cause & TFHCAUSE_TLB_MOD) != 0;
@@ -343,22 +337,20 @@ static int gru_try_dropin(struct gru_state *gru,
 	if (atomic_read(&gts->ts_gms->ms_range_active))
 		goto failactive;
 
-	ret = gru_vtop(gts, vaddr, write, atomic, &gpa, &pageshift);
+	ret = gru_vtop(gts, vaddr, write, &gpa, &pageshift);
 	if (ret == VTOP_INVALID)
 		goto failinval;
-	if (ret == VTOP_RETRY)
-		goto failupm;
 
 	if (!(gts->ts_sizeavail & GRU_SIZEAVAIL(pageshift))) {
 		gts->ts_sizeavail |= GRU_SIZEAVAIL(pageshift);
-		if (atomic || !gru_update_cch(gts)) {
+		if (!gru_update_cch(gts)) {
 			gts->ts_force_cch_reload = 1;
 			goto failupm;
 		}
 	}
 
 	if (unlikely(cbe) && pageshift == PAGE_SHIFT) {
-		gru_preload_tlb(gru, gts, atomic, vaddr, asid, write, tlb_preload_count, tfh, cbe);
+		gru_preload_tlb(gru, gts, vaddr, asid, write, tlb_preload_count, tfh, cbe);
 		gru_flush_cache_cbe(cbe);
 	}
 
@@ -367,9 +359,9 @@ static int gru_try_dropin(struct gru_state *gru,
 	tfh_write_restart(tfh, gpa, GAA_RAM, vaddr, asid, write,
 			  GRU_PAGESIZE(pageshift));
 	gru_dbg(grudev,
-		"%s: gid %d, gts 0x%p, tfh 0x%p, vaddr 0x%lx, asid 0x%x, indexway 0x%x,"
+		"gid %d, gts 0x%p, tfh 0x%p, vaddr 0x%lx, asid 0x%x, indexway 0x%x,"
 		" rw %d, ps %d, gpa 0x%lx\n",
-		atomic ? "atomic" : "non-atomic", gru->gs_gid, gts, tfh, vaddr, asid,
+		gru->gs_gid, gts, tfh, vaddr, asid,
 		indexway, write, pageshift, gpa);
 	STAT(tlb_dropin);
 	return 0;
@@ -378,15 +370,12 @@ static int gru_try_dropin(struct gru_state *gru,
 	/* No asid (delayed unload). */
 	STAT(tlb_dropin_fail_no_asid);
 	gru_dbg(grudev, "FAILED no_asid tfh: 0x%p, vaddr 0x%lx\n", tfh, vaddr);
-	if (!cbk)
-		tfh_user_polling_mode(tfh);
-	else
-		gru_flush_cache(tfh);
+	gru_flush_cache(tfh);
 	gru_flush_cache_cbe(cbe);
 	return -EAGAIN;
 
 failupm:
-	/* Atomic failure switch CBR to UPM */
+	/* CCH update failure switches the CBR back to UPM. */
 	tfh_user_polling_mode(tfh);
 	gru_flush_cache_cbe(cbe);
 	STAT(tlb_dropin_fail_upm);
@@ -405,8 +394,7 @@ static int gru_try_dropin(struct gru_state *gru,
 	/* TFH status did not show exception pending */
 	gru_flush_cache(tfh);
 	gru_flush_cache_cbe(cbe);
-	if (cbk)
-		gru_flush_cache(cbk);
+	gru_flush_cache(cbk);
 	STAT(tlb_dropin_fail_no_exception);
 	gru_dbg(grudev, "FAILED non-exception tfh: 0x%p, status %d, state %d\n",
 		tfh, tfh->status, tfh->state);
@@ -416,14 +404,13 @@ static int gru_try_dropin(struct gru_state *gru,
 	/* TFH state was idle  - no miss pending */
 	gru_flush_cache(tfh);
 	gru_flush_cache_cbe(cbe);
-	if (cbk)
-		gru_flush_cache(cbk);
+	gru_flush_cache(cbk);
 	STAT(tlb_dropin_fail_idle);
 	gru_dbg(grudev, "FAILED idle tfh: 0x%p, state %d\n", tfh, tfh->state);
 	return 0;
 
 failinval:
-	/* All errors (atomic & non-atomic) switch CBR to EXCEPTION state */
+	/* Invalid translations switch the CBR to EXCEPTION state. */
 	tfh_exception(tfh);
 	gru_flush_cache_cbe(cbe);
 	STAT(tlb_dropin_fail_invalid);
@@ -431,11 +418,8 @@ static int gru_try_dropin(struct gru_state *gru,
 	return -EFAULT;
 
 failactive:
-	/* Range invalidate active. Switch to UPM iff atomic */
-	if (!cbk)
-		tfh_user_polling_mode(tfh);
-	else
-		gru_flush_cache(tfh);
+	/* Retry after the active range invalidation completes. */
+	gru_flush_cache(tfh);
 	gru_flush_cache_cbe(cbe);
 	STAT(tlb_dropin_fail_range_active);
 	gru_dbg(grudev, "FAILED range active: tfh 0x%p, vaddr 0x%lx\n",
-- 
2.47.3


  parent reply	other threads:[~2026-07-30 11:13 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-30 11:12 [PATCH 0/3] misc: sgi-gru: Remove broken page-table walks Muhammad Usama Anjum
2026-07-30 11:12 ` [PATCH 1/3] misc: sgi-gru: remove interrupt-context " Muhammad Usama Anjum
2026-07-30 11:12 ` Muhammad Usama Anjum [this message]
2026-07-30 11:12 ` [PATCH 3/3] misc: sgi-gru: inline the user CBR status update Muhammad Usama Anjum
2026-07-30 12:22 ` [PATCH 0/3] misc: sgi-gru: Remove broken page-table walks Dimitri Sivanich
2026-07-30 12:53   ` Muhammad Usama Anjum
2026-07-30 14:08   ` Arnd Bergmann
2026-07-31 11:32   ` Greg Kroah-Hartman
2026-07-31 13:29     ` Dimitri Sivanich
2026-07-31 13:34       ` Muhammad Usama Anjum

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=20260730111316.3672672-3-usama.anjum@arm.com \
    --to=usama.anjum@arm.com \
    --cc=arnd@arndb.de \
    --cc=dimitri.sivanich@hpe.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.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

all inboxes | Powered by JetHome®