Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp990691imu; Tue, 20 Nov 2018 09:53:35 -0800 (PST) X-Google-Smtp-Source: AFSGD/XMA1m9Odj2TVpXzhxq91NNNhqltNellbYGf9vFk02CxlD7SiME2xia1+hwMU1xPIBygbTt X-Received: by 2002:a63:a84a:: with SMTP id i10mr2815638pgp.263.1542736415675; Tue, 20 Nov 2018 09:53:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542736415; cv=none; d=google.com; s=arc-20160816; b=Ulu/SJOxG0/4fZmaPbNUI0/SQxGPTUSIwi44j9ZEE6YdfFvXbugAWYEvBnmYWhB7Jo NaCzm2+q0lVO4/QCRh0m6jofyxsPYN59VsMvz7rGSpfUKNgizrbwpr7zw/4CO7KTRtZg K4gGrJv9sLij+BT1xeQ9pV9FxVQy8k59D4nivjk8HYKRy6zZRR9k03g/diV894c1sofs j/vwVOVTDRdF0ogl5JJsxITc57wxgJh0uPDDY4US59LSs7V/UOL5Cy3SOxfKFycO1SVl KHRIxzzyvTsFhc+Z8a4PT376tuDN7gv3j/TroURf0OnR/CfxxzlZMKfpZ/XcLr4oOJ7r NosQ== 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:dkim-signature; bh=E4uDeGcHjS28m8Y3GVEAHI2k3FFYlV0squiBOxB4Zjo=; b=TjfRTDQlI0n+iAb+8ic17r215n1mRUKr/H3/AEHy9TvwHFbJST0nsA9kO7zTXl+skb VetS8WtNNWExca1FGwWcvEITn9ByZDSSugH6Qf8ohMLm17c4mCSwmhitAR+pezgd+sKi AxoipXCoy12iRCII5e6ifmVBGjmWAw1IgPDNRscf1bZkDTOzyGepnGY2LjBNxtYKFGDt isZpxAWZdHeddtW7Z+eitqcWEP/bX4PBWD3xcXfOshWg6jSgesylyFmzXDsEGk168LdW ELztK1CCNsMoItgxk5DeSnFwvIsWsW/gh7WeLPXSlN0e88eGIxETSVyVXyKiNZekZWg6 RE3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=AsPYakNh; 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 v3si43831665pgh.305.2018.11.20.09.53.09; Tue, 20 Nov 2018 09:53:35 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=AsPYakNh; 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 S1730114AbeKUCCF (ORCPT + 99 others); Tue, 20 Nov 2018 21:02:05 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:41273 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725898AbeKUCBr (ORCPT ); Tue, 20 Nov 2018 21:01:47 -0500 Received: by mail-wr1-f68.google.com with SMTP id x10so2421587wrs.8; Tue, 20 Nov 2018 07:32:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=E4uDeGcHjS28m8Y3GVEAHI2k3FFYlV0squiBOxB4Zjo=; b=AsPYakNhleTtSFGYfr0/v67a68rWA3Vc+aszgL11cX7RURvBlC98QyB8M1ZBql69ik 6DgOp7SOUXSIuk5DvA4XP1IlogC4PgiJ8kL7alI9ZDayEMSIYGDfXfa2ASQJg8B2QLEs tBUIft3AYZo/BsVa3qXT1BeETsqUgQEJ4HZk/7sMWfihPBlQ9ul3q10wnOJlO+INh3S8 xc5zG/xV2WyOTkhXw+XMzo6HoA26hkLey40WbqQboha0ohsbYvSLuW4XYR0XmGfs5R9d RNK7Q0hGwb+vkC4IMUQi8x8sDc2AxmalHNk3N9lod/QaDIxBuzaVwod2ASQloeyGZq+0 Mu0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=E4uDeGcHjS28m8Y3GVEAHI2k3FFYlV0squiBOxB4Zjo=; b=EaJOWQFcXDQjkWxwRqjC2UNBu1vmqNRjkaayg32xdU/7x18Wnxhfpc6P0xhMhiXlOq XX0s+XD1+i/JST2tCweaELrVkoFEVwEZ/pgNxB7ROLhX1sDkB0m4T5e/0GKTR3680uFc qbZZ2kPu7EMoDpDC1jq2ffSiBVpxUMo3xuXGhek4GV9qMEtP+hcH4flON2mZDzFUOX6x +PgtJUlUEY3Gio4xkzlb8XmAPUfrPBWY4vFImnnohqpoIA0mwgtO0qzhKwj3Ccr9Dfqd 4MnErG9sPR5bN/P4myZsWIdCt8WfPFtX278og39KOEYYwzXO0cEXEEr8FfRhNSRO2qhf 1j3g== X-Gm-Message-State: AA+aEWYCRAgs/JENWsfCGIxC8AltfGo5rgzCdTH7IWjh0eGwlqXV7W+9 ZysjT8upRC4GzCb8N7JC1FrUiGN8/ro= X-Received: by 2002:a5d:66c1:: with SMTP id k1mr2354209wrw.132.1542727924627; Tue, 20 Nov 2018 07:32:04 -0800 (PST) Received: from NewMoon.iit.local ([90.147.180.254]) by smtp.gmail.com with ESMTPSA id k73sm14677464wmd.36.2018.11.20.07.32.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Nov 2018 07:32:04 -0800 (PST) From: Andrea Merello To: vkoul@kernel.org, dan.j.williams@intel.com, michal.simek@xilinx.com, appana.durga.rao@xilinx.com, dmaengine@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, robh+dt@kernel.org, mark.rutland@arm.com, devicetree@vger.kernel.org, radhey.shyam.pandey@xilinx.com, Andrea Merello Subject: [PATCH v6 5/7] dmaengine: xilinx_dma: autodetect whether the HW supports scatter-gather Date: Tue, 20 Nov 2018 16:31:49 +0100 Message-Id: <20181120153151.18024-5-andrea.merello@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181120153151.18024-1-andrea.merello@gmail.com> References: <20181120153151.18024-1-andrea.merello@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The AXIDMA and CDMA HW can be either direct-access or scatter-gather version. These are SW incompatible. The driver can handle both versions: a DT property was used to tell the driver whether to assume the HW is in scatter-gather mode. This patch makes the driver to autodetect this information. The DT property is not required anymore. No changes for VDMA. Cc: Rob Herring Cc: Mark Rutland Cc: devicetree@vger.kernel.org Cc: Radhey Shyam Pandey Signed-off-by: Andrea Merello Reviewed-by: Radhey Shyam Pandey --- Changes in v2: - autodetect only in !VDMA case Changes in v3: - cc DT maintainers/ML Changes in v4: - fix typos in commit message Changes in v5: None Changes in v6: None --- drivers/dma/xilinx/xilinx_dma.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/dma/xilinx/xilinx_dma.c b/drivers/dma/xilinx/xilinx_dma.c index 0716db61f1d0..41bd8caca09e 100644 --- a/drivers/dma/xilinx/xilinx_dma.c +++ b/drivers/dma/xilinx/xilinx_dma.c @@ -86,6 +86,7 @@ #define XILINX_DMA_DMASR_DMA_DEC_ERR BIT(6) #define XILINX_DMA_DMASR_DMA_SLAVE_ERR BIT(5) #define XILINX_DMA_DMASR_DMA_INT_ERR BIT(4) +#define XILINX_DMA_DMASR_SG_MASK BIT(3) #define XILINX_DMA_DMASR_IDLE BIT(1) #define XILINX_DMA_DMASR_HALTED BIT(0) #define XILINX_DMA_DMASR_DELAY_MASK GENMASK(31, 24) @@ -412,7 +413,6 @@ struct xilinx_dma_config { * @dev: Device Structure * @common: DMA device structure * @chan: Driver specific DMA channel - * @has_sg: Specifies whether Scatter-Gather is present or not * @mcdma: Specifies whether Multi-Channel is present or not * @flush_on_fsync: Flush on frame sync * @ext_addr: Indicates 64 bit addressing is supported by dma device @@ -432,7 +432,6 @@ struct xilinx_dma_device { struct device *dev; struct dma_device common; struct xilinx_dma_chan *chan[XILINX_DMA_MAX_CHANS_PER_DEVICE]; - bool has_sg; bool mcdma; u32 flush_on_fsync; bool ext_addr; @@ -2417,7 +2416,6 @@ static int xilinx_dma_chan_probe(struct xilinx_dma_device *xdev, chan->dev = xdev->dev; chan->xdev = xdev; - chan->has_sg = xdev->has_sg; chan->desc_pendingcount = 0x0; chan->ext_addr = xdev->ext_addr; /* This variable ensures that descriptors are not @@ -2517,6 +2515,15 @@ static int xilinx_dma_chan_probe(struct xilinx_dma_device *xdev, chan->stop_transfer = xilinx_dma_stop_transfer; } + /* check if SG is enabled (only for AXIDMA and CDMA) */ + if (xdev->dma_config->dmatype != XDMA_TYPE_VDMA) { + if (dma_ctrl_read(chan, XILINX_DMA_REG_DMASR) & + XILINX_DMA_DMASR_SG_MASK) + chan->has_sg = true; + dev_dbg(chan->dev, "ch %d: SG %s\n", chan->id, + chan->has_sg ? "enabled" : "disabled"); + } + /* Initialize the tasklet */ tasklet_init(&chan->tasklet, xilinx_dma_do_tasklet, (unsigned long)chan); @@ -2655,7 +2662,6 @@ static int xilinx_dma_probe(struct platform_device *pdev) return PTR_ERR(xdev->regs); /* Retrieve the DMA engine properties from the device tree */ - xdev->has_sg = of_property_read_bool(node, "xlnx,include-sg"); xdev->max_buffer_len = GENMASK(XILINX_DMA_MAX_TRANS_LEN_MAX - 1, 0); if (xdev->dma_config->dmatype == XDMA_TYPE_AXIDMA) { -- 2.17.1