From: Lokesh Vutla Date: Thu, 25 Jul 2019 13:52:24 +0530 Subject: [U-Boot] [PATCH v2 05/12] armV7R: K3: am654: Allow using SPL BSS pre-relocation In-Reply-To: References: <20190604225555.12186-1-dannenberg@ti.com> <20190604225555.12186-6-dannenberg@ti.com> <20190719000047.GA20116@bill-the-cat> <20190720155138.GY20116@bill-the-cat> Message-ID: <2e89ea9b-ab14-e462-b51c-236710db455b@ti.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: quoted-printable To: u-boot@lists.denx.de Hi Simon, On 25/07/19 12:31 PM, Simon Goldschmidt wrote: > Hi Lokesh, >=20 > thanks for following up on this. >=20 > On Thu, Jul 25, 2019 at 6:36 AM Lokesh Vutla wrote: >> >> Hi Tom, >> >> On 20/07/19 9:21 PM, Tom Rini wrote: >>> On Fri, Jul 19, 2019 at 07:29:37AM +0200, Simon Goldschmidt wrote: >>>> On Fri, Jul 19, 2019 at 2:29 AM Tom Rini wrote: >>>>> >>>>> On Tue, Jun 04, 2019 at 05:55:48PM -0500, Andreas Dannenberg wrote: >>>>> >>>>>> In order to be able to use more advanced driver functionality which = often >>>>>> relies on having BSS initialized during early boot prior to relocati= on >>>>>> several things need to be in place: >>>>>> >>>>>> 1) Memory needs to be available for BSS to use. For this, we locate = BSS >>>>>> at the top of the MCU SRAM area, with the stack starting right be= low >>>>>> it, >>>>>> 2) We need to move the initialization of BSS prior to entering >>>>>> board_init_f(). We will do this with a separate commit by turning= on >>>>>> the respective CONFIG option. >>>>>> >>>>>> In this commit we also clean up the assignment of the initial SP add= ress >>>>>> as part of the refactoring, taking into account the pre-decrement po= st- >>>>>> increment nature in which the SP is used on ARM. >>>>>> >>>>>> Signed-off-by: Andreas Dannenberg >>>>> >>>>> Applied to u-boot/master, thanks! >>>> >>>> Wait, why has this been merged? Unfortunately, I haven't followed this= series, >>>> but in a discussion about a similar patch I sent [1], using BSS from >>>> board_init_f >>>> was turned down. And Simon Glass rather convinced me that this is the = current >>>> API U-Boot has (and is documented in README). >>>> >>>> So either we must change this API and its documentation (and I would e= xpect the >>>> author of this patch to combine the README change with the code change= ), or this >>>> patch would have to be rejected. >>>> >>>> Again, I'm sorry I only see this now. In thought to remember a >>>> discussion in this >>>> thread, but I clearly remember that wrong... >>>> >>>> [1] https://patchwork.ozlabs.org/patch/1057237/ >>> >>> And I had missed that other thread. Lokesh, since I think Andreas is >>> out currently can you expand a little on what we can/can't do on this >>> platform? Thanks! >> >> The reason why BSS is needed very early in this platform is for the foll= owing >> reasons: >> - System co-processor is the central resource manager in SoC and should = be >> loaded and started very early in the boot process. Without that no perip= heral or >> memory can be initialized. So for loading system co-processor image, we = only >> have limited SRAM and a peripheral initialized by ROM. >> - System co-processor(DMSC) is being represented as remote-core in >> Device-tree(We are strictly following DM and DT model for the entire SoC= ). >> - Since DM is also followed by each peripheral device and remote core, D= M should >> be enabled very early and many peripheral drivers are dependent on BSS u= sage. >> So, BSS has been made available very early. >> >> Hope this is clear. Let me know if more details are required, I will be = happy to >> explain. >=20 > Don't get me wrong: I'm not against using BSS early. I just want to ensur= e this > stays consistent throught U-Boot. I understand and agree that it should be consistent. Just discussed this wi= th Andreas, who is courteous enough to update the details in his vacation. >=20 > The reasons you stated still don't make it clear to me *why* bss is needed > early. There are other boards using DM early that don't need this. In my > opinion, DM drivers normally don't rely on BSS but keep all their state in This statement doesn't hold true for all the drviers. At least the mmc driv= er uses "initialized" variable stored in BSS to avoid initializing mmc multiple times[0]. In the past we en counted other drivers using it. I guess the idea here is to enable the BSS support generically instead of fixing each of eve= ry driver. > heap memory. If you only need BSS early because drivers rely on BSS, you = might > have to fix those drivers? So, correct me here, why should driver be restricted to not use BSS? Also doing a grep for bss usage very early in board_init_f produced many re= sults: =E2=9E=9C u-boot git:(master) git grep -in "memset(__bss_start" | cut -d := -f 1 arch/arm/mach-socfpga/spl_gen5.c arch/arm/mach-zynqmp/spl.c arch/mips/mach-jz47xx/jz4780/jz4780.c board/barco/platinum/spl_picon.c board/barco/platinum/spl_titanium.c board/compulab/cl-som-imx7/spl.c board/congatec/cgtqmx6eval/cgtqmx6eval.c board/dhelectronics/dh_imx6/dh_imx6_spl.c board/el/el6x/el6x.c board/freescale/imx8mq_evk/spl.c board/freescale/imx8qm_mek/spl.c board/freescale/imx8qxp_mek/spl.c board/freescale/ls1021aiot/ls1021aiot.c board/freescale/ls1021aqds/ls1021aqds.c board/freescale/ls1021atwr/ls1021atwr.c board/freescale/mx6sabreauto/mx6sabreauto.c board/freescale/mx6sabresd/mx6sabresd.c board/freescale/mx6slevk/mx6slevk.c board/freescale/mx6sxsabresd/mx6sxsabresd.c board/freescale/mx6ul_14x14_evk/mx6ul_14x14_evk.c board/k+p/kp_imx6q_tpc/kp_imx6q_tpc_spl.c board/liebherr/display5/spl.c board/logicpd/imx6/imx6logic.c board/phytec/pcm058/pcm058.c board/phytec/pfla02/pfla02.c board/sks-kinkel/sksimx6/sksimx6.c board/solidrun/mx6cuboxi/mx6cuboxi.c board/technexion/pico-imx6ul/spl.c board/technexion/pico-imx7d/spl.c board/toradex/apalis_imx6/apalis_imx6.c board/toradex/colibri_imx6/colibri_imx6.c board/udoo/neo/neo.c board/variscite/dart_6ul/spl.c board/woodburn/woodburn.c There might be some false positive cases but most of the above files are utilizing bss in board_init_f. >=20 > Further, allowing BSS early is still against what the main README says, s= o I > want to raise the question again: shouldn't this main README be changed i= f we > suddenly allow BSS to be used early (because that main README says we can= 'that > do that)? I do agree on this part. We should fix README in this case. [0] https://gitlab.com/u-boot/u-boot/blob/master/drivers/mmc/mmc.c#L1832 Thanks and regards, Lokesh