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: 9452327 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6331D6071C for ; Tue, 29 Nov 2016 15:02:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5583A1FF27 for ; Tue, 29 Nov 2016 15:02:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 465E42838E; Tue, 29 Nov 2016 15:02:15 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 BD3AC1FF27 for ; Tue, 29 Nov 2016 15:02:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933757AbcK2PB4 (ORCPT ); Tue, 29 Nov 2016 10:01:56 -0500 Received: from mail-lf0-f54.google.com ([209.85.215.54]:36720 "EHLO mail-lf0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933733AbcK2PBa (ORCPT ); Tue, 29 Nov 2016 10:01:30 -0500 Received: by mail-lf0-f54.google.com with SMTP id t196so123868755lff.3 for ; Tue, 29 Nov 2016 07:01:29 -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=cEy9xp7fO37mA7ag2FKf+gNgl/wNWgAV7+FuOp+PGsORZB4+0PI8Gq9oPubkbiJU7P zUaP1ejF76H4q71+2T4Jgn7oYWhZYTGWmrrld2KC/EWNpTtg84gBqYTxy6cItCm28HUN EG9yErlMV6Cs7ciOeQtVqkizuOGjxOuQFD4t0z7hrNpduaT7naSSkxD8/Wfb7+403x8o rZl3j4h4ZAd4wN6oovZlNi1XlC2MMF/69QhMQX7ko1pIHSWxeXH7qiBMcTAucAEKBsBg Ya3pKb6lszbSSHokDyylIGd+u+4Lx3n6RGdMjJ6NSujE+tOzr6rt/U96xs4DBcxeRPl1 GzUQ== X-Gm-Message-State: AKaTC01fI5UbueH3IHy6sTadsT6gTMM1pL+G5VHN1vPRasD3JNHq9SsurqJ4zXe83NoOMkGX 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: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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) {