From patchwork Fri Nov 3 12:05:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 833821 X-Patchwork-Delegate: jh80.chung@samsung.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="HnC3Z4yt"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3yT15c1vVkz9s5L for ; Fri, 3 Nov 2017 23:11:30 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 5378FC21DDD; Fri, 3 Nov 2017 12:11:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id C34E4C21C41; Fri, 3 Nov 2017 12:11:19 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id D4E1AC21C41; Fri, 3 Nov 2017 12:11:18 +0000 (UTC) Received: from mail-pg0-f66.google.com (mail-pg0-f66.google.com [74.125.83.66]) by lists.denx.de (Postfix) with ESMTPS id 55DD5C21C29 for ; Fri, 3 Nov 2017 12:11:17 +0000 (UTC) Received: by mail-pg0-f66.google.com with SMTP id y5so2301851pgq.7 for ; Fri, 03 Nov 2017 05:11:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=cPnyrMqG9hGQr+S2ktqKOxz/Exo0NkLBgTH3GoY0hCo=; b=HnC3Z4ytVKklogmCr09zbdTJz4Idvmr4uMGv8TPvoY0ft5YW1W7ZcYu9PhN8eJ6u9X ZzvyzzPPKhoQdnhSdOO6yBMo8te/PoNdgYRnxlDky0JChCPcfh1EGAFRxJ4TJASraQH/ t0zPbiGvWMin8BwmgL3gNqs8caAgPIZfwvIo1wadJyzFbirGpaSDrg1vwf3RhULBrka3 MxvEWGL7RW31QawCd190qrqUUGhL7//I/unCcXIlTHBEc7P/4VbespQkc1IChIYv4sx3 2UNJu4sEsEKkUFyzwrwYBauV7m0dHvWSAtiTdvUt6QY7bsgnwrJFdAqslNvppnInhS2X iE2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=cPnyrMqG9hGQr+S2ktqKOxz/Exo0NkLBgTH3GoY0hCo=; b=QLH61wH3TxDdsdKgrx1w/Q6GYK/UjjlKbBB2B18s1IT+3wDGDiZqdPe2rJpz2Tp47v mcOJ434nggR2DX58+BuXZBG9o9YFYh3tPCxHR5oNhoRJ6HnRSVvi5L09Wdl3GG6hEEx+ fih53bW22sDBFOdBzhWgbZ07m4MGG9oDI3ichS4grWyB/PwOgAx1yuPyxle9pQZHra+A QOUMZyOY3AO6ueT5WYQxOjdC1ZGIoxdDzO/6Nj8ohBSEcPx5mpElRkYkBTRrTkTwzvqQ YEHb2NSHssRvpwsCK6V1LKgsaQSMulvNZjaKS+M9dgJFKUvyoDxTF4MHaiu7I0Q7X/PC Llug== X-Gm-Message-State: AMCzsaWpTLKUPSuFwSXatxc8bgHeEzF4GVYpyrv8rtD+cANXmv+gWowU DwqXA9U+rLTgwAzUvVQcB72Y4ob3 X-Google-Smtp-Source: ABhQp+R/oBBn5J8CLqTr4e/tT5jtXxa5nkdPnw1iGQkMjZdf54ESpue+IC82RimUfjd9OVNdubLyow== X-Received: by 10.159.229.130 with SMTP id az2mr6712118plb.113.1509711074948; Fri, 03 Nov 2017 05:11:14 -0700 (PDT) Received: from localhost.localdomain ([115.97.180.212]) by smtp.gmail.com with ESMTPSA id j12sm11871567pfe.160.2017.11.03.05.11.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 03 Nov 2017 05:11:13 -0700 (PDT) From: Jagan Teki X-Google-Original-From: Jagan Teki To: u-boot@lists.denx.de Date: Fri, 3 Nov 2017 17:35:46 +0530 Message-Id: <1509710746-32268-1-git-send-email-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.7.4 Cc: Tom Rini , Stephen Warren , Jacob Chen Subject: [U-Boot] [PATCH] mmc-uclass: spl: upriv->mmc override by host descriptor address X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This specific issue observed with SPL_DM_MMC in falcon mode on rk3288 which used dw_mmc.c driver. Bug details: ----------- based on the falcon configuration, SPL trying to read the kernel from specified sectors, while mmc sending multi-block command(CMD18) the host descriptor address here next_addr(from dw_mmc.c, on below Bug log at blk_cnt = 938) is trying to override upriv(which further corrupting upriv->mmc) since after mmc pointing to wrong address which is causing next commands(CMD12) is unable to get the host pointer since it's reading wrong address which eventually block the booting at mmc stage. Bug log: ------- For blk_cnt = 946 Before: mmc_get_mmc_dev: dev = 0xff716088, upriv = 0x7e088, mmc = 0xff7160fc dwmci_set_idma_desc: addr = 0x274dfc0, next_addr = 0x7e080 After: mmc_get_mmc_dev: dev = 0xff716088, upriv = 0x7e088, mmc = 0xff7160fc For blk_cnt = 938 Before: mmc_get_mmc_dev: dev = 0xff716088, upriv = 0x7e088, mmc = 0xff7160fc dwmci_set_idma_desc: addr = 0x274efc0, next_addr = 0x7e0c0 After: mmc_get_mmc_dev: dev = 0xff716088, upriv = 0x7e088, mmc = 0x274efc0 Based on the above information, this patch is trying to allocate mmc_uclass_priv using .priv_auto_alloc_size so if it is zero, the respective uclass driver is responsible for allocating any data required. So in this scenario memory is not override between upriv->mmc and host description. mmc_uclass_priv with ..priv_auto_alloc_size: -------------------------------------------- For blk_cnt = 938 Before: mmc_get_mmc_dev: dev = 0xff71608c, upriv = 0x0, mmc = 0xff716100 dwmci_set_idma_desc: addr = 0x274efc0, next_addr = 0x7e0c0 After: mmc_get_mmc_dev: dev = 0xff71608c, upriv = 0x0, mmc = 0xff716100 Signed-off-by: Jagan Teki --- Note: - debug code: https://paste.ubuntu.com/25879159/ - Bug log: https://paste.ubuntu.com/25879138/ - Fix log: https://paste.ubuntu.com/25879139/ drivers/mmc/mmc-uclass.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c index 5dda20c..cdb0d28 100644 --- a/drivers/mmc/mmc-uclass.c +++ b/drivers/mmc/mmc-uclass.c @@ -299,5 +299,9 @@ UCLASS_DRIVER(mmc) = { .id = UCLASS_MMC, .name = "mmc", .flags = DM_UC_FLAG_SEQ_ALIAS, +#ifdef CONFIG_SPL_BUILD + .priv_auto_alloc_size = sizeof(struct mmc_uclass_priv), +#else .per_device_auto_alloc_size = sizeof(struct mmc_uclass_priv), +#endif };