Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp898145imw; Thu, 14 Jul 2022 13:01:41 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vaJvaJvVFHV9LD8OyV+/HZoTBzCV6YbWktbZDX7UeiRb8Pxrl0vZ3j0uySqcpDPgb8sKGx X-Received: by 2002:a05:6402:4410:b0:434:f35f:132e with SMTP id y16-20020a056402441000b00434f35f132emr14460174eda.215.1657828900797; Thu, 14 Jul 2022 13:01:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657828900; cv=none; d=google.com; s=arc-20160816; b=P8N6iSybWop8NPhl8hykOaLuBuDmsubqfhCFWwDOjc7AA29idSS4F2vtVde7qKGelC hVc6e3olhbrtWdQiGPMmXLLZlc6wJgchldbDRl7QhQ6tyw08dOoKmIhqUbzmdKO3/bdp 3WIYzrn6DSsxoHXsx/K7FPhZbeUzKW148Nnz/NW5cImRpAPA5odsk7BaYivuSJY9ps4a bwbVJGScmb+ub0qKx+pp6bAuspgDR11GOcYbpk5CTqEAJaIGb3ZJc5y2fgZAhuQelM62 GzHKTeA8bA6l2yargpz86acC/56t5HJfURH4AERi3j2JrjASh/21xyrTCx6RVe0XSRrR mevg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:user-agent:references:in-reply-to :subject:cc:to:from:date:content-transfer-encoding:mime-version :dkim-signature; bh=3ro6DsiZOyVl0p4EfjbReVqk2JZ+ojOAHyeH+zjJsEw=; b=SshZUAerSRJomvKGyEcR8V/zBWqnpy27HQRyoepLo9J3d9Jcdl2i0Po8dtbeu9po+5 bb1dmofJSH/DZ/io+D/Zliz5To9Bu5L6eIvUWZSaxFiY5cCeWZCVDqEOWpo4PvZfAYOJ zidBTok9Z9dwxd4DkabCDGxlAII6PhZF398+KGCGs97GIIGt2MMm4r0DGIQfI7pA6ECy MAFDsTi0D2b3piv5SqUxR0JWm8y8vO/oUmEWmfiv9jwWziu8CwMtTwV0yjmFgzSnaXYX 10w4JrAXIposdiJlz/rEoXRLHIWtYWK3mvHybJF/TbMUOjOHGKPudPHwT24IvHNMfRVT igCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=iBPQLNv4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j10-20020a05640211ca00b004396851005fsi3772543edw.100.2022.07.14.13.01.10; Thu, 14 Jul 2022 13:01:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=iBPQLNv4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240520AbiGNTmG (ORCPT + 99 others); Thu, 14 Jul 2022 15:42:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232143AbiGNTmF (ORCPT ); Thu, 14 Jul 2022 15:42:05 -0400 Received: from ssl.serverraum.org (ssl.serverraum.org [176.9.125.105]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59C296C13E; Thu, 14 Jul 2022 12:42:01 -0700 (PDT) Received: from ssl.serverraum.org (web.serverraum.org [172.16.0.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id 8758B22238; Thu, 14 Jul 2022 21:41:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1657827716; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3ro6DsiZOyVl0p4EfjbReVqk2JZ+ojOAHyeH+zjJsEw=; b=iBPQLNv4oS0P3UsioZAiEjIeQk76v1WKPCD5H0BzEwm00wXbLr8bX/Ya43aeQ5023QJq2k 4q5ldJ7b56ZzTlNLFYfJBNS0SE3Cpk9/hYEctK+IcAQ8s1yWUCUeHXT5KFE5rSHhco2K8k KjI4b29t+HcLCCg6PXHnUv2ihhDi6d4= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 14 Jul 2022 21:41:48 +0200 From: Michael Walle To: Michal Suchanek Cc: linux-sunxi@lists.linux.dev, Rob Herring , Krzysztof Kozlowski , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Tudor Ambarus , Pratyush Yadav , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org Subject: Re: [PATCH 1/2] mtd: spi-nor: When a flash memory is missing do not report an error In-Reply-To: <701967b0c418db333c66b48d225df60aa9d03ead.1657826188.git.msuchanek@suse.de> References: <701967b0c418db333c66b48d225df60aa9d03ead.1657826188.git.msuchanek@suse.de> User-Agent: Roundcube Webmail/1.4.13 Message-ID: X-Sender: michael@walle.cc X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 Hi, Am 2022-07-14 21:19, schrieb Michal Suchanek: > It is normal that devices are designed with multiple types of storage, > and only some types of storage are present. > > The kernel can handle this situation gracefully for many types of > storage devices such as mmc or ata but it reports and error when spi > flash is not present. > > Only print a notice that the storage device is missing when no response > to the identify command is received. > > Consider reply buffers with all bits set to the same value no response. I'm not sure you can compare SPI with ATA and MMC. I'm just speaking of DT now, but there, for ATA and MMC you just describe the controller and it will auto-detect the connected storage. Whereas with SPI you describe both the controller and the flash. So I'd argue that your hardware description is wrong if it describes a flash which is not present. > Signed-off-by: Michal Suchanek > --- > drivers/mtd/spi-nor/core.c | 25 +++++++++++++++++++++++-- > 1 file changed, 23 insertions(+), 2 deletions(-) > > diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c > index 502967c76c5f..6bab540171a4 100644 > --- a/drivers/mtd/spi-nor/core.c > +++ b/drivers/mtd/spi-nor/core.c > @@ -1652,6 +1652,24 @@ static const struct flash_info > *spi_nor_match_id(struct spi_nor *nor, > return NULL; > } > > +static const bool buffer_uniform(const u8 *buffer, size_t length) > +{ > + bool all0; > + size_t i; > + > + for (all0 = true, i = 0; i < length; i++) > + if (buffer[i] != 0) { > + all0 = false; > + break; > + } > + if (all0) > + return true; > + for (i = 0; i < length; i++) > + if (buffer[i] != 0xff) > + return false; > + return true; > +} That seems unnecessarily complex. if (!memchr_inv(id, '\x00', SPI_NOR_MAX_ID_LEN) || !memchr_inv(id, '\xff', SPI_NOR_MAX_ID_LEN)) should be the same. -michael > + > static const struct flash_info *spi_nor_detect(struct spi_nor *nor) > { > const struct flash_info *info; > @@ -1666,8 +1684,11 @@ static const struct flash_info > *spi_nor_detect(struct spi_nor *nor) > > info = spi_nor_match_id(nor, id); > if (!info) { > - dev_err(nor->dev, "unrecognized JEDEC id bytes: %*ph\n", > - SPI_NOR_MAX_ID_LEN, id); > + if (buffer_uniform(id, SPI_NOR_MAX_ID_LEN)) > + dev_info(nor->dev, "No flash memory detected.\n"); > + else > + dev_err(nor->dev, "unrecognized JEDEC id bytes: %*ph\n", > + SPI_NOR_MAX_ID_LEN, id); > return ERR_PTR(-ENODEV); > } > return info;