From patchwork Fri Oct 21 06:05:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Nazzareno Trimarchi X-Patchwork-Id: 1692861 X-Patchwork-Delegate: dario.binacchi@amarulasolutions.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.a=rsa-sha256 header.s=google header.b=eMdeStnz; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Mtv8s53MTz23kD for ; Fri, 21 Oct 2022 17:05:49 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7689184FC2; Fri, 21 Oct 2022 08:05:44 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.b="eMdeStnz"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3AD8284FBA; Fri, 21 Oct 2022 08:05:42 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) (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 C453584F93 for ; Fri, 21 Oct 2022 08:05:39 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=michael@amarulasolutions.com Received: by mail-wm1-x331.google.com with SMTP id v11so1521363wmd.1 for ; Thu, 20 Oct 2022 23:05:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=QRyTLi2eGdJNwnU0PFd237jU+vsCUUG3kL7vX2o+Ehw=; b=eMdeStnzDoW3KMVFT0LRwPm/5Odmlbt1MHXbJPWR4zddAD81tkbYTwZrXeutGpK4M0 bcxWjGG6hJBw05emmbMyv2b7kri5QBAL1HvkORgE7vufy335dxIsjdKAz13RsxPKJjSe jJ4DuKQpPvqB1HHxk6ywGFHXGKNRR+naJ++os= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=QRyTLi2eGdJNwnU0PFd237jU+vsCUUG3kL7vX2o+Ehw=; b=5DbIVjU8janNpvNOLB9pjMqEw7nbRY1XAxwgRHBarAhxjyUSlr57FIWLW8Do9t1hlk yLpnop5Ga0meGAkFH2/orsiRa6P1HHPiniyOniPJsvYbG35jCK+nuyKW3HjUr/5NNTsA z1xtCqQw3wsNUFwuCO9Y//gaIS0Tw4KWbxCI8cB6cplYzDk9wzbITDGpo6cTN/w1ymVT KJNFngVmF6VIBNvW2c5CVJhDR8Wrk2Vh2bcCZKFIKNvByPkhv0tD5thzCPHWx+N7QGXN ewTtKX9mNBvjfy4Dp4S2FXSSc9ebrsrEvn9wQhJvA3meIujqeS1IAJcJ/LxhYgctmSZ1 fQ+g== X-Gm-Message-State: ACrzQf3vs9dF6HR4GWgnhFnSSupT/uKl3r0I7AROygf/8KWkEYeriEuY YkHncoBXB7oGS4Ohhcuhlm4gAg== X-Google-Smtp-Source: AMsMyM6VuRKALNF6u4iEN/pkr04ITc+FQAy5DNiWZSg34HcmWW1OoxRa+60D8Oe9yPEnk3uAhKCFFw== X-Received: by 2002:a05:600c:46ca:b0:3c6:f3e3:df99 with SMTP id q10-20020a05600c46ca00b003c6f3e3df99mr11644719wmo.77.1666332339152; Thu, 20 Oct 2022 23:05:39 -0700 (PDT) Received: from panicking.. ([5.171.212.88]) by smtp.gmail.com with ESMTPSA id r10-20020a5d52ca000000b0022e653f5abbsm18438255wrv.69.2022.10.20.23.05.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Oct 2022 23:05:38 -0700 (PDT) From: Michael Trimarchi To: Dario Binacchi Cc: u-boot@lists.denx.de, =?utf-8?b?TWFyY2luIEdvxYJhxZs=?= Subject: [PATCH] mtd: nand: make Samsung SLC NAND usable again Date: Fri, 21 Oct 2022 08:05:36 +0200 Message-Id: <20221021060536.11747-1-michael@amarulasolutions.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.6 at phobos.denx.de X-Virus-Status: Clean Upstream linux commit 69fc01296c9281 commit a1286a1fc416 ("mtd: nand: Move Samsung specific init/detection logic in nand_samsung.c") introduced a regression for Samsung SLC NAND chips. Prior to this commit chip->bits_per_cell was initialized by calling nand_get_bits_per_cell() before using nand_is_slc(). With the offending commit this call is skipped, leaving chip->bits_per_cell cleared to zero when the manufacturer specific '.detect' function calls nand_is_slc() which in turn interprets bits_per_cell != 1 as indication for an MLC chip. The effect is that e.g. a K9F1G08U0F NAND chip is falsely detected as MLC NAND with 4KiB page size rather than SLC with 2KiB page size. Add a call to nand_get_bits_per_cell() before calling the .detect hook function in nand_manufacturer_detect(), so that the nand_is_slc() calls in the manufacturer specific code will return correct results. Reported-by: Marcin Gołaś Signed-off-by: Michael Trimarchi --- drivers/mtd/nand/raw/nand_base.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c index 215b9ba84f..bc61ad03eb 100644 --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -4171,10 +4171,13 @@ static void nand_manufacturer_detect(struct nand_chip *chip) * nand_decode_ext_id() otherwise. */ if (chip->manufacturer.desc && chip->manufacturer.desc->ops && - chip->manufacturer.desc->ops->detect) + chip->manufacturer.desc->ops->detect) { + /* The 3rd id byte holds MLC / multichip data */ + chip->bits_per_cell = nand_get_bits_per_cell(chip->id.data[2]); chip->manufacturer.desc->ops->detect(chip); - else + } else { nand_decode_ext_id(chip); + } } /*