Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E75FFC07E96 for ; Thu, 15 Jul 2021 07:15:19 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0348A6128C for ; Thu, 15 Jul 2021 07:15:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0348A6128C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5D2848033E; Thu, 15 Jul 2021 09:15:16 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ZISF+0lt"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 92719804E7; Thu, 15 Jul 2021 09:15:14 +0200 (CEST) Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 8ACAC8022F for ; Thu, 15 Jul 2021 09:15:11 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jorge.ramirez.ortiz@gmail.com Received: by mail-wr1-x429.google.com with SMTP id f9so6325766wrq.11 for ; Thu, 15 Jul 2021 00:15:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=azS009Ygt4kl/4GBDg19mLrTUqK3PNZn22IH7jFIHdg=; b=ZISF+0lt5jfsvf3zFoes8xD8/kDGTUz6pQtx5D2/mnG6Ngw6bJGiX9EqIV9XuME5Ui u0ccsY0z1D0Rb/sNcZETDCaoV2YcF2Dp3VfTrH1zByXKjMYz7hSrQBSC9wZCOefhWmwJ WyknW5d0tTmt/YT6r9erU08/mth/owOYM5HJVY2w7CQQgNWkSphlFxBoRNlqs+tS+KsB FMIVHOOylbSOi0f+QmjEUx0dC391pJW0nNL2ppJGks/ha0y8dJ0feq63AiKC+vHJHG1o E02D5Gnss3PBpr2dptfxi85ggOZulQXwLY5fPLwkSvNTe4W5kWBuYygXq1s0orpqPJsh LcmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=azS009Ygt4kl/4GBDg19mLrTUqK3PNZn22IH7jFIHdg=; b=O4izOpZixDrFqnwwMcVjjfPWe6lf4o+a+4mELN8gpnFq4IxP70nlkjJ6PMcRoz8Kn0 ZgQ8jsAFipcfbPZBZkmg9Ao9EshxcgCScOE0FVn5h/sayDLjMcEn/ESSXezaciukDVU1 a8mcRWzv77z4YqWZkTnC0oBOh3tZyPpyFGEA/zdY9uCTyutqKxLVfvHHE6h8kti8DvaG wsuT4mov2VLOJwtZoLC263BLUQ8An3R1vSqWxvikfOi7K5Ei6kmg2jowlW11j7ejMtqM JKVWAEMqL8XQMB9fRUjoZEtSBwQoGDW3lQjkXFt07tsSVQryPIUHI6A0TNnjSJn1SFAc 50jw== X-Gm-Message-State: AOAM531n7KrGyafbAdz9iyKDilTtMMXivQnEEJIjcSsugsRoZG2taeMc 4oecvLNxwgOdJK/j9UtjhHw= X-Google-Smtp-Source: ABdhPJypvd8gQdKpVYFB6wJYrBXKiczbzuwm20NTVV/oddJmNsNfTIQdi76D0XLgBfydt3rD+s1p2w== X-Received: by 2002:a5d:4d01:: with SMTP id z1mr3512175wrt.34.1626333311150; Thu, 15 Jul 2021 00:15:11 -0700 (PDT) Received: from trex (138.red-79-146-80.dynamicip.rima-tde.net. [79.146.80.138]) by smtp.gmail.com with ESMTPSA id d10sm5096081wro.43.2021.07.15.00.15.10 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 15 Jul 2021 00:15:10 -0700 (PDT) From: "Jorge Ramirez-Ortiz, Gmail" X-Google-Original-From: "Jorge Ramirez-Ortiz, Gmail" Date: Thu, 15 Jul 2021 09:15:09 +0200 To: Ramon Fried Cc: Stephan Gerhold , U-Boot Mailing List , Jorge Ramirez-Ortiz , Nicolas Dechesne , Tom Rini Subject: Re: [PATCH] arm: mach-snapdragon: pinctrl: Place pin_name in .data section Message-ID: <20210715071509.GA15301@trex> References: <20210705121847.48432-1-stephan@gerhold.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean On 06/07/21, Ramon Fried wrote: > On Mon, Jul 5, 2021 at 3:19 PM Stephan Gerhold wrote: > > > > According to arch/arm/lib/crt0_64.S, the BSS section is "UNAVAILABLE" > > and uninitialized before relocation. Also, it overlaps with the > > appended DTB before relocation, so writing data into a variable > > in the BSS section might corrupt the appended DTB. > > > > Unfortunately, pinctrl-apq8016.c and pinctrl-apq8096.c do place the > > "pin_name" variable in the BSS section (since it's uninitialized). > > It's also used before relocation, when setting up the pinctrl for > > the serial driver. > > > > On DB410c this causes "GPIO_5" to be written into some part of an > > appended DTB, e.g.: > > > > 80111820: edfe0dd0 9f100000 38000000 c00e0000 ...........8.... > > 80111830: 28000000 11000000 10000000 00000000 ...(............ > > 80111840: 4f495047 8800355f 00000000 00000000 GPIO_5.......... > > 80111850: 00000000 00000000 01000000 00000000 ................ > > 80111860: 03000000 04000000 00000000 02000000 ................ > > 80111870: 03000000 04000000 0f000000 02000000 ................ > > 80111880: 03000000 2d000000 1b000000 6c617551 .......-....Qual > > 80111890: 6d6d6f63 63655420 6c6f6e68 6569676f comm Technologie > > > > Depending on the part of the DTB that is corrupted this might not > > cause any problems, but it can also result in strange reboots > > without any serial output. > > > > Fortunately, in practice this does not cause issues on DB410c yet > > because board_fdt_blob_setup() in dragonboard410c.c currently > > overrides the appended DTB with the one passed by the previous > > bootloader (LK) (which does not get corrupted). > > > > DB820c does not have board_fdt_blob_setup() so I would expect it to > > be affected by this problem. Perhaps everyone was just fortunate to > > not compile an U-Boot configuration where the pin_name corrupts an > > important part of the DTB. I'll try to confirm during the week. After Ramon's pinctrl changes db820c did indeed break - was able to test a few months back- but we didnt have a board to test back then (and nobody complained) will come back to you on this but from what you are saying, this is probably the fix we needed for db820c > > > > Make sure "pin_name" is explicitly placed in the .data section > > instead of .bss to fix this. > > > > Cc: Ramon Fried > > Signed-off-by: Stephan Gerhold > > --- > > > > arch/arm/mach-snapdragon/pinctrl-apq8016.c | 3 +-- > > arch/arm/mach-snapdragon/pinctrl-apq8096.c | 2 +- > > 2 files changed, 2 insertions(+), 3 deletions(-) > > > > diff --git a/arch/arm/mach-snapdragon/pinctrl-apq8016.c b/arch/arm/mach-snapdragon/pinctrl-apq8016.c > > index 1042b564c3..70c0be0bca 100644 > > --- a/arch/arm/mach-snapdragon/pinctrl-apq8016.c > > +++ b/arch/arm/mach-snapdragon/pinctrl-apq8016.c > > @@ -10,7 +10,7 @@ > > #include > > > > #define MAX_PIN_NAME_LEN 32 > > -static char pin_name[MAX_PIN_NAME_LEN]; > > +static char pin_name[MAX_PIN_NAME_LEN] __section(".data"); > > static const char * const msm_pinctrl_pins[] = { > > "SDC1_CLK", > > "SDC1_CMD", > > @@ -59,4 +59,3 @@ struct msm_pinctrl_data apq8016_data = { > > .get_function_mux = apq8016_get_function_mux, > > .get_pin_name = apq8016_get_pin_name, > > }; > > - > > diff --git a/arch/arm/mach-snapdragon/pinctrl-apq8096.c b/arch/arm/mach-snapdragon/pinctrl-apq8096.c > > index 20a71c319b..45462f01c2 100644 > > --- a/arch/arm/mach-snapdragon/pinctrl-apq8096.c > > +++ b/arch/arm/mach-snapdragon/pinctrl-apq8096.c > > @@ -10,7 +10,7 @@ > > #include > > > > #define MAX_PIN_NAME_LEN 32 > > -static char pin_name[MAX_PIN_NAME_LEN]; > > +static char pin_name[MAX_PIN_NAME_LEN] __section(".data"); > > static const char * const msm_pinctrl_pins[] = { > > "SDC1_CLK", > > "SDC1_CMD", > > -- > > 2.32.0 > > > Reviewed-by: Ramon Fried