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 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D53F4C47257 for ; Fri, 8 May 2020 17:30:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B4FDE218AC for ; Fri, 8 May 2020 17:30:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588959027; bh=0gKRQpi2KaSxsOl0ZhcPyYXDz/x9dFFAJqh3/p3z9WM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=tsw201o+jXOn18hTUwV/h9D+0ONtsdP8SlGr9Ez+AIDEsVDullF7iyosTKRANjX+W 5fdJGsRxR434LJB4qNPKLdHZgJBYtokd6rKrK10BprAkgXbq5t7InF6h7xHsWByChB QUKq6ub/FyvQLqqkcfm+b56lKiZR8sl/KuqrUuNo= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727107AbgEHRa1 (ORCPT ); Fri, 8 May 2020 13:30:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:60636 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726746AbgEHRa0 (ORCPT ); Fri, 8 May 2020 13:30:26 -0400 Received: from localhost (fw-tnat.cambridge.arm.com [217.140.96.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8225A2184D; Fri, 8 May 2020 17:30:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588959026; bh=0gKRQpi2KaSxsOl0ZhcPyYXDz/x9dFFAJqh3/p3z9WM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=vKqqyuvPjhkAzCGClJKkDSVKAyZwKhi6gaCRFPy7ElHjRQpeDtZHzw41IyWBqBPa5 /LSR615uZXfQyokHoAD6fu8KO1d66CCehqEWBRv9oF84YEjQztZT1nbAXEKgQ6rJa9 s7U4PQW1G+P/mZyBqZE/2eeNcZzIrjaH2LvCTis8= Date: Fri, 8 May 2020 18:30:23 +0100 From: Mark Brown To: Serge Semin Cc: Serge Semin , Georgy Vlasov , Ramil Zaripov , Alexey Malahov , Thomas Bogendoerfer , Paul Burton , Ralf Baechle , Arnd Bergmann , Allison Randal , Andy Shevchenko , Gareth Williams , Rob Herring , linux-mips@vger.kernel.org, devicetree@vger.kernel.org, Thomas Gleixner , "wuxu.wu" , Linus Walleij , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 07/17] spi: dw: Add Tx/Rx finish wait methods to DMA Message-ID: <20200508173023.GO4820@sirena.org.uk> References: <20200508132943.9826-1-Sergey.Semin@baikalelectronics.ru> <20200508132943.9826-8-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="CbqR2XcyIs6OSP+I" Content-Disposition: inline In-Reply-To: <20200508132943.9826-8-Sergey.Semin@baikalelectronics.ru> X-Cookie: Give him an evasive answer. User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --CbqR2XcyIs6OSP+I Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, May 08, 2020 at 04:29:32PM +0300, Serge Semin wrote: > Since DMA transfers are performed asynchronously with actual SPI > transaction, then even if DMA transfers are finished it doesn't mean > all data is actually pushed to the SPI bus. Some data might still be This looks like a bug fix so it should really have gone at the start of the series so it can be sent to Linus as a bug fix rather than waiting for the merge window. This makes sense to me, a couple of nits below: > +static void dw_spi_dma_wait_tx_done(struct dw_spi *dws) > +{ > + int retry = WAIT_RETRIES; > + unsigned long ns; > + > + ns = (NSEC_PER_SEC / spi_get_clk(dws)) * dws->n_bytes * BITS_PER_BYTE; > + ns *= dw_readl(dws, DW_SPI_TXFLR); > + > + while (dw_spi_dma_tx_busy(dws) && retry--) > + ndelay(ns); How deep can the FIFO be with this IP - could we end up ndelay()ing for non-trivial amounts of time? > +static inline u32 spi_get_clk(struct dw_spi *dws) > +{ > + u32 div = dw_readl(dws, DW_SPI_BAUDR); > + > + return div ? dws->max_freq / div : 0; Please write normal conditional statements rather than using the ternery operator - it helps with legibility. --CbqR2XcyIs6OSP+I Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAl61ly4ACgkQJNaLcl1U h9Ai2Qf/WPH1t7wgklh6vuMSUy2FBvsRnaDP6wc4mxtKqpcm+bsscPDA26ZnfSJE Uw4yfOO0JLjtRN6ZGSzYIKcDl3k6y3upXZdGBjZB96bmqjSTgc52QqDrTiDCdaRg C9zf5J5L/OXARSk20XHTHnqV/F0nKPMxMVUcUYrZodnARTpvq33BaEJFBfWfaUYC oJJpZfKpHSXzQMrTTULOAGYKqJgLYTxObMai31W46Io2VCF+02Wk1RUeS42VFEt0 vbusbfJO0D0MqcUZ6HzHSwFfkWaUWguCYboe7dYf+A3goddE2QZgP7CSvV+0yvxM h+q4ml5Yg4KZIFGg+tZZrCozvh2tOA== =kVhk -----END PGP SIGNATURE----- --CbqR2XcyIs6OSP+I--