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: 2377611 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id AB48D3FD8C for ; Tue, 2 Apr 2013 12:04:52 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UMzvK-0007o1-6d; Tue, 02 Apr 2013 12:02:46 +0000 Received: from mailout4.samsung.com ([203.254.224.34]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UMzv7-0007k0-H7 for linux-arm-kernel@lists.infradead.org; Tue, 02 Apr 2013 12:02:34 +0000 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-arm-kernel@lists.infradead.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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130402_080233_808853_5723A97D X-CRM114-Status: GOOD ( 10.29 ) X-Spam-Score: -9.2 (---------) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-9.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [203.254.224.34 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -2.3 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: linux-samsung-soc@vger.kernel.org, boojin.kim@samsung.com, jaswinder.singh@linaro.org, kyungmin.park@samsung.com, myungjoo.ham@samsung.com, Chanho Park , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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; }