Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp1698875rdb; Sun, 8 Oct 2023 22:38:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEy2MkuWOd61Qya17d2nTqm7HaFvJH2CCHN9/HGBTyjwibPPU/hwsVcOd5Kexz2BZ7zKQgh X-Received: by 2002:a05:6a20:4292:b0:14c:a53c:498c with SMTP id o18-20020a056a20429200b0014ca53c498cmr14814109pzj.10.1696829924513; Sun, 08 Oct 2023 22:38:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696829924; cv=none; d=google.com; s=arc-20160816; b=Dl86L/hRm7pBKfdbg/lxxWGBkm3QzZRrWMFnz9XL7sCidnXnkTPoQfxqpN53W1uCjc /dVyGddSxub0q2+QZL6SCVJKS1Tf7KCTcN98uMaIehGCiuojctB30S5R1lZ2Ljug9j/x 7/FttqaVA50m5TiIasPOuMNstWx9FF0UQhYYeCw1pQzrc1rDgEDl9mGAh3DAySphw1ip UXbvlJTU+RqyfPcfGiqlbiY5lrSX3Rlo7ZT6KdtBxyOFbW3gYzzQr/Q8mgEAZFN3WG0b A/soGIOHvz5sJMmx5boEColCwO3CAEOnBCDF8rdnIHuGkY600CAP7IZZRSoHl5Lzpqvq fRbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=89PbZyDGuw3RxTI66QlyxtPyuE/6ZX0DJsx13J1srTs=; fh=N4h0UzbIIxOUFNj20D1jncGYPd1CqZhiLM4pYB4RuDg=; b=BOyfFiwBbV5Ulp06HpM6kIGBPPEJBWmnULWL2tpJPsOsHmPCdMVRYj/zgoT3cR/BuE 5I97c3YXamCsKn8ogEwJndQEw11SkPdJlExtd7cJVhm4Kpw/wmSvuP6TmGd6qrW/tGGf UIK9jx+lc8WXqXjOmZ+Iust8fKnXNZuDqoVlrOwozptCZx5UNMIAtqPdeiZn7aijFmPZ b3ZXAk8a6uIDIZPKCG7lIJYFcQxojpt5kWaqWuYi2tb7kin9Zpek9gSebmtnc79NIoVR yjOCUygWlqO2ghBL5AoXNdrp9hiJiq32fa5GrZe+knPUZB933vpM+BPun1lmWNbv+on4 AGgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=l0MfWOxv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id f2-20020a170902ce8200b001b845157b69si9759609plg.414.2023.10.08.22.38.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Oct 2023 22:38:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=l0MfWOxv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id DFCB4802CC3C; Sun, 8 Oct 2023 22:38:40 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345116AbjJIFiW (ORCPT + 99 others); Mon, 9 Oct 2023 01:38:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345049AbjJIFiV (ORCPT ); Mon, 9 Oct 2023 01:38:21 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC4619E; Sun, 8 Oct 2023 22:38:19 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E01C4C433C7; Mon, 9 Oct 2023 05:38:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696829899; bh=94byP8ietls/5mIzLClS8+CihfeMV58zSREKNeczpCg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=l0MfWOxvfEWDZMsbSHJPSNf+ElS6wVx6szorg9qy2Caanj7yuXak6mouFETE+dME7 EVkNVlzLvvv1lWyDy7Z6FYOzeY4DvJs7M++8eV0EAMLbFbmTr4PKhaxKLiviCaD8ud tESRKgAnwSlq8hOIKVdhwANTXTBxfuT0e9Bf3KwKGQH2aCsAo9ZCOqi4E9HoT7abdt JoL8inff9KRGrCBnFQS3s9EhWdaEbzBFovwvQP4AL7K4Rb7777wHVf5yNrUMIhQsP1 52T6OANvn7qe6WcbV/1u+37oi0YxAu+yXRrAHy0XiAzNt+u8v1q+8B0IZGNpOn6KRg n8ea3NDQOc6Jw== Date: Mon, 9 Oct 2023 11:08:15 +0530 From: Vinod Koul To: Kelvin.Cao@microchip.com Cc: dmaengine@vger.kernel.org, George.Ge@microchip.com, logang@deltatee.com, christophe.jaillet@wanadoo.fr, hch@infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v6 1/1] dmaengine: switchtec-dma: Introduce Switchtec DMA engine PCI driver Message-ID: References: <20230728200327.96496-1-kelvin.cao@microchip.com> <20230728200327.96496-2-kelvin.cao@microchip.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=2.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Sun, 08 Oct 2023 22:38:41 -0700 (PDT) X-Spam-Level: ** On 06-10-23, 22:34, Kelvin.Cao@microchip.com wrote: > On Fri, 2023-10-06 at 16:00 +0530, Vinod Koul wrote: > > EXTERNAL EMAIL: Do not click links or open attachments unless you > > know the content is safe > > > > On 05-10-23, 18:35, Kelvin.Cao@microchip.com?wrote: > > > > > > > > +static struct dma_async_tx_descriptor * > > > > > > +switchtec_dma_prep_wimm_data(struct dma_chan *c, dma_addr_t > > > > > > dma_dst, u64 data, > > > > > > +????????????????????????? unsigned long flags) > > > > > > > > > > can you please explain what this wimm data refers to... > > > > > > > > > > I think adding imm callback was a mistake, we need a better > > > > > justification for another user for this, who programs this, > > > > > what > > > > > gets > > > > > programmed here > > > > > > > > Sure. I think it's an alternative method to prep_mem and would be > > > > more > > > > convenient to use when the write is 8-byte and the data to be > > > > moved > > > > is > > > > not in a DMA mapped memory location. For example, we write to a > > > > doorbell register with the value from a local variable which is > > > > not > > > > associated with a DMA address to notify the receiver to consume > > > > the > > > > data, after confirming that the previously initiated DMA > > > > transactions > > > > of the data have completed. I agree that the use scenario would > > > > be > > > > very > > > > limited. > > > > Can you please explain more about this 'value' where is it derived > > from? > > Who programs it and how... > > Sure. Think of a producer/consumer use case where the producer is a > host DMA client driver and the consumer is a PCIe EP. On the EP, there What are the examples of DMA clients here? > is a memory-mapped data buffer for data receiving and a memory-mapped > doorbell buffer for triggering data consuming. Each time for a bulk > data transfer, the DMA client driver first DMA the data of size X to > the memory-mapped data buffer, then it DMA the value X to the doorbell > buffer to trigger data consumption on device. On receiving a doorbell > writing, the device starts to consume the data of size X from the data > buffer. > > For the first DMA operation, the DMA client would use dma_prep_memory() > like what most DMA clients do. However, for the second transfer, value > X is held in a local variable like below. > > u64 size_to_transfer; Why cant the client driver write to doorbell, is there anything which prevents us from doing so? > > In this case, the client would use dma_prep_wimm_data() to DMA value X > to the doorbell buffer, like below. > > dma_prep_wimm_data(chan, dst_for_db_buffer, size_to_transfer, flag); > > Hope this example explains the thing. People would argue that the > client could use the same dma_prep_memory() for the doorbell ringing. I > would agree, this API just adds an alternative way to do so when the > data is as little as 64 bit and it also saves a call site to > dma_alloc_coherent() to allocate a source DMA buffer just for holding > the 8-byte value, which is required by dma_prep_memcpy(). I would prefer that, (after the option of mmio write from client), there is nothing special about this, another txn. You can queue up both and have dmaengine write to doorbell immediately after the buffer completes > > > > > > > > +???? /* set sq/cq */ > > > > > > +???? writel(lower_32_bits(swdma_chan->dma_addr_sq), > > > > > > &chan_fw- > > > > > > > sq_base_lo); > > > > > > +???? writel(upper_32_bits(swdma_chan->dma_addr_sq), > > > > > > &chan_fw- > > > > > > > sq_base_hi); > > > > > > +???? writel(lower_32_bits(swdma_chan->dma_addr_cq), > > > > > > &chan_fw- > > > > > > > cq_base_lo); > > > > > > +???? writel(upper_32_bits(swdma_chan->dma_addr_cq), > > > > > > &chan_fw- > > > > > > > cq_base_hi); > > > > > > + > > > > > > +???? writew(SWITCHTEC_DMA_SQ_SIZE, &swdma_chan- > > > > > > >mmio_chan_fw- > > > > > > > sq_size); > > > > > > +???? writew(SWITCHTEC_DMA_CQ_SIZE, &swdma_chan- > > > > > > >mmio_chan_fw- > > > > > > > cq_size); > > > > > > > > > > what is write happening in the descriptor alloc callback, that > > > > > does > > > > > not > > > > > sound correct to me > > > > > > > > All the queue descriptors of a channel are pre-allocated, so I > > > > think > > > > it's proper to convey the queue address/size to hardware at this > > > > point. > > > > After this initialization, we only need to assign cookie in > > > > submit > > > > and > > > > update queue head to hardware in issue_pending. > > > > Sorry that is not right, you can prepare multiple descriptors and > > then > > submit. Only at submit is the cookie assigned which is in order, so > > this > > should be moved to when we start the txn and not in this call > > > The hardware assumes the SQ/CQ is a contiguous circular buffer of fix > sized element. And the above code passes the address and size of SQ/CQ > to the hardware. At this point hardware will do nothing but take note > of the SQ/CQ location/size.? > > When do dma_issue_pending(), the actual SQ head write will occur to > update hardware with the current SQ head, as below: > > writew(swdma_chan->head, &swdma_chan->mmio_chan_hw->sq_tail); But if the order of txn submission is changed you will issue dma txn in wrong order, so it should be written only when desc is submitted not in the prep invocation! -- ~Vinod