From patchwork Thu Jun 14 07:36:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 138531 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1773210lji; Thu, 14 Jun 2018 00:40:40 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIhH2KjrCLfGYuElHQvBch5+VlLrJicCrfd6jo5baWnXfy1h141v04yG9Z2g23x82587qa7 X-Received: by 2002:a17:902:56e:: with SMTP id 101-v6mr1715363plf.25.1528962040211; Thu, 14 Jun 2018 00:40:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528962040; cv=none; d=google.com; s=arc-20160816; b=P42EtwXrHtOkwXV1Pr0Ug4nxUpxIrOCyOXUDBpidxuj7EyS9s1O+xO4OpHku62CSyF Ry6x2MLecXDJmqqg9qYWlKfWYhwkUOVdk1m1ApS63yanPdawBmseWcwJpsk9p1YwdImm T4teGiw/DQzXbn3e+RnsFshTw01WIJff3x0lnHXZs+uZdYw2UyKnrVrbdjTwwpVRpsqt jMoGR49hcCfqS00ALncmnFJ/Az+UEdt9s6MxwAHPaC+AofGmEoCkfatro6+vNB4kSMq/ smjeMXmEsVMDQWncMreOaSBJkq72Pp1bHodOZtf3eNQBFC5UQIMxVBgxJeJ0CanppKM/ oaTg== 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=j3jIepUwDw2xc+pgExVeFYswjqlQIgEI3e1Xbicq7EM=; b=TCalSfpUdz4fImPvIFVftCJ4akP08G5LkGq6zhkR6nnSxF12DvyNOMTK7fdvmo7nOi bplsv+kdckJDi1SwKouZsVzxGUzZUxj8BN+DBmIAv06cwuZoYfDargMdSHQSyEYfEwED 97c5gTbc4MF9tklgCjzeOZ7M76fQiNlwIAUE/2/tUPjRNfOPi5YkYxu+KRY0p1gmDQ05 Bqq2u/OWaLrOGdW7jolTpNMxaY6Tvv7jo6RZT8IADwLU7eT/k4RxWxlXF98k4fYVuvUk 8UkBHgFFnBCGB4P9oOCCcb0Yx6YAVHxzqp1jm/L4LC5Rja0FeWDeZ2/0p/ga+HOmIH02 c/5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="WCY8GY/O"; 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=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 z23-v6si4527594pfe.296.2018.06.14.00.40.39; Thu, 14 Jun 2018 00:40:40 -0700 (PDT) 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=@linaro.org header.s=google header.b="WCY8GY/O"; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754929AbeFNHki (ORCPT + 30 others); Thu, 14 Jun 2018 03:40:38 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:34669 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754626AbeFNHhL (ORCPT ); Thu, 14 Jun 2018 03:37:11 -0400 Received: by mail-lf0-f67.google.com with SMTP id o9-v6so7862283lfk.1 for ; Thu, 14 Jun 2018 00:37:11 -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=j3jIepUwDw2xc+pgExVeFYswjqlQIgEI3e1Xbicq7EM=; b=WCY8GY/OeAWDmjl+LuTZek/xIP13o7zPX81zm3bgC5AYZ3I/7nM0a2nrxcl9T8oqpd SpWgH9GFCPF+Li4ff1Eofz2FSAuD4/iCEU6U0/HvQEK9VxSgLbEIU89SdazFhRLYLCwx GESwzpJOwLqjY2vklT2asaX7MZe5eY88F1snA= 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=j3jIepUwDw2xc+pgExVeFYswjqlQIgEI3e1Xbicq7EM=; b=h5YGV/fCrqMIoyrIev5fuZqRYvwMprp26SR4GiE9e14QhVF2z3QRljwZ6upYldlPqG LAhqRg8vGXtHXEsEe9SIJBF+/68+rOAzeep/b1KR83lUyAa1BbKNdhOxLZT5TsC6dVGf W6hUHhTL9CpZb5Pclg/CQMc3h1RKN0UJQEEbV3XLmMIesWfuD4Q1iOjBNH4GWnf3uzH9 2TqQSJWFMvK2zVhPt+p6PwYsoDWoZOIO3qze0LTcpG8toENRfyJ0oEmrf3ZDx1HJGSjK Gm7ssrF7hXoxRPO2cUIm+hwwaXOPFoVHs3Xr+neZAiIzHh+p77yrYi9TBJDBaGAx9wbK f4UQ== X-Gm-Message-State: APt69E1EwZvQRbJhbflOaywNW5zZtacvgPmaGRQXi1oWH1tpVQtMQGPE W8qaZWz3y9E8VbWdsrMvX1Ri1A== X-Received: by 2002:a2e:5047:: with SMTP id v7-v6mr963704ljd.122.1528961830002; Thu, 14 Jun 2018 00:37:10 -0700 (PDT) Received: from localhost.localdomain (59-201-94-178.pool.ukrtel.net. [178.94.201.59]) by smtp.gmail.com with ESMTPSA id a195-v6sm957597lfe.44.2018.06.14.00.37.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Jun 2018 00:37:09 -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, ilias.apalodimas@linaro.org, p-varis@ti.com, spatton@ti.com, francois.ozog@linaro.org, yogeshs@ti.com, nsekhar@ti.com, andrew@lunn.ch, Ivan Khoronzhuk Subject: [PATCH v2 net-next 1/6] net: ethernet: ti: cpsw: use cpdma channels in backward order for txq Date: Thu, 14 Jun 2018 10:36:45 +0300 Message-Id: <20180614073650.29659-2-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180614073650.29659-1-ivan.khoronzhuk@linaro.org> References: <20180614073650.29659-1-ivan.khoronzhuk@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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.1 diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index 534596ce00d3..406537d74ec1 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);