Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3289394ybz; Sun, 3 May 2020 23:16:50 -0700 (PDT) X-Google-Smtp-Source: APiQypLn2T81kIfHazdILHFvMycCmr5VMnMHf8lMiYwhq5z0FRXVRWlVG2zzd/5R/sIyrk0+zEZb X-Received: by 2002:a17:907:4033:: with SMTP id nk3mr13900818ejb.273.1588573009811; Sun, 03 May 2020 23:16:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588573009; cv=none; d=google.com; s=arc-20160816; b=Dxlp+UQPo2C6CLE8ZKU/6mFwqnOgF7Wo3UdoxZTb78EobEvFNzIONmG6hi7hv8bp0e l+IKZVmVUNnsSrr59vsPOpcE8vTfm07sGOqg4LZ8UPfm2289nHq24PvBJHDRLUSKkXd1 3D607CGQCXwiS/6XJL2N5IGRskj3cm7c/iO/7u54FTAxr/fcB+uM23QX/Y2QOk+qp312 0UMc61p1COim/Vlpd2Xigh8ayiA2vRm06nHKwtyyQx93oSPqchRz5OTXZ8HhjYFOni3p /NB9C2lhGr9xY/LQWR5BjAIDbDmG9N53DjVByoJcKj42w6vAhXQrPdZLO5g6VwZfADC8 3FiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=CdpK7/9vSUQyFMsSYXlEuiajPYz1p+GosKFhB36TDCk=; b=tYlnuUWJhKtGm2i0Bgm3IG0TJpd3YtXKTVfvskMyRwZXTPh4FfHU+YkVo9VNCCrnER D6hJnE/ztkjewPkzQtk/+p0/uO1p2sjYgResaMyq+AT1yPEd91YGlwORJLhD0defQ0v6 sev6kPb0va7vcKnRHntWO2tEHLVm//PyJpOoK7iq2VFdF4own5Ht+HfwXd3+uhVJFtmO 2KofI6qKWOXywtY5dhRXzpqJ5j78VS9tM5VVXV0SP+mTSVNCYFzp0sxl9FdUdgJok7K+ JVW5xybzgsB4tiE0TC6L10JOA0bkpkMfBgYW3wr9WeCdC6Fdyyq47Y5TTswkg+EsvfxU yzQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="znPn/xmR"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g4si6060071ejb.192.2020.05.03.23.16.26; Sun, 03 May 2020 23:16:49 -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=@kernel.org header.s=default header.b="znPn/xmR"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726913AbgEDGOx (ORCPT + 99 others); Mon, 4 May 2020 02:14:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:55476 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726404AbgEDGOw (ORCPT ); Mon, 4 May 2020 02:14:52 -0400 Received: from localhost (unknown [171.76.84.84]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3AF73206B9; Mon, 4 May 2020 06:14:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588572892; bh=N0yq5ahXgMtgtu91eiz8HXvEkM1smExwUQNbeJhVm90=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=znPn/xmRZBsl9Cqux5lgOg2EXM8P3iOA/D6w5D6hv/aEEJ90kAs2PreaLAjsVcJCo NhlwZCpIr90Z1zHF5LGKeqzvFgtoAN/8C8afMW7WrJdN+4VCPQVtWkRkhcnPyeCkMw KBRPvwQXAOvoveIhm3b5Je5SAQQyTxQdw1AAwT4E= Date: Mon, 4 May 2020 11:44:45 +0530 From: Vinod Koul To: Sanjay R Mehta Cc: gregkh@linuxfoundation.org, dan.j.williams@intel.com, Thomas.Lendacky@amd.com, Shyam-sundar.S-k@amd.com, Nehal-bakulchandra.Shah@amd.com, robh@kernel.org, mchehab+samsung@kernel.org, davem@davemloft.net, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org Subject: Re: [PATCH v4 2/3] dmaengine: ptdma: register PTDMA controller as a DMA resource Message-ID: <20200504061445.GK1375924@vkoul-mobl> References: <1588108416-49050-1-git-send-email-Sanju.Mehta@amd.com> <1588108416-49050-3-git-send-email-Sanju.Mehta@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1588108416-49050-3-git-send-email-Sanju.Mehta@amd.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 28-04-20, 16:13, Sanjay R Mehta wrote: > +static void pt_do_cmd_complete(unsigned long data) > +{ > + struct pt_tasklet_data *tdata = (struct pt_tasklet_data *)data; > + struct pt_cmd *cmd = tdata->cmd; > + struct pt_cmd_queue *cmd_q = &cmd->pt->cmd_q; > + u32 tail; > + > + tail = lower_32_bits(cmd_q->qdma_tail + cmd_q->qidx * Q_DESC_SIZE); > + if (cmd_q->cmd_error) { > + /* > + * Log the error and flush the queue by > + * moving the head pointer > + */ > + pt_log_error(cmd_q->pt, cmd_q->cmd_error); > + iowrite32(tail, cmd_q->reg_head_lo); > + } > + > + cmd->pt_cmd_callback(cmd->data, cmd->ret); So in the isr you schedule this tasklet and this invokes the calback.. this is very inefficient. You should submit the next txn to dmaengine in your isr, keeping the dma idle at this point is very inefficient. > +static void pt_cmd_callback(void *data, int err) > +{ > + struct pt_dma_desc *desc = data; > + struct pt_dma_chan *chan; > + int ret; This is called as callback from pt layer.. > + > + if (err == -EINPROGRESS) > + return; > + > + chan = container_of(desc->vd.tx.chan, struct pt_dma_chan, > + vc.chan); > + > + dev_dbg(chan->pt->dev, "%s - tx %d callback, err=%d\n", > + __func__, desc->vd.tx.cookie, err); > + > + if (err) > + desc->status = DMA_ERROR; > + > + while (true) { > + /* Check for DMA descriptor completion */ > + desc = pt_handle_active_desc(chan, desc); > + > + /* Don't submit cmd if no descriptor or DMA is paused */ > + if (!desc || chan->status == DMA_PAUSED) > + break; > + > + ret = pt_issue_next_cmd(desc); And you call this to issue next cmd... The missing thing I am seeing here is vchan_cookie_complete() you need to call that here for correct vchan list mgmt > +static struct pt_dma_desc *pt_create_desc(struct dma_chan *dma_chan, > + struct scatterlist *dst_sg, > + unsigned int dst_nents, > + struct scatterlist *src_sg, > + unsigned int src_nents, > + unsigned long flags) unaligned add indentation! Pls run checkpatch --strict to check for these oddities > + dma_dev->dev = pt->dev; > + dma_dev->src_addr_widths = PT_DMA_WIDTH(dma_get_mask(pt->dev)); > + dma_dev->dst_addr_widths = PT_DMA_WIDTH(dma_get_mask(pt->dev)); > + dma_dev->directions = DMA_MEM_TO_MEM; > + dma_dev->residue_granularity = DMA_RESIDUE_GRANULARITY_DESCRIPTOR; > + dma_cap_set(DMA_MEMCPY, dma_dev->cap_mask); > + dma_cap_set(DMA_INTERRUPT, dma_dev->cap_mask); > + dma_cap_set(DMA_PRIVATE, dma_dev->cap_mask); > + > + INIT_LIST_HEAD(&dma_dev->channels); > + > + chan = pt->pt_dma_chan; > + chan->pt = pt; > + dma_chan = &chan->vc.chan; > + > + dma_dev->device_free_chan_resources = pt_free_chan_resources; > + dma_dev->device_prep_dma_memcpy = pt_prep_dma_memcpy; > + dma_dev->device_prep_dma_interrupt = pt_prep_dma_interrupt; > + dma_dev->device_issue_pending = pt_issue_pending; > + dma_dev->device_tx_status = pt_tx_status; > + dma_dev->device_pause = pt_pause; > + dma_dev->device_resume = pt_resume; > + dma_dev->device_terminate_all = pt_terminate_all; Pls implement .device_synchronize as well > +struct pt_dma_desc { > + struct virt_dma_desc vd; > + > + struct pt_device *pt; > + > + struct list_head pending; > + struct list_head active; why not use vc->desc_submitted, desc_issued instead! > + > + enum dma_status status; > + > + size_t len; > +}; > + > +struct pt_dma_chan { > + struct virt_dma_chan vc; > + > + struct pt_device *pt; > + > + enum dma_status status; channel status as well as desc, why do you need both? -- ~Vinod