All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH for-6.2 00/25] arm: Get rid of system_clock_scale global
@ 2021-08-12  9:33 Peter Maydell
  2021-08-12  9:33 ` [PATCH for-6.2 01/25] arm: Move M-profile RAS register block into its own device Peter Maydell
                   ` (24 more replies)
  0 siblings, 25 replies; 91+ messages in thread
From: Peter Maydell @ 2021-08-12  9:33 UTC (permalink / raw)
  To: qemu-arm, qemu-devel
  Cc: Damien Hedde, Luc Michel, Alistair Francis, Subbaraya Sundeep,
	Joel Stanley, Alexandre Iooss

This is mostly a (big) refactoring to use Clocks instead of a global. 
Review of the new multiplier/divider functionality I've added to the
Clock API would also be interesting.  If you're a maintainer for an
M-profile board that isn't covered by 'make check-acceptance' then
I'd appreciate it if you have time to test that this series didn't
accidentally break your board...

The Arm v7M systick timer can run off one of two clocks
(guest-selectable by writing the SYST_CSR.CLKSOURCE control
register bit):
 * the main CPU clock
 * a separate 'reference clock' which the SoC and board may
   or may not wire up

Currently we model this as:
 * the global variable system_clock_scale is set to the period in ns
   of the CPU clock by the board or SoC level code
 * the reference clock is a fixed 1MHz, hardcoded in armv7m_systick.c

This is very old code, dating back to the first v7M support in 2007.
We now have a Clock API, so we can model clocks using something a bit
more complicat^Wsophisticated than a global variable.

The series starts with some refactoring to move the creation of
various sub-devices including the systick timers out of the nvic
object and into the 'armv7m' container object. The NVIC was doing some
of this for historical reasons, but it makes more sense to have all of
the "create subdevices and map them into the right place in the
peripheral region of the address space" be in one place. This also
means that when we start wiring Clocks up we don't have to go via the
NVIC to get from the armv7m object to the systick timers.

We then add clock inputs to the systick device, which are initially
ignored. Subsequent patches wire up those clock inputs in SoC and
board level code. Once all the boards have wired up their clocks, we
can change the systick device to use those instead of the
system_clock_scale global. Finally we can delete all the places
setting the global.

For some of the boards the systick reference clock is a fixed
multiple/division of the CPU clock. To support this, the "clock:
Provide builtin multiplier/divider" patch enhances the Clock API to
let you configure a Clock such that all its children are run at a
given ratio of the parent clock.

For the different boards I have taken a variety of approaches:
 * sometimes the refclk frequency was easy to determine from
   the SoC docs, and the patches implement that, changing the
   behaviour from the old 1MHz fixed refclk. This is in
   effect a very minor bugfix.
 * in a few cases I couldn't determine the refclk frequency, so
   I have implemented those boards to retain the old 1MHz
   value, as at least no-behavioural-change
 * some SoCs don't wire up the refclk at all; with this series
   we will correctly implement that (the SYST_CSR.CLKSOURCE control
   register bit in the systick device is then read-only), so
   again a minor bugfix
In some SoCs the refclk should theoretically be guest-programmable; we
didn't implement that before and we still don't. I've put in a few
comments noting this missing feature where relevant.

The other user of the system_clock_scale global is the GPTM timer in
the stellaris board, so there's a patch converting that to also use
Clock input.

There are also a few patches implementing minor cleanups I noticed
along the way that I felt would be in the way if I didn't fix them up
first.

NB: this series is a migration compat break for all the M-profile
boards, because it adds Clock objects to vmstate structs.

I've tested this with 'make check-acceptance', which tests the
emcraft-sf2 board, and I've run some stellaris and various MPS images
I have locally.  Other affected boards (microbit, netduino2,
netduinoplus2, stm32vldiscovery) are untested (though 'make check'
confirms that they at least don't crash on startup...).  Testing from
maintainers of those boards would be appreciated.

thanks
-- PMM

Peter Maydell (25):
  arm: Move M-profile RAS register block into its own device
  arm: Move systick device creation from NVIC to ARMv7M object
  arm: Move system PPB container handling to armv7m
  hw/timer/armv7m_systick: Add usual QEMU interface comment
  hw/timer/armv7m_systick: Add input clocks
  hw/arm/armv7m: Create input clocks
  armsse: Wire up systick cpuclk clock
  hw/arm/mps2.c: Connect up armv7m clocks
  clock: Provide builtin multiplier/divider
  hw/arm: Don't allocate separate MemoryRegions in stm32 SoC realize
  hw/arm/stm32f100: Wire up sysclk and refclk
  hw/arm/stm32f205: Wire up sysclk and refclk
  hw/arm/stm32f405: Wire up sysclk and refclk
  hw/arm/stm32vldiscovery: Delete trailing blank line
  hw/arm/nrf51: Wire up sysclk
  hw/arm/stellaris: split stellaris_sys_init()
  hw/arm/stellaris: Wire sysclk up to armv7m
  hw/arm/msf2_soc: Don't allocate separate MemoryRegions
  hw/arm/msf2: Use Clock input to MSF2_SOC instead of m3clk property
  hw/arm/msf2-soc: Wire up refclk
  hw/timer/armv7m_systick: Use clock inputs instead of
    system_clock_scale
  hw/arm/stellaris: Fix code style issues in GPTM code
  hw/arm/stellaris: Split stellaris-gptm into its own file
  hw/timer/stellaris-gptm: Use Clock input instead of system_clock_scale
  arm: Remove system_clock_scale global

 docs/devel/clocks.rst             |  23 ++
 include/hw/arm/armv7m.h           |  24 ++
 include/hw/arm/msf2-soc.h         |   8 +-
 include/hw/arm/nrf51_soc.h        |   2 +
 include/hw/arm/stm32f100_soc.h    |   8 +
 include/hw/arm/stm32f205_soc.h    |   8 +
 include/hw/arm/stm32f405_soc.h    |   3 +
 include/hw/clock.h                |  29 +++
 include/hw/intc/armv7m_nvic.h     |   8 -
 include/hw/misc/armv7m_ras.h      |  37 +++
 include/hw/timer/armv7m_systick.h |  36 ++-
 include/hw/timer/stellaris-gptm.h |  51 ++++
 hw/arm/armsse.c                   |  20 +-
 hw/arm/armv7m.c                   | 260 +++++++++++++++++++-
 hw/arm/mps2.c                     |  17 +-
 hw/arm/msf2-soc.c                 |  68 +++--
 hw/arm/msf2-som.c                 |   7 +-
 hw/arm/netduino2.c                |  12 +-
 hw/arm/netduinoplus2.c            |  12 +-
 hw/arm/nrf51_soc.c                |  20 +-
 hw/arm/stellaris.c                | 396 ++++--------------------------
 hw/arm/stm32f100_soc.c            |  47 +++-
 hw/arm/stm32f205_soc.c            |  47 +++-
 hw/arm/stm32f405_soc.c            |  30 +++
 hw/arm/stm32vldiscovery.c         |  13 +-
 hw/core/clock-vmstate.c           |  24 +-
 hw/core/clock.c                   |  29 ++-
 hw/intc/armv7m_nvic.c             | 274 +--------------------
 hw/misc/armv7m_ras.c              |  93 +++++++
 hw/timer/armv7m_systick.c         | 116 ++++++---
 hw/timer/stellaris-gptm.c         | 332 +++++++++++++++++++++++++
 MAINTAINERS                       |   2 +
 hw/arm/Kconfig                    |   1 +
 hw/misc/meson.build               |   2 +
 hw/timer/Kconfig                  |   3 +
 hw/timer/meson.build              |   1 +
 36 files changed, 1292 insertions(+), 771 deletions(-)
 create mode 100644 include/hw/misc/armv7m_ras.h
 create mode 100644 include/hw/timer/stellaris-gptm.h
 create mode 100644 hw/misc/armv7m_ras.c
 create mode 100644 hw/timer/stellaris-gptm.c

-- 
2.20.1



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

end of thread, other threads:[~2021-08-18 12:06 UTC | newest]

Thread overview: 91+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-12  9:33 [PATCH for-6.2 00/25] arm: Get rid of system_clock_scale global Peter Maydell
2021-08-12  9:33 ` [PATCH for-6.2 01/25] arm: Move M-profile RAS register block into its own device Peter Maydell
2021-08-12 11:08   ` Alexandre IOOSS
2021-08-12 11:09     ` Peter Maydell
2021-08-13  0:59   ` Alistair Francis
2021-08-15 17:30   ` Philippe Mathieu-Daudé
2021-08-16  7:28     ` David Hildenbrand
2021-08-16  9:16     ` Peter Maydell
2021-08-17  8:25   ` Luc Michel
2021-08-17 10:10     ` Damien Hedde
2021-08-12  9:33 ` [PATCH for-6.2 02/25] arm: Move systick device creation from NVIC to ARMv7M object Peter Maydell
2021-08-13  1:23   ` Alistair Francis
2021-08-17  9:24   ` Luc Michel
2021-08-12  9:33 ` [PATCH for-6.2 03/25] arm: Move system PPB container handling to armv7m Peter Maydell
2021-08-12 11:56   ` Alexandre IOOSS
2021-08-17  9:25   ` Luc Michel
2021-08-12  9:33 ` [PATCH for-6.2 04/25] hw/timer/armv7m_systick: Add usual QEMU interface comment Peter Maydell
2021-08-13  1:26   ` Alistair Francis
2021-08-17  9:29   ` Luc Michel
2021-08-12  9:33 ` [PATCH for-6.2 05/25] hw/timer/armv7m_systick: Add input clocks Peter Maydell
2021-08-13  1:27   ` Alistair Francis
2021-08-17  9:32   ` Luc Michel
2021-08-12  9:33 ` [PATCH for-6.2 06/25] hw/arm/armv7m: Create " Peter Maydell
2021-08-13  1:28   ` Alistair Francis
2021-08-17  9:34   ` Luc Michel
2021-08-12  9:33 ` [PATCH for-6.2 07/25] armsse: Wire up systick cpuclk clock Peter Maydell
2021-08-13  1:29   ` Alistair Francis
2021-08-17  9:36   ` Luc Michel
2021-08-12  9:33 ` [PATCH for-6.2 08/25] hw/arm/mps2.c: Connect up armv7m clocks Peter Maydell
2021-08-17  9:39   ` Luc Michel
2021-08-12  9:33 ` [PATCH for-6.2 09/25] clock: Provide builtin multiplier/divider Peter Maydell
2021-08-12 12:08   ` Alexandre IOOSS
2021-08-12 12:22     ` Peter Maydell
2021-08-13  1:33   ` Alistair Francis
2021-08-15 16:32   ` Philippe Mathieu-Daudé
2021-08-16  9:05     ` Peter Maydell
2021-08-16  9:32       ` Philippe Mathieu-Daudé
2021-08-16  9:36         ` Peter Maydell
2021-08-16  9:58           ` Philippe Mathieu-Daudé
2021-08-15 21:27   ` Luc Michel
2021-08-17  9:59   ` Damien Hedde
2021-08-17 10:46     ` Peter Maydell
2021-08-17 14:58       ` Damien Hedde
2021-08-12  9:33 ` [PATCH for-6.2 10/25] hw/arm: Don't allocate separate MemoryRegions in stm32 SoC realize Peter Maydell
2021-08-12 12:13   ` Alexandre IOOSS
2021-08-12 12:27     ` Peter Maydell
2021-08-15 16:37       ` Philippe Mathieu-Daudé
2021-08-13  1:34   ` Alistair Francis
2021-08-17  9:41   ` Luc Michel
2021-08-12  9:33 ` [PATCH for-6.2 11/25] hw/arm/stm32f100: Wire up sysclk and refclk Peter Maydell
2021-08-13  1:36   ` Alistair Francis
2021-08-14  9:01   ` Alexandre IOOSS
2021-08-17  9:45   ` Luc Michel
2021-08-12  9:33 ` [PATCH for-6.2 12/25] hw/arm/stm32f205: " Peter Maydell
2021-08-13  1:38   ` Alistair Francis
2021-08-14  9:02   ` Alexandre IOOSS
2021-08-17  9:47   ` Luc Michel
2021-08-12  9:33 ` [PATCH for-6.2 13/25] hw/arm/stm32f405: " Peter Maydell
2021-08-13  1:37   ` Alistair Francis
2021-08-14  9:03   ` Alexandre IOOSS
2021-08-17  9:47   ` Luc Michel
2021-08-12  9:33 ` [PATCH for-6.2 14/25] hw/arm/stm32vldiscovery: Delete trailing blank line Peter Maydell
2021-08-12 12:27   ` Alexandre IOOSS
2021-08-13  1:39   ` Alistair Francis
2021-08-17  9:48   ` Luc Michel
2021-08-12  9:33 ` [PATCH for-6.2 15/25] hw/arm/nrf51: Wire up sysclk Peter Maydell
2021-08-14  9:06   ` Alexandre IOOSS
2021-08-12  9:33 ` [PATCH for-6.2 16/25] hw/arm/stellaris: split stellaris_sys_init() Peter Maydell
2021-08-14  9:10   ` Alexandre IOOSS
2021-08-12  9:33 ` [PATCH for-6.2 17/25] hw/arm/stellaris: Wire sysclk up to armv7m Peter Maydell
2021-08-14  9:12   ` Alexandre IOOSS
2021-08-12  9:33 ` [PATCH for-6.2 18/25] hw/arm/msf2_soc: Don't allocate separate MemoryRegions Peter Maydell
2021-08-14  9:13   ` Alexandre IOOSS
2021-08-12  9:33 ` [PATCH for-6.2 19/25] hw/arm/msf2: Use Clock input to MSF2_SOC instead of m3clk property Peter Maydell
2021-08-14  9:20   ` Alexandre IOOSS
2021-08-14 10:11     ` Peter Maydell
2021-08-14 10:47       ` Alexandre IOOSS
2021-08-12  9:33 ` [PATCH for-6.2 20/25] hw/arm/msf2-soc: Wire up refclk Peter Maydell
2021-08-17 15:05   ` Damien Hedde
2021-08-12  9:33 ` [PATCH for-6.2 21/25] hw/timer/armv7m_systick: Use clock inputs instead of system_clock_scale Peter Maydell
2021-08-17 15:55   ` Damien Hedde
2021-08-17 15:59     ` Peter Maydell
2021-08-17 16:14       ` Damien Hedde
2021-08-12  9:33 ` [PATCH for-6.2 22/25] hw/arm/stellaris: Fix code style issues in GPTM code Peter Maydell
2021-08-14  9:26   ` Alexandre IOOSS
2021-08-12  9:33 ` [PATCH for-6.2 23/25] hw/arm/stellaris: Split stellaris-gptm into its own file Peter Maydell
2021-08-17 15:59   ` Damien Hedde
2021-08-12  9:33 ` [PATCH for-6.2 24/25] hw/timer/stellaris-gptm: Use Clock input instead of system_clock_scale Peter Maydell
2021-08-18 12:03   ` Damien Hedde
2021-08-12  9:33 ` [PATCH for-6.2 25/25] arm: Remove system_clock_scale global Peter Maydell
2021-08-13  5:08   ` Alistair Francis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.