Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752879AbbHZSnf (ORCPT ); Wed, 26 Aug 2015 14:43:35 -0400 Received: from mezzanine.sirena.org.uk ([106.187.55.193]:36194 "EHLO mezzanine.sirena.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751337AbbHZSnd (ORCPT ); Wed, 26 Aug 2015 14:43:33 -0400 Date: Wed, 26 Aug 2015 19:43:23 +0100 From: Mark Brown To: Qais Yousef Cc: alsa-devel@alsa-project.org, Liam Girdwood , Jaroslav Kysela , Takashi Iwai , linux-kernel@vger.kernel.org Message-ID: <20150826184323.GE28760@sirena.org.uk> References: <1440419959-14315-1-git-send-email-qais.yousef@imgtec.com> <1440419959-14315-6-git-send-email-qais.yousef@imgtec.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="a+b56+3nqLzpiR9O" Content-Disposition: inline In-Reply-To: <1440419959-14315-6-git-send-email-qais.yousef@imgtec.com> X-Cookie: Victory uber allies! User-Agent: Mutt/1.5.23 (2014-03-12) X-SA-Exim-Connect-IP: 94.175.94.161 X-SA-Exim-Mail-From: broonie@sirena.org.uk Subject: Re: [PATCH 05/10] ALSA: axd: add buffers manipulation files 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: 2158 Lines: 73 --a+b56+3nqLzpiR9O Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Aug 24, 2015 at 01:39:14PM +0100, Qais Yousef wrote: > + /* > + * must ensure we have one access at a time to the queue and rd_idx > + * to be preemption and SMP safe > + * Sempahores will ensure that we will only read after a complete write > + * has finished, so we will never read and write from the same location. > + */ In what way will sempahores ensure that we will only read after a complete write? > + buf = bufferq->queue[bufferq->rd_idx]; So buffers are always retired in the same order that they are acquired? > +int axd_bufferq_put(struct axd_bufferq *bufferq, char *buf, int buf_size) > +{ > + int ret; > + > + if (!bufferq->queue) > + return 0; > + > + if (buf_size < 0) > + buf_size = bufferq->stride; We've got strides as well? What is that? > +void axd_bufferq_abort_take(struct axd_bufferq *bufferq) > +{ > + if (axd_bufferq_is_empty(bufferq)) { > + bufferq->abort_take = 1; > + up(&bufferq->rd_sem); > + } > +} > + > +void axd_bufferq_abort_put(struct axd_bufferq *bufferq) > +{ > + if (axd_bufferq_is_full(bufferq)) { > + bufferq->abort_put = 1; > + up(&bufferq->wr_sem); > + } > +} These look *incredibly* racy. Why are they here and why are they safe? --a+b56+3nqLzpiR9O Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJV3gjKAAoJECTWi3JdVIfQnKoH/AtcvuiB7W1ujxAejJqZKFLz CfAuL2+kcQbWxeg23amyKo4YnVzIEmDpD6Rp/6F/zYvVywBnW4RfdmW8+PMUGaX1 cQETxvpsWxwfo17je7Rw2sKLjC4CUI4QDHHK2l3kRfQS43ElTHPhvWHsGuTPoRAi VFiD9ktGteU8t6GCYa3Kdew0fLp0bQVUgRfx4tQGfh0cXA/obUSo72TZtzl3uRUW YLTiB0vVplxPMs4Mknp3/czNQ4QybzngQH/Bg3/ZMpEXHYQc73WmR9MPalxa4IDo L5JHz6Cv/5wGu1nCA6XeSJfD3KUQPkhm6c5h4zW/dacRv0matGFduVwTdqZ/e+Q= =HgYV -----END PGP SIGNATURE----- --a+b56+3nqLzpiR9O-- -- 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/