From patchwork Wed Jun 19 10:04:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 167220 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp518648ilk; Wed, 19 Jun 2019 03:04:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqwxa82KUHbWiuwmU6qFJwFtoWU43WF99kEKM73yPwxdtrjMJa11sROz/XSOGiJ6N0Yl8mgq X-Received: by 2002:a17:902:29c3:: with SMTP id h61mr83101540plb.37.1560938649480; Wed, 19 Jun 2019 03:04:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560938649; cv=none; d=google.com; s=arc-20160816; b=JFeoJOyBRCFK6Aw+Vf8rCKNuNi3cqSak9vuX04vOgMK820U+of7GtQ6nfKQa89sWkh FXZf9lJnF/uIleYLtZAxAPR69hrZqe48BJdf8/sQO2FfA77Wzyac6QYJ9HUPspzXJ7Ur KFph0nQk3woPUGqfK1fxz3kJtEt6soop663XeqeCQW9tVhOAfO9d2gF1NAaN7JV9CHeF rvBQjotffUPJAwEn1Cwy9mfB0d7IqvY9atzmnM0+9u/VD51hh7SruSXnUJOs0atNDnSu kKmhPS7JayYmTpUmR2FRcxHFa5nVnExb2scdQhcAHU6JL0+P4lugQxcFeYn2UTkIVHo4 dXpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=+U8s5zjt+68t+3zrCJ60IzWHDPnf4eGmiq3HaOOcocs=; b=UiejNfN4PZQ/F+/1K+ZnjL4Q85Y1x6o5g0HC3wM3SSCeeY+jyWQUZqNCH+uw8tY1Lj lbqHxAQdBf5aIw3KSQfPVZEjUM93p44p3amuFxdu81pW+XrdMN9enGlriGXRkzd54zDN byKYOrnEXQsTsSQBtYtG+i0fsSQ0OKnzvqRQhVhrLtONuGCqtp0TYoMqNbfgcE4HHTHB HpmN3NEVpc5hgkygV9aYFR7BlcCMd/4L7iP4R829BwZkgiFNlVd0mOk2SeXoroeUNUbb sDdJcoPzi39STpVyD7CZDrvfhXqYZ/mMIRJ3iUcLlgCwKKja2VIPKV4orsTApFbowfHY 0alQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O4di6Byu; 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 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 15si2666972pgz.466.2019.06.19.03.04.09; Wed, 19 Jun 2019 03:04:09 -0700 (PDT) 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 header.s=google header.b=O4di6Byu; 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 sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731482AbfFSKEI (ORCPT + 9 others); Wed, 19 Jun 2019 06:04:08 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:45174 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726479AbfFSKEH (ORCPT ); Wed, 19 Jun 2019 06:04:07 -0400 Received: by mail-wr1-f65.google.com with SMTP id f9so2647814wre.12 for ; Wed, 19 Jun 2019 03:04:05 -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; bh=+U8s5zjt+68t+3zrCJ60IzWHDPnf4eGmiq3HaOOcocs=; b=O4di6ByusizFJY+7WsmOchdwPMJatZzJZ/jaARxHWoSFDxSZMN0Ja6Ay0hxion8TTU MyLlnHVkOpW+6IjrAaivprSFe8h4NW07NUmpiLNS7qO9vVQVYh9LMw4FcUKe1wVflhjJ akWSXc/DvfWbfiX1firsXTTXuYft4AlwQoYv2YuZD4P7ZEZ4mUdJTu9bfVphcc1FZppj v/XvVm+JYY/PvePpy7YIMD3/5+BoXd+VIfhm42xGAUczBQujiAOBDZ48IM4Qa7ei35dn uc89YjbQj8KgMbMZRrSpRY3TSV+ock9xHDj3RyZoP/S5CWSz8y79jv/h7HlmI7ObaSIC mQTA== 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; bh=+U8s5zjt+68t+3zrCJ60IzWHDPnf4eGmiq3HaOOcocs=; b=iqLYzVBFvcbfjw1ylF81twd8hbIwtaMkTv/WaDJT60CFfqf+OIjYxkRwFAoF5vt8tz 1ww/PvN/b8wvkkHfoyw1bwxKtyiT6DmZgEnRHG8RZ2ZlWY0A6uiz0K5kDcx89QbQjza8 /Fc5+RV433S3SMx+ZVgEx7HKZ3Fn6LxZ0fuwpl1pNrPjng9fS/MAr5WlMhKesbkzkSb2 3v1lbi3RSVSnHMGMj0J3d1rAoQbYzYE5DAzGyOBvAkEdVMsa0MNGxAPmlsyqUXgLfVUE 9CoEVISi5vN3sviRwFN2cu7DrNc5itwKdGNOEzUJRT3Rf58UzfMK0u63KKDrQz9jzVbJ ++NA== X-Gm-Message-State: APjAAAWtOKyA2803NVZgvjIqi/53KccErSXRl0OHqZdTaOvsPnAvACk6 Y8m6qElDzQzxQ4slyt1mGs7jRA== X-Received: by 2002:adf:d4cc:: with SMTP id w12mr23299018wrk.121.1560938644712; Wed, 19 Jun 2019 03:04:04 -0700 (PDT) Received: from apalos.lan (athedsl-4461147.home.otenet.gr. [94.71.2.75]) by smtp.gmail.com with ESMTPSA id y184sm1197729wmg.14.2019.06.19.03.04.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 19 Jun 2019 03:04:03 -0700 (PDT) From: Ilias Apalodimas To: jaswinder.singh@linaro.org Cc: netdev@vger.kernel.org, ard.biesheuvel@linaro.org, masahisa.kojima@linaro.org, davem@davemloft.net, Ilias Apalodimas Subject: [net-next, PATCH 1/2, v2] net: netsec: initialize tx ring on ndo_open Date: Wed, 19 Jun 2019 13:04:00 +0300 Message-Id: <1560938641-16778-1-git-send-email-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Since we changed the Tx ring handling and now depends on bit31 to figure out the owner of the descriptor, we should initialize this every time the device goes down-up instead of doing it once on driver init. If the value is not correctly initialized the device won't have any available descriptors Changes since v1: - Typo fixes Fixes: 35e07d234739 ("net: socionext: remove mmio reads on Tx") Signed-off-by: Ilias Apalodimas Acked-by: Ard Biesheuvel --- drivers/net/ethernet/socionext/netsec.c | 32 ++++++++++++++----------- 1 file changed, 18 insertions(+), 14 deletions(-) -- 2.20.1 diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c index cba5881b2746..a10ef700f16d 100644 --- a/drivers/net/ethernet/socionext/netsec.c +++ b/drivers/net/ethernet/socionext/netsec.c @@ -1029,7 +1029,6 @@ static void netsec_free_dring(struct netsec_priv *priv, int id) static int netsec_alloc_dring(struct netsec_priv *priv, enum ring_id id) { struct netsec_desc_ring *dring = &priv->desc_ring[id]; - int i; dring->vaddr = dma_alloc_coherent(priv->dev, DESC_SZ * DESC_NUM, &dring->desc_dma, GFP_KERNEL); @@ -1040,19 +1039,6 @@ static int netsec_alloc_dring(struct netsec_priv *priv, enum ring_id id) if (!dring->desc) goto err; - if (id == NETSEC_RING_TX) { - for (i = 0; i < DESC_NUM; i++) { - struct netsec_de *de; - - de = dring->vaddr + (DESC_SZ * i); - /* de->attr is not going to be accessed by the NIC - * until netsec_set_tx_de() is called. - * No need for a dma_wmb() here - */ - de->attr = 1U << NETSEC_TX_SHIFT_OWN_FIELD; - } - } - return 0; err: netsec_free_dring(priv, id); @@ -1060,6 +1046,23 @@ static int netsec_alloc_dring(struct netsec_priv *priv, enum ring_id id) return -ENOMEM; } +static void netsec_setup_tx_dring(struct netsec_priv *priv) +{ + struct netsec_desc_ring *dring = &priv->desc_ring[NETSEC_RING_TX]; + int i; + + for (i = 0; i < DESC_NUM; i++) { + struct netsec_de *de; + + de = dring->vaddr + (DESC_SZ * i); + /* de->attr is not going to be accessed by the NIC + * until netsec_set_tx_de() is called. + * No need for a dma_wmb() here + */ + de->attr = 1U << NETSEC_TX_SHIFT_OWN_FIELD; + } +} + static int netsec_setup_rx_dring(struct netsec_priv *priv) { struct netsec_desc_ring *dring = &priv->desc_ring[NETSEC_RING_RX]; @@ -1361,6 +1364,7 @@ static int netsec_netdev_open(struct net_device *ndev) pm_runtime_get_sync(priv->dev); + netsec_setup_tx_dring(priv); ret = netsec_setup_rx_dring(priv); if (ret) { netif_err(priv, probe, priv->ndev, From patchwork Wed Jun 19 10:04:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 167221 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp518678ilk; Wed, 19 Jun 2019 03:04:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqygRZRz9HYRHSPAAo4UbEM0bZHRaUybePDMbIaHpDnmTDxmkmFQLWRRcdSZ5zKBgCMT1hg5 X-Received: by 2002:a17:902:42d:: with SMTP id 42mr113305755ple.228.1560938650996; Wed, 19 Jun 2019 03:04:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560938650; cv=none; d=google.com; s=arc-20160816; b=BG+Ss8i1xow1XxU5piT/qXjoEodtbWcnak2FzLKT7Pjsfelmkjhh1WnpRqByXQrbnj CjYzrVCKWcHVCThhG7l2J51DBdpnlHPYJd0lAmANhLQsd0zLSndVe86Vy4Mj6M3sJJ44 DXTQMjNyhLe+qM+i1G98bwDvkYm7FbLomheH1ddnApDl3v/ekQ2kwch1WWfuwXEAD5BH U18uuJZ6V3XrxSpLUcBoWKxWEL0b1jkNuNEOJ2f6LxwjM2Y6v3NTp1KFdlRqqnuDSqgY GMZgW1fW0BcRrrR+IUkDa/RkawBLO8SeImuLl5pbusjmhhgtnNSEzm9cvebbw1vcJdAm O7lA== 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=1fgMUEftCwlz2jZ0+44CQ5qx9KER8ZCjlEHRZ/xlXrU=; b=m/BfsXNSArhJ1+sRCftHuuD2N5vPhTVxrEBqgSW3X0CUJMezz0uLYSoagOZBWBChur Y6LujtNhQXnqSQIX0mrMVhcQkD490Qd+74I9UB79L696rcDP6RN5QS8cA14liUblD0Fw ajsc3RMVybwNMK8RjBht7tvdlaaeMT6C/k7af833znTau5dBNwK7nFPCBFMYdKDe63aF Gk5sdTyDQhaiWhDXK8IAn5af0JKBOHEqLuFzyffpqSKUVxp1PJIL3NgEp62dalGd76dr tmpdcAxSbkDMitvyinzkGcLI7O+VF2p+H8ZCtucIT8ipHc0MaY+KWRKK738+CqU94bSw wDhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ysaKDqsE; 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 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 15si2666972pgz.466.2019.06.19.03.04.10; Wed, 19 Jun 2019 03:04:10 -0700 (PDT) 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 header.s=google header.b=ysaKDqsE; 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 sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731521AbfFSKEK (ORCPT + 9 others); Wed, 19 Jun 2019 06:04:10 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:52837 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731423AbfFSKEI (ORCPT ); Wed, 19 Jun 2019 06:04:08 -0400 Received: by mail-wm1-f66.google.com with SMTP id s3so1071506wms.2 for ; Wed, 19 Jun 2019 03:04:07 -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=1fgMUEftCwlz2jZ0+44CQ5qx9KER8ZCjlEHRZ/xlXrU=; b=ysaKDqsE85Z9OLVRlsnTeHEsqvMt9Vowt+ZU0tZYZm6UTd4tJ01luhBv1NCKOIjB/a ygCyLg09asmsH71eodlG7dVF5LfdIj8BlSC/MEsMXopBkCEWmgNLMObZvAOfIi47aSMy HC1rHn2oCbxF1KA7A6JUfL/+X3Cbzyuoe+NJSWnNSvVHoaXu0pLcBuYwNpefzfD2lDOq Itw2czp+t4qK5J67/rHYiEYtA0O5W/8drLDT/Z4iXAkAXcVzT2yN3Kebq+5y9D+At89Z 2KtRd8MqjBdg7nem/U7gJ/jeK9sCggWOgUymRzzHKJab3jcYL8O94cgL1aJMy23SgXUF yBsQ== 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=1fgMUEftCwlz2jZ0+44CQ5qx9KER8ZCjlEHRZ/xlXrU=; b=UZtnEQD5/SWJ0m2CdWu1CW1+kPUDanylIR+inpe9LXnYSsQ6b8d+1F1oRkfk83kcjk NuewGwW9LSVr8VI7grbYesxdB9+lrQd2lmoMIr0zzDQdJVoEhSNlr4skLvOZlDIPyBd/ diUv8h+hoONyK70QeDKq408zMkM1jH6aHi/UrZT3jK7DEBrC/gQSEKkq2DXy+MC1d2tM 22+mj47Tj9NNMcY5swZ5lBjQk+iV4d98Qe+H1xorfjWn34UKJUTrRoAPJGpaVbebw59h l0JetKF7vLt3ExfOqlt4MPT5aJZhHdkrtspK/c+NzZxaJklVpaXjB2Cis2rPr/a3BQZT RkUQ== X-Gm-Message-State: APjAAAWrUmey/0rcReN+owIIGnK3/USIJZyHcK7z/XHbfrwmKPRaU5+Z nUsbad+n+BeCDXXMzy7lXRUiGEu/J9o= X-Received: by 2002:a1c:7d4e:: with SMTP id y75mr7614207wmc.169.1560938646440; Wed, 19 Jun 2019 03:04:06 -0700 (PDT) Received: from apalos.lan (athedsl-4461147.home.otenet.gr. [94.71.2.75]) by smtp.gmail.com with ESMTPSA id y184sm1197729wmg.14.2019.06.19.03.04.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 19 Jun 2019 03:04:05 -0700 (PDT) From: Ilias Apalodimas To: jaswinder.singh@linaro.org Cc: netdev@vger.kernel.org, ard.biesheuvel@linaro.org, masahisa.kojima@linaro.org, davem@davemloft.net, Ilias Apalodimas Subject: [net-next, PATCH 2/2, v2] net: netsec: remove loops in napi Rx process Date: Wed, 19 Jun 2019 13:04:01 +0300 Message-Id: <1560938641-16778-2-git-send-email-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560938641-16778-1-git-send-email-ilias.apalodimas@linaro.org> References: <1560938641-16778-1-git-send-email-ilias.apalodimas@linaro.org> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org netsec_process_rx was running in a loop trying to process as many packets as possible before re-enabling interrupts. With the recent DMA changes this is not needed anymore as we manage to consume all the budget without looping over the function. Since it has no performance penalty let's remove that and simplify the Rx path a bit Signed-off-by: Ilias Apalodimas Acked-by: Ard Biesheuvel --- drivers/net/ethernet/socionext/netsec.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) -- 2.20.1 diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c index a10ef700f16d..48fd7448b513 100644 --- a/drivers/net/ethernet/socionext/netsec.c +++ b/drivers/net/ethernet/socionext/netsec.c @@ -820,19 +820,12 @@ static int netsec_process_rx(struct netsec_priv *priv, int budget) static int netsec_napi_poll(struct napi_struct *napi, int budget) { struct netsec_priv *priv; - int rx, done, todo; + int done; priv = container_of(napi, struct netsec_priv, napi); netsec_process_tx(priv); - - todo = budget; - do { - rx = netsec_process_rx(priv, todo); - todo -= rx; - } while (rx); - - done = budget - todo; + done = netsec_process_rx(priv, budget); if (done < budget && napi_complete_done(napi, done)) { unsigned long flags;