Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752552AbbBXN52 (ORCPT ); Tue, 24 Feb 2015 08:57:28 -0500 Received: from mezzanine.sirena.org.uk ([106.187.55.193]:52440 "EHLO mezzanine.sirena.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750880AbbBXN51 (ORCPT ); Tue, 24 Feb 2015 08:57:27 -0500 Date: Tue, 24 Feb 2015 22:56:23 +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: <20150224135622.GH6236@finisterre.sirena.org.uk> References: <1424782803-13103-1-git-send-email-stanimir.varbanov@linaro.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="K5rlT6r/WqkiQKGB" Content-Disposition: inline In-Reply-To: <1424782803-13103-1-git-send-email-stanimir.varbanov@linaro.org> X-Cookie: for ARTIFICIAL FLAVORING!! User-Agent: Mutt/1.5.23 (2014-03-12) X-SA-Exim-Connect-IP: 106.188.14.230 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: 1744 Lines: 52 --K5rlT6r/WqkiQKGB Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Feb 24, 2015 at 03:00:03PM +0200, Stanimir Varbanov wrote: > +static void spi_qup_dma_done(void *data) > +{ > + struct spi_qup *qup = data; > + > + if (atomic_dec_and_test(&qup->dma_outstanding)) > + complete(&qup->done); > +} I'm finding it hard to be thrilled about the use of atomics for synchronization (they're just generally hard to work with) and... > + cookie = dmaengine_submit(desc); > + ret = dma_submit_error(cookie); > + if (ret) > + return ret; > + atomic_inc(&qup->dma_outstanding); ..don't we have two potential races here: one if somehow the DMA manages to complete prior to the atomic_inc() (unlikely but that's what race conditions are all about really) and one if we are issuing multiple DMAs and the early ones complete before the later ones are issued? --K5rlT6r/WqkiQKGB Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJU7IMGAAoJECTWi3JdVIfQu/cH/1fG6dAPVLBUQg0T80p8/VQd pt4mPNUOjdBaV+TJArpDC++jEHj5USYzbhk+KmDiZ8Yg4G6q26htfL4x6gNeC8d/ pLoW5dtZa/0Z+OVBmtDhtLvaSqNU+u6VfViR9DAH1UYU+OhaSFyW1GSpwEkxGZEt p1R2EPr0IYK1NOt7KQjbv9gF/EdUc3unYPlX9eT4jY97Rq9H/ZJlJGeO2CfuC8L6 rtaVRkRyuk6/BNfmuDHKLx9N0L0AJDKbpgKYjs4vsB1DYw+sbhs0ud8fZtJMktPk z3FhKTYZvmvAZvV1u9ERiFun+S4s1NcAFYoiObs18jJHfRHvcX2MJu+mZR19lgs= =9BCd -----END PGP SIGNATURE----- --K5rlT6r/WqkiQKGB-- -- 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/