From patchwork Wed Dec 12 14:38:16 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guennadi Liakhovetski X-Patchwork-Id: 1867341 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 2236A3FC81 for ; Wed, 12 Dec 2012 14:38:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754328Ab2LLOii (ORCPT ); Wed, 12 Dec 2012 09:38:38 -0500 Received: from moutng.kundenserver.de ([212.227.17.9]:58563 "EHLO moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754456Ab2LLOi0 (ORCPT ); Wed, 12 Dec 2012 09:38:26 -0500 Received: from axis700.grange (dslb-146-060-250-080.pools.arcor-ip.net [146.60.250.80]) by mrelayeu.kundenserver.de (node=mrbap1) with ESMTP (Nemesis) id 0LjLyR-1T9Bmx0r31-00cpph; Wed, 12 Dec 2012 15:38:24 +0100 Received: from 6a.grange (6a.grange [192.168.1.11]) by axis700.grange (Postfix) with ESMTPS id EB520105FE; Wed, 12 Dec 2012 15:38:21 +0100 (CET) Received: from lyakh by 6a.grange with local (Exim 4.72) (envelope-from ) id 1TinRz-0004iQ-2S; Wed, 12 Dec 2012 15:38:19 +0100 From: Guennadi Liakhovetski To: linux-mmc@vger.kernel.org Cc: linux-sh@vger.kernel.org, Magnus Damm , Chris Ball Subject: [PATCH 12/14] mmc: sh-mmcif: reset DMA completion immediately before starting DMA Date: Wed, 12 Dec 2012 15:38:16 +0100 Message-Id: <1355323098-18061-13-git-send-email-g.liakhovetski@gmx.de> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1355323098-18061-1-git-send-email-g.liakhovetski@gmx.de> References: <1355323098-18061-1-git-send-email-g.liakhovetski@gmx.de> X-Provags-ID: V02:K0:gsJELThgjP+PutqM0SqokMuegPjte31FkHMJyGM8Ftp J+jNEn6rA5/HvawfDDQz3/VRtmNYHEQkNlVngsuQBN+KwxCRlO OiYgGirTQBno202Fh55kjMBDfKJwDaBQYOe6+xLiHlXtGJHuBA vIJ7OX/fxsuBMbK+AyO11yqtaOMr0cOlWN0vW8RRlybDpuevFZ Wc2Wie6N6ohpfTd8u0HNJ8LyEcrQqd/EYf99ydnmMt9f7ltcAo 3mOi9dyPRPSQvf4VUqxbWVsr5UG48Cgyv2S4rne0VRGrgz7niD 9C238JJdPf/e3zvpj+audmob1JAHP/OITNVx9AgZ8ZGFgOZuZ8 NDwmiFo0GMgoXSKPWq0iH2G2/u9kOT3jC2W0vT9l4UAyuGX6gY pyPX0odNfYwmPC2rulCh3SMfd+LcQDFdIU= Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org DMA completion can be signalled from the DMA callback and from the error handler. If both are called, the completion struct can enter an inconsistent state. To prevent this move completion initialisation immediately before activating DMA. Signed-off-by: Guennadi Liakhovetski --- drivers/mmc/host/sh_mmcif.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c index 03493e4..1dd7fc0 100644 --- a/drivers/mmc/host/sh_mmcif.c +++ b/drivers/mmc/host/sh_mmcif.c @@ -419,8 +419,6 @@ static void sh_mmcif_request_dma(struct sh_mmcif_host *host, if (ret < 0) goto ecfgrx; - init_completion(&host->dma_complete); - return; ecfgrx: @@ -1061,6 +1059,12 @@ static bool sh_mmcif_end_cmd(struct sh_mmcif_host *host) if (!data) return false; + /* + * Completion can be signalled from DMA callback and error, so, have to + * reset here, before setting .dma_active + */ + init_completion(&host->dma_complete); + if (data->flags & MMC_DATA_READ) { if (host->chan_rx) sh_mmcif_start_dma_rx(host);