From patchwork Mon Jun 25 09:27:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Merello X-Patchwork-Id: 10485363 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CCC6E603B5 for ; Mon, 25 Jun 2018 09:30:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C1B6D28930 for ; Mon, 25 Jun 2018 09:30:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B45532894D; Mon, 25 Jun 2018 09:30:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4433328930 for ; Mon, 25 Jun 2018 09:30:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=qoj5w/k35RgbEYC9NUxQKVcFECfuee+EmfsE0+aWMQc=; b=nofjdKLLUZBTc/Euw/WWxAwjBH gIczE46vfaGOaNK2ivmZMa1KnpQbfzyFixmZuj8jXkajaOMnJftD90s5ENynS92YYmZezVShsxAQq j1UVLblZzBPBSwfFabaPU3Z4kpGz6oOn7QhnDsk3Xg4zZZiuxTbnZwvuRCd5OZgwNWbjkwWnWXPAC V8LfVupt+ZQDVA45XdlC4rqrn0CocwwOplhNHZgKGBZ5YwVsca2L8BHIz0TgPTSNI+cpsQDj4EUvK o+20dzJoxaVxFZMRB8Z4gP4Aka87BF8xlV5K8fZubLdQvX40F7tmq9sXgcUxFHP2NOu7gHyZjw5Zj 69E8sgkQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fXNpJ-00042e-KK; Mon, 25 Jun 2018 09:30:25 +0000 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fXNmz-00026A-62 for linux-arm-kernel@lists.infradead.org; Mon, 25 Jun 2018 09:28:08 +0000 Received: by mail-wm0-x244.google.com with SMTP id z13-v6so2959461wma.5 for ; Mon, 25 Jun 2018 02:27:53 -0700 (PDT) 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=pQWm49q+VQG4QldyEA43MFoYJbGcwmhy3rCvnd6Er4o=; b=jb/iRY/m0mDJmcTe5cb1vunHUmnQwrbVn3p3M7Eiv6pPBguIm2jj5630vmR76AKErv KxVuMFMUFnL/UAap9jDiU1UQuhCeVv/5UOVt11Qjl4ssNwsu3elHuIhhidweP3wXpbjJ 0pKx3OdziQ0ilEW74muANQX6OA/PLv5cv4WkiFfOBlR8RYct7vYO/LW8xvXnIK4zwiCg C5y0pnVEz3Bt3bBoO9qFQdho7XnGBd5LjCSHCC+psuzhqOyVx58+/QbmgfFaBJMcDOsw vk98e1oOFrjpdnDaIg3KdtrfdzdvhT8dMFk6H0GjqZboONJ4bczrA6rUkeMaheendLDk 5EPA== 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=pQWm49q+VQG4QldyEA43MFoYJbGcwmhy3rCvnd6Er4o=; b=TZIq15LTvjFpMjKdpyQKTqZWyCceKQKoI9J4+sbm2tIA4FoyvdnbdMsJQ/WtRyAAKy G26i4PU87tJvOs0OK18nJUwg44BpDXlcjioPV6gjKbwSBKD1/ofPjWKdum1Tn57bQWT0 BEfXbPju1zphCYHfgVYYY+OZplQmCr0VjByaAyaXGLa8rAmCYaphUUrbgkdSSuA+MxTi Ly2eq3SlFrJB2uUgCS2eyeVl9yjD6eyy9POmfNXxQmZowUWdId5nL4ADF4x1uzAmnF3H 8ogpQhTVJR7SuYxBsxSSS1uamWxSzYlx8k7aXn3Zs/wf0qyBKusrmSHbkNC8WFDVffz5 sOqQ== X-Gm-Message-State: APt69E33yuj9Co9cbbU9Bhbw3+Xo6OvWYPRXrOHFIdPGSi9G+InVZxLR GwvrMMidHdOybnp0D3iKPGQ= X-Google-Smtp-Source: AAOMgpcd2BRxORtSgLoZGjn6ICIR9iItU1bVT9eS4g7vFGG/MqyMpRobaYk+ispRb8syM3rTQt7DjA== X-Received: by 2002:a1c:8d15:: with SMTP id p21-v6mr310217wmd.145.1529918871920; Mon, 25 Jun 2018 02:27:51 -0700 (PDT) Received: from NewMoon.iit.local ([90.147.180.254]) by smtp.gmail.com with ESMTPSA id v2-v6sm15638779wrm.84.2018.06.25.02.27.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Jun 2018 02:27:51 -0700 (PDT) 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 Subject: [PATCH v3 4/5] dmaengine: xilinx_dma: autodetect whether the HW supports scatter-gather Date: Mon, 25 Jun 2018 11:27:23 +0200 Message-Id: <20180625092724.22164-4-andrea.merello@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180625092724.22164-1-andrea.merello@gmail.com> References: <20180625092724.22164-1-andrea.merello@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180625_022801_239354_404BD965 X-CRM114-Status: GOOD ( 17.73 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, Andrea Merello , Radhey Shyam Pandey , linux-kernel@vger.kernel.org, Rob Herring , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The AXIDMA and CDMA HW can be either direct-access or scatter-gather version. These are SW incompatible. The driver can handle both version: a DT property was used to tell the driver whether to assume the HW is is 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 --- 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 7f0ab904b749..43fcc71ff287 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) @@ -406,7 +407,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 @@ -426,7 +426,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; @@ -2393,7 +2392,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 @@ -2486,6 +2484,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); @@ -2624,7 +2631,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) {