From patchwork Mon Jun 15 16:18:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joshua Clayton X-Patchwork-Id: 6610581 Return-Path: X-Original-To: patchwork-linux-arm@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 2B2899F1C1 for ; Mon, 15 Jun 2015 16:23:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3E2382071B for ; Mon, 15 Jun 2015 16:23:03 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 49E0120719 for ; Mon, 15 Jun 2015 16:23:02 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Z4X7l-0006Rq-4Q; Mon, 15 Jun 2015 16:20:37 +0000 Received: from mail-pa0-x22d.google.com ([2607:f8b0:400e:c03::22d]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Z4X6o-0004ux-Lp for linux-arm-kernel@lists.infradead.org; Mon, 15 Jun 2015 16:19:39 +0000 Received: by pabqy3 with SMTP id qy3so68322615pab.3 for ; Mon, 15 Jun 2015 09:19:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=MlFIU+uPjKZDArEVnf2jv8cxkZ9Ahnf72T0oBuNCzSU=; b=QU0+lwRSWSOkdkE/HMrlHzbiUorhiPCqPO2B6M9+y3+4f1u15Hu2+cTXqOTQ8LW3gE rxKtPRNePprxKILOu5/8uK7FQ8KdjA049VsLEo8z0GC8muOKaE3PTzKSR2MVPy77e1Jc aD1JMvrdt387ZVig+FhxAqvvvZ7JOPmxkqUZe4+y5j6wQYxEHQVDPpUpi0UvE0ZFcwTX AmrxCN2BYlN6xs8NOLF3+A3N97lCoa1I1/s/yDGA2eH87t1NYt9TJ0oY/thWv81XB/Ob M5MZJUTuZTfZmciY7hgyc6i/eNLKPduD+ZJs3qJGr5HJnyek5AT/LdwIYbK92YU92AiR 1k9g== X-Received: by 10.70.135.129 with SMTP id ps1mr49290420pdb.110.1434385159146; Mon, 15 Jun 2015 09:19:19 -0700 (PDT) Received: from localhost.localdomain (68-185-59-186.static.knwc.wa.charter.com. [68.185.59.186]) by mx.google.com with ESMTPSA id qg5sm12717637pdb.13.2015.06.15.09.19.17 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Jun 2015 09:19:17 -0700 (PDT) From: Joshua Clayton To: Vinod Koul Subject: [PATCH 04/10] dma: sdma-imx set dma script address directly Date: Mon, 15 Jun 2015 09:18:59 -0700 Message-Id: <1434385144-4432-5-git-send-email-stillcompiling@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1434385144-4432-1-git-send-email-stillcompiling@gmail.com> References: <1434385144-4432-1-git-send-email-stillcompiling@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150615_091938_801623_336DA69A X-CRM114-Status: GOOD ( 19.17 ) X-Spam-Score: -0.8 (/) Cc: Joshua Clayton , linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, Dan Williams , Shawn Guo , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 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 X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable 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 SDMA uses different firmware scripts per device type and per direction, but only one script per channel may be used at a time. By moving the call to sdma_get_pc() into get_context, it will be called any time the dma direction may change. Then there is no need to store multiple script addresses, so those may be removed from struct sdma_channel. We also add an error message should setting the script fail to find a valid script address. Signed-off-by: Joshua Clayton --- drivers/dma/imx-sdma.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c index 7c8703f..fdf88c4 100644 --- a/drivers/dma/imx-sdma.c +++ b/drivers/dma/imx-sdma.c @@ -257,7 +257,6 @@ struct sdma_channel { unsigned int period_len; struct sdma_buffer_descriptor *bd; dma_addr_t bd_phys; - unsigned int pc_from_device, pc_to_device; unsigned long flags; dma_addr_t per_address; unsigned long event_mask[2]; @@ -688,8 +687,8 @@ static irqreturn_t sdma_int_handler(int irq, void *dev_id) /* * sets the pc of SDMA script according to the peripheral type */ -static void sdma_get_pc(struct sdma_channel *sdmac, - enum sdma_peripheral_type peripheral_type) +static s32 sdma_get_pc(struct sdma_channel *sdmac, + enum dma_transfer_direction direction) { struct sdma_engine *sdma = to_sdma_engine(sdmac); int per_2_emi = 0, emi_2_per = 0; @@ -699,10 +698,7 @@ static void sdma_get_pc(struct sdma_channel *sdmac, */ int per_2_per = 0, emi_2_emi = 0; - sdmac->pc_from_device = 0; - sdmac->pc_to_device = 0; - - switch (peripheral_type) { + switch (sdmac->peripheral_type) { case IMX_DMATYPE_MEMORY: emi_2_emi = sdma->script_addrs->ap_2_ap_addr; break; @@ -774,8 +770,14 @@ static void sdma_get_pc(struct sdma_channel *sdmac, break; } - sdmac->pc_from_device = per_2_emi; - sdmac->pc_to_device = emi_2_per; + switch (direction) { + case DMA_MEM_TO_DEV: + return emi_2_per; + case DMA_DEV_TO_MEM: + return per_2_emi; + default: + return 0; + } } static int sdma_load_context(struct sdma_channel *sdmac) @@ -788,15 +790,13 @@ static int sdma_load_context(struct sdma_channel *sdmac) int ret; unsigned long flags; - if (sdmac->direction == DMA_DEV_TO_MEM) { - load_address = sdmac->pc_from_device; - } else { - load_address = sdmac->pc_to_device; + load_address = sdma_get_pc(sdmac, sdmac->direction); + if (!load_address) { + dev_err(sdma->dev, "SDMA channel %d: No dma script found\n", + channel); + return -EFAULT; } - if (load_address < 0) - return load_address; - dev_dbg(sdma->dev, "load_address = %d\n", load_address); dev_dbg(sdma->dev, "wml = 0x%08x\n", (u32)sdmac->watermark_level); dev_dbg(sdma->dev, "shp_addr = 0x%08x\n", sdmac->shp_addr); @@ -867,8 +867,6 @@ static int sdma_config_channel(struct sdma_channel *sdmac) break; } - sdma_get_pc(sdmac, sdmac->peripheral_type); - if ((sdmac->peripheral_type != IMX_DMATYPE_MEMORY) && (sdmac->peripheral_type != IMX_DMATYPE_DSP)) { /* Handle multiple event channels differently */