From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1CCEFCD6E5D for ; Fri, 5 Jun 2026 06:16:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:References :In-Reply-To:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=c4lVPqZsoSipXBUP19peXfQ5UiZLtDnptalKcBB7a4g=; b=FtmAiMF83QaSGZ rpATN3noq6vXfwgCmtrZHL+6I1irSrAaJzw+p0P63x7jqcBgaQOeSR6mDVgGk74ysgbnWfGPUv2qt QmKBKf4uv1IOfyWzjTetgaWoYOPpKDn2x2fMrF1MCHbEqMBXHljiOtwPh2g1RKtfYJfD5qeKqXEmO 6eGXCGg06AojiGkr8Ym5zJWXW6dKWMYQg9DfMaURe5HCP4ZxvQaPqIEpZ8jW1K8c3j3su6PwZMjtr wL7DroidjBmUpctIZObWES646NgjBk448M3bG27BulwKhuBcin0be8gZTxi+Jq83wfStxhhRHpW5l gkw1Dg5+heFCWwMMPCGw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wVNql-000000008y9-2Tty; Fri, 05 Jun 2026 06:16:11 +0000 Received: from smtpout-02.galae.net ([185.246.84.56]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wVNqi-000000008xi-0zNU for linux-mtd@lists.infradead.org; Fri, 05 Jun 2026 06:16:10 +0000 Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 071F91A0904; Fri, 5 Jun 2026 06:16:05 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id B77BA5FED1; Fri, 5 Jun 2026 06:16:04 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 3E923106A1EE4; Fri, 5 Jun 2026 08:15:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1780640163; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=deiuXUFDNSX7cfC+kx+/zdue7rrj2MqboxTE2cMg8zE=; b=cHzlsZS2hSySMxs5YUSmcxkzm4CHL4ifkBgF3iZ+s0sxiTlqKSFgF3Ygfz6DjgQr2eS/N6 dQdX/HnAaJ6AuiDDIRsOpRXSdkppcayDYo0Bv9zJ6dUAS5xT9DRhyX6hmupWwkr5oiZXIS aLvyCQdark05GVxMuc5TdJm9W5NfjBTcYsfnxbZiDysCviCZwSVWrpoW1LX95R63CLrTk+ Juo/BjZ5OutF7onvPh5K1UEOuyskhoaGcqrS9EdYXll1ThE6jYJ3jKDotEIzWwOWhqXw9D RNmF+7TlRBdVFRZXG4XCvNnBGZ/yftz4c+MbbEh8eAQt1EWy6xLbSjHkQ9OLog== From: Miquel Raynal To: Santhosh Kumar K Cc: , , , , , , , , , , , , , , , Subject: Re: [PATCH v3 04/13] spi: spi-mem: add spi_mem_apply_base_freq_cap() In-Reply-To: <354e81b1-3070-439b-b404-20a2c30bd774@ti.com> (Santhosh Kumar K.'s message of "Thu, 4 Jun 2026 17:40:26 +0530") References: <20260527175527.2247679-1-s-k6@ti.com> <20260527175527.2247679-5-s-k6@ti.com> <87fr3bhqkk.fsf@bootlin.com> <354e81b1-3070-439b-b404-20a2c30bd774@ti.com> User-Agent: mu4e 1.12.7; emacs 30.2 Date: Fri, 05 Jun 2026 08:15:57 +0200 Message-ID: <87fr31wm02.fsf@bootlin.com> MIME-Version: 1.0 X-Last-TLS-Session-Version: TLSv1.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260604_231608_432918_671773FE X-CRM114-Status: GOOD ( 11.94 ) X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+linux-mtd=archiver.kernel.org@lists.infradead.org SGkgU2FudGhvc2gsCgpPbiAwNC8wNi8yMDI2IGF0IDE3OjQwOjI2ICswNTMwLCBTYW50aG9zaCBL dW1hciBLIDxzLWs2QHRpLmNvbT4gd3JvdGU6Cgo+IEhlbGxvIE1pcXVlbCwKPgo+IE9uIDI4LzA1 LzI2IDE0OjEzLCBNaXF1ZWwgUmF5bmFsIHdyb3RlOgo+PiBIaSBTYW50aG9zaCwKPj4gCj4+PiAt LS0gYS9kcml2ZXJzL3NwaS9zcGktbWVtLmMKPj4+ICsrKyBiL2RyaXZlcnMvc3BpL3NwaS1tZW0u Ywo+Pj4gQEAgLTM5OCw3ICszOTgsMTEgQEAgaW50IHNwaV9tZW1fZXhlY19vcChzdHJ1Y3Qgc3Bp X21lbSAqbWVtLCBjb25zdCBzdHJ1Y3Qgc3BpX21lbV9vcCAqb3ApCj4+PiAgIAl1OCAqdG1wYnVm Owo+Pj4gICAJaW50IHJldDsKPj4+ICAgLQkvKiBNYWtlIHN1cmUgdGhlIG9wZXJhdGlvbiBmcmVx dWVuY3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RpbmZvL2xpbnV4 LW10ZC8K 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 DEF76405C22 for ; Fri, 5 Jun 2026 06:16:06 +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=1780640172; cv=none; b=PzGNRewr3NL1AORikm61e8uoZ2xQp7f+C8vDb/tCfAZSM/TjeRvpN0JRgN036w22F57ArMFNPz56scG26yruwAkcGr3NfSEegGbaLrsURp6otxyO06+5dMCOZpoIe3UfDhtEkAozelXayDYVDQLrzeA4om9TyZ0UJSZNpvZheiM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780640172; c=relaxed/simple; bh=tooW/XxqZtgoRZGuqoPGpyAcWluv8ktlW6V5MDUZHPk=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=rV2T/hwyF74NAi6NyLXP22Lb/MyqRJsU9Jb3uFu8AvDr+K4PgBZz+4JZIjjMNupGvft9UsGO8Gr/GHdSeLa1aFirOZa1iRFdA/ylDMVDSpaTHzx76AFe1dMnVTZAIgHcNcx9Rq64BW+VjRivVVwbXjIl5LBlbBed5EqfFNSQ0EA= 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=cHzlsZS2; 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="cHzlsZS2" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id F13254E40769; Fri, 5 Jun 2026 06:16:04 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id B77BA5FED1; Fri, 5 Jun 2026 06:16:04 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 3E923106A1EE4; Fri, 5 Jun 2026 08:15:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1780640163; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=deiuXUFDNSX7cfC+kx+/zdue7rrj2MqboxTE2cMg8zE=; b=cHzlsZS2hSySMxs5YUSmcxkzm4CHL4ifkBgF3iZ+s0sxiTlqKSFgF3Ygfz6DjgQr2eS/N6 dQdX/HnAaJ6AuiDDIRsOpRXSdkppcayDYo0Bv9zJ6dUAS5xT9DRhyX6hmupWwkr5oiZXIS aLvyCQdark05GVxMuc5TdJm9W5NfjBTcYsfnxbZiDysCviCZwSVWrpoW1LX95R63CLrTk+ Juo/BjZ5OutF7onvPh5K1UEOuyskhoaGcqrS9EdYXll1ThE6jYJ3jKDotEIzWwOWhqXw9D RNmF+7TlRBdVFRZXG4XCvNnBGZ/yftz4c+MbbEh8eAQt1EWy6xLbSjHkQ9OLog== From: Miquel Raynal To: Santhosh Kumar K Cc: , , , , , , , , , , , , , , , Subject: Re: [PATCH v3 04/13] spi: spi-mem: add spi_mem_apply_base_freq_cap() In-Reply-To: <354e81b1-3070-439b-b404-20a2c30bd774@ti.com> (Santhosh Kumar K.'s message of "Thu, 4 Jun 2026 17:40:26 +0530") References: <20260527175527.2247679-1-s-k6@ti.com> <20260527175527.2247679-5-s-k6@ti.com> <87fr3bhqkk.fsf@bootlin.com> <354e81b1-3070-439b-b404-20a2c30bd774@ti.com> User-Agent: mu4e 1.12.7; emacs 30.2 Date: Fri, 05 Jun 2026 08:15:57 +0200 Message-ID: <87fr31wm02.fsf@bootlin.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Hi Santhosh, On 04/06/2026 at 17:40:26 +0530, Santhosh Kumar K wrote: > Hello Miquel, > > On 28/05/26 14:13, Miquel Raynal wrote: >> Hi Santhosh, >>=20 >>> --- a/drivers/spi/spi-mem.c >>> +++ b/drivers/spi/spi-mem.c >>> @@ -398,7 +398,11 @@ int spi_mem_exec_op(struct spi_mem *mem, const str= uct spi_mem_op *op) >>> u8 *tmpbuf; >>> int ret; >>> - /* Make sure the operation frequency is correct before going >>> futher */ >>> + /* >>> + * Ops not configured for maximum speed are limited to the conservati= ve >>> + * base speed; spi_mem_adjust_op_freq() then caps to the device maxim= um. >>> + */ >>> + spi_mem_apply_base_freq_cap(mem, (struct spi_mem_op *)op); >>> spi_mem_adjust_op_freq(mem, (struct spi_mem_op *)op); >> There are many more spi_mem_adjust_op_freq() calls in the core where >> we would >> not apply the base frequency. Aren't we missing these places? Wouldn't it >> be more appropriate to call spi_mem_apply_base_freq_cap() at the beginni= ng >> of spi_mem_adjust_op_freq() ? > > Moving spi_mem_apply_base_freq() into spi_mem_adjust_op_freq() would > affect operation selection. Yes, and that is precisely what we want. > spi_mem_adjust_op_freq() is used during variant evaluation through > spinand_select_op_variant() and spi_mem_calc_op_duration(). And this is a one time specific initialization path. There we need more logic, probably. > Applying the > cap there would cause all candidates to be evaluated at base_speed_hz > rather than the actual max_speed_hz. As a result, variant selection > could converge on a different operation than the one that would be > optimal. But this is only a single place. Whereas in your implementation you push the complexity in every place using the spi mem interface, I don't think this is wise as you will likely end up with many unseen corner cases. Thanks, Miqu=C3=A8l