Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp299750imu; Fri, 7 Dec 2018 01:03:03 -0800 (PST) X-Google-Smtp-Source: AFSGD/W5cPRZ4ls/tH4qlEKv4K2McunBmozz89/gFMNwnQAKEAmIVWwdTOdptkzIX+VeB5Or1vdo X-Received: by 2002:a63:374e:: with SMTP id g14mr1235010pgn.59.1544173383438; Fri, 07 Dec 2018 01:03:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544173383; cv=none; d=google.com; s=arc-20160816; b=vOYqD/t1LeYF8m1bWTLS8kKYWBGWRXzvHOXXm5gzxLOoJIGhEBbNmPmHroirqXzvz4 ioPvBlkfs/Ak//iNPuelJf8eiSbMyu4ZTca5cR+10uHKLsQcrjkxBXAG/62dMCdjOlfL /Am1/OoWdNmHZ5b1Fb8voMRLK7Q8z7QB9CkuIGAvPlGh18L8BDx6BKvOVmoW6iKqY+9i y4bKOx6ISgj0Iv1O5JslmRsRMyoEVeC6qoaWVkPQEryrmHVmEo28W0zLBD27ZrewTHF7 hXGvtBtZ11zvq1AP+5DKCgNVY1rsESNWZby6MosK4jNnajsrV3Y7FhN8lupunmz+rZdu W8Uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=VR1gPBQ1CSh1jcJ8Jfuz+n8BWAI+TRmlu6pfUupFgoY=; b=r59mnN5v+EUJ2IID/vC2CZb8MdIbrQ06Glk/wVASO8FoMpLp92kjPkvXWDxQfxGHYM ITtZ4nc3tpggELNbtG4aZfKqXhZ4ekudiW4C7sY+Hqemii9hQRCTOzsFTX5ECMmIZpdx M4kWMnrhcNeQRVwb82NbO4Gqhqatcxf67WfQXGepMrP3zeXrEFzY4sN60umQyCiHHylH /9bPhWE6/PhuoRL3sBJgFkrtqtS2qVxPNN++9ljkfLJzxfw46TbL/cLa2dbyS+i92G9W tcACaUOIP9vrRdt53MkXbk8PxPiIsXIXlM+MUCq2mPp0bddmuL2qd236zyleUzqTvRvz J7CQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a26si2391303pgl.282.2018.12.07.01.02.45; Fri, 07 Dec 2018 01:03:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725998AbeLGJAW (ORCPT + 99 others); Fri, 7 Dec 2018 04:00:22 -0500 Received: from mail.bootlin.com ([62.4.15.54]:46231 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725966AbeLGJAV (ORCPT ); Fri, 7 Dec 2018 04:00:21 -0500 Received: by mail.bootlin.com (Postfix, from userid 110) id EAAEA20711; Fri, 7 Dec 2018 10:00:19 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.2 Received: from bbrezillon (aaubervilliers-681-1-79-44.w90-88.abo.wanadoo.fr [90.88.21.44]) by mail.bootlin.com (Postfix) with ESMTPSA id A0F5E20701; Fri, 7 Dec 2018 10:00:09 +0100 (CET) Date: Fri, 7 Dec 2018 10:00:09 +0100 From: Boris Brezillon To: Cc: , , , , , , Subject: Re: [PATCH v2] mtd: spi-nor: parse SFDP 4-byte Address Instruction Table Message-ID: <20181207100009.5e2bb49a@bbrezillon> In-Reply-To: <20181206144330.30860-1-tudor.ambarus@microchip.com> References: <20181206144330.30860-1-tudor.ambarus@microchip.com> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Tudor, On Thu, 6 Dec 2018 14:43:39 +0000 wrote: > /** > * spi_nor_parse_sfdp() - parse the Serial Flash Discoverable Parameters. > * @nor: pointer to a 'struct spi_nor' > @@ -3276,6 +3462,10 @@ static int spi_nor_parse_sfdp(struct spi_nor *nor, > err = spi_nor_parse_smpt(nor, param_header); > break; > > + case SFDP_4BAIT_ID: > + err = spi_nor_parse_4bait(nor, param_header, params); > + break; > + > default: > break; > } > @@ -3857,7 +4047,8 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, > (JEDEC_MFR(info) == SNOR_MFR_SPANSION && mtd->size > SZ_16M)) > nor->flags |= SNOR_F_4B_OPCODES; > > - if (nor->addr_width == 4 && nor->flags & SNOR_F_4B_OPCODES) > + if (nor->addr_width == 4 && nor->flags & SNOR_F_4B_OPCODES && > + !(nor->flags & SNOR_F_HAS_4BAIT)) > spi_nor_set_4byte_opcodes(nor); The list of checks is growing. Maybe we could move those checks at the beginning of spi_nor_set_4byte_opcodes() so we can unconditionally call spi_nor_set_4byte_opcodes() here. Not something I ask you to fix in this patch, just thinking out loud. The rest of the patch looks good, but I'm pretty sure we'll run into trouble as soon as we start parsing this 4BAIT section (as has been the case for all other SFPD sections so far), just because vendors tend to get this sort of things wrong. I don't have a solution for that other than the proposed SFDP fixup hooks infrastructure [1] or the more conservative "don't parse/trust SFDP" approach. Note that, even if we go for the SFDP fixups approach, we might still break setups where the 4BAIT section of the SFDP table is broken until someone comes with a fixup for those broken chips. Since I don't like to block inclusion of new features for purely theoretical issues, I'm in favor of applying this patch, but be prepared to receive bug reports during the 4.21-rc cycle ;-). Regards, Boris [1]http://patchwork.ozlabs.org/patch/1008687/