Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3871722pxb; Tue, 17 Nov 2020 05:53:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJy4SpoxS0hKhVvt1M0VxR9fOCMn2N0apXjKSViPg/wL9wnI78NH+3649q/dVeXji1Ztrd4x X-Received: by 2002:aa7:d407:: with SMTP id z7mr21422070edq.234.1605621239436; Tue, 17 Nov 2020 05:53:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605621239; cv=none; d=google.com; s=arc-20160816; b=CjrubJqNXCrNw1J7YIl01gsb46Z98M+TAXgHuUrmg1qXGLrp8UE1YLHy59g3jMfwxO GHrCytIwXQXpllgSvcruQNpYgzrElakaTg64huzoeP8GRCW8rm86QDlmA1we+jBKJLTU pmVEDISufIn7VW/S+ew+k3ycyBfs3IOhvoJFBVP0z3JuUDLZby6hgVQXhf4DHMWnmUIE mxgmKbID1MtJ21obAi31yNcpSgcql/1w6LS7LObw2G9Q7Zi45zTGUyq7QVHb1foyl3tz p/NWKM3PRCi5y4XOtu9M1LvAjqm7emLDL3PfLw+GWCXjzolKPukOm98gZmXnO/4BOppA HIrQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0IrKS1RqJR0HV41o2ZLUm2rHv50yPT4XckrA5iDRoTY=; b=sTIxyeQFSwlKqPxOz3d2N4PyH83hXTjHqf+BOCl46q9SE7Z5sc0HTX8CfZNr1m8jwi GGO79spTFjz82tMRS6pNsdqNAyhGwN6+pE8fwBiSWYySSHS51GuHrW/rt9ASgd5IT1Af V6JLpfnxVPG6VKhLbXNu2BlcDfFtWPlxVom/acsEFlPXJ8+yaEkxFzs6RS7b8+Sab8Mz d71UWGCM1rAAD5bFFSZmRxiNsYGlovEXK22E4h3VOS2pNHtzKP3DnpsAyDa9Rn/hgeMq ZyUdpuAG9C0YLtCLGzVlxfBaf4FUvHKRezespChZmW3ijW0ONopzmOhIpQFGmCo4f4Vc 3mzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gkZ5O8xZ; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id yl23si15489542ejb.441.2020.11.17.05.53.36; Tue, 17 Nov 2020 05:53:59 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=gkZ5O8xZ; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731990AbgKQNbC (ORCPT + 99 others); Tue, 17 Nov 2020 08:31:02 -0500 Received: from mail.kernel.org ([198.145.29.99]:39792 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730544AbgKQNah (ORCPT ); Tue, 17 Nov 2020 08:30:37 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 713202078E; Tue, 17 Nov 2020 13:30:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605619838; bh=SRWrzidpz1bA2eErxINd4qxHZVMh8LqjQ3WtTqAAJu4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gkZ5O8xZNNfpxBQjX4DPndg2jsZsTaA4BFXOUEVQ8/jIhn7n5+smHnUj+mcdk4JLR AleWWqzIgTkx46uL503ng77ZxT1p5fPdUtZV8kGutH4VRK0iT7MVCrO5GuH9/U3c5J BG5x+o4ijKTXP7nG1cLv8U1S6G5rS8mEEdIltN5o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bert Vermeulen , Vignesh Raghavendra , Tudor Ambarus , Pratyush Yadav , Joel Stanley , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Sasha Levin Subject: [PATCH 5.9 020/255] mtd: spi-nor: Fix address width on flash chips > 16MB Date: Tue, 17 Nov 2020 14:02:40 +0100 Message-Id: <20201117122139.927316406@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201117122138.925150709@linuxfoundation.org> References: <20201117122138.925150709@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bert Vermeulen [ Upstream commit 324f78dfb442b82365548b657ec4e6974c677502 ] If a flash chip has more than 16MB capacity but its BFPT reports BFPT_DWORD1_ADDRESS_BYTES_3_OR_4, the spi-nor framework defaults to 3. The check in spi_nor_set_addr_width() doesn't catch it because addr_width did get set. This fixes that check. Fixes: f9acd7fa80be ("mtd: spi-nor: sfdp: default to addr_width of 3 for configurable widths") Signed-off-by: Bert Vermeulen Signed-off-by: Vignesh Raghavendra Reviewed-by: Tudor Ambarus Reviewed-by: Pratyush Yadav Reviewed-by: Joel Stanley Reviewed-by: Cédric Le Goater Tested-by: Joel Stanley Tested-by: Cédric Le Goater Link: https://lore.kernel.org/r/20201006132346.12652-1-bert@biot.com Signed-off-by: Sasha Levin --- drivers/mtd/spi-nor/core.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index b37d6c1936de1..f0ae7a01703a1 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -3008,13 +3008,15 @@ static int spi_nor_set_addr_width(struct spi_nor *nor) /* already configured from SFDP */ } else if (nor->info->addr_width) { nor->addr_width = nor->info->addr_width; - } else if (nor->mtd.size > 0x1000000) { - /* enable 4-byte addressing if the device exceeds 16MiB */ - nor->addr_width = 4; } else { nor->addr_width = 3; } + if (nor->addr_width == 3 && nor->mtd.size > 0x1000000) { + /* enable 4-byte addressing if the device exceeds 16MiB */ + nor->addr_width = 4; + } + if (nor->addr_width > SPI_NOR_MAX_ADDR_WIDTH) { dev_dbg(nor->dev, "address width is too large: %u\n", nor->addr_width); -- 2.27.0