public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: Arnd Bergmann <arnd@arndb.de>,
	John Madieu <john.madieu.xa@bp.renesas.com>,
	Chen-Yu Tsai <wens@kernel.org>
Cc: "Lee Jones" <lee@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	devicetree@vger.kernel.org,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	linux-kernel@vger.kernel.org, "Rob Herring" <robh@kernel.org>,
	"André Draszik" <andre.draszik@linaro.org>,
	"Peter Griffin" <peter.griffin@linaro.org>
Subject: Re: [PATCH 0/2] mfd: syscon: introduce no-auto-mmio DT property
Date: Thu, 30 Oct 2025 15:39:12 +0300	[thread overview]
Message-ID: <aQNccP-lHqgygmsu@stanley.mountain> (raw)
In-Reply-To: <dbd5558a-90d9-404c-ae98-a8c04cdad08a@app.fastmail.com>

On Thu, Oct 30, 2025 at 09:33:39AM +0100, Arnd Bergmann wrote:
> On Thu, Oct 30, 2025, at 08:33, Dan Carpenter wrote:
> > 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.
> 
> I'm not following the logic here.  Do you mean that they avoid the
> issue today by ensuring that the regmap is always probed before
> its only user, or do you mean something else?
> 
> > 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):
> 
> Right, this is exactly what I had in mind. With a new kernel and old
> dtb, this would not change anything, while an old kernel but new dtb
> would run into a different bug and fail to probe instead of using the
> wrong device. I think both cases are fine.
> 
>      Arnd

Actually, probably the right thing to do is to leave out the "syscon"
compatible.  That's what the drivers/soc/sunxi/sunxi_sram.c driver does.
There is still an ordering issue where the sunxi_sram SoC driver needs
to be probed first or the stmmac driver probe will fail.  There is probably
some kind of way that SoC drivers are always probed earlier?

Beside the exynos driver the only other place that calls
of_syscon_register_regmap() is drivers/soc/renesas/rz-sysc.c but I don't
think that syscon has any users yet.

regards,
dan carpenter

  parent reply	other threads:[~2025-10-30 12:39 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-29 17:27 [PATCH 0/2] mfd: syscon: introduce no-auto-mmio DT property Dan Carpenter
2025-10-29 17:27 ` [PATCH 1/2] dt-bindings: mfd: syscon: introduce no-auto-mmio property for syscons Dan Carpenter
2025-10-29 17:33   ` Conor Dooley
2025-10-29 17:41     ` Dan Carpenter
2025-10-29 18:37       ` Conor Dooley
2025-10-29 18:47         ` Dan Carpenter
2025-10-29 22:00           ` Conor Dooley
2025-10-30  8:20           ` Krzysztof Kozlowski
2025-10-30 18:16   ` Rob Herring
2025-10-29 19:43 ` [PATCH 0/2] mfd: syscon: introduce no-auto-mmio DT property Arnd Bergmann
2025-10-30  7:33   ` Dan Carpenter
2025-10-30  8:33     ` Arnd Bergmann
2025-10-30  8:49       ` Dan Carpenter
2025-10-30 12:39       ` Dan Carpenter [this message]
2025-10-30 12:50         ` Chen-Yu Tsai
2025-10-30 13:09           ` Dan Carpenter
2025-10-30 14:10             ` Arnd Bergmann
2025-10-30 14:39             ` Chen-Yu Tsai
2025-10-30 18:21             ` Rob Herring
2025-10-30 12:59         ` Peter Griffin

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=aQNccP-lHqgygmsu@stanley.mountain \
    --to=dan.carpenter@linaro.org \
    --cc=andre.draszik@linaro.org \
    --cc=arnd@arndb.de \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=john.madieu.xa@bp.renesas.com \
    --cc=krzk+dt@kernel.org \
    --cc=lee@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peter.griffin@linaro.org \
    --cc=robh@kernel.org \
    --cc=wens@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