From patchwork Sun May 15 09:25:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Trimarchi X-Patchwork-Id: 1944 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id E21733F18B for ; Sun, 15 May 2022 11:25:46 +0200 (CEST) Received: by mail-ed1-f71.google.com with SMTP id s29-20020a50ab1d000000b00427e495f00csf7761057edc.14 for ; Sun, 15 May 2022 02:25:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1652606746; cv=pass; d=google.com; s=arc-20160816; b=VGXM0QBcqe1knFyH8VzfcFwfv4XW8Lc2Sf/TtvKv3J9MV5/0+9D+macSt0b43cGQj7 OuYNaFYl/17TFlkI+UcZCiipcrYFbbd9VSq9L/TqL9Ra1feIu7CNqXtzWvJJ/TG3o3uu S0uA0wEJotDHR0+x7o0jP0d0TQ4gwC4NX/o/fzkWtK4/RMq7EoQ22pSHIKklcX6rikRj u9+y+uu7ok3CESGnm+CE9U5saItecVRjMm3jDm2hVCfqXyH8QUwhDjsQSGIowRDtWdxp IRWShHlvhVWcZH0r/2T3G3cuV3lP4WgXk2v+sspdzoA4foKyUJ7bh4rQOX1KN+1Y4LCz bnCA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=IEyW5/jR/tsoOGbO5MM4PJF3dbcttBOAblnyO4gtoxI=; b=0eNDkcDNZPViM/gtqrB7LvbgN4fiiFt1sNcw7hDw5xL/jAp5f1US/S03td7Rnxo9ft TaDpyaswBAUHHe8KEHC2NA9POEICkfNpOiVt78/Ifi98odI3JNgdoPZ9hMWzsfKoVoUE ybUoLY/HfJLtiLMjbxiGLsRL9BGTeaSWRFQU3YMV/g3KheV32/NGyTvXxslqPKjfnEs6 XnSetH9PWB+PsN9Q1myYBKmI4bjTB1p3hl2oiFmwzoN3MuHQlIaty1BcytnI1yuGJsr9 3YRIkzWrLHr59X350qJ2Gh9Vn9aD5aYwIiWTAcugs1CSd7ys9hnC3Z6ah38JCgs6ZgmT G5QA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=IjzYrGSd; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=IEyW5/jR/tsoOGbO5MM4PJF3dbcttBOAblnyO4gtoxI=; b=aCsB00UuAozksiZffwG3KubmIDLtEzNbcZ5Rk7Mpa35hfOjs1K0syqoArxLYT9X9Md Ru9/9DiLLQLMA7gp8Ro4WH2Qp1D6f9/6Frj2w6IG3qmx5d3w225+xCSWxBSc1XZaXJJ2 1gYNsEL7Q9HfVqkBRubu3v13xhbwE2nTrduSc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=IEyW5/jR/tsoOGbO5MM4PJF3dbcttBOAblnyO4gtoxI=; b=0V8DdFczC1kvp+82A4qJbunJSN06cK2SQfdMcTUH1bl+UKhL1ehYzkPIB1OgtVr41v QhkEmp8vDBNv7DXbTYc1+U9Suv2NAHuCZpbfZ7ZS8FZtnwjXlv24TNyKKmvjDsxtKo4n agGQz4kSjnnrd7lnwfhPXESL56dTF8VgD5n77oper0pq9otQ5+uSQuAhxmahgZmZYHmD exM7uGKwBtyzN2ZhfuXP17amjE/g0E6udYdIuF0t6hI5uL4+lGwsK6XWfLxwXBjDbXNd 41unQafhaxcLlVV+7tLAQQo+bN++rkXxnqFWV9UGWXrZTM1/myIR5dc4+ACjxAwAsIGE O/8A== X-Gm-Message-State: AOAM531CXh6iGsWyHATdMQEDGW+6CJlYJH9Q6fRY/vKjiSew4X4X7uUR VOwHtNqrZvRw3/6yIE/VCXTUmX7y X-Google-Smtp-Source: ABdhPJwyiE+zrcA8J0Gwj8k0hHYNWcztJQs+a3A62dHF7rtfSp8lPNQk/hy11tI/8Bb3pc8cn2cbcQ== X-Received: by 2002:a05:6402:84a:b0:426:262d:967e with SMTP id b10-20020a056402084a00b00426262d967emr7571445edz.286.1652606746224; Sun, 15 May 2022 02:25:46 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:26d2:b0:428:f87:ccd8 with SMTP id x18-20020a05640226d200b004280f87ccd8ls3091847edd.1.gmail; Sun, 15 May 2022 02:25:45 -0700 (PDT) X-Received: by 2002:a05:6402:d0a:b0:425:d455:452 with SMTP id eb10-20020a0564020d0a00b00425d4550452mr7391078edb.259.1652606744879; Sun, 15 May 2022 02:25:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652606744; cv=none; d=google.com; s=arc-20160816; b=wdusAvyh3feqhSdaKWTfDJo7im2gLL5d9QVgDpH8J8uuB0FfR294kcwKc68cwWVqAp 3TKkWgn7zngjPrOWNZOPPywnTFXdOnkwC/JoMmbtVg09EKEdZh/Zpn5vuBpi6uRICm9P hNOTZDKv7byKJFei44xh9fHPY7p1OTkDARmS6Cf4NCtTHgoiNUDukE+wjO8wSpOurLxS HwhU0gYYPRQUsFsgFjc+ciRrSLpdS9qh+f0b3juPjDUpCZA77vpyq/B3AaUPm+117TYh wwVVHxNZ1v+CObyefaQvkwmOeQTL/HG2zVMrWeJ1JCwQefzaS6ZNs+HS856aq31O0gVU 8cCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=LfiQWwLJyJZvkgKutBx9y9teVnkqTwppDmZ2w6mM5A8=; b=LGN+v1AW3Qxu+N0I3aVVBvHK4q0Ur+WCImfWG/S4ldlMd1XTFKQKt+KbS4zEqJdVJD NBfoOV2arxQHfVyTaQyQrcts4KsrS2Pdq/VQAzDIaUH6iQrHB78/Vsk4JdCxRYWEQhNX BpvkK21cRxy2R7Ab8blRU9eOs+wEMwofR8fIp8FtKFFng26jQOYeVUtOWwURouoWtQ12 FrbjJwkNKmYjCy5TzRmACZMVcv/JIH4n7fzs7iytNceMoIGfeRIAHnkC9gS9ayg1L+/5 xpUwaMpsUhLpww3+vylT/JRU+/bp7LLEoT+qNWf4RkyXyaMDQd6A7OCpbTHvO7tVFO6+ DYFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=IjzYrGSd; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id oz33-20020a1709077da100b006fde63acc81sor2587559ejc.94.2022.05.15.02.25.44 for (Google Transport Security); Sun, 15 May 2022 02:25:44 -0700 (PDT) Received-SPF: pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a17:907:761c:b0:6d6:e553:7bd1 with SMTP id jx28-20020a170907761c00b006d6e5537bd1mr10623607ejc.5.1652606744604; Sun, 15 May 2022 02:25:44 -0700 (PDT) Received: from localhost.localdomain (mob-109-118-140-232.net.vodafone.it. [109.118.140.232]) by smtp.gmail.com with ESMTPSA id m17-20020a17090677d100b006f3ef214dc5sm2509888ejn.43.2022.05.15.02.25.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 May 2022 02:25:43 -0700 (PDT) From: Michael Trimarchi To: Han Xu , U-Boot-Denx Cc: Ye Li , Stefano Babic , Miquel Raynal , Fabio Estevam , Dario Binacchi , Sean Anderson , linux-amarula@amarulasolutions.com, Jagan Teki , Ariel D'Alessandro , Tom Rini , Fabio Estevam , Tim Harvey Subject: [PATCH V3 1/5] nand: raw: mxs_nand: Fix specific hook registration Date: Sun, 15 May 2022 11:25:34 +0200 Message-Id: <20220515092538.1736154-2-michael@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220515092538.1736154-1-michael@amarulasolutions.com> References: <20220515092538.1736154-1-michael@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: michael@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=IjzYrGSd; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Move the hook after nand_scan_tail is called. The hook must be replaced to the mxs specific one but those must to be assignment later in the probe function. With this fix markbad is working again. Before this change: nand markbad 0xDEC00 NXS NAND: Writing OOB isn't supported NXS NAND: Writing OOB isn't supported block 0x000dec00 NOT marked as bad! ERROR 0 Cc: Han Xu Cc: Fabio Estevam Acked-by: Han Xu Tested-By: Tim Harvey Signed-off-by: Michael Trimarchi --- V2->V3: - Add tested-by from Tim - Add ack from Han Xu V1->V2: - Adjust the commit message - Add Cc Han Xu and Fabio --- drivers/mtd/nand/raw/mxs_nand.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/mtd/nand/raw/mxs_nand.c b/drivers/mtd/nand/raw/mxs_nand.c index ee5d7fde9c..53f24b9c4b 100644 --- a/drivers/mtd/nand/raw/mxs_nand.c +++ b/drivers/mtd/nand/raw/mxs_nand.c @@ -1246,22 +1246,6 @@ int mxs_nand_setup_ecc(struct mtd_info *mtd) /* Enable BCH complete interrupt */ writel(BCH_CTRL_COMPLETE_IRQ_EN, &bch_regs->hw_bch_ctrl_set); - /* Hook some operations at the MTD level. */ - if (mtd->_read_oob != mxs_nand_hook_read_oob) { - nand_info->hooked_read_oob = mtd->_read_oob; - mtd->_read_oob = mxs_nand_hook_read_oob; - } - - if (mtd->_write_oob != mxs_nand_hook_write_oob) { - nand_info->hooked_write_oob = mtd->_write_oob; - mtd->_write_oob = mxs_nand_hook_write_oob; - } - - if (mtd->_block_markbad != mxs_nand_hook_block_markbad) { - nand_info->hooked_block_markbad = mtd->_block_markbad; - mtd->_block_markbad = mxs_nand_hook_block_markbad; - } - return 0; } @@ -1467,6 +1451,22 @@ int mxs_nand_init_ctrl(struct mxs_nand_info *nand_info) if (err) goto err_free_buffers; + /* Hook some operations at the MTD level. */ + if (mtd->_read_oob != mxs_nand_hook_read_oob) { + nand_info->hooked_read_oob = mtd->_read_oob; + mtd->_read_oob = mxs_nand_hook_read_oob; + } + + if (mtd->_write_oob != mxs_nand_hook_write_oob) { + nand_info->hooked_write_oob = mtd->_write_oob; + mtd->_write_oob = mxs_nand_hook_write_oob; + } + + if (mtd->_block_markbad != mxs_nand_hook_block_markbad) { + nand_info->hooked_block_markbad = mtd->_block_markbad; + mtd->_block_markbad = mxs_nand_hook_block_markbad; + } + err = nand_register(0, mtd); if (err) goto err_free_buffers; From patchwork Sun May 15 09:25:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Trimarchi X-Patchwork-Id: 1945 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id AC2DD3F1F5 for ; Sun, 15 May 2022 11:25:48 +0200 (CEST) Received: by mail-ed1-f71.google.com with SMTP id cf16-20020a0564020b9000b00425d543c75dsf7782770edb.11 for ; Sun, 15 May 2022 02:25:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1652606748; cv=pass; d=google.com; s=arc-20160816; b=IvYFPx3dWI4DJMZflvSifVGI7vWBHVHGDmVj3SG2T2xwXlA1a7JxBBLY2Ni6eSK6mA MmX8w97JdTzfAw2ykhxZSoiIxF8XLYICTVWdyvbWuKu/PtNS4CpGKi7zVb/uT2uj9dHh QuMMYTA+aWRWio35N8Y/VNbnonP251BA5RS2xEpzyjjj3gxDgrLlJq5jD3IC/cnPz8TF gRIsdbir0XIrwMIn3JZO4HwmeskYShpc8kpdwB/8hQgq9UWmG+pwL5CX9cF06SXXPUwy YNPG6VZrqp24OM9WlXG6Bpg2oBt3ZrvLIjx51i8g6diN/v6LZtz86ebrMJjcO5kbfvTT MFuQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=KYRNTsVdaYlSHSfuYmA3P2EOKXN+Uq5zL8g/UB0TvXg=; b=bo07Qcv/jJoqEKGZ1dqVpS7QJW/Y5piKQiWNheN3nHOxiXCvOlmUyPsR8xW3PKMXtd /xsEtRV7cSYiDsNQAWTJl1qZQg8Csi1a3EnVLFKN2szaw48F9HSmPq3De8Sun0s8V1uL KRWiJob/xJ0TnK2kCoap7/1kaFG+gAR2e6tFjeNNJQYcK4QHz0QWzkWzB5abcEXs8Y5c 0FMIjdVH77eytcCE47Sv8RPNdPjpkbNBbxfSpeHjlfQy1508yXaYEcr/vwu34TwvvF1X TswuiAR+6o29irVt02zMSl0xCRnxBW8qny0OryFyisKo0jOKz5DDNHE5uwUGV8y/QS/h Nw0A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=nKcjAwye; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=KYRNTsVdaYlSHSfuYmA3P2EOKXN+Uq5zL8g/UB0TvXg=; b=FwyvyFehsRoiMAywdjCqPfjSNCe1SB3j4FBjDEjdA/JJN7RkqRVYAmeI+aYBubHSIm +eEy70CB3M6hvHdlMm4NKPjV/aKZSEGZ/Wux/5IVCHCVEeRx/9uFQj1cEOiCvBih+4gO MEHnLTmtbGtLQ6GUh/PNw4HA4MjWH1sjlM/18= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=KYRNTsVdaYlSHSfuYmA3P2EOKXN+Uq5zL8g/UB0TvXg=; b=jTDoNLEmi7HdusC0ef55h6PBjsSaj1Boh2E2BqVOQOQ4l/WHURQyX53+D5EU+Ozx5g pszXihC7ZoTi8CLTMb4Zig9gLrBQWfIHAAKl307j0AwixNM0G4evoiv//F4KnmhXY6hQ Ut0CvZlV+X0gqweo4qzd39NFWDl5UE7buWRu1t5jBn3Be9sIsSPH7M7U5Ra5wv3ctvDB yZJKpdVZCLw/2jXbZs/yLEe7JDy2nbc3VQVD/fcKvlDbLCpyoUJ0vnxglC53b4Azlyxb /opPYax5OemDpLRala5hlrYscBekL8dWq7u7DdTk6yeUnIn8Rl4Kry0mzy+9hGoD39aE Q5xw== X-Gm-Message-State: AOAM531oOKoiANRBwcHKNh8912iCNK41HKsw3ZDd2VHar8USbLb7dx7a ITOXyhNjQFOgyn8ufSx2HmCaxKw6 X-Google-Smtp-Source: ABdhPJyGRZVBzrUXe16cEKrM3jM9qvy22SzW3A9s+bhS4BtN/JjfCq6kZDO2wJrCMvpHpZ2H7WE8xA== X-Received: by 2002:a17:906:314b:b0:6d6:da31:e545 with SMTP id e11-20020a170906314b00b006d6da31e545mr11538565eje.125.1652606748434; Sun, 15 May 2022 02:25:48 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:2741:b0:41f:7eee:e393 with SMTP id z1-20020a056402274100b0041f7eeee393ls3092660edd.3.gmail; Sun, 15 May 2022 02:25:47 -0700 (PDT) X-Received: by 2002:a05:6402:e83:b0:428:727e:7e2c with SMTP id h3-20020a0564020e8300b00428727e7e2cmr7641133eda.26.1652606747110; Sun, 15 May 2022 02:25:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652606747; cv=none; d=google.com; s=arc-20160816; b=CbnkeBwsDedOW+52aETSYY8JGTH3Uo8oesjjP03qyW5j1fmtP7gbsSzMqM+XpiQwi0 qbji/TWFylstF6NNeSAmOKGt/bpo2JBjfrx7HB+rk6D4kRIZur5lnK4P3qJzU1/bfzwS tXqcb+3Qns27laXY4gA6QkaN9kW5f4HLM0d5cNwI3zXHSm+MO5O1Op4iLfkr+unMovCs G60gFW0g+DDg21an+oqn05ty2K9n3vZL8MMF1fLZ4knDb1rGilpVjrv6JGzM2xvFEu8h yQmIDqYUE5MqCP1KRMcWwC0jEm6Z+zm6TkvX0V6MHjicZFZxqNpG8gPPVpeo4GyrjqRX NabQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=O159ccGFk9andF48EnbXRwWOzhVcnIM+anpKSCa6pik=; b=L1yLmzHWAQPYEMJllZg1bwuktW81XgCgd2ArwVcq8N/CVnJ9GEWldxHv4ZC2/tSymH skOcBbebkXUR96RVe6l4gK8Ka28a4AUEC3+91iatifC2lyDsQ285OCEkDMohBR4FADAP 1u+fEIjtr6+c90GLaQPEr7mwNKm38D4iR3KHi9mvRJ9f4FrK1CvuaBlM3gvU763fdcEe 2K3gx0haatioCSYpuSXfxL3a7hla1SObeG6F+R5dr6xCX72dHtxVok7AJ6jGATlhoEs2 gVDUJGb/KhacLzMP2n9wgNanssIHNp1jajw6KFe/ddsR0Zz/SynX4sally0vkWBSVxHA NWJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=nKcjAwye; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id u7-20020a170906108700b006df7a679668sor2621850eju.59.2022.05.15.02.25.47 for (Google Transport Security); Sun, 15 May 2022 02:25:47 -0700 (PDT) Received-SPF: pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a17:907:9958:b0:6e7:f67a:a1e7 with SMTP id kl24-20020a170907995800b006e7f67aa1e7mr10756458ejc.400.1652606746791; Sun, 15 May 2022 02:25:46 -0700 (PDT) Received: from localhost.localdomain (mob-109-118-140-232.net.vodafone.it. [109.118.140.232]) by smtp.gmail.com with ESMTPSA id m17-20020a17090677d100b006f3ef214dc5sm2509888ejn.43.2022.05.15.02.25.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 May 2022 02:25:46 -0700 (PDT) From: Michael Trimarchi To: Han Xu , U-Boot-Denx Cc: Ye Li , Stefano Babic , Miquel Raynal , Fabio Estevam , Dario Binacchi , Sean Anderson , linux-amarula@amarulasolutions.com, Jagan Teki , Ariel D'Alessandro , Tom Rini , Fabio Estevam , Tim Harvey Subject: [PATCH V3 2/5] mtd: nand: mxs_nand_spl: Fix bad block skipping Date: Sun, 15 May 2022 11:25:35 +0200 Message-Id: <20220515092538.1736154-3-michael@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220515092538.1736154-1-michael@amarulasolutions.com> References: <20220515092538.1736154-1-michael@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: michael@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=nKcjAwye; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The specific implementation was having bug. Those bugs are since the beginning of the implementation. Some manufactures can already experience this bug in their SPL code. This bug can be more visible on architecture that has complicated boot process like imx8mn. Older version of uboot can be affected if the bad block appear in correspoding of the beginning of u-boot image. In order to adjust the function we scan from the first erase block. The problematic part of old code was in this part: while (is_badblock(mtd, offs, 1)) { page = page + nand_page_per_block; /* Check i we've reached the end of flash. */ if (page >= mtd->size >> chip->page_shift) { free(page_buf); return -ENOMEM; } } Even we fix it adding increment of the offset of one erase block size , we don't fix the problem, because the first erase block where the image start is not checked. The code was tested on an imx8mn where the boot rom api was not able to skip it. This code is used by other architecures like imx6 and imx8mm Cc: Han Xu Cc: Fabio Estevam Acked-by: Han Xu Tested-By: Tim Harvey Signed-off-by: Michael Trimarchi --- V2->V3: - Add tested-by from Tim - Add ack from Han Xu - Rework english of commit message V1->V2: - Adjust the commit message - Add Cc Han Xu and Fabio - fix size >= 0 to > 0 --- drivers/mtd/nand/raw/mxs_nand_spl.c | 90 ++++++++++++++++------------- 1 file changed, 49 insertions(+), 41 deletions(-) diff --git a/drivers/mtd/nand/raw/mxs_nand_spl.c b/drivers/mtd/nand/raw/mxs_nand_spl.c index 59a67ee414..2bfb181007 100644 --- a/drivers/mtd/nand/raw/mxs_nand_spl.c +++ b/drivers/mtd/nand/raw/mxs_nand_spl.c @@ -218,14 +218,14 @@ void nand_init(void) mxs_nand_setup_ecc(mtd); } -int nand_spl_load_image(uint32_t offs, unsigned int size, void *buf) +int nand_spl_load_image(uint32_t offs, unsigned int size, void *dst) { - struct nand_chip *chip; - unsigned int page; + unsigned int sz; + unsigned int block, lastblock; + unsigned int page, page_offset; unsigned int nand_page_per_block; - unsigned int sz = 0; + struct nand_chip *chip; u8 *page_buf = NULL; - u32 page_off; chip = mtd_to_nand(mtd); if (!chip->numchips) @@ -235,47 +235,42 @@ int nand_spl_load_image(uint32_t offs, unsigned int size, void *buf) if (!page_buf) return -ENOMEM; - page = offs >> chip->page_shift; - page_off = offs & (mtd->writesize - 1); + /* offs has to be aligned to a page address! */ + block = offs / mtd->erasesize; + lastblock = (offs + size - 1) / mtd->erasesize; + page = (offs % mtd->erasesize) / mtd->writesize; + page_offset = offs % mtd->writesize; nand_page_per_block = mtd->erasesize / mtd->writesize; - debug("%s offset:0x%08x len:%d page:%x\n", __func__, offs, size, page); - - while (size) { - if (mxs_read_page_ecc(mtd, page_buf, page) < 0) - return -1; - - if (size > (mtd->writesize - page_off)) - sz = (mtd->writesize - page_off); - else - sz = size; - - memcpy(buf, page_buf + page_off, sz); - - offs += mtd->writesize; - page++; - buf += (mtd->writesize - page_off); - page_off = 0; - size -= sz; - - /* - * Check if we have crossed a block boundary, and if so - * check for bad block. - */ - if (!(page % nand_page_per_block)) { - /* - * Yes, new block. See if this block is good. If not, - * loop until we find a good block. - */ - while (is_badblock(mtd, offs, 1)) { - page = page + nand_page_per_block; - /* Check i we've reached the end of flash. */ - if (page >= mtd->size >> chip->page_shift) { + while (block <= lastblock && size > 0) { + if (!is_badblock(mtd, mtd->erasesize * block, 1)) { + /* Skip bad blocks */ + while (page < nand_page_per_block) { + int curr_page = nand_page_per_block * block + page; + + if (mxs_read_page_ecc(mtd, page_buf, curr_page) < 0) { free(page_buf); - return -ENOMEM; + return -EIO; } + + if (size > (mtd->writesize - page_offset)) + sz = (mtd->writesize - page_offset); + else + sz = size; + + memcpy(dst, page_buf + page_offset, sz); + dst += sz; + size -= sz; + page_offset = 0; + page++; } + + page = 0; + } else { + lastblock++; } + + block++; } free(page_buf); @@ -294,6 +289,19 @@ void nand_deselect(void) u32 nand_spl_adjust_offset(u32 sector, u32 offs) { - /* Handle the offset adjust in nand_spl_load_image,*/ + unsigned int block, lastblock; + + block = sector / mtd->erasesize; + lastblock = (sector + offs) / mtd->erasesize; + + while (block <= lastblock) { + if (is_badblock(mtd, block * mtd->erasesize, 1)) { + offs += mtd->erasesize; + lastblock++; + } + + block++; + } + return offs; } From patchwork Sun May 15 09:25:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Trimarchi X-Patchwork-Id: 1946 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 456943F18B for ; Sun, 15 May 2022 11:25:51 +0200 (CEST) Received: by mail-ed1-f72.google.com with SMTP id y1-20020a056402170100b0042aa8f679fdsf884780edu.1 for ; Sun, 15 May 2022 02:25:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1652606750; cv=pass; d=google.com; s=arc-20160816; b=ZqTvzibgByk9mdfWmx6KGUHZnGVsUaXbyp9EjbE+TOrNAeHo6jHukQCecCyUzZUnrN kGv8pqCWS2d9MOSTS+7YePikHnmZajuduucf+yxT4KxJYERsQ3v+ei0Kvgg6qwHwF5iU P1YBEmMDiuaYvaAiKktajfR2Mtq+QW7I023AeKK5KLSykG0/Msrh/RbL34q984GN+Ppo oT178eqQ0td6ZwwbPyytb6/miyjDitXsvxE8YcYnFsijyCXocsm98aD7UNS/c0r18vxG zLo0Qf5CsD3VVpFHyTVk4NsQUree4fymFcF7pzRV4a9Tt0DwOikQCLB2orK/+SJFhzyx LnWw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=H5C8SkiieAb2CjID/CKroqhZTkpoO9Nxn23UGdVre+4=; b=WTHXbKA71y13rztfYYLNEV8lIZlwAJnbMGFpOF7CMxCHG/mpOp95eTte3YTlROZInl YNNxMklCKzKydn7N79A7kuAxEy5GNvFrpHg3hMCPRBVBz54DoLRo4WfR1RR2Lwta1caw bEk+6LzsV7cyV0PeiRinZ6mh8X9HEhhcIRxGUsFIa0IkhFP82XFyuO8Sal16RrICU6Cl 0Yx6b5Zmg+WGPh3Z9nObxyZDnwgudpRbSh8ffQSytEgcRdF6ZbP+wbOC3Jfeht5N1Ek5 P9HY7oUgW0nLr/mTFsM9bEPeTydeCv3Ncr+Kl/TAXDwp9H9LCFC0viA0ZUmlwci/Wiw1 PTOg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="Fa/MCzAw"; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=H5C8SkiieAb2CjID/CKroqhZTkpoO9Nxn23UGdVre+4=; b=Pv6rhxaIXrfnzDwXPPRHge0HciPVdA52HzX+7AXDX4f3opM1pY5tsx0HmE9Ur4uTwx jOPGJadgk23bobOtfhSuh/0bgMJz9Wr9/OdbaxSfu5gCzeuV7CYILv0iIvMNxL+Tv64n QWaPQPRgxq45q63lRbykaVInAF7s9M2QPv3hc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=H5C8SkiieAb2CjID/CKroqhZTkpoO9Nxn23UGdVre+4=; b=yacPPc+iP5I9RlVaOVajE76poIYjHQbWrnpy+7AqfrzuHZUWDHzOuS1Cz2JH/zHKEm g1v0SKGME09IueZaBPa2ZunArCldRL62ZIXKSYFBG6UB3UkAri56dg7APWPHx9YbmHoG 7LEnP1oVoq8+4CjPrps5x0bQpfWGYaBu1mEoE+3/vwkDfBzf+IAiEwZjKscDhGDjjCt2 SFUZsXnjaRNQEWzegAk2gXhgNsNK2Q678q6MOTQjkv7CAXR0pnqBr4XX1d7cBsOmMPFo Ui8oLDj4tivcv4uASXn3OdLVyfck30dtvgczcGuziYmlkCaJV7KYedmvWYtvLxKhyWOA ipGw== X-Gm-Message-State: AOAM533ucrhcYia2DJqrOfSAT1r6qH9BkrrkbeCUTvB9MeE1Z71Q2vWO x+Tjq+t3yILFl6DLvS3H1HMDWRbn X-Google-Smtp-Source: ABdhPJyRvUnygKdIy5RcoJZy7BaeoeurL7IoVauK5ty210HTPzmrg3FGGWztmvjn5ckMzOWeXSJobA== X-Received: by 2002:a05:6402:5113:b0:427:f443:f63e with SMTP id m19-20020a056402511300b00427f443f63emr7506076edd.317.1652606750797; Sun, 15 May 2022 02:25:50 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:907:1b28:b0:6f3:ea95:a02b with SMTP id mp40-20020a1709071b2800b006f3ea95a02bls5989998ejc.9.gmail; Sun, 15 May 2022 02:25:49 -0700 (PDT) X-Received: by 2002:a17:907:7dab:b0:6f4:6650:395d with SMTP id oz43-20020a1709077dab00b006f46650395dmr10862191ejc.82.1652606749468; Sun, 15 May 2022 02:25:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652606749; cv=none; d=google.com; s=arc-20160816; b=Vp7L+IFXjHosrv9xj3QIBM/UbesfhpxRkA5AO4MsVc0GpUik1+zASHmXG3wofmwW1N SB7YIQnSSOVDQO5vUp2Atl6ASsvwmbXkBDZIpl0Kzm8oWNYDDsFeePONG8AXe6LqH9bH OC37DXlAUcwjxzZlWtlNBUnptUFFbPh2FVytIJqXrFdgJX2y0LSr++Qh8XdikE6Y8GVE smVhOAxwrLbQBb8Zu6v0ah97pJqOCwbOgxVvwh6bMfUQs9um0dNE/nMXtwBCxU0yKoMf 5Q9zgLJTX1RKDaas9ws0iV8YBVGd/9IBG3hQXNSZLOcnks5x4QQ5ImdSWe3GyoNspVh5 aZ+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=l77AqYbMqx7fcUmAt1Nphq7xS9njuYv1XHAQ4YODQ3w=; b=EW0Of6nhA+80Mu6KKYjM+R3GTvhWy+JN7+XG3bVUrGV/t1ieiHppM86QwJIyasjeNu 8nVjNZV2xdXhHz2NkN/JwNgEsPymWHXNinO0T0wRX7qLS7CIN7jVSytGsahjisLpzDxF 3Bt1K4C71T5VC3RZPAPslxAloUfMdNDy96m0LxDEFJsDPB2no0P5+a12ewUKM5qVVlGh P2xbLcbnJnFEw+KDX63u+s8UD4dyX2YjdGCGBBXMq0QGFAVZGOVv87OQjD9lF6iVCnz8 FDzn/TzJ7lVyHZ0awAH7Tk/anfdEo3HlgV78RcELxfaugfpIq6Qy8qKEb0b2NP9FZMFq y+bQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="Fa/MCzAw"; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id j18-20020a170906535200b006e4e1b35024sor2591509ejo.38.2022.05.15.02.25.49 for (Google Transport Security); Sun, 15 May 2022 02:25:49 -0700 (PDT) Received-SPF: pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a17:907:62a2:b0:6e0:e201:b94e with SMTP id nd34-20020a17090762a200b006e0e201b94emr11056559ejc.730.1652606749123; Sun, 15 May 2022 02:25:49 -0700 (PDT) Received: from localhost.localdomain (mob-109-118-140-232.net.vodafone.it. [109.118.140.232]) by smtp.gmail.com with ESMTPSA id m17-20020a17090677d100b006f3ef214dc5sm2509888ejn.43.2022.05.15.02.25.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 May 2022 02:25:48 -0700 (PDT) From: Michael Trimarchi To: Han Xu , U-Boot-Denx Cc: Ye Li , Stefano Babic , Miquel Raynal , Fabio Estevam , Dario Binacchi , Sean Anderson , linux-amarula@amarulasolutions.com, Jagan Teki , Ariel D'Alessandro , Tom Rini , Tim Harvey Subject: [PATCH V3 3/5] arm: mach-imx: cmd_nandbcb fix bad block handling Date: Sun, 15 May 2022 11:25:36 +0200 Message-Id: <20220515092538.1736154-4-michael@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220515092538.1736154-1-michael@amarulasolutions.com> References: <20220515092538.1736154-1-michael@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: michael@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="Fa/MCzAw"; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The badblock should be skipped properly in reading and writing. Fix the logic. The bcb struct is written, skipping the bad block, so we need to read using the same logic. This was tested create bad block in the area and then flash it and read it back. Acked-by: Han Xu Tested-By: Tim Harvey Signed-off-by: Michael Trimarchi --- V2->V3: - Add tested-by from Tim - Add ack from Han Xu V1->V2: - Adjust the commit message - Add Cc Han Xu and Fabio - move out from RFC --- arch/arm/mach-imx/cmd_nandbcb.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/arch/arm/mach-imx/cmd_nandbcb.c b/arch/arm/mach-imx/cmd_nandbcb.c index f119e9f88d..c54f52b343 100644 --- a/arch/arm/mach-imx/cmd_nandbcb.c +++ b/arch/arm/mach-imx/cmd_nandbcb.c @@ -506,10 +506,6 @@ static int read_fcb(struct boot_config *boot_cfg, struct fcb_block *fcb, int ret = 0; mtd = boot_cfg->mtd; - if (mtd_block_isbad(mtd, off)) { - printf("Block %d is bad, skipped\n", (int)CONV_TO_BLOCKS(off)); - return 1; - } fcb_raw_page = kzalloc(mtd->writesize + mtd->oobsize, GFP_KERNEL); if (!fcb_raw_page) { @@ -530,7 +526,7 @@ static int read_fcb(struct boot_config *boot_cfg, struct fcb_block *fcb, else if (plat_config.misc_flags & FCB_ENCODE_BCH_40b) mxs_nand_mode_fcb_40bit(mtd); - ret = nand_read(mtd, off, &size, (u_char *)fcb); + ret = nand_read_skip_bad(mtd, off, &size, NULL, mtd->size, (u_char *)fcb); /* switch BCH back */ mxs_nand_mode_normal(mtd); @@ -617,6 +613,7 @@ static int write_fcb(struct boot_config *boot_cfg, struct fcb_block *fcb) for (i = 0; i < g_boot_search_count; i++) { if (mtd_block_isbad(mtd, off)) { printf("Block %d is bad, skipped\n", i); + off += mtd->erasesize; continue; } @@ -676,20 +673,15 @@ static int read_dbbt(struct boot_config *boot_cfg, struct dbbt_block *dbbt, void *dbbt_data_page, loff_t off) { size_t size; + size_t actual_size; struct mtd_info *mtd; loff_t to; int ret; mtd = boot_cfg->mtd; - if (mtd_block_isbad(mtd, off)) { - printf("Block %d is bad, skipped\n", - (int)CONV_TO_BLOCKS(off)); - return 1; - } - size = sizeof(struct dbbt_block); - ret = nand_read(mtd, off, &size, (u_char *)dbbt); + ret = nand_read_skip_bad(mtd, off, &size, &actual_size, mtd->size, (u_char *)dbbt); printf("NAND DBBT read from 0x%llx offset 0x%zx read: %s\n", off, size, ret ? "ERROR" : "OK"); if (ret) @@ -697,9 +689,9 @@ static int read_dbbt(struct boot_config *boot_cfg, struct dbbt_block *dbbt, /* dbbtpages == 0 if no bad blocks */ if (dbbt->dbbtpages > 0) { - to = off + 4 * mtd->writesize; + to = off + 4 * mtd->writesize + actual_size - size; size = mtd->writesize; - ret = nand_read(mtd, to, &size, dbbt_data_page); + ret = nand_read_skip_bad(mtd, to, &size, NULL, mtd->size, dbbt_data_page); printf("DBBT data read from 0x%llx offset 0x%zx read: %s\n", to, size, ret ? "ERROR" : "OK"); @@ -729,6 +721,7 @@ static int write_dbbt(struct boot_config *boot_cfg, struct dbbt_block *dbbt, if (mtd_block_isbad(mtd, off)) { printf("Block %d is bad, skipped\n", (int)(i + CONV_TO_BLOCKS(off))); + off += mtd->erasesize; continue; } From patchwork Sun May 15 09:25:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Trimarchi X-Patchwork-Id: 1947 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 8F9F83F1F5 for ; Sun, 15 May 2022 11:25:53 +0200 (CEST) Received: by mail-ed1-f70.google.com with SMTP id q12-20020a056402040c00b0042a84f9939dsf1826017edv.7 for ; Sun, 15 May 2022 02:25:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1652606753; cv=pass; d=google.com; s=arc-20160816; b=ZVpz2RE5y6m7lkBbgqzLWpbQAeWC12mbVeUq3BuJ4M0ZpkukeZzXoklati/KnhrTyx aJSm9uKqby2XvIi9au9nWUOOGHPDqGZe1v49SB4psfeShzcUPjmANWxHpzfAmJFwMz/l i5PQs8wI9dCVND3GkhMg/xti1uYKgQkf1g23B+hGdQgGsXGSBckCL2RLJFcsFrv2xbuN cLaolPbmit7KzRrig3+UFgtEWQeL3qxX2nlHy9CbryAbWpAdmNqht46wYUOtTjjiwW70 8Ks+I8ERzSbhbcya4c67ro33A0pyHxDGcKRhQ9UxXwP6Ojp2q0DCwVmKG+O9HwMG+rAl Pqmg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=vE6epefha6srk2Mh1iKxygWCmicQCXoIgd0ZBNYiLnk=; b=WSVs39Nr170GWzF5PfLHsL6wr9adVbznCZzHFOFYhUj1f5KK5gnLiD3lj1czufP330 CzB/owpKvolJy4ePxhnrXl8QNms4JkmeEhRKDxIlc6D0YOg5X3yIejfxNW+lEngoMl7Z s2+3u0gxvS1QkWG2oNmrvJ3/fAR/OMtkjLkmezL22U7RP4pmv6ySg8k0TI3rpu64K+AF 1uVpViJzg91J3bekq1Po2BmPZQZVwhp3jOw1VC+3IXDnj9MjhmWhJ6w0YzLm50VbS1LC K0GHPZtEQdzdm7XFG7ibMzeWsMVOzu4iiiICBdiyeJkAEAFednfy1f74+hBKt4lO1S94 XIAg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=E+PF5PFZ; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=vE6epefha6srk2Mh1iKxygWCmicQCXoIgd0ZBNYiLnk=; b=LPA+vKhxHeGMJLbqQmOOBvnxjRvo3bukVVs0TbXFUTdGjoaRAileOKbqh0pekxnYHc etY2p5fIqcWDGR0Mv57uUF0iompQiodnRNwWW4ERHr6eR8Zcdr8+Q3GZinhzC8sR/pFo bZrrIVPb+3MHVHbSSU/A8VbD2AWSUD5H+b33w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=vE6epefha6srk2Mh1iKxygWCmicQCXoIgd0ZBNYiLnk=; b=s/CQehhTZbvgTlGXqunEYglyyajAnTIUxTb02GyKw/0b6JFC/eGqksUPLQ4UX9GDbW ODLcRBustnfpjhh6EDhDYDmimepueLxgxtXNq/WFBFm5qlKeik+5FlQJOOiw+agTXMIV YkFCLTPckz2/Z4nK363/14tRCPXHHfU0+Y4itOgwYMo94DSwB39bvkTG7IjZwMNCu+b7 NyTratXnHITvwJ1Y0Sn87IOoHk+3SOYOOcamWeXiX6RLQcj0RYOY3sPWhQX09V5/rSO2 fABOqjod0mtL5SrKMzdt3stneMRex4LzzWPs3pzKJKGqtuq6+XMHGbOWK6+jKVeePnp5 ZbMQ== X-Gm-Message-State: AOAM530f0dcg79h4B53ZNhN0Bdk5mUKjXx3aY8kHAaALQDQhtGQX9N3+ 7TnBMEowVDvTejxPDeKn67GhAhNI X-Google-Smtp-Source: ABdhPJzjqnW93IVUBR0IcVL0rm8FuyvgbnHiQeYPAIX6Q/PlcXeEzPlrVCeLZWofMFc34PMvYR/fmg== X-Received: by 2002:a05:6402:40c5:b0:427:af77:c10c with SMTP id z5-20020a05640240c500b00427af77c10cmr7593185edb.387.1652606753091; Sun, 15 May 2022 02:25:53 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:907:6e09:b0:6f3:ead4:abc6 with SMTP id sd9-20020a1709076e0900b006f3ead4abc6ls5995051ejc.5.gmail; Sun, 15 May 2022 02:25:52 -0700 (PDT) X-Received: by 2002:a17:907:7f9e:b0:6f4:d3d0:8d8e with SMTP id qk30-20020a1709077f9e00b006f4d3d08d8emr11232114ejc.501.1652606751671; Sun, 15 May 2022 02:25:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652606751; cv=none; d=google.com; s=arc-20160816; b=L6tK//SW+vYDEXzRmoss3xznuTfQzI4UFu/q9uhOaei6PEuiFWH1Lp+sPKk9gpQVn+ EOScP1AlEwIw8rtASItCJeKAOo3dmLRLIjvnxtFulLHjp+JT2j+WUxBUQrdL3fqgi0aB GqWEovtU33Qj0MHT9pwE4qFlOGrFTYNHZR0SRrVDrWPrsXnqIhs3YENWgHSriA2ozyHv As8OwSo1FYYV4wG347xic48/IrlUXCRrk6w+R41vnQi1zzdbyPPrBq7kM4I9FPwk8XbA 5t/nsNn0QrfQeA+jlIzZvRhkqzgfRZKpQOrg713m9K7K9PlfyWoqKBJuNqzMkZ3stKe7 T70w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=Lqpc+4C+2iXEt08Np8F5Se0LUURUGSaGVqPRbJIufRg=; b=g6J6OzKkm47JjRM+kAZnKzEdFuvhm9y0LxdTDWcFnhym8G6/ICq8ztTVY+NHsMusVB SVZFkiJOg6YMnJYZCvP2COdnJYg1etqbN/N2vRMHy0xWtgJv4GkHsY0WT6upbxmPhprB WZO7a8XqGIhwjqEZDAn2y5XPqt2vwuzshzMP6eVTd3Ki/dCP77yvHueAl52DATcmzJjk 2yHnfRmCjf3rzaEa7MPUEt2wR/XoYqcaRN0sJBr5fDTcDVnZx4j3N/1gG8AhMNttzcEp 2A7qVKNKRAA+7YXIt/Z3cgzC4IV5eSOWXoJ8LbiO0WfYoNtIesHYVyxZe68zm2S67aQV aeSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=E+PF5PFZ; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id y29-20020a170906519d00b006f3957492a1sor2444399ejk.122.2022.05.15.02.25.51 for (Google Transport Security); Sun, 15 May 2022 02:25:51 -0700 (PDT) Received-SPF: pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a17:906:3a45:b0:6f4:e9e7:4ff with SMTP id a5-20020a1709063a4500b006f4e9e704ffmr10990920ejf.100.1652606751407; Sun, 15 May 2022 02:25:51 -0700 (PDT) Received: from localhost.localdomain (mob-109-118-140-232.net.vodafone.it. [109.118.140.232]) by smtp.gmail.com with ESMTPSA id m17-20020a17090677d100b006f3ef214dc5sm2509888ejn.43.2022.05.15.02.25.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 May 2022 02:25:50 -0700 (PDT) From: Michael Trimarchi To: Han Xu , U-Boot-Denx Cc: Ye Li , Stefano Babic , Miquel Raynal , Fabio Estevam , Dario Binacchi , Sean Anderson , linux-amarula@amarulasolutions.com, Jagan Teki , Ariel D'Alessandro , Tom Rini , Fabio Estevam , Tim Harvey Subject: [PATCH V3 4/5] spl: spl_nand: Fix bad block handling in fitImage Date: Sun, 15 May 2022 11:25:37 +0200 Message-Id: <20220515092538.1736154-5-michael@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220515092538.1736154-1-michael@amarulasolutions.com> References: <20220515092538.1736154-1-michael@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: michael@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=E+PF5PFZ; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , If the fitImage has some bad block in fit image area, the offset must be recalulcated. This should be done always. After implementing it in mxs now is possible to call the function even for that platform. Cc: Fabio Estevam Tested-By: Tim Harvey Reviewed-by: Tom Rini Signed-off-by: Michael Trimarchi --- V2->V3: - Add tested-by from Tim - Add ack from Han Xu V1->V2: - move out from RFC --- common/spl/spl_nand.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/common/spl/spl_nand.c b/common/spl/spl_nand.c index fc61b447a5..82a10ffa63 100644 --- a/common/spl/spl_nand.c +++ b/common/spl/spl_nand.c @@ -43,15 +43,12 @@ static ulong spl_nand_fit_read(struct spl_load_info *load, ulong offs, ulong size, void *dst) { int err; -#ifdef CONFIG_SYS_NAND_BLOCK_SIZE ulong sector; sector = *(int *)load->priv; - offs = sector + nand_spl_adjust_offset(sector, offs - sector); -#else offs *= load->bl_len; size *= load->bl_len; -#endif + offs = sector + nand_spl_adjust_offset(sector, offs - sector); err = nand_spl_load_image(offs, size, dst); if (err) return 0; From patchwork Sun May 15 09:25:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Trimarchi X-Patchwork-Id: 1948 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 5746F3F18B for ; Sun, 15 May 2022 11:25:55 +0200 (CEST) Received: by mail-ed1-f71.google.com with SMTP id ay24-20020a056402203800b0042a96a76ba5sf1715105edb.20 for ; Sun, 15 May 2022 02:25:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1652606754; cv=pass; d=google.com; s=arc-20160816; b=lZTSe//U5yklExj5V+Ol3qzugyL6SAj518xMRlIup5pOliMtoIEhjtP6egpDvLeryo Zy+0kqVcL746E7Mo/hmI1yFv9T+rpxfpHsdnaIwxJDMl5sSvFm2AD8VbokBCVT9JJhlg gJSU5WRf1tfpsr3sR3WzJiLxe/TnEV5YKv+x0aXHkkS2UGPMB3/46JITEuAveW0tf1p9 K6TwLWMY7RgNpwmWgk+aljor+VYDUTmR/LlUf7D7M9YdmjoXdmw+0Ba1oj0B1Ns38Acx tzqo2HK0TqrdKHvkt1snoQZgKFSEFbYD7URMIZf7dKg/P7XSe969YXC84f217UlJd4go F1cw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=+ovTP/Nuk3eBMS5p4dBTLJ7I0XEVw5i8DJQpOSiy9KY=; b=wHI8YdMCQLKyuDjwMlL0RYeQ9t3kOCtRE7NGtdiai5DZ0suE5YOwonyIg7VoLOr2iG r11Q/dkPrtw44NpJZ56W+IFBa6t7ye1AZDexT1xsvKeerXC1kneR2Zygw5cRq9e48WD2 gb9/R2vrDhm3UIxfK0OesQTAatB/OYLy+kXOkOf4m8b8dt9KiGDyLmhZVcD4SPN09qW9 a3UZ1cQ9cOLBeUPr/Tef3kyj2rEy9S0HFh2wfRo4qQLhrR8G5k8UXL7N7lTXnuFLjnF/ 2D9t4PkL5pLxNS2Upg8EHLp2jbEBrkHGtGQ7gZS+m/YFypozUWvZhF5ssSxuM0ZOAcKt kGHQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=agXqkaKY; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=+ovTP/Nuk3eBMS5p4dBTLJ7I0XEVw5i8DJQpOSiy9KY=; b=Z3LqnrMf+g/ihgLbIws0R7qSbwObXsNLfaXCQetRiR71amtLQiWLwSbso1IF17j3iA UX9VB07ngrtE6s0CwnsUDlcjyDnzt/Ike+nykaOf/rczi4v6eP8kKPseSXnRw+fsSnzY 4N4AI9Djm6XvrytDnD+O5qMERxlsrH8mr3l0I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=+ovTP/Nuk3eBMS5p4dBTLJ7I0XEVw5i8DJQpOSiy9KY=; b=NfRFqYLYgQrtVUX2M3v0Jz6NKrfzC8D0uii81drv5ea+tE4bFY4ExcYfO82v6nCJdB SrZd3x3Otvi4COehZErcPF/SgJwLQ272Dx8HS5+VUFgQZeNSIv3gX1U+1I5idJYbfQAV tkPXub7AHd9I3qdKO5GxR5LziRq/7o4roGRLk9WEWQrdsJjH/dkv7Gv5nwjfV2MKVLKJ qKSiCTDj81s750ovgx6KL6sozGX+7hQDH6uuD3shF0zWQhBz1NVFgtoNkID0yu2gz88K xovnY0g0ZKN6Cbw8OBl4PAkamf/XA8T1W43V8GyYSVN5gUA68B6Yoq54rbvDTlDbZv3A SS7g== X-Gm-Message-State: AOAM532XKmfIBHMCN+Y4KPhSXPFpOrMmP4bwp5i8E1O55FMxeJnKKiwO R7SoLgRC9AYj7MzTHS3Cy6GgtQ0w X-Google-Smtp-Source: ABdhPJzIuFwkwFAkhPwzFdpljh2t62W9/H60BTN7q80QrnhPpkbtM/WP7ufb6eetiJsNNTdXjv9vog== X-Received: by 2002:a17:907:d8b:b0:6f4:99e5:78f with SMTP id go11-20020a1709070d8b00b006f499e5078fmr10829129ejc.37.1652606754818; Sun, 15 May 2022 02:25:54 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:26d2:b0:428:f87:ccd8 with SMTP id x18-20020a05640226d200b004280f87ccd8ls3091959edd.1.gmail; Sun, 15 May 2022 02:25:53 -0700 (PDT) X-Received: by 2002:a05:6402:5413:b0:42a:adef:b360 with SMTP id ev19-20020a056402541300b0042aadefb360mr958718edb.122.1652606753609; Sun, 15 May 2022 02:25:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652606753; cv=none; d=google.com; s=arc-20160816; b=EKJNlJBZ/YSGgP5uuo2p5ndOOaHkK47DzEDDxXDRIgHrUJpzUJ3HDNhoukzC7R2gUr vYqrFmGAF/xHu6tKXqDnxEqdtjENFWL5avGUBxYHW0Kxa52IOOvJreBktoo4vY2knWs4 gfxssHy9PZ5SilVR421XOJ1FioeVCASXjOCRM6jbjySSNe5DqZMKofJRw2xjYOosxIaW sxfNKK2khhoHuJivHwH7PSY1u0mEMEQcDQSAW0Gh9DEgCf5K22v9RfxJQ8ojmWyaBUaV qsz8AoxSI+o6yAJY1pd0d17Gy2+h2jZv4KhUYV66H7mWagiS7gtNsGvdD4M/holZqzPr pgQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=DAT1p9zvkasU+WLS+OJcn3KlBC2sHgpNgRKfH6x1mzU=; b=sBo8b9osQKzB2QORX6w5+IQW7ZENJvtemBe0ntSEyLntUAF47G21Wjhn/kDvFodS2U zODfS0J//tQVj/TZ0PUtneYraM16FN0dL54KU9n7w+3po3iaVpoWEH1dsQ/9JwI+Jin4 6tYFLMq5l0uO6BalKC35iDtdc9kOZ8KHWRDwXKumuwJlDYGllAJ73sLtTvhlRKkm0nBj 6ljA5S8mZZm+rAp0aT8UG4zWqykl/GF28Xo25TGzdNeyMzH2SHLn/ftc4D1HrhvO+0/n 4Lgtr42QgHZ5/P3Ohs60yEd2TZHluU6949Y9IpofzPOpn6GEflcBo0G9S5+BH1NT3GLl SPxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=agXqkaKY; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id y8-20020aa7d508000000b0041cd124088asor3521257edq.31.2022.05.15.02.25.53 for (Google Transport Security); Sun, 15 May 2022 02:25:53 -0700 (PDT) Received-SPF: pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:aa7:d791:0:b0:42a:62a7:a1bd with SMTP id s17-20020aa7d791000000b0042a62a7a1bdmr7387127edq.247.1652606753367; Sun, 15 May 2022 02:25:53 -0700 (PDT) Received: from localhost.localdomain (mob-109-118-140-232.net.vodafone.it. [109.118.140.232]) by smtp.gmail.com with ESMTPSA id m17-20020a17090677d100b006f3ef214dc5sm2509888ejn.43.2022.05.15.02.25.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 May 2022 02:25:52 -0700 (PDT) From: Michael Trimarchi To: Han Xu , U-Boot-Denx Cc: Ye Li , Stefano Babic , Miquel Raynal , Fabio Estevam , Dario Binacchi , Sean Anderson , linux-amarula@amarulasolutions.com, Jagan Teki , Ariel D'Alessandro , Tom Rini Subject: [PATCH 5/5] board: bsh: Switch to nand spl load instead of romapi Date: Sun, 15 May 2022 11:25:38 +0200 Message-Id: <20220515092538.1736154-6-michael@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220515092538.1736154-1-michael@amarulasolutions.com> References: <20220515092538.1736154-1-michael@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: michael@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=agXqkaKY; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , romapi is not eble to skip bad block so we need to workaround using the spl Signed-off-by: Michael Trimarchi --- board/bsh/imx8mn_smm_s2/spl.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/board/bsh/imx8mn_smm_s2/spl.c b/board/bsh/imx8mn_smm_s2/spl.c index 0f61acc630..e778cd16c4 100644 --- a/board/bsh/imx8mn_smm_s2/spl.c +++ b/board/bsh/imx8mn_smm_s2/spl.c @@ -18,6 +18,9 @@ int spl_board_boot_device(enum boot_device boot_dev_spl) { + if (IS_ENABLED(CONFIG_NAND_MXS) && get_boot_device() == USB_BOOT) + return BOOT_DEVICE_NAND; + return BOOT_DEVICE_BOOTROM; }