linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 0/9] Apple SoC CPU P-state switching
@ 2021-10-11 16:56 Hector Martin
  2021-10-11 16:56 ` [RFC PATCH 1/9] MAINTAINERS: apple: Add apple-mcc and clk-apple-cluster paths Hector Martin
                   ` (8 more replies)
  0 siblings, 9 replies; 40+ messages in thread
From: Hector Martin @ 2021-10-11 16:56 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Hector Martin, Alyssa Rosenzweig, Sven Peter, Marc Zyngier,
	Mark Kettenis, Michael Turquette, Stephen Boyd, Rob Herring,
	Krzysztof Kozlowski, Viresh Kumar, Nishanth Menon,
	Catalin Marinas, Rafael J. Wysocki, Kevin Hilman, Ulf Hansson,
	linux-clk, devicetree, linux-pm, linux-kernel

Hi folks, here's a first attempt at cpufreq support for the Apple M1.
I'd appreciate any feedback on this approach.

The hardware in these SoCs is very simple: you just poke a single
register to change the performance state of a CPU cluster. There's
some init required on older firmware versions, but we're going to
say that's the bootloader's responsibility. This keeps the driver
nice and simple and generic and likely to work on future SoCs too.

However, there's a catch: the memory controller config should also be
modified when higher clock states are engaged on the P-cores, to
get optimal performance.

This series implements this using two drivers, on top of the existing
cpufreq-dt infrastructure. The cpu clock driver represents the p-state
switching as if it were a standard clock driver, so it can work with
cpufreq-dt. To do this, it also needs access to the OPP table, so it can
map the incoming clock frequences back to P-State index numbers, so that
is present in the binding. This might be a bit strange, since the same
OPP table is referenced by the CPUs themselves, and by the clocks driver
that provides the actual switching for them...

The memory controller stuff is implemented as a genpd provider that
exposes two performance states that the CPU OPP tables can depend on.
Unfortunately, the cpufreq path doesn't work properly for this, since
the CPUs aren't typical devices participating in runtime-pm. So instead
I opted to put that logic in the clock driver, which means it gets a
power-domains reference to the memory controller. This required a hack
to the OPP core so that it wouldn't complain about the missing parent
domain when evaluating the OPPs in the context of the CPUs...

The actual memory controller config is two magic numbers per performance
state. I'd love to find out what they do, but this seems unlikely
without docs or a deep memory performance analysis expedition... so I
think we're going to have to settle for this way, at least for now. If
things become better understood in the future, we can modify the binding
and keep the driver backwards-compatible with old DTs at least.

I did benchmark the CPU p-state switching, so the latency numbers there
have been experimentally measured. The CPU capacity numbers are also
based on real benchmarks (oddly enough, Dhrystone was a big outlier
here that was not representative of everything else, so we didn't use
it).

Patches:
 #1:   MAINTAINERS updates, split out so this can go through the SoC
       tree so we can spare all the subsystem maintainers the merge
       conflicts, since we have a bunch of other changes here going on
       in parallel.
 #2-3: DT bindings
 #4:   The aforementioned hack for the OPP core
 #5:   Add of_genpd_add_provider_simple_noclk()
 #6:   Memory controller driver
 #7:   CPU p-state clock driver
 #8:   Add some deps for ARCH_APPLE
 #9:   DT updates (for asahi-soc tree)

Hector Martin (9):
  MAINTAINERS: apple: Add apple-mcc and clk-apple-cluster paths
  dt-bindings: memory-controller: Add apple,mcc binding
  dt-bindings: clock: Add apple,cluster-clk binding
  opp: core: Don't warn if required OPP device does not exist
  PM: domains: Add of_genpd_add_provider_simple_noclk()
  memory: apple: Add apple-mcc driver to manage MCC perf in Apple SoCs
  clk: apple: Add clk-apple-cluster driver to manage CPU p-states
  arm64: apple: Select MEMORY and APPLE_MCC
  arm64: apple: Add CPU frequency scaling support for t8103

 .../bindings/clock/apple,cluster-clk.yaml     | 115 ++++++++
 .../memory-controllers/apple,mcc.yaml         |  80 ++++++
 .../opp/apple,mcc-operating-points.yaml       |  62 +++++
 MAINTAINERS                                   |   5 +
 arch/arm64/Kconfig.platforms                  |   2 +
 arch/arm64/boot/dts/apple/t8103.dtsi          | 255 +++++++++++++++++-
 drivers/base/power/domain.c                   |  39 ++-
 drivers/clk/Kconfig                           |   9 +
 drivers/clk/Makefile                          |   1 +
 drivers/clk/clk-apple-cluster.c               | 184 +++++++++++++
 drivers/memory/Kconfig                        |   9 +
 drivers/memory/Makefile                       |   1 +
 drivers/memory/apple-mcc.c                    | 130 +++++++++
 drivers/opp/core.c                            |   5 +-
 include/linux/pm_domain.h                     |   8 +
 15 files changed, 887 insertions(+), 18 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/clock/apple,cluster-clk.yaml
 create mode 100644 Documentation/devicetree/bindings/memory-controllers/apple,mcc.yaml
 create mode 100644 Documentation/devicetree/bindings/opp/apple,mcc-operating-points.yaml
 create mode 100644 drivers/clk/clk-apple-cluster.c
 create mode 100644 drivers/memory/apple-mcc.c

-- 
2.33.0


^ permalink raw reply	[flat|nested] 40+ messages in thread

end of thread, other threads:[~2021-10-19 22:44 UTC | newest]

Thread overview: 40+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-11 16:56 [RFC PATCH 0/9] Apple SoC CPU P-state switching Hector Martin
2021-10-11 16:56 ` [RFC PATCH 1/9] MAINTAINERS: apple: Add apple-mcc and clk-apple-cluster paths Hector Martin
2021-10-11 16:57 ` [RFC PATCH 2/9] dt-bindings: memory-controller: Add apple,mcc binding Hector Martin
2021-10-12  8:48   ` Krzysztof Kozlowski
2021-10-19 22:43     ` Rob Herring
2021-10-11 16:57 ` [RFC PATCH 3/9] dt-bindings: clock: Add apple,cluster-clk binding Hector Martin
2021-10-12  8:51   ` Krzysztof Kozlowski
2021-10-12  9:35     ` Viresh Kumar
     [not found]       ` <D0DE08FE-562E-4A48-BCA0-9094DAFCA564@marcan.st>
     [not found]         ` <20211012094302.3cownyzr4phxwifs@vireshk-i7>
     [not found]           ` <64584F8C-D49F-41B5-9658-CF8A25186E67@marcan.st>
     [not found]             ` <20211012095735.mhh2lzu52ohtotl6@vireshk-i7>
2021-10-12 13:48               ` Hector Martin
2021-10-11 16:57 ` [RFC PATCH 4/9] opp: core: Don't warn if required OPP device does not exist Hector Martin
2021-10-12  3:21   ` Viresh Kumar
2021-10-12  5:34     ` Hector Martin
2021-10-12  5:51       ` Viresh Kumar
2021-10-12  5:57         ` Hector Martin
2021-10-12  9:26           ` Viresh Kumar
2021-10-12  9:31             ` Hector Martin "marcan"
2021-10-12  9:32               ` Viresh Kumar
2021-10-14  6:52                 ` Hector Martin
2021-10-14  6:56                   ` Viresh Kumar
2021-10-14  7:03                     ` Hector Martin
2021-10-14  7:22                       ` Viresh Kumar
2021-10-14  7:23                       ` Hector Martin
2021-10-14 11:08                         ` Ulf Hansson
2021-10-14  9:55           ` Ulf Hansson
2021-10-14 11:43             ` Hector Martin
2021-10-14 12:55               ` Ulf Hansson
2021-10-14 17:02                 ` Hector Martin
2021-10-15 11:26                   ` Ulf Hansson
2021-10-11 16:57 ` [RFC PATCH 5/9] PM: domains: Add of_genpd_add_provider_simple_noclk() Hector Martin
2021-10-11 16:57 ` [RFC PATCH 6/9] memory: apple: Add apple-mcc driver to manage MCC perf in Apple SoCs Hector Martin
2021-10-12  9:19   ` Krzysztof Kozlowski
2021-10-14  6:59     ` Hector Martin
2021-10-14  7:36       ` Krzysztof Kozlowski
2021-10-14  7:52         ` Hector Martin
2021-10-14  8:04           ` Krzysztof Kozlowski
2021-10-14  8:31             ` Hector Martin
2021-10-11 16:57 ` [RFC PATCH 7/9] clk: apple: Add clk-apple-cluster driver to manage CPU p-states Hector Martin
     [not found]   ` <163424925931.1688384.9647104000291025081@swboyd.mtv.corp.google.com>
2021-10-17  9:16     ` Hector Martin
2021-10-11 16:57 ` [RFC PATCH 8/9] arm64: apple: Select MEMORY and APPLE_MCC Hector Martin
2021-10-11 16:57 ` [RFC PATCH 9/9] arm64: apple: Add CPU frequency scaling support for t8103 Hector Martin

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).