rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Danilo Krummrich <dakr@kernel.org>
To: Rob Herring <robh@kernel.org>
Cc: "Greg KH" <greg@kroah.com>, "Danilo Krummrich" <dakr@redhat.com>,
	"Viresh Kumar" <viresh.kumar@linaro.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	"Miguel Ojeda" <miguel.ojeda.sandonis@gmail.com>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Alex Gaynor" <alex.gaynor@gmail.com>,
	"Wedson Almeida Filho" <wedsonaf@gmail.com>,
	"Boqun Feng" <boqun.feng@gmail.com>,
	"Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <benno.lossin@proton.me>,
	"Andreas Hindborg" <a.hindborg@samsung.com>,
	"Alice Ryhl" <aliceryhl@google.com>,
	linux-pm@vger.kernel.org,
	"Vincent Guittot" <vincent.guittot@linaro.org>,
	"Stephen Boyd" <sboyd@kernel.org>, "Nishanth Menon" <nm@ti.com>,
	rust-for-linux@vger.kernel.org,
	"Manos Pitsidianakis" <manos.pitsidianakis@linaro.org>,
	"Erik Schilling" <erik.schilling@linaro.org>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Joakim Bech" <joakim.bech@linaro.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH V4 8/8] cpufreq: Add Rust based cpufreq-dt driver
Date: Wed, 17 Jul 2024 00:33:30 +0200	[thread overview]
Message-ID: <Zpb1OiMj96k1kEAd@pollux> (raw)
In-Reply-To: <CAL_Jsq+OHqoo9Lxpw5GE0315dmjQPvRo60=PsJXCx=heOfmBNw@mail.gmail.com>

On Tue, Jul 16, 2024 at 09:53:15AM -0600, Rob Herring wrote:
> On Tue, Jul 16, 2024 at 9:22 AM Greg KH <greg@kroah.com> wrote:
> >
> > On Tue, Jul 16, 2024 at 05:15:25PM +0200, Danilo Krummrich wrote:
> > > On Thu, Jul 11, 2024 at 06:34:22PM +0200, Greg KH wrote:
> > > > On Thu, Jul 11, 2024 at 06:12:08PM +0200, Danilo Krummrich wrote:
> > > > > On Thu, Jul 11, 2024 at 04:37:50PM +0200, Greg KH wrote:
> > > > > > On Thu, Jul 11, 2024 at 03:21:31PM +0200, Danilo Krummrich wrote:
> > > > > > > (2) You require drivers to always implement a "dummy" struct platform_device,
> > > > > > > there is platform_device_register_simple() for that purpose.
> > > > > >
> > > > > > No, NEVER do that.  platform devices are only for real platform devices,
> > > > > > do not abuse that interface any more than it already is.
> > > > >
> > > > > I thought we're talking about cases like [1] or [2], but please correct me if
> > > > > those are considered abusing the platform bus as well.
> > > > >
> > > > > (Those drivers read the CPU OF nodes, instead of OF nodes that represent a
> > > > > separate device.)
> > > > >
> > > > > [1] https://elixir.bootlin.com/linux/latest/source/drivers/cpuidle/cpuidle-riscv-sbi.c#L586
> > > > > [2] https://elixir.bootlin.com/linux/latest/source/drivers/cpuidle/cpuidle-psci.c#L441
> > > >
> > > > Yes, these are abuses of that and should be virtual devices as they have
> > > > nothing to do with the platform bus.
> > >
> > > For those drivers, wouldn't it be better if proper devices would be derived from
> > > the CPU OF nodes directly? This seems to be a common problem for cpuidle and
> > > cpufreq drivers.
> >
> > Yes they should.
> 
> Well, which one do we bind? The cpufreq driver or cpuidle driver? Or
> there's the thermal f/w throttling as well. It's messy. Also, the CPUs
> already have a struct device associated with them for the topology
> stuff, but no driver IIRC.

I did not mean to say that they should bind to the CPU nodes compatible string,
but rather have devices populated from sub-nodes of the CPU / CPU cluster nodes
or from the SoC's 'simple-bus' or whatever makes sense for the specific HW.

Generally, I think there should be something in the DT that populates the
corresponding device, rather than having a virtual device. The device isn't
really virtual, it controls some real HW.

> 
> Another complication is it is not the CPU that determines what
> cpufreq/cpuidle drivers to use, but a platform decision. That decision
> may evolve as well which means it can't be driven from the DT.

Often it's SoC specific, but that should be fine, right? Or do you mean
something else?

> 
> > > But it's quite a while ago I dealt with such drivers, maybe there are reasons
> > > not to do so.
> >
> > I think people just got lazy :)
> 
> Virtual device was probably the right thing given there isn't directly
> any device we are controlling/programming. This driver is just built
> on top of other subsystems (clock and regulator).

The two examples I gave use a firmware interface to control the CPU's idle
state.

But even for the case you mention here, I'd still argue that the driver controls
some real hardware, just not directly. It controls the semantics and is still HW
specific.

Having a dedicated DT node also makes it easy to provide the resources, e.g.
regulators and clocks.

- Danilo

> 
> Rob
> 

      reply	other threads:[~2024-07-16 22:33 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-11  6:57 [PATCH V4 0/8] Rust bindings for cpufreq and OPP core + sample driver Viresh Kumar
2024-07-11  6:57 ` [PATCH V4 1/8] rust: Add initial bindings for OPP framework Viresh Kumar
2024-07-11  6:57 ` [PATCH V4 2/8] rust: Extend OPP bindings for the OPP table Viresh Kumar
2024-07-11  6:57 ` [PATCH V4 3/8] rust: Extend OPP bindings for the configuration options Viresh Kumar
2024-07-11  6:57 ` [PATCH V4 4/8] rust: Add initial bindings for cpufreq framework Viresh Kumar
2024-07-11  6:57 ` [PATCH V4 5/8] rust: Extend cpufreq bindings for policy and driver ops Viresh Kumar
2024-07-11  6:57 ` [PATCH V4 6/8] rust: Extend cpufreq bindings for driver registration Viresh Kumar
2024-07-11  6:57 ` [PATCH V4 7/8] rust: Extend OPP bindings with CPU frequency table Viresh Kumar
2024-07-11  6:57 ` [PATCH V4 8/8] cpufreq: Add Rust based cpufreq-dt driver Viresh Kumar
2024-07-11 10:43   ` Danilo Krummrich
2024-07-11 13:08     ` Viresh Kumar
2024-07-11 13:21       ` Danilo Krummrich
2024-07-11 14:37         ` Greg KH
2024-07-11 16:12           ` Danilo Krummrich
2024-07-11 16:34             ` Greg KH
2024-07-11 16:41               ` Greg KH
2024-07-11 17:21                 ` Greg KH
2024-07-11 17:42                   ` Danilo Krummrich
2024-07-16 15:15               ` Danilo Krummrich
2024-07-16 15:22                 ` Greg KH
2024-07-16 15:53                   ` Rob Herring
2024-07-16 22:33                     ` Danilo Krummrich [this message]

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=Zpb1OiMj96k1kEAd@pollux \
    --to=dakr@kernel.org \
    --cc=a.hindborg@samsung.com \
    --cc=alex.bennee@linaro.org \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=benno.lossin@proton.me \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=dakr@redhat.com \
    --cc=erik.schilling@linaro.org \
    --cc=gary@garyguo.net \
    --cc=greg@kroah.com \
    --cc=joakim.bech@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=manos.pitsidianakis@linaro.org \
    --cc=miguel.ojeda.sandonis@gmail.com \
    --cc=nm@ti.com \
    --cc=ojeda@kernel.org \
    --cc=rafael@kernel.org \
    --cc=robh@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=sboyd@kernel.org \
    --cc=vincent.guittot@linaro.org \
    --cc=viresh.kumar@linaro.org \
    --cc=wedsonaf@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).