Received: by 10.192.165.148 with SMTP id m20csp1332705imm; Thu, 10 May 2018 09:05:00 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrJUnn1RekQgSCNU2GovxfRNRppPeOAG1BBUU+IcOMj8Y6AO8qXExaY8GS7Tb6Gq5fx0YAM X-Received: by 2002:a63:344c:: with SMTP id b73-v6mr1617638pga.258.1525968300570; Thu, 10 May 2018 09:05:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525968300; cv=none; d=google.com; s=arc-20160816; b=BVLYOorz13aBjoz1GBail8H+GtJaXuuZI87UYe1mJghEU+IzqjZUrPWwwLro2SMwyM I7q61WWVq3ofC9bVtdZ/UKycqavj81hZ13AAgwfTMPToXQGz0IAi+Ko1JarESQ3pPZSr y+zLkKov+ZlrmIa0HiZj1pLt8Bd0TrSkQ5dUDy6wQ/eK/84QmxFzvybVfkJyZ1paAiXq 39aBRkWzgNnjACW65wWUK7soKJbHlHOPV3fO73EmmopmVJfypfIGq/+C2RtceBqqdLGS nkC6SpRon6V3xy36OxlKXgNGEsiV4iUIj3ohwqRV0/wu96NX99ASMSo3CD/QzDLmjezi M44A== 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=eJSwIOx2RJPpPjez1SGYj18AvJYq87WBUAH84HUwlLs=; b=zE9S2l5AbA9zzrR8TUBOyg1/sPjEwdnlYUCoPngf/4BgNRIS3Aa5rLAoMILZkXbdC9 v8iWMEojpGyaHrvsI7DZo4AUwLiZGBZ0Jd8ZoA8vQiyudz2FaG26VfNITm/Yc/39UHjn nknRJ/uWe5EhniLcOdyiyyWC1fAlw8YKSFVsNIrgLAk7yRTT64td0mjMs3zRMMDFbHnL zeyPAJVyd1VKs+4m7r0JZqfk0QGAY4R+Oax76TXX+WmlyoOnOkYjHB6QIzWI2n6nafIh ZIxwuK+7MRiEm8iXjiUW/6aYzr6r15kb5+o0WTYi3H6et7L0SAaXIp8CTFptjiYRnSbs Hb/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=D7J3UZgc; 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 1-v6si1082987pla.565.2018.05.10.09.04.45; Thu, 10 May 2018 09:05:00 -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=D7J3UZgc; 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 S966499AbeEJQEM (ORCPT + 99 others); Thu, 10 May 2018 12:04:12 -0400 Received: from mail-io0-f195.google.com ([209.85.223.195]:34520 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966464AbeEJQEJ (ORCPT ); Thu, 10 May 2018 12:04:09 -0400 Received: by mail-io0-f195.google.com with SMTP id p124-v6so3621807iod.1; Thu, 10 May 2018 09:04:09 -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=eJSwIOx2RJPpPjez1SGYj18AvJYq87WBUAH84HUwlLs=; b=D7J3UZgciUFlPF9guB7Jk/sASZ+8NkT5cORT7KGXLbAivadjs/LUiYCTYHKObAEsJ7 VZOPHXD/YeTMJ5Gwx+TV3RbzWoWhc2FcJWFo3hGRGbof06JXrm4ob/nw1V+bIu3zXicr u3AES7kpy6MaH6AtYgxT+ZJAMzZlYORhWbyHg1IsY3zMxvuec4aE08Q63yeXteKb0EPL vb1wxMhOCaFK1aZ6mDj/mn4xrNc/EayKc8yjNzSvBrfChMk8ZKi8TtJt4wxVxwBN2DYJ 7IuLU5ssA+oBN9Ug9soD2ftaeVOFk8BDHnHlTDCqTiZLfrQQyfYmKH9dpvj4fMmW/B2m VwRQ== 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=eJSwIOx2RJPpPjez1SGYj18AvJYq87WBUAH84HUwlLs=; b=DsQzCdcSl2F2JE3YQmOMz41bklS9ZEXrI5KwGLqFSKDdNNai0boOidNejd+j0/5bYv HpZPMne3nRkF9GLpPO5KQ4J4zLfLZBmpgCnyN8sJ+9qkkcTKREDgNP/uVAicCZUvvk5K O4QD1UwY3ql429epQ1oHrAbsSdtvTeaB54k5k2r2pZINVuu8ULhvH7qaNDhcv7sMUwkm YX4VAZiH99bFqcgGMAOkBR9ElWJZTFR1DrCRGPrPl5zCU+gyTb9YMNetLOJPcqYOX6Me Zs0RieLEXeGSvqzHcm+8Eh+Yr11iLmlLTixIOSMr2G6C4ZHhyE6lTU2bWRD1hDc9LJq0 mCsw== X-Gm-Message-State: ALKqPwcSfNknHuRsu1sScghCbI4rfgzuAmToleF+nAf0aqElmM2nNDkv optitxuXMBAUwInsZUXfIPZhyGkgRYlU7+ze54k= X-Received: by 2002:a6b:7c9:: with SMTP id g70-v6mr2174712ioi.82.1525968248870; Thu, 10 May 2018 09:04:08 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a4f:4d51:0:0:0:0:0 with HTTP; Thu, 10 May 2018 09:04:08 -0700 (PDT) In-Reply-To: References: <2484918.HKVQc3yJkt@bear> <53b13d76-16a1-0e0a-09e1-c917e5d49326@samsung.com> <182f50b9-55b6-c9ce-07fb-718a1d22e9c8@samsung.com> From: Frank Mori Hess Date: Thu, 10 May 2018 12:04:08 -0400 Message-ID: Subject: Re: Revert "dmaengine: pl330: add DMA_PAUSE feature" To: Marek Szyprowski Cc: Vinod Koul , dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, Dan Williams , r.baldyga@hackerion.com, Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz , Linux Samsung SOC 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 Thu, May 10, 2018 at 4:31 AM, Marek Szyprowski wrote: > Hi Frank, > > On 2018-05-09 19:48, Frank Mori Hess wrote: >> On Wed, May 9, 2018 at 9:19 AM, Marek Szyprowski >> wrote: >>> I understand that pl330 doesn't support real PAUSE, but as it has been >>> implemented since 2015 the limited support is perfectly possible - just >>> to let serial driver to read the amount of data transferred. >>> >>> Please note that DMA engine documentation clearly states that the best >>> residue granularity the driver might expect is BURST granularity. There >>> is no way to get the information about the data which still sits in the >>> DMA engine fifo when transfer is paused/terminated. This means that >>> the serial driver should set maxburst = 1 if it is interested in >>> getting exact number of bytes received/sent. With maxburst = 1 there >>> is no such thing as data loose in the DMA engine fifo. >> That is not my understanding of the dmaengine pause requirements, but >> of course Vinod can speak authoritatively on this. > > Basing on the comments in dma_residue_granularity enum documentation (see > include/linux/dmaengine.h) there is no better granularity of residue > reporting than BURST units. If driver needs byte accuracy, then it should > use MAXBURST=1 and DMA_SLAVE_BUSWIDTH_1_BYTE configuration. That's an interesting line of thought. The 8250 serial driver clearly assumes it can do the sequence dma pause read residue dma terminate without data loss. It checks for the capabilities cmd_pause cmd_terminate residue_granularity != DMA_RESIDUE_GRANULARITY_DESCRIPTOR and some of the 8250 drivers like 8250_dw.c set a maxburst > 1. If it can't count on the pause/residue/terminate working without data loss then it is just broken. As is the 8250_omap.c driver. Is the description of dmaengine_pause in the documentation of "This pauses activity on the DMA channel without data loss" to be interpreted as "as long as you resume afterwards"? >> I also don't agree >> that data loss cannot happen for single transfers. It only becomes >> less likely since there are fewer bytes in the dma controller fifo and >> they stay there for a shorter period of time. But even so, there is >> nothing stopping the DMAKILL from killing the transfer thread after it >> does a single byte load but before it does the associated single byte >> store, as they are performed by separate instructions. As far as your >> serial port goes, the byte has been read by the host, even though it >> never made it to memory, so it is gone forever. The dma-330 does have >> a load lock which prevents some operations from interrupting a >> load/store combination, but in my observations DMAKILL does not >> respect the load lock. > > For the last 3 years no one observed any issue with the current design > (single transfers with DMA_SLAVE_BUSWIDTH_1_BYTE). By removing this > feature we will loose ability to use DMA in the serial drivers, what is > mainly useful for low-power bluetooth operation (serial console is really > negligible case). It's not surprising it hasn't been reported. It is a race that requires a DMAKILL to be issued just as a byte is in-flight through the dma controller. The only reason a driver would pause the un-resumeable pl330 would be because the driver either knows or suspects no more data will be arriving and it gives up on the transfer. The only reason I noticed is we had a test which sent data to a serial port, waited just long enough for the serial port rx to timeout, then sent more data just as the pause was issuing DMAKILL. And then the test did this a few hundred thousand times until it noticed bad data. Also, given the way 8250 rx timeouts work, a person typing into a serial console wouldn't type fast enough to trigger the bug unless the baud rate was set extremely low. And if someone lost a keystroke every 10^5 bytes, who would blame the dma controller? I do admit I didn't do this test using single transfers, because our goal was getting bursts to work. Unfortunately, the test program relies on some custom hardware I no longer have access to so I can't easily re-run the test now. However, since the DMA-330 manual documents the DMAKILL instruction to: "Remove all entries in the MFIFO for the DMA channel." "Remove all entries in the read buffer queue and write buffer queue for the DMA channel." Relying on it to work as a safe pause for single transfers seems like wishful thinking. I sure didn't want to believe the DMA-330 couldn't be safely paused, but I eventually had to resign myself to it.