From patchwork Tue Apr 2 12:01:15 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chanho Park X-Patchwork-Id: 2377591 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 1876BDF2A1 for ; Tue, 2 Apr 2013 12:02:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760101Ab3DBMCc (ORCPT ); Tue, 2 Apr 2013 08:02:32 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:18314 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754730Ab3DBMCb (ORCPT ); Tue, 2 Apr 2013 08:02:31 -0400 Received: from epcpsbgr2.samsung.com (u142.gpu120.samsung.co.kr [203.254.230.142]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MKM00B9GMRREYR0@mailout4.samsung.com> for linux-samsung-soc@vger.kernel.org; Tue, 02 Apr 2013 21:02:30 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [203.254.230.44]) by epcpsbgr2.samsung.com (EPCPMTA) with SMTP id 4A.DE.07735.6D8CA515; Tue, 02 Apr 2013 21:02:30 +0900 (KST) X-AuditID: cbfee68e-b7f946d000001e37-b1-515ac8d68ad5 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 77.F3.17838.6D8CA515; Tue, 02 Apr 2013 21:02:30 +0900 (KST) Received: from localhost.localdomain ([10.90.51.45]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MKM00FMEMRYX910@mmp1.samsung.com>; Tue, 02 Apr 2013 21:02:30 +0900 (KST) From: Chanho Park To: vinod.koul@intel.com, djbw@fb.com Cc: boojin.kim@samsung.com, jaswinder.singh@linaro.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, myungjoo.ham@samsung.com, kyungmin.park@samsung.com, Chanho Park Subject: [PATCH 1/2] dma: pl330: split off common code to give back descriptors Date: Tue, 02 Apr 2013 21:01:15 +0900 Message-id: <1364904076-3130-2-git-send-email-chanho61.park@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1364904076-3130-1-git-send-email-chanho61.park@samsung.com> References: <1364904076-3130-1-git-send-email-chanho61.park@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpikeLIzCtJLcpLzFFi42I5/e+Zju61E1GBBmd3qVm8OfmHzeLyfm2L zf0P2Cwmb7rPaHG26Q27xabH11gtZpzfx2Rxu3EFm8XLvv0sDpweE5vfsXss3vOSyePOtT1s HpuX1Hv0bVnF6PF5k1wAWxSXTUpqTmZZapG+XQJXxpoHr5kLbgpVTJm1i7WB8TB/FyMnh4SA icTGfz3MELaYxIV769m6GLk4hASWMUr031vA0sXIAVZ055AkRHwRo8S7P0+ZIJwWJom/nTNY QbrZBHQltjx/xQjSICKgKrH+shhIDbPAY0aJGZf6WUBqhAX8JVpu7AbbxgJUc/7oFyYQm1fA Q2Lm+T1MEMsUJOZMsgEJcwp4Svz/v4kdxBYCKln5vAlsr4TANnaJvdOfsUDMEZD4NvkQ1KGy EpsOQD0jKXFwxQ2WCYzCCxgZVjGKphYkFxQnpRcZ6RUn5haX5qXrJefnbmKEhH/fDsabB6wP MSYDjZvILCWanA+Mn7ySeENjMyMLUxNTYyNzSzPShJXEedVarAOFBNITS1KzU1MLUovii0pz UosPMTJxcEo1MC7jSBE4Uz3TMuCmvlQ9+/KkBK19qWtb3m1QVXXPl2/iV3gpaKL8ICVv2kR3 R9EE05JHXPOP+dzYlnBqa7pk5JGVq3sXM+q+stSf/L53nkSH9MKPB4UmuVrffvKv466UuE9P TnpUy7O2BdbuUhNv+3Q57bKfbP77YxZrTsXjx9NbhP7z2qReVmIpzkg01GIuKk4EAPKlS9mV AgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrPIsWRmVeSWpSXmKPExsVy+t9jAd1rJ6ICDWZvVbR4c/IPm8Xl/doW m/sfsFlM3nSf0eJs0xt2i02Pr7FazDi/j8niduMKNouXfftZHDg9Jja/Y/dYvOclk8eda3vY PDYvqffo27KK0ePzJrkAtqgGRpuM1MSU1CKF1Lzk/JTMvHRbJe/geOd4UzMDQ11DSwtzJYW8 xNxUWyUXnwBdt8wcoKOUFMoSc0qBQgGJxcVK+naYJoSGuOlawDRG6PqGBMH1GBmggYR1jBlr HrxmLrgpVDFl1i7WBsbD/F2MHBwSAiYSdw5JdjFyApliEhfurWfrYuTiEBJYxCjx7s9TJgin hUnib+cMVpAqNgFdiS3PXzGCNIsIqEqsvywGUsMs8JhRYsalfhaQGmEBf4mWG7uZQWwWoJrz R78wgdi8Ah4SM8/vYYJYrCAxZ5INSJhTwFPi//9N7CC2EFDJyudNTBMYeRcwMqxiFE0tSC4o TkrPNdQrTswtLs1L10vOz93ECI6uZ1I7GFc2WBxiFOBgVOLhdZgTGSjEmlhWXJl7iFGCg1lJ hDduZ1SgEG9KYmVValF+fFFpTmrxIcZkoKMmMkuJJucDIz+vJN7Q2MTMyNLIzNjE3NiYNGEl cd4DrdaBQgLpiSWp2ampBalFMFuYODilGhhbfJuthN/JVshrLzKovuyRtfT+J8eDIeLZz5bz ZIt6vnvr4PLC9us9tnfPP7a++Fr0QaRCctW8ab9P6PGsdufqYpyx3ahhzw7BnjSTezpXXltP eVhgf04+anp309qgu+dFmv8GRM62jvoyo2ztmwNpD9fViCzkb9yQ6styMvSYjjpX2vXv4jOV WIozEg21mIuKEwE4f/858gIAAA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org This patch adds __pl330_giveback_descs which give back descriptors when fails allocating descriptors. It requires to eliminate duplication for pl330_prep_dma_sg which will be added later. Signed-off-by: Chanho Park Signed-off-by: Myungjoo Ham Signed-off-by: Kyungmin Park --- drivers/dma/pl330.c | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c index 7181531..47ed13f 100644 --- a/drivers/dma/pl330.c +++ b/drivers/dma/pl330.c @@ -2795,6 +2795,28 @@ pl330_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dst, return &desc->txd; } +static void __pl330_giveback_desc(struct dma_pl330_dmac *pdmac, + struct dma_pl330_desc *first) +{ + unsigned long flags; + struct dma_pl330_desc *desc; + + if (!first) + return; + + spin_lock_irqsave(&pdmac->pool_lock, flags); + + while (!list_empty(&first->node)) { + desc = list_entry(first->node.next, + struct dma_pl330_desc, node); + list_move_tail(&desc->node, &pdmac->desc_pool); + } + + list_move_tail(&first->node, &pdmac->desc_pool); + + spin_unlock_irqrestore(&pdmac->pool_lock, flags); +} + static struct dma_async_tx_descriptor * pl330_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, unsigned int sg_len, enum dma_transfer_direction direction, @@ -2803,7 +2825,6 @@ pl330_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, struct dma_pl330_desc *first, *desc = NULL; struct dma_pl330_chan *pch = to_pchan(chan); struct scatterlist *sg; - unsigned long flags; int i; dma_addr_t addr; @@ -2823,20 +2844,7 @@ pl330_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, dev_err(pch->dmac->pif.dev, "%s:%d Unable to fetch desc\n", __func__, __LINE__); - if (!first) - return NULL; - - spin_lock_irqsave(&pdmac->pool_lock, flags); - - while (!list_empty(&first->node)) { - desc = list_entry(first->node.next, - struct dma_pl330_desc, node); - list_move_tail(&desc->node, &pdmac->desc_pool); - } - - list_move_tail(&first->node, &pdmac->desc_pool); - - spin_unlock_irqrestore(&pdmac->pool_lock, flags); + __pl330_giveback_desc(pdmac, first); return NULL; }