From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0E32F374169 for ; Mon, 16 Mar 2026 09:57:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773655040; cv=none; b=OCWGUj5WWoKI40uP3Z+Y6e+NSCXUy1DaObOY88qWLS0xTRpMnwC71RuPRj+VP5Jxm1+ER18YQ0xBCg8UIDVaO2fSokQclf9zHvQGUm8qigHK4dYaVlAxO0C+noEuqgmstnU4Q7oqkf+ke1+evSufqlioN3kVh5tcjaxnX1liui4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773655040; c=relaxed/simple; bh=7brzX4WOi+5jYVLMoJofPutcuzGjrekvjwI7c1OWTA0=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=FJNZHBoTjL3CEJC9YzXSKJZysEbr3KGVf0VMMdceGZ/3UJG4jbQWWdj7T2QjZ6fIQLSiEydWfVmRD8edYTluWxKey01FBcS98IovVCbrHXBKiYSAeJxa148frnYuSoDZF0sE4NG+xw7edX+YWG2zf8pxGcZ0hjTkgBKoBszrdGs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=mKt49IQt; arc=none smtp.client-ip=209.85.221.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="mKt49IQt" Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-439ce3605ecso3249979f8f.0 for ; Mon, 16 Mar 2026 02:57:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1773655037; x=1774259837; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=ORR2k9D3W/c7ahH5HJ1Wm+dpUNHSI19Jin/n96XvaOU=; b=mKt49IQtq7Up/4AfWeOx4yqmt3a+xXbMUHoXhGGY3rkDnFvYAJDpQlstGhf/VeFaGI 9QxFzB/oqSB8PsfFg0lfCey8n2S+SgkzP2xN693zkzneYEL2OWJ7GE/b8ef081LXEUmc DcmaXKVsDIuskaUyQlTxeUvZBr9b48CKUs3gbJKazxdoBhhvLDkcDRV1ZfYbXeX0jK9q Augyd4uRZm5I+DdKcFaJJLASix/SLJ3BeQ3i9p8puYkonNHi9q2usA4iUNomwt6R2TqD jwzq8ZadqoLthQNAZKg5iA0WVVpOt80Ju0/wwrjpwZflJFaDCgYv/FoKzkvLcSPrm4Ys YHEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773655037; x=1774259837; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ORR2k9D3W/c7ahH5HJ1Wm+dpUNHSI19Jin/n96XvaOU=; b=Bji2+wC/2/DzTo4X4vjaFh621xCydn2HRRBSZRLICrvaM9MOJkIHb8Yu6fsOLwW4X7 sMPURb4u7sBfKMtMuf9G4BGKOcNEIjiQwgnAIl5B+VXk0531ZlvwkRKL3tparr3F1xNE eDUMAOTduDUtFWHBp8nDcrOIssBo6U1VIsMrJ15wZFFDADonjvccdHDN7Xgt07DuAY7b Z40KBxxX9+l5zoVNCgqUAGc+0J2Z2F19HRugqArFHFR+ln6mu2epAgmyjvMTTcq5Hcxd 0mEGLYN40+F9h2521EtOcOs0e2ipLlQSQh8OTCkTphbKl+m8xPGjxyiAfjcHcmZZ3XX1 yYjg== X-Forwarded-Encrypted: i=1; AJvYcCU7F2UffbQA8kBbgy6QLwdGc9feA3UPKlczteM6/wIi0oTeuwAdSNBjVwJ5Ta+4wwMxAZOZcH5kuFFnlh0=@vger.kernel.org X-Gm-Message-State: AOJu0YwBmeQxcVwI4byNbUcs8m3qA4e7dTNt4MljOEL9DCHj8Ly9Trvs nY6r2YM10HznSGxWKZOwh5DMeug87sBRHX9dATT1V4gTgQ8eWe+WKDpk146hz75tTG0= X-Gm-Gg: ATEYQzySgD5ZX5k3kHUXG2v4lsCVC/GUZdI+Xzf96j7STrDFaI2ISlcCxauWW4aO03p CnyJVBJLYraOYx1CxfgiTgXcfECf5qK/p680ytvnnFu1ILk+U8HCAWQkgBoMHkeO/hJPXM7bwUx bODy7DZL4Ke/Z19Jicz9I9NW4NhO4A0rwzT/KihCYJapYwAxxKfUEDFmNg8rYe9puTjWapI6m8m /BTP6nD8vMyvS4XZrMfBxOwWsliIcEfYtMavDoS7Wq0tGd50PgGDM0KyIQXUQAo8P5j0iPQuPNP /z7rXmQwWdVVBLosAb9J2DoLhUA5wZKjuch0utHWjSYkVvEYRCM5LPKn7OT5gW2axxOviuAXZlT fKCqbZaaWI+urBVYRia9sNJHGs+6H3JckXbAwCBjNk/9HGYyLm5LLcvSL7wWIFGh2QbHW7KzbM+ Kom9s0UFgShCbfEKMDxHWbrW7s4Zko X-Received: by 2002:a5d:5d86:0:b0:439:b3a3:7239 with SMTP id ffacd0b85a97d-43a04d78189mr21771898f8f.5.1773655037253; Mon, 16 Mar 2026 02:57:17 -0700 (PDT) Received: from [192.168.1.3] ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43b3b0e9b99sm18531007f8f.18.2026.03.16.02.57.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 16 Mar 2026 02:57:16 -0700 (PDT) Message-ID: Date: Mon, 16 Mar 2026 09:57:15 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH spi-next 11/11] spi: spi-fsl-lpspi: fsl_lpspi_set_bitrate(): don't treat devtype_data->prescale_max == 0 as a special case To: Marc Kleine-Budde Cc: linux-spi@vger.kernel.org, imx@lists.linux.dev, linux-kernel@vger.kernel.org, kernel@pengutronix.de, Frank Li , Mark Brown References: <20260316-spi-fsl-lpspi-cleanups-v1-0-1b695607702d@pengutronix.de> <20260316-spi-fsl-lpspi-cleanups-v1-11-1b695607702d@pengutronix.de> Content-Language: en-US From: James Clark In-Reply-To: <20260316-spi-fsl-lpspi-cleanups-v1-11-1b695607702d@pengutronix.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 16/03/2026 8:39 am, Marc Kleine-Budde wrote: > The i.MX93 is affected by erratum ERR051608, the maximum prescaler value is > 1 not 7 as in the original datasheet. > > On unaffected SoC the maximum prescaler is 7. Commit 783bf5d09f86 ("spi: > spi-fsl-lpspi: limit PRESCALE bit in TCR register") added struct > fsl_lpspi_devtype_data to hold the system dependent prescale_max value. > > Commit 9bbfb1ec959c ("spi: spi-fsl-lpspi: Treat prescale_max == 0 as no > erratum") introduced the special value 0 to signal the default and > corresponding run-time check with a conditional operator. > > To simplify the code, set the prescale_max of imx7ulp_lpspi_devtype_data The whole point of the original change was to not repeat the normal value for every device in the config just because one device has an errata. This new change is exactly the opposite of simplification IMO. > and s32g_lpspi_devtype_data to 7 and in fsl_lpspi_set_bitrate() directly > use the fsl_lpspi->devtype_data->prescale_max. > > On ARM64 this leads to a reduction of the code of 52 bytes: > > | add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-52 (-52) > | Function old new delta > | fsl_lpspi_setup_transfer.isra 956 936 -20 > | $x 7144 7112 -32 On clang 15 this change makes it bigger by 220 bytes rather than smaller. I checked because I was suspicious that removing a single ternary could save 52 bytes, but it looks like the outcome after all the optimisations is just unpredictable so there isn't much point in making changes like this. You also didn't say _why_ we need to save 50 bytes, or what the performance impact is. > | Total: Before=19675, After=19623, chg -0.26% > > This partly reverts commit 9bbfb1ec959ce95f91cfab544f705e5257be3be1. > > Cc: James Clark > Signed-off-by: Marc Kleine-Budde > --- > drivers/spi/spi-fsl-lpspi.c | 13 ++++++++----- > 1 file changed, 8 insertions(+), 5 deletions(-) > > diff --git a/drivers/spi/spi-fsl-lpspi.c b/drivers/spi/spi-fsl-lpspi.c > index 3a0e9726fa71..f2c7bb3bc4cc 100644 > --- a/drivers/spi/spi-fsl-lpspi.c > +++ b/drivers/spi/spi-fsl-lpspi.c > @@ -96,7 +96,7 @@ > #define SR_CLEAR_MASK GENMASK(13, 8) > > struct fsl_lpspi_devtype_data { > - u8 prescale_max : 3; /* 0 == no limit */ > + u8 prescale_max : 3; > bool query_hw_for_num_cs : 1; > }; > > @@ -143,8 +143,10 @@ struct fsl_lpspi_data { > }; > > /* > - * Devices with ERR051608 have a max TCR_PRESCALE value of 1, otherwise there is > - * no prescale limit: https://www.nxp.com/docs/en/errata/i.MX93_1P87f.pdf > + * Devices with ERR051608 have a max TCR_PRESCALE value of 1, otherwise use > + * the register limit of 7. > + * > + * https://www.nxp.com/docs/en/errata/i.MX93_1P87f.pdf > */ > static const struct fsl_lpspi_devtype_data imx93_lpspi_devtype_data = { > .prescale_max = 1, > @@ -152,10 +154,11 @@ static const struct fsl_lpspi_devtype_data imx93_lpspi_devtype_data = { > }; > > static const struct fsl_lpspi_devtype_data imx7ulp_lpspi_devtype_data = { > - /* All defaults */ > + .prescale_max = 7, > }; > > static const struct fsl_lpspi_devtype_data s32g_lpspi_devtype_data = { > + .prescale_max = 7, > .query_hw_for_num_cs = true, > }; > > @@ -348,7 +351,7 @@ static int fsl_lpspi_set_bitrate(struct fsl_lpspi_data *fsl_lpspi) > int scldiv; > > perclk_rate = clk_get_rate(fsl_lpspi->clk_per); > - prescale_max = fsl_lpspi->devtype_data->prescale_max ?: 7; > + prescale_max = fsl_lpspi->devtype_data->prescale_max; > > if (!config.speed_hz) { > dev_err(fsl_lpspi->dev, >