Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2520787ybl; Mon, 20 Jan 2020 04:34:55 -0800 (PST) X-Google-Smtp-Source: APXvYqwsN2PtQZ1u8S6YbkWsulkYB2/4LmknarsmFJOgGflZfdgbmz0V1JzyskBcAanLYXrv0aQp X-Received: by 2002:a9d:6859:: with SMTP id c25mr16044823oto.205.1579523695609; Mon, 20 Jan 2020 04:34:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579523695; cv=none; d=google.com; s=arc-20160816; b=ptfvMa+H6Wiuqrcn2o9SKCtwfK3b4GmdZ45aFoEW3IGzpViii2QHhB0iLMrW9ElQSE wNcRz5PdZDAbMdo+LyyFhXy9wM4tHlKaRHAN2YX2HZhn8I+E6bTkTZG/SRWMmpAlJw4D n7N9F1KsIqOSf+B/g9PXZQvH3OvkXR5YSxl0Stug809/3/5GnqMpp8m+nvJnKU7/EEMu gnyIEhD/tLRojwi9wQMwqvoszfr/PyxJHhFQpKalLhfUxB9PukVl014xTRvPTByXQzUN zh+VpJyJH/bajIcOYVtqZKkz+0bujG3lIZDtJE0XEnkR7yDCvU5LGuOcBLTPMeoJCKuN gtXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=vsyjDKU49jq+q0HeyiljDQyi4P4mh1ockYj+nEfJXo8=; b=rEDUq38GEoh+bxVTFtzyqA69JeHRduogHgBoMPh3UNI/lg2Qrm/SWdaxVTV0hzQOYt u/LkmyFi67G/5HzyoDCYkogifJ+XfmgxnJUBl0ISBDwT0AcLv7lQTYGNmiKUMaMDNsYe hoB6QhdoGveQOoh1MLOMRaPpDWFFcxitT7edoV8BrSoCRUUEfFgZsMBEKQD3amxzdy6C FoO2UtGstZ07FC0CnY6qvHcQr9P21R4gJTK0ViRvlEqSfD7VdGLnqNQnZ/2CsDcpL9i4 mtUFinSPyxz7ZrEszR6TTTAAvoJdo+5PfkWyv5MRnxV2bZJl23lNqs0pHVXxxkVDeoQa Bc1w== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d17si17829706oib.174.2020.01.20.04.34.44; Mon, 20 Jan 2020 04:34:55 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728783AbgATMdr (ORCPT + 99 others); Mon, 20 Jan 2020 07:33:47 -0500 Received: from olimex.com ([184.105.72.32]:45159 "EHLO olimex.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726589AbgATMdq (ORCPT ); Mon, 20 Jan 2020 07:33:46 -0500 Received: from localhost.localdomain ([94.155.250.134]) by olimex.com with ESMTPSA (ECDHE-RSA-AES128-GCM-SHA256:TLSv1.2:Kx=ECDH:Au=RSA:Enc=AESGCM(128):Mac=AEAD) (SMTP-AUTH username stefan@olimex.com, mechanism PLAIN) for ; Mon, 20 Jan 2020 04:33:42 -0800 From: Stefan Mavrodiev To: Dan Williams , Vinod Koul , Maxime Ripard , Chen-Yu Tsai , David Airlie , Daniel Vetter , linux-kernel@vger.kernel.org (open list), dmaengine@vger.kernel.org (open list:DMA GENERIC OFFLOAD ENGINE SUBSYSTEM), linux-arm-kernel@lists.infradead.org (moderated list:ARM/Allwinner sunXi SoC support), dri-devel@lists.freedesktop.org (open list:DRM DRIVERS FOR ALLWINNER A10) Cc: linux-sunxi@googlegroups.com, Stefan Mavrodiev Subject: [PATCH v2 1/2] dmaengine: sun4i: Add support for cyclic requests with dedicated DMA Date: Mon, 20 Jan 2020 14:33:25 +0200 Message-Id: <20200120123326.30743-2-stefan@olimex.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200120123326.30743-1-stefan@olimex.com> References: <20200120123326.30743-1-stefan@olimex.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently the cyclic transfers can be used only with normal DMAs. They can be used by pcm_dmaengine module, which is required for implementing sound with sun4i-hdmi encoder. This is so because the controller can accept audio only from a dedicated DMA. This patch enables them, following the existing style for the scatter/gather type transfers. Signed-off-by: Stefan Mavrodiev --- Changes for v2: - None drivers/dma/sun4i-dma.c | 45 ++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/drivers/dma/sun4i-dma.c b/drivers/dma/sun4i-dma.c index e397a50058c8..7b41815d86fb 100644 --- a/drivers/dma/sun4i-dma.c +++ b/drivers/dma/sun4i-dma.c @@ -669,43 +669,41 @@ sun4i_dma_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t buf, size_t len, dma_addr_t src, dest; u32 endpoints; int nr_periods, offset, plength, i; + u8 ram_type, io_mode, linear_mode; if (!is_slave_direction(dir)) { dev_err(chan2dev(chan), "Invalid DMA direction\n"); return NULL; } - if (vchan->is_dedicated) { - /* - * As we are using this just for audio data, we need to use - * normal DMA. There is nothing stopping us from supporting - * dedicated DMA here as well, so if a client comes up and - * requires it, it will be simple to implement it. - */ - dev_err(chan2dev(chan), - "Cyclic transfers are only supported on Normal DMA\n"); - return NULL; - } - contract = generate_dma_contract(); if (!contract) return NULL; contract->is_cyclic = 1; - /* Figure out the endpoints and the address we need */ + if (vchan->is_dedicated) { + io_mode = SUN4I_DDMA_ADDR_MODE_IO; + linear_mode = SUN4I_DDMA_ADDR_MODE_LINEAR; + ram_type = SUN4I_DDMA_DRQ_TYPE_SDRAM; + } else { + io_mode = SUN4I_NDMA_ADDR_MODE_IO; + linear_mode = SUN4I_NDMA_ADDR_MODE_LINEAR; + ram_type = SUN4I_NDMA_DRQ_TYPE_SDRAM; + } + if (dir == DMA_MEM_TO_DEV) { src = buf; dest = sconfig->dst_addr; - endpoints = SUN4I_DMA_CFG_SRC_DRQ_TYPE(SUN4I_NDMA_DRQ_TYPE_SDRAM) | - SUN4I_DMA_CFG_DST_DRQ_TYPE(vchan->endpoint) | - SUN4I_DMA_CFG_DST_ADDR_MODE(SUN4I_NDMA_ADDR_MODE_IO); + endpoints = SUN4I_DMA_CFG_DST_DRQ_TYPE(vchan->endpoint) | + SUN4I_DMA_CFG_DST_ADDR_MODE(io_mode) | + SUN4I_DMA_CFG_SRC_DRQ_TYPE(ram_type); } else { src = sconfig->src_addr; dest = buf; - endpoints = SUN4I_DMA_CFG_SRC_DRQ_TYPE(vchan->endpoint) | - SUN4I_DMA_CFG_SRC_ADDR_MODE(SUN4I_NDMA_ADDR_MODE_IO) | - SUN4I_DMA_CFG_DST_DRQ_TYPE(SUN4I_NDMA_DRQ_TYPE_SDRAM); + endpoints = SUN4I_DMA_CFG_DST_DRQ_TYPE(ram_type) | + SUN4I_DMA_CFG_SRC_DRQ_TYPE(vchan->endpoint) | + SUN4I_DMA_CFG_SRC_ADDR_MODE(io_mode); } /* @@ -747,8 +745,13 @@ sun4i_dma_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t buf, size_t len, dest = buf + offset; /* Make the promise */ - promise = generate_ndma_promise(chan, src, dest, - plength, sconfig, dir); + if (vchan->is_dedicated) + promise = generate_ddma_promise(chan, src, dest, + plength, sconfig); + else + promise = generate_ndma_promise(chan, src, dest, + plength, sconfig, dir); + if (!promise) { /* TODO: should we free everything? */ return NULL; -- 2.17.1