Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753244AbbB0OqY (ORCPT ); Fri, 27 Feb 2015 09:46:24 -0500 Received: from ns.mm-sol.com ([37.157.136.199]:36189 "EHLO extserv.mm-sol.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752158AbbB0OqX (ORCPT ); Fri, 27 Feb 2015 09:46:23 -0500 Message-ID: <54F08339.5020708@mm-sol.com> Date: Fri, 27 Feb 2015 16:46:17 +0200 From: Stanimir Varbanov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130330 Thunderbird/17.0.5 MIME-Version: 1.0 To: Mark Brown CC: Stanimir Varbanov , 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 Subject: Re: [PATCH v2] spi: qup: Add DMA capabilities References: <1424782803-13103-1-git-send-email-stanimir.varbanov@linaro.org> <20150224135622.GH6236@finisterre.sirena.org.uk> <54ECA216.306@linaro.org> <20150226023317.GE6236@finisterre.sirena.org.uk> In-Reply-To: <20150226023317.GE6236@finisterre.sirena.org.uk> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1612 Lines: 40 On 02/26/2015 04:33 AM, Mark Brown wrote: > 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. > yep, that's what I wanted to express in third option above. -- regards, Stan -- 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/