| From 0861d1b4a85475a62ce6d232b4727970263584a3 Mon Sep 17 00:00:00 2001 |
| From: Huazhong Tan <tanhuazhong@huawei.com> |
| Date: Tue, 30 Oct 2018 21:50:46 +0800 |
| Subject: net: hns3: bugfix for the initialization of command queue's spin lock |
| |
| [ Upstream commit b2f74dbaf12bf59ff35d451005b3cdee78232ff0 ] |
| |
| 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> |
| Signed-off-by: Sasha Levin <sashal@kernel.org> |
| --- |
| .../net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c | 14 ++++++++++---- |
| 1 file 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) |
| { |
| int ret; |
| |
| + /* Setup the lock for command queue */ |
| + spin_lock_init(&hdev->hw.cmq.csq.lock); |
| + spin_lock_init(&hdev->hw.cmq.crq.lock); |
| + |
| /* Setup the queue entries for use cmd queue */ |
| hdev->hw.cmq.csq.desc_num = HCLGE_NIC_CMQ_DESC_NUM; |
| hdev->hw.cmq.crq.desc_num = HCLGE_NIC_CMQ_DESC_NUM; |
| @@ -337,18 +341,20 @@ int hclge_cmd_init(struct hclge_dev *hdev) |
| u32 version; |
| int ret; |
| |
| + spin_lock_bh(&hdev->hw.cmq.csq.lock); |
| + spin_lock_bh(&hdev->hw.cmq.crq.lock); |
| + |
| hdev->hw.cmq.csq.next_to_clean = 0; |
| hdev->hw.cmq.csq.next_to_use = 0; |
| hdev->hw.cmq.crq.next_to_clean = 0; |
| hdev->hw.cmq.crq.next_to_use = 0; |
| |
| - /* Setup the lock for command queue */ |
| - spin_lock_init(&hdev->hw.cmq.csq.lock); |
| - spin_lock_init(&hdev->hw.cmq.crq.lock); |
| - |
| hclge_cmd_init_regs(&hdev->hw); |
| clear_bit(HCLGE_STATE_CMD_DISABLE, &hdev->state); |
| |
| + spin_unlock_bh(&hdev->hw.cmq.crq.lock); |
| + spin_unlock_bh(&hdev->hw.cmq.csq.lock); |
| + |
| ret = hclge_cmd_query_firmware_version(&hdev->hw, &version); |
| if (ret) { |
| dev_err(&hdev->pdev->dev, |
| -- |
| 2.17.1 |
| |