Received: by 2002:a19:f614:0:0:0:0:0 with SMTP id x20csp58773lfe; Fri, 15 Apr 2022 19:24:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3b4RDTnk9n/1ID331RcS+3gdPeyK2KP0y9b5rFm67NBfJf4yOHai4Ad1AgUAqBYSOXc8e X-Received: by 2002:a17:902:834a:b0:14f:3337:35de with SMTP id z10-20020a170902834a00b0014f333735demr1567789pln.8.1650075892433; Fri, 15 Apr 2022 19:24:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650075892; cv=none; d=google.com; s=arc-20160816; b=S/5T3PGUkR8gpmCskqv1dZGxGL/mZpzaPfJqpNLO8WmJ+d927I7jm/1SpuLiS5jzrL 5VHBiO1e343vdLx5k+IvPavZEBGfv3k7MPFphTJkEe74ALt4grnItaXb13O9JSUshAA/ gFpevsC5oqh9PYqsCY2ekeZNWzt19zgO3y7wHyQoxuD4e5EpxiyjYZiLKE+Omnvvli+2 /yWZ6aS/Oxe7xvEYTuoBb3qQpx6Bzbr+tu3J6R8/t5OrX3UchCbxAE3wZAYlGgQI0Vzo x+ebVq+pu1mWX97fR0RFyGr5wYZAVwV8BPl6JpGWvnsbYbHkEYiFFV0phY804I5tP8ak W/+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=BcGsVe7xbV75glV/hfTDZav/+E8Nuw3SsfVlM00Btsc=; b=dL8JIiBr5gqf2FjOAOywET7RUB59iJs94QbrGVdMl60xqMkwan1vKqEHlXmCcrrx3V e50OuI+AJsS0OKp/rlSkTVHe8LQtq9JZYmGP+PI/6dIolmQWpytIh5fiaCcYHT+2joxJ lR297A9I+UwVIJwWC6B0c1oREk9Z+zFB9R8DRHqGtuHEa4tXra1LqR3H4lLzZibWLcic l0sAHQIwBgwWCmkdBCUFT3Mqbf/hKmBbRPcDJKgUphNl4iFQNHeqP7WmFo+lIJca9xQw Qawlxx+6zEr02kkI2rKgj6/4ZzxiNiCdcwVRQ7BVshN3nP6WuDX3yNPU6S3dDqoAEODq wnGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=b0pwOTmW; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id u21-20020a17090abb1500b001cde9966f04si5360776pjr.175.2022.04.15.19.24.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 19:24:52 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=b0pwOTmW; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6D11A2C3FA2; Fri, 15 Apr 2022 18:37:01 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240014AbiDNPnJ (ORCPT + 99 others); Thu, 14 Apr 2022 11:43:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354587AbiDNPSX (ORCPT ); Thu, 14 Apr 2022 11:18:23 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EBD7ECB3B for ; Thu, 14 Apr 2022 08:06:50 -0700 (PDT) Received: from localhost (unknown [IPv6:2a01:e0a:2c:6930:5cf4:84a1:2763:fe0d]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: bbrezillon) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 218D21F47B07; Thu, 14 Apr 2022 16:06:48 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1649948808; bh=UpSLyopnlq5YAkIaxL8rC/z8gQiFGUjISBXjuDV87YA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=b0pwOTmW+kxJoLFq5v97T8FjTuaAb8wrqPxesw6cwS+6nTA86EsvdR+Chu26nEWCy Xf3qKjda/0QTX/bFoVGdrjagui6XsSTSQ1L9HwCXh74Rm5w5x0DiRSjHVb0JxxNPNQ bqWf+vIKAbX/hVQfy7h2oTN2Iy0IZKRAebF+sd41nSxF4QV0psAsLqbKE2uWE8/WlE qcVEUlR3nJwD01Nq3MxUmpUKrKWr2rLCJUC36537UvTZAn/x0R6pehthyq6/P2TqtC xv6GBdR7477RO7wlrat+EGIYskHD8T4Xr1PPPiqCP99itD0GSaDanjiPUTpFkJP+5h qVJgqOvlkKTAA== Date: Thu, 14 Apr 2022 17:06:44 +0200 From: Boris Brezillon To: Chuanhong Guo Cc: linux-mtd@lists.infradead.org, Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Patrice Chotard , Christophe Kerello , Mark Brown , Daniel Palmer , linux-kernel@vger.kernel.org (open list) Subject: Re: [PATCH 1/2] mtd: spinand: add support for detection with param page Message-ID: <20220414170644.4a53484f@collabora.com> In-Reply-To: <20220414143426.723168-2-gch981213@gmail.com> References: <20220414143426.723168-1-gch981213@gmail.com> <20220414143426.723168-2-gch981213@gmail.com> Organization: Collabora X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.31; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 14 Apr 2022 22:34:25 +0800 Chuanhong Guo wrote: > SPI-NAND detection using chip ID isn't always reliable. > Here are two known cases: > 1. ESMT uses JEDEC ID from other vendors. This may collapse with future > chips. Really?! So the manufacturer id matching is not even possible? > 2. Winbond W25N01KV uses the exact same JEDEC ID as W25N01GV while > having completely different chip parameters. > > Recent SPI-NANDs have a parameter page which is stored in the same > format as raw NAND ONFI data. There are strings for chip manufacturer > and chip model. Chip ECC requirement and memory organization are > available too. > This patch adds support for detecting SPI-NANDs with the parameter page > after ID matching failed. In this detection, memory organization and > ECC requirements are taken from the parameter page, and other SPI-NAND > specific parameters are obtained by matching chip model string with > a separated table. Oh come on! Looks like they never learn from their mistakes... > > It's common for vendors to release a series of SPI-NANDs with the same > SPI-NAND parameters in different voltages and/or capacities. The chip > table defined in this patch supports multiple model strings in one > entry, and multiple chip models can be covered using only one entry. That's really disappointing. And I guess the ONFI-page read commands are not even standard, and each vendor will come with its own sequence to read it. What's bothering me the most is the fact that ONFI parameter pages are not even designed for SPI NANDs. They have a bunch of parameters that don't really apply to SPI NANDs, and we're still lacking SPI-specific info, like the read/write/erase command variants, the maximum SPI bus width (AKA SPI modes)... To sum-up, if we have to support reading the ONFI parameter page, I'd rather keep it vendor-private (but that's assuming the vendor ID detection works, and you seem to imply ESMT cheats on that too), and use it only as a way to distinguish between 2 chip variants. > > Signed-off-by: Chuanhong Guo > --- > > I'm not brave enough to touch raw nand code without testing, so > sanitize_string, onfi_crc16 and nand_bit_wise_majority are > duplicated from raw/nand_onfi.c into spi/onfi.c > > drivers/mtd/nand/spi/Makefile | 2 +- > drivers/mtd/nand/spi/core.c | 23 +-- > drivers/mtd/nand/spi/onfi.c | 296 ++++++++++++++++++++++++++++++++++ Please, no. Try to move the common code to drivers/mtd/nand/onfi.c instead of duplicating it. AFAICT, the only thing that's spinand specific is spinand_onfi_read() and the last part of spinand_onfi_detect(). I'm sure we can find a way to expose generic onfi_parsing() helpers.