From patchwork Mon Jul 2 13:08:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 140751 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp3978169ljj; Mon, 2 Jul 2018 06:08:32 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKx5Cffr4usDSmaGY78RogJXL2+mAGK/XTyc0+7vAy1Nqw9jAtan4oSHFnIUc+OmMBVtdf+ X-Received: by 2002:a17:902:ab95:: with SMTP id f21-v6mr25287381plr.264.1530536911954; Mon, 02 Jul 2018 06:08:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530536911; cv=none; d=google.com; s=arc-20160816; b=b9+JKJAzyDi8E1p4Lqp1KOj2y/iIZkWoBWCN3O6vhnbtDaIxskO6kU5Fz6McJ0BAA0 zocrFqAf8IdpiMhOJ+XmZjbVfpz3u+KQrbXXh2UGqJqM2u3YFBG7YvIGHSXjgltsZwBT LAaO3LZM45Ubw/0muH+b3JVWLm+zQXQI9ICAAW0SGPIem8UMnraZLe10wV7rhGcLz5Wm zCM1uLR43hS1ymLCOsERlnzwMj5VbLBc4BXzPkuyaVoqJL6ukCTuh2Ccj9IFoquKNSug vV+RoFZGFYb2RsKSemshf/v181Ec8POmxADvQUNeoRzdEiD+RNebYth+lihdanfQVjrF tLuQ== 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:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=dH2gO8NhFHBOhSm1w0/dHc5QyFNV3eBy3xi5kax64gM=; b=X5PxuRpo3iiz9+6dDAGyX5tbhWbOpkyHYzEkH9K3WA3Y79L4CEFFTPbBG4MjJubD/w Cmf6WycyfY4057Cq3Gxkqec+MVdEZnYLHxnpSxHMjalIhQ+JE0YuVcngruXJhvoSlWUA eVQrZIDWoOsl4xNo/lQzfaXt97nc7x7Y2lFQTdnZY1umYtEwlw/RIacyh3ALkhOL5MpN CBFMSobOiIsuJZtB23mQo5jI093mZ5xqQqnN36jGloBKsChZNVTL9KG+c4dX3hQMedHo zc967nf6TjqP6saKEa7EhNEIYZG42Ize/lVcAi3iY4pL1NHZDxelqLrKHg85wlzAue/R jGrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=e0pRkbue; 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 g38-v6si4270272pgg.363.2018.07.02.06.08.29; Mon, 02 Jul 2018 06:08:31 -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=e0pRkbue; 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 S1752235AbeGBNI2 (ORCPT + 31 others); Mon, 2 Jul 2018 09:08:28 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:56229 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751544AbeGBNIX (ORCPT ); Mon, 2 Jul 2018 09:08:23 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20180702130821euoutp0138c3a5ddc0161a89612c5153061399d6~9jzQBHYmB2481724817euoutp01x for ; Mon, 2 Jul 2018 13:08:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20180702130821euoutp0138c3a5ddc0161a89612c5153061399d6~9jzQBHYmB2481724817euoutp01x DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1530536901; bh=dH2gO8NhFHBOhSm1w0/dHc5QyFNV3eBy3xi5kax64gM=; h=From:To:Cc:Subject:Date:References:From; b=e0pRkbueESiJl5QCZRjKULPNVnAe+w77UVrDBvGtg9sjVzHEBjNkjxwUR7SzvQ2D5 JxDw6KjoZ4FsJu7GvzRmmPRjZYgzFANQCgGNZy1Bw54T/xR7EAI8yANzu1hEjMYtML kSfHmXZ8LDwgX6ora9O/lhiLZZwvGQxsljIcFECU= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20180702130820eucas1p2f5eed38296df902da13618ab8d612bcc~9jzOds-UD1641816418eucas1p2K; Mon, 2 Jul 2018 13:08:20 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 8D.A7.05700.3C32A3B5; Mon, 2 Jul 2018 14:08:19 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20180702130819eucas1p2e11d8fabec93ba78d9e84f4ca6e5fd65~9jzNWZMqQ1216712167eucas1p27; Mon, 2 Jul 2018 13:08:19 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20180702130818eusmtrp2d2156079f358e2725be26a8fafc3b73f~9jzNGMM6R1434414344eusmtrp2V; Mon, 2 Jul 2018 13:08:18 +0000 (GMT) X-AuditID: cbfec7f2-1c1ff70000011644-26-5b3a23c370c4 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 6C.14.04178.2C32A3B5; Mon, 2 Jul 2018 14:08:18 +0100 (BST) Received: from AMDC2765.digital.local (unknown [106.116.147.25]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20180702130818eusmtip1c83027ab3e481782ddf1359e4258c515~9jzMr3HVY1214012140eusmtip1Q; Mon, 2 Jul 2018 13:08:18 +0000 (GMT) From: Marek Szyprowski To: dmaengine@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Cc: Marek Szyprowski , Vinod Koul , Dan Williams , Lars-Peter Clausen , Mark Brown , Bartlomiej Zolnierkiewicz Subject: [PATCH] dma: add support for reporting pause and resume separately Date: Mon, 2 Jul 2018 15:08:10 +0200 X-Mailer: git-send-email 2.17.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrPIsWRmVeSWpSXmKPExsWy7djPc7qHla2iDT49s7C4cvEQk8XGGetZ LaY+fMJmMX3qBUaL1VP/slosmTyf1eLyrjlsFmuP3GW32HnnBLMDp8eGz01sHov3vGTy2LSq k81jyZtDrB59W1YxenzeJBfAFsVlk5Kak1mWWqRvl8CVMXPdNvaCPvmKox0X2RoY26S6GDk5 JARMJN62L2PtYuTiEBJYwShxdOpOFgjnC6NEV+M2dgjnM6PErd8r2GBafm6eDlW1nFHi5LQT bBDOV0aJXfvWMYNUsQkYSnS97QLrEBGIkpi5+ihYB7PAL0aJC8tuARVxcAgLeEvsbJQGqWER UJV4PrGbCWKDvMTqDQeYQeolBF6zSZxY1Qs2lFegTOJx/1tmiCIXiZYrrawQtrDEq+Nb2CFs GYn/O+czQTQ3M0q0z5jFDuH0MEpsnbMD6glricPHL7KCXMEsoCmxfpc+RNhRYtLFQ+wgYQkB PokbbwVBwsxA5qRt05khwrwSHW1CENVqErOOr4Nbe/DCJajTPCROXH3CAmILCcRKrJ97jGUC o9wshF0LGBlXMYqnlhbnpqcWG+allusVJ+YWl+al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yc+/3s7Zbp9jdv5/fkWusXbxWb+PfhFbEJmhfziLTXNfyfckfGObmUotox2EDuT6O/0T3TN BiWW4oxEQy3mouJEALnZuYhmAgAA Message-Id: <20180702130819eucas1p2e11d8fabec93ba78d9e84f4ca6e5fd65~9jzNWZMqQ1216712167eucas1p27@eucas1p2.samsung.com> X-CMS-MailID: 20180702130819eucas1p2e11d8fabec93ba78d9e84f4ca6e5fd65 X-Msg-Generator: CA X-RootMTR: 20180702130819eucas1p2e11d8fabec93ba78d9e84f4ca6e5fd65 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180702130819eucas1p2e11d8fabec93ba78d9e84f4ca6e5fd65 References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 'cmd_pause' DMA channel capability means that respective DMA engine supports both pausing and resuming given DMA channel. However, in some cases it is important to know if DMA channel can be paused without the need to resume it. This is a typical requirement for proper residue reading on transfer timeout in UART drivers. There are also some DMA engines with limited hardware, which doesn't really support resuming. Reporting pause and resume capabilities separately allows UART drivers to properly check for the really required capabilities and operate in DMA mode also in systems with limited DMA hardware. On the other hand drivers, which rely on full channel suspend/resume support, should now check for both 'pause' and 'resume' features. Existing clients of dma_get_slave_caps() have been checked and the only driver which rely on proper channel resuming is soc-generic-dmaengine-pcm driver, which has been updated to check the newly added capability. Existing 'cmd_pause' now only indicates that DMA engine support pausing given DMA channel. Signed-off-by: Marek Szyprowski --- This patch is a follow-up of the Vinod's advise from the following discussion: https://www.spinics.net/lists/linux-samsung-soc/msg63166.html --- drivers/dma/dmaengine.c | 8 ++------ include/linux/dmaengine.h | 5 ++++- sound/soc/soc-generic-dmaengine-pcm.c | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) -- 2.17.1 Acked-by: Mark Brown diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c index 08ba8473a284..84ac38dbdb65 100644 --- a/drivers/dma/dmaengine.c +++ b/drivers/dma/dmaengine.c @@ -500,12 +500,8 @@ int dma_get_slave_caps(struct dma_chan *chan, struct dma_slave_caps *caps) caps->max_burst = device->max_burst; caps->residue_granularity = device->residue_granularity; caps->descriptor_reuse = device->descriptor_reuse; - - /* - * Some devices implement only pause (e.g. to get residuum) but no - * resume. However cmd_pause is advertised as pause AND resume. - */ - caps->cmd_pause = !!(device->device_pause && device->device_resume); + caps->cmd_pause = !!device->device_pause; + caps->cmd_resume = !!device->device_resume; caps->cmd_terminate = !!device->device_terminate_all; return 0; diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h index 861be5cab1df..c8c3a7a93802 100644 --- a/include/linux/dmaengine.h +++ b/include/linux/dmaengine.h @@ -415,7 +415,9 @@ enum dma_residue_granularity { * each type, the dma controller should set BIT() and same * should be checked by controller as well * @max_burst: max burst capability per-transfer - * @cmd_pause: true, if pause and thereby resume is supported + * @cmd_pause: true, if pause is supported (i.e. for reading residue or + * for resume later) + * @cmd_resume: true, if resume is supported * @cmd_terminate: true, if terminate cmd is supported * @residue_granularity: granularity of the reported transfer residue * @descriptor_reuse: if a descriptor can be reused by client and @@ -427,6 +429,7 @@ struct dma_slave_caps { u32 directions; u32 max_burst; bool cmd_pause; + bool cmd_resume; bool cmd_terminate; enum dma_residue_granularity residue_granularity; bool descriptor_reuse; diff --git a/sound/soc/soc-generic-dmaengine-pcm.c b/sound/soc/soc-generic-dmaengine-pcm.c index 56a541b9ff9e..76c46d793843 100644 --- a/sound/soc/soc-generic-dmaengine-pcm.c +++ b/sound/soc/soc-generic-dmaengine-pcm.c @@ -156,7 +156,7 @@ static int dmaengine_pcm_set_runtime_hwparams(struct snd_pcm_substream *substrea ret = dma_get_slave_caps(chan, &dma_caps); if (ret == 0) { - if (dma_caps.cmd_pause) + if (dma_caps.cmd_pause && dma_caps.cmd_resume) hw.info |= SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME; if (dma_caps.residue_granularity <= DMA_RESIDUE_GRANULARITY_SEGMENT) hw.info |= SNDRV_PCM_INFO_BATCH;