Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1463798ybg; Tue, 2 Jun 2020 10:36:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzNEp0EwMpJgFDbSpAUiSztqTs1y8DovBPVpwL3tm+Dyk+Lpmx2k0lj5cRT4FctqPzpuSqR X-Received: by 2002:aa7:d957:: with SMTP id l23mr15745190eds.206.1591119417763; Tue, 02 Jun 2020 10:36:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591119417; cv=none; d=google.com; s=arc-20160816; b=WrqlEGkM9WPT2IJVJG+RI0hkAyQhFLd3xKa30No12T80R5AOHFujaJ3D20+5bFqEbC PpJtuys9sl4/MamUa7NvqUGYDscv3f9ZCfPRBnN6/GfJAMLOKGOf4RugtkOE1liE6syC C2PxmNuhrSmedVXMCwtmdI5oJzvkNYUZqhgWfz4fuFl+K4OuSDNEq2qGg0xRFt63axun 77e01LYM+FFYIEGd9q2RSKK9Cqs4d+fF1sxndSpvK2yB3tNU8MoJ6Q+xUP2N2w3P9BiO 1FgoisYEthYPFpOjhCbkYQHrMzcrr5f3uoANDL5WxL1EvqQQlL9mRoFdek2YKoWrbDXC E0eA== 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=cBGTL0Kxil03wrOoJRMt6TMIwoGa3DB2H5rd4f8PV6E=; b=wc79eGPNbe/Ia62iru1MXF/rUc9AS40Ieq9f6yQi3ygVE/1eGqYj4+uQS8t1WHR5bl KW9QyyaY+g0MHhPyZXx5T+YNnMOMdYDscVkqD531chDvOe39iebAXBvyVq3b1DficY95 /R8jGkZfsPDSnyl2P/zsC9tq4jaXxOgjby8Vazy+XtXUiCxBcaMvWR5fO9t7d3tvoObi qT480D1M0dwANa73YNATARf5QqmwQybdeq8BCnEiRAI7elybU7XgK7Z9fnJPtT4/SUbS 1LQycK5N37npSvi9SRTFjE+fq7+Bg+LveUdaY+8gvMizVGhHYU5uEWI9stPbx40e+RQy 9z5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sunS1w+p; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id m1si1883135edf.548.2020.06.02.10.36.34; Tue, 02 Jun 2020 10:36:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sunS1w+p; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1726977AbgFBRen (ORCPT + 99 others); Tue, 2 Jun 2020 13:34:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725969AbgFBRen (ORCPT ); Tue, 2 Jun 2020 13:34:43 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 247CFC05BD1E; Tue, 2 Jun 2020 10:34:43 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id 64so5359041pfg.8; Tue, 02 Jun 2020 10:34:43 -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=cBGTL0Kxil03wrOoJRMt6TMIwoGa3DB2H5rd4f8PV6E=; b=sunS1w+poDICRs3zo89HpSDwh6tZFdEEorDFokhLApGSY+eAgsTuY5ihiawbv6LYfl 4rqLqsu2lj8JCnVOAzLipxY/W65sW1CSdwjewerypOxhiYVDAS+a8CjuNmQUwr1iwH7B BGBXZTs1KGJN54uoh5Zg/X9nMEuoN4WVT8Y5JryUF2scp7ChOguenNmgsdy0zZ3gRoO5 isOHfjgMT1yroaGBDNLeoWXj0ieyozP3ELXhClVnDLN/aUtG+Ctoq25M+5ncf7m5/uWK 2EDjfR7YOERitUp+D6lONcnEkQufGPn8e6lwE+Mpqhv4FIIWci4oT1MQJv0rLFT8NEe/ yroA== 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=cBGTL0Kxil03wrOoJRMt6TMIwoGa3DB2H5rd4f8PV6E=; b=ldGEcBWaZdPIpGyFjVdV0hl1dWbgb3JBTt4ZkoM6BHvprGxF3WK+IpV4Q66x3awTbh 7KyJXxGLt6K0AGotuZsf8vgDXEVqXhtUof6iJiTIIFKQIYZrRbZSUBht81BupkC+llkN N8Z1ZSQSc0MUJ7PfJ23GvJokJU8bDEEprOMMBC0165SVCMyFiTbCVux1DC3A81UwVMZj lSt2pkYS8q5XzZrucaoUZL9Tha7Svf07G4p3m4BYiniwEYsPFNLHoICqUmJrG6q7xTjq 0LTVNObbinKgdGduflB7AAUsWSw6BUV2jgAJVGmw5QrVznQgjnzr+v56hdU9mCFnagGj FwzQ== X-Gm-Message-State: AOAM530EeC2R4aP3h2RBNXcB840X9rRoHnkzX1wFcREdSl+9jbw22vKX OvOgTIfSv3HpGi7MTTgN97Q= X-Received: by 2002:a05:6a00:2c5:: with SMTP id b5mr4605461pft.41.1591119282604; Tue, 02 Jun 2020 10:34:42 -0700 (PDT) Received: from localhost.localdomain ([223.235.152.125]) by smtp.gmail.com with ESMTPSA id i22sm2864382pfo.92.2020.06.02.10.34.06 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Jun 2020 10:34:41 -0700 (PDT) From: Amit Singh Tomar To: andre.przywara@arm.com, vkoul@kernel.org, afaerber@suse.de, manivannan.sadhasivam@linaro.org Cc: dan.j.williams@intel.com, cristian.ciocaltea@gmail.com, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-actions@lists.infradead.org Subject: [PATCH v3 01/10] dmaengine: Actions: get rid of bit fields from dma descriptor Date: Tue, 2 Jun 2020 23:03:03 +0530 Message-Id: <1591119192-18538-2-git-send-email-amittomer25@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1591119192-18538-1-git-send-email-amittomer25@gmail.com> References: <1591119192-18538-1-git-send-email-amittomer25@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org At the moment, Driver uses bit fields to describe registers of the DMA descriptor structure that makes it less portable and maintainable, and Andre suugested(and even sketched important bits for it) to make use of array to describe this DMA descriptors instead. It gives the flexibility while extending support for other platform such as Actions S700. This commit removes the "owl_dma_lli_hw" (that includes bit-fields) and uses array to describe DMA descriptor. Suggested-by: Andre Przywara Signed-off-by: Amit Singh Tomar --- Changes since v2: * No change. Changes since v1: * Defined macro for frame count value. * Introduced llc_hw_flen() from patch 2/9. * Removed the unnecessary line break. Changes since rfc: * No change. --- drivers/dma/owl-dma.c | 84 ++++++++++++++++++++++++--------------------------- 1 file changed, 40 insertions(+), 44 deletions(-) diff --git a/drivers/dma/owl-dma.c b/drivers/dma/owl-dma.c index c683051257fd..dd85c205454e 100644 --- a/drivers/dma/owl-dma.c +++ b/drivers/dma/owl-dma.c @@ -120,30 +120,21 @@ #define BIT_FIELD(val, width, shift, newshift) \ ((((val) >> (shift)) & ((BIT(width)) - 1)) << (newshift)) -/** - * struct owl_dma_lli_hw - Hardware link list for dma transfer - * @next_lli: physical address of the next link list - * @saddr: source physical address - * @daddr: destination physical address - * @flen: frame length - * @fcnt: frame count - * @src_stride: source stride - * @dst_stride: destination stride - * @ctrla: dma_mode and linklist ctrl config - * @ctrlb: interrupt config - * @const_num: data for constant fill - */ -struct owl_dma_lli_hw { - u32 next_lli; - u32 saddr; - u32 daddr; - u32 flen:20; - u32 fcnt:12; - u32 src_stride; - u32 dst_stride; - u32 ctrla; - u32 ctrlb; - u32 const_num; +/* Frame count value is fixed as 1 */ +#define FCNT_VAL 0x1 + +/* Describe DMA descriptor, hardware link list for dma transfer */ +enum owl_dmadesc_offsets { + OWL_DMADESC_NEXT_LLI = 0, + OWL_DMADESC_SADDR, + OWL_DMADESC_DADDR, + OWL_DMADESC_FLEN, + OWL_DMADESC_SRC_STRIDE, + OWL_DMADESC_DST_STRIDE, + OWL_DMADESC_CTRLA, + OWL_DMADESC_CTRLB, + OWL_DMADESC_CONST_NUM, + OWL_DMADESC_SIZE }; /** @@ -153,7 +144,7 @@ struct owl_dma_lli_hw { * @node: node for txd's lli_list */ struct owl_dma_lli { - struct owl_dma_lli_hw hw; + u32 hw[OWL_DMADESC_SIZE]; dma_addr_t phys; struct list_head node; }; @@ -320,6 +311,11 @@ static inline u32 llc_hw_ctrlb(u32 int_ctl) return ctl; } +static u32 llc_hw_flen(struct owl_dma_lli *lli) +{ + return lli->hw[OWL_DMADESC_FLEN] & GENMASK(19, 0); +} + static void owl_dma_free_lli(struct owl_dma *od, struct owl_dma_lli *lli) { @@ -351,8 +347,9 @@ static struct owl_dma_lli *owl_dma_add_lli(struct owl_dma_txd *txd, list_add_tail(&next->node, &txd->lli_list); if (prev) { - prev->hw.next_lli = next->phys; - prev->hw.ctrla |= llc_hw_ctrla(OWL_DMA_MODE_LME, 0); + prev->hw[OWL_DMADESC_NEXT_LLI] = next->phys; + prev->hw[OWL_DMADESC_CTRLA] |= + llc_hw_ctrla(OWL_DMA_MODE_LME, 0); } return next; @@ -365,8 +362,7 @@ static inline int owl_dma_cfg_lli(struct owl_dma_vchan *vchan, struct dma_slave_config *sconfig, bool is_cyclic) { - struct owl_dma_lli_hw *hw = &lli->hw; - u32 mode; + u32 mode, ctrlb; mode = OWL_DMA_MODE_PW(0); @@ -407,22 +403,22 @@ static inline int owl_dma_cfg_lli(struct owl_dma_vchan *vchan, return -EINVAL; } - hw->next_lli = 0; /* One link list by default */ - hw->saddr = src; - hw->daddr = dst; - - hw->fcnt = 1; /* Frame count fixed as 1 */ - hw->flen = len; /* Max frame length is 1MB */ - hw->src_stride = 0; - hw->dst_stride = 0; - hw->ctrla = llc_hw_ctrla(mode, - OWL_DMA_LLC_SAV_LOAD_NEXT | - OWL_DMA_LLC_DAV_LOAD_NEXT); + lli->hw[OWL_DMADESC_CTRLA] = llc_hw_ctrla(mode, + OWL_DMA_LLC_SAV_LOAD_NEXT | + OWL_DMA_LLC_DAV_LOAD_NEXT); if (is_cyclic) - hw->ctrlb = llc_hw_ctrlb(OWL_DMA_INTCTL_BLOCK); + ctrlb = llc_hw_ctrlb(OWL_DMA_INTCTL_BLOCK); else - hw->ctrlb = llc_hw_ctrlb(OWL_DMA_INTCTL_SUPER_BLOCK); + ctrlb = llc_hw_ctrlb(OWL_DMA_INTCTL_SUPER_BLOCK); + + lli->hw[OWL_DMADESC_NEXT_LLI] = 0; + lli->hw[OWL_DMADESC_SADDR] = src; + lli->hw[OWL_DMADESC_DADDR] = dst; + lli->hw[OWL_DMADESC_SRC_STRIDE] = 0; + lli->hw[OWL_DMADESC_DST_STRIDE] = 0; + lli->hw[OWL_DMADESC_FLEN] = len | FCNT_VAL << 20; + lli->hw[OWL_DMADESC_CTRLB] = ctrlb; return 0; } @@ -754,7 +750,7 @@ static u32 owl_dma_getbytes_chan(struct owl_dma_vchan *vchan) /* Start from the next active node */ if (lli->phys == next_lli_phy) { list_for_each_entry(lli, &txd->lli_list, node) - bytes += lli->hw.flen; + bytes += llc_hw_flen(lli); break; } } @@ -785,7 +781,7 @@ static enum dma_status owl_dma_tx_status(struct dma_chan *chan, if (vd) { txd = to_owl_txd(&vd->tx); list_for_each_entry(lli, &txd->lli_list, node) - bytes += lli->hw.flen; + bytes += llc_hw_flen(lli); } else { bytes = owl_dma_getbytes_chan(vchan); } -- 2.7.4