From patchwork Thu Aug 21 11:01:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang Wang X-Patchwork-Id: 4756621 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6D0879F2E9 for ; Thu, 21 Aug 2014 11:03:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5F0A4200EC for ; Thu, 21 Aug 2014 11:03:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 82943200E7 for ; Thu, 21 Aug 2014 11:03:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754690AbaHULDF (ORCPT ); Thu, 21 Aug 2014 07:03:05 -0400 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:25826 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754687AbaHULDD (ORCPT ); Thu, 21 Aug 2014 07:03:03 -0400 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.14.5/8.14.5) with SMTP id s7LB2wew029406; Thu, 21 Aug 2014 04:02:58 -0700 Received: from sc-owa01.marvell.com ([199.233.58.136]) by mx0b-0016f401.pphosted.com with ESMTP id 1nwduuramk-19 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NOT); Thu, 21 Aug 2014 04:02:58 -0700 Received: from maili.marvell.com (10.93.76.43) by sc-owa01.marvell.com (10.93.76.21) with Microsoft SMTP Server id 8.3.327.1; Thu, 21 Aug 2014 04:02:57 -0700 Received: from localhost (unknown [10.38.34.193]) by maili.marvell.com (Postfix) with ESMTP id EBD8E3F7040; Thu, 21 Aug 2014 04:02:56 -0700 (PDT) From: Xiang Wang To: Vinod Koul , Dan Williams , , , , CC: Xiang Wang Subject: [PATCH] dmaengine: increase privatecnt in dma_get_any_slave_channel Date: Thu, 21 Aug 2014 19:01:21 +0800 Message-ID: <1408618881-30279-1-git-send-email-wangxfdu@gmail.com> X-Mailer: git-send-email 1.7.5.4 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.12.52, 1.0.27, 0.0.0000 definitions=2014-08-21_04:2014-08-21, 2014-08-21, 1970-01-01 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=7.0.1-1402240000 definitions=main-1408210131 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,HK_RANDOM_FROM,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 From: Xiang Wang There might be such calling sequence for dma channel: 1. register dma device dma_async_device_register -> if (dma_has_cap(DMA_PRIVATE, device->cap_mask)) device->privatecnt++; 2. request channel dma_request_slave_channel -> of_dma_request_slave_channel -> of_dma_xlate -> dma_get_any_slave_channel in dma drivers note that device->privatecnt is not changed during this. 3. release channel dma_release_channel -> if (--chan->device->privatecnt == 0) dma_cap_clear(DMA_PRIVATE, chan->device->cap_mask); So if we request a channel then release it, DMA_PRIVATE will be cleared unexpectedly. In this patch, we increase privatecnt in step 2 just like what __dma_request_channel does. Signed-off-by: Xiang Wang --- drivers/dma/dmaengine.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c index ed610b4..01bb372 100644 --- a/drivers/dma/dmaengine.c +++ b/drivers/dma/dmaengine.c @@ -557,6 +557,9 @@ struct dma_chan *dma_get_any_slave_channel(struct dma_device *device) } } + if (chan && dma_has_cap(DMA_PRIVATE, device->cap_mask)) + device->privatecnt++; + mutex_unlock(&dma_list_mutex); return chan;