Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp5452003imm; Tue, 16 Oct 2018 10:25:37 -0700 (PDT) X-Google-Smtp-Source: ACcGV62PDsZaWvtY+W+JN+wZoVH7+qlD6FHIXQyDkfVPaIJk6/J3bWcV74bWKy1Ib+Lrj+X+n2Xf X-Received: by 2002:a62:3942:: with SMTP id g63-v6mr23679114pfa.170.1539710737259; Tue, 16 Oct 2018 10:25:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539710737; cv=none; d=google.com; s=arc-20160816; b=SIzvIBBCjxdY3AXdKIEw+MQIampDuwKO8qMCsMWmKjQiXdIDdtSZ4AdE+PoQmeNBI8 Wa72KrGkUvP79tfExK2qrvzN9KAeJ83ml0KUHomm5PSXHBmeVt49EJT1ZBm0t+euEReU L9y7qZ9RxnOatH2ikHJyXFvCxDTfWP8a6l/rkRTwNXZpwifNknLvbIx1gJTCZOpJhWQm JAMua42E7YMGIDukRktXBLFDNnozitVIqrVgpdgg7hmksfA7vOwWjOnfDz/wAeG5Vcwn sac3pxK34AtTH0k6RHefwQMroXPqHlzTia2eIQlXoh5ASnqgV5IMi9pFy31+w3ZQMMhb l1SQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=3JrtMP7WVTD8wiLGFuDf+vgd6Y2EFMG2/wpytKJGuQo=; b=B3XItUS5ZjZQFunZY3bqnMNmyBVPUbnd46V21PDUZDUmFLXp5f8Knnk35iIy3Z9bRh 3p3I10ec+lOAhz2qHJMgcPut40drwh9X3r5UkT1mnvl7LfBiqX6EANZaccG6H5rcDJGr nYTmV++mNVmwMAka91BSyVLT6BVM1KjIwN+kHdbY72ScKSYxdfa9KY0ELwsrk1mr9IBb cWNCirVnYTGoI7xXEBJPctIShO7tLcA7XDfOLeXzaqI9zGpL1RM4q1eIeAYGgA6eSl70 IYcnbS48b3uuj0AXmmEqqa5CLFMHFf82G5cAJyy+TMwvec8srjZ/5D7c7I9pL4x7zcrl tuvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JZWHdeGG; 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 b3-v6si8515712plc.103.2018.10.16.10.25.21; Tue, 16 Oct 2018 10:25:37 -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; dkim=pass header.i=@kernel.org header.s=default header.b=JZWHdeGG; 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 S1731462AbeJQBPG (ORCPT + 99 others); Tue, 16 Oct 2018 21:15:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:33614 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730396AbeJQBPE (ORCPT ); Tue, 16 Oct 2018 21:15:04 -0400 Received: from localhost (ip-213-127-77-176.ip.prioritytelecom.net [213.127.77.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 755A12089E; Tue, 16 Oct 2018 17:23:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539710619; bh=eB6SoYe63r+hhX4/cvZ71V9tW8blDbrwiAK539bjjOo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JZWHdeGGChpO5/4Gf2LNG17HeYANtsDDDmClJGcl+6ObIL2OqCgayEMZupuo7SDHL oN70yC6Hz8892SxQZcZGvUyqIHYRgdSceCFPKpxMWZ+HvYjPngzEMjQ4Xp7c+pDUjm Lw01E5W8MclfOrtGdPR4VpS6GnxvQHh0jH5/c32I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yunsheng Lin , Peng Li , Yisen Zhuang , Salil Mehta , "David S. Miller" Subject: [PATCH 4.9 29/71] net: hns: fix for unmapping problem when SMMU is on Date: Tue, 16 Oct 2018 19:09:26 +0200 Message-Id: <20181016170540.857388623@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181016170539.315587743@linuxfoundation.org> References: <20181016170539.315587743@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yunsheng Lin [ Upstream commit 2e9361efa707e186d91b938e44f9e326725259f7 ] 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 Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/hisilicon/hns/hnae.c | 2 - drivers/net/ethernet/hisilicon/hns/hns_enet.c | 30 ++++++++++++++++---------- 2 files changed, 20 insertions(+), 12 deletions(-) --- a/drivers/net/ethernet/hisilicon/hns/hnae.c +++ b/drivers/net/ethernet/hisilicon/hns/hnae.c @@ -80,7 +80,7 @@ static void hnae_unmap_buffer(struct hna 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)); } --- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c +++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c @@ -39,9 +39,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]; @@ -63,7 +63,7 @@ static void fill_v2_desc(struct hnae_rin 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); @@ -132,6 +132,14 @@ static void fill_v2_desc(struct hnae_rin 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 }, @@ -288,15 +296,15 @@ static void fill_tso_desc(struct hnae_ri /* 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,