aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHuazhong Tan <tanhuazhong@huawei.com>2018-10-30 09:50:46 -0400
committerDavid S. Miller <davem@davemloft.net>2018-10-31 15:42:38 -0400
commitb2f74dbaf12bf59ff35d451005b3cdee78232ff0 (patch)
treedbbb1183aed14b295c647af31516ad9aecc8f864
parent0d4411408a7fb9aad0645f23911d9bfdd2ce3177 (diff)
net: hns3: bugfix for the initialization of command queue's spin lock
The spin lock of the command queue only need to be initialized once when the driver initializes the command queue. It is not necessary to initialize the spin lock when resetting. At the same time, the modification of the queue member should be performed after acquiring the lock. Fixes: 3efb960f056d ("net: hns3: Refactor the initialization of command queue") Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c
index ac13cb2b168e..68026a5ad7e7 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c
@@ -304,6 +304,10 @@ int hclge_cmd_queue_init(struct hclge_dev *hdev)
304{ 304{
305 int ret; 305 int ret;
306 306
307 /* Setup the lock for command queue */
308 spin_lock_init(&hdev->hw.cmq.csq.lock);
309 spin_lock_init(&hdev->hw.cmq.crq.lock);
310
307 /* Setup the queue entries for use cmd queue */ 311 /* Setup the queue entries for use cmd queue */
308 hdev->hw.cmq.csq.desc_num = HCLGE_NIC_CMQ_DESC_NUM; 312 hdev->hw.cmq.csq.desc_num = HCLGE_NIC_CMQ_DESC_NUM;
309 hdev->hw.cmq.crq.desc_num = HCLGE_NIC_CMQ_DESC_NUM; 313 hdev->hw.cmq.crq.desc_num = HCLGE_NIC_CMQ_DESC_NUM;
@@ -337,18 +341,20 @@ int hclge_cmd_init(struct hclge_dev *hdev)
337 u32 version; 341 u32 version;
338 int ret; 342 int ret;
339 343
344 spin_lock_bh(&hdev->hw.cmq.csq.lock);
345 spin_lock_bh(&hdev->hw.cmq.crq.lock);
346
340 hdev->hw.cmq.csq.next_to_clean = 0; 347 hdev->hw.cmq.csq.next_to_clean = 0;
341 hdev->hw.cmq.csq.next_to_use = 0; 348 hdev->hw.cmq.csq.next_to_use = 0;
342 hdev->hw.cmq.crq.next_to_clean = 0; 349 hdev->hw.cmq.crq.next_to_clean = 0;
343 hdev->hw.cmq.crq.next_to_use = 0; 350 hdev->hw.cmq.crq.next_to_use = 0;
344 351
345 /* Setup the lock for command queue */
346 spin_lock_init(&hdev->hw.cmq.csq.lock);
347 spin_lock_init(&hdev->hw.cmq.crq.lock);
348
349 hclge_cmd_init_regs(&hdev->hw); 352 hclge_cmd_init_regs(&hdev->hw);
350 clear_bit(HCLGE_STATE_CMD_DISABLE, &hdev->state); 353 clear_bit(HCLGE_STATE_CMD_DISABLE, &hdev->state);
351 354
355 spin_unlock_bh(&hdev->hw.cmq.crq.lock);
356 spin_unlock_bh(&hdev->hw.cmq.csq.lock);
357
352 ret = hclge_cmd_query_firmware_version(&hdev->hw, &version); 358 ret = hclge_cmd_query_firmware_version(&hdev->hw, &version);
353 if (ret) { 359 if (ret) {
354 dev_err(&hdev->pdev->dev, 360 dev_err(&hdev->pdev->dev,