From patchwork Thu Nov 8 15:19:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 150528 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp946780ljp; Thu, 8 Nov 2018 07:20:05 -0800 (PST) X-Google-Smtp-Source: AJdET5dPyTP+UTBmA96xvBpHjD9fEGBAId1a9OFrnFmIdTZh4ubmMjZ2nYusN2L4QnUJk7xFkCzL X-Received: by 2002:a17:902:b093:: with SMTP id p19-v6mr5042320plr.107.1541690405851; Thu, 08 Nov 2018 07:20:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541690405; cv=none; d=google.com; s=arc-20160816; b=LO8i4dXFGibmxhB9JdkKvJsdAZFnXiR0fyD8z9wMmRFVIj9w0S4YLllyqx9LJ0zBda wCm6ya7nTbmsX5wjtuVn2U5FLEtOUWwySWCacqiUwmmGIwEt5inZxCeHsR2WmNSRWCTU Kw3EkY8obnD2c/0bzQU6pfPFJu36ul16pRp00u2gthORNZ4iz83vmipOohHSf8lpH0v9 ZlVORID4le3RPHxU5SyUyzHEbZk6MNxxzxdLXsmGTDUZuzLqs7QtAVpFV3UIDtepDuGG 88ZqBTYid9IK/Q2c/zTzKaxI8vMkZuTkCiHL9Bteol3KnWWTCe0yhU7irTR/ck3hiFVK BZ2Q== 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=3zsgd+CtHMTwOWR1dpt9Nr8IaScl002XXeEHX+BT7eo=; b=wMpgnYDmHxcqFc47YuumUd2cNAjcGS1ghHiwQpvzyRMdEjSwRlxUPiGKAIJ/ojJqzQ xQWMFhuCCbEVDpuVbSe+TA72M5cD4gfLyRdAH/syWbYM9FT9cTaZkO+WojAaxFPcgDvs 8JXnJIaOzkoqUddDiXbV0c7dtu+BZa5pFS+qjjRU6rOspjZm1P2h/AwpvvkcycKNZfaE lxEUu4kbrVXoB9pxu6aziQWzc1a2HHKRwerJXE8V+ecEVhVlijZ5ZtLMOmsgQVED0nLm /X3jPFQb7x8UyClGUP40rON/s/fWhpTs3lzicnxtU5VskupeFMpFfbnYB6/L0HEqh1aG qBdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KsvtNnr5; 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 v4-v6si4319717plz.250.2018.11.08.07.20.05; Thu, 08 Nov 2018 07:20:05 -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 header.s=google header.b=KsvtNnr5; 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 S1727223AbeKIA4B (ORCPT + 10 others); Thu, 8 Nov 2018 19:56:01 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:39174 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726627AbeKIA4B (ORCPT ); Thu, 8 Nov 2018 19:56:01 -0500 Received: by mail-wm1-f66.google.com with SMTP id u13-v6so1562232wmc.4 for ; Thu, 08 Nov 2018 07:20:01 -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; bh=3zsgd+CtHMTwOWR1dpt9Nr8IaScl002XXeEHX+BT7eo=; b=KsvtNnr5CfFxxLLJ0fARBWH3aQxUjS3s7uboXfdeNwM8h3JUaZ0DzY2L8UCmeLPZSs UfEyHxtrUY3GvbHz0tTeTZAJOXqyxb4X8nm9LRGgraJ6+Ne7dxx88jKrN5Oj8GXyRRH5 YrKSfpIr9/BAU/rvgInXNCqKZigxr3U8zZCc0= 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=3zsgd+CtHMTwOWR1dpt9Nr8IaScl002XXeEHX+BT7eo=; b=XcetIicABQEOIZYVMB1R0CVC/fAVR61eIiZapOAfDTvw8eabCgRUmnDjZJTYVxjnCQ +zo9MDEbbKVVPusUfYiVJWYt6WOm0ZpwpAGUVYiCp8jHLzJBR5fOGKx0sLo1ImOO1TS+ x6QGa6oqtDj6aWoybiGK4gGfPcXj0zqsrNGts/XLwww9oo0Gt0bjrTvS3HGhgn/UODVe LXvZHv24EA39f+4vxdOJMzloUfJ+K+zOBBv6yJiPq1bGT7Aa7fAs+DY0QoYID+FRjwSu yJs3w1GBSMLtmpaeqHID/tfz6o7wTHpWtKDhXDk0iYyy1CHgtRSxqBkJKIQcQsNQgIp/ FGEg== X-Gm-Message-State: AGRZ1gLneVNMNGjd4VkO4O2oaewVtsUY2F/gWR/esVJWpG3PA6nV79IL JPMZn6F+klyLX0usOo8mUmFi+7PHGwTb6w== X-Received: by 2002:a1c:6754:: with SMTP id b81-v6mr1622643wmc.104.1541690399710; Thu, 08 Nov 2018 07:19:59 -0800 (PST) Received: from apalos.lan (ppp-94-65-93-8.home.otenet.gr. [94.65.93.8]) by smtp.gmail.com with ESMTPSA id x139-v6sm2937764wme.3.2018.11.08.07.19.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 08 Nov 2018 07:19:58 -0800 (PST) From: Ilias Apalodimas To: netdev@vger.kernel.org, jaswinder.singh@linaro.org, ard.biesheuvel@linaro.org Cc: masami.hiramatsu@linaro.org, masahisa.kojima@linaro.org, brouer@redhat.com, arnd@arndb.de, Ilias Apalodimas Subject: [net-next, PATCH 1/2] net: socionext: different approach on DMA Date: Thu, 8 Nov 2018 17:19:54 +0200 Message-Id: <1541690395-8337-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 Current driver dynamically allocates an skb and maps it as DMA Rx buffer. In order to prepare for upcoming XDP changes, let's introduce a different allocation scheme. Buffers are allocated dynamically and mapped into hardware. During the Rx operation the driver uses build_skb() to produce the necessary buffers for the network stack. This change increases performance ~15% on 64b packets with smmu disabled and ~5% with smmu enabled Signed-off-by: Ilias Apalodimas --- drivers/net/ethernet/socionext/netsec.c | 227 ++++++++++++++++++-------------- 1 file changed, 128 insertions(+), 99 deletions(-) -- 2.7.4 diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c index d9d0d03..9d24f29 100644 --- a/drivers/net/ethernet/socionext/netsec.c +++ b/drivers/net/ethernet/socionext/netsec.c @@ -234,6 +234,9 @@ #define DESC_NUM 256 +#define NETSEC_SKB_PAD (NET_SKB_PAD + NET_IP_ALIGN) +#define NETSEC_RX_BUF_SZ 1536 + #define DESC_SZ sizeof(struct netsec_de) #define NETSEC_F_NETSEC_VER_MAJOR_NUM(x) ((x) & 0xffff0000) @@ -571,34 +574,10 @@ static const struct ethtool_ops netsec_ethtool_ops = { /************* NETDEV_OPS FOLLOW *************/ -static struct sk_buff *netsec_alloc_skb(struct netsec_priv *priv, - struct netsec_desc *desc) -{ - struct sk_buff *skb; - - if (device_get_dma_attr(priv->dev) == DEV_DMA_COHERENT) { - skb = netdev_alloc_skb_ip_align(priv->ndev, desc->len); - } else { - desc->len = L1_CACHE_ALIGN(desc->len); - skb = netdev_alloc_skb(priv->ndev, desc->len); - } - if (!skb) - return NULL; - - desc->addr = skb->data; - desc->dma_addr = dma_map_single(priv->dev, desc->addr, desc->len, - DMA_FROM_DEVICE); - if (dma_mapping_error(priv->dev, desc->dma_addr)) { - dev_kfree_skb_any(skb); - return NULL; - } - return skb; -} static void netsec_set_rx_de(struct netsec_priv *priv, struct netsec_desc_ring *dring, u16 idx, - const struct netsec_desc *desc, - struct sk_buff *skb) + const struct netsec_desc *desc) { struct netsec_de *de = dring->vaddr + DESC_SZ * idx; u32 attr = (1 << NETSEC_RX_PKT_OWN_FIELD) | @@ -617,59 +596,6 @@ static void netsec_set_rx_de(struct netsec_priv *priv, dring->desc[idx].dma_addr = desc->dma_addr; dring->desc[idx].addr = desc->addr; dring->desc[idx].len = desc->len; - dring->desc[idx].skb = skb; -} - -static struct sk_buff *netsec_get_rx_de(struct netsec_priv *priv, - struct netsec_desc_ring *dring, - u16 idx, - struct netsec_rx_pkt_info *rxpi, - struct netsec_desc *desc, u16 *len) -{ - struct netsec_de de = {}; - - memcpy(&de, dring->vaddr + DESC_SZ * idx, DESC_SZ); - - *len = de.buf_len_info >> 16; - - rxpi->err_flag = (de.attr >> NETSEC_RX_PKT_ER_FIELD) & 1; - rxpi->rx_cksum_result = (de.attr >> NETSEC_RX_PKT_CO_FIELD) & 3; - rxpi->err_code = (de.attr >> NETSEC_RX_PKT_ERR_FIELD) & - NETSEC_RX_PKT_ERR_MASK; - *desc = dring->desc[idx]; - return desc->skb; -} - -static struct sk_buff *netsec_get_rx_pkt_data(struct netsec_priv *priv, - struct netsec_rx_pkt_info *rxpi, - struct netsec_desc *desc, - u16 *len) -{ - struct netsec_desc_ring *dring = &priv->desc_ring[NETSEC_RING_RX]; - struct sk_buff *tmp_skb, *skb = NULL; - struct netsec_desc td; - int tail; - - *rxpi = (struct netsec_rx_pkt_info){}; - - td.len = priv->ndev->mtu + 22; - - tmp_skb = netsec_alloc_skb(priv, &td); - - tail = dring->tail; - - if (!tmp_skb) { - netsec_set_rx_de(priv, dring, tail, &dring->desc[tail], - dring->desc[tail].skb); - } else { - skb = netsec_get_rx_de(priv, dring, tail, rxpi, desc, len); - netsec_set_rx_de(priv, dring, tail, &td, tmp_skb); - } - - /* move tail ahead */ - dring->tail = (dring->tail + 1) % DESC_NUM; - - return skb; } static int netsec_clean_tx_dring(struct netsec_priv *priv, int budget) @@ -736,19 +662,65 @@ static int netsec_process_tx(struct netsec_priv *priv, int budget) return done; } +static void *netsec_alloc_rx_data(struct netsec_priv *priv, + dma_addr_t *dma_handle, u16 *desc_len) +{ + size_t total_len = SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); + size_t payload_len = NETSEC_RX_BUF_SZ; + dma_addr_t mapping; + void *buf; + + total_len += SKB_DATA_ALIGN(payload_len + NETSEC_SKB_PAD); + + buf = napi_alloc_frag(total_len); + if (!buf) + return NULL; + + mapping = dma_map_single(priv->dev, buf + NETSEC_SKB_PAD, payload_len, + DMA_FROM_DEVICE); + if (unlikely(dma_mapping_error(priv->dev, mapping))) + goto err_out; + + *dma_handle = mapping; + *desc_len = payload_len; + + return buf; + +err_out: + skb_free_frag(buf); + return NULL; +} + +static void netsec_rx_fill(struct netsec_priv *priv, u16 from, u16 num) +{ + struct netsec_desc_ring *dring = &priv->desc_ring[NETSEC_RING_RX]; + u16 idx = from; + + while (num) { + netsec_set_rx_de(priv, dring, idx, &dring->desc[idx]); + idx++; + if (idx >= DESC_NUM) + idx = 0; + num--; + } +} + static int netsec_process_rx(struct netsec_priv *priv, int budget) { struct netsec_desc_ring *dring = &priv->desc_ring[NETSEC_RING_RX]; struct net_device *ndev = priv->ndev; struct netsec_rx_pkt_info rx_info; - int done = 0; - struct netsec_desc desc; struct sk_buff *skb; - u16 len; + int done = 0; while (done < budget) { u16 idx = dring->tail; struct netsec_de *de = dring->vaddr + (DESC_SZ * idx); + struct netsec_desc *desc = &dring->desc[idx]; + u16 pkt_len, desc_len; + dma_addr_t dma_handle; + void *buf_addr; + u32 truesize; if (de->attr & (1U << NETSEC_RX_PKT_OWN_FIELD)) { /* reading the register clears the irq */ @@ -762,18 +734,59 @@ static int netsec_process_rx(struct netsec_priv *priv, int budget) */ dma_rmb(); done++; - skb = netsec_get_rx_pkt_data(priv, &rx_info, &desc, &len); - if (unlikely(!skb) || rx_info.err_flag) { + + pkt_len = de->buf_len_info >> 16; + rx_info.err_code = (de->attr >> NETSEC_RX_PKT_ERR_FIELD) & + NETSEC_RX_PKT_ERR_MASK; + rx_info.err_flag = (de->attr >> NETSEC_RX_PKT_ER_FIELD) & 1; + if (rx_info.err_flag) { netif_err(priv, drv, priv->ndev, - "%s: rx fail err(%d)\n", - __func__, rx_info.err_code); + "%s: rx fail err(%d)\n", __func__, + rx_info.err_code); ndev->stats.rx_dropped++; + dring->tail = (dring->tail + 1) % DESC_NUM; + /* reuse buffer page frag */ + netsec_rx_fill(priv, idx, 1); continue; } + rx_info.rx_cksum_result = + (de->attr >> NETSEC_RX_PKT_CO_FIELD) & 3; - dma_unmap_single(priv->dev, desc.dma_addr, desc.len, - DMA_FROM_DEVICE); - skb_put(skb, len); + /* allocate a fresh buffer and map it to the hardware. + * This will eventually replace the old buffer in the hardware + */ + buf_addr = netsec_alloc_rx_data(priv, &dma_handle, &desc_len); + if (unlikely(!buf_addr)) + break; + + dma_sync_single_for_cpu(priv->dev, desc->dma_addr, pkt_len, + DMA_FROM_DEVICE); + prefetch(desc->addr); + + truesize = SKB_DATA_ALIGN(desc->len + NETSEC_SKB_PAD) + + SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); + skb = build_skb(desc->addr, truesize); + if (unlikely(!skb)) { + /* free the newly allocated buffer, we are not going to + * use it + */ + dma_unmap_single(priv->dev, dma_handle, desc_len, + DMA_FROM_DEVICE); + skb_free_frag(buf_addr); + netif_err(priv, drv, priv->ndev, + "rx failed to build skb\n"); + break; + } + dma_unmap_single_attrs(priv->dev, desc->dma_addr, desc->len, + DMA_FROM_DEVICE, DMA_ATTR_SKIP_CPU_SYNC); + + /* Update the descriptor with the new buffer we allocated */ + desc->len = desc_len; + desc->dma_addr = dma_handle; + desc->addr = buf_addr; + + skb_reserve(skb, NETSEC_SKB_PAD); + skb_put(skb, pkt_len); skb->protocol = eth_type_trans(skb, priv->ndev); if (priv->rx_cksum_offload_flag && @@ -782,8 +795,11 @@ static int netsec_process_rx(struct netsec_priv *priv, int budget) if (napi_gro_receive(&priv->napi, skb) != GRO_DROP) { ndev->stats.rx_packets++; - ndev->stats.rx_bytes += len; + ndev->stats.rx_bytes += pkt_len; } + + netsec_rx_fill(priv, idx, 1); + dring->tail = (dring->tail + 1) % DESC_NUM; } return done; @@ -946,7 +962,10 @@ static void netsec_uninit_pkt_dring(struct netsec_priv *priv, int id) dma_unmap_single(priv->dev, desc->dma_addr, desc->len, id == NETSEC_RING_RX ? DMA_FROM_DEVICE : DMA_TO_DEVICE); - dev_kfree_skb(desc->skb); + if (id == NETSEC_RING_RX) + skb_free_frag(desc->addr); + else if (id == NETSEC_RING_TX) + dev_kfree_skb(desc->skb); } memset(dring->desc, 0, sizeof(struct netsec_desc) * DESC_NUM); @@ -1002,22 +1021,30 @@ static int netsec_alloc_dring(struct netsec_priv *priv, enum ring_id id) static int netsec_setup_rx_dring(struct netsec_priv *priv) { struct netsec_desc_ring *dring = &priv->desc_ring[NETSEC_RING_RX]; - struct netsec_desc desc; - struct sk_buff *skb; - int n; + int i; - desc.len = priv->ndev->mtu + 22; + for (i = 0; i < DESC_NUM; i++) { + struct netsec_desc *desc = &dring->desc[i]; + dma_addr_t dma_handle; + void *buf; + u16 len; - for (n = 0; n < DESC_NUM; n++) { - skb = netsec_alloc_skb(priv, &desc); - if (!skb) { + buf = netsec_alloc_rx_data(priv, &dma_handle, &len); + if (!buf) { netsec_uninit_pkt_dring(priv, NETSEC_RING_RX); - return -ENOMEM; + goto err_out; } - netsec_set_rx_de(priv, dring, n, &desc, skb); + desc->dma_addr = dma_handle; + desc->addr = buf; + desc->len = len; } + netsec_rx_fill(priv, 0, DESC_NUM); + return 0; + +err_out: + return -ENOMEM; } static int netsec_netdev_load_ucode_region(struct netsec_priv *priv, u32 reg, @@ -1377,6 +1404,8 @@ static int netsec_netdev_init(struct net_device *ndev) int ret; u16 data; + BUILD_BUG_ON_NOT_POWER_OF_2(DESC_NUM); + ret = netsec_alloc_dring(priv, NETSEC_RING_TX); if (ret) return ret; From patchwork Thu Nov 8 15:19:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 150529 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp946790ljp; Thu, 8 Nov 2018 07:20:06 -0800 (PST) X-Google-Smtp-Source: AJdET5cAvUhRTf2Ji66y9TKBqr8M4xANIakrvJv+k9tAMCoE/GLGlT7QxlCwr8VKTgRuemUwpRwY X-Received: by 2002:a17:902:9346:: with SMTP id g6-v6mr4825719plp.148.1541690406227; Thu, 08 Nov 2018 07:20:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541690406; cv=none; d=google.com; s=arc-20160816; b=dDnEGo0srsUWm/zt1JXKkphzPf9XskeVcfR8OF5Vr+32MJ2wVCSzZ/ILva86TfQJIK a84CswGWntE+iSv5o+JLKp2clQ3p+3Ot5iQoarLZ3ZHaLzuedZpVpNPagYSX2dt6v/fv AzO29ozO6LieR8PNX1rHGAYPaQwqtYVLwCGVnYxWFBRe4WaNpmdicPcbGt6OXob1JGex qkUTcbJoSBMKuCoIK6b6SXR9MkHqGZmlxW1Gvw3iVUIhWf/iiA36v9PtjYCN8qisjjyP oBdyB+c8F7EJQGJTn0udGFLcmF2HQzA7g9u9iiynEo4mluM+Wa/iXvnYcnn+0iqNA/vC YDJQ== 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=EeEfZdWz4Sz9cknFfQy1le2gNMBOFDGKE+QjghPi6fk=; b=ghANeqxuJhK3mhzSchvLKwuer6XZaYfRuSLosZ9yhXpeI7/s8+ISDWchq7E971t0tb 7DFJXe8rly8vuPQM8QDghNk04byffX3VXIX+UkgBFFzN8qzGV6GpBW1jInHVTsQ1jyVF U4xCOmcsAIno5okuWozc0PzBWLnuGJtHbVvmX36hMo7eg/uC22GWXKoR1LWpw61lzZUT pXE5kLB6ElpCkk1Av9Yxc2uAavr93Mu60+C25cd+A6dx+3aFNb6cpea27zI82fqGU7Qs xnk7W5CeUmfdMhP7xYaSS4Dh6s6aHdqXO489unHelcEXnQ94fwWCJURsqnPscN6I9eEP IFNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MeCRz6HS; 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 v4-v6si4319717plz.250.2018.11.08.07.20.05; Thu, 08 Nov 2018 07:20:06 -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 header.s=google header.b=MeCRz6HS; 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 S1727238AbeKIA4C (ORCPT + 10 others); Thu, 8 Nov 2018 19:56:02 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:40041 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727001AbeKIA4C (ORCPT ); Thu, 8 Nov 2018 19:56:02 -0500 Received: by mail-wr1-f66.google.com with SMTP id i17-v6so21665455wre.7 for ; Thu, 08 Nov 2018 07:20:02 -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=EeEfZdWz4Sz9cknFfQy1le2gNMBOFDGKE+QjghPi6fk=; b=MeCRz6HS9P0Euwhustas4co/kju6dRdo9V9XpCbi3zBgEqG2wP2offgSF+nvhhwSjB oGNOxliiqBHqrZN3B+eL8fmqCoLb5nLPK+8FMrIllJp4VFdjC+2tMAPBf+x6b2/KZuBj 0GUyAagJP+s6RbjpGKpLgcLAxGBbxNJ7rqH9o= 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=EeEfZdWz4Sz9cknFfQy1le2gNMBOFDGKE+QjghPi6fk=; b=qcJfQmC4ysJqUhybjrVmYYBBa0bGD5V4OfjF8hTtJS1SB1Lphl1pxux6WVng7613a+ EAg11iOGWjcviKMslPVo5QW4kPnKruY21TqBE+hEKc7MhrcSpV0+/WHshw+sKqdK5bjj atU5mqeDb6lW3bZTKnWyLQPmxrutnnpIKVPxCqCKSm6EoG0yfLh5zuwQ4g+JwyPnSuzF 0keL7aHqtc62+J0s+gSpyQ4jx6jPWg3Y0ZGnWdw6/uQRQnJvQows1iK9Y1nK1rSdKOY3 u8+7cZYdPM6r5UpY2I+NMlOvSS3kW9N8PXcqlpw+LimD9HVL5N+TXCQVKK3Or2d2N/92 3FTA== X-Gm-Message-State: AGRZ1gKmUoE4xah+YZAa7HB5Ztn6JF2Qq6SkYHl6LWWyu8658nn8UInp z0nMR6lYiVv6M4mNxrIfkajySjOgRvQDeA== X-Received: by 2002:adf:9326:: with SMTP id 35-v6mr4805852wro.318.1541690401681; Thu, 08 Nov 2018 07:20:01 -0800 (PST) Received: from apalos.lan (ppp-94-65-93-8.home.otenet.gr. [94.65.93.8]) by smtp.gmail.com with ESMTPSA id x139-v6sm2937764wme.3.2018.11.08.07.19.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 08 Nov 2018 07:20:00 -0800 (PST) From: Ilias Apalodimas To: netdev@vger.kernel.org, jaswinder.singh@linaro.org, ard.biesheuvel@linaro.org Cc: masami.hiramatsu@linaro.org, masahisa.kojima@linaro.org, brouer@redhat.com, arnd@arndb.de, Ilias Apalodimas Subject: [net-next, PATCH 2/2] net: socionext: refactor netsec_alloc_dring() Date: Thu, 8 Nov 2018 17:19:55 +0200 Message-Id: <1541690395-8337-2-git-send-email-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1541690395-8337-1-git-send-email-ilias.apalodimas@linaro.org> References: <1541690395-8337-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 return -ENOMEM directly instead of assigning it in a variable Signed-off-by: Ilias Apalodimas --- drivers/net/ethernet/socionext/netsec.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) -- 2.7.4 diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c index 9d24f29..bba9733 100644 --- a/drivers/net/ethernet/socionext/netsec.c +++ b/drivers/net/ethernet/socionext/netsec.c @@ -996,26 +996,21 @@ 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 ret = 0; dring->vaddr = dma_zalloc_coherent(priv->dev, DESC_SZ * DESC_NUM, &dring->desc_dma, GFP_KERNEL); - if (!dring->vaddr) { - ret = -ENOMEM; + if (!dring->vaddr) goto err; - } dring->desc = kcalloc(DESC_NUM, sizeof(*dring->desc), GFP_KERNEL); - if (!dring->desc) { - ret = -ENOMEM; + if (!dring->desc) goto err; - } return 0; err: netsec_free_dring(priv, id); - return ret; + return -ENOMEM; } static int netsec_setup_rx_dring(struct netsec_priv *priv)