Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp751212imm; Fri, 11 May 2018 05:58:16 -0700 (PDT) X-Google-Smtp-Source: AB8JxZon2MUaFsdyVh/+vO/pajtG2YkfP7USEBp6+vvn9bJc1V/QFkfYUMiVhQS1nOa4R8I1b6B/ X-Received: by 2002:a17:902:778a:: with SMTP id o10-v6mr5496983pll.214.1526043496736; Fri, 11 May 2018 05:58:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526043496; cv=none; d=google.com; s=arc-20160816; b=xaz+jL/c/8LBBYzgmq/krodBcTSgxB67sJU5NoMOSuGPN8zZyG5kwHU+5y3v5HOY9E dvjAYji6jLExrzYyhroqIwInti2/IKT8NbJYzpc7byKkXQHoIJM6zYakwtuTZcnQ8MAy Umxl/FYRVRX8IEVPt0w3xaoUQ1qkiNcohZNXiXOhw/blF5epoo2DCuNpuVijNkWR3B8u hRDLR9WlNM2zc7mwW7rk1YetQgyuZwLw406ghnb0/RDAz/QLhw9aokH0cCf+EABBS2N3 OIQTa9N+gmRtN9lA2BIOlUCy5KHUVy+W6/Pu6ymmZgnKU7IrZCuINZ4qHkziCjQOy/3A 2BDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:cc:to:subject:dkim-signature:dkim-filter :arc-authentication-results; bh=FPrqqZ7WjSRczG7hFNAHIHPibfPc/QOb3khfAVHLS90=; b=L7hBlObHJFocvg21yoyGqcs8rVgt9pec/B8IyZgP6g8gC/YZRFMFjFa6cQpaeEN/s2 lFuFEvYMFMfCSuV7tASMfNBOM/1U5ty4G/VHAyQ7jOSd1p0zhVnDY5Sa3uarx3zyuY7F Qke0GlT41Cym4REQZbVZ3cGR9Odhn1CjPRZ7w4ZHWg3aAPffXj+lbzJ8dGOjPXH7+vvd 2DwSUc4KkWrFbowjfUFrJ4PFA0/8AhmVNlAEwWGkABazkYCQ0HCu7SObxGaP4/qOuqrS htCUpf/+54Up0yqNsmeBb0InaLfOgOYK6bwjElFU40bjEiVnIAijkHwmAR9aKWzwvFOz TXwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=HpTsnIoY; 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=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i89-v6si3350322pfd.117.2018.05.11.05.58.02; Fri, 11 May 2018 05:58: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=@samsung.com header.s=mail20170921 header.b=HpTsnIoY; 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=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753089AbeEKM5v (ORCPT + 99 others); Fri, 11 May 2018 08:57:51 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:42743 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752677AbeEKM5s (ORCPT ); Fri, 11 May 2018 08:57:48 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20180511125746euoutp01ff1073048ffc3e2de4e9218900eeb328~tmHKKisUs0039800398euoutp01t for ; Fri, 11 May 2018 12:57:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20180511125746euoutp01ff1073048ffc3e2de4e9218900eeb328~tmHKKisUs0039800398euoutp01t DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1526043466; bh=FPrqqZ7WjSRczG7hFNAHIHPibfPc/QOb3khfAVHLS90=; h=Subject:To:Cc:From:Date:In-Reply-To:References:From; b=HpTsnIoYH1OpR2nZhz8UuhR9SQuZzjB0Dn8yD9N5bzGixjntnhJHDnWXYGMrlUnP/ bPPLVwjxYC2qcLgsUlRuyODfjrbPxUo0hR/5iX4X0ZpyCNeeDDeSfwFn1ep3qekyvP 9DLyhfvBpQLYVKl9JbCVrH4kO5arA4VIwH+IFNy8= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20180511125745eucas1p24f1c22136c8716a5edf6532f8dbf390a~tmHJZxeVL3126631266eucas1p2b; Fri, 11 May 2018 12:57:45 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id AE.8D.10409.94395FA5; Fri, 11 May 2018 13:57:45 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20180511125744eucas1p1d61fdc9709033179b915390dfe1019e4~tmHIbLRqH3170531705eucas1p1u; Fri, 11 May 2018 12:57:44 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20180511125744eusmtrp12a4617c2138ede4e91e9ad31d831d3e5~tmHIMNKnu2811728117eusmtrp1c; Fri, 11 May 2018 12:57:44 +0000 (GMT) X-AuditID: cbfec7f5-b45ff700000028a9-33-5af593492fef Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 41.94.04183.84395FA5; Fri, 11 May 2018 13:57:44 +0100 (BST) Received: from [106.116.147.30] (unknown [106.116.147.30]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20180511125743eusmtip2b6fbb6fa94601a6e6336d714290de35f~tmHHsWgwU3154131541eusmtip2S; Fri, 11 May 2018 12:57:43 +0000 (GMT) Subject: Re: Revert "dmaengine: pl330: add DMA_PAUSE feature" To: Frank Mori Hess 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 From: Marek Szyprowski Message-ID: <06f54061-c537-b399-e493-ec2cdf4def5d@samsung.com> Date: Fri, 11 May 2018 14:57:43 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: Content-Transfer-Encoding: 7bit Content-Language: en-US X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrBKsWRmVeSWpSXmKPExsWy7djP87qek79GGdz9LGixccZ6VovpUy8w Wqye+pfVYv7juWwW589vYLe4vGsOm8WM8/uYLO7++8RosfPOCWYHTo+ds+6yexzZeYzNY/Ge l0wem1Z1snn0bVnF6PF5k1wAWxSXTUpqTmZZapG+XQJXxv35CQXHDSpmPtvO3sDYqN7FyMkh IWAi0f77PnMXIxeHkMAKRomWo4vZQBJCAl8YJbbcc4dIfGaUePFkKitMx/61txkhEssZJfZP aWaCcN4zSnx5/YMJpEpYwFaifcspsFEiAmoSG7YfZAEpYhbYwSSx/PYXRpAEm4ChRNfbLrAi XgE7iYVLZgAVcXCwCKhK7DmhAxIWFYiRmDbvOhNEiaDEyZlPWEBsToFAia9zj4BdxCwgL7H9 7RxmCFtc4taT+WAHSQgcY5dY/OcV1NkuEv+OvGWCsIUlXh3fwg5hy0icntzDAmHXS/R9PwLV 3MMosbdlKlSDtcTh4xdZQY5jFtCUWL9LHyJsK3Gt/xMzSFhCgE/ixltBiBv4JCZtmw4V5pXo aBOCqFaT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dc0tLA3Njc2NzSyUxHnPG1RGCQmkJ5akZqemFqQWwfQxcXBKNTBaNSq9sk785b5zjj3PMRb5 VUpqSyNOHZy74PBqhi/pSw//OWaypiP/T8utJZVZCqIP9Xe3N3rZdE5cfS+Eb+9MhcIvilI7 7XZVOO14pHZ8NYc9f1z8xjcz1ZROCEyIWqJjorT1ukPB+uOCWz6xXv5isvDWnHK/m2WbT/8N /fCiKt1yWen1uQxhSizFGYmGWsxFxYkAd0nFu90CAAA= X-CMS-MailID: 20180511125744eucas1p1d61fdc9709033179b915390dfe1019e4 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-MTR: 20180511125744eucas1p1d61fdc9709033179b915390dfe1019e4 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180508090407eucas1p13713284c2d3f5aa5c66f8d136be683c1 X-RootMTR: 20180508090407eucas1p13713284c2d3f5aa5c66f8d136be683c1 References: <2484918.HKVQc3yJkt@bear> <53b13d76-16a1-0e0a-09e1-c917e5d49326@samsung.com> <182f50b9-55b6-c9ce-07fb-718a1d22e9c8@samsung.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Frank, On 2018-05-10 18:04, Frank Mori Hess wrote: > On Thu, May 10, 2018 at 4:31 AM, Marek Szyprowski > wrote: >> 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. Right. From DMA engine API perspective this is the only valid way to read the residue when you terminate the transfer. > It checks for the capabilities > > cmd_pause > cmd_terminate > residue_granularity != DMA_RESIDUE_GRANULARITY_DESCRIPTOR Checking for cmd_pause is a bit too strict, because cmd_pause means 'driver supports both pause and resume', but the serial driver doesn't use resume at all. A check for residue_granularity != DMA_RESIDUE_GRANULARITY_DESCRIPTOR is on the other hand a bit too loose. > 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 assume that this requirement is for both - resuming and terminating. >>> 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? Like I already said, console is not a proper use case for serial dma. The more appropriate is bluetooth and still, I'm not aware of the issue with the current code. > 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. Okay, so you don't have any evidence that DMA transfers done in single reads/writes is broken with the current cmd_pause implementation. This revert in fact at best disables DMA mode in the serial drivers (or in worse case, i.e. Exynos, causes current drivers to do trashed transfers due to lack of checking for the needed dma engine capabilities). Maybe instead of reverting support for it, there should be a check for BURST vs. SINGLE mode and we would keep the current implementation for SINGLE transfers? Vinod, could you comment a bit this discussion from the DMA engine maintainer perspective? Best regards -- Marek Szyprowski, PhD Samsung R&D Institute Poland