[Bug Description]
Previously, when changing the ring parameters, we free the old
ring resources firstly, and then setup the new ring resources.
In some case of an allocation fail, there will be no resources
to use.
[Steps to Reproduce]
1.load PF&VF driver
2.allocate 8 VF for each PF
3.tesgine send tcp/udp packets to ports
4.modify VF queue depth by ethtool -G command
[Bug Description]
Previously, when changing the ring parameters, we free the old
ring resources firstly, and then setup the new ring resources.
In some case of an allocation fail, there will be no resources
to use.
[Steps to Reproduce]
1.load PF&VF driver
2.allocate 8 VF for each PF
3.tesgine send tcp/udp packets to ports
4.modify VF queue depth by ethtool -G command
[Actual Results] ad003, pud=00000020805 b6003, pmd=00000000000 00000 vhulk1903. 5.1.h163. eulerosv3r1. aarch64 #2 buffer_ detach+ 0x30/0x80 [hns3] desc+0x38/ 0x118 [hns3] buffer_ detach+ 0x30/0x80 [hns3] desc+0x38/ 0x118 [hns3] ring+0x20/ 0x58 [hns3] all_ring+ 0x48/0x88 [hns3] ringparam+ 0x11c/0x208 [hns3] 0x1654/ 0x22d8 0x19c/0x420 ioctl+0xf8/ 0x220 0x290/0x598 ioctl+0xc4/ 0x838 0x8c/0x98 sys_ioctl+ 0x28/0x38 common+ 0xa0/0x180 handler+ 0x38/0x78
Kernel break down by NULL pointer.
ethtool -G eth15 tx 32768 rx 3276[ 4269.988246] hns3 0000:7d:02.2 eth15: Changing Tx/Rx ring depth from 1024/1024 to 32768/32768
8
[ 4270.010318] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000
[ 4270.019096] Mem abort info:
[ 4270.021880] ESR = 0x96000006
[ 4270.024924] Exception class = DABT (current EL), IL = 32 bits
[ 4270.030832] SET = 0, FnV = 0
[ 4270.033875] EA = 0, S1PTW = 0
[ 4270.037005] Data abort info:
[ 4270.039872] ISV = 0, ISS = 0x00000006
[ 4270.043696] CM = 0, WnR = 0
[ 4270.046655] user pgtable: 4k pages, 48-bit VAs, pgdp = 00000000414534bd
[ 4270.053258] [0000000000000000] pgd=00000020805
[ 4270.061947] Internal error: Oops: 96000006 [#1] SMP
[ 4270.066812] CPU: 37 PID: 17447 Comm: ethtool Tainted: G W OE 4.19.30-
[ 4270.077838] Hardware name: Huawei Technologies Co., Ltd. EVBCS/EVBCS, BIOS CS SPC100B010 1P TA 05/26/2019
[ 4270.087389] pstate: 40400009 (nZcv daif +PAN -UAO)
[ 4270.092170] pc : hns3_free_
[ 4270.097556] lr : hns3_free_
[ 4270.102245] sp : ffff8020cbe8f9e0
[ 4270.105545] x29: ffff8020cbe8f9e0 x28: ffff802754d10f00
[ 4270.110843] x27: 0000000000000000 x26: 0000000000000001
[ 4270.116141] x25: ffff80271ad8b8c0 x24: 0000000000000400
[ 4270.121439] x23: 0000000000000198 x22: ffff80271ad8b8c0
[ 4270.126737] x21: 0000000000000000 x20: ffff80275c847c80
[ 4270.132034] x19: 0000000000000000 x18: 0000000000000010
[ 4270.137332] x17: 0000000000000000 x16: 0000000000000000
[ 4270.142629] x15: ffff0000895099df x14: 6f7420343230312f
[ 4270.147927] x13: 34323031206d6f72 x12: ffff00000930b838
[ 4270.153224] x11: ffff0000086bfe70 x10: 785420676e69676e
[ 4270.158522] x9 : 00000000000271a1 x8 : 746520322e32303a
[ 4270.163819] x7 : 64373a3030303020 x6 : ffff8027dfacd270
[ 4270.169117] x5 : ffff8027dfacd270 x4 : 0000000000000000
[ 4270.174414] x3 : ffff8027dfad5848 x2 : 0ecdb7f3d9c07600
[ 4270.179712] x1 : 0000000000000000 x0 : 0000000000000000
[ 4270.185010] Process ethtool (pid: 17447, stack limit = 0x000000003a407b44)
[ 4270.191869] Call trace:
[ 4270.194304] hns3_free_
[ 4270.199342] hns3_free_
[ 4270.203685] hns3_fini_
[ 4270.207942] hns3_uninit_
[ 4270.212719] hns3_set_
[ 4270.217498] dev_ethtool+
[ 4270.221234] dev_ioctl+
[ 4270.224622] sock_do_
[ 4270.228270] sock_ioctl+
[ 4270.231746] do_vfs_
[ 4270.235307] ksys_ioctl+
[ 4270.238608] __arm64_
[ 4270.242517] el0_svc_
[ 4270.246252] el0_svc_
[ 4270.249987] el0_svc+0x8/0xc
[ 4270.252854] Code: 52800500 f9400a81 9b207e60 8b000035 (f8606822)
[ 4270.258933] Modules linked in: hclgevf(OE) hns3_dfx(OE) hns3(OE) hclge(OE) hnae3(OE)
[ 4270.266667] ---[ end trace d3f59d7a2d086cd1 ]---
[ 4270.271270] Kernel panic - not syncing: Fatal exception
[ 4270.276480] kernel fault(0x5) notification starting on CPU 37
[ 4270.282210] kernel fault(0x5) notification finished on CPU 37
[ 4270.287942] SMP: stopping secondary CPUs
[ 4270.291859] Kernel Offset: disabled
[ 4270.295334] CPU features: 0x2,a2a00a38
[ 4270.299068] Memory Limit: none
[ 4270.302119] kernel reboot(0x2) notification starting on CPU 37
[ 4270.307937] kernel reboot(0x2) notification finished on CPU 37
[ 4270.313755] ---[ end Kernel panic - not syncing: Fatal exception ]---
[Expected Results]
Ok.
[Reproducibility]
Inevitably
[Additional information]
Hardware: D06
Firmware: NA
Kernel: NA
[Resolution]
This patch refines it by setup new ring resources and
free the old ring resources in order.
net: hns3: refine for set ring parameters