From patchwork Fri Jul 5 15:05:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 168541 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp3692194ilk; Fri, 5 Jul 2019 08:05:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqwHWQaISsheehu2Vrr3eY2KWH30KrEPP8b8T7UQIlD7gMixjwsY93KJWKBdefUYDaX73jUK X-Received: by 2002:a17:90a:7f85:: with SMTP id m5mr6215624pjl.78.1562339116152; Fri, 05 Jul 2019 08:05:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562339116; cv=none; d=google.com; s=arc-20160816; b=Q/6cZ2Xj+hfk81TCeFPRRcddntH4KIl92y6Cqf9fhDf4XkocrEchdJSjZ7Pqe2R4W7 /tSobQTJCdByQWnny1bvqcRuUhLeK3BRuOOyULydLXosBnnmB2w3Rl2r+fW7iX/pDqno iTt/IT2idm8yny0B1rPXF9IgEEDweldFKxkkGyac4udRc+8XD3nEJjeOsRD77d7SDb+i yzguv59DFongFWmGR7fkMujm+unkCvfyRgNWVOj6UQ9FqDkYg7SisKWPjCrN9yM5weTg USvCxUWefH55qFl8YH+fS4ApVWjlxXuYxJ4zykwqLKnAd9HglmDbuIxXu6nbkqwt3X5i qMJg== 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=3MKWFq9DHUtTXp9RzrqM9cpDCCIlrZafhvrB3JiYBHI=; b=yoWfHHG8e/u3OLu3WatDViU1kx0Y4wilLB0nMR7K+gHKndXLWYvAi3MOPLbD3DfZnI YjxJtCm7op25TkL4ovuuPUg/PZ47xenIgkMyYqyTBX8OL1NLCVtV2bwWQ1sbzTY7Yufj CpNSnqIatR0puK6rNj6Z1OcKdylG/UBAVdD5SpcFY8oTJGI5Waqav5Y9uwajX8+uiOH3 q6lTuxbIDc8scsadU4HzXZNIPN4LuLcdM07JiEgR+/uBSjTENEYj9vOI3/k6wQ/wB/9w G+UiLvHJoYo2BzQRt+9Hl5mkls89xYfw381yZp5yx1vxQqhbs5clRTRI3uMCu/S+1IeX 2QZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xyvsBDpH; 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=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 k3si7626348pjt.103.2019.07.05.08.05.15; Fri, 05 Jul 2019 08:05:16 -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=pass header.i=@linaro.org header.s=google header.b=xyvsBDpH; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727717AbfGEPFO (ORCPT + 5 others); Fri, 5 Jul 2019 11:05:14 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:33655 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727663AbfGEPFM (ORCPT ); Fri, 5 Jul 2019 11:05:12 -0400 Received: by mail-lj1-f195.google.com with SMTP id h10so9592801ljg.0 for ; Fri, 05 Jul 2019 08:05:10 -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=3MKWFq9DHUtTXp9RzrqM9cpDCCIlrZafhvrB3JiYBHI=; b=xyvsBDpHC1EZ2dWvSDA7okDtJU8c+RYRWvLbfE6yTRUaRRPTeMx4naijBhc1gORYBB fqdWq7A4JFUU/wg6qPHgari2TlXnujB97hM6gGjY9uRNSnKE3DASyEnY+PcghuM4LxeS uxg3pFkhfafUBbPn9ybRasj+SKZpSafJKQtuprX2VQe5LNP2FoBNFBSB72e53SCevH54 o1YOQlp++pyanvB+mbRD9wbCSAs8T59Q2MOM0g0b7uSPxVgzGTQPtbMSEAEwteBb84Ke TjQE87Vma0iBWrx672Jg9bHwyDPLi4EiuZX6A7snuUiaOOACOncLlzvSB3BYPwgz7CEn bfmg== 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=3MKWFq9DHUtTXp9RzrqM9cpDCCIlrZafhvrB3JiYBHI=; b=IUomSExlahnNqB2zWj0lVlK313Bh1q3BtFsNYKJ7A/juGLKvU+TcBd067xmItMzZa7 0HHi2IsBdBuFilUMd5RkQxMXAo30+RDztK+j56UseW8l/Z04qaTVLrR0wZK84jtFH+u7 Vbp1PKFSYivStO8inN2sgPtjxt2e0n71BUG72mJNrRxwqu5W2E81HYFKzwVkZZjoB11H WRgq4fa4iN7BLnB3n3BM/gMbMi4tDdyF0SqWBTEN9u/QqKvm205ZlGqZT2lCW6XNbAzH qpGauP1M7gJrm7kI8LJZj0fMPET2wb9lYQ62jYJJiCBBAvLPQnxQVbljDz+9zT02GX2D xUMQ== X-Gm-Message-State: APjAAAUMVAGEO37WAf2kUwqDxSxhoaX8o0wstdi9x0rYGu0VAZVYiWdF PiWkhimFcM5bk2bkUW85NtEH9w== X-Received: by 2002:a2e:5c09:: with SMTP id q9mr2499358ljb.120.1562339109281; Fri, 05 Jul 2019 08:05:09 -0700 (PDT) Received: from localhost.localdomain (59-201-94-178.pool.ukrtel.net. [178.94.201.59]) by smtp.gmail.com with ESMTPSA id y4sm1433660lfc.56.2019.07.05.08.05.08 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 05 Jul 2019 08:05:08 -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 v8 net-next 3/5] net: ethernet: ti: davinci_cpdma: allow desc split while down Date: Fri, 5 Jul 2019 18:05:00 +0300 Message-Id: <20190705150502.6600-4-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190705150502.6600-1-ivan.khoronzhuk@linaro.org> References: <20190705150502.6600-1-ivan.khoronzhuk@linaro.org> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@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 | 17 +++++++++++------ drivers/net/ethernet/ti/davinci_cpdma.c | 17 ++++++++++++++++- drivers/net/ethernet/ti/davinci_cpdma.h | 3 +-- 3 files changed, 28 insertions(+), 9 deletions(-) -- 2.17.1 diff --git a/drivers/net/ethernet/ti/cpsw_ethtool.c b/drivers/net/ethernet/ti/cpsw_ethtool.c index f60dc1dfc443..c477e6b620d6 100644 --- a/drivers/net/ethernet/ti/cpsw_ethtool.c +++ b/drivers/net/ethernet/ti/cpsw_ethtool.c @@ -650,7 +650,7 @@ int cpsw_set_ringparam(struct net_device *ndev, { struct cpsw_priv *priv = netdev_priv(ndev); struct cpsw_common *cpsw = priv->cpsw; - int ret; + int descs_num, ret; /* ignore ering->tx_pending - only rx_pending adjustment is supported */ @@ -659,20 +659,25 @@ int cpsw_set_ringparam(struct net_device *ndev, ering->rx_pending > (cpsw->descs_pool_size - CPSW_MAX_QUEUES)) return -EINVAL; - if (ering->rx_pending == cpdma_get_num_rx_descs(cpsw->dma)) + descs_num = cpdma_get_num_rx_descs(cpsw->dma); + if (ering->rx_pending == descs_num) return 0; cpsw_suspend_data_pass(ndev); - cpdma_set_num_rx_descs(cpsw->dma, ering->rx_pending); + ret = cpdma_set_num_rx_descs(cpsw->dma, ering->rx_pending); + if (ret) { + if (cpsw_resume_data_pass(ndev)) + goto err; - if (cpsw->usage_count) - cpdma_chan_split_pool(cpsw->dma); + return ret; + } ret = cpsw_resume_data_pass(ndev); if (!ret) return 0; - +err: + cpdma_set_num_rx_descs(cpsw->dma, descs_num); 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 8da46394c0e7..a3b6aeb4e935 100644 --- a/drivers/net/ethernet/ti/davinci_cpdma.c +++ b/drivers/net/ethernet/ti/davinci_cpdma.c @@ -1423,8 +1423,23 @@ 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 temp, ret; + + spin_lock_irqsave(&ctlr->lock, flags); + + temp = ctlr->num_rx_desc; 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); + if (ret) { + ctlr->num_rx_desc = temp; + ctlr->num_tx_desc = ctlr->pool->num_desc - ctlr->num_rx_desc; + } + + 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 0271a20c2e09..d3cfe234d16a 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 Fri Jul 5 15:05:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 168543 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp3692432ilk; Fri, 5 Jul 2019 08:05:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqwga3yw8GQSR4BFiZTEuU6jaqX8DUzuptPlCmPo7MvUEiwnNbAYB63B2wKLQjPy8QIUWIty X-Received: by 2002:a65:664f:: with SMTP id z15mr6284239pgv.344.1562339127493; Fri, 05 Jul 2019 08:05:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562339127; cv=none; d=google.com; s=arc-20160816; b=tcaGAe295u0TguGDu1waeEWhdaVTyW9/NsMIZCpYUj3KW7cbJW5cZSBdFbQC1a1P6i xMiUqu2d7u7UFQ8P7saeSV7vGE8qxD7byd3YwIpYRUju7EzEuFL0MPtW5M41av40+KrE 2576Y09xeawMEschRvjB/Aaeo8e1wdpFLzkkcaYBRMXXfCAsT4ffS0N5+Kyda9YDkKSs /S4LxWEkOD3M+QlgG1G1HqTcMKx9OHyPK4rRifn+LeRp1e0Erqh6Y4nbN9KD5FOZ8kOw 8QxUENouLFbGUrRs7PyL18PAi1y1vfNMVwMm/RaQKPAJOv64cuWOa6RcIUyFNdMD/0d7 uqmw== 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=h0qJMdNciD39g3Q1jo3+1MbbNG9llP7wamgm8+ijc+0=; b=pl/a+6WfGV5WlgTeZ1KHzWoZscZLrdCx4BHk1UiKw2thS13SM5QunP3L6MPVkjRaSC 1IzLKDV+LoNCOuXhu30v0Fnbojnux6iiuTAPtptDFk6Dz4kPGMlNTlJ+rbPwWxG8Aooh JlvcAG6rJpzME0+AAWfgT4jDL29YPWGOMiRz88T8AafOiuEqry8AOmd8VZH7FNScMMbP gHFae3Bh5V1i7b8q3tiB+CE0KoqSYac72+czhUKPpNyzYaHhukUrYGtx/QsA9mMKExNZ R0M0im0H31MqukEKiQUwudDXe4WhMlxS+29kPeg128sDJu0KRUE32WQm2e2Kwv6v9G9g 78kQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oDfE98kP; 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=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 c9si9490272pgp.72.2019.07.05.08.05.26; Fri, 05 Jul 2019 08:05:27 -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=pass header.i=@linaro.org header.s=google header.b=oDfE98kP; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727727AbfGEPFP (ORCPT + 5 others); Fri, 5 Jul 2019 11:05:15 -0400 Received: from mail-lf1-f49.google.com ([209.85.167.49]:34619 "EHLO mail-lf1-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727675AbfGEPFM (ORCPT ); Fri, 5 Jul 2019 11:05:12 -0400 Received: by mail-lf1-f49.google.com with SMTP id b29so6576612lfq.1 for ; Fri, 05 Jul 2019 08:05: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=h0qJMdNciD39g3Q1jo3+1MbbNG9llP7wamgm8+ijc+0=; b=oDfE98kPmAv8olG5EU/cTLrPDhDZJWfBTXlVneiTLeFEQ9KVnwf7eKt2hlFFPocvxy uUe6nfw3ViFwp6yvmIysmpnO+k9Wu4fTfhs3b2tq6dQfOoYCsExy7L4KNXeqdLhAdPB+ 1TD/0Ae8V6EAMs6Bp058Iot84/ZdoxMc4KMgSAsQU52JUMJJXwvWaGJClgWF6teMbUBo uxIthothA0rkhAtBjhsvVdG0aikqWxw7xh3yzReaMfq/gpNokRVaTVAT2x/zMcsjRGHC 9G5We3AuyDNiOJXRYSYb0VMqaQpmIp1a2feZzkvQOtBADs5UthlrQM8CmV6gNxnsdfwn h3sA== 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=h0qJMdNciD39g3Q1jo3+1MbbNG9llP7wamgm8+ijc+0=; b=oxoDjBZboorAmBtk7O7SJY2hRQHhxbJigCgVCxkj8g6JlXUADiuftNpvs6Y3pTdUaE Yj8xVqIeM2LVk5eM0ShRKY0xyiKnYBCBVZjiwgiQuep0+Il96bmTQIxof5M3yt+ogFH7 9A+9Y2U7HQ3p5zmfXTpvMPA8ML97QghzwP+E6YOdANVDcIZeyUp0iH6FWlROxl9A7qQr ribScx00lRYfpc9oe7bCi85mAqi0+O68DFyL7gcO+ZetZQQk2WqImuUpPju41mHUoxWI TZDU2kiZDJwZM5qMU4M/SjbzNFa076Xdj4GvjSihPj8JKQ9Gr2TdZsdJdahKMqdErU+f X5Gg== X-Gm-Message-State: APjAAAUn+HUs/g/aSFpzdWJr3YQ60b/E/XQnhjCyFOuqLiM99q1bivB3 9CHDlKEue29QIAAmJmhzNdunYA== X-Received: by 2002:ac2:5c42:: with SMTP id s2mr2285518lfp.61.1562339110625; Fri, 05 Jul 2019 08:05: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 y4sm1433660lfc.56.2019.07.05.08.05.09 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 05 Jul 2019 08:05:10 -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 v8 net-next 4/5] net: ethernet: ti: cpsw_ethtool: allow res split while down Date: Fri, 5 Jul 2019 18:05:01 +0300 Message-Id: <20190705150502.6600-5-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190705150502.6600-1-ivan.khoronzhuk@linaro.org> References: <20190705150502.6600-1-ivan.khoronzhuk@linaro.org> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@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 c477e6b620d6..e4d7185fde49 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)