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: 11024535 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8C29E138B for ; Sun, 30 Jun 2019 17:24:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 70CEF28481 for ; Sun, 30 Jun 2019 17:24:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 64A9228500; Sun, 30 Jun 2019 17:24:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F39D528481 for ; Sun, 30 Jun 2019 17:24:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726830AbfF3RYv (ORCPT ); Sun, 30 Jun 2019 13:24:51 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:37646 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726835AbfF3RYY (ORCPT ); Sun, 30 Jun 2019 13:24:24 -0400 Received: by mail-lj1-f195.google.com with SMTP id 131so10640002ljf.4 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=AqyE8A+cZsqaO770rmQBr42xiyAOIYLl+x6rxv2kNj36r99K6Jeu4eHc0hPx3++ry+ pNNwLxWydJ/HAI7OhD9Jju7RBImGCtPXRJ+R2RmycY1sBeHNhTPFLmZDrT+Jtk3lEEIQ q/V8a+eJuVzAja5fzekNwRHvLjGPiRrfyWAQIUuekD1/paUiJGLXTqhKMfGQgOWWFufn d9o0v53ixT5AL48QccYoUuOQ+JS4BrUnpKwcntSbbiHeFvJJCRu1uYrxDYwqgvyyVl6q ucP+9pnM36VeqS2AlIFMsexqP/BlVwh13EtFk/8vQfGeBYM6ZbAqZ2w2dXK8Oy7mSITm tjlw== X-Gm-Message-State: APjAAAXuP2Ob41DmDpzfj/68iPdmKSf+utIfGCnWK8517XYfb4KUWrbE tdi8rtCyEo3PvatzpIfdgJ6HBA== X-Google-Smtp-Source: APXvYqwsL8R2TVbeV5aEhdmMQehA9L7CU1wJdpURGN5CoaeB4uTTKPZJDGH0IasikzP5ayeCPqfpow== 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-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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