mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jaidev Shastri via B4 Relay <devnull+jaidevshastri.vt.edu@kernel.org>
To: Ulf Hansson <ulfh@kernel.org>,
	 Geert Uytterhoeven <geert+renesas@glider.be>,
	 Magnus Damm <magnus.damm@gmail.com>
Cc: linux-pm@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
	 linux-kernel@vger.kernel.org,
	Jaidev Shastri <jaidevshastri@vt.edu>
Subject: [PATCH] pmdomain: renesas: rcar-sysc: publish the external request mask
Date: Mon, 21 Sep 2026 21:17:55 -0400	[thread overview]
Message-ID: <20260921-mb-rcar-sysc-v1-1-fb25996bb2f4@vt.edu> (raw)

From: Jaidev Shastri <jaidevshastri@vt.edu>

rcar_sysc_pd_init() maps the SYSC registers and stores rcar_sysc_base,
rcar_sysc_extmask_offs and rcar_sysc_extmask_val with plain stores,
before it registers the power domains. rcar_sysc_power() tests
rcar_sysc_extmask_val and then writes through rcar_sysc_base at that
offset, from genpd on any CPU.

Publish the mask value last with smp_store_release() and read it once
with smp_load_acquire() in rcar_sysc_power().

Found with MBCheck, a static herd7-based memory consistency checker.

Signed-off-by: Jaidev Shastri <jaidevshastri@vt.edu>
---
 drivers/pmdomain/renesas/rcar-sysc.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/pmdomain/renesas/rcar-sysc.c b/drivers/pmdomain/renesas/rcar-sysc.c
index bd7bb9cbd..d0eaaeeb9 100644
--- a/drivers/pmdomain/renesas/rcar-sysc.c
+++ b/drivers/pmdomain/renesas/rcar-sysc.c
@@ -106,15 +106,19 @@ static int rcar_sysc_power(const struct rcar_sysc_pd *pd, bool on)
 	unsigned int chan_mask = BIT(pd->chan_bit);
 	unsigned int status, k;
 	unsigned long flags;
+	u32 extmask_val;
 	int ret;
 
 	spin_lock_irqsave(&rcar_sysc_lock, flags);
 
+	/* Pairs with the smp_store_release() in rcar_sysc_pd_init(). */
+	extmask_val = smp_load_acquire(&rcar_sysc_extmask_val);
+
 	/*
 	 * Mask external power requests for CPU or 3DG domains
 	 */
-	if (rcar_sysc_extmask_val) {
-		iowrite32(rcar_sysc_extmask_val,
+	if (extmask_val) {
+		iowrite32(extmask_val,
 			  rcar_sysc_base + rcar_sysc_extmask_offs);
 	}
 
@@ -157,7 +161,7 @@ static int rcar_sysc_power(const struct rcar_sysc_pd *pd, bool on)
 	iowrite32(isr_mask, rcar_sysc_base + SYSCISCR);
 
  out:
-	if (rcar_sysc_extmask_val)
+	if (extmask_val)
 		iowrite32(0, rcar_sysc_base + rcar_sysc_extmask_offs);
 
 	spin_unlock_irqrestore(&rcar_sysc_lock, flags);
@@ -381,7 +385,12 @@ static int __init rcar_sysc_pd_init(void)
 
 	/* Optional External Request Mask Register */
 	rcar_sysc_extmask_offs = info->extmask_offs;
-	rcar_sysc_extmask_val = info->extmask_val;
+	/*
+	 * rcar_sysc_power() tests rcar_sysc_extmask_val and then uses
+	 * rcar_sysc_base and the offset, so publish the value last, with
+	 * release semantics.
+	 */
+	smp_store_release(&rcar_sysc_extmask_val, info->extmask_val);
 
 	domains = kzalloc_obj(*domains);
 	if (!domains) {

---
base-commit: 93f51579e7df248780214094418f205253383cc5
change-id: 20260921-mb-rcar-sysc-6e76b8d94835

Best regards,
--  
Jaidev Shastri <jaidevshastri@vt.edu>



             reply	other threads:[~2026-09-22  1:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-22  1:17 Jaidev Shastri via B4 Relay [this message]
2026-09-22  9:23 ` Geert Uytterhoeven

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=20260921-mb-rcar-sysc-v1-1-fb25996bb2f4@vt.edu \
    --to=devnull+jaidevshastri.vt.edu@kernel.org \
    --cc=geert+renesas@glider.be \
    --cc=jaidevshastri@vt.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=ulfh@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®