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