From patchwork Sun Jun 24 20:53:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 10484855 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C7F266023A for ; Sun, 24 Jun 2018 20:55:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B2AA228567 for ; Sun, 24 Jun 2018 20:55:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A7388286A7; Sun, 24 Jun 2018 20:55:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2306B28567 for ; Sun, 24 Jun 2018 20:55:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=2siB7oyCwaS78jO/78Nil5PGPAnFrNziKESkrJ3TqE4=; b=J/d01u1HS7uzey05vanfeWvpzS p9wqGMYeQwkTxVnh57pXQ8GvBam0XRXHgu6wDW9AmWLOBCWB/6Gfr6616vx9LKH4y++t2rHUDhThW QXDnnsVPxrP4W7y4umzR0naXyKsMxCoXc/wE6suD9MrEU8ISXauOvxbBrLJMvGsScFE7pRyk+WUtY LgSo4UN3AS/jCs+0qcGfcPukLlIfM5bD87cHVbmZR7omVe76P1Fo96xkjOnmVzV+VehHnk69znri7 iJmFVxM1dIkHYRHpRoqTTXAKvK8mhRNA70BSCS8fu7afz9PK7dIazrDwbwwyQBDa3xXWF5Q0AFzM4 sW5W9Q8A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fXC2W-0001XP-DE; Sun, 24 Jun 2018 20:55:16 +0000 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fXC1b-0000bF-JZ; Sun, 24 Jun 2018 20:54:21 +0000 Received: by mail-wm0-x241.google.com with SMTP id e16-v6so7051623wmd.0; Sun, 24 Jun 2018 13:54:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=yO5RYOHtYmX3HA/BDzAD7fJMie0GLQ0c7Gnq7ZD8tYs=; b=Qw3MLltujRXPtawVJjXK5Spd4+VlqtaxOcWgbb3erEt9W3T1Jh5G8Inu9y3rd/ygsF SOTN3ewWOwqNlmVVXhk2jHZ7srNkccGvePDO78briLzy7ghFCbmFRpwOexOTQfdLEQlY B7Ad0PqpLs0CotL/fDmhOXoK7L+xPv0BHsDIUbbprnC4IPfLUpooNaINaUopDOfL/QnB MjB+pyPFcLCzmXAhNk93vTooJxlRuftZEcUEBdMzN9jz54LORHlPVP6B9ZUTBddPPdsS zZ+Lgtk8Xmz4xrZINxDeHmhUjnHRJK4cCkVT+Iez5UJeYvwZ3YxyBdBo0Wp8NhCQ+oYU m/Vg== 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:in-reply-to :references; bh=yO5RYOHtYmX3HA/BDzAD7fJMie0GLQ0c7Gnq7ZD8tYs=; b=dPvPFAj/n5MmW25/n/kmZpmsatAxJTSwVgwHK0tovnLqZr0hv+0ITa4BISTk54E6Sa jXkI2o6eMg22ZX4MQGy3CVOEBQWrc1IZ8GXiaOY6vjbiUke7Ujow6ApjXq5otL9bB6ru Dud50DKgNZfedgFBRDvv+5vXWZPyc8BvvHtdyyBwYvevfuspKBR0C9DGYWSVqHNRDI6X XPyKI0Lrb4/trisiHTCsDNPITAxXMAAktwKm8/aaIarKHsL4nSiw9zD/cBXzCjuG6U/g oNK42UeJMDb97HC3+hR0d9MoGVOq94yEPq8VuSFVyNxmZ2CmiyAj0az4P8AKFvb5zz+Q qOcA== X-Gm-Message-State: APt69E2mONIrGa72J+VC/IK1k0rnqkJarL99hXd+fzLIa5FqN5qCW8Sx xiC8hN8pfwJauuyJ2gw5cOCwjhng X-Google-Smtp-Source: ADUXVKKBClsExjp58XpllC73nuhms2n7URwh+9fyECtZ3bC2J+Kscjr00zLJ0YFrCP3fOUJ9N6C9Ww== X-Received: by 2002:a1c:cbc2:: with SMTP id b185-v6mr2153504wmg.117.1529873648555; Sun, 24 Jun 2018 13:54:08 -0700 (PDT) Received: from blackbox.darklights.net (p5DE38BB3.dip0.t-ipconnect.de. [93.227.139.179]) by smtp.googlemail.com with ESMTPSA id g88-v6sm9815347wmc.27.2018.06.24.13.54.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Jun 2018 13:54:07 -0700 (PDT) From: Martin Blumenstingl To: linux-mtd@lists.infradead.org, boris.brezillon@bootlin.com, richard@nod.at Subject: [PATCH v2 1/1] mtd: rawnand: hynix: fix decoding the OOB size on H27UCG8T2BTR Date: Sun, 24 Jun 2018 22:53:55 +0200 Message-Id: <20180624205355.20060-2-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180624205355.20060-1-martin.blumenstingl@googlemail.com> References: <20180624205355.20060-1-martin.blumenstingl@googlemail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180624_135419_671527_598C5238 X-CRM114-Status: GOOD ( 14.37 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Martin Blumenstingl , yixun.lan@amlogic.com, marek.vasut@gmail.com, liang.yang@amlogic.com, miquel.raynal@bootlin.com, linux-amlogic@lists.infradead.org, computersforpeace@gmail.com, dwmw2@infradead.org MIME-Version: 1.0 Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The datasheet of the H27UCG8T2BTR states that this chip has a page size of "16,384 + 1,280(Spare) bytes". The description of the "4th Byte of Device Identifier Description" indicates that bits 6, 3 and 2 are encoding the "Redundant Area Size / 8KB", where 640 bytes is a value of 0x6 (110 in binary notation). hynix_nand_extract_oobsize decodes an OOB size of 640 bytes for this chip. Kernel boot log extract before this patch: nand: Could not find valid ONFI parameter page; aborting nand: device found, Manufacturer ID: 0xad, Chip ID: 0xde nand: Hynix NAND 8GiB 3,3V 8-bit nand: 8192 MiB, MLC, erase size: 4096 KiB, page size: 16384, OOB size: 640 However, based on the description in the datasheet we need to multiply the OOB size with 2, because it's "640 spare bytes per 8192 bytes page size" and this NAND chip has a page size of 16384 (= 2 * 8192). After this patch the kernel boot log reports: nand: Could not find valid ONFI parameter page; aborting nand: device found, Manufacturer ID: 0xad, Chip ID: 0xde nand: Hynix NAND 8GiB 3,3V 8-bit nand: 8192 MiB, MLC, erase size: 4096 KiB, page size: 16384, OOB size: 1280 Signed-off-by: Martin Blumenstingl Reviewed-by: Boris Brezillon --- drivers/mtd/nand/raw/nand_hynix.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/mtd/nand/raw/nand_hynix.c b/drivers/mtd/nand/raw/nand_hynix.c index d542908a0ebb..8cbe77f447c7 100644 --- a/drivers/mtd/nand/raw/nand_hynix.c +++ b/drivers/mtd/nand/raw/nand_hynix.c @@ -473,6 +473,19 @@ static void hynix_nand_extract_oobsize(struct nand_chip *chip, WARN(1, "Invalid OOB size"); break; } + + /* + * The datasheet of H27UCG8T2BTR mentions that the "Redundant + * Area Size" is encoded "per 8KB" (page size). This chip uses + * a page size of 16KiB. The datasheet mentions an OOB size of + * 1.280 bytes, but the OOB size encoded in the ID bytes (using + * the existing logic above) is 640 bytes. + * Update the OOB size for this chip by taking the value + * determined above and scaling it to the actual page size (so + * the actual OOB size for this chip is: 640 * 16k / 8k). + */ + if (chip->id.data[1] == 0xde) + mtd->oobsize *= mtd->writesize / SZ_8K; } }