From patchwork Fri May 18 21:15:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 136365 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1726547lji; Fri, 18 May 2018 14:15:22 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoJRERLbtHfRazUHMkdALtAi63jNvt5u9yAFx0PSgqrdyc/RutMfmJSNnog39pY0IbeAXt7 X-Received: by 2002:a63:7a5e:: with SMTP id j30-v6mr8840992pgn.145.1526678122380; Fri, 18 May 2018 14:15:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526678122; cv=none; d=google.com; s=arc-20160816; b=OnOVtdas9Wi4su3qSudt4bG/KSVXDM0FofGyJIYyGRIY5qHFKSC5nlFQia5D51XI+w NS0hRw3eZM5kESfyR/xamMLByt8UkRFpv3hCdSrDVzVBupGLs5lkGNG4nzQkp6A+IXSZ L51ZCEIJGBPZ3yI7VEuL+o8vzGaa8Hqqo+2WAsuCwDEB6DtlopmqxXkEsCM3Bt8qF1Rj jlCupYwP+6H+gR/ApAbKtoyHTLIJAUy49q8R5AkOPMDuPaQLvUTpsTQYntdLU8kiKdte iyyjho93V5FHLSUkbmpfAhQ64orKrlxl/ODx8MjFAywMprZF5vIkxIkQGiYO77JyLl4s MkxA== 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:arc-authentication-results; bh=hS0BVweyUmVmQbsSEeaeIxOTL5TGrymxbJAyAD/O7II=; b=svlPfUafST77t+nOVIwfilJlWThUKxLL61v/46yDQAnNJQTN5/vwDQgp70DSlh61tV whlbjYYz23jRqVQT8eoQukiVRaDBFuS6Sl/iQ2a/DQdNbs6onRILBXjl7QbSdfO9eqWg PuC2Y3QnkmgxVx0VyyzAuwwAc/E7GDUJPlwDRZeFJxuQqajGCKOReOTvferWff9TwCul dJi5Jkrsc2p4DfZFJtJkIBHDs+tmivzPVpK80N0vDnoYFU+jpSMKaT9HEvIRYNwzHmk1 Pdxf6TSL9zexpezqNy2sqxzAJ9DoT3V+xQRJtraNF/0cmJC/OiBHq8mPpu13A9KeTb3B /QCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Iq7ekSlX; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g92-v6si8287272plg.342.2018.05.18.14.15.22; Fri, 18 May 2018 14:15:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Iq7ekSlX; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752193AbeERVPT (ORCPT + 5 others); Fri, 18 May 2018 17:15:19 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:34991 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751606AbeERVPS (ORCPT ); Fri, 18 May 2018 17:15:18 -0400 Received: by mail-lf0-f66.google.com with SMTP id y72-v6so15917418lfd.2 for ; Fri, 18 May 2018 14:15:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=LG3vbTOt3H4eqZw84rnHtarB8hn9NN2ZT3db1ZaLe8w=; b=Iq7ekSlXrcMHEzYWVyaU9iPWUbLNPrEUrtbvOJCsxayInBm2lXxPRpWAwwCTLlMXgN IQ0gjTZGCESBk4pHQNlKhT9tvm2h48Auu9j6++UdwTLyu0yad8vWEE7I5ByR+MI9EW0+ W6rrMtaxOndSFeTKv49+doRfXkafjQImYY3x8= 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=LG3vbTOt3H4eqZw84rnHtarB8hn9NN2ZT3db1ZaLe8w=; b=leQ+TbGfW2yGU5FSXoAxGTDdK4Le8+K2nZeD6nMriL4oq3yc2mo3BCekGDNFV7Trhi RsNtQjoCoTJqG+WnXR00nO/4wwEvPBf4+wBuhsnSEue9GGZ2neTWbyAZt6Q3v99YhUpp 431Gpvwc4bZiKPBOhsgVVNDJ61qIPpfgZHzbCXYDB6TzqcWwSYltfZHj4XTuC7UyDPKr in3CvqyycO8LxxMB+rp+045L5XB6ko5Af0HUsLPCyJnBs5rTpR8mRBT/nGuzyjcTCoHO aFj4u9PqlBgw2jq37G/oE6l+g7SR8vs5CUKbWmMv/X4YFDoWCpW5OdHJyJjrJ9+YjBDf 8Zsw== X-Gm-Message-State: ALKqPweMKkTM1Uah+0HfGnWKV9ktS6JJJrSjuvGiWNqZtTrkIRYm3K2P kc9gK8pPmDnoJ+6G1ERGjLvE3w== X-Received: by 2002:a2e:4d5d:: with SMTP id a90-v6mr6918962ljb.86.1526678117391; Fri, 18 May 2018 14:15:17 -0700 (PDT) Received: from localhost.localdomain (59-201-94-178.pool.ukrtel.net. [178.94.201.59]) by smtp.gmail.com with ESMTPSA id g20-v6sm2045991lfk.39.2018.05.18.14.15.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 May 2018 14:15:16 -0700 (PDT) From: Ivan Khoronzhuk To: grygorii.strashko@ti.com, davem@davemloft.net Cc: corbet@lwn.net, akpm@linux-foundation.org, netdev@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, vinicius.gomes@intel.com, henrik@austad.us, jesus.sanchez-palencia@intel.com, Ivan Khoronzhuk Subject: [RFC PATCH 1/6] net: ethernet: ti: cpsw: use cpdma channels in backward order for txq Date: Sat, 19 May 2018 00:15:05 +0300 Message-Id: <20180518211510.13341-2-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180518211510.13341-1-ivan.khoronzhuk@linaro.org> References: <20180518211510.13341-1-ivan.khoronzhuk@linaro.org> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org The cpdma channel highest priority is from hi to lo number. The driver has limited number of descriptors that are shared between number of cpdma channels. Number of queues can be tuned with ethtool, that allows to not spend descriptors on not needed cpdma channels. In AVB usually only 2 tx queues can be enough with rate limitation. The rate limitation can be used only for hi priority queues. Thus, to use only 2 queues the 8 has to be created. It's wasteful. So, in order to allow using only needed number of rate limited tx queues, save resources, and be able to set rate limitation for them, let assign tx cpdma channels in backward order to queues. Signed-off-by: Ivan Khoronzhuk --- drivers/net/ethernet/ti/cpsw.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) -- 2.17.0 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index a7285dddfd29..9bd615da04d3 100644 --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c @@ -967,8 +967,8 @@ static int cpsw_tx_mq_poll(struct napi_struct *napi_tx, int budget) /* process every unprocessed channel */ ch_map = cpdma_ctrl_txchs_state(cpsw->dma); - for (ch = 0, num_tx = 0; ch_map; ch_map >>= 1, ch++) { - if (!(ch_map & 0x01)) + for (ch = 0, num_tx = 0; ch_map & 0xff; ch_map <<= 1, ch++) { + if (!(ch_map & 0x80)) continue; txv = &cpsw->txv[ch]; @@ -2431,7 +2431,7 @@ static int cpsw_update_channels_res(struct cpsw_priv *priv, int ch_num, int rx) void (*handler)(void *, int, int); struct netdev_queue *queue; struct cpsw_vector *vec; - int ret, *ch; + int ret, *ch, vch; if (rx) { ch = &cpsw->rx_ch_num; @@ -2444,7 +2444,8 @@ static int cpsw_update_channels_res(struct cpsw_priv *priv, int ch_num, int rx) } while (*ch < ch_num) { - vec[*ch].ch = cpdma_chan_create(cpsw->dma, *ch, handler, rx); + vch = rx ? *ch : 7 - *ch; + vec[*ch].ch = cpdma_chan_create(cpsw->dma, vch, handler, rx); queue = netdev_get_tx_queue(priv->ndev, *ch); queue->tx_maxrate = 0; @@ -2980,7 +2981,7 @@ static int cpsw_probe(struct platform_device *pdev) u32 slave_offset, sliver_offset, slave_size; const struct soc_device_attribute *soc; struct cpsw_common *cpsw; - int ret = 0, i; + int ret = 0, i, ch; int irq; cpsw = devm_kzalloc(&pdev->dev, sizeof(struct cpsw_common), GFP_KERNEL); @@ -3155,7 +3156,8 @@ static int cpsw_probe(struct platform_device *pdev) if (soc) cpsw->quirk_irq = 1; - cpsw->txv[0].ch = cpdma_chan_create(cpsw->dma, 0, cpsw_tx_handler, 0); + ch = cpsw->quirk_irq ? 0 : 7; + cpsw->txv[0].ch = cpdma_chan_create(cpsw->dma, ch, cpsw_tx_handler, 0); if (IS_ERR(cpsw->txv[0].ch)) { dev_err(priv->dev, "error initializing tx dma channel\n"); ret = PTR_ERR(cpsw->txv[0].ch); From patchwork Fri May 18 21:15:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 136367 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1726596lji; Fri, 18 May 2018 14:15:25 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoS26S6ieF/0O8oaJ56IRSTg5nIEXZlc0C3N/ezFb/lnRe+ZrjddxhQDVQNoZvwjl4uXC1i X-Received: by 2002:a65:49c3:: with SMTP id t3-v6mr8576935pgs.65.1526678125585; Fri, 18 May 2018 14:15:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526678125; cv=none; d=google.com; s=arc-20160816; b=vcZdd9dLiOaRXT5uR5OEm9MKUvjVvefUTedslTw9sdwriwv3V8wZrb1ci1Jv+urtbN sGScgLkKWzw1XhJBn6xizBWStL6t0Z4b7ra9cqShKsPsDjPpw+AW6UaIHH3/ftyAHYz6 jodvBV3JYT/PHuyak23rkkP4pCZE1JMAm9CtGiaQYEBeiJgQCM80KEYZ2oDbhoDI264f yHUNOBX0t0gruYjOkZRYVq3c+ZzYfueMymH7cJy4MTODwFW9UPvs1/2uokzoxQ4c5g1g 5qpwFNRSE5drzkMdmZbFQioA25+iNCX3H2LDvv4PSfWnMwesgf6u+timpgTBHd7jEUgb 52lw== 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:arc-authentication-results; bh=Fvy1uWAIHjgQjtXdfGYGORKGpD9kiUO/cLZPbaCeCA8=; b=mRp0I81epytc+jUnm3oBzeznYjsxmSQKG/TxzYm+0flMm87iXjHEhPXrhO9IM6foYV QNUhEQizIqfjlorABEgNW2fCpqQIgG2Z8+yYQZFa9mBT4FyXg8K2Y/f9QJAYgCzz0GAs DBZmwNnG1wNliigI2uVW/En6PXN7kIKvKvIjkE6yo+d7PEZ3ZQ+ebzCr0kVJ6OvWOcBU 3R50p649vWqdLaRB56SgZe9iymbPXbHVNuzuCqKKEGHsxg33W1/jx+h5bW+MOFZNfD3F EVyoWVlVXyG8TsDUEPsJSRsW5cC6udXEnYV/9veMaQ0fCnOiLuYOB8QCft9pu0RRSgwR i58w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=WoT3uFz2; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c13-v6si6779854pgt.649.2018.05.18.14.15.25; Fri, 18 May 2018 14:15:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=WoT3uFz2; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752206AbeERVPX (ORCPT + 5 others); Fri, 18 May 2018 17:15:23 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:44023 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752129AbeERVPU (ORCPT ); Fri, 18 May 2018 17:15:20 -0400 Received: by mail-lf0-f66.google.com with SMTP id n18-v6so15864252lfh.10 for ; Fri, 18 May 2018 14:15:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=evqVlSgwE0Mq3D3CWJiiP/nrSl0JupLCAxkyhHdkCDo=; b=WoT3uFz2l1Ig2Hb8nuOBRLmj+prhEM/N7QtBaCTrE5h7DdyLImWJ8EN8BXQgLgBb6z IT9DeRR169jNdTgTTXJXK5rPyxtBId3D3aFbxk4pojtlBMphio0VEX6mcsHNIFZkeNvc Lja90ER3Tx+Eez7UWmVAIjFJcO6I+qfm9+bBw= 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=evqVlSgwE0Mq3D3CWJiiP/nrSl0JupLCAxkyhHdkCDo=; b=pRyfCRKGeZBtIJz/+Xfo7MSjI2F5e2jgV+31bvCK1fcvMun8TyIMVB/LuJCjalEdHQ vS5EnbLfeOtZ0phroxiFgOs1gsBIWYE/OEfty0vgl8JYxSAFd4FuXo5aZ25cWc2OHJlx O8sHED/ES7zsSQTYCIPIz522GCe7YoQlF48IhyswnOERuBiaAaocUBcuVMuxlr8w83Zt G7e7ZrNGAIu7Dg45V+hjddvV0HyhhfSp2OaKgMx742V7sa3Egh41qwXp+9kAewiu4dGT dXGqsOr+p63NZ7OWwC8LemCi2rXNmbvUMEuS4ZcRRJ+/0qDCo1mVheCv/eQvqwGUtbQE B+FA== X-Gm-Message-State: ALKqPwfqvmUbktMEFDJmF6RVVC69WMEZeCeGd3fZG0EGgmqxz2y9YRzx tJ35WP2rTUtdjd2c6tJ/gGBsmQ== X-Received: by 2002:a2e:2a45:: with SMTP id q66-v6mr6617173ljq.40.1526678118623; Fri, 18 May 2018 14:15:18 -0700 (PDT) Received: from localhost.localdomain (59-201-94-178.pool.ukrtel.net. [178.94.201.59]) by smtp.gmail.com with ESMTPSA id g20-v6sm2045991lfk.39.2018.05.18.14.15.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 May 2018 14:15:18 -0700 (PDT) From: Ivan Khoronzhuk To: grygorii.strashko@ti.com, davem@davemloft.net Cc: corbet@lwn.net, akpm@linux-foundation.org, netdev@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, vinicius.gomes@intel.com, henrik@austad.us, jesus.sanchez-palencia@intel.com, Ivan Khoronzhuk Subject: [RFC PATCH 2/6] net: ethernet: ti: cpdma: fit rated channels in backward order Date: Sat, 19 May 2018 00:15:06 +0300 Message-Id: <20180518211510.13341-3-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180518211510.13341-1-ivan.khoronzhuk@linaro.org> References: <20180518211510.13341-1-ivan.khoronzhuk@linaro.org> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org According to TRM tx rated channels should be in 7..0 order, so correct it. Signed-off-by: Ivan Khoronzhuk --- drivers/net/ethernet/ti/davinci_cpdma.c | 31 ++++++++++++------------- 1 file changed, 15 insertions(+), 16 deletions(-) -- 2.17.0 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/net/ethernet/ti/davinci_cpdma.c b/drivers/net/ethernet/ti/davinci_cpdma.c index 31ae04117f0a..37fbdc668cc7 100644 --- a/drivers/net/ethernet/ti/davinci_cpdma.c +++ b/drivers/net/ethernet/ti/davinci_cpdma.c @@ -406,37 +406,36 @@ static int cpdma_chan_fit_rate(struct cpdma_chan *ch, u32 rate, struct cpdma_chan *chan; u32 old_rate = ch->rate; u32 new_rmask = 0; - int rlim = 1; + int rlim = 0; int i; - *prio_mode = 0; for (i = tx_chan_num(0); i < tx_chan_num(CPDMA_MAX_CHANNELS); i++) { chan = ctlr->channels[i]; - if (!chan) { - rlim = 0; + if (!chan) continue; - } if (chan == ch) chan->rate = rate; if (chan->rate) { - if (rlim) { - new_rmask |= chan->mask; - } else { - ch->rate = old_rate; - dev_err(ctlr->dev, "Prev channel of %dch is not rate limited\n", - chan->chan_num); - return -EINVAL; - } - } else { - *prio_mode = 1; - rlim = 0; + rlim = 1; + new_rmask |= chan->mask; + continue; } + + if (rlim) + goto err; } *rmask = new_rmask; + *prio_mode = rlim; return 0; + +err: + ch->rate = old_rate; + dev_err(ctlr->dev, "Upper cpdma ch%d is not rate limited\n", + chan->chan_num); + return -EINVAL; } static u32 cpdma_chan_set_factors(struct cpdma_ctlr *ctlr,