From patchwork Sat Aug 13 05:05:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iyappan Subramanian X-Patchwork-Id: 9278327 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 CF62160780 for ; Sat, 13 Aug 2016 05:07:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AED9328B44 for ; Sat, 13 Aug 2016 05:07:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 90D8228B48; Sat, 13 Aug 2016 05:07:28 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0FECB28B44 for ; Sat, 13 Aug 2016 05:07:27 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bYR8j-00068J-Pk; Sat, 13 Aug 2016 05:05:45 +0000 Received: from mail-pf0-x236.google.com ([2607:f8b0:400e:c00::236]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bYR8D-0004qF-22 for linux-arm-kernel@lists.infradead.org; Sat, 13 Aug 2016 05:05:13 +0000 Received: by mail-pf0-x236.google.com with SMTP id y134so2073791pfg.0 for ; Fri, 12 Aug 2016 22:04:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=apm.com; s=apm; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CyOpGvYw07WFDhUOvOn1lhPb06Ug7D3spAsfzwqb7qo=; b=AvZUqqJlZ4x0jBSY2wIjoB33JHCGUAv4jniFWkpsrdjBuSFyhcYj2+p7Wm498/gZqn dwdY5C2SA+1kqU6IuA7U40eiWvHBfF4Whx46NiUE6/f58dTdiSVnkpuVrmFr5xy5ed9W qEzJyt1BnBzvefoGALJZC5AtZ+txAs8XTfiFc= 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=CyOpGvYw07WFDhUOvOn1lhPb06Ug7D3spAsfzwqb7qo=; b=JrXY4k3NZjNKcpV/4zvm5j/yi69z7WwRj7y508kkne6A972Rk2lE92s5vvbDNXMumj +bm4EyHtj6b2C/bOu+uv93pUAHge6by2EABMFZD62PbMQNRZO19BMykr5CNWA0cXa5ne N4lvk5/83KunhXt8HDW2ss5Q0tejWNw3AIAzQCAO3G/bMFk6rjPMJGoq+56MJDAFPwui 2UXuRI2srp/wthQ9o+Rz651wLLNz7mRyvF2DorGpNgex2Z21WX367AeQzk4BkRucsygm 1V3UAch5XVkFd2vsdYv4Qjau/elWR/vnqWG7nIRgD1tj5y3uhGLLCpBsMLWuH6ezULlG Y/Og== X-Gm-Message-State: AEkoouu+7fr2tlFlBp1A9Mebn6Ke5hiyan+klHQhbNuSa/Sl1RoWF1vxjmb1H3UUnpENptBn X-Received: by 10.98.71.91 with SMTP id u88mr33419373pfa.145.1471064692210; Fri, 12 Aug 2016 22:04:52 -0700 (PDT) Received: from isubrama-dev.amcc.com ([206.80.4.98]) by smtp.gmail.com with ESMTPSA id o2sm16753965pfg.10.2016.08.12.22.04.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 12 Aug 2016 22:04:51 -0700 (PDT) From: Iyappan Subramanian To: davem@davemloft.net, netdev@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH net-next v2 02/12] drivers: net: xgene: fix: Add dma_unmap_single Date: Fri, 12 Aug 2016 22:05:38 -0700 Message-Id: <1471064748-28033-3-git-send-email-isubramanian@apm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1471064748-28033-1-git-send-email-isubramanian@apm.com> References: <1471064748-28033-1-git-send-email-isubramanian@apm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160812_220513_183312_94D89D05 X-CRM114-Status: GOOD ( 12.34 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: patches@apm.com, linux@armlinux.org.uk, linux-arm-kernel@lists.infradead.org, Iyappan Subramanian MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP In addition to xgene_enet_delete_bufpool() freeing skbs, their associated dma memory should also be unmapped. Signed-off-by: Iyappan Subramanian --- drivers/net/ethernet/apm/xgene/xgene_enet_main.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_main.c b/drivers/net/ethernet/apm/xgene/xgene_enet_main.c index ceeb3f4..c1fd33d 100644 --- a/drivers/net/ethernet/apm/xgene/xgene_enet_main.c +++ b/drivers/net/ethernet/apm/xgene/xgene_enet_main.c @@ -72,7 +72,6 @@ static int xgene_enet_refill_bufpool(struct xgene_enet_desc_ring *buf_pool, skb = netdev_alloc_skb_ip_align(ndev, len); if (unlikely(!skb)) return -ENOMEM; - buf_pool->rx_skb[tail] = skb; dma_addr = dma_map_single(dev, skb->data, len, DMA_FROM_DEVICE); if (dma_mapping_error(dev, dma_addr)) { @@ -81,6 +80,8 @@ static int xgene_enet_refill_bufpool(struct xgene_enet_desc_ring *buf_pool, return -EINVAL; } + buf_pool->rx_skb[tail] = skb; + raw_desc->m1 = cpu_to_le64(SET_VAL(DATAADDR, dma_addr) | SET_VAL(BUFDATALEN, bufdatalen) | SET_BIT(COHERENT)); @@ -102,12 +103,21 @@ static u8 xgene_enet_hdr_len(const void *data) static void xgene_enet_delete_bufpool(struct xgene_enet_desc_ring *buf_pool) { + struct device *dev = ndev_to_dev(buf_pool->ndev); + struct xgene_enet_raw_desc16 *raw_desc; + dma_addr_t dma_addr; int i; /* Free up the buffers held by hardware */ for (i = 0; i < buf_pool->slots; i++) { - if (buf_pool->rx_skb[i]) + if (buf_pool->rx_skb[i]) { dev_kfree_skb_any(buf_pool->rx_skb[i]); + + raw_desc = &buf_pool->raw_desc16[i]; + dma_addr = GET_VAL(DATAADDR, le64_to_cpu(raw_desc->m1)); + dma_unmap_single(dev, dma_addr, XGENE_ENET_MAX_MTU, + DMA_FROM_DEVICE); + } } }