Skip to content

Commit 094c281

Browse files
Peiyang WangPaolo Abeni
authored andcommitted
net: hns3: use appropriate barrier function after setting a bit value
There is a memory barrier in followed case. When set the port down, hclgevf_set_timmer will set DOWN in state. Meanwhile, the service task has different behaviour based on whether the state is DOWN. Thus, to make sure service task see DOWN, use smp_mb__after_atomic after calling set_bit(). CPU0 CPU1 ========================== =================================== hclgevf_set_timer_task() hclgevf_periodic_service_task() set_bit(DOWN,state) test_bit(DOWN,state) pf also has this issue. Fixes: ff20009 ("net: hns3: remove unnecessary work in hclgevf_main") Fixes: 1c6dfe6 ("net: hns3: remove mailbox and reset work in hclge_main") Signed-off-by: Peiyang Wang <wangpeiyang1@huawei.com> Signed-off-by: Jijie Shao <shaojijie@huawei.com> Reviewed-by: Simon Horman <horms@kernel.org> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 950aa42 commit 094c281

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7957,8 +7957,7 @@ static void hclge_set_timer_task(struct hnae3_handle *handle, bool enable)
79577957
/* Set the DOWN flag here to disable link updating */
79587958
set_bit(HCLGE_STATE_DOWN, &hdev->state);
79597959

7960-
/* flush memory to make sure DOWN is seen by service task */
7961-
smp_mb__before_atomic();
7960+
smp_mb__after_atomic(); /* flush memory to make sure DOWN is seen by service task */
79627961
hclge_flush_link_update(hdev);
79637962
}
79647963
}

drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2181,8 +2181,7 @@ static void hclgevf_set_timer_task(struct hnae3_handle *handle, bool enable)
21812181
} else {
21822182
set_bit(HCLGEVF_STATE_DOWN, &hdev->state);
21832183

2184-
/* flush memory to make sure DOWN is seen by service task */
2185-
smp_mb__before_atomic();
2184+
smp_mb__after_atomic(); /* flush memory to make sure DOWN is seen by service task */
21862185
hclgevf_flush_link_update(hdev);
21872186
}
21882187
}

0 commit comments

Comments
 (0)