Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp704351ybi; Wed, 3 Jul 2019 03:21:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqxyj5TftaxBss1QrL2r9PvsbiamckLQdwEg74NiRBiWo3eDfv1coHMQ+2KXddhQ2/5rG7Pt X-Received: by 2002:a63:4522:: with SMTP id s34mr51148pga.362.1562149306728; Wed, 03 Jul 2019 03:21:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562149306; cv=none; d=google.com; s=arc-20160816; b=LrNmNzYrE1zjjsD/djdD1VbG20gjagXPLDJib8pDHr9iRBKCQPPA0UZdcDDRJZWOPa iMAlnxqSpTtJUtKmuFzGkSKBJKKlb/U7OtKtqZexx1se5xWE+XGP6xNRLmEimMyUE7OK TRFR3TxD72KedYEfJQu23oYU5n+dsg7YpxvQ6fS4mk2YQj4IXvSd/oWk7FrxF6OTR32E cfTk7kn/8dsNJPWAPx94MN5zs7iIu9gvIQFgGEXGxfnuextQbytkOLdooR9RIYntJUh3 SjV1DtW9DDe5AHzxIzUmJiD5hdrzCo7hdrnVG3vNjERWS5amWwrNXNMBVHvYgbR1ha08 J30Q== 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=NO88iVnC5CJGavQX1+oifd5FyeZJrmYwPjjZG7dx1kY=; b=zaiPqVnMbFPS+YMhGRjaclP0AOOIeWf/qzo1VbXTdUoFg6rcJaFJzQRPqcYrSK4IKs NI8Ri0XtVDvfyucdPIjrRtxV8hib9hV05b4ZVnTLADiJ4JuEyeu+ssbZv5jiFR1znxC3 68UM+6HKhaYrPVsyjCa0gP8qJYcaT9ViR4MDR19ht6iKBut4r0Y/DxaFSHfSWVxlaldr upMMamzybdVAHZaDYMVAFzGa3gs8V0gVy7Pfcwh60LLOtOlruON690bJCtETlnBIAMdH FQyx3fe2XRvd4L2+WxLwx8pcgEamT+17iTIDhOv4dnDqIWTG7l4bkHu4y4aVQ6My41Bj OPBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xWYBTfuK; 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 j17si1870938pfa.198.2019.07.03.03.21.31; Wed, 03 Jul 2019 03:21:46 -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=xWYBTfuK; 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 S1727261AbfGCKTd (ORCPT + 99 others); Wed, 3 Jul 2019 06:19:33 -0400 Received: from mail-lf1-f46.google.com ([209.85.167.46]:37304 "EHLO mail-lf1-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727124AbfGCKTN (ORCPT ); Wed, 3 Jul 2019 06:19:13 -0400 Received: by mail-lf1-f46.google.com with SMTP id d11so1382291lfb.4 for ; Wed, 03 Jul 2019 03:19: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=NO88iVnC5CJGavQX1+oifd5FyeZJrmYwPjjZG7dx1kY=; b=xWYBTfuK3oxbaw2ihXoCR1u2W/q6BAnSu9cuBDvpQcBnRxJrqDr3icL3pTOdlndgs+ QXqo/j3RtvVa44pp6toHXNoIlGVhbRYMfCOW8QQO2ghQ06fy4ypjGdNgj7T9Gi5S4nOH fDFkAFjhlOlGDQMVULlWzD8KpUv90CS0+hkcx7poj8wdLN0h+GvIUWY7wWwFh/2e/zKZ Th5PGNeqgL0oopeVwiQuJfIXZrkJ/8ZHoOdgNR+0vdq+sL/bAraUeu0UcPNrBlJaB9XP 8/dgRutS7yeilCIy6OCRqECJt9lk/TMVy8V9XXmgTQE9iCu5K6dIjLmym3X+11dbFgqG 0OKw== 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=NO88iVnC5CJGavQX1+oifd5FyeZJrmYwPjjZG7dx1kY=; b=i0T4BWD2wGz7BBpIoFYzX2hIhmTlMmtlCRMbpee9cJ81ddzcFNvVi48c8TDF6u/Alk YxhJVX56gO/Bcuw6aBAm0HjE16niE9SonsXPwO0VyeW1jbTFuejfKBgLOKcnqPZHyMIM +F7Fsl1DSIN24vhAOIh3VhnJPZq3YS9k2Zd1MeHk5/mWtgzTqj3Nk2hm0yRUQ+fG0Kmn 3VK/YhJcHvp1JHJWwKAjOwChyrBc5IhaMtm/hyrtqtY/YhX+Jud3fFDXBFkm5ZYfrX1x Smp8u5IN3Jo1ilI8WAFzyGV6h6u1fkf/lExUKwALmUMkDAFAFVBgqpVt8Bx/UeXMfQeE /4Qw== X-Gm-Message-State: APjAAAUfuivDKUWaZ5ictPEhkwf+JfZPcxF68F5iyR47E7lJUsE0qrlZ 1yRSc/krBZA9btBjWp2vIM553A== X-Received: by 2002:ac2:419a:: with SMTP id z26mr14069127lfh.21.1562149150989; Wed, 03 Jul 2019 03:19: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 i9sm67267lfl.10.2019.07.03.03.19.09 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 03:19: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 v6 net-next 3/5] net: ethernet: ti: davinci_cpdma: allow desc split while down Date: Wed, 3 Jul 2019 13:19:01 +0300 Message-Id: <20190703101903.8411-4-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190703101903.8411-1-ivan.khoronzhuk@linaro.org> References: <20190703101903.8411-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(-) diff --git a/drivers/net/ethernet/ti/cpsw_ethtool.c b/drivers/net/ethernet/ti/cpsw_ethtool.c index f60dc1dfc443..08d7aaee8299 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 8da46394c0e7..4167b0b77c8e 100644 --- a/drivers/net/ethernet/ti/davinci_cpdma.c +++ b/drivers/net/ethernet/ti/davinci_cpdma.c @@ -1423,8 +1423,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 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 -- 2.17.1