Received: by 2002:a4a:301c:0:0:0:0:0 with SMTP id q28-v6csp622177oof; Tue, 25 Sep 2018 02:22:57 -0700 (PDT) X-Google-Smtp-Source: ACcGV60DcYMYsq+zt5FeaMV5AniY1+9Bu/v35DC/hugOhMTlj8fUX2dau6Hz+kQ+3QsyzFT/X45v X-Received: by 2002:a63:8c4:: with SMTP id 187-v6mr155945pgi.396.1537867377072; Tue, 25 Sep 2018 02:22:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537867377; cv=none; d=google.com; s=arc-20160816; b=D2Bj0ZcXzpf9BAC12P0KdwNnXQLgxX59NlWMtl6F1ZSIsQi7G7Xi9tJ4sybo8ZQNut PNb6jIKIfAxkYKpuU1JY8yT48o0nd2lMlvBYP4tE1x7nKAuSL5Zm3h0oKD9v4ekjW3hI q1sLEu8LpC19+6QmYG//NTaUB5i1fhu7jWGT/5OWM8adtcUdzYcw2IZlSZ047B7UXa3n D25pCyHlNUonNUkmZvjgeMumDBG/TwGoBVZQvPjXIcJcE4oQQhWcc86jDSn9lewcCWbd gqsqIGSz8wvHROJ+wMP+AO5EMnrAXK2aa+5ySo56mpecJa2OvJlBjvGR+vTbq5F5Ie2E R+3w== 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 t6-v6si85961pgk.306.2018.09.25.02.22.41; Tue, 25 Sep 2018 02:22:57 -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 S1728692AbeIYP3C (ORCPT + 99 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 Content-Type: text/plain 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(-) 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, -- 2.7.4