From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Yunsheng Lin <linyunsheng@huawei.com>,
Peng Li <lipeng321@huawei.com>,
Salil Mehta <salil.mehta@huawei.com>,
"David S . Miller" <davem@davemloft.net>,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH AUTOSEL 4.9 12/38] net: hns: fix for unmapping problem when SMMU is on
Date: Tue, 16 Oct 2018 00:14:56 -0400 [thread overview]
Message-ID: <20181016041522.135789-12-sashal@kernel.org> (raw)
In-Reply-To: <20181016041522.135789-1-sashal@kernel.org>
From: Yunsheng Lin <linyunsheng@huawei.com>
[ 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 <linyunsheng@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Reviewed-by: Yisen Zhuang <yisen.zhuang@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
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 b6ed818f78ff..06bc8638501e 100644
--- 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 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 8a2a07e21324..92ed6534ceae 100644
--- 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_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);
@@ -132,6 +132,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 },
@@ -288,15 +296,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.17.1
next prev parent reply other threads:[~2018-10-16 4:15 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-16 4:14 [PATCH AUTOSEL 4.9 01/38] xfrm: Validate address prefix lengths in the xfrm selector Sasha Levin
2018-10-16 4:14 ` [PATCH AUTOSEL 4.9 02/38] xfrm6: call kfree_skb when skb is toobig Sasha Levin
2018-10-16 4:14 ` [PATCH AUTOSEL 4.9 03/38] mac80211: Always report TX status Sasha Levin
2018-10-16 4:14 ` [PATCH AUTOSEL 4.9 04/38] cfg80211: reg: Init wiphy_idx in regulatory_hint_core() Sasha Levin
2018-10-16 4:14 ` [PATCH AUTOSEL 4.9 05/38] mac80211: fix pending queue hang due to TX_DROP Sasha Levin
2018-10-16 4:14 ` [PATCH AUTOSEL 4.9 06/38] cfg80211: Address some corner cases in scan result channel updating Sasha Levin
2018-10-16 4:14 ` [PATCH AUTOSEL 4.9 07/38] mac80211: TDLS: fix skb queue/priority assignment Sasha Levin
2018-10-16 4:14 ` [PATCH AUTOSEL 4.9 08/38] ARM: 8799/1: mm: fix pci_ioremap_io() offset check Sasha Levin
2018-10-16 4:14 ` [PATCH AUTOSEL 4.9 09/38] xfrm: validate template mode Sasha Levin
2018-10-16 4:14 ` [PATCH AUTOSEL 4.9 10/38] ARM: dts: BCM63xx: Fix incorrect interrupt specifiers Sasha Levin
2018-10-16 4:14 ` [PATCH AUTOSEL 4.9 11/38] net: macb: Clean 64b dma addresses if they are not detected Sasha Levin
2018-10-16 4:14 ` Sasha Levin [this message]
2018-10-16 4:14 ` [PATCH AUTOSEL 4.9 13/38] soc: fsl: qbman: qman: avoid allocating from non existing gen_pool Sasha Levin
2018-10-16 4:14 ` [PATCH AUTOSEL 4.9 14/38] soc: fsl: qe: Fix copy/paste bug in ucc_get_tdm_sync_shift() Sasha Levin
2018-10-16 4:14 ` [PATCH AUTOSEL 4.9 15/38] nl80211: Fix possible Spectre-v1 for NL80211_TXRATE_HT Sasha Levin
2018-10-16 4:15 ` [PATCH AUTOSEL 4.9 16/38] mac80211_hwsim: do not omit multicast announce of first added radio Sasha Levin
2018-10-16 4:15 ` [PATCH AUTOSEL 4.9 17/38] Bluetooth: SMP: fix crash in unpairing Sasha Levin
2018-10-16 4:15 ` [PATCH AUTOSEL 4.9 18/38] pxa168fb: prepare the clock Sasha Levin
2018-10-16 4:15 ` [PATCH AUTOSEL 4.9 19/38] qed: Avoid implicit enum conversion in qed_roce_mode_to_flavor Sasha Levin
2018-10-16 4:15 ` [PATCH AUTOSEL 4.9 20/38] bonding: avoid possible dead-lock Sasha Levin
2018-10-16 4:15 ` [PATCH AUTOSEL 4.9 21/38] qed: Avoid constant logical operation warning in qed_vf_pf_acquire Sasha Levin
2018-10-16 4:15 ` [PATCH AUTOSEL 4.9 22/38] bnxt_en: Fix TX timeout during netpoll Sasha Levin
2018-10-16 4:15 ` [PATCH AUTOSEL 4.9 23/38] asix: Check for supported Wake-on-LAN modes Sasha Levin
2018-10-16 4:15 ` [PATCH AUTOSEL 4.9 24/38] ax88179_178a: " Sasha Levin
2018-10-16 4:15 ` [PATCH AUTOSEL 4.9 25/38] lan78xx: " Sasha Levin
2018-10-16 4:15 ` [PATCH AUTOSEL 4.9 26/38] sr9800: " Sasha Levin
2018-10-16 4:15 ` [PATCH AUTOSEL 4.9 27/38] r8152: Check for supported Wake-on-LAN Modes Sasha Levin
2018-10-16 4:15 ` [PATCH AUTOSEL 4.9 28/38] smsc75xx: Check for Wake-on-LAN modes Sasha Levin
2018-10-16 4:15 ` [PATCH AUTOSEL 4.9 29/38] smsc95xx: " Sasha Levin
2018-10-16 4:15 ` [PATCH AUTOSEL 4.9 30/38] qlcnic: fix Tx descriptor corruption on 82xx devices Sasha Levin
2018-10-16 4:15 ` [PATCH AUTOSEL 4.9 31/38] i2c: i2c-scmi: fix for i2c_smbus_write_block_data Sasha Levin
2018-10-16 4:15 ` [PATCH AUTOSEL 4.9 32/38] perf/ring_buffer: Prevent concurent ring buffer access Sasha Levin
2018-10-16 4:15 ` [PATCH AUTOSEL 4.9 33/38] perf/x86/intel/uncore: Fix PCI BDF address of M3UPI on SKX Sasha Levin
2018-10-16 4:15 ` [PATCH AUTOSEL 4.9 34/38] net: fec: fix rare tx timeout Sasha Levin
2018-10-16 4:15 ` [PATCH AUTOSEL 4.9 35/38] declance: Fix continuation with the adapter identification message Sasha Levin
2018-10-16 4:15 ` [PATCH AUTOSEL 4.9 36/38] net/usb: cancel pending work when unbinding smsc75xx Sasha Levin
2018-10-16 4:15 ` [PATCH AUTOSEL 4.9 37/38] net: cxgb3_main: fix a missing-check bug Sasha Levin
2018-10-16 4:15 ` [PATCH AUTOSEL 4.9 38/38] mm/vmstat.c: fix outdated vmstat_text Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181016041522.135789-12-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linyunsheng@huawei.com \
--cc=lipeng321@huawei.com \
--cc=salil.mehta@huawei.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox