Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3129352ybz; Mon, 27 Apr 2020 10:28:27 -0700 (PDT) X-Google-Smtp-Source: APiQypLn9KhyVKirxISm3nE9V6sbWGoOsG1HLFKWOcgte8hKPO78yDmYgP9pT4ukou0yV9WtuE2W X-Received: by 2002:a17:906:3291:: with SMTP id 17mr20309902ejw.343.1588008507549; Mon, 27 Apr 2020 10:28:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588008507; cv=none; d=google.com; s=arc-20160816; b=1Lv9gJH6jHjf2pxs2hKE2O555ELkqXxB2+5ybZ7ymURbp0jzRdlhNJ1m1o79FW0z9U EsozxmJuVObjApALJT29dHUoposhA4mcQAukUII6k+MY16QSSdZYkMbdOroXz02a4hCd 98k1EEfHQNFqqeRS2x1yjikYO3R+wSK3Qgum1q4+PT1VOx6ai9gDdTenULpXcvDNQLRF kTQ9E3zQztZbEdfq8oMhNKivVLp76lCIrlgBsCDazby0fv3QhzBOn5lTEgrZmfuNDvRZ GG8d2RZAp5TpgevaRpOMdJfvY8SzeC9jku5KFigA7O51fNFCLpNMA7BikewOiHdoDT05 62hA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=esf929+F6f7soqyXyodUT5bLsI1nPG4KhHfA6Nn6YVQ=; b=vpRJkQBBzrtXyMUyO5H+41XluuqEcNe1Q5RKUqHkqMMXJq6OVCUrZluUMtKaG9TmE0 XIXuKld/tEjBG5N6/iUEzEH5ary0PjretizN9crjBzJ8nMTDw1x601CKYl0fy82uvzmC HS9dYyjTUcu+7UhuonYVMcbgUyVZWjNxNBmbhXt2dRtmTKNgFYE7zW0fIeIj+FjnRHo6 hZJHniq5PQGaCtSPSd2HW912OwC8Eo4e5IbCRp0aGMJO6QnAPhC/y4tnadIqIbSO0tzB U7TpEETQhMKu/jOepY5IevEzFk323wIPXD8WkqtgBuu/V7FBSP3yNiCGOmAlmgxzqJIv jXBw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l35si142365edl.187.2020.04.27.10.28.04; Mon, 27 Apr 2020 10:28:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726498AbgD0R01 (ORCPT + 99 others); Mon, 27 Apr 2020 13:26:27 -0400 Received: from relay10.mail.gandi.net ([217.70.178.230]:56411 "EHLO relay10.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726493AbgD0R01 (ORCPT ); Mon, 27 Apr 2020 13:26:27 -0400 Received: from localhost (unknown [42.111.30.142]) (Authenticated sender: me@yadavpratyush.com) by relay10.mail.gandi.net (Postfix) with ESMTPSA id 984AF240006; Mon, 27 Apr 2020 17:26:18 +0000 (UTC) Date: Mon, 27 Apr 2020 22:53:36 +0530 From: Pratyush Yadav To: Yicong Yang Cc: Pratyush Yadav , Tudor Ambarus , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Mark Brown , Nicolas Ferre , Alexandre Belloni , Ludovic Desroches , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Sekhar Nori Subject: Re: [PATCH v4 05/16] mtd: spi-nor: default to address width of 3 for configurable widths Message-ID: <20200427172336.ihezwq3wn75m7k3l@yadavpratyush.com> References: <20200424184410.8578-1-p.yadav@ti.com> <20200424184410.8578-6-p.yadav@ti.com> <6b6384ad-d37a-eea6-af29-322e83924912@hisilicon.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6b6384ad-d37a-eea6-af29-322e83924912@hisilicon.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Yicong, On 26/04/20 11:53AM, Yicong Yang wrote: > On 2020/4/25 2:43, Pratyush Yadav wrote: > > JESD216D.01 says that when the address width can be 3 or 4, it defaults > > to 3 and enters 4-byte mode when given the appropriate command. So, when > > we see a configurable width, default to 3 and let flash that default to > > 4 change it in a post-bfpt fixup. > > > > This fixes SMPT parsing for flashes with configurable address width. If > > the SMPT descriptor advertises variable address width, we use > > nor->addr_width as the address width. But since it was not set to any > > value from the SFDP table, the read command uses an address width of 0, > > resulting in an incorrect read being issued. > > > > Signed-off-by: Pratyush Yadav > > --- > > drivers/mtd/spi-nor/sfdp.c | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/drivers/mtd/spi-nor/sfdp.c b/drivers/mtd/spi-nor/sfdp.c > > index f917631c8110..5cecc4ba2141 100644 > > --- a/drivers/mtd/spi-nor/sfdp.c > > +++ b/drivers/mtd/spi-nor/sfdp.c > > @@ -460,6 +460,7 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor, > > /* Number of address bytes. */ > > switch (bfpt.dwords[BFPT_DWORD(1)] & BFPT_DWORD1_ADDRESS_BYTES_MASK) { > > case BFPT_DWORD1_ADDRESS_BYTES_3_ONLY: > > + case BFPT_DWORD1_ADDRESS_BYTES_3_OR_4: > > nor->addr_width = 3; > > break; > > Should we also assign address width to 3 in default condition. At least we should not > leave it uninitialized here. The default condition would be taken when this field is 3. The value 3 is reserved, and so no current device should use this value. That said, I don't see any downsides of doing so. If the value 3 means something else in later revisions of the standard, this code would need to change anyway. If not, we would use a relatively sane default for devices with a faulty BFPT. I haven't received any comments on my series so far. If end up having to re-roll it, I will add this change. Otherwise, I'm not sure if it is a good idea to re-roll a 16-patch series for a one liner that isn't fixing some major bug. In that case, maybe you can send an independent patch that does this after mine is merged? -- Regards, Pratyush Yadav