Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp2274568pxm; Sun, 27 Feb 2022 16:45:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJwTebYk72aZ2tEhY6o7sPMu6NxF9We/MTrPp0oYDSDW7CBuX+x/vM3TLi4G7yGV6jNDvuxO X-Received: by 2002:a17:906:50b:b0:6d0:9ebc:b9df with SMTP id j11-20020a170906050b00b006d09ebcb9dfmr13413547eja.67.1646009144511; Sun, 27 Feb 2022 16:45:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646009144; cv=none; d=google.com; s=arc-20160816; b=EfLq2OwBCjehIzryZ27BSkPpiQ7KG9/0hioTcSqXLNmwym0YzukRat8/0+sJWQwu8e nrUs0B2cIx4tcK16ewzYU5RT1TOBL1/UJjyCq1kBktDJ6G7XyI/j63A2oB9lQZS7npN8 JWPQPjzyE5YvFcJM+LzgtlXH7vFrB0pF39xVxU2FK/YbPkIgoadOefx2o3j9YOu77Wie BtgW6j6BxlddwX6gRN/bOSX4yAOls6SDsyX9c4fzQstYvGsKlXdWI/chc6dJGE43HIT2 aX8wa2vMYdqapj6Cjl7jNOc0swl7GlX8Ia0xJFd2ChbKgWN2tQ/mly1DjgvmWGMMUJTn G+bA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=omAb345/9YBZAq7IAzYS9R1ufqM+eeXJFI/5bZ/KE3w=; b=f9Z6HVzXKzALYw7hp0QqXc5uBpbGOGX9Fw8qcYWVGqrLpXuy+/yJjFOIdUa7qGte+8 Q+hvF1A/Lf1+3uhejf+B4KLqXDyU7NLyfPimCEJkIIUQz75D3kvI6Y9lKDWg39/Vbk0p ZQTaJmwACKt+lmJ+W0YUupaxXLM7Y3OwM5uEaik0m4xA3PeL95jMDM0ROAeqvXzYmZpT ovYLDmyM8hcrjYMmTkau2d30Pu3djYvkqsU1XpSgk1F1sy7ZAhfOze2pAAKwPG4Ad8WJ z1mqGiMdzvucHEk938ckrBHdfO7k3EZhY15QPTLSTCPxQo6c3RZtsIMlfQssfPArQ0h/ G1cg== ARC-Authentication-Results: i=1; mx.google.com; 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 e8-20020a1709061e8800b006d076e0adc5si5592984ejj.157.2022.02.27.16.45.22; Sun, 27 Feb 2022 16:45:44 -0800 (PST) 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; 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 S230494AbiB0V2f (ORCPT + 99 others); Sun, 27 Feb 2022 16:28:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229549AbiB0V2d (ORCPT ); Sun, 27 Feb 2022 16:28:33 -0500 X-Greylist: delayed 8971 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Sun, 27 Feb 2022 13:27:55 PST Received: from 6.mo552.mail-out.ovh.net (6.mo552.mail-out.ovh.net [188.165.49.222]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86CC313F79 for ; Sun, 27 Feb 2022 13:27:55 -0800 (PST) Received: from mxplan5.mail.ovh.net (unknown [10.109.143.118]) by mo552.mail-out.ovh.net (Postfix) with ESMTPS id E30F222C9F; Sun, 27 Feb 2022 21:27:53 +0000 (UTC) Received: from kaod.org (37.59.142.103) by DAG4EX1.mxp5.local (172.16.2.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.18; Sun, 27 Feb 2022 22:27:52 +0100 Authentication-Results: garm.ovh; auth=pass (GARM-103G005bd4da659-6e74-42ae-98f4-7b2406606e6c, 949565DF20DEE76D4A77FF7731A75FE8B07B1F6B) smtp.auth=clg@kaod.org X-OVh-ClientIp: 82.64.250.170 Message-ID: <890fce14-8001-74c9-21a9-0de117e743ef@kaod.org> Date: Sun, 27 Feb 2022 22:27:52 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH 08/10] spi: aspeed: Calibrate read timings Content-Language: en-US To: Pratyush Yadav CC: , , Mark Brown , Tudor Ambarus , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , , Joel Stanley , Andrew Jeffery , Chin-Ting Kuo , , Rob Herring , , References: <20220214094231.3753686-1-clg@kaod.org> <20220214094231.3753686-9-clg@kaod.org> <20220225091809.gvup3mcst45szi6x@ti.com> From: =?UTF-8?Q?C=c3=a9dric_Le_Goater?= In-Reply-To: <20220225091809.gvup3mcst45szi6x@ti.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [37.59.142.103] X-ClientProxiedBy: DAG6EX2.mxp5.local (172.16.2.52) To DAG4EX1.mxp5.local (172.16.2.31) X-Ovh-Tracer-GUID: 9a51f072-26f3-48de-b05f-06cdd16eb070 X-Ovh-Tracer-Id: 17066672266216704900 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvvddrleekgddugeejucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhepkfffgggfuffvfhfhjggtgfhisehtkeertddtfeejnecuhfhrohhmpeevrogurhhitggpnfgvpgfiohgrthgvrhcuoegtlhhgsehkrghougdrohhrgheqnecuggftrfgrthhtvghrnhepudetudefueeffedvjeeiieffleegtefgledthfelueevieetgeekuedvffdtteehnecuffhomhgrihhnpehoiihlrggsshdrohhrghenucfkpheptddrtddrtddrtddpfeejrdehledrudegvddruddtfeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhhouggvpehsmhhtphhouhhtpdhhvghlohepmhigphhlrghnhedrmhgrihhlrdhovhhhrdhnvghtpdhinhgvtheptddrtddrtddrtddpmhgrihhlfhhrohhmpegtlhhgsehkrghougdrohhrghdpnhgspghrtghpthhtohepuddprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrgh X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,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 On 2/25/22 10:18, Pratyush Yadav wrote: > On 14/02/22 10:42AM, Cédric Le Goater wrote: >> To accommodate the different response time of SPI transfers on different >> boards and different SPI NOR devices, the Aspeed controllers provide a >> set of Read Timing Compensation registers to tune the timing delays >> depending on the frequency being used. The AST2600 SoC has one of >> these registers per device. On the AST2500 and AST2400 SoCs, the >> timing register is shared by all devices which is a bit problematic to >> get good results other than for one device. >> >> The algorithm first reads a golden buffer at low speed and then performs >> reads with different clocks and delay cycle settings to find a breaking >> point. This selects a default good frequency for the CEx control register. >> The current settings are bit optimistic as we pick the first delay giving >> good results. A safer approach would be to determine an interval and >> choose the middle value. >> >> Due to the lack of API, calibration is performed when the direct mapping >> for reads is created. > > The dirmap_create mapping says nothing about _when_ it should be called. > So there is no guarantee that it will only be called after the flash is > fully initialized. spi_nor_create_read_dirmap() is called after spi_nor_scan() in spi_nor_probe(). Since a spi_mem_dirmap_info descriptor is created using the nor fields : struct spi_mem_dirmap_info info = { .op_tmpl = SPI_MEM_OP(SPI_MEM_OP_CMD(nor->read_opcode, 0), SPI_MEM_OP_ADDR(nor->addr_width, 0, 0), SPI_MEM_OP_DUMMY(nor->read_dummy, 0), SPI_MEM_OP_DATA_IN(0, NULL, 0)), .offset = 0, .length = nor->params->size, }; struct spi_mem_op *op = &info.op_tmpl; the spi-mem framework makes the assumption that the nor object is initialized. > I suggest you either make this a requirement of the API, how ? Thanks, C. > or create a new API that guarantees it will only be called after > the flash is initialized, like [0]. > > [0] https://patchwork.ozlabs.org/project/linux-mtd/patch/20210311191216.7363-2-p.yadav@ti.com/ > >> >> Cc: Pratyush Yadav >> Signed-off-by: Cédric Le Goater >> --- >