From patchwork Wed Jun 19 07:57:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 167217 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp400655ilk; Wed, 19 Jun 2019 00:57:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqyJRj5rE3bI8HIC3kMOdqfTq5HK7yj94M+ejUWZrGgFcuMQRyMZp6I474vw5Q6723n91ONP X-Received: by 2002:a65:620d:: with SMTP id d13mr6686770pgv.109.1560931042630; Wed, 19 Jun 2019 00:57:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560931042; cv=none; d=google.com; s=arc-20160816; b=r9CELzqZOzOgyCWOV8ZAZolM18qkN530PV85rGsu242o89EbQH2FH/dfZrd1Oi9896 ZRFNGbDQBRwD6N1zzfi9HOfGd2Wkov/XScYv2stCs7hD0s6aHyxrTfeSoTUS2n9bx/3S 7oIbpFiGgLXII6m4Ih28H7uJBNi6PIHmiwwagBah0KPuFdLoEmq/S9GAF6/fK07FGLjq UKeKRRYphzYu4IQdQti5dOtAvsEUt2pnKM+7e1A5XBD214+tklfjwwod0qpp81gdfr8/ Isnh7CEkxowPHCY0WQTXId8KrjkSmKV8T9eXn/4ypIG1bSMobRfH1Wmbm92Jv0pHJkPY q4hQ== 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=bokJRGcKnRg+lYalbUGR/zo7jSchbb9EpVxMeRfuJ+8=; b=JGBhKBbmsSiI8o7orwJhTO/ApSAnfycm8tvyKZod5lDzNm0ZMWlEeBDb7i6Okgmnr8 PzAPS5fSPY3zeU4Hxh1Q7cnXnsvdKbR7miGrIx37x6iPKpJpaLBKlt2LhtQ+LrfJNcLD cufpdyL2vUuGAceKBTtL5Au8VjG0jVlwBPhLgbz4HphZaZv8i8VCsI0B/S3UM+zAltLi jJRnlTyUpgEz3ZdzOm4NO5+L9QZG1gbGJ1l76O6fsk1krNxsEYTz5JYN/TPe1gE2wOZ0 uijAENVcH96RgbXrHSUZx0zh7uYyC8JdJ0dPbbHM2yh6vWcOhs7Ma/eNFU4Sx/YUfxXT 2j1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=G5fWNCRW; 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 m24si2317921pgj.127.2019.06.19.00.57.22; Wed, 19 Jun 2019 00:57:22 -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=G5fWNCRW; 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 S1731280AbfFSH5U (ORCPT + 9 others); Wed, 19 Jun 2019 03:57:20 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:46027 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725946AbfFSH5U (ORCPT ); Wed, 19 Jun 2019 03:57:20 -0400 Received: by mail-wr1-f65.google.com with SMTP id f9so2189937wre.12 for ; Wed, 19 Jun 2019 00:57:18 -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=bokJRGcKnRg+lYalbUGR/zo7jSchbb9EpVxMeRfuJ+8=; b=G5fWNCRWNQVLQQBBasOMOCRIYXNe9mzu+YNFWyVwekahl/pQY7vkvSCJNHB0ItWPE8 J+HGhdTdp7I0rhWks5uk2bEYvBAIMKHNf5AC9Ahf+GnUX2EQ1P6ihKbAtx86p5jG8O9U NLd3kIelXNASuZnE0HZ1cgfnReAXL0hJQKY2wpn74bP0fOrf0LKrHSsYa2zpzKMKeCpS oI0ErGkALcdNuHzvIZtAk4I2rBUT6GzN/35yNcc06vnFo5LbmUO9aiWyptN4sqvH9j5M y2bUvIbH8xgbbcMPwpAH38GYx4HKdH1DvhlWsx6Q/xJMi8h6WVMsW6VuCsQTPQ13driU bDRg== 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=bokJRGcKnRg+lYalbUGR/zo7jSchbb9EpVxMeRfuJ+8=; b=l0Oy4sA12lrCfYubyEGl2FahCGzcJVQM7sC4R82HMNrdJlp9GpQFx38HcCQx7VbNL3 kfpcmhX9F59pQ5vmHMU1BdhmncCIyat5PW9hXmTpPmBR7mEQRMiXR/W4Z1nI8F5VFVb1 nzq8AUpKnH2kNB+4+4Mx9TLg1V8B5M8zxduAZDNcAslS15zWQnWT4uy67C0qSMUJN2/E R1tBKskUf+szC/jPrAJxhrymMU0mV3jjB/cv5r0AIthhVTjN4HCZN6/eLaKXLw2W6Prn b2R2ehJ0x8/FYb+AH8aCHTcnS3g8rLnZtqOcrn16/c+ZTXPX1EIkVsm3ldLGcZv6FBdv /Euw== X-Gm-Message-State: APjAAAWX+W3UNVBzRkO3i+Fyi32HPExluAE1lifpCIVpZmiLInKk6ElQ N/rNZTLLR94EfuYpd0/Gz7rfIw== X-Received: by 2002:adf:e446:: with SMTP id t6mr73214471wrm.115.1560931038107; Wed, 19 Jun 2019 00:57:18 -0700 (PDT) Received: from apalos.lan (athedsl-4461147.home.otenet.gr. [94.71.2.75]) by smtp.gmail.com with ESMTPSA id y133sm842572wmg.5.2019.06.19.00.57.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 19 Jun 2019 00:57:17 -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] net: netsec: initialize tx ring on ndo_open Date: Wed, 19 Jun 2019 10:57:13 +0300 Message-Id: <1560931034-6810-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 depend not 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 Fixes: 35e07d23473972b8876f98bcfc631ebcf779e870 ("net: socionext: remove mmio reads on Tx") Signed-off-by: Ilias Apalodimas --- drivers/net/ethernet/socionext/netsec.c | 32 ++++++++++++++----------- 1 file changed, 18 insertions(+), 14 deletions(-) -- 2.20.1 Acked-by: Ard Biesheuvel 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 07:57:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 167218 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp400694ilk; Wed, 19 Jun 2019 00:57:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqy9gmB/khBJ6VQ0+YwloHp3tb1PzbCJyBjotIc7jTe9M+4rt0a8R4Xq1BdIjPi1daM7kjiZ X-Received: by 2002:a63:5f16:: with SMTP id t22mr6416814pgb.156.1560931044839; Wed, 19 Jun 2019 00:57:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560931044; cv=none; d=google.com; s=arc-20160816; b=Am77m0G/nm0Lh8H+Dw9vK2CPzMG4teEonNygggzzgnjbEwKNLzq3xLRA9tb2ai4Thk FKPEADCF6Xwp6Ae/+5GUXF9vLE37NdO0fdugyLs+VlGGFeC9Zws0oxSruI3xWlfxP9P0 przZZGuo1Ydb8uy/vgGg2kGUiHVQgncao00LecQWncv8zdOO+mIPxtUeC7h4dlhmosHQ m+7IeLg9xFFfrfYJpTmmuidP2iWUatDrR3UN8S1wA4oPrgjY/cFZDCTdS7kMyHHVWU3E NUDfS60CUQoOBnvCdzsulXGpLiAcC1IcbiMW0DM+SZEwz9tgt6oD6TH5Sfgrw/CU61dk M6ig== 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=5dKyKaOwlavWxNSkxomQj1frz5OqSkhjLhkBVlvUo7s=; b=L+5ml6tvOFsBRoYtilYnJq8JMyMwCmu4veqRLGpeP71VjE+YHQX/cHO0uFcZ3MPnk8 juPA16yx46MDqEOh9wIJjZVYWGLrkYROJgQrIed832wJcmq4YOtwyNpu7pxN3hBrt+Tu 2t8NsNKy46e1SkQyAGHN/VFKLQYNuJ8UYWmik4nBTwOFfR8bDP/WNjrtwuJYjaDfK7Iy O/cQiFzPY407j0g88ESc/w67QHEPZLoAcBzeuCn4oKkqoTzr4AsiMCzEA75Ro1tVvvjv BoueJm8jl0k1l/cETHuoom9AgTNTKuGb0FAg+d3XzwcB48Ks+y5qk0mcky5D30ZSKyRK Xe5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ejK7Vcn9; 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 m24si2317921pgj.127.2019.06.19.00.57.24; Wed, 19 Jun 2019 00:57:24 -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=ejK7Vcn9; 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 S1731284AbfFSH5X (ORCPT + 9 others); Wed, 19 Jun 2019 03:57:23 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:39664 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731135AbfFSH5V (ORCPT ); Wed, 19 Jun 2019 03:57:21 -0400 Received: by mail-wr1-f67.google.com with SMTP id x4so2222549wrt.6 for ; Wed, 19 Jun 2019 00:57:20 -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=5dKyKaOwlavWxNSkxomQj1frz5OqSkhjLhkBVlvUo7s=; b=ejK7Vcn9eWef9XRwQvmw0FPGayQ+0xgjw6rLpse5J5EOiCfwH86gVbr23NxdAiAYAz eMD7JX0P6YlcM7qnACBvqdpu+yQEyetHWVoTwz4mWLVo7rvIH2DtSBrtdrAYABta595Z P1/ith7PGNoe+p6xnpQXwcX8upSBuw7wCDV/uV/ljf2hvrBztfpT7dc4sqA7m8TOmr5I P/obynNB9EymrZ8IfYL4d42BsiXNfINQTB52BRiTbAqmhng7zlGn/X4w7odwvb5Le5VO vEVBXxOq/Qgb7ng6V7+WzC5m9549f7JcUOoZrCy9rZATvTrvb4wfUpRChlQX5sxdcUmI sY9w== 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=5dKyKaOwlavWxNSkxomQj1frz5OqSkhjLhkBVlvUo7s=; b=CC0QvMNacouZTsXrqHsL2fcAP7UwoezAOTZlwjUImufzC0apCXdVTFD/dAJ0ZwYe3N HuzG487ehfZdKZr+FGOdKXIfzASG++rs60mxk3b2y7G+ootEVV9xwYFFsJshV1R26bHS 7BTHXsS02HvLZYqEiB7p/c9sbMowWFNa0qBwekNZ+oBAJELpJyZkvYRTOuA/nFeTM5IN mstz87BU77prFet1hXThY7jf+vKjaNRDmrdQaxnHs0xAgqEwUmJXj1oba7MgbkcqVMfu IGAwXMrBukWL07btjhill/aiQMqR/pHwomVBnS/7Sp9sNYXA1kKRZRWUOs08v7Ru6552 hYLw== X-Gm-Message-State: APjAAAXWxEMR9DjVsEehMKVUIHqVqwA201U6sSkYLMyzwzgMXRYjxbka t1zcIfl0oupeP9FzCEkIQ2q7NZc65vA= X-Received: by 2002:a5d:46ce:: with SMTP id g14mr28806425wrs.203.1560931039621; Wed, 19 Jun 2019 00:57:19 -0700 (PDT) Received: from apalos.lan (athedsl-4461147.home.otenet.gr. [94.71.2.75]) by smtp.gmail.com with ESMTPSA id y133sm842572wmg.5.2019.06.19.00.57.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 19 Jun 2019 00:57:18 -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] net: netsec: remove loops in napi Rx process Date: Wed, 19 Jun 2019 10:57:14 +0300 Message-Id: <1560931034-6810-2-git-send-email-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560931034-6810-1-git-send-email-ilias.apalodimas@linaro.org> References: <1560931034-6810-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 --- drivers/net/ethernet/socionext/netsec.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) -- 2.20.1 Acked-by: Ard Biesheuvel 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;