pietrushnic / rpi-dt-linux

This repository aims to handle all patches required for Raspberry Pi support in upstream Linux kernel.
Other
2 stars 0 forks source link

bcm2835-cpufreq driver #2

Closed pietrushnic closed 9 years ago

pietrushnic commented 9 years ago

This driver doesn't work when taking it as is from Lubomir repo:

[    2.584545] cpufreq: __cpufreq_add_dev: ->get() failed
[    2.589774] bcm2835-cpufreq soc:cpufreq: Could not register cpufreq driver

I will try to dive in when I find time.

pietrushnic commented 9 years ago

@lkundrak is it something obvious that I missing ?

pietrushnic commented 9 years ago

It looks like DMA is required to make this driver work:

[    0.623977]  soc:cpufreq: no dma range information to setup
notro commented 9 years ago

It looks like DMA is required to make this driver work

Seems to be just an informational debug message about the 'dma-ranges' property: http://lxr.free-electrons.com/source/drivers/of/platform.c#L191

AFAICT DMA is not needed by the mailbox driver. get() failed seem to indicate that there is a failure reading the mailbox. Have you turned on debug output from the mailbox driver?

Do you have the return code returned from probing, or could you add a printk so we know the error code?

The call chain seems to be something like this: bcm2835_cpufreq_probe -> cpufreq_register_driver -> subsys_interface_register -> sif->add_dev: cpufreq_add_dev -> __cpufreq_add_dev -> cpufreq_driver->get: bcm2835_cpufreq_get -> bcm2835_cpufreq_get_clock -> mbox_send_message -> msg_submit -> chan->mbox->ops->send_data: bcm2835_send_data

But you can enable the DMA driver anyway as it's needed later by mmc when it's patched: DMA_BCM2835

pietrushnic commented 9 years ago

On Sat, Oct 18, 2014 at 04:40:47AM -0700, notro wrote:

AFAICT DMA is not needed by the mailbox driver. get() failed seem to indicate that there is a failure reading the mailbox. Have you turned on debug output from the mailbox driver?

Yes, by using file drivers/mailbox/bcm2835-mbox.c +p in /boot/uEnv.txt. What is strange that bcm2835-cpufreq driver message disappears when running with mbox debugging enabled. It exists when debugging is disabled.

Do you have the return code returned from probing, or could you add a printk so we know the error code?

I will try to hunt this today evening.

pietrushnic commented 9 years ago

After debugging enable in cpufreq.c:

[    0.000000] Initializing cgroup subsys cpuset
[    0.000000] Initializing cgroup subsys cpu
[    0.000000] Initializing cgroup subsys cpuacct
[    0.000000] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
[    0.000000] pcpu-alloc: [0] 0 
[    0.000000] Kernel command line: earlyprintk loglevel=8 console=ttyAMA0 verbose rootwait root=/dev/mmcblk0p2 rw debug dyndbg="module pinctrl_bcm2835 +p; file drivers/gpio/gpiolib.c +p; file drivers/of/platform.c +p; file kernel/irq/irqdomain.c +p; file kernel/irq/manage.c +p; file kernel/resource.c +p; file drivers/cpufreq/cpufreq.c +p;"
[    0.647564]    create child: /soc/cpufreq
[    0.651741]  soc:cpufreq: no dma range information to setup
[    4.386195] cpufreq: trying to register driver bcm2835-cpufreq
[    4.392041] cpufreq: adding CPU 0
[    4.395508] cpufreq: __cpufreq_add_dev: ->get() failed
[    4.400715] cpufreq: no CPU initialized for driver bcm2835-cpufreq
[    4.407141] cpufreq: __cpufreq_remove_dev_prepare: unregistering CPU 0
[    4.413673] cpufreq: __cpufreq_remove_dev_prepare: No cpu_data found
[    4.420109] bcm2835-cpufreq soc:cpufreq: Could not register cpufreq driver: -19
pietrushnic commented 9 years ago

With bcm2835-mbox debugging info:

[    4.464464] cpufreq: trying to register driver bcm2835-cpufreq
[    4.470562] cpufreq: adding CPU 0
[    4.473941] bcm2835-mbox 2000b880.mailbox: Request 0x1B63D008
[    4.479700] bcm2835-mbox 2000b880.mailbox: Reply 0x1B63D008
[    4.485382] bcm2835-mbox 2000b880.mailbox: Request 0x1B63D008
[    4.491145] bcm2835-mbox 2000b880.mailbox: Reply 0x1B63D008
[    4.496799] bcm2835-mbox 2000b880.mailbox: Request 0x1B63D008
[    4.502559] bcm2835-mbox 2000b880.mailbox: Reply 0x1B63D008
[    4.508220] bcm2835-mbox 2000b880.mailbox: Request 0x1B63D008
[    4.513981] bcm2835-mbox 2000b880.mailbox: Reply 0x1B63D008
[    4.519778] cpufreq: setting new policy for CPU 0: 700000 - 700000 kHz
[    4.526314] cpufreq: new min and max freqs are 700000 - 700000 kHz
[    4.532537] cpufreq: governor switch
[    4.536119] cpufreq: __cpufreq_governor for CPU 0, event 4
[    4.541637] cpufreq: __cpufreq_governor for CPU 0, event 1
[    4.547128] cpufreq: target for CPU 0: 700000 kHz, relation 1, requested 700000 kHz
[    4.554808] cpufreq: governor: change or update limits
[    4.559977] cpufreq: __cpufreq_governor for CPU 0, event 3
[    4.565465] cpufreq: target for CPU 0: 700000 kHz, relation 1, requested 700000 kHz
[    4.573164] cpufreq: initialization complete
[    4.577439] cpufreq: driver bcm2835-cpufreq up and running
[    4.582961] bcm2835-cpufreq soc:cpufreq: Broadcom BCM2835 CPU frequency control driver

without debugging info:

[    0.913571]  leds: no dma range information to setup
[    2.357614] bcm2835-mbox 2000b880.mailbox: mailbox enabled
[    4.387000] cpufreq: trying to register driver bcm2835-cpufreq
[    4.392846] cpufreq: adding CPU 0
[    4.396316] cpufreq: __cpufreq_add_dev: ->get() failed
[    4.401521] cpufreq: no CPU initialized for driver bcm2835-cpufreq
[    4.407950] cpufreq: __cpufreq_remove_dev_prepare: unregistering CPU 0
[    4.414483] cpufreq: __cpufreq_remove_dev_prepare: No cpu_data found
[    4.420918] bcm2835-cpufreq soc:cpufreq: Could not register cpufreq driver: -19
notro commented 9 years ago

bcm2835_cpufreq_get_clock(): print out ret and msg->request_code to determine whether the mbox call fails or the firmware returns an invalid response.

pietrushnic commented 9 years ago

I narrow down issue and will submit patch today. Although I'm not sure if it will not affect other drivers. It looks like tx_done use MAIL0_STA instead MAIL1_STA, checking mbox 1 fix the problem with cpufreq. I will send PR and wait on comments from you. BTW few people hope you will appear on IRC (freenode - #raspberrypi-kernel).

notro commented 9 years ago

BTW few people hope you will appear on IRC (freenode - #raspberrypi-kernel).

I have some drivers (fbdev) of my own that I want to work on to get included mainstream, so I stay on the sideline in this matter.

There are several competent people involved now, so I think this will turn out just fine, and in a much shorter time than I expected.