From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E62EC43387 for ; Thu, 3 Jan 2019 13:00:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 40C8A217F5 for ; Thu, 3 Jan 2019 13:00:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=synopsys.com header.i=@synopsys.com header.b="NtO1x59n" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727515AbfACNA3 (ORCPT ); Thu, 3 Jan 2019 08:00:29 -0500 Received: from smtprelay2.synopsys.com ([198.182.60.111]:51990 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727331AbfACNA3 (ORCPT ); Thu, 3 Jan 2019 08:00:29 -0500 Received: from mailhost.synopsys.com (mailhost3.synopsys.com [10.12.238.238]) by smtprelay.synopsys.com (Postfix) with ESMTP id D83CB10C1235; Thu, 3 Jan 2019 05:00:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1546520428; bh=nh6pFPtvfJFcf7z1GARUUB1xXuxNBEt6/NOYdZaZHh8=; h=Subject:To:CC:References:From:Date:In-Reply-To:From; b=NtO1x59nhl5Nw9z8yzJV8htHS1HpbGCICfI5uAlL//4+1WcDxZGKa9gsbe9cH7prK 7YwqyLkXTcYuLXqMRZEWK6ui5pbQKpKCEVRMpGHfgdR2lmk6gFnW0tMnvNP0Uhsoc2 7+e3zMolbuTZuvEm3LVX2uX+Swd3id/suZKax4nGjjQFn639nDCUmVPsvXbOA6/QoY 9mHr8eSDNfupGQWSnnJRW8aDgTvvEswZs1SDWlDjFtFrzBipLSz/dvFLwtOMYlj6ka monrFc0fvrkFPsRDdCpx5tR8AuN45Ae7YVkjsDbs2GgX+ZzPX2oSK9imfT8x8SDNzD Puc8I+Iw8UJkg== Received: from US01WEHTC2.internal.synopsys.com (us01wehtc2-vip.internal.synopsys.com [10.12.239.238]) by mailhost.synopsys.com (Postfix) with ESMTP id BDED63677; Thu, 3 Jan 2019 05:00:28 -0800 (PST) Received: from DE02WEHTCB.internal.synopsys.com (10.225.19.94) by US01WEHTC2.internal.synopsys.com (10.12.239.237) with Microsoft SMTP Server (TLS) id 14.3.408.0; Thu, 3 Jan 2019 05:00:28 -0800 Received: from DE02WEHTCA.internal.synopsys.com (10.225.19.92) by DE02WEHTCB.internal.synopsys.com (10.225.19.94) with Microsoft SMTP Server (TLS) id 14.3.408.0; Thu, 3 Jan 2019 14:00:27 +0100 Received: from [10.107.25.131] (10.107.25.131) by DE02WEHTCA.internal.synopsys.com (10.225.19.80) with Microsoft SMTP Server (TLS) id 14.3.408.0; Thu, 3 Jan 2019 14:00:27 +0100 Subject: Re: [RFC 1/6] dma: Add Synopsys eDMA IP core driver To: Vinod Koul , Gustavo Pimentel CC: "linux-pci@vger.kernel.org" , "dmaengine@vger.kernel.org" , Eugeniy Paltsev , Andy Shevchenko , Joao Pinto References: <20181217065120.GH2472@vkoul-mobl> <0768a44c-60d2-0983-b2e3-b8f711a24504@synopsys.com> <256fef2b-0dea-edee-396a-353520159005@synopsys.com> <20190103124542.GC21403@vkoul-mobl> From: Gustavo Pimentel Message-ID: Date: Thu, 3 Jan 2019 12:55:56 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <20190103124542.GC21403@vkoul-mobl> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.107.25.131] Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Hi Vinod, On 03/01/2019 12:45, Vinod Koul wrote: > Hi Gustavo, > > On 03-01-19, 09:53, Gustavo Pimentel wrote: >> Hi Vinod, >> >> (snipped) >> >>>>> +{ >>>>> + struct dw_edma_chan *chan = dchan2dw_edma_chan(dchan); >>>>> + const struct dw_edma_core_ops *ops = chan2ops(chan); >>>>> + enum dma_transfer_direction dir; >>>>> + unsigned long flags; >>>>> + int err = 0; >>>>> + >>>>> + spin_lock_irqsave(&chan->vc.lock, flags); >>>>> + >>>>> + if (!config) { >>>>> + err = -EINVAL; >>>>> + goto err_config; >>>>> + } >>>>> + >>>>> + if (chan->configured) { >>>>> + dev_err(chan2dev(chan), ": channel already configured\n"); >>>>> + err = -EPERM; >>>>> + goto err_config; >>>>> + } >>>>> + >>>>> + dir = config->direction; >>>> >>>> Direction is depreciated, I have already removed the usages, so please >>>> do not add new ones. >>>> >>>> You need to take direction for respective prep_ calls >>> >>> Ok, I already do that. IMHO I found it strange to have the same information >>> repeated on two places. But now that you say that this is deprecated, it makes >>> sense now. >>> >>>> >>>>> + if (dir == DMA_DEV_TO_MEM && chan->dir == EDMA_DIR_WRITE) { >>>>> + dev_info(chan2dev(chan), >>>>> + ": direction DMA_DEV_TO_MEM (EDMA_DIR_WRITE)\n"); >>>>> + chan->p_addr = config->src_addr; >>>>> + } else if (dir == DMA_MEM_TO_DEV && chan->dir == EDMA_DIR_READ) { >>>>> + dev_info(chan2dev(chan), >>>>> + ": direction DMA_MEM_TO_DEV (EDMA_DIR_READ)\n"); >>>>> + chan->p_addr = config->dst_addr; >>>>> + } else { >>>>> + dev_err(chan2dev(chan), ": invalid direction\n"); >>>>> + err = -EINVAL; >>>>> + goto err_config; >>>>> + } >>>> >>>> This should be removed >>> >>> Yeah, it was just for validation purposes. Now that direction is deprecated on >>> the API, makes no sense to validate it. >>> >>>> >>>>> + >>>>> + dev_info(chan2dev(chan), >>>>> + ": src_addr(physical) = 0x%.16x\n", config->src_addr); >>>>> + dev_info(chan2dev(chan), >>>>> + ": dst_addr(physical) = 0x%.16x\n", config->dst_addr); >>>> >> >> I've a doubt now. As you know, for a DMA transfer you need the source and >> destination addresses, which in the limited can be swapped according to the >> direction MEM_TO_DEV/DEV_TO_MEM case. >> >> For the sake of simplicity, I'll just consider now the MEM_TO_DEV case, since >> the other case is similar but the source and destination address are swapped. >> >> In my code I can get some of the information that I need by using the >> sg_dma_address() in the scatter-gather list (which gives me the source address). >> >> The remaining information I got from here, using the direction to help me to >> select which address I'll use later on the DMA transfer, in this case the >> destination address. >> >> Since this is deprecated how should I proceed? How can I get that information? >> There is some similar function to sg_dma_address() that could give me the >> destination address? > > So the direction field is deprecated but rest of the configuration comes > from from dma_slave_config. The user should set src_addr, dst_addr and > then based on direction passed in the .device_prep_dma_* call arguments > one can use one of these as peripheral address. Ok, and the address given by sg_dma_address()? Is redundant or not applicable for this case? > > Also, please keep in mind that for memory to memory transfers you should > not expect the dma_slave_config to be used My DMA implementation is only MEM_TO_DEV and DEV_TO_MEM. > > Thanks > Thanks.