Skip to content

Commit b3c3fe8

Browse files
Yunsheng Lindavem330
authored andcommitted
net: hns3: schedule hclgevf_service by using delayed workqueue
Currently, a timer is defined to schedule hclgevf_service per second. To simplify the code, this patch uses the delayed work instead of timer to schedule hclgevf_serive. Signed-off-by: Yunsheng Lin <[email protected]> Signed-off-by: Huazhong Tan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 54e1f08 commit b3c3fe8

File tree

2 files changed

+15
-27
lines changed

2 files changed

+15
-27
lines changed

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

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1786,8 +1786,11 @@ void hclgevf_mbx_task_schedule(struct hclgevf_dev *hdev)
17861786
static void hclgevf_task_schedule(struct hclgevf_dev *hdev)
17871787
{
17881788
if (!test_bit(HCLGEVF_STATE_DOWN, &hdev->state) &&
1789-
!test_and_set_bit(HCLGEVF_STATE_SERVICE_SCHED, &hdev->state))
1790-
schedule_work(&hdev->service_task);
1789+
!test_and_set_bit(HCLGEVF_STATE_SERVICE_SCHED, &hdev->state)) {
1790+
mod_delayed_work(system_wq, &hdev->service_task,
1791+
round_jiffies_relative(HZ));
1792+
hdev->stats_timer++;
1793+
}
17911794
}
17921795

17931796
static void hclgevf_deferred_task_schedule(struct hclgevf_dev *hdev)
@@ -1800,17 +1803,6 @@ static void hclgevf_deferred_task_schedule(struct hclgevf_dev *hdev)
18001803
hclgevf_reset_task_schedule(hdev);
18011804
}
18021805

1803-
static void hclgevf_service_timer(struct timer_list *t)
1804-
{
1805-
struct hclgevf_dev *hdev = from_timer(hdev, t, service_timer);
1806-
1807-
mod_timer(&hdev->service_timer, jiffies +
1808-
HCLGEVF_GENERAL_TASK_INTERVAL * HZ);
1809-
1810-
hdev->stats_timer++;
1811-
hclgevf_task_schedule(hdev);
1812-
}
1813-
18141806
static void hclgevf_reset_service_task(struct work_struct *work)
18151807
{
18161808
#define HCLGEVF_MAX_RESET_ATTEMPTS_CNT 3
@@ -1933,7 +1925,7 @@ static void hclgevf_service_task(struct work_struct *work)
19331925
struct hnae3_handle *handle;
19341926
struct hclgevf_dev *hdev;
19351927

1936-
hdev = container_of(work, struct hclgevf_dev, service_task);
1928+
hdev = container_of(work, struct hclgevf_dev, service_task.work);
19371929
handle = &hdev->nic;
19381930

19391931
if (hdev->stats_timer >= HCLGEVF_STATS_TIMER_INTERVAL) {
@@ -1953,6 +1945,8 @@ static void hclgevf_service_task(struct work_struct *work)
19531945
hclgevf_deferred_task_schedule(hdev);
19541946

19551947
clear_bit(HCLGEVF_STATE_SERVICE_SCHED, &hdev->state);
1948+
1949+
hclgevf_task_schedule(hdev);
19561950
}
19571951

19581952
static void hclgevf_clear_event_cause(struct hclgevf_dev *hdev, u32 regclr)
@@ -2194,10 +2188,10 @@ static void hclgevf_set_timer_task(struct hnae3_handle *handle, bool enable)
21942188
struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
21952189

21962190
if (enable) {
2197-
mod_timer(&hdev->service_timer, jiffies + HZ);
2191+
hclgevf_task_schedule(hdev);
21982192
} else {
2199-
del_timer_sync(&hdev->service_timer);
2200-
cancel_work_sync(&hdev->service_task);
2193+
set_bit(HCLGEVF_STATE_DOWN, &hdev->state);
2194+
cancel_delayed_work_sync(&hdev->service_task);
22012195
clear_bit(HCLGEVF_STATE_SERVICE_SCHED, &hdev->state);
22022196
}
22032197
}
@@ -2279,10 +2273,7 @@ static void hclgevf_state_init(struct hclgevf_dev *hdev)
22792273
clear_bit(HCLGEVF_STATE_MBX_SERVICE_SCHED, &hdev->state);
22802274
clear_bit(HCLGEVF_STATE_MBX_HANDLING, &hdev->state);
22812275

2282-
/* setup tasks for service timer */
2283-
timer_setup(&hdev->service_timer, hclgevf_service_timer, 0);
2284-
2285-
INIT_WORK(&hdev->service_task, hclgevf_service_task);
2276+
INIT_DELAYED_WORK(&hdev->service_task, hclgevf_service_task);
22862277
clear_bit(HCLGEVF_STATE_SERVICE_SCHED, &hdev->state);
22872278

22882279
INIT_WORK(&hdev->rst_service_task, hclgevf_reset_service_task);
@@ -2302,10 +2293,8 @@ static void hclgevf_state_uninit(struct hclgevf_dev *hdev)
23022293
del_timer_sync(&hdev->keep_alive_timer);
23032294
if (hdev->keep_alive_task.func)
23042295
cancel_work_sync(&hdev->keep_alive_task);
2305-
if (hdev->service_timer.function)
2306-
del_timer_sync(&hdev->service_timer);
2307-
if (hdev->service_task.func)
2308-
cancel_work_sync(&hdev->service_task);
2296+
if (hdev->service_task.work.func)
2297+
cancel_delayed_work_sync(&hdev->service_task);
23092298
if (hdev->mbx_service_task.func)
23102299
cancel_work_sync(&hdev->mbx_service_task);
23112300
if (hdev->rst_service_task.func)

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,8 @@ struct hclgevf_dev {
283283
struct hclgevf_mbx_resp_status mbx_resp; /* mailbox response */
284284
struct hclgevf_mbx_arq_ring arq; /* mailbox async rx queue */
285285

286-
struct timer_list service_timer;
287286
struct timer_list keep_alive_timer;
288-
struct work_struct service_task;
287+
struct delayed_work service_task;
289288
struct work_struct keep_alive_task;
290289
struct work_struct rst_service_task;
291290
struct work_struct mbx_service_task;

0 commit comments

Comments
 (0)