From patchwork Sun Jun 30 17:23:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 168189 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp1960049ilk; Sun, 30 Jun 2019 10:24:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqy4nAYvV6oLjj8bCZhvqSovr+6yX4M/8HOs0hYYaXl0T6c+rDyjiVrgGZGCvIzWfheZo2DB X-Received: by 2002:a65:4786:: with SMTP id e6mr12001054pgs.448.1561915489299; Sun, 30 Jun 2019 10:24:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561915489; cv=none; d=google.com; s=arc-20160816; b=AkbXDRCaGLI4MVtS8zve684aBYUkAw4DS9Mhhl4UqF/hFtV2zHTnrUAP/8MOR5QYEe RluNcghV7AnQ6jKvkstT7p4qVVu4Da6LNqoLCdl7XvMaZGLwE4ZsLOc4oH1oi8zK4JnN sTJaw11m1yn6fW4Vohb7bgwrqFym2+fcmRS05AU4yyrP4CZL84jx4dhYBZh6IIcifXFx O743tNhmvHmgCErzbU7w7XmNnRd6XJHELfnQzHnDEx8LTYO2QC28uQsFlk1tV++vWSCc 208HThNwIqkW2Kgh190EKtJIyJi97nyuFqcf+k6KMRAarO6Omfg5Hb7rkx9EZK2NEeyL IOGg== 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=uUkBROZO3WakB4095Sqlp9gekMGTEEFtZPkRqC6risY=; b=UBtRbLm//RX3CqzDzg2GJfYw+OodI3JraRttcsXu0F7GoDv0EoUFrtiXeuizPywepS mJMkhRFPmJN0f39mPtsNHtESmSJLGp9TxzGck/q//9n7KILLSyrLTBriY6fVtlv9g3TD ETci/NjiXwBcPHK+l+IOVp9cRGHl5V6aw4W4i4V5s5zaDD61eiviMg/914PvzV9R053A 4uLIczg1TfGQc1Zuwt01v01NXjLHccpSU4Cx3oYQfwYv/HMA3SllJgfW8bnmebTcSJGV 9KI3zElkdKb1a4l/ql+ciUL29ct3VrNKPlda2l9jqh9XAVWgznU/VT2HtYrQhvnlh1PN 9+BQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="uM/mKdfk"; 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 a7si8986936pfc.54.2019.06.30.10.24.49; Sun, 30 Jun 2019 10:24:49 -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="uM/mKdfk"; 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 S1727048AbfF3RYs (ORCPT + 30 others); Sun, 30 Jun 2019 13:24:48 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:40891 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726830AbfF3RYZ (ORCPT ); Sun, 30 Jun 2019 13:24:25 -0400 Received: by mail-lj1-f196.google.com with SMTP id a21so10637799ljh.7 for ; Sun, 30 Jun 2019 10:24:23 -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=uUkBROZO3WakB4095Sqlp9gekMGTEEFtZPkRqC6risY=; b=uM/mKdfkiRjikWMeGLjOxOlcNobeB2PCrFWOmSy/QtV7Zsq52w/Gy5oRsJqd9UggZx Lyqbs6ExkSsMzUjJETRoZDJXY9pMe1ZkHXh/R1sIIz8bLDB25qSz6F4DaVH7AV5+sHfv 1f0baQOqGfw+PBMOv5dADsX+o3W+3Q9pVXtJZxc0JuS1lbsjXcAFAZwrnrTpSlBFh9XV J2uFs9tD8k66Q4XIjckj4WN9swTcCRH6y+n3LDHz0PrNP039e8YF3jWW6Js07RE7n/UE FuQufsOTvvgpChK2FKg0yDTuMqfV83AS8PjQfDie2BCSoqab9kPy56ScG9/FrQEDHLmq SDug== 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=uUkBROZO3WakB4095Sqlp9gekMGTEEFtZPkRqC6risY=; b=qD/BacL/iZyF84nXZ8YS1UXw9WayOw0MYUMr4QQ0rrWNlJddDXalKnrOlDvKFgInf8 H3FwZr/05oH/qdRAS+xRkdHxRCXLdFkr1ZbuuNDLPJa0vRKcYdiR62jLDIttO5W3MbQd WXDsDhggYSzicvMnkDGSdkH6olAwb3FdjEw5mvnX7TPjaXTn7Kbrll8Tpaq+JDqd9a8Y ftAwK07lO1aYLlAMCmpMBQpNftip1fTIDhiQ6POcfmLwKh2U3KAQoEB982EbtpzreGwK Zf5MVb2koly1Jv9ealQsfnQ8laVgc8Sz6RuoHuSsMjTuQ5NCKvdE5sST1D3FS3r9VwuR FrTw== X-Gm-Message-State: APjAAAVOnuZ+jBGAjx798a10OlK3cw3M3/nILu7fRBw9+knp8MEmf+yr zqnLJfGelK8DPdUPMjIkbw0pqA== X-Received: by 2002:a2e:740a:: with SMTP id p10mr7897078ljc.19.1561915462387; Sun, 30 Jun 2019 10:24:22 -0700 (PDT) Received: from localhost.localdomain (59-201-94-178.pool.ukrtel.net. [178.94.201.59]) by smtp.gmail.com with ESMTPSA id c1sm2273795lfh.13.2019.06.30.10.24.21 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 30 Jun 2019 10:24:21 -0700 (PDT) From: Ivan Khoronzhuk To: grygorii.strashko@ti.com, hawk@kernel.org, davem@davemloft.net Cc: ast@kernel.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, xdp-newbies@vger.kernel.org, ilias.apalodimas@linaro.org, netdev@vger.kernel.org, daniel@iogearbox.net, jakub.kicinski@netronome.com, john.fastabend@gmail.com, Ivan Khoronzhuk Subject: [PATCH v5 net-next 4/6] net: ethernet: ti: davinci_cpdma: allow desc split while down Date: Sun, 30 Jun 2019 20:23:46 +0300 Message-Id: <20190630172348.5692-5-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190630172348.5692-1-ivan.khoronzhuk@linaro.org> References: <20190630172348.5692-1-ivan.khoronzhuk@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org That's possible to set ring params while interfaces are down. When interface gets up it uses number of descs to fill rx queue and on later on changes to create rx pools. Usually, this resplit can happen after phy is up, but it can be needed before this, so allow it to happen while setting number of rx descs, when interfaces are down. Also, if no dependency on intf state, move it to cpdma layer, where it should be. Signed-off-by: Ivan Khoronzhuk --- drivers/net/ethernet/ti/cpsw_ethtool.c | 9 ++++----- drivers/net/ethernet/ti/davinci_cpdma.c | 10 +++++++++- drivers/net/ethernet/ti/davinci_cpdma.h | 3 +-- 3 files changed, 14 insertions(+), 8 deletions(-) -- 2.17.1 diff --git a/drivers/net/ethernet/ti/cpsw_ethtool.c b/drivers/net/ethernet/ti/cpsw_ethtool.c index 7c19eebbabcc..6ab0cec8560a 100644 --- a/drivers/net/ethernet/ti/cpsw_ethtool.c +++ b/drivers/net/ethernet/ti/cpsw_ethtool.c @@ -664,15 +664,14 @@ int cpsw_set_ringparam(struct net_device *ndev, cpsw_suspend_data_pass(ndev); - cpdma_set_num_rx_descs(cpsw->dma, ering->rx_pending); - - if (cpsw->usage_count) - cpdma_chan_split_pool(cpsw->dma); + ret = cpdma_set_num_rx_descs(cpsw->dma, ering->rx_pending); + if (ret) + goto err; ret = cpsw_resume_data_pass(ndev); if (!ret) return 0; - +err: dev_err(cpsw->dev, "cannot set ring params, closing device\n"); dev_close(ndev); return ret; diff --git a/drivers/net/ethernet/ti/davinci_cpdma.c b/drivers/net/ethernet/ti/davinci_cpdma.c index ea25b23c8058..7dc2c1ee6238 100644 --- a/drivers/net/ethernet/ti/davinci_cpdma.c +++ b/drivers/net/ethernet/ti/davinci_cpdma.c @@ -1427,8 +1427,16 @@ int cpdma_get_num_tx_descs(struct cpdma_ctlr *ctlr) return ctlr->num_tx_desc; } -void cpdma_set_num_rx_descs(struct cpdma_ctlr *ctlr, int num_rx_desc) +int cpdma_set_num_rx_descs(struct cpdma_ctlr *ctlr, int num_rx_desc) { + unsigned long flags; + int ret; + + spin_lock_irqsave(&ctlr->lock, flags); ctlr->num_rx_desc = num_rx_desc; ctlr->num_tx_desc = ctlr->pool->num_desc - ctlr->num_rx_desc; + ret = cpdma_chan_split_pool(ctlr); + spin_unlock_irqrestore(&ctlr->lock, flags); + + return ret; } diff --git a/drivers/net/ethernet/ti/davinci_cpdma.h b/drivers/net/ethernet/ti/davinci_cpdma.h index aafa8889c789..df66b8c797ee 100644 --- a/drivers/net/ethernet/ti/davinci_cpdma.h +++ b/drivers/net/ethernet/ti/davinci_cpdma.h @@ -116,8 +116,7 @@ enum cpdma_control { int cpdma_control_get(struct cpdma_ctlr *ctlr, int control); int cpdma_control_set(struct cpdma_ctlr *ctlr, int control, int value); int cpdma_get_num_rx_descs(struct cpdma_ctlr *ctlr); -void cpdma_set_num_rx_descs(struct cpdma_ctlr *ctlr, int num_rx_desc); +int cpdma_set_num_rx_descs(struct cpdma_ctlr *ctlr, int num_rx_desc); int cpdma_get_num_tx_descs(struct cpdma_ctlr *ctlr); -int cpdma_chan_split_pool(struct cpdma_ctlr *ctlr); #endif From patchwork Sun Jun 30 17:23:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 168187 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp1959901ilk; Sun, 30 Jun 2019 10:24:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqzCbIQxSOvVH6NEqJ7SO0P8m4ciShMU1/xrZ8Yyr0gQ37dlDsSDeub9rvd0S8y6K/tEOjxx X-Received: by 2002:a65:55ca:: with SMTP id k10mr20330857pgs.14.1561915478396; Sun, 30 Jun 2019 10:24:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561915478; cv=none; d=google.com; s=arc-20160816; b=qFnWRi6uxdhKEhttaXQhpqsNzsDZP8XWHQ527ELUeVlfV0/jWd9QYOJHgDkHcsBvN9 GgzczOhTvEAPT82SGA0wadV/sNjh6iG3YSf47laz/qeFVVoMliyj4JXN0BlkWZG2WVkR EUfiEmF4bIAaUySupjr5y1NHdcmiyHdN4jgR0NGd3AQkprSYH8kRE+6GyegOn0Wt5ubw zeUgeLRvWAkgX0qg+Q9mlOlU0XSci0H3Zb4CziXjDDvpi2B4GfHUjTryCYCg3/yXBsIf gIUFqT9q31ilYCrxWg0sjPFwUf1qE4/qdomEnIS0CF4KomT0lFh0xJn4YgEc+LhuzyHI pReQ== 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=GFCzf2qYFkFg+4VKLMFV4Jixzxe0BQO8ulzJAgHRDlU=; b=rA2CCLWT6Cr7DhXU0KNOWjS9JyORnZHk/6hfKFZPQ5tH3BnS1jAnOk8BXlvx4mbB+Z VdURCYJ42gLe5i9SQsjXTebqHHWf7W1qMmBZFFn4QmL0dHEKlUnVkYiCenBrDk/pLt5b Xtm2fa6PCUdFsiJVt86fByXJ1k4lfQaD/Fs5ep1s7mJB9O0kTEFAVns/wIe1j429Tp9k kHQg8leb5vPBjEgCVye0f2gax8KFGkuEiKaf4BKTEEy1jGmZxwHxJRN5XzjZwRBDfHwY Nppaio7W1n6u/piDz+kEedAoWqXD3xNP3nvKguhSP7qfHbruZr5YoaZu/ElQ3zaAh7ax Kj5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lMX0Cm6L; 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 r24si7343977pgv.323.2019.06.30.10.24.38; Sun, 30 Jun 2019 10:24:38 -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=lMX0Cm6L; 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 S1727000AbfF3RY1 (ORCPT + 30 others); Sun, 30 Jun 2019 13:24:27 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:35960 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726879AbfF3RYZ (ORCPT ); Sun, 30 Jun 2019 13:24:25 -0400 Received: by mail-lj1-f194.google.com with SMTP id i21so10656790ljj.3 for ; Sun, 30 Jun 2019 10:24:24 -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=GFCzf2qYFkFg+4VKLMFV4Jixzxe0BQO8ulzJAgHRDlU=; b=lMX0Cm6LTzBuz+GHYDw0DNMsSrZKxRSBoVT4X7KPkCYaRNDNuqp58zcRnME8wwOcjL RTt9eCCiXyF3G1LNlJaXYWNpZrTmMep2KnZ+C6G/9mUT71kvIaW9TmW1evExUi3ndh0u ymN77nvvdUXy8MprSwEjZAwSsPAZpbuXv/Gzu7pZsFWin0Fd21ujRNcha+iY7eZeRn9e 9I3fRo5LQk9SI4Ob3706WeVB/gFYYUM8h3086qitcZrpEvB+DNhzEdYBnQh9fH+CDCi5 SgjSWD2j4sX0knHWGtdB5YSXRsyiDo9XAy/8Srqb2XlwX4MWfTkqzDCbRXcI/ACyZifP Cutg== 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=GFCzf2qYFkFg+4VKLMFV4Jixzxe0BQO8ulzJAgHRDlU=; b=M1h+TGXFw5cxTqzi2HGxOZebeIqjR523lO/A+2ydTzf5VoLWptpeEQc5fL/taD1VYm 8btkQNeokeBNdKgXMBs6cLXWAs7rlQRz71K1h554ttzfQ4sSW4CCXPgJU7jcdfTKS1UE EGcLyMPn8lPPVxAnht1wUEX0eqVUHfOStUagcPGNZN4WpdOz8daLV1nlkEW7nue105HE lYHBwllN4H/vQq2p5Sf5Z+nVocjD8DmXbwZU9e68hnr96eMXJ4kzrbZcps1oU9c9D/P9 sjKUPyr1eU1VR9ZHEcC7aT12mNuLzyNOaX+NPd7pGNGtaogqUOaDwGkc/bT77lVOd9v0 vj4A== X-Gm-Message-State: APjAAAVSdQ47xeEt1C48pSGOUzMXvkSWKvyNUcSnvAwBKbz39HhlLdEk 0t9Yw3MSoap/HCZqYBz+emH8iA== X-Received: by 2002:a2e:8849:: with SMTP id z9mr11396486ljj.203.1561915463532; Sun, 30 Jun 2019 10:24:23 -0700 (PDT) Received: from localhost.localdomain (59-201-94-178.pool.ukrtel.net. [178.94.201.59]) by smtp.gmail.com with ESMTPSA id c1sm2273795lfh.13.2019.06.30.10.24.22 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 30 Jun 2019 10:24:23 -0700 (PDT) From: Ivan Khoronzhuk To: grygorii.strashko@ti.com, hawk@kernel.org, davem@davemloft.net Cc: ast@kernel.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, xdp-newbies@vger.kernel.org, ilias.apalodimas@linaro.org, netdev@vger.kernel.org, daniel@iogearbox.net, jakub.kicinski@netronome.com, john.fastabend@gmail.com, Ivan Khoronzhuk Subject: [PATCH v5 net-next 5/6] net: ethernet: ti: cpsw_ethtool: allow res split while down Date: Sun, 30 Jun 2019 20:23:47 +0300 Message-Id: <20190630172348.5692-6-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190630172348.5692-1-ivan.khoronzhuk@linaro.org> References: <20190630172348.5692-1-ivan.khoronzhuk@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org That's possible to set channel num while interfaces are down. When interface gets up it should resplit budget. This resplit can happen after phy is up but only if speed is changed, so should be set before this, for this allow it to happen while changing number of channels, when interfaces are down. Signed-off-by: Ivan Khoronzhuk --- drivers/net/ethernet/ti/cpsw_ethtool.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) -- 2.17.1 diff --git a/drivers/net/ethernet/ti/cpsw_ethtool.c b/drivers/net/ethernet/ti/cpsw_ethtool.c index 6ab0cec8560a..99935c1d265d 100644 --- a/drivers/net/ethernet/ti/cpsw_ethtool.c +++ b/drivers/net/ethernet/ti/cpsw_ethtool.c @@ -620,8 +620,7 @@ int cpsw_set_channels_common(struct net_device *ndev, } } - if (cpsw->usage_count) - cpsw_split_res(cpsw); + cpsw_split_res(cpsw); ret = cpsw_resume_data_pass(ndev); if (!ret)