Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp526686imm; Tue, 15 May 2018 05:26:02 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp04klmlcnmbNgnnjKgJkz80gtOc2V2wsOtrLcSJRY1hrcP3u7ugsCvKnTP06GJB4rtNGJZ X-Received: by 2002:a63:bd09:: with SMTP id a9-v6mr11996100pgf.250.1526387162878; Tue, 15 May 2018 05:26:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526387162; cv=none; d=google.com; s=arc-20160816; b=SB5HHWf1nbZ5utmsqQ7q4pmYDB8ACX1qKgFP2yjGj9pEZ0pxpFihnNuwSH88MONYd8 UG0oO6uJ92b+YDjW8leVH+gul5ctpKwUBG709Z1y+QiaGDZJmQPYT9wnUrsUWstXuarT /ZHC967dMpNp9BrGgyf9MFsgu8K910CPJYNii9nh5o4QVDAN4+nzlvFtdUGtJX455s9S kcI1KNndjogljv6BXVaw2uF6Cjqa3eAMthP20DhsLuKc3cMXIefTozo+wjEd8DJsZz6h dk1FKH1W6VDytoo9Lj0GXu0ET8b0Qwjzq/hKQFZa1trGEAyT9U/zAS95aa4pnfGDUQq9 Juzw== 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=IYoyWF92ktoY1uCL1nmuyZcprRT5cQ07nkOYNEandLY=; b=EUParv76mkua6iyXBhMdxxA7iPo+nT/wZ8UX8bi0XybmP9JeYwDhnZ84cgtTxVnkah z72FkkibZgIEiUhRMdopONQwtKjchSWWmxGoftVqLC0HqJkMq2FFIWhgncNHQSUe1r86 vYCCp2wqROUyXXTgMoQAKBXbtrjkeQuNttkGm6+QwRlJENgjed8HQ4JGVz0C9o2JkNHx jqbLzx9bOtfKNm3VKVBRR94l7us3+crPRnEbH1TjDxSuM+05XhETA7zKs8chf68K8JjX FtebdDac/4Zm5CEJYHwigQfW2m11tXwgdAkFngFOuTL6Mrr2zqlT4KDzVkTFDfhkgZzI l2kQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=FI+FxDtI; 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 j5-v6si5251891pgs.281.2018.05.15.05.25.39; Tue, 15 May 2018 05:26:02 -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=FI+FxDtI; 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 S1753277AbeEOMYo (ORCPT + 99 others); Tue, 15 May 2018 08:24:44 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:49600 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753169AbeEOMYk (ORCPT ); Tue, 15 May 2018 08:24:40 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20180515122438euoutp01f8310a6c00c6d590df00d40a259aaa77~u0PXrLWNb0056300563euoutp017 for ; Tue, 15 May 2018 12:24:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20180515122438euoutp01f8310a6c00c6d590df00d40a259aaa77~u0PXrLWNb0056300563euoutp017 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1526387078; bh=IYoyWF92ktoY1uCL1nmuyZcprRT5cQ07nkOYNEandLY=; h=Subject:To:Cc:From:Date:In-Reply-To:References:From; b=FI+FxDtIpaH/x+F50qDS9Vt901q14TJjWRtycUj50uD915b7zetZz8jWB3rSP02oz lJQl9rELIYXwf2JhXjJ2aGGLj1SVU7JT0QdabnazB88RkL9eLnSZmlThcK0HsNt4IQ Yf0MoXEmMYI4H2/EOj45fPFfhYH1uI0omg6eCrX8= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20180515122434eucas1p2d30d9638bfa76f0637a1a65e97438793~u0PURhSOY0350703507eucas1p2z; Tue, 15 May 2018 12:24:34 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 91.E4.10409.181DAFA5; Tue, 15 May 2018 13:24:33 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20180515122431eucas1p13d52747049f0d72ffc8e072f5f4b8759~u0PRXahqD2738727387eucas1p1t; Tue, 15 May 2018 12:24:31 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20180515122430eusmtrp1809b15529c50c1d80d8e78e862fd81cb~u0PQTCqRX1095410954eusmtrp1b; Tue, 15 May 2018 12:24:30 +0000 (GMT) X-AuditID: cbfec7f5-b45ff700000028a9-d6-5afad1812a5e Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id CB.8A.04183.E71DAFA5; Tue, 15 May 2018 13:24:30 +0100 (BST) Received: from [106.116.147.30] (unknown [106.116.147.30]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20180515122429eusmtip2981deae10d119ae010c4264ff8593550~u0PP3dWUs1953519535eusmtip2j; Tue, 15 May 2018 12:24:29 +0000 (GMT) Subject: Re: Revert "dmaengine: pl330: add DMA_PAUSE feature" To: Vinod Cc: Frank Mori Hess , 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: Date: Tue, 15 May 2018 14:24:28 +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: <20180515062144.GC13271@vkoul-mobl> Content-Transfer-Encoding: 7bit Content-Language: en-US X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrJKsWRmVeSWpSXmKPExsWy7djP87qNF39FGZw9ImKxccZ6VovpUy8w Wqye+pfVYv7juWwW589vYLe4vGsOm8WM8/uYLO7++8RosfPOCWYHTo+ds+6yexzZeYzNY/Ge l0wem1Z1snn0bVnF6PF5k1wAWxSXTUpqTmZZapG+XQJXxt/2K+wF9x0r3t/4yN7A+Mqki5GT Q0LARKJj3nGmLkYuDiGBFYwSh49eh3K+MEpMOH2EDcL5zCixcE8fI0zLlo2zoKqWM0o0Ll8E VfWeUWJHzxNWkCphAVuJ9i2ngBIcHCICMhLn9kWD1DAL7GWSOHjtFTNIDZuAoUTX2y6wGl4B O4l9DzhAwiwCqhKd+2cygdiiAjES0+ZdB7N5BQQlTs58wgJicwoYSFy9spQNxGYWkJfY/nYO M4QtLnHryXyw4yQEzrFLzN5+mRXiaheJ+28OsUPYwhKvjm+BsmUkTk/uYYGw6yX6vh+Bau5h lNjbMpUJImEtcfj4RVaQQ5kFNCXW79KHCNtKXN7ZxQwSlhDgk7jxVhDiBj6JSdumQ4V5JTra hCCq1SRmHV8Ht/XghUvMExiVZyH5bBaSb2Yh+WYWwt4F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k14cKUmeXn/y91 fRu949U6x2NbN+mbfJpy6+vc3Tv3V217qjl51x/3Yy8vbFyw0vfzpritv9rmzH21/Uyj4901 Ww8qlGyc/aXSdl/ih0Z5l9B/HXY2mmH3Hjv4tq385/dQtKrm42u18l79OyortjS+0vhUW79i 0Y41G40bMkuTt2uw3nvSHbhSiaU4I9FQi7moOBEAAtuwOd8CAAA= X-CMS-MailID: 20180515122431eucas1p13d52747049f0d72ffc8e072f5f4b8759 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-MTR: 20180515122431eucas1p13d52747049f0d72ffc8e072f5f4b8759 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> <06f54061-c537-b399-e493-ec2cdf4def5d@samsung.com> <20180515062144.GC13271@vkoul-mobl> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Vinod, On 2018-05-15 08:21, Vinod wrote: > On 11-05-18, 14:57, Marek Szyprowski wrote: >> 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. > Not really, API allows you to read any point of time, you may support it or not > is different matter. Granularity of reporting is also a different point. I mean to read the residue in stable conditions (the incoming bytes has been either read by dma or still sits in the uart fifo). Too bad that it is not possible to read residue after terminating the transfer. This would remove the need for this fake pause support. >>> 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. > thats true and it was added for audio which does pause/resume. If you feel it > helps in serial to get pause & resume capabilities independently we can split > them up, feel free to send a patch Okay, I will prepare a patch for this. > For Pause/resume data loss is _not_ expected. > >>> 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. > Terminate is abort, data loss may happen here. Okay. Then it is up to the drivers to rely on this or not. >>>>> 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. > Why do you say serial is not important? I mean that using DMA engine for uart/serial device for implementing only a console support is a bit pointless, because typically console doesn't transfer much data and overhead of using DMA mode (setting up dma engine) is bigger than doing all the transfers in PIO mode. >>> 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? > So I will try to summarise here: > > - Pause/resume does not expect data loss > - Status can be queried any point of time > - Granularity reporting is upto device > - To support a use case and device limitations it is okay to support only > singles. What about the revert this thread is about? I would really like to have some evidence of broken data in single transfer modes before removing functionality that was present for years. The discussed use case (pause+terminate) is crucial for serial devices at least on Samsung SoCs and this revert break them. Quick grep shows that PL330 is being used by a few other SoC families too, but I didn't check if any of them use it for serial device. Best regards -- Marek Szyprowski, PhD Samsung R&D Institute Poland