Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF2ECC4338F for ; Wed, 28 Jul 2021 17:42:44 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 00C206023F for ; Wed, 28 Jul 2021 17:42:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 00C206023F Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=ti.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2C67482D1C; Wed, 28 Jul 2021 19:42:42 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="b1vVx3IJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6054F82D5B; Wed, 28 Jul 2021 19:42:40 +0200 (CEST) Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id BEE3E82CDA for ; Wed, 28 Jul 2021 19:42:35 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=p.yadav@ti.com Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 16SHgXjI123292; Wed, 28 Jul 2021 12:42:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1627494153; bh=CRdn9zSWx9dCn+DvZDyJwN7kjA0vJOgDONacWYGNGh0=; h=Date:From:To:CC:Subject:References:In-Reply-To; b=b1vVx3IJITmD1Sl61YGXjVn5EeIwnWjNnku5yFTDGVBNsq+73DtiitWqWtRwvuQLt +L8r8EF8822JsIRBTe1JgHpQfVnbhxkfplNXaJbBcaAbKChzm0OmAXh1woeXwj4We2 iieUC7p6sc9CebVzLKiWrn25cAY2i7a+zfvPf54Q= Received: from DFLE112.ent.ti.com (dfle112.ent.ti.com [10.64.6.33]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 16SHgXiO039102 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 28 Jul 2021 12:42:33 -0500 Received: from DFLE103.ent.ti.com (10.64.6.24) by DFLE112.ent.ti.com (10.64.6.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Wed, 28 Jul 2021 12:42:32 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DFLE103.ent.ti.com (10.64.6.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2 via Frontend Transport; Wed, 28 Jul 2021 12:42:32 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 16SHgVqG040416; Wed, 28 Jul 2021 12:42:32 -0500 Date: Wed, 28 Jul 2021 23:12:31 +0530 From: Pratyush Yadav To: Bin Meng CC: Jagan Teki , Vignesh Raghavendra , Subject: Re: [RFC PATCH] mtd: spi-nor-core: Handle SPI_RX_SLOW in spi_nor_adjust_hwcaps() Message-ID: <20210728174229.gydgmak45emvtoud@ti.com> References: <20210728155606.554431-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20210728155606.554431-1-bmeng.cn@gmail.com> User-Agent: NeoMutt/20171215 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean On 28/07/21 11:56PM, Bin Meng wrote: > When CONFIG_SPI_FLASH_SMART_HWCAPS is on, SPI_RX_SLOW flag of the > SPI controller is not honored. This adds the missing logic there. > > With this patch, SPI flash read works again with ICH SPI controller > on Intel Crown Bay board. > > Signed-off-by: Bin Meng > > --- > The quirky stuff of ICH SPI controller is that it only supports normal > read (opcode 3) but not fast read (opcode 11), so that's why SPI_RX_SLOW > was introduced before. > > At present the ICH SPI driver does not implement the supports_op() hook. > I can add a check against opcode 11 there, however I see a comment in > spi_nor_check_op() saying that SPI controller implementation should not > check the opcode. > > /* > * First test with 4 address bytes. The opcode itself might be a 3B > * addressing opcode but we don't care, because SPI controller > * implementation should not check the opcode, but just the sequence. > */ > > drivers/mtd/spi/spi-nor-core.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c > index 99e2f16349..e9b46c39b5 100644 > --- a/drivers/mtd/spi/spi-nor-core.c > +++ b/drivers/mtd/spi/spi-nor-core.c > @@ -2855,6 +2855,7 @@ spi_nor_adjust_hwcaps(struct spi_nor *nor, > const struct spi_nor_flash_parameter *params, > u32 *hwcaps) > { > + struct spi_slave *spi = nor->spi; > unsigned int cap; > > /* > @@ -2879,6 +2880,10 @@ spi_nor_adjust_hwcaps(struct spi_nor *nor, > if (!(*hwcaps & BIT(cap))) > continue; > > + if ((spi->mode & SPI_RX_SLOW) && > + (BIT(cap) == SNOR_HWCAPS_READ_FAST)) > + *hwcaps &= ~BIT(cap); > + NACK. We already check for SPI_RX_SLOW in spi_nor_scan(): /* Some devices cannot do fast-read, no matter what DT tells us */ if ((info->flags & SPI_NOR_NO_FR) || (spi->mode & SPI_RX_SLOW)) params.hwcaps.mask &= ~SNOR_HWCAPS_READ_FAST; I think the real bug here is that the smart spi_nor_adjust_hwcaps() does not respect the flash's hwcaps, and only looks to the controller on what can be supported. Doing the below should fix this: diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c index 8dd44c0f1e..4323b49651 100644 --- a/drivers/mtd/spi/spi-nor-core.c +++ b/drivers/mtd/spi/spi-nor-core.c @@ -2741,7 +2741,7 @@ spi_nor_adjust_hwcaps(struct spi_nor *nor, * Enable all caps by default. We will mask them after checking what's * really supported using spi_mem_supports_op(). */ - *hwcaps = SNOR_HWCAPS_ALL; + *hwcaps = SNOR_HWCAPS_ALL & params->hwcaps.mask; /* X-X-X modes are not supported yet, mask them all. */ *hwcaps &= ~SNOR_HWCAPS_X_X_X; Can you please test and confirm if it does indeed fix the issue for you? > rdidx = spi_nor_hwcaps_read2cmd(BIT(cap)); > if (rdidx >= 0 && > spi_nor_check_readop(nor, ¶ms->reads[rdidx])) > -- > 2.25.1 > -- Regards, Pratyush Yadav Texas Instruments Inc.