Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753556AbbBZCeU (ORCPT ); Wed, 25 Feb 2015 21:34:20 -0500 Received: from mezzanine.sirena.org.uk ([106.187.55.193]:54850 "EHLO mezzanine.sirena.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753302AbbBZCeS (ORCPT ); Wed, 25 Feb 2015 21:34:18 -0500 Date: Thu, 26 Feb 2015 11:33:17 +0900 From: Mark Brown To: Stanimir Varbanov Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-spi@vger.kernel.org, Rob Herring , Mark Rutland , Kumar Gala , Andy Gross , Sagar Dharia , Daniel Sneddon Message-ID: <20150226023317.GE6236@finisterre.sirena.org.uk> References: <1424782803-13103-1-git-send-email-stanimir.varbanov@linaro.org> <20150224135622.GH6236@finisterre.sirena.org.uk> <54ECA216.306@linaro.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="LuH5Zozo3bmn6wjd" Content-Disposition: inline In-Reply-To: <54ECA216.306@linaro.org> X-Cookie: for ARTIFICIAL FLAVORING!! User-Agent: Mutt/1.5.23 (2014-03-12) X-SA-Exim-Connect-IP: 106.188.12.244 X-SA-Exim-Mail-From: broonie@sirena.org.uk Subject: Re: [PATCH v2] spi: qup: Add DMA capabilities X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:24:06 +0000) X-SA-Exim-Scanned: Yes (on mezzanine.sirena.org.uk) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2153 Lines: 55 --LuH5Zozo3bmn6wjd Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Feb 24, 2015 at 06:08:54PM +0200, Stanimir Varbanov wrote: > yes, there is a potential race between atomic_inc and dma callback. I > reordered these calls to save few checks, and now it returns to me. > I imagine few options here: > - reorder the dmaengine calls and atomic operations, i.e. > call atomic_inc for rx and tx channels before corresponding > dmaengine_submit and dmaengine_issue_pending. > - have two different dma callbacks and two completions and waiting for > the two. > - manage to receive only one dma callback, i.e. the last transfer in > case of presence of the rx_buf and tx_buf at the same time. > - let me see for better solution. Any solution which doesn't make use of atomics is likely to be better, as I said they are enormously error prone. A more common approach is a single completion triggering on the RX (for RX only or bidirectional transfers) or TX if that's the only thing active. For most hardware you can just use the RX to manage completion since it must of necessity complete at the same time as or later than the transmit side, transmit often completes early since the DMA completes when the FIFO is full not when the data is on the wire. --LuH5Zozo3bmn6wjd Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJU7oXsAAoJECTWi3JdVIfQ6dEH/i01U4dPHFLAyECWxZgarSWL 6/8J05YeGghSPz6NRFt5yjegy/vuTyyEptgrKzyy+hd23Iq6bl7RMa28YbEuAd8m 9gsa/azVnI7RIPoh8qkyjTSceF6kEe4OJ0C46V6gvBjS4mwHyUWH8nJOYX9AL45q izl6VvwhTOZXZtZaCm9mSw48Q8bhL7r0/NJL6ysa3Di3oYQNZ0cfIlhuzmy73NqT zr9e+2LEJzQm4oXS30GxJD0Eu4eH2Pq5k9yJZm9DoAfmQVY9+VIZmQ4C9IhP/VYB Cc4APLjLaEQZb92RwdcHa4rbTNlwhnBSkY+SnMigDN4q0n1TamEslat1tcctXcI= =x3K5 -----END PGP SIGNATURE----- --LuH5Zozo3bmn6wjd-- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/