]>
Commit | Line | Data |
---|---|---|
288d6f25 SL |
1 | From ce3a850a2a35528c307b6284fc210cff38e11260 Mon Sep 17 00:00:00 2001 |
2 | From: Yonglong Liu <liuyonglong@huawei.com> | |
3 | Date: Thu, 4 Apr 2019 16:46:46 +0800 | |
4 | Subject: net: hns: Fix WARNING when remove HNS driver with SMMU enabled | |
5 | ||
6 | [ Upstream commit 8601a99d7c0256b7a7fdd1ab14cf6c1f1dfcadc6 ] | |
7 | ||
8 | When enable SMMU, remove HNS driver will cause a WARNING: | |
9 | ||
10 | [ 141.924177] WARNING: CPU: 36 PID: 2708 at drivers/iommu/dma-iommu.c:443 __iommu_dma_unmap+0xc0/0xc8 | |
11 | [ 141.954673] Modules linked in: hns_enet_drv(-) | |
12 | [ 141.963615] CPU: 36 PID: 2708 Comm: rmmod Tainted: G W 5.0.0-rc1-28723-gb729c57de95c-dirty #32 | |
13 | [ 141.983593] Hardware name: Huawei D05/D05, BIOS Hisilicon D05 UEFI Nemo 1.8 RC0 08/31/2017 | |
14 | [ 142.000244] pstate: 60000005 (nZCv daif -PAN -UAO) | |
15 | [ 142.009886] pc : __iommu_dma_unmap+0xc0/0xc8 | |
16 | [ 142.018476] lr : __iommu_dma_unmap+0xc0/0xc8 | |
17 | [ 142.027066] sp : ffff000013533b90 | |
18 | [ 142.033728] x29: ffff000013533b90 x28: ffff8013e6983600 | |
19 | [ 142.044420] x27: 0000000000000000 x26: 0000000000000000 | |
20 | [ 142.055113] x25: 0000000056000000 x24: 0000000000000015 | |
21 | [ 142.065806] x23: 0000000000000028 x22: ffff8013e66eee68 | |
22 | [ 142.076499] x21: ffff8013db919800 x20: 0000ffffefbff000 | |
23 | [ 142.087192] x19: 0000000000001000 x18: 0000000000000007 | |
24 | [ 142.097885] x17: 000000000000000e x16: 0000000000000001 | |
25 | [ 142.108578] x15: 0000000000000019 x14: 363139343a70616d | |
26 | [ 142.119270] x13: 6e75656761705f67 x12: 0000000000000000 | |
27 | [ 142.129963] x11: 00000000ffffffff x10: 0000000000000006 | |
28 | [ 142.140656] x9 : 1346c1aa88093500 x8 : ffff0000114de4e0 | |
29 | [ 142.151349] x7 : 6662666578303d72 x6 : ffff0000105ffec8 | |
30 | [ 142.162042] x5 : 0000000000000000 x4 : 0000000000000000 | |
31 | [ 142.172734] x3 : 00000000ffffffff x2 : ffff0000114de500 | |
32 | [ 142.183427] x1 : 0000000000000000 x0 : 0000000000000035 | |
33 | [ 142.194120] Call trace: | |
34 | [ 142.199030] __iommu_dma_unmap+0xc0/0xc8 | |
35 | [ 142.206920] iommu_dma_unmap_page+0x20/0x28 | |
36 | [ 142.215335] __iommu_unmap_page+0x40/0x60 | |
37 | [ 142.223399] hnae_unmap_buffer+0x110/0x134 | |
38 | [ 142.231639] hnae_free_desc+0x6c/0x10c | |
39 | [ 142.239177] hnae_fini_ring+0x14/0x34 | |
40 | [ 142.246540] hnae_fini_queue+0x2c/0x40 | |
41 | [ 142.254080] hnae_put_handle+0x38/0xcc | |
42 | [ 142.261619] hns_nic_dev_remove+0x54/0xfc [hns_enet_drv] | |
43 | [ 142.272312] platform_drv_remove+0x24/0x64 | |
44 | [ 142.280552] device_release_driver_internal+0x17c/0x20c | |
45 | [ 142.291070] driver_detach+0x4c/0x90 | |
46 | [ 142.298259] bus_remove_driver+0x5c/0xd8 | |
47 | [ 142.306148] driver_unregister+0x2c/0x54 | |
48 | [ 142.314037] platform_driver_unregister+0x10/0x18 | |
49 | [ 142.323505] hns_nic_dev_driver_exit+0x14/0xf0c [hns_enet_drv] | |
50 | [ 142.335248] __arm64_sys_delete_module+0x214/0x25c | |
51 | [ 142.344891] el0_svc_common+0xb0/0x10c | |
52 | [ 142.352430] el0_svc_handler+0x24/0x80 | |
53 | [ 142.359968] el0_svc+0x8/0x7c0 | |
54 | [ 142.366104] ---[ end trace 60ad1cd58e63c407 ]--- | |
55 | ||
56 | The tx ring buffer map when xmit and unmap when xmit done. So in | |
57 | hnae_init_ring() did not map tx ring buffer, but in hnae_fini_ring() | |
58 | have a unmap operation for tx ring buffer, which is already unmapped | |
59 | when xmit done, than cause this WARNING. | |
60 | ||
61 | The hnae_alloc_buffers() is called in hnae_init_ring(), | |
62 | so the hnae_free_buffers() should be in hnae_fini_ring(), not in | |
63 | hnae_free_desc(). | |
64 | ||
65 | In hnae_fini_ring(), adds a check is_rx_ring() as in hnae_init_ring(). | |
66 | When the ring buffer is tx ring, adds a piece of code to ensure that | |
67 | the tx ring is unmap. | |
68 | ||
69 | Signed-off-by: Yonglong Liu <liuyonglong@huawei.com> | |
70 | Signed-off-by: Peng Li <lipeng321@huawei.com> | |
71 | Signed-off-by: David S. Miller <davem@davemloft.net> | |
72 | Signed-off-by: Sasha Levin <sashal@kernel.org> | |
73 | --- | |
74 | drivers/net/ethernet/hisilicon/hns/hnae.c | 4 +++- | |
75 | 1 file changed, 3 insertions(+), 1 deletion(-) | |
76 | ||
77 | diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.c b/drivers/net/ethernet/hisilicon/hns/hnae.c | |
78 | index b3645297477e..3ce41efe8a94 100644 | |
79 | --- a/drivers/net/ethernet/hisilicon/hns/hnae.c | |
80 | +++ b/drivers/net/ethernet/hisilicon/hns/hnae.c | |
81 | @@ -144,7 +144,6 @@ static int hnae_alloc_buffers(struct hnae_ring *ring) | |
82 | /* free desc along with its attached buffer */ | |
83 | static void hnae_free_desc(struct hnae_ring *ring) | |
84 | { | |
85 | - hnae_free_buffers(ring); | |
86 | dma_unmap_single(ring_to_dev(ring), ring->desc_dma_addr, | |
87 | ring->desc_num * sizeof(ring->desc[0]), | |
88 | ring_to_dma_dir(ring)); | |
89 | @@ -177,6 +176,9 @@ static int hnae_alloc_desc(struct hnae_ring *ring) | |
90 | /* fini ring, also free the buffer for the ring */ | |
91 | static void hnae_fini_ring(struct hnae_ring *ring) | |
92 | { | |
93 | + if (is_rx_ring(ring)) | |
94 | + hnae_free_buffers(ring); | |
95 | + | |
96 | hnae_free_desc(ring); | |
97 | kfree(ring->desc_cb); | |
98 | ring->desc_cb = NULL; | |
99 | -- | |
100 | 2.20.1 | |
101 |