Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp754684ybz; Wed, 15 Apr 2020 18:14:18 -0700 (PDT) X-Google-Smtp-Source: APiQypL5dKPn81VGwaPWi7yuM0nQqlrK+mHdFc4fJHgOIgQwO3zNEQeNUyhKuNsxtWkNl2dsUC2q X-Received: by 2002:a17:906:7d1:: with SMTP id m17mr7293415ejc.247.1586999658400; Wed, 15 Apr 2020 18:14:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586999658; cv=none; d=google.com; s=arc-20160816; b=oBJExVqtAVgh54cHAvqDL4ENs9XJMLoSwUeG753ih672mvgsuppDNVZrpV26gZg3i7 AIBVF+N41NSM2w7j/J+idAQ8Doybq2dUPSWmAuuDqZt0zgGBNRZPtIO64RzTVOpDrJDs JUyuTC8vZPd6lLMsFXRo1JmutA343OJagafPaJKFUHhmVhlVSC1dOn9BrDpnfFAeu7ax qoVk58MM3yXz9hfYlXNPcgKR0m3u+BN2nQ/ACQHDTLG6rwJUUM82U9OqsAEouWEzOVXY oXheJVKllTe9upjhmSA7olTKj1kT2yq5c+Wm9SHGwfPATkTAQA+ysYYWr9nmKUpyBLoS vVMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=L1IlX2IpSQEMdDjEJKh5CMpEL+4kcWoPfApz2jdxM08=; b=pDOhXSMBdVMRRJ5R25BbZRpRO8wLGqPJe4RNXrB3B5dTBTT6Og2htxZsEEcFMLhhDW rYMJ4kgF431TJTICM8IXDS1c8xs4Kw6fLig0OFUuN5labmPStbOSl7d8tjeOHxEh51cZ 4SKqueM08ydEXDsXIIUd34QSAONzos/yfEk1dqaOVmgh4A2MDjgOE/eyw2pPd+KI6T3i 6L6znWDwTOPcBA46/MW9vHlXYDbjs7JyDZ5GRzDMFjJB75QLm9iXuLrj0eTr8jQGev/s juv+5LwdQtSHCu1JkAqdDohFa5exIrZW8xIrGq0+U4IziY9RicSFxRv0v4RY4Az6r0aG F76g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=Er0LS+1q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i6si13131697edg.339.2020.04.15.18.13.55; Wed, 15 Apr 2020 18:14:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=Er0LS+1q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389318AbgDOX0r (ORCPT + 99 others); Wed, 15 Apr 2020 19:26:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389268AbgDOX0p (ORCPT ); Wed, 15 Apr 2020 19:26:45 -0400 Received: from mail-lf1-x142.google.com (mail-lf1-x142.google.com [IPv6:2a00:1450:4864:20::142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B4B6C061A10 for ; Wed, 15 Apr 2020 16:26:43 -0700 (PDT) Received: by mail-lf1-x142.google.com with SMTP id j14so4118287lfg.9 for ; Wed, 15 Apr 2020 16:26:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=L1IlX2IpSQEMdDjEJKh5CMpEL+4kcWoPfApz2jdxM08=; b=Er0LS+1q+NZt2g0tIsdiUQ0aIqzQIX/d5/FQVosexWpAB2ylC02jbt5wiQStKD20Nt WlSa0W7tvpOL75ueuetXJprO1qcmES76gksNQSurpvagjbP2NHp3W5sVL2qB+nr8hOn6 0+wLxHxtkoYcFvB4NkKiPqxWZ1omKz27UtCLOH1RDwNZCrwkQN8KpY3s9U/IBk8M+D7S bcGAcyzswBqYfxArH3Pp0AppQK4Z0ocT7vqGEpd+/m+8KDoTaXFdy+/V9sSDjznXrP7f sIRojXk/AhQ36ij8wJZLT7brr6d3m6HkJijaqBmnUACRKYJ2HLHopiQ/HcE3wdu0YfPD yxew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=L1IlX2IpSQEMdDjEJKh5CMpEL+4kcWoPfApz2jdxM08=; b=tXXcnTTJYfXtDj7Wf3Lolcfrz3ElDGsGN6pgTADIf/e/e7xZOD46Gwne3swhWZwcJb PUNjdaIsk612ZmRuLhG7gWlzEbTcz47c7DQvpyI91dUEKeF+oR0K4By2Q8QtVkAwER0q wQf/ALCccp5xxkBVCeN3wMcafmmqdwNDVp3DtX1ldbVetWWdjKuNdOvh/CkVSgH8reLr R271c/IPRnv469duAPp5q1iob1+TgRU5JTvfJbO2Xm5KrZSNFe50nOPKTAOiHugJlsmr 521eqItmwkCLGSlRZaAqjAmpHYm1P7aR73ouMqKdZrU8f8hH6nUT7WebZ9FqZEwqKcZx l/VA== X-Gm-Message-State: AGi0PubwE55loiTTw3WKF82I9gOSNH8z1+hlO2uWZYVsuVchpHUnLfjP G4H+XA35lRm/f1FVNHSHrqVjO3b2WGNjiTrSDyO56g== X-Received: by 2002:a19:dc05:: with SMTP id t5mr4319328lfg.73.1586993201362; Wed, 15 Apr 2020 16:26:41 -0700 (PDT) MIME-Version: 1.0 References: <1586916464-27727-1-git-send-email-alan.mikhak@sifive.com> In-Reply-To: From: Alan Mikhak Date: Wed, 15 Apr 2020 16:26:30 -0700 Message-ID: Subject: Re: [PATCH RFC] dmaengine: dw-edma: Decouple dw-edma-core.c from struct pci_dev To: Gustavo Pimentel Cc: "dmaengine@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-pci@vger.kernel.org" , "dan.j.williams@intel.com" , "vkoul@kernel.org" , "kishon@ti.com" , "paul.walmsley@sifive.com" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 15, 2020 at 2:23 PM Alan Mikhak wrote: > > On Wed, Apr 15, 2020 at 1:58 PM Gustavo Pimentel > wrote: > > > > Hi Alan, > > > > > > > At the moment, pci-epf-test grabs the first available dma channel on the > > > > > endpoint side and uses it for either read, write, or copy operation. it is not > > > > > possible at the moment to specify which dma channel to use on the pcitest > > > > > command line. This may be possible by modifying the command line option > > > > > -D to also specify the name of one or more dma channels. > > > > > > > > I'm assuming that behavior is due to your code, right? I'm not seen that > > > > behavior on the Kernel tree. > > > > Check my previous suggestion, it should be something similar to what is > > > > been done while you select the MSI/MSI-X interrupt to trigger. > > > > > > I believe this behavior exists in the kernel tree because the call to > > > dma_request_chan_by_mask() always specifies channel zero. The user > > > of pcitest has no way of specifying which one of the available dma channels > > > to use. > > > > I think we were discussing different things. I was referring to the > > pci-epf-test code, that I wasn't being able to find any instruction to > > call the DMA driver which had the described behavior. > > > > I think you can do it by doing this: > > > > Pseudo code: > > > > #define EDMA_TEST_CHANNEL_NAME "dma%uchan%u" > > > > static bool dw_edma_test_filter(struct dma_chan *chan, void *filter) > > { > > if (strcmp(dev_name(chan->device->dev), EDMA_TEST_DEVICE_NAME) || > > strcmp(dma_chan_name(chan), filter)) > > return false; > > > > return true; > > } > > > > static void dw_edma_test_thread_create(int id, int channel) > > { > > struct dma_chan *chan; > > dma_cap_mask_t mask; > > char filter[20]; > > > > dma_cap_zero(mask); > > dma_cap_set(DMA_SLAVE, mask); > > dma_cap_set(DMA_CYCLIC, mask); > > > > snprintf(filter, sizeof(filter), EDMA_TEST_CHANNEL_NAME, id, > > channel); > > chan = dma_request_channel(mask, dw_edma_test_filter, filter); > > > > [..] > > } > > Thanks Gustavo, This pseudo code is very useful. Now I know how to do > that part of the change. > > What I have further in mind is to enable the pcitest user to specify some > arbitrary string with -D option to select one or more of the dma channels > that are available on the endpoint side. Since the user executes pcitest > from host-side command prompt and pci-epf-test executes in kernel on the > endpoint side, the messaging between userspace pcitest and kernel-space > pci_endpoint_test as well as the messaging across the bus between > pci_endpoint_test and pci-epf-test needs to be expanded to pass the user > string from the host to the endpoint. Upon receiving each read, write, or > copy message, pci-epf-test could then try to acquire the specified dma > channel and execute the user command or fail it if no such channel is > available at that moment. > > > > > > I believe this behavior exists in the kernel tree because the call to > > > dma_request_chan_by_mask() happens during the execution of > > > pci_epf_test_bind() and the call to dma_release_channel() happens > > > during the execution of pci_epf_test_unbind(). As long as pci-epf-test > > > is bound, I cannot use another program such as dmatest from the > > > endpoint-side command prompt to exercise the same channel. > > > > Ok, I understood it now. Right, you can't use the dmatest here, even > > because, as far as I know, it is only MEM TO MEM operations and we need > > DEVICE_TO_MEM and vice-versa. > > On the platforms that I have this in mind for, I may not only have embedded dma channels inside the PCIe controller but also platform dma channels. Either type of dma channel can be used by pcitest whereas dmatest can only use the type that can do MEM to MEM as you said. Either of these types can be used to transfer data to or from the PCIe bus. I need to use both kinds with pcitest to make sure the PCIe subsystem is ok. > > > > > > What I was suggesting is perhaps pci-epf-test can be modified to > > > acquire and release the channel on each call to pci_epf_test_read(), > > > ...write(), or ...copy() when the pcitest user specifies -D option. > > > > Right, you are on the right track. > > Perhaps you could take a look at patch [1] that I have done some time ago > > for testing the eDMA, I think you have all the tools/guideline there to > > do this adaption. > > Another thing, > > > > [1] https://patchwork.kernel.org/patch/10760521/ > > Thanks for the guidance and reference code patch [1]. I will definitely > take a close look at [1]. > > > > > > >