From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F17F62C15AA for ; Tue, 24 Feb 2026 08:24:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771921469; cv=none; b=hai7swUf1oTsVRllYOMZghSWyk5y/8kjHPh5e7DRzdOD7uROOp7mc1Nz8ET3BQda7XREFNnMBBi9iA/JNX80+6AhSInFpXu+feWPl1dfXsRn6tfUaMgZuZKkaio3pjz6XkoEYiAOYIvOzB3+V1eZS+5jYhkq1vGkNAdUA0/8d3M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771921469; c=relaxed/simple; bh=t0zlc/D9kCr5tanhkgQ6QIvizwF1CTy6Sa72LpcrlM8=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=VBb4TGwb033+/s1kiB5AEUrK47KxoLQ+ndsTmccD3FJJpn3KslGSPKeqcOwIurHHAOA2MJWjwLINsdrRzb/05MUSzMItzCW7xMTCUeISd05ydgaPsT/yqDfXbVDS4Gt9ZmuVX0wWsHrPHUUfoDNCwmgXDsc6XooyGBTqYx8v1vE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=HeB57+fn; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="HeB57+fn" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 4CC9C4E41053; Tue, 24 Feb 2026 08:24:24 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 1ADE05FD9D; Tue, 24 Feb 2026 08:24:24 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 5C44410368B4A; Tue, 24 Feb 2026 09:24:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1771921463; h=from:subject:date:message-id:to:cc:mime-version:content-type: in-reply-to:references; bh=zPjzKhw1AxnfmEmjJdRMUR5r5zdOO8JlzBDPEyp693o=; b=HeB57+fnClU0MrGfFUoN6r+rkSjHGumxUq0UAYjtBPYwGwpAcxuGyUEnZ5oCeZOS4AY9Zk CB9fBoPMe6z//UALVcZNpwFFgvTEQm2/PQIO/3vGLnf0bRqf8RD4/bF+1Pxab5UQ8zCc0U dfIh4+cspJA9uU6mVcE+HWLagj/jrun70e9dsZVWf4jJfpDsNa8A35Iers9UWyLcQB9AFC AZDwAuE92KyOj/KVgvcNYJW0huwIUc0wWyyi2YEsQoUmFccQFi8CQDW4Pjed8b+uomSqoP C0G7YYARMrsJtXE2JWEoAy8A949405fEU4u6Yq0WVURYCot8KgHzfzg2VymNCw== From: Miquel Raynal To: Cheng Ming Lin Cc: Tudor Ambarus , Pratyush Yadav , Michael Walle , Richard Weinberger , Vignesh Raghavendra , Jakub Czapiga , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, alvinzhou@mxic.com.tw, Cheng Ming Lin Subject: Re: [PATCH] mtd: spi-nor: core: Fix false positive in Read CR capability check In-Reply-To: <20260224025550.1102660-1-linchengming884@gmail.com> (Cheng Ming Lin's message of "Tue, 24 Feb 2026 10:55:50 +0800") References: <20260224025550.1102660-1-linchengming884@gmail.com> User-Agent: mu4e 1.12.7; emacs 30.2 Date: Tue, 24 Feb 2026 09:24:15 +0100 Message-ID: <87ecmar1lc.fsf@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain X-Last-TLS-Session-Version: TLSv1.3 Hi Cheng Ming, On 24/02/2026 at 10:55:50 +08, Cheng Ming Lin wrote: > From: Cheng Ming Lin > > The current code uses spi_nor_spimem_check_op() to check if the SPI > controller supports the Read CR operation. However, this leads to a > false positive where capable controllers are wrongly flagged with > SNOR_F_NO_READ_CR. > > SPI_NOR_RDCR_OP defines an operation without an address phase > (addr.nbytes = 0, addr.buswidth = 0). When this operation is passed > to spi_nor_spimem_check_op(), the function overwrites op->addr.nbytes > to 3 or 4 to test addressing capabilities (as it was originally designed > for data read/write ops). > > This modified operation is then rejected by spi_mem_check_op() in the > core spi-mem.c because it has a non-zero address length but a zero address > buswidth, which is an invalid combination. > > Fix this by bypassing spi_nor_spimem_check_op() for register operations. > Instead, directly call spi_mem_supports_op() to test the exact operation > without altering its address phase. > > Fixes: 5008c3ec3f89 ("mtd: spi-nor: core: Check read CR support") > Signed-off-by: Cheng Ming Lin That is indeed a problem, I already sent a patch for that but there is a bit of turnover in the spi-nor team. It hasn't been acked so I didn't took it through the final MR. The problem now exists in 7.0-rc1, see: https://lore.kernel.org/linux-mtd/20260108121430.1096844-1-miquel.raynal@bootlin.com/ > --- > drivers/mtd/spi-nor/core.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c > index 8ffeb41c3e08..13201908a69f 100644 > --- a/drivers/mtd/spi-nor/core.c > +++ b/drivers/mtd/spi-nor/core.c > @@ -2466,7 +2466,7 @@ spi_nor_spimem_adjust_hwcaps(struct spi_nor *nor, u32 *hwcaps) > > spi_nor_spimem_setup_op(nor, &op, nor->reg_proto); > > - if (spi_nor_spimem_check_op(nor, &op)) > + if (!spi_mem_supports_op(nor->spimem, &op)) > nor->flags |= SNOR_F_NO_READ_CR; > } > }