Message ID | F7A2533A-D64C-4187-ABD4-416C446D1637@martin.sperl.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
> On 12.02.2016, at 18:34, Martin Sperl <kernel@martin.sperl.org> wrote: > > The screen is still blinking and UART does not work. > Maybe the driver is not able to handle the “remapping” > of registers to a different range and is touching ram > used by the FW? > > The only solution that I found is using fixed clocks > in the device-tree (which is not what we intended: > / { > clk_uart0: clock@3 { > compatible = "fixed-clock"; > reg = <3>; > #clock-cells = <0>; > clock-output-names = "uart0_pclk"; > clock-frequency = <3000000>; > }; > > clk_apb_p: clock@4 { > compatible = "fixed-clock"; > reg = <4>; > #clock-cells = <0>; > clock-output-names = "apb_pclk"; > clock-frequency = <126000000>; > }; > }; > &uart0 { > clocks = <&clk_uart0 &clk_apb_p>; > }; > > (so I have ruled out that the amba-pl011 writes to > the wrong addresses). > > So as far as I can tell it is only clock related > and when the new clock-framework is used it fails... So the issue is triggered as soon as the plld_per pll divider gets disabled/reenabled. This happens because the clk_hw.core.prepare_count drops down to 0 and then unprepare is called. So we need to increase the ref-count for the pll and pll_dividers to at least 1 so that these never get disabled - at least for now until we can come up with a better contract with the firmware. Obviously this may impact other drivers as well where a pll is used for the first time - if nothing else uses it and the clock gets released, then the clock would trigger a unprepare of the whole branch of the clock tree. The question is: how can we solve it in an acceptable manner? Do we need a driver that just holds a reference to those clocks? Or should we just prepare the clock after registering it in clk-bcm2835.c? As for why does this not show up when compiled in? It seems that in that case the amba_pl011 driver never gets removed and then probed again. This is possibly related to the optional use of DMA, with the amba-pl011 driver that retries the install, which is not supported on the bcm2835 - at least that is what the datasheet says. And DMA is (probably) not enabled during the early boot stages, so it does not fail once when it tries to register DMA. Thanks, Martin
> On 13.02.2016, at 11:01, Stefan Wahren <stefan.wahren@i2se.com> wrote: > diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c > index 637f8ae..03d95c1 100644 > --- a/drivers/clk/bcm/clk-bcm2835.c > +++ b/drivers/clk/bcm/clk-bcm2835.c > @@ -1638,6 +1675,9 @@ static int bcm2835_clock_set_rate(struct clk_hw *hw, > enum bcm2835_clock_mash_type mash = divmash_get_mash(dm); > u32 ctl; > > + if (cprman_read(cprman, data->ctl_reg) & CM_BUSY) > + pr_warn("%s: clk still busy from %d\n", __func__, cprman->func_code); > + > spin_lock(&cprman->regs_lock); > > /* if div and mash are identical, then there is nothing to do */ > @@ -1663,6 +1703,11 @@ static int bcm2835_clock_set_rate(struct clk_hw *hw, > unlock_exit: > spin_unlock(&cprman->regs_lock); > > + cprman->func_code = 10; > + > + if (cprman_read(cprman, data->ctl_reg) & CM_BUSY) > + pr_warn("%s: clk now busy from %d\n", __func__, cprman->func_code); > + > return 0; > } > Seems as if you apply it on top of (parts of) my patchset - not on top of a clean 4.5-rc3. Anyway - after some fixing I get the following outputs - the amba-pl011 driver is still patched with debug messages: After boot with aux-uart as tty: root@raspcm:~# dmesg | grep bcm2835 [ 0.018172] bcm2835: system timer (irq = 27) [ 0.711388] bcm2835-aux-uart 20215040.serial: could not get clk: -517 [ 1.649124] bcm2835-rng 20104000.rng: hwrng registered [ 2.051190] bcm2835_clock_on: clk still busy from 6 [ 2.056159] bcm2835_clock_on: clk now busy from 9 [ 8.062743] bcm2835-wdt 20100000.watchdog: Broadcom BCM2835 watchdog timer [ 12.042105] bcm2835-i2s 20203000.i2s: can't request region for resource [mem 0x20101098-0x20101099] [ 12.191701] bcm2835-i2s: probe of 20203000.i2s failed with error -16 Loading the module: root@raspcm:~# modprobe amba-pl011 [ 106.685812] Serial: AMBA PL011 UART driver [ 106.693702] uart-pl011 20201000.uart: pl011_setup_port: f0201000 20201000 [ 106.702109] 20201000.uart: ttyAMA0 at MMIO 0x20201000 (irq = 81, base_baud = 0) is a PL011 rev2 root@raspcm:~# and starting getty: root@raspcm:~# /sbin/getty -a root -L ttyAMA0 115200 vt100 [ 137.851123] pl011_startup - start [ 137.854538] pl011_hwinit - prepare-enable [ 137.858772] bcm2835_clock_on: clk still busy from 6 [ 137.863755] bcm2835_clock_on: clk now busy from 9 [ 137.868590] pl011_hwinit - prepare-enable - ret = 0 [ 137.875249] uart-pl011 20201000.uart: no DMA platform data [ 137.880940] pl011_startup - exit [ 137.888840] pl011_shutdown - start [ 137.892360] pl011_shutdown - disable_unprepare [ 137.896933] bcm2835_clock_off: clk still busy from 9 [ 137.902112] pl011_shutdown - exit [ 137.907233] pl011_startup - start [ 137.910713] pl011_hwinit - prepare-enable [ 137.914808] bcm2835_pll_on: PLL still locked from 1 [ 138.019876] bcm2835-clk 20101000.cprman: plld: couldn't lock PLL [ 138.026000] pl011_hwinit - prepare-enable - ret = -110 [ 138.031266] pl011_startup - error = -110 - disable_unprepare [ 138.037048] ------------[ cut here ]------------ [ 138.041777] WARNING: CPU: 0 PID: 2377 at drivers/clk/clk.c:680 clk_core_disable+0x34/0xf0() [ 138.051063] ---[ end trace dd2f225b2af4c32c ]--- [ 138.055859] ------------[ cut here ]------------ [ 138.060627] WARNING: CPU: 0 PID: 2377 at drivers/clk/clk.c:575 clk_core_unprepare+0x34/0x110() [ 138.070321] ---[ end trace dd2f225b2af4c32d ]--- No HDMI output - this time no “flashing” - just no signal. Machine is crashed - the attached AXIS USB network card (0b95:772b) just transmits identical packets on the network without stopping… I have also disabled the DMA-engine in the amba-pl011 driver (in the driver itself add: #undef CONFIG_DMA_ENGINE) and then I get: root@raspcm:/build/linux# /sbin/getty -a root -L ttyAMA0 115200 vt100 [ 97.010287] pl011_startup - start [ 97.013698] pl011_hwinit - prepare-enable [ 97.017931] bcm2835_clock_on: clk still busy from 6 [ 97.022905] bcm2835_clock_on: clk now busy from 9 [ 97.027755] pl011_hwinit - prepare-enable - ret = 0 [ 97.034378] pl011_startup - exit [ 97.041197] pl011_shutdown - start [ 97.044728] pl011_shutdown - disable_unprepare [ 97.049386] bcm2835_clock_off: clk still busy from 9 [ 97.054458] pl011_shutdown - exit [ 97.059633] pl011_startup - start [ 97.063033] pl011_hwinit - prepare-enable [ 97.067533] bcm2835_pll_on: PLL still locked from 1 [ 97.172655] bcm2835-clk 20101000.cprman: plld: couldn't lock PLL [ 97.178838] pl011_hwinit - prepare-enable - ret = -110 [ 97.184075] pl011_startup - error = -110 - disable_unprepare [ 97.189905] ------------[ cut here ]------------ [ 97.194640] WARNING: CPU: 0 PID: 2442 at drivers/clk/clk.c:680 clk_core_disab le+0x34/0xf0() [ 97.203924] ---[ end trace 3e878f70606eba69 ]--- [ 97.208692] ------------[ cut here ]------------ [ 97.213429] WARNING: CPU: 0 PID: 2442 at drivers/clk/clk.c:575 clk_core_unpre pare+0x34/0x110() [ 97.223096] ---[ end trace 3e878f70606eba6a ]— Not sure why the pl011 driver runs the startup/shutdown/startup loop. Martin
Hi Martin, > Martin Sperl <kernel@martin.sperl.org> hat am 13. Februar 2016 um 12:53 > geschrieben: > > > Seems as if you apply it on top of (parts of) my patchset - not on top of a > clean 4.5-rc3. sorry about that. I took the wrong directory. > > Anyway - after some fixing I get the following outputs - > the amba-pl011 driver is still patched with debug messages: > > After boot with aux-uart as tty: > root@raspcm:~# dmesg | grep bcm2835 > [ 0.018172] bcm2835: system timer (irq = 27) > [ 0.711388] bcm2835-aux-uart 20215040.serial: could not get clk: -517 > [ 1.649124] bcm2835-rng 20104000.rng: hwrng registered > [ 2.051190] bcm2835_clock_on: clk still busy from 6 > [ 2.056159] bcm2835_clock_on: clk now busy from 9 I get the same output here. It belongs to mmc clock. > [ 8.062743] bcm2835-wdt 20100000.watchdog: Broadcom BCM2835 watchdog timer > [ 12.042105] bcm2835-i2s 20203000.i2s: can't request region for resource [mem > 0x20101098-0x20101099] > [ 12.191701] bcm2835-i2s: probe of 20203000.i2s failed with error -16 > > Loading the module: > root@raspcm:~# modprobe amba-pl011 > [ 106.685812] Serial: AMBA PL011 UART driver > [ 106.693702] uart-pl011 20201000.uart: pl011_setup_port: f0201000 20201000 > [ 106.702109] 20201000.uart: ttyAMA0 at MMIO 0x20201000 (irq = 81, base_baud = > 0) is a PL011 rev2 > root@raspcm:~# > > and starting getty: > root@raspcm:~# /sbin/getty -a root -L ttyAMA0 115200 vt100 > [ 137.851123] pl011_startup - start > [ 137.854538] pl011_hwinit - prepare-enable > [ 137.858772] bcm2835_clock_on: clk still busy from 6 > [ 137.863755] bcm2835_clock_on: clk now busy from 9 > [ 137.868590] pl011_hwinit - prepare-enable - ret = 0 > [ 137.875249] uart-pl011 20201000.uart: no DMA platform data > [ 137.880940] pl011_startup - exit > [ 137.888840] pl011_shutdown - start > [ 137.892360] pl011_shutdown - disable_unprepare > [ 137.896933] bcm2835_clock_off: clk still busy from 9 > [ 137.902112] pl011_shutdown - exit > [ 137.907233] pl011_startup - start > [ 137.910713] pl011_hwinit - prepare-enable > [ 137.914808] bcm2835_pll_on: PLL still locked from 1 > [ 138.019876] bcm2835-clk 20101000.cprman: plld: couldn't lock PLL > [ 138.026000] pl011_hwinit - prepare-enable - ret = -110 > [ 138.031266] pl011_startup - error = -110 - disable_unprepare > [ 138.037048] ------------[ cut here ]------------ > [ 138.041777] WARNING: CPU: 0 PID: 2377 at drivers/clk/clk.c:680 > clk_core_disable+0x34/0xf0() > [ 138.051063] ---[ end trace dd2f225b2af4c32c ]--- > [ 138.055859] ------------[ cut here ]------------ > [ 138.060627] WARNING: CPU: 0 PID: 2377 at drivers/clk/clk.c:575 > clk_core_unprepare+0x34/0x110() > [ 138.070321] ---[ end trace dd2f225b2af4c32d ]--- > > No HDMI output - this time no “flashing” - just no signal. > Machine is crashed - the attached AXIS USB network card (0b95:772b) > just transmits identical packets on the network without stopping… > According to the datasheet busy bit shouldn't be set while changing the clock. So this isn't good. I hope this could be fixed, too. Regards >
diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c index 015e687..4856657 100644 --- a/drivers/clk/bcm/clk-bcm2835.c +++ b/drivers/clk/bcm/clk-bcm2835.c @@ -758,6 +761,7 @@ static const struct bcm2835_clock_data bcm2835_clock_uart_da .div_reg = CM_UARTDIV, .int_bits = 10, .frac_bits = 12, + .is_vpu_clock = true, }; /* HDMI state machine */