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,