[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aQMUu08phVPqfgEB@stanley.mountain>
Date: Thu, 30 Oct 2025 10:33:15 +0300
From: Dan Carpenter <dan.carpenter@...aro.org>
To: Arnd Bergmann <arnd@...db.de>
Cc: Lee Jones <lee@...nel.org>, Conor Dooley <conor+dt@...nel.org>,
	devicetree@...r.kernel.org,
	Krzysztof Kozlowski <krzk+dt@...nel.org>,
	linux-kernel@...r.kernel.org, Rob Herring <robh@...nel.org>,
	André Draszik <andre.draszik@...aro.org>,
	Peter Griffin <peter.griffin@...aro.org>
Subject: Re: [PATCH 0/2] mfd: syscon: introduce no-auto-mmio DT property
On Wed, Oct 29, 2025 at 08:43:33PM +0100, Arnd Bergmann wrote:
> On Wed, Oct 29, 2025, at 18:27, Dan Carpenter wrote:
> > Most syscons are accessed via MMMIO and created automatically.  But one
> > example of a syscon that isn't is in drivers/soc/samsung/exynos-pmu.c
> > where the syscon can only be accessed via the secure partition.  We are
> > looking at upstreaming a different driver where the syscon will be
> > accessed via SCMI.
> >
> > Normally, syscons are accessed by doing something like
> > syscon_regmap_lookup_by_phandle_args() but that function will
> > automatically create an MMIO syscon if one hasn't been registered.  So
> > the ordering becomes a problem.  The exynos-pmu.c driver solves this
> > but it's a bit awkward and it would be even trickier if there were
> > several drivers accessing the same syscon.
> 
> What would happen on the current exynos platform if we just take away
> the 'regs' property? I would hope that we can avoid encoding what
> is essentially operating system policy in that driver and instead
> just describe it as a device that expects to be implemented by
> firmware and doesn't need registers?
Exynos solves this because they only have one phandle so when they parse
it, that's when then they create the syscon.  If you had multiple drivers
accessing the same syscon then that doesn't work.
If we left out the "regs" property it wouldn't be created automatically
but syscon_regmap_lookup_by_phandle() will return -EINVAL and probe would
fail.  It needs to be -EPROBE_DEFER so the probe tries again after the
regmap is registered.  We'd need to add a check like this (untested):
I can test this probably later today when the test system is back.
regards,
dan carpenter
diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
index ae71a2710bed..41da49a0c767 100644
--- a/drivers/mfd/syscon.c
+++ b/drivers/mfd/syscon.c
@@ -51,6 +51,9 @@ static struct syscon *of_syscon_register(struct device_node *np, bool check_res)
 
 	WARN_ON(!mutex_is_locked(&syscon_list_lock));
 
+	if (!of_find_property(np, "regs", NULL))
+		return ERR_PTR(-EPROBE_DEFER);
+
 	struct syscon *syscon __free(kfree) = kzalloc(sizeof(*syscon), GFP_KERNEL);
 	if (!syscon)
 		return ERR_PTR(-ENOMEM);
Powered by blists - more mailing lists
 
