From patchwork Tue Nov 29 15:00:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 84843 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp1632642qgi; Tue, 29 Nov 2016 07:02:12 -0800 (PST) X-Received: by 10.98.65.156 with SMTP id g28mr28143678pfd.110.1480431732139; Tue, 29 Nov 2016 07:02:12 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s77si60198828pfa.20.2016.11.29.07.02.12; Tue, 29 Nov 2016 07:02:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of netdev-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; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933945AbcK2PB5 (ORCPT + 5 others); Tue, 29 Nov 2016 10:01:57 -0500 Received: from mail-lf0-f44.google.com ([209.85.215.44]:32861 "EHLO mail-lf0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933943AbcK2PBf (ORCPT ); Tue, 29 Nov 2016 10:01:35 -0500 Received: by mail-lf0-f44.google.com with SMTP id c13so123488957lfg.0 for ; Tue, 29 Nov 2016 07:01:34 -0800 (PST) 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=ugC+RA2EBBAO2Xi6Oi9SegSQA4IsdnkNSJZ/qiR7oJg=; b=bh0KQrfQLjn6SnLZQyWPg+4oJ/P/8C7bcKA+LwVio+/lWiUEWiHBcS/KpvDdosSjkb BtuktGI/vrFq1m816HhHiXlWyGMRJ9JhbAlrocY3Nsdah/G0IkaGBHTb8QlA8fryYBhP soajt2KyAn+VL+TCP8+CwytxoS6GQzK9T0oBQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ugC+RA2EBBAO2Xi6Oi9SegSQA4IsdnkNSJZ/qiR7oJg=; b=lAuC9zbQILmxnqrk6n6QYwGyY1CJn+GsTrrPGJFz7405+lgU23Gnu7INCDmfZIBy9a 5ctDTS6v2mE8LwMGbKxuvCz0eT9O1Vb3pEpT08IQcmvuDs4GzurNTVc3N+YkOYnFgERN 18Jpcl+h0ULoYTrFrKNsHqnurymoD7mOa9wxZY7WHwJR3jS6yN/lVvYFjh4Tb+NlxwRG SNe7zwPmbyku8A9YX0gOlQk5pE6cN9lLmp2y7aSZjfXsuvxz6Qolbch1VqgBsUXsTel5 dIB2XZ4hrrCDB7Dy3M2kHhQ+DGwnHPg1jRhrlcBwdTflhudz6BPFk0Rb3yYu4UT/2H7X 1oSQ== X-Gm-Message-State: AKaTC01KQtRzfJ6iK04fNPWCip4NRlqOhaX4oM5UySxVfmB7Dufkrjtt8yBYSwSZpXa72G3W X-Received: by 10.46.74.26 with SMTP id x26mr8879681lja.51.1480431683718; Tue, 29 Nov 2016 07:01:23 -0800 (PST) Received: from localhost.localdomain (183-224-132-95.pool.ukrtel.net. [95.132.224.183]) by smtp.gmail.com with ESMTPSA id c78sm9663673lfc.39.2016.11.29.07.01.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 Nov 2016 07:01:23 -0800 (PST) From: Ivan Khoronzhuk To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, mugunthanvnm@ti.com, grygorii.strashko@ti.com Cc: linux-omap@vger.kernel.org, Ivan Khoronzhuk Subject: [PATCH 4/5] net: ethernet: ti: cpsw: optimize end of poll cycle Date: Tue, 29 Nov 2016 17:00:50 +0200 Message-Id: <1480431651-6081-5-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1480431651-6081-1-git-send-email-ivan.khoronzhuk@linaro.org> References: <1480431651-6081-1-git-send-email-ivan.khoronzhuk@linaro.org> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Check budget fullness only after it's updated and update channel mask only once to keep budget balance between channels. It's also needed for farther changes. Signed-off-by: Ivan Khoronzhuk --- drivers/net/ethernet/ti/cpsw.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) -- 2.7.4 diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index c102675..8a70298 100644 --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c @@ -788,19 +788,13 @@ static int cpsw_tx_poll(struct napi_struct *napi_tx, int budget) /* process every unprocessed channel */ ch_map = cpdma_ctrl_txchs_state(cpsw->dma); - for (ch = 0, num_tx = 0; num_tx < budget; ch_map >>= 1, ch++) { - if (!ch_map) { - ch_map = cpdma_ctrl_txchs_state(cpsw->dma); - if (!ch_map) - break; - - ch = 0; - } - + for (ch = 0, num_tx = 0; ch_map; ch_map >>= 1, ch++) { if (!(ch_map & 0x01)) continue; num_tx += cpdma_chan_process(cpsw->txch[ch], budget - num_tx); + if (num_tx >= budget) + break; } if (num_tx < budget) { @@ -823,19 +817,13 @@ static int cpsw_rx_poll(struct napi_struct *napi_rx, int budget) /* process every unprocessed channel */ ch_map = cpdma_ctrl_rxchs_state(cpsw->dma); - for (ch = 0, num_rx = 0; num_rx < budget; ch_map >>= 1, ch++) { - if (!ch_map) { - ch_map = cpdma_ctrl_rxchs_state(cpsw->dma); - if (!ch_map) - break; - - ch = 0; - } - + for (ch = 0, num_rx = 0; ch_map; ch_map >>= 1, ch++) { if (!(ch_map & 0x01)) continue; num_rx += cpdma_chan_process(cpsw->rxch[ch], budget - num_rx); + if (num_rx >= budget) + break; } if (num_rx < budget) {