From patchwork Tue Oct 20 09:46:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lars-Peter Clausen X-Patchwork-Id: 7445691 Return-Path: X-Original-To: patchwork-dmaengine@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 703DC9F302 for ; Tue, 20 Oct 2015 09:47:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 93E6B20885 for ; Tue, 20 Oct 2015 09:47:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B28C820880 for ; Tue, 20 Oct 2015 09:47:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753523AbbJTJrf (ORCPT ); Tue, 20 Oct 2015 05:47:35 -0400 Received: from smtp-out-200.synserver.de ([212.40.185.200]:1138 "EHLO smtp-out-188.synserver.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753515AbbJTJqn (ORCPT ); Tue, 20 Oct 2015 05:46:43 -0400 Received: (qmail 2866 invoked by uid 0); 20 Oct 2015 09:46:42 -0000 X-SynServer-TrustedSrc: 1 X-SynServer-AuthUser: lars@metafoo.de X-SynServer-PPID: 2410 Received: from pd9e2f76f.dip0.t-ipconnect.de (HELO lars-laptop.ad.analog.com) [217.226.247.111] by 217.119.54.77 with SMTP; 20 Oct 2015 09:46:41 -0000 From: Lars-Peter Clausen To: Vinod Koul , Takashi Iwai Cc: Dan Williams , Russell King , Laurent Pinchart , Kuninori Morimoto , Qiao Zhou , Shengjiu Wang , Matt Campbell , Jonah Petri , dmaengine@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Lars-Peter Clausen Subject: [PATCH 2/4] dmaengine: virt-dma: Add synchronization helper function Date: Tue, 20 Oct 2015 11:46:29 +0200 Message-Id: <1445334391-12272-3-git-send-email-lars@metafoo.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1445334391-12272-1-git-send-email-lars@metafoo.de> References: <1445334391-12272-1-git-send-email-lars@metafoo.de> Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a synchronize helper function for the virt-dma library. The function makes sure that any scheduled descriptor complete callbacks have finished running before the function returns. This needs to be called by drivers using virt-dma in their device_synchronize() callback. Depending on the driver additional operations might be necessary in addition to calling vchan_synchronize() to ensure proper synchronization. Signed-off-by: Lars-Peter Clausen --- drivers/dma/virt-dma.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/dma/virt-dma.h b/drivers/dma/virt-dma.h index 181b9526..e93de76 100644 --- a/drivers/dma/virt-dma.h +++ b/drivers/dma/virt-dma.h @@ -151,4 +151,17 @@ static inline void vchan_free_chan_resources(struct virt_dma_chan *vc) vchan_dma_desc_free_list(vc, &head); } +/** + * vchan_synchronize() - synchronize callback execution to the current context + * @vc: virtual channel to synchronize + * + * Makes sure that all scheduled or active callbacks have finished running. For + * proper operation the caller has to ensure that no new callbacks are scheduled + * after the invocation of this function started. + */ +static inline void vchan_synchronize(struct virt_dma_chan *vc) +{ + tasklet_kill(&vc->task); +} + #endif