Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4361718pxf; Tue, 16 Mar 2021 11:30:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzX5pP3BELVch8L6Cb96VXyAlNFTKilVoKH0chlpndT7nl6l6/qOMUTkUhhwgQtFXJgJEcq X-Received: by 2002:a17:906:22d4:: with SMTP id q20mr32071650eja.54.1615919431946; Tue, 16 Mar 2021 11:30:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615919431; cv=none; d=google.com; s=arc-20160816; b=Ai7qDBCNaB0qGTvOJCHssEo575/z5T4yv/I4Xbt2bvMxxd3YfsXJyNc2wkAuSGUmk9 +wYeWngFh/NsL5ZK4xKXtTgIrmPti5DzAMpMHf9EBHr5Xpkhy/ZAd7eCPVvWJjD4Kvjc oHlTHgNI3JyD19i5eaINikdPnFtJmrxfphdEkr/A/lvhO5oHY8inxKQnbh5lCL6B80YP YeURsRlcF65ZN+5TAOlLjWp5xXNE0J2S6n6stoFFSJ6Rx4F5AbjEe48A0//EJNiw85OH h+eWuckEuOF8rFK4NjkKGx97ai88fL0ZBX/HxhGvxW5IcoO2py67l8y5EUByvsSYK/rm 3Kww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=1SDfT390py2AYSqNPPkU+Q1iDS07rdITWfy251DIhuw=; b=hXW3q6GBfF10t4svdkRB/V3FQpsAtO9kiUJHhZxU7ndYmQaeS60YkNbNYGQAsA9Vs5 3boMUrx+k5DM0KMNemhAMqrOOg+E9hmUsPxup5EBLPY8HW+bcuWwB3M8W7caT/ZQvaas QTciQkxESZ8ewRXperacxg34lYrdaX1nRUTMMtkEdlWsVAhEhQM5jPgfiCCofoBeB3eq o5Y8T7tAJNaPC6CNiiAFENq+7HbzlYGyCx0+TRPooFdTA94nCVaG2F8/RXNKQ6NR4wiS tqO2G3YwtohOT3rOKYwQZDe8lIysr5ElJ9BM+1t9vQ4tPUBEdjpTrM2bEPAqYqv4harf qpng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=MRC8R6pY; 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=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i19si14542259ejf.626.2021.03.16.11.30.08; Tue, 16 Mar 2021 11:30:31 -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; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=MRC8R6pY; 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=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237007AbhCPLEf (ORCPT + 99 others); Tue, 16 Mar 2021 07:04:35 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:37336 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231208AbhCPLEO (ORCPT ); Tue, 16 Mar 2021 07:04:14 -0400 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 12GB441Z037915; Tue, 16 Mar 2021 06:04:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1615892644; bh=1SDfT390py2AYSqNPPkU+Q1iDS07rdITWfy251DIhuw=; h=Date:From:To:CC:Subject:References:In-Reply-To; b=MRC8R6pYHvdMD7FZyorZDxVNbm5tVOR0H6t9mQmmCVyPSuk937gULy/Ri+fKHYrxz ZDApKE0Nj6lMsjN8TXisD5NWmx7sEd2L/j3THYkllq0r1kzUPyAZZCQX40rx+d6dT+ qo/yaKhu22e223mkmBwG9U0Sov/Yl4jumkHXA2o0= Received: from DFLE115.ent.ti.com (dfle115.ent.ti.com [10.64.6.36]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 12GB44qm078938 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 16 Mar 2021 06:04:04 -0500 Received: from DFLE115.ent.ti.com (10.64.6.36) by DFLE115.ent.ti.com (10.64.6.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Tue, 16 Mar 2021 06:04:04 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DFLE115.ent.ti.com (10.64.6.36) 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; Tue, 16 Mar 2021 06:04:04 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 12GB431C114680; Tue, 16 Mar 2021 06:04:03 -0500 Date: Tue, 16 Mar 2021 16:34:02 +0530 From: Pratyush Yadav To: Michael Walle CC: , , Tudor Ambarus , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra Subject: Re: [RFC PATCH 2/3] mtd: spi-nor: sfdp: fix spi_nor_read_sfdp() Message-ID: <20210316110400.kepjn6b654lhq4dy@ti.com> References: <20210312190548.6954-1-michael@walle.cc> <20210312190548.6954-3-michael@walle.cc> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20210312190548.6954-3-michael@walle.cc> User-Agent: NeoMutt/20171215 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/03/21 08:05PM, Michael Walle wrote: > If spi_nor_read_sfdp() is used after probe, we have to set read_proto > and the read dirmap. > > Signed-off-by: Michael Walle > --- > drivers/mtd/spi-nor/sfdp.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/drivers/mtd/spi-nor/sfdp.c b/drivers/mtd/spi-nor/sfdp.c > index b1814afefc33..47634ec9b899 100644 > --- a/drivers/mtd/spi-nor/sfdp.c > +++ b/drivers/mtd/spi-nor/sfdp.c > @@ -179,19 +179,27 @@ static int spi_nor_read_sfdp(struct spi_nor *nor, u32 addr, > size_t len, void *buf) > { > u8 addr_width, read_opcode, read_dummy; > + struct spi_mem_dirmap_desc *rdesc; > + enum spi_nor_protocol read_proto; > int ret; > > read_opcode = nor->read_opcode; > + read_proto = nor->read_proto; > + rdesc = nor->dirmap.rdesc; > addr_width = nor->addr_width; > read_dummy = nor->read_dummy; > > nor->read_opcode = SPINOR_OP_RDSFDP; > + nor->read_proto = SNOR_PROTO_1_1_1; > + nor->dirmap.rdesc = NULL; > nor->addr_width = 3; > nor->read_dummy = 8; NACK. You can't assume the device is still in 1S-1S-1S mode after probe. For example, the s28hs512t flash is switched to 8D-8D-8D mode by the time the probe finishes so this would be an invalid command. Same for any flash that goes into a stateful mode. And you can't even keep using nor->read_proto to read SFDP because the Read SFDP command might not be supported in all modes. xSPI spec (JESD251) says that the Read SFDP command is optional in 8D-8D-8D mode. I think the best approach for this would be to cache the entire SFDP table at parse time. This obviously comes with a memory overhead but I don't think it would be too big. For example, the sfdp table on s28hs512t is 491 bytes and it has 6 tables. Anyway, if the memory usage is too much of a problem we can put the feature behind a config. > > ret = spi_nor_read_raw(nor, addr, len, buf); > > nor->read_opcode = read_opcode; > + nor->read_proto = read_proto; > + nor->dirmap.rdesc = rdesc; > nor->addr_width = addr_width; > nor->read_dummy = read_dummy; > > -- > 2.20.1 > -- Regards, Pratyush Yadav Texas Instruments Inc.