Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7236479rwb; Tue, 15 Nov 2022 09:20:29 -0800 (PST) X-Google-Smtp-Source: AA0mqf4AcewyFowWL0IlekiwvmPCGYwn06wfTJSZHyL+JkhYBZPMmXR3tIquhFVAgkh3Vt5IJIvl X-Received: by 2002:a63:fd41:0:b0:470:71df:7ec5 with SMTP id m1-20020a63fd41000000b0047071df7ec5mr16865785pgj.272.1668532828856; Tue, 15 Nov 2022 09:20:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668532828; cv=none; d=google.com; s=arc-20160816; b=x+d86mKMJg+7wra2P1A9OI1xlYSdg/oQbefxVvMdSLJXMvXYWGiJNgiumF9heVMeLa pz+IcBN7xWvZnSXe5/uhWF5tphQn9wqtrHjTjSrR/ADsZ6gWAIHnWmrvquIpGIuTqrx/ +G08u+Xgg3Rk265HypdnfMkBxAZCOk3nGngC766DVH43ZDxtVYOdH85Zld7a58cNZlaX vs4HSU6TltIG8u7UJRS7d2thaIKUxQPKH8rwmXJDeB6jj5opfwU39wrtjLY1A0tsM4Re NYhWVxML3pFplOidSowcGRD0t9Fyv0jQ7n61j8B/w7uR3CynRHqbBYJwtKd4IcyeFGOt 627w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=V4blfu7B2c/DkXCyaBC0mkO1CXFtVZaKt04aUaxP7xI=; b=YIg47cl+Hy4iMMJsgI9etC37IyG6y4PGrZzIoq6wbgXQWRBDz3KwnHBQ6S0ryYNrd/ ls01nDjdtiifhrQfZuYeDPzY7ZucCYH3ISv03X5JqrlWZ71MHUvswHOyryee/XxpHAM7 xd1vjZMIdcRx+C79aGnnKyTK+1fsbf6S2MgCzAubJVhMKbPs4YeHZ1zy53QK5CEOAzK1 OWyfyK70pvC8jBWLUDxDcXhmQFcmuAAed8zRmyJ3TSWufDmeOosVfkZEIsFIXa8F1jZc JPWu2nsLeJ7rt2dAKqS7VXjPVGeCTwjoF/PjutiZiQdz9wMDMWeO5YbpOwUK5BFVdYP1 KX0A== 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 pb6-20020a17090b3c0600b00212d9aae585si16594464pjb.57.2022.11.15.09.20.15; Tue, 15 Nov 2022 09:20:28 -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 S232589AbiKOQyp (ORCPT + 91 others); Tue, 15 Nov 2022 11:54:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231779AbiKOQyn (ORCPT ); Tue, 15 Nov 2022 11:54:43 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C53236165 for ; Tue, 15 Nov 2022 08:54:41 -0800 (PST) Received: from gallifrey.ext.pengutronix.de ([2001:67c:670:201:5054:ff:fe8d:eefb] helo=bjornoya.blackshift.org) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ouzCc-0007iv-CD; Tue, 15 Nov 2022 17:54:26 +0100 Received: from pengutronix.de (unknown [IPv6:2a03:f580:87bc:d400:6ac2:39cd:4970:9b29]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: mkl-all@blackshift.org) by smtp.blackshift.org (Postfix) with ESMTPSA id 6717211F6D8; Tue, 15 Nov 2022 16:54:22 +0000 (UTC) Date: Tue, 15 Nov 2022 17:54:13 +0100 From: Marc Kleine-Budde To: Frieder Schrempf Cc: David Jander , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, Mark Brown , Sascha Hauer , Shawn Guo , Marek Vasut , NXP Linux Team , stable@vger.kernel.org, Frieder Schrempf , Pengutronix Kernel Team , Baruch Siach , Fabio Estevam , Minghao Chi Subject: Re: [PATCH v2] spi: spi-imx: Fix spi_bus_clk if requested clock is higher than input clock Message-ID: <20221115165413.4tvmhiv64gdmctml@pengutronix.de> References: <20221115162654.2016820-1-frieder@fris.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="ewz52byjukhww6c4" Content-Disposition: inline In-Reply-To: <20221115162654.2016820-1-frieder@fris.de> X-SA-Exim-Connect-IP: 2001:67c:670:201:5054:ff:fe8d:eefb X-SA-Exim-Mail-From: mkl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS 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 --ewz52byjukhww6c4 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 15.11.2022 17:26:53, Frieder Schrempf wrote: > From: Frieder Schrempf >=20 > In case the requested bus clock is higher than the input clock, the corre= ct > dividers (pre =3D 0, post =3D 0) are returned from mx51_ecspi_clkdiv(), b= ut > *fres is left uninitialized and therefore contains an arbitrary value. >=20 > This causes trouble for the recently introduced PIO polling feature as the > value in spi_imx->spi_bus_clk is used there to calculate for which > transfers to enable PIO polling. >=20 > Fix this by setting *fres even if no clock dividers are in use. >=20 > This issue was observed on Kontron BL i.MX8MM with an SPI peripheral cloc= k set > to 50 MHz by default and a requested SPI bus clock of 80 MHz for the SPI = NOR > flash. >=20 > With the fix applied the debug message from mx51_ecspi_clkdiv() now print= s the > following: >=20 > spi_imx 30820000.spi: mx51_ecspi_clkdiv: fin: 50000000, fspi: 50000000, > post: 0, pre: 0 >=20 > Fixes: 07e759387788 ("spi: spi-imx: add PIO polling support") The *fres parameter was introduced in: | Fixes: 6fd8b8503a0d ("spi: spi-imx: Fix out-of-order CS/SCLK operation at= low speeds") The exiting code: | if (unlikely(fspi > fin)) | return 0; was not sufficient any more and should be fixed. Marc --=20 Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung West/Dortmund | Phone: +49-231-2826-924 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | --ewz52byjukhww6c4 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEBsvAIBsPu6mG7thcrX5LkNig010FAmNzxDMACgkQrX5LkNig 0110Zgf/Rqhnp8+E6FdaZsP6cCH4rkGX9yPjEfdoke2AoOZYNlE2+z/TNpYclQ5D bTbfVjwa8E68JFsqUBwCoAY68xQ0N53ijC65ziL1veRdOJafpCIAUU12USeDCSvX JzIQPTfzpzsHJyQqUoShoP4BGCZI0k56WQndSs2nrOcQku1u8XYuLlJHDyi8LhI4 p+W+o8Efaszewd4IuIrYPROrKA+FHGN4PHQh4UjQtICIWoFWQhaE4p0OeLY4yLph Rf1/i+yrrxhciog1YkHEAqQfdofcCSAq6NrZo9/MdXQwiRCXyhDhe+L0YOfvXQn3 IGHS49ow9mnNg/LLLUUKOHDqzOcNvA== =bbCr -----END PGP SIGNATURE----- --ewz52byjukhww6c4--