Received: by 10.192.245.15 with SMTP id i15csp1223212imn; Sun, 11 Mar 2018 09:11:16 -0700 (PDT) X-Google-Smtp-Source: AG47ELsKfbAJHNLno6RREsmu0TLb8FJLqgEk0EUiAymU8+LFsobzT3Wc8QLJhMIhZqiLv+Pp1ztx X-Received: by 2002:a17:902:be02:: with SMTP id r2-v6mr5202165pls.234.1520784676643; Sun, 11 Mar 2018 09:11:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520784676; cv=none; d=google.com; s=arc-20160816; b=GCsfIxRvQUKrO5XTpzdO/FeWAcOYbRTDFovtoKU2hsnhgtBWiQO1lV0UT6BNlob1Qy X3WUMr+lFIf3Q2BdZaYCX+Fsbuc4xFSzIBfeR+DlsC0d8JvKXGnaEolxhViXHZjVVBrp RVsv/BvTGniwkYYjLhNbWBMaAPIiJRf/zn5ti4PBjVRPZj6EDBRXQNdbLyGyJzEXcyaG nmGJakUfgwckLbLLNWSdaCC4PK05vA6OqcnvuItquAuyaI7JzoX+lAAiaC9tNoYNlPwq WuK62odT0AhaMxfzWKKHYE4D+rChWMcKt6NFiiSAsISLCboH8GtxJRs+BJFgcNiW7gSS TXqg== 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:mime-version:dkim-signature :arc-authentication-results; bh=V0h4UR+2tiRWRyAwEwSImTvN9T24xfDLOEXE1N0yveA=; b=vIUfKtSMO4DMXb/e+Mtb0DXOKOUJzTvoZFTWwWlgAhK6HaBskoO7IcjC2qfQLS3bNr KstZLmUizK7RI1c3w5v50KXZcCgsZLU8TCADDUDCv2O3Q8S8vgLxbQlOkz9vHaPsYKjh eFX05zfKMBkbXIjla6OT61gL0faRQIih0Cw1qUHmrRLolmuh3eZYS0FsPkvHFU35s/qv l+YyLkRopgLVn7uro+Odlmd4NUIe+d2uKFZgAq8iD8xeuHF6JRUj4db7WwYfTW/tD0/F yAmb8j0ZpT1Vt80gGWI3yWxbVmPZH3OTlcq3Aism8JdLki36Ra22tW/II+BAjS5/024g qWIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=m1eEmtqC; 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 n1si3797643pgc.527.2018.03.11.09.11.01; Sun, 11 Mar 2018 09:11:16 -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=m1eEmtqC; 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 S932171AbeCKQKH (ORCPT + 99 others); Sun, 11 Mar 2018 12:10:07 -0400 Received: from mail-io0-f194.google.com ([209.85.223.194]:39454 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932136AbeCKQKF (ORCPT ); Sun, 11 Mar 2018 12:10:05 -0400 Received: by mail-io0-f194.google.com with SMTP id v10so2004976iob.6; Sun, 11 Mar 2018 09:10:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=V0h4UR+2tiRWRyAwEwSImTvN9T24xfDLOEXE1N0yveA=; b=m1eEmtqCNOLOCe0wM4iBHPQFo9AnpvVASSv4w01av9yOKxb93dIDn2jkKd4iEPmZZu IiX+AyADMJoclTF1m5NZQBFjUAYNhocPgfn5CKHY6h2Z3tgWKk6rDo9tD0Vqn/yFyAdd XwH6h4Wejj3zSwXKvvjK4l6wce4Ky83dSJwiAIbzfKrt530CSSAb6Z9R2Knkm7uAELau /Wk+HmkuCFGBRuGPgU8I9EPoN7GM/iLypN0wBaG86dZ3JArK3PEWhAJbkJyNKjuyMnSZ QsDGPLYa5cdRr+ZtfSSU2I1rl60VaAlXFrdKES0iqQbmkdfIQGLUPw4SlrFEFjEDc5uP jxeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=V0h4UR+2tiRWRyAwEwSImTvN9T24xfDLOEXE1N0yveA=; b=r01OMWHXXeOoy5l+7kbRFkNzNZuDYU7QsQVvHKhbb5rDXkHJ8kJZy4z4PpvllaAnhh dd6cUNTk/MpvBfyKl7YWwe6K9KFQnXydBUmFhOgr0b3LUSQCllD4XAEuiVnZntAFy1fc yzZ7SmoXkrSmF1tF2+JWynXF2eZiF6HVJsdRZ9dp5Cd1o2JpWaih2aGELj9Wnnh/gHVd HDuNtw68EMqY9COyVWT2Mi29fnqSFws97b1RzWXFVVh5K/VoLXJGZK6swA7MW+ygCP8C UogOG/igo0LOlskFT95kQbHMAk1N/HgO9tQV7tKihuXroogoS8F4lzweQVow4OWRECkB Pubg== X-Gm-Message-State: AElRT7G6Ek6m/K9VdVBYuXwTZt8AD3PH2eB33Yd0glDvYE+YiMwB75+u ra/IQkgokbihuqBiUrZUI7/om49v2dPrA3TT7XM= X-Received: by 10.107.188.194 with SMTP id m185mr5867745iof.21.1520784604813; Sun, 11 Mar 2018 09:10:04 -0700 (PDT) MIME-Version: 1.0 Received: by 10.79.164.85 with HTTP; Sun, 11 Mar 2018 09:10:03 -0700 (PDT) In-Reply-To: <20180311150151.GB15443@localhost> References: <1957017.QzKNMJJqD6@bear> <20180306120259.GT15443@localhost> <23394379.8nZhno5foU@bear> <20180311150151.GB15443@localhost> From: Frank Mori Hess Date: Sun, 11 Mar 2018 12:10:03 -0400 Message-ID: Subject: Re: [PATCH v3] dmaengine: pl330: flush before wait, and add dev burst support. To: Vinod Koul Cc: fmhess@users.sourceforge.net, dmaengine@vger.kernel.org, Dan Williams , 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 Sun, Mar 11, 2018 at 11:01 AM, Vinod Koul wrote: > > sorry if it wasnt clear earlier, the lines below should come after the --- > line. git-am skips that part while applying.. ok >> >> + /* do FLUSHP at beginning to clear any stale dma requests before the >> + * first WFP. >> + */ > > multiline comments should be: > > /* > * this is an example of multi-line > * comment > */ > > Pls fix at this and other places... ok > >> static inline int _ldst_memtodev(struct pl330_dmac *pl330, >> unsigned dry_run, u8 buf[], >> - const struct _xfer_spec *pxs, int cyc) >> + const struct _xfer_spec *pxs, int cyc, >> + enum pl330_cond cond) >> { >> int off = 0; >> - enum pl330_cond cond; >> >> if (pl330->quirks & PL330_QUIRK_BROKEN_NO_FLUSHP) >> cond = BURST; >> - else >> - cond = SINGLE; >> >> + /* do FLUSHP at beginning to clear any stale dma requests before the >> + * first WFP. >> + */ >> + if (!(pl330->quirks & PL330_QUIRK_BROKEN_NO_FLUSHP)) >> + off += _emit_FLUSHP(dry_run, &buf[off], pxs->desc->peri); >> while (cyc--) { >> off += _emit_WFP(dry_run, &buf[off], cond, pxs->desc->peri); >> off += _emit_LD(dry_run, &buf[off], ALWAYS); >> - off += _emit_STP(dry_run, &buf[off], cond, pxs->desc->peri); >> - >> - if (!(pl330->quirks & PL330_QUIRK_BROKEN_NO_FLUSHP)) >> - off += _emit_FLUSHP(dry_run, &buf[off], >> - pxs->desc->peri); >> + if (cond == ALWAYS) { >> + off += _emit_STP(dry_run, &buf[off], SINGLE, >> + pxs->desc->peri); >> + off += _emit_STP(dry_run, &buf[off], BURST, >> + pxs->desc->peri); >> + } else { >> + off += _emit_STP(dry_run, &buf[off], cond, >> + pxs->desc->peri); >> + } > > this looks quite similar to previous routine above, if so can we please make > it common function and invoke from both of these... _ldst_memtodev and _ldst_devtomem are similar, but they were even more similar before my patch. Do I really have to refactor existing code to get my patch applied? I'm not trying to take over maintainership of the pl330.c driver. > >> +static int _dregs(struct pl330_dmac *pl330, unsigned int dry_run, u8 buf[], >> + const struct _xfer_spec *pxs, int transfer_length) >> +{ >> + int off = 0; >> + int dregs_ccr; >> + >> + if (transfer_length == 0) >> + return off; >> + >> + switch (pxs->desc->rqtype) { >> + case DMA_MEM_TO_DEV: >> + off += _ldst_memtodev(pl330, dry_run, &buf[off], pxs, >> + transfer_length, SINGLE); >> + break; > > empty line after each case pls ok > >> + case DMA_DEV_TO_MEM: >> + off += _ldst_devtomem(pl330, dry_run, &buf[off], pxs, >> + transfer_length, SINGLE); >> + break; >> + case DMA_MEM_TO_MEM: >> + dregs_ccr = pxs->ccr; >> + dregs_ccr &= ~((0xf << CC_SRCBRSTLEN_SHFT) | >> + (0xf << CC_DSTBRSTLEN_SHFT)); >> + dregs_ccr |= (((transfer_length - 1) & 0xf) << >> + CC_SRCBRSTLEN_SHFT); >> + dregs_ccr |= (((transfer_length - 1) & 0xf) << >> + CC_DSTBRSTLEN_SHFT); >> + off += _emit_MOV(dry_run, &buf[off], CCR, dregs_ccr); >> + off += _ldst_memtomem(dry_run, &buf[off], pxs, 1); >> + break; >> + default: >> + off += 0x40000000; /* Scare off the Client */ > > Can you explain this bit, shouldnt this be err? > I just copied that behavior from the existing _bursts() function. I guess the original author's idea was returning a big offset would result in a dry run failure due to exceeding the maximum buffer size. I do agree an error would be better, although it would require refactoring since the return values from _bursts and _dregs are not checked for errors, they just blindly add the return value to the offset. >> @@ -1303,11 +1362,6 @@ static int _setup_req(struct pl330_dmac *pl330, unsigned dry_run, >> /* DMAMOV CCR, ccr */ >> off += _emit_MOV(dry_run, &buf[off], CCR, pxs->ccr); >> >> - x = &pxs->desc->px; >> - /* Error if xfer length is not aligned at burst size */ >> - if (x->bytes % (BRST_SIZE(pxs->ccr) * BRST_LEN(pxs->ccr))) >> - return -EINVAL; >> - >> off += _setup_xfer(pl330, dry_run, &buf[off], pxs); >> >> /* DMASEV peripheral/event */ >> @@ -2115,15 +2169,29 @@ static int pl330_config(struct dma_chan *chan, >> pch->fifo_addr = slave_config->dst_addr; >> if (slave_config->dst_addr_width) >> pch->burst_sz = __ffs(slave_config->dst_addr_width); >> - if (slave_config->dst_maxburst) >> - pch->burst_len = slave_config->dst_maxburst; >> + if (pch->dmac->quirks & PL330_QUIRK_BROKEN_NO_FLUSHP) >> + pch->burst_len = 1; > > so in this case we don't honour the requested burst length? > I don't have any experience with the PL330_QUIRK_BROKEN_NO_FLUSHP hardware, or knowledge of how it (mis)behaves. So I just tried to maintain the existing behavior as much as possible. The old code advertised the max burst length as 1 with PL330_QUIRK_BROKEN_NO_FLUSHP hardware, and programmed the pl330 to respond only to burst requests (and of course the old code never did any peripheral bursts longer than 1). I actually don't mind changing the behavior of PL330_QUIRK_BROKEN_NO_FLUSHP but it seems like someone with more knowledge of that hardware should be involved, like the rock-chips.com guys who introduced it in commit 271e1b86e69140fe65718ae8a264284c46d3129d , >> + else if (slave_config->dst_maxburst) { >> + if (slave_config->dst_maxburst > PL330_MAX_BURST) >> + pch->burst_len = PL330_MAX_BURST; >> + else >> + pch->burst_len = slave_config->dst_maxburst; >> + } else >> + pch->burst_len = 1; >> } else if (slave_config->direction == DMA_DEV_TO_MEM) { >> if (slave_config->src_addr) >> pch->fifo_addr = slave_config->src_addr; >> if (slave_config->src_addr_width) >> pch->burst_sz = __ffs(slave_config->src_addr_width); >> - if (slave_config->src_maxburst) >> - pch->burst_len = slave_config->src_maxburst; >> + if (pch->dmac->quirks & PL330_QUIRK_BROKEN_NO_FLUSHP) >> + pch->burst_len = 1; >> + else if (slave_config->src_maxburst) { >> + if (slave_config->src_maxburst > PL330_MAX_BURST) >> + pch->burst_len = PL330_MAX_BURST; >> + else >> + pch->burst_len = slave_config->src_maxburst; >> + } else >> + pch->burst_len = 1; > > again this looks duplicate.. > -- > ~Vinod Ok, I'll make a little helper function. -- Frank