Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp781425imm; Wed, 20 Jun 2018 06:33:59 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLjP9Qi/4hFTSgWT2zXc7sOC09oj5FsiX6RG8uDHl7bmHinzOsGDzYlpmAchHWt/pNZGnFD X-Received: by 2002:a62:469d:: with SMTP id o29-v6mr22774859pfi.80.1529501639866; Wed, 20 Jun 2018 06:33:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529501639; cv=none; d=google.com; s=arc-20160816; b=Q7Svie9659lWVPxryYyUnEXyxduERWKzeNNQtd+aTlYWv94TiMlpWkNfcrQY45hl5X UBrfZ5WYe2JthZVqwfhO/4zxssIacgnk94ciPy6Ol+utvi+1S7s6qtGl+Q+3mCkwAatP b8XtggbEJU6kBfwE2nJFaI7X7uJ7cCvCa2qVnHzXBvx87+WEbC4oWqFPVaaqfVdQlrVj G4TAAkJQc4eiGivXlLhc8imF+a7+nHcCnPQ74I7RhNxiPWcZvEZBrJ/lsne/7kXO2MH2 Nmovx9p+A78GwPuqmKHipk2FnCt/2OyDpK+8fjlXZQkIydJQkID7+pxi/z2keaH0aVNV qEiA== 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 :references:in-reply-to:reply-to:mime-version:dkim-signature :arc-authentication-results; bh=lqUjxbFZJnbLw6sxx3tgEDZ8J0hF4yGPrCfPxDnYrLA=; b=NOCpF5tE1KTuADPt+enONzl+dVO8ih/hcJFWxXRwOwSk0TZNKiRgrHOo60OBA9nV0F KtKaAmwMErXFEN3ggCXe8OET8/nqmw2Qjhc/0A1a+/hVHEd+VIdlYHdmCCdwMahaNjva HPC9uz7d5Asp6AboMsADsYoBWZlidrbGbxtXsUtTpnkwSMBkSttO6Xd9R1x7FCVdgqZi JPDy8r9m2/duhJgWEaRi/u1Y+Y1RlJVHehgDj3c8znPbLfoPS7+Bf54SpdDz6lXsOwwD RgDHckR9A7qaaY6xntJTX2G+n7ri1G2IgtMjZCcV76nkH7tNIe/seianCfZZ10LuUeKo 7TCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ixTxzZuR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r17-v6si2428320pfg.305.2018.06.20.06.33.45; Wed, 20 Jun 2018 06:33:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ixTxzZuR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754272AbeFTNcp (ORCPT + 99 others); Wed, 20 Jun 2018 09:32:45 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:46083 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752891AbeFTNcm (ORCPT ); Wed, 20 Jun 2018 09:32:42 -0400 Received: by mail-wr0-f194.google.com with SMTP id v13-v6so3305390wrp.13; Wed, 20 Jun 2018 06:32:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:reply-to:in-reply-to:references:from:date:message-id :subject:to:cc; bh=lqUjxbFZJnbLw6sxx3tgEDZ8J0hF4yGPrCfPxDnYrLA=; b=ixTxzZuRqIFfj8M6psUno5so6JgYuwjN5xSxWYmsuAC2gpuxEL3YeMYOY22RyFvDwK hwCYgHo4qenM6AMjJcCgAd5rLVNx6qN3o1rxShMKwvC8+onmTRcCci9ETealDPTWpIoL tC0uSKecnLE7KQmmw+8y2eEj92A3Ml0HwNsJrfYdWLIgR42ks0z5s+wgT4SRBSxno0kk d05KLj56/iSLUrH/b0RRP9mVLY22uxLjOsDBaQ1L5uBSbFr6Tfc2x/VxSFxt6ypW5UdU eeZWl5hLmsIX8vO6EUiMUkrmBx/thnz6QPwKShnPX0bpBv+p7Rp07Ddo8g+p+qPC3BR4 ymSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:reply-to:in-reply-to:references :from:date:message-id:subject:to:cc; bh=lqUjxbFZJnbLw6sxx3tgEDZ8J0hF4yGPrCfPxDnYrLA=; b=Tt6AWCorWxiFHgD5kFBxhZ1TqrIUyI3o6zBNLCza1P+Mmf37Fa7/vAV8CzbpFEIWex eUuQ84gLMZJN3YjgTd/KH8ezjCa9D1jLxoifYdhHYcXz5K9zo05rFIhqxMPNprrhbooG eWbKgrX+qKtkQoSSnnSxUU1iX62ITeJN5NjrLzhEqPjYnVsW8gO/HIb2hvAtMpmR3GPf 40oVKfLTwMFnikk12WHjT3TZiyF4ZQ5U7QcMkbRqjF5r5gGs4C9bv7pWbGr48FqxcOY1 xOz7jFY2JrQSO2FZIbgy8r/I1XzV/V7aH2RO/+8B1NM7J+v1kDgLQdfX1aDHGIJa7Y+l sjOA== X-Gm-Message-State: APt69E1N1KoOECmMWUXge4oamkMTvYPE+VnDMitoWj0XMZOc9+Dlb4nn vzmO6r4kSHgCHUrpQS1QuKGQ3kd/Xs2osTByz24= X-Received: by 2002:adf:e751:: with SMTP id c17-v6mr17960442wrn.143.1529501561236; Wed, 20 Jun 2018 06:32:41 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a1c:5c8d:0:0:0:0:0 with HTTP; Wed, 20 Jun 2018 06:32:20 -0700 (PDT) Reply-To: andrea.merello@gmail.com In-Reply-To: References: <20180620083653.17010-1-andrea.merello@gmail.com> <20180620083653.17010-2-andrea.merello@gmail.com> From: Andrea Merello Date: Wed, 20 Jun 2018 15:32:20 +0200 Message-ID: Subject: Re: [PATCH 2/6] dmaengine: xilinx_dma: fix completion callback is not invoked for each DMA operation To: Radhey Shyam Pandey Cc: "vkoul@kernel.org" , "dan.j.williams@intel.com" , Michal Simek , Appana Durga Kedareswara Rao , "dmaengine@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" 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, Jun 20, 2018 at 2:36 PM, Radhey Shyam Pandey wrote: >> -----Original Message----- >> From: dmaengine-owner@vger.kernel.org [mailto:dmaengine- >> owner@vger.kernel.org] On Behalf Of Andrea Merello >> Sent: Wednesday, June 20, 2018 2:07 PM >> To: vkoul@kernel.org; dan.j.williams@intel.com; Michal Simek >> ; Appana Durga Kedareswara Rao >> ; dmaengine@vger.kernel.org >> Cc: linux-arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org; >> Andrea Merello >> Subject: [PATCH 2/6] dmaengine: xilinx_dma: fix completion callback is not >> invoked for each DMA operation >> >> API specification says: "On completion of each DMA operation, the next in >> queue is started and a tasklet triggered. The tasklet will then call the >> client driver completion callback routine for notification, if set." >> >> Currently the driver keeps a "desc_pendingcount" counter of the total >> descriptor pending, and it uses as IRQ coalesce threshold, as result it >> only calls the CBs after ALL pending operations are completed, which is >> wrong. > I think IRQ coalescing enable/disable should be configurable. > Performance related usecases will need this support. I didn't intend this (only) wrt performances; my concern was mostly wrt correctness. If my point of view is wrong then I'll drop this patch from the series. (.. I might respin it again in future: I had a patch wrt an old driver version that allowed submitting new descriptors to the HW while the DMA is running, and in this case disabling coalesce is needed i.e. in order to submit a new empty buffer whenever the DMA finishes a transfer without waiting the DMA to stop). BTW, is there any dmaengine API suitable for setting interrupt coalesce? >> >> This patch uses disable IRQ coalesce and checks for the completion flag >> for the descriptors (which is further divided in segments). >> >> Possibly a better optimization could be using proper IRQ coalesce >> threshold to get an IRQ after all segments of the descriptors are done. >> But we don't do that yet.. >> >> NOTE: for now we do this only for AXI DMA, other DMA flavors are >> untested/untouched. >> This is loosely based on >> commit 65df81a6dc74 ("xilinx_dma: IrqThreshold set incorrectly, unreliable.") >> in my linux-4.6-zynq tree > NOTE description doesn't help much. > >> >> From: Jeremy Trimble [original patch] >> Signed-off-by: Andrea Merello >> --- >> drivers/dma/xilinx/xilinx_dma.c | 39 +++++++++++++++++++++------------ >> 1 file changed, 25 insertions(+), 14 deletions(-) >> >> diff --git a/drivers/dma/xilinx/xilinx_dma.c b/drivers/dma/xilinx/xilinx_dma.c >> index a516e7ffef21..cf12f7147f07 100644 >> --- a/drivers/dma/xilinx/xilinx_dma.c >> +++ b/drivers/dma/xilinx/xilinx_dma.c >> @@ -164,6 +164,7 @@ >> #define XILINX_DMA_CR_COALESCE_SHIFT 16 >> #define XILINX_DMA_BD_SOP BIT(27) >> #define XILINX_DMA_BD_EOP BIT(26) >> +#define XILINX_DMA_BD_CMPLT BIT(31) >> #define XILINX_DMA_COALESCE_MAX 255 >> #define XILINX_DMA_NUM_DESCS 255 >> #define XILINX_DMA_NUM_APP_WORDS 5 >> @@ -1274,12 +1275,9 @@ static void xilinx_dma_start_transfer(struct >> xilinx_dma_chan *chan) >> >> reg = dma_ctrl_read(chan, XILINX_DMA_REG_DMACR); >> >> - if (chan->desc_pendingcount <= XILINX_DMA_COALESCE_MAX) { >> - reg &= ~XILINX_DMA_CR_COALESCE_MAX; >> - reg |= chan->desc_pendingcount << >> - XILINX_DMA_CR_COALESCE_SHIFT; >> - dma_ctrl_write(chan, XILINX_DMA_REG_DMACR, reg); >> - } >> + reg &= ~XILINX_DMA_CR_COALESCE_MAX; >> + reg |= 1 << XILINX_DMA_CR_COALESCE_SHIFT; >> + dma_ctrl_write(chan, XILINX_DMA_REG_DMACR, reg); >> >> if (chan->has_sg && !chan->xdev->mcdma) >> xilinx_write(chan, XILINX_DMA_REG_CURDESC, >> @@ -1378,6 +1376,20 @@ static void xilinx_dma_complete_descriptor(struct >> xilinx_dma_chan *chan) >> return; >> >> list_for_each_entry_safe(desc, next, &chan->active_list, node) { >> + if (chan->xdev->dma_config->dmatype == >> XDMA_TYPE_AXIDMA) { >> + /* >> + * Check whether the last segment in this descriptor >> + * has been completed. >> + */ >> + const struct xilinx_axidma_tx_segment *const tail_seg >> = >> + list_last_entry(&desc->segments, >> + struct >> xilinx_axidma_tx_segment, >> + node); >> + >> + /* we've processed all the completed descriptors */ >> + if (!(tail_seg->hw.status & XILINX_DMA_BD_CMPLT)) >> + break; >> + } >> list_del(&desc->node); >> if (!desc->cyclic) >> dma_cookie_complete(&desc->async_tx); >> @@ -1826,14 +1838,13 @@ static struct dma_async_tx_descriptor >> *xilinx_dma_prep_slave_sg( >> struct xilinx_axidma_tx_segment, node); >> desc->async_tx.phys = segment->phys; >> >> - /* For the last DMA_MEM_TO_DEV transfer, set EOP */ >> - if (chan->direction == DMA_MEM_TO_DEV) { >> - segment->hw.control |= XILINX_DMA_BD_SOP; >> - segment = list_last_entry(&desc->segments, >> - struct xilinx_axidma_tx_segment, >> - node); >> - segment->hw.control |= XILINX_DMA_BD_EOP; >> - } >> + /* For the first transfer, set SOP */ >> + segment->hw.control |= XILINX_DMA_BD_SOP; >> + /* For the last transfer, set EOP */ >> + segment = list_last_entry(&desc->segments, >> + struct xilinx_axidma_tx_segment, >> + node); >> + segment->hw.control |= XILINX_DMA_BD_EOP; >> >> return &desc->async_tx; >> >> -- >> 2.17.1 >> >> -- >> To unsubscribe from this list: send the line "unsubscribe dmaengine" in >> the body of a message to majordomo@vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html