Re: [PATCH v3 00/15] raspi: add the bcm2835 cprman clock manager

2020-10-27 Thread Peter Maydell
On Tue, 27 Oct 2020 at 08:55, Philippe Mathieu-Daudé  wrote:
>
> Hi Peter,
>
> On 10/19/20 9:31 PM, Peter Maydell wrote:
> > On Mon, 19 Oct 2020 at 16:45, Peter Maydell  
> > wrote:
> >>
> >> On Sat, 10 Oct 2020 at 14:57, Luc Michel  wrote:
> >>>
> >>> v2 -> v3:
> >>>   - patch 03: moved clock_new definition to hw/core/clock.c [Phil]
> >>>   - patch 03: commit message typo [Clement]
> >>>   - patch 10: clarifications around the CM_CTL/CM_DIBV mux registers.
> >>>   reg_cm replaced with reg_ctl and reg_div. Add some
> >>>   comments for clarity. [Phil]
> >>>   - patch 10: fixed update_mux_from_cm not matching the CM_DIV offset
> >>>   correctly. [Phil]
> >>>   - patch 11: replaced manual bitfield extraction with extract32 [Phil]
> >>>   - patch 11: added a visual representation of CM_DIV for clarity [Phil]
> >>>   - patch 11: added a missing return in clock_mux_update.
> >>
> >>
> >>
> >> Applied to target-arm.next, thanks.
> >
> > Dropped again due to segv in 'make check' when running with
> > clang sanitizer, which I gather from irc that you're looking
> > into.
>
> The fix has been merged as commit a6e9b9123e7
> ("hw/core/qdev-clock: add a reference on aliased clocks")
> and the series also got:
> Tested-by: Guenter Roeck 
>
> Hopefully it will make it for 5.2 :)



Applied to target-arm.next, thanks.

-- PMM



Re: [PATCH v3 00/15] raspi: add the bcm2835 cprman clock manager

2020-10-27 Thread Philippe Mathieu-Daudé
Hi Peter,

On 10/19/20 9:31 PM, Peter Maydell wrote:
> On Mon, 19 Oct 2020 at 16:45, Peter Maydell  wrote:
>>
>> On Sat, 10 Oct 2020 at 14:57, Luc Michel  wrote:
>>>
>>> v2 -> v3:
>>>   - patch 03: moved clock_new definition to hw/core/clock.c [Phil]
>>>   - patch 03: commit message typo [Clement]
>>>   - patch 10: clarifications around the CM_CTL/CM_DIBV mux registers.
>>>   reg_cm replaced with reg_ctl and reg_div. Add some
>>>   comments for clarity. [Phil]
>>>   - patch 10: fixed update_mux_from_cm not matching the CM_DIV offset
>>>   correctly. [Phil]
>>>   - patch 11: replaced manual bitfield extraction with extract32 [Phil]
>>>   - patch 11: added a visual representation of CM_DIV for clarity [Phil]
>>>   - patch 11: added a missing return in clock_mux_update.
>>
>>
>>
>> Applied to target-arm.next, thanks.
> 
> Dropped again due to segv in 'make check' when running with
> clang sanitizer, which I gather from irc that you're looking
> into.

The fix has been merged as commit a6e9b9123e7
("hw/core/qdev-clock: add a reference on aliased clocks")
and the series also got:
Tested-by: Guenter Roeck 

Hopefully it will make it for 5.2 :)

Thanks,

Phil.



Re: [PATCH v3 00/15] raspi: add the bcm2835 cprman clock manager

2020-10-23 Thread Philippe Mathieu-Daudé

On 10/23/20 5:55 AM, Guenter Roeck wrote:

On 10/22/20 3:06 PM, Philippe Mathieu-Daudé wrote:

Cc'ing Guenter who had a similar patch and might be interested
to test :)


I applied the series on top of qemu mainline and ran all my test with it
(raspi2 with qemu-system-arm as well as qemu-system-aarch64, and raspi3
in both big endian and little endian mode with qemu-system-aarch64.
All tests passed without error or kernel warning.


Awesome :) I'm glad we finally get this complex part implemented.

Regards,

Phil.



For the series:

Tested-by: Guenter Roeck 

Guenter




Re: [PATCH v3 00/15] raspi: add the bcm2835 cprman clock manager

2020-10-22 Thread Guenter Roeck
On 10/22/20 3:06 PM, Philippe Mathieu-Daudé wrote:
> Cc'ing Guenter who had a similar patch and might be interested
> to test :)
> 
I applied the series on top of qemu mainline and ran all my test with it
(raspi2 with qemu-system-arm as well as qemu-system-aarch64, and raspi3
in both big endian and little endian mode with qemu-system-aarch64.
All tests passed without error or kernel warning.

For the series:

Tested-by: Guenter Roeck 

Guenter

> patch 16/15 fixup:
> https://www.mail-archive.com/qemu-devel@nongnu.org/msg752113.html
> 
> On 10/10/20 3:57 PM, Luc Michel wrote:
>> v2 -> v3:
>>    - patch 03: moved clock_new definition to hw/core/clock.c [Phil]
>>    - patch 03: commit message typo [Clement]
>>    - patch 10: clarifications around the CM_CTL/CM_DIBV mux registers.
>>    reg_cm replaced with reg_ctl and reg_div. Add some
>>    comments for clarity. [Phil]
>>    - patch 10: fixed update_mux_from_cm not matching the CM_DIV offset
>>    correctly. [Phil]
>>    - patch 11: replaced manual bitfield extraction with extract32 [Phil]
>>    - patch 11: added a visual representation of CM_DIV for clarity [Phil]
>>    - patch 11: added a missing return in clock_mux_update.
>>
>> v1 -> v2:
>>    - patch 05: Added a comment about MMIO .valid constraints [Phil]
>>    - patch 05: Added MMIO .impl [Phil]
>>    - patch 05: Moved init_internal_clock to the public clock API, renamed
>>  clock_new (new patch 03) [Phil]
>>    - patch 11: use muldiv64 for clock mux frequency output computation [Phil]
>>    - patch 11: add a check for null divisor (Phil: I dropped your r-b)
>>    - Typos, formatting, naming, style [Phil]
>>
>> Patches without review: 03, 11, 13
>>
>> Hi,
>>
>> This series add the BCM2835 CPRMAN clock manager peripheral to the
>> Raspberry Pi machine.
>>
>> Patches 1-4 are preliminary changes, patches 5-13 are the actual
>> implementation.
>>
>> The two last patches add a clock input to the PL011 and
>> connect it to the CPRMAN.
>>
>> This series has been tested with Linux 5.4.61 (the current raspios
>> version). It fixes the kernel Oops at boot time due to invalid UART
>> clock value, and other warnings/errors here and there because of bad
>> clocks or lack of CPRMAN.
>>
>> Here is the clock tree as seen by Linux when booted in QEMU:
>> (/sys/kernel/debug/clk/clk_summary with some columns removed)
>>
>>  enable  prepare
>>     clock count    count  rate
>> -
>>   otg 0    0 48000
>>   osc 5    5  1920
>>  gp2  1    1 32768
>>  tsens    0    0   192
>>  otp  0    0   480
>>  timer    0    0   102
>>  pllh 4    4 86400
>>     pllh_pix_prediv   1    1   3375000
>>    pllh_pix   0    0    337500
>>     pllh_aux  1    1 21600
>>    vec    0    0 10800
>>     pllh_rcal_prediv  1    1   3375000
>>    pllh_rcal  0    0    337500
>>  plld 3    3    200024
>>     plld_dsi1 0    0   7812501
>>     plld_dsi0 0    0   7812501
>>     plld_per  3    3 50006
>>    gp1    1    1  2500
>>    uart   1    2  47999625
>>     plld_core 2    2 50006
>>    sdram  0    0 16668
>>  pllc 3    3    24
>>     pllc_per  1    1    12
>>    emmc   0    0 2
>>     pllc_core2    0    0   9375000
>>     pllc_core1    0    0   9375000
>>     pllc_core0    2    2    12
>>    vpu    1    1 7
>>   aux_spi2    0    0 7
>>   aux_spi1    0    0 7
>>   aux_uart    0    0 7
>>   peri_image  0    0 7
>>  plla 2    2    225000
>>     plla_ccp2 0    0   8789063
>>     plla_dsi0 0    0   8789063
>>     plla_core 1    1 75000
>>    h264   0    0 25000
>>    isp    0    0 25000
>>   dsi1p   0    0 0
>>   dsi0p   0    0 0
>>   dsi1e   0    0 0
>>   dsi0e   0    0 0
>>   cam1   

Re: [PATCH v3 00/15] raspi: add the bcm2835 cprman clock manager

2020-10-22 Thread Guenter Roeck
Hi,

On 10/22/20 3:06 PM, Philippe Mathieu-Daudé wrote:
> Cc'ing Guenter who had a similar patch and might be interested
> to test :)
> 

great. I think my patch doesn't work anymore since qemu 5.0 (at least not
for raspi3), and it was pretty hackish anyway. I'll give the series a try.

Guenter

> patch 16/15 fixup:
> https://www.mail-archive.com/qemu-devel@nongnu.org/msg752113.html
> 
> On 10/10/20 3:57 PM, Luc Michel wrote:
>> v2 -> v3:
>>    - patch 03: moved clock_new definition to hw/core/clock.c [Phil]
>>    - patch 03: commit message typo [Clement]
>>    - patch 10: clarifications around the CM_CTL/CM_DIBV mux registers.
>>    reg_cm replaced with reg_ctl and reg_div. Add some
>>    comments for clarity. [Phil]
>>    - patch 10: fixed update_mux_from_cm not matching the CM_DIV offset
>>    correctly. [Phil]
>>    - patch 11: replaced manual bitfield extraction with extract32 [Phil]
>>    - patch 11: added a visual representation of CM_DIV for clarity [Phil]
>>    - patch 11: added a missing return in clock_mux_update.
>>
>> v1 -> v2:
>>    - patch 05: Added a comment about MMIO .valid constraints [Phil]
>>    - patch 05: Added MMIO .impl [Phil]
>>    - patch 05: Moved init_internal_clock to the public clock API, renamed
>>  clock_new (new patch 03) [Phil]
>>    - patch 11: use muldiv64 for clock mux frequency output computation [Phil]
>>    - patch 11: add a check for null divisor (Phil: I dropped your r-b)
>>    - Typos, formatting, naming, style [Phil]
>>
>> Patches without review: 03, 11, 13
>>
>> Hi,
>>
>> This series add the BCM2835 CPRMAN clock manager peripheral to the
>> Raspberry Pi machine.
>>
>> Patches 1-4 are preliminary changes, patches 5-13 are the actual
>> implementation.
>>
>> The two last patches add a clock input to the PL011 and
>> connect it to the CPRMAN.
>>
>> This series has been tested with Linux 5.4.61 (the current raspios
>> version). It fixes the kernel Oops at boot time due to invalid UART
>> clock value, and other warnings/errors here and there because of bad
>> clocks or lack of CPRMAN.
>>
>> Here is the clock tree as seen by Linux when booted in QEMU:
>> (/sys/kernel/debug/clk/clk_summary with some columns removed)
>>
>>  enable  prepare
>>     clock count    count  rate
>> -
>>   otg 0    0 48000
>>   osc 5    5  1920
>>  gp2  1    1 32768
>>  tsens    0    0   192
>>  otp  0    0   480
>>  timer    0    0   102
>>  pllh 4    4 86400
>>     pllh_pix_prediv   1    1   3375000
>>    pllh_pix   0    0    337500
>>     pllh_aux  1    1 21600
>>    vec    0    0 10800
>>     pllh_rcal_prediv  1    1   3375000
>>    pllh_rcal  0    0    337500
>>  plld 3    3    200024
>>     plld_dsi1 0    0   7812501
>>     plld_dsi0 0    0   7812501
>>     plld_per  3    3 50006
>>    gp1    1    1  2500
>>    uart   1    2  47999625
>>     plld_core 2    2 50006
>>    sdram  0    0 16668
>>  pllc 3    3    24
>>     pllc_per  1    1    12
>>    emmc   0    0 2
>>     pllc_core2    0    0   9375000
>>     pllc_core1    0    0   9375000
>>     pllc_core0    2    2    12
>>    vpu    1    1 7
>>   aux_spi2    0    0 7
>>   aux_spi1    0    0 7
>>   aux_uart    0    0 7
>>   peri_image  0    0 7
>>  plla 2    2    225000
>>     plla_ccp2 0    0   8789063
>>     plla_dsi0 0    0   8789063
>>     plla_core 1    1 75000
>>    h264   0    0 25000
>>    isp    0    0 25000
>>   dsi1p   0    0 0
>>   dsi0p   0    0 0
>>   dsi1e   0    0 0
>>   dsi0e   0    0 0
>>   cam1    0    0 0
>>   cam0    0    0 0
>>   dpi 0    0 

Re: [PATCH v3 00/15] raspi: add the bcm2835 cprman clock manager

2020-10-22 Thread Philippe Mathieu-Daudé

Cc'ing Guenter who had a similar patch and might be interested
to test :)

patch 16/15 fixup:
https://www.mail-archive.com/qemu-devel@nongnu.org/msg752113.html

On 10/10/20 3:57 PM, Luc Michel wrote:

v2 -> v3:
   - patch 03: moved clock_new definition to hw/core/clock.c [Phil]
   - patch 03: commit message typo [Clement]
   - patch 10: clarifications around the CM_CTL/CM_DIBV mux registers.
   reg_cm replaced with reg_ctl and reg_div. Add some
   comments for clarity. [Phil]
   - patch 10: fixed update_mux_from_cm not matching the CM_DIV offset
   correctly. [Phil]
   - patch 11: replaced manual bitfield extraction with extract32 [Phil]
   - patch 11: added a visual representation of CM_DIV for clarity [Phil]
   - patch 11: added a missing return in clock_mux_update.

v1 -> v2:
   - patch 05: Added a comment about MMIO .valid constraints [Phil]
   - patch 05: Added MMIO .impl [Phil]
   - patch 05: Moved init_internal_clock to the public clock API, renamed
 clock_new (new patch 03) [Phil]
   - patch 11: use muldiv64 for clock mux frequency output computation [Phil]
   - patch 11: add a check for null divisor (Phil: I dropped your r-b)
   - Typos, formatting, naming, style [Phil]

Patches without review: 03, 11, 13

Hi,

This series add the BCM2835 CPRMAN clock manager peripheral to the
Raspberry Pi machine.

Patches 1-4 are preliminary changes, patches 5-13 are the actual
implementation.

The two last patches add a clock input to the PL011 and
connect it to the CPRMAN.

This series has been tested with Linux 5.4.61 (the current raspios
version). It fixes the kernel Oops at boot time due to invalid UART
clock value, and other warnings/errors here and there because of bad
clocks or lack of CPRMAN.

Here is the clock tree as seen by Linux when booted in QEMU:
(/sys/kernel/debug/clk/clk_summary with some columns removed)

 enable  prepare
clock countcount  rate
-
  otg 00 48000
  osc 55  1920
 gp2  11 32768
 tsens00   192
 otp  00   480
 timer00   102
 pllh 44 86400
pllh_pix_prediv   11   3375000
   pllh_pix   00337500
pllh_aux  11 21600
   vec00 10800
pllh_rcal_prediv  11   3375000
   pllh_rcal  00337500
 plld 33200024
plld_dsi1 00   7812501
plld_dsi0 00   7812501
plld_per  33 50006
   gp111  2500
   uart   12  47999625
plld_core 22 50006
   sdram  00 16668
 pllc 3324
pllc_per  1112
   emmc   00 2
pllc_core200   9375000
pllc_core100   9375000
pllc_core02212
   vpu11 7
  aux_spi200 7
  aux_spi100 7
  aux_uart00 7
  peri_image  00 7
 plla 22225000
plla_ccp2 00   8789063
plla_dsi0 00   8789063
plla_core 11 75000
   h264   00 25000
   isp00 25000
  dsi1p   00 0
  dsi0p   00 0
  dsi1e   00 0
  dsi0e   00 0
  cam100 0
  cam000 0
  dpi 00 0
  tec 00 0
  smi 00 0
  slim00 0
  gp0 00 0
  dft 00 0
  aveo00 0
  pcm 00 0
  pwm 00 0
  hsm 00   

Re: [PATCH v3 00/15] raspi: add the bcm2835 cprman clock manager

2020-10-19 Thread Peter Maydell
On Mon, 19 Oct 2020 at 16:45, Peter Maydell  wrote:
>
> On Sat, 10 Oct 2020 at 14:57, Luc Michel  wrote:
> >
> > v2 -> v3:
> >   - patch 03: moved clock_new definition to hw/core/clock.c [Phil]
> >   - patch 03: commit message typo [Clement]
> >   - patch 10: clarifications around the CM_CTL/CM_DIBV mux registers.
> >   reg_cm replaced with reg_ctl and reg_div. Add some
> >   comments for clarity. [Phil]
> >   - patch 10: fixed update_mux_from_cm not matching the CM_DIV offset
> >   correctly. [Phil]
> >   - patch 11: replaced manual bitfield extraction with extract32 [Phil]
> >   - patch 11: added a visual representation of CM_DIV for clarity [Phil]
> >   - patch 11: added a missing return in clock_mux_update.
>
>
>
> Applied to target-arm.next, thanks.

Dropped again due to segv in 'make check' when running with
clang sanitizer, which I gather from irc that you're looking
into.

thanks
-- PMM



Re: [PATCH v3 00/15] raspi: add the bcm2835 cprman clock manager

2020-10-19 Thread Peter Maydell
On Sat, 10 Oct 2020 at 14:57, Luc Michel  wrote:
>
> v2 -> v3:
>   - patch 03: moved clock_new definition to hw/core/clock.c [Phil]
>   - patch 03: commit message typo [Clement]
>   - patch 10: clarifications around the CM_CTL/CM_DIBV mux registers.
>   reg_cm replaced with reg_ctl and reg_div. Add some
>   comments for clarity. [Phil]
>   - patch 10: fixed update_mux_from_cm not matching the CM_DIV offset
>   correctly. [Phil]
>   - patch 11: replaced manual bitfield extraction with extract32 [Phil]
>   - patch 11: added a visual representation of CM_DIV for clarity [Phil]
>   - patch 11: added a missing return in clock_mux_update.



Applied to target-arm.next, thanks.

-- PMM



Re: [PATCH v3 00/15] raspi: add the bcm2835 cprman clock manager

2020-10-16 Thread Philippe Mathieu-Daudé

On 10/10/20 3:57 PM, Luc Michel wrote:
[...]

Hi,

This series add the BCM2835 CPRMAN clock manager peripheral to the
Raspberry Pi machine.


Series:
Tested-by: Philippe Mathieu-Daudé 



[PATCH v3 00/15] raspi: add the bcm2835 cprman clock manager

2020-10-10 Thread Luc Michel
v2 -> v3:
  - patch 03: moved clock_new definition to hw/core/clock.c [Phil]
  - patch 03: commit message typo [Clement]
  - patch 10: clarifications around the CM_CTL/CM_DIBV mux registers.
  reg_cm replaced with reg_ctl and reg_div. Add some
  comments for clarity. [Phil]
  - patch 10: fixed update_mux_from_cm not matching the CM_DIV offset
  correctly. [Phil]
  - patch 11: replaced manual bitfield extraction with extract32 [Phil]
  - patch 11: added a visual representation of CM_DIV for clarity [Phil]
  - patch 11: added a missing return in clock_mux_update.

v1 -> v2:
  - patch 05: Added a comment about MMIO .valid constraints [Phil]
  - patch 05: Added MMIO .impl [Phil]
  - patch 05: Moved init_internal_clock to the public clock API, renamed
clock_new (new patch 03) [Phil]
  - patch 11: use muldiv64 for clock mux frequency output computation [Phil]
  - patch 11: add a check for null divisor (Phil: I dropped your r-b)
  - Typos, formatting, naming, style [Phil]

Patches without review: 03, 11, 13

Hi,

This series add the BCM2835 CPRMAN clock manager peripheral to the
Raspberry Pi machine.

Patches 1-4 are preliminary changes, patches 5-13 are the actual
implementation.

The two last patches add a clock input to the PL011 and
connect it to the CPRMAN.

This series has been tested with Linux 5.4.61 (the current raspios
version). It fixes the kernel Oops at boot time due to invalid UART
clock value, and other warnings/errors here and there because of bad
clocks or lack of CPRMAN.

Here is the clock tree as seen by Linux when booted in QEMU:
(/sys/kernel/debug/clk/clk_summary with some columns removed)

enable  prepare  
   clock countcount  rate
-
 otg 00 48000
 osc 55  1920
gp2  11 32768
tsens00   192
otp  00   480
timer00   102
pllh 44 86400
   pllh_pix_prediv   11   3375000
  pllh_pix   00337500
   pllh_aux  11 21600
  vec00 10800
   pllh_rcal_prediv  11   3375000
  pllh_rcal  00337500
plld 33200024
   plld_dsi1 00   7812501
   plld_dsi0 00   7812501
   plld_per  33 50006
  gp111  2500
  uart   12  47999625
   plld_core 22 50006
  sdram  00 16668
pllc 3324
   pllc_per  1112
  emmc   00 2
   pllc_core200   9375000
   pllc_core100   9375000
   pllc_core02212
  vpu11 7
 aux_spi200 7
 aux_spi100 7
 aux_uart00 7
 peri_image  00 7
plla 22225000
   plla_ccp2 00   8789063
   plla_dsi0 00   8789063
   plla_core 11 75000
  h264   00 25000
  isp00 25000
 dsi1p   00 0
 dsi0p   00 0
 dsi1e   00 0
 dsi0e   00 0
 cam100 0
 cam000 0
 dpi 00 0
 tec 00 0
 smi 00 0
 slim00 0
 gp0 00 0
 dft 00 0
 aveo00 0
 pcm 00 0
 pwm 00 0
 hsm 00 0

It shows small differences with real hardware due other missing
peripherals for which the driver turn the clock off (like tsens).

Luc Michel (15):
  hw/core/clock: provide the VMSTATE_ARRAY_CLOCK macro
  hw/core/clock: trace clock values in Hz