From: Chiqijun chiqijun@huawei.com
driver inclusion category: bugfix bugzilla: 4472
-----------------------------------------------------------------------
Semaphore, spin_lock, etc. in linux do not need to be deinitialized, remove these useless definitions. Directly use the linux interface, the driver no longer encapsulates functions.
Signed-off-by: Chiqijun chiqijun@huawei.com Reviewed-by: Zengweiliang zengweiliang.zengweiliang@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- .../net/ethernet/huawei/hinic/hinic_api_cmd.c | 20 ++------------ drivers/net/ethernet/huawei/hinic/hinic_cfg.c | 13 ---------- .../net/ethernet/huawei/hinic/hinic_cmdq.c | 6 ----- .../net/ethernet/huawei/hinic/hinic_hwdev.c | 7 ++--- .../net/ethernet/huawei/hinic/hinic_hwif.c | 2 -- .../net/ethernet/huawei/hinic/hinic_mbox.c | 13 ---------- .../net/ethernet/huawei/hinic/hinic_mgmt.c | 11 -------- .../net/ethernet/huawei/hinic/hinic_nic_cfg.c | 3 --- drivers/net/ethernet/huawei/hinic/hinic_rx.c | 3 +-- drivers/net/ethernet/huawei/hinic/hinic_tx.c | 4 +-- drivers/net/ethernet/huawei/hinic/hinic_wq.c | 2 -- .../ethernet/huawei/hinic/ossl_knl_linux.c | 22 ---------------- .../ethernet/huawei/hinic/ossl_knl_linux.h | 26 ------------------- 13 files changed, 7 insertions(+), 125 deletions(-)
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_api_cmd.c b/drivers/net/ethernet/huawei/hinic/hinic_api_cmd.c index e611faa945b2..5a1e8655be38 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_api_cmd.c +++ b/drivers/net/ethernet/huawei/hinic/hinic_api_cmd.c @@ -971,15 +971,13 @@ static int api_chain_init(struct hinic_api_cmd_chain *chain, cell_ctxt_size = chain->num_cells * sizeof(*chain->cell_ctxt); if (!cell_ctxt_size) { sdk_err(dev, "Api chain cell size cannot be zero\n"); - err = -EINVAL; - goto alloc_cell_ctxt_err; + return -EINVAL; }
chain->cell_ctxt = kzalloc(cell_ctxt_size, GFP_KERNEL); if (!chain->cell_ctxt) { sdk_err(dev, "Failed to allocate cell contexts for a chain\n"); - err = -ENOMEM; - goto alloc_cell_ctxt_err; + return -ENOMEM; }
chain->wb_status = dma_zalloc_coherent(dev, @@ -1032,13 +1030,6 @@ static int api_chain_init(struct hinic_api_cmd_chain *chain, alloc_wb_status_err: kfree(chain->cell_ctxt);
-/*lint -save -e548*/ -alloc_cell_ctxt_err: - if (chain->chain_type == HINIC_API_CMD_WRITE_ASYNC_TO_MGMT_CPU) - spin_lock_deinit(&chain->async_lock); - else - sema_deinit(&chain->sem); -/*lint -restore*/ return err; }
@@ -1055,13 +1046,6 @@ static void api_chain_free(struct hinic_api_cmd_chain *chain) dma_free_coherent(dev, sizeof(*chain->wb_status), chain->wb_status, chain->wb_status_paddr); kfree(chain->cell_ctxt); - -/*lint -save -e548*/ - if (chain->chain_type == HINIC_API_CMD_WRITE_ASYNC_TO_MGMT_CPU) - spin_lock_deinit(&chain->async_lock); - else - sema_deinit(&chain->sem); -/*lint -restore*/ }
/** diff --git a/drivers/net/ethernet/huawei/hinic/hinic_cfg.c b/drivers/net/ethernet/huawei/hinic/hinic_cfg.c index 68149027e403..05f9a58d2ec9 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_cfg.c +++ b/drivers/net/ethernet/huawei/hinic/hinic_cfg.c @@ -1485,12 +1485,10 @@ int init_cfg_mgmt(struct hinic_hwdev *dev)
free_interrupt_mem: kfree(cfg_mgmt->irq_param_info.alloc_info); - mutex_deinit(&((cfg_mgmt->irq_param_info).irq_mutex)); cfg_mgmt->irq_param_info.alloc_info = NULL;
free_eq_mem: kfree(cfg_mgmt->eq_info.eq); - mutex_deinit(&cfg_mgmt->eq_info.eq_mutex); cfg_mgmt->eq_info.eq = NULL;
free_mgmt_mem: @@ -1524,11 +1522,9 @@ void free_cfg_mgmt(struct hinic_hwdev *dev)
kfree(cfg_mgmt->irq_param_info.alloc_info); cfg_mgmt->irq_param_info.alloc_info = NULL; - mutex_deinit(&((cfg_mgmt->irq_param_info).irq_mutex));
kfree(cfg_mgmt->eq_info.eq); cfg_mgmt->eq_info.eq = NULL; - mutex_deinit(&cfg_mgmt->eq_info.eq_mutex);
kfree(cfg_mgmt); } @@ -2141,16 +2137,11 @@ static int hinic_os_dep_init(struct hinic_hwdev *hwdev)
static void hinic_os_dep_deinit(struct hinic_hwdev *hwdev) { - destroy_work(&hwdev->fault_work); - destroy_workqueue(hwdev->workq);
down(&hwdev->fault_list_sem);
up(&hwdev->fault_list_sem); - - sema_deinit(&hwdev->fault_list_sem); - sema_deinit(&hwdev->recover_sem); }
void hinic_ppf_hwdev_unreg(void *hwdev) @@ -2335,8 +2326,6 @@ int hinic_init_hwdev(struct hinic_init_para *para) vfree(hwdev->chip_fault_stats);
alloc_chip_fault_stats_err: - sema_deinit(&hwdev->func_sem); - sema_deinit(&hwdev->ppf_sem); kfree(hwdev); *para->hwdev = NULL;
@@ -2406,8 +2395,6 @@ void hinic_free_hwdev(void *hwdev) clear_bit(HINIC_HWDEV_NONE_INITED, &dev->func_state); hinic_free_hwif(dev); vfree(dev->chip_fault_stats); - sema_deinit(&dev->func_sem); - sema_deinit(&dev->ppf_sem); kfree(dev); }
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_cmdq.c b/drivers/net/ethernet/huawei/hinic/hinic_cmdq.c index 38b54860e4bc..d7802caca0a6 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_cmdq.c +++ b/drivers/net/ethernet/huawei/hinic/hinic_cmdq.c @@ -672,12 +672,10 @@ static int cmdq_sync_cmd_direct_resp(struct hinic_cmdq *cmdq, sdk_err(cmdq->hwdev->dev_hdl, "Cmdq sync command timeout, prod idx: 0x%x\n", curr_prod_idx); hinic_dump_ceq_info(cmdq->hwdev); - destroy_completion(&done); return -ETIMEDOUT; }
timeout_check_ok: - destroy_completion(&done); smp_rmb(); /* read error code after completion */
if (errcode > 1) @@ -803,12 +801,10 @@ static int cmdq_sync_cmd_detail_resp(struct hinic_cmdq *cmdq, sdk_err(cmdq->hwdev->dev_hdl, "Cmdq sync command timeout, prod idx: 0x%x\n", curr_prod_idx); hinic_dump_ceq_info(cmdq->hwdev); - destroy_completion(&done); return -ETIMEDOUT; }
timeout_check_ok: - destroy_completion(&done); smp_rmb(); /* read error code after completion */
if (errcode > 1) @@ -1354,7 +1350,6 @@ static int init_cmdq(struct hinic_cmdq *cmdq, struct hinic_hwdev *hwdev, kfree(cmdq->cmd_infos);
cmd_infos_err: - spin_lock_deinit(&cmdq->cmdq_lock);
return err; } @@ -1363,7 +1358,6 @@ static void free_cmdq(struct hinic_hwdev *hwdev, struct hinic_cmdq *cmdq) { hinic_free_db_addr(hwdev, cmdq->db_base, NULL); kfree(cmdq->cmd_infos); - spin_lock_deinit(&cmdq->cmdq_lock); }
int hinic_set_cmdq_ctxts(struct hinic_hwdev *hwdev) diff --git a/drivers/net/ethernet/huawei/hinic/hinic_hwdev.c b/drivers/net/ethernet/huawei/hinic/hinic_hwdev.c index 3ae6e215b907..1d56349c0c11 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_hwdev.c +++ b/drivers/net/ethernet/huawei/hinic/hinic_hwdev.c @@ -4677,7 +4677,6 @@ static void hinic_heartbeat_timer_handler(unsigned long data) if (__detect_heartbeat_ehd_lost(hwdev) || !hinic_get_heartbeat_status(hwdev)) { hwdev->heartbeat_lost = 1; - stop_timer(&hwdev->heartbeat_timer); queue_work(hwdev->workq, &hwdev->timer_work); } else { mod_timer(&hwdev->heartbeat_timer, @@ -4697,16 +4696,14 @@ void hinic_init_heartbeat(struct hinic_hwdev *hwdev) hwdev->heartbeat_timer.expires = jiffies + msecs_to_jiffies(HINIC_HEARTBEAT_START_EXPIRE);
- add_to_timer(&hwdev->heartbeat_timer, HINIC_HEARTBEAT_PERIOD); + add_timer(&hwdev->heartbeat_timer);
INIT_WORK(&hwdev->timer_work, hinic_heartbeat_event_handler); }
void hinic_destroy_heartbeat(struct hinic_hwdev *hwdev) { - destroy_work(&hwdev->timer_work); - stop_timer(&hwdev->heartbeat_timer); - delete_timer(&hwdev->heartbeat_timer); + del_timer_sync(&hwdev->heartbeat_timer); }
u8 hinic_nic_sw_aeqe_handler(void *handle, u8 event, u64 data) diff --git a/drivers/net/ethernet/huawei/hinic/hinic_hwif.c b/drivers/net/ethernet/huawei/hinic/hinic_hwif.c index b267084d3672..dcb7471227cf 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_hwif.c +++ b/drivers/net/ethernet/huawei/hinic/hinic_hwif.c @@ -622,7 +622,6 @@ int hinic_init_hwif(struct hinic_hwdev *hwdev, void *cfg_reg_base, return 0;
hwif_ready_err: - spin_lock_deinit(&hwif->free_db_area.idx_lock); kfree(hwif);
return err; @@ -634,7 +633,6 @@ int hinic_init_hwif(struct hinic_hwdev *hwdev, void *cfg_reg_base, */ void hinic_free_hwif(struct hinic_hwdev *hwdev) { - spin_lock_deinit(&hwdev->hwif->free_db_area.idx_lock); kfree(hwdev->hwif); }
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_mbox.c b/drivers/net/ethernet/huawei/hinic/hinic_mbox.c index add76893055d..bbc16cc38b33 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_mbox.c +++ b/drivers/net/ethernet/huawei/hinic/hinic_mbox.c @@ -699,8 +699,6 @@ static void recv_func_mbox_work_handler(struct work_struct *work) recv_func_mbox_handler(mbox_work->func_to_func, mbox_work->recv_mbox, mbox_work->src_func_idx);
- destroy_work(&mbox_work->work); - kfree(mbox_work); }
@@ -840,8 +838,6 @@ static void update_random_id_work_handler(struct work_struct *work) sdk_warn(func_to_func->hwdev->dev_hdl, "Update vf id(0x%x) random id fail\n", mbox_work->src_func_idx);
- destroy_work(&mbox_work->work); - kfree(mbox_work); }
@@ -1087,10 +1083,8 @@ static int send_mbox_seg(struct hinic_mbox_func_to_func *func_to_func, if (!wait_for_completion_timeout(done, jif)) { sdk_err(hwdev->dev_hdl, "Send mailbox segment timeout\n"); dump_mox_reg(hwdev); - destroy_completion(done); return -ETIMEDOUT; } - destroy_completion(done);
wb_status = get_mbox_status(send_mbox); } @@ -1247,7 +1241,6 @@ int hinic_mbox_to_func(struct hinic_mbox_func_to_func *func_to_func, }
send_err: - destroy_completion(&mbox_for_resp->recv_done); up(&func_to_func->mbox_send_sem);
return err; @@ -1670,9 +1663,6 @@ int hinic_func_to_func_init(struct hinic_hwdev *hwdev) destroy_workqueue(func_to_func->workq);
create_mbox_workq_err: - spin_lock_deinit(&func_to_func->mbox_lock); - sema_deinit(&func_to_func->msg_send_sem); - sema_deinit(&func_to_func->mbox_send_sem); kfree(func_to_func);
return err; @@ -1690,9 +1680,6 @@ void hinic_func_to_func_free(struct hinic_hwdev *hwdev) free_mbox_wb_status(func_to_func); free_mbox_info(func_to_func->mbox_resp); free_mbox_info(func_to_func->mbox_send); - spin_lock_deinit(&func_to_func->mbox_lock); - sema_deinit(&func_to_func->mbox_send_sem); - sema_deinit(&func_to_func->msg_send_sem);
kfree(func_to_func); } diff --git a/drivers/net/ethernet/huawei/hinic/hinic_mgmt.c b/drivers/net/ethernet/huawei/hinic/hinic_mgmt.c index ac9988710cad..510f5365baa7 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_mgmt.c +++ b/drivers/net/ethernet/huawei/hinic/hinic_mgmt.c @@ -461,7 +461,6 @@ int hinic_pf_to_mgmt_sync(void *hwdev, enum hinic_mod_type mod, u8 cmd, pf_to_mgmt_send_event_set(pf_to_mgmt, SEND_EVENT_END);
if (!(((struct hinic_hwdev *)hwdev)->chip_present_flag)) { - destroy_completion(recv_done); up(&pf_to_mgmt->sync_msg_lock); return -ETIMEDOUT; } @@ -481,7 +480,6 @@ int hinic_pf_to_mgmt_sync(void *hwdev, enum hinic_mod_type mod, u8 cmd, }
unlock_sync_msg: - destroy_completion(recv_done); up(&pf_to_mgmt->sync_msg_lock);
return err; @@ -1113,8 +1111,6 @@ static void recv_mgmt_msg_work_handler(struct work_struct *work) mgmt_work->msg_len, mgmt_work->msg_id, !mgmt_work->async_mgmt_to_pf);
- destroy_work(&mgmt_work->work); - kfree(mgmt_work->msg); kfree(mgmt_work); } @@ -1387,9 +1383,6 @@ int hinic_pf_to_mgmt_init(struct hinic_hwdev *hwdev) destroy_workqueue(pf_to_mgmt->workq);
create_mgmt_workq_err: - spin_lock_deinit(&pf_to_mgmt->sync_event_lock); - spin_lock_deinit(&pf_to_mgmt->async_msg_lock); - sema_deinit(&pf_to_mgmt->sync_msg_lock); kfree(pf_to_mgmt);
return err; @@ -1409,9 +1402,6 @@ void hinic_pf_to_mgmt_free(struct hinic_hwdev *hwdev) destroy_workqueue(pf_to_mgmt->workq); hinic_api_cmd_free(pf_to_mgmt->cmd_chain); free_msg_buf(pf_to_mgmt); - spin_lock_deinit(&pf_to_mgmt->sync_event_lock); - spin_lock_deinit(&pf_to_mgmt->async_msg_lock); - sema_deinit(&pf_to_mgmt->sync_msg_lock); kfree(pf_to_mgmt); }
@@ -1451,7 +1441,6 @@ void hinic_clp_pf_to_mgmt_free(struct hinic_hwdev *hwdev) { struct hinic_clp_pf_to_mgmt *clp_pf_to_mgmt = hwdev->clp_pf_to_mgmt;
- sema_deinit(&clp_pf_to_mgmt->clp_msg_lock); kfree(clp_pf_to_mgmt->clp_msg_buf); kfree(clp_pf_to_mgmt); } diff --git a/drivers/net/ethernet/huawei/hinic/hinic_nic_cfg.c b/drivers/net/ethernet/huawei/hinic/hinic_nic_cfg.c index fb94588daa30..9acde2025cd6 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_nic_cfg.c +++ b/drivers/net/ethernet/huawei/hinic/hinic_nic_cfg.c @@ -2922,7 +2922,6 @@ int hinic_vf_func_init(struct hinic_hwdev *hwdev) kfree(nic_io->vf_infos);
out_free_nic_io: - sema_deinit(&hwdev->nic_io->nic_cfg.cfg_lock); kfree(hwdev->nic_io); hwdev->nic_io = NULL;
@@ -2950,8 +2949,6 @@ void hinic_vf_func_free(struct hinic_hwdev *hwdev) } }
- sema_deinit(&hwdev->nic_io->nic_cfg.cfg_lock); - kfree(hwdev->nic_io); hwdev->nic_io = NULL; } diff --git a/drivers/net/ethernet/huawei/hinic/hinic_rx.c b/drivers/net/ethernet/huawei/hinic/hinic_rx.c index c8cbcdfd5883..977f816e7258 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_rx.c +++ b/drivers/net/ethernet/huawei/hinic/hinic_rx.c @@ -67,8 +67,7 @@ static bool rx_alloc_mapped_page(struct hinic_rxq *rxq, return true;
/* alloc new page for storage */ - page = alloc_pages_node(NUMA_NO_NODE, GFP_ATOMIC | __GFP_COLD | - __GFP_COMP, nic_dev->page_order); + page = alloc_pages_node(NUMA_NO_NODE, GFP_ATOMIC, nic_dev->page_order); if (unlikely(!page)) { nicif_err(nic_dev, drv, netdev, "Alloc rxq: %d page failed\n", rxq->q_id); diff --git a/drivers/net/ethernet/huawei/hinic/hinic_tx.c b/drivers/net/ethernet/huawei/hinic/hinic_tx.c index 3d9d9d0d6d0c..be57be78feee 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_tx.c +++ b/drivers/net/ethernet/huawei/hinic/hinic_tx.c @@ -155,9 +155,9 @@ static int tx_map_skb(struct hinic_nic_dev *nic_dev, struct sk_buff *skb, frag = &skb_shinfo(skb)->frags[i - 1]; nsize = skb_frag_size(frag);
- vaddr = _kc_kmap_atomic(skb_frag_page(frag)); + vaddr = kmap_atomic(skb_frag_page(frag)); memcpy(cpy_buff, vaddr + frag->page_offset, nsize); - _kc_kunmap_atomic(vaddr); + kunmap_atomic(vaddr); cpy_buff += nsize; } } diff --git a/drivers/net/ethernet/huawei/hinic/hinic_wq.c b/drivers/net/ethernet/huawei/hinic/hinic_wq.c index 4d8180c6b271..032b28332a65 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_wq.c +++ b/drivers/net/ethernet/huawei/hinic/hinic_wq.c @@ -528,8 +528,6 @@ void hinic_wqs_free(struct hinic_wqs *wqs) { u32 page_idx;
- spin_lock_deinit(&wqs->alloc_blocks_lock); - for (page_idx = 0; page_idx < wqs->num_pages; page_idx++) wqs_free_page(wqs, page_idx);
diff --git a/drivers/net/ethernet/huawei/hinic/ossl_knl_linux.c b/drivers/net/ethernet/huawei/hinic/ossl_knl_linux.c index daed2eca32c1..1aa09e55c64e 100644 --- a/drivers/net/ethernet/huawei/hinic/ossl_knl_linux.c +++ b/drivers/net/ethernet/huawei/hinic/ossl_knl_linux.c @@ -13,30 +13,8 @@ * */
-#include <linux/pci_regs.h> - #include "ossl_knl_linux.h"
-void add_to_timer(struct timer_list *timer, long period) -{ - if (!timer) - return; - - add_timer(timer); -} - -void stop_timer(struct timer_list *timer) -{ -} - -void delete_timer(struct timer_list *timer) -{ - if (!timer) - return; - - del_timer_sync(timer); -} - int local_atoi(const char *name) { int val = 0; diff --git a/drivers/net/ethernet/huawei/hinic/ossl_knl_linux.h b/drivers/net/ethernet/huawei/hinic/ossl_knl_linux.h index dd5d0fc949d7..c15958aecd9a 100644 --- a/drivers/net/ethernet/huawei/hinic/ossl_knl_linux.h +++ b/drivers/net/ethernet/huawei/hinic/ossl_knl_linux.h @@ -29,14 +29,6 @@ #include <linux/udp.h> #include <linux/highmem.h>
-#ifndef __GFP_COLD -#define __GFP_COLD 0 -#endif - -#ifndef __GFP_COMP -#define __GFP_COMP 0 -#endif - #ifndef SUPPORTED_100000baseKR4_Full #define SUPPORTED_100000baseKR4_Full 0 #define ADVERTISED_100000baseKR4_Full 0 @@ -142,12 +134,6 @@
#define HAVE_NDO_SET_VF_TRUST
-/*****************************************************************************/ -#include <linux/kconfig.h> - -#define _kc_kmap_atomic(page) kmap_atomic(page) -#define _kc_kunmap_atomic(addr) kunmap_atomic(addr) - /*****************************************************************************/ #define HAVE_NAPI_GRO_FLUSH_OLD
@@ -208,13 +194,6 @@
#define HAVE_ENCAPSULATION_CSUM
-#define spin_lock_deinit(lock) - -#define destroy_work(work) -void add_to_timer(struct timer_list *timer, long period); -void stop_timer(struct timer_list *timer); -void delete_timer(struct timer_list *timer); - int local_atoi(const char *name);
#define nicif_err(priv, type, dev, fmt, args...) \ @@ -228,11 +207,6 @@ int local_atoi(const char *name); #define nicif_dbg(priv, type, dev, fmt, args...) \ netif_level(dbg, priv, type, dev, "[NIC]"fmt, ##args)
-#define destroy_completion(completion) -#define sema_deinit(lock) -#define mutex_deinit(lock) -#define rwlock_deinit(lock) - #define tasklet_state(tasklet) ((tasklet)->state)
#endif