From: Simon Goldschmidt Date: Mon, 14 Jan 2019 16:21:42 +0100 Subject: [U-Boot] [PATCH] arm: socfpga: make debug uart work on socfpga_gen5 In-Reply-To: <4a852bc0-e8da-c5cd-286e-b26fee37b0ec@denx.de> References: <20190107193617.27034-1-simon.k.r.goldschmidt@gmail.com> <81fe0635-48a1-3b7d-3564-4e3fb95f4567@denx.de> <05606036-ab99-fa07-a6d1-07c3d3fa97ee@denx.de> <1f43b4ff-5dfa-4f78-f74d-56c2c9b89520@gmail.com> <80f5cdca-1824-a0f3-9210-7266ea28659b@denx.de> <9fc16627-8f99-6a6a-451e-149b1a781e43@gmail.com> <93afb2af-2ab8-a7b2-509b-dd74046d2300@denx.de> <06cff397-d609-4d36-1ebf-6a29c1e3e842@denx.de> <73de7c42-a6d0-aa79-767c-ff7cac0e19d6@denx.de> <4a852bc0-e8da-c5cd-286e-b26fee37b0ec@denx.de> Message-ID: <2f3c2f77-65e5-0aa6-4c1a-a9ec8757fe2f@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Am 08.01.2019 um 13:56 schrieb Marek Vasut: > On 1/8/19 1:42 PM, Simon Goldschmidt wrote: >> On Tue, Jan 8, 2019 at 1:08 PM Marek Vasut wrote: >>> >>> On 1/8/19 1:06 PM, Simon Goldschmidt wrote: >>>> On Tue, Jan 8, 2019 at 12:20 PM Marek Vasut wrote: >>>>> >>>>> On 1/8/19 7:41 AM, Simon Goldschmidt wrote: >>>>>> On Mon, Jan 7, 2019 at 11:58 PM Marek Vasut wrote: >>>>>>> >>>>>>> On 1/7/19 10:01 PM, Simon Goldschmidt wrote: >>>>>>>> Am 07.01.2019 um 21:47 schrieb Marek Vasut: >>>>>>>>> On 1/7/19 9:33 PM, Simon Goldschmidt wrote: >>>>>>>>>> Am 07.01.2019 um 21:25 schrieb Marek Vasut: >>>>>>>>>>> On 1/7/19 9:24 PM, Simon Goldschmidt wrote: >>>>>>>>>>>> Am 07.01.2019 um 21:19 schrieb Marek Vasut: >>>>>>>>>>>>> On 1/7/19 8:36 PM, Simon Goldschmidt wrote: >>>>>>>>>>>>>> When debug UART is enabled on socfpga_gen5, the debug uart driver >>>>>>>>>>>>>> hangs >>>>>>>>>>>>>> in an endless loop because 'socfpga_bridges_reset' calls printf >>>>>>>>>>>>>> before >>>>>>>>>>>>>> the debug UART is initialized. >>>>>>>>>>>>>> >>>>>>>>>>>>>> After the generic fix for this in the UART driver did not work >>>>>>>>>>>>>> due to >>>>>>>>>>>>>> portability issues, let's just drop this printf statement when >>>>>>>>>>>>>> called >>>>>>>>>>>>>> from SPL with debug UART enabled. >>>>>>>>>>>>>> >>>>>>>>>>>>>> Signed-off-by: Simon Goldschmidt >>>>>>>>>>>>> >>>>>>>>>>>>> Can we have an un-portable fix which at least works on SoCFPGA ? :) >>>>>>>>>>>> >>>>>>>>>>>> This one worked on socfpga but broke rockchip: >>>>>>>>>>>> >>>>>>>>>>>> https://patchwork.ozlabs.org/patch/992553/ >>>>>>>>>>>> >>>>>>>>>>>> However, the message below wasn't shown either with that patch >>>>>>>>>>>> applied. >>>>>>>>>>>> The code just runs too early to enable the UART. >>>>>>>>>>>> >>>>>>>>>>>> Do you want to keep the message (although I failed to see in which >>>>>>>>>>>> situation it can be printed) or do you just dislike the #ifdef thing? >>>>>>>>>>> >>>>>>>>>>> I'd like to keep the error message if possible. Is it possible ? >>>>>>>>>> >>>>>>>>>> I have *never* seen this message yet. I have failed to produce a >>>>>>>>>> situation where it is shown. >>>>>>>>> >>>>>>>>> I believe that. >>>>>>>>> >>>>>>>>>> This function ('socfpga_bridges_reset') is called 5 times throughout the >>>>>>>>>> code, but only *one* single time with 'reset=0' as argument (only with >>>>>>>>>> 0, the code in question is executed). And this is in SPL before >>>>>>>>>> initializing the console and even before the debug UART can be >>>>>>>>>> initialized. >>>>>>>>>> >>>>>>>>>> As I could see, the printf *is* executed on every boot (I saw the code >>>>>>>>>> hanging when enabling debug UART). However, when not booting from FPGA, >>>>>>>>>> it is just normal that the FPGA is not ready when running SPL. Why do >>>>>>>>>> you want an error message here anyway? >>>>>>>>> >>>>>>>>> I was under the impression this is an error message, but it might not be >>>>>>>>> so ? Maybe the wording is incorrect ? >>>>>>>> >>>>>>>> Now that I re-read it, "aborting" is incorrect, yes. >>>>>>>> >>>>>>>> So how should we proceed? This is an error message that can never be >>>>>>>> shown (like the code is now) but breaks debug UART. >>>>>>>> >>>>>>>> I'd say we can drop it altogether. It might only be interesint if (in >>>>>>>> the future) that code would get called from somewhere else (i.e. later, >>>>>>>> after console initialization). >>>>>>>> >>>>>>>> Re-reading spl_gen5.c, there are some 'debug' calls before the debug >>>>>>>> uart is initialized which probably would need to be removed as well, but >>>>>>>> that's a different story... >>>>>>> >>>>>>> How come those don't hang the system then ? >>>>>> >>>>>> I just haven't enabled debug output in spl_gen5.c, yet. I guess they would hang >>>>>> the system when enabling them. >>>>>> >>>>>> While it would be easy to remove these debug statements, to be future-proof >>>>>> it would of course make sense to make the debug UART robust against this. >>>>>> >>>>>> But given the problems with Rockchip ns16550, we would need a dedicated >>>>>> debug UART for socfpga to solve this. And that would probably mean code >>>>>> duplication. >>>>> >>>>> What is the problem with Rockchip ? I don't want various SoCs blocking >>>>> others. >>>> >>>> I had sent a patch that does not wait for the TX fifo to hold more bytes if the >>>> baudrate prescaler is 0 (according to both the socfgpa and the rockchip docs, >>>> the UART is disabled if the prescaler is 0). >>>> >>>> However, it seems that the prescaler was read back as 0 on a rockchip board >>>> which caused chars to be missing from the console output. >>>> >>>> See this mail: >>>> https://lists.denx.de/pipermail/u-boot/2018-December/350355.html >>>> >>>> I checked with Henri and did not find a solution so I reverted the patch: >>>> https://patchwork.ozlabs.org/patch/1007211/ >>>> >>>> Keeping this patch but only for selected platforms would be my favourite, but it >>>> would at least mean we need yet another debug UART selection, plus some changes >>>> to make the "prescaler == 0" detection specific to this new debug UART. >>>> Would this be better acceptable? >>> >>> Doesn't the DT compatible tell you the UART type ? It does, so you can >>> match on that and apply the workaround accordingly . >> >> We're talking about debug UART here only. No DT compatible involved. >> >>> Or you can cache the prescaler. >> >> We already had that. Simon mentioned that on some platforms you neither have bss >> available nor 'gd' at the point where the debug UART is inialized, so >> there's not portable >> storage to cache the prescaler, either :-( >> >> The best I can think of right now would probably be to extend the list >> of debug UARTS >> with an socfpga specific type which compiles the same code as DEBUG_UART_NS16550 >> but enables this prescaler check. > > Uhhhhhh, unless you find a better option, that'd be fine by me. This patch should be dropped in favour to another patch taht adds a Kconfig option to check the baudrate prescaler: https://patchwork.ozlabs.org/patch/1022600/ Regards, Simon