From patchwork Tue Sep 25 09:21:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 147425 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp489056lji; Tue, 25 Sep 2018 02:22:27 -0700 (PDT) X-Google-Smtp-Source: ACcGV63w9Tk57AihIUa/GkB6XGrXadBeQ0QeTQh4qRjbBArntultE3p4jJe12jUj65vcWTgOvEUP X-Received: by 2002:a63:d40c:: with SMTP id a12-v6mr152274pgh.394.1537867347198; Tue, 25 Sep 2018 02:22:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537867347; cv=none; d=google.com; s=arc-20160816; b=lt9kFl9EKD3rLcwkBYaupRttZ3cjRbmsKt85/IlNWJUqCYRQjLQ8qkw2ONJzX0keiv gQlMHI2OgxrLeevTBqnJidXhpVnOgq/MkyK+aBZ0K7RGx56P4ioTv8HvlBi3DyCcbx7q Q56EIVPfCG79hWbDU8/XDlTPJFdBNn6uCS9ngKVFK9bqIJeID3zurFKwSgxcHpYCwLoi yFKnLHzsurLHPHP9hd9f0Y6FEZzJelhMBfxrT9sfvr4MEKVFnlF6R+u9bbzmTYCIM3wQ jwN6c1bAQjcChE1hlrG+lCoGglkgUokqGgjk0KFZPJLJnh2c/s0MAe+kTZeFVkFZs3TJ 3WYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=SfoBk7RSQGtSR8FsglR3LxHBLMLpybLrf105paIhGhE=; b=hp2n2kPpJ420VwPWPHeCA2zHqeZJPKjDje9e/yJOgl7KTLuCMcCuYgAbwBC0mZUw0l tE8+fTnQ8WqdkJmB8LuTeYcPe63bMzzrmY9KQGrjaW2j+pBqJuzAT3m7NIqKO4XYwEQA n9hyohlzqGsDvO0jA8N8ZQdrlCs91yqomqfoYfe288DqbzHyn3PxXp9Dbpf31ZmmMZ6h vSQts2aT18+YrM7O+98+M9NBd6mjcYXLOKnMfvfZg5ZAZgPXFIwKq8DtjrXofrSUOfaK PBOGxPIdACam8A9Es4dG2EmOlxyA9BXpYJCVHBHPUI7py5SmcNJicC+iG3FrxbG1E7c0 7EbQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g12-v6si1904793pgi.467.2018.09.25.02.22.26; Tue, 25 Sep 2018 02:22:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728820AbeIYP3C (ORCPT + 32 others); Tue, 25 Sep 2018 11:29:02 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:12699 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727767AbeIYP3C (ORCPT ); Tue, 25 Sep 2018 11:29:02 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 2F78FE247D698; Tue, 25 Sep 2018 17:22:22 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.202.226.54) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.399.0; Tue, 25 Sep 2018 17:22:16 +0800 From: Salil Mehta To: CC: , , , , , , , Yunsheng Lin Subject: [PATCH net] net: hns: fix for unmapping problem when SMMU is on Date: Tue, 25 Sep 2018 10:21:55 +0100 Message-ID: <20180925092155.11024-1-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 MIME-Version: 1.0 X-Originating-IP: [10.202.226.54] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yunsheng Lin If SMMU is on, there is more likely that skb_shinfo(skb)->frags[i] can not send by a single BD. when this happen, the hns_nic_net_xmit_hw function map the whole data in a frags using skb_frag_dma_map, but unmap each BD' data individually when tx is done, which causes problem when SMMU is on. This patch fixes this problem by ummapping the whole data in a frags when tx is done. Signed-off-by: Yunsheng Lin Signed-off-by: Peng Li Reviewed-by: Yisen Zhuang Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns/hnae.c | 2 +- drivers/net/ethernet/hisilicon/hns/hns_enet.c | 30 +++++++++++++++++---------- 2 files changed, 20 insertions(+), 12 deletions(-) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.c b/drivers/net/ethernet/hisilicon/hns/hnae.c index a051e58..79d03f8 100644 --- a/drivers/net/ethernet/hisilicon/hns/hnae.c +++ b/drivers/net/ethernet/hisilicon/hns/hnae.c @@ -84,7 +84,7 @@ static void hnae_unmap_buffer(struct hnae_ring *ring, struct hnae_desc_cb *cb) if (cb->type == DESC_TYPE_SKB) dma_unmap_single(ring_to_dev(ring), cb->dma, cb->length, ring_to_dma_dir(ring)); - else + else if (cb->length) dma_unmap_page(ring_to_dev(ring), cb->dma, cb->length, ring_to_dma_dir(ring)); } diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c b/drivers/net/ethernet/hisilicon/hns/hns_enet.c index f56855e..5ce23d4 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c +++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c @@ -40,9 +40,9 @@ #define SKB_TMP_LEN(SKB) \ (((SKB)->transport_header - (SKB)->mac_header) + tcp_hdrlen(SKB)) -static void fill_v2_desc(struct hnae_ring *ring, void *priv, - int size, dma_addr_t dma, int frag_end, - int buf_num, enum hns_desc_type type, int mtu) +static void fill_v2_desc_hw(struct hnae_ring *ring, void *priv, int size, + int send_sz, dma_addr_t dma, int frag_end, + int buf_num, enum hns_desc_type type, int mtu) { struct hnae_desc *desc = &ring->desc[ring->next_to_use]; struct hnae_desc_cb *desc_cb = &ring->desc_cb[ring->next_to_use]; @@ -64,7 +64,7 @@ static void fill_v2_desc(struct hnae_ring *ring, void *priv, desc_cb->type = type; desc->addr = cpu_to_le64(dma); - desc->tx.send_size = cpu_to_le16((u16)size); + desc->tx.send_size = cpu_to_le16((u16)send_sz); /* config bd buffer end */ hnae_set_bit(rrcfv, HNSV2_TXD_VLD_B, 1); @@ -133,6 +133,14 @@ static void fill_v2_desc(struct hnae_ring *ring, void *priv, ring_ptr_move_fw(ring, next_to_use); } +static void fill_v2_desc(struct hnae_ring *ring, void *priv, + int size, dma_addr_t dma, int frag_end, + int buf_num, enum hns_desc_type type, int mtu) +{ + fill_v2_desc_hw(ring, priv, size, size, dma, frag_end, + buf_num, type, mtu); +} + static const struct acpi_device_id hns_enet_acpi_match[] = { { "HISI00C1", 0 }, { "HISI00C2", 0 }, @@ -289,15 +297,15 @@ static void fill_tso_desc(struct hnae_ring *ring, void *priv, /* when the frag size is bigger than hardware, split this frag */ for (k = 0; k < frag_buf_num; k++) - fill_v2_desc(ring, priv, - (k == frag_buf_num - 1) ? + fill_v2_desc_hw(ring, priv, k == 0 ? size : 0, + (k == frag_buf_num - 1) ? sizeoflast : BD_MAX_SEND_SIZE, - dma + BD_MAX_SEND_SIZE * k, - frag_end && (k == frag_buf_num - 1) ? 1 : 0, - buf_num, - (type == DESC_TYPE_SKB && !k) ? + dma + BD_MAX_SEND_SIZE * k, + frag_end && (k == frag_buf_num - 1) ? 1 : 0, + buf_num, + (type == DESC_TYPE_SKB && !k) ? DESC_TYPE_SKB : DESC_TYPE_PAGE, - mtu); + mtu); } netdev_tx_t hns_nic_net_xmit_hw(struct net_device *ndev,