Commit 08a764a7 authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Paolo Abeni

net: ethernet: mtk_wed: add reset/reset_complete callbacks

Introduce reset and reset_complete wlan callback to schedule WLAN driver
reset when ethernet/wed driver is resetting.
Tested-by: default avatarDaniel Golle <daniel@makrotopia.org>
Co-developed-by: default avatarSujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: default avatarSujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent 93b2591a
...@@ -3970,6 +3970,11 @@ static void mtk_pending_work(struct work_struct *work) ...@@ -3970,6 +3970,11 @@ static void mtk_pending_work(struct work_struct *work)
set_bit(MTK_RESETTING, &eth->state); set_bit(MTK_RESETTING, &eth->state);
mtk_prepare_for_reset(eth); mtk_prepare_for_reset(eth);
mtk_wed_fe_reset();
/* Run again reset preliminary configuration in order to avoid any
* possible race during FE reset since it can run releasing RTNL lock.
*/
mtk_prepare_for_reset(eth);
/* stop all devices to make sure that dma is properly shut down */ /* stop all devices to make sure that dma is properly shut down */
for (i = 0; i < MTK_MAC_COUNT; i++) { for (i = 0; i < MTK_MAC_COUNT; i++) {
...@@ -4007,6 +4012,8 @@ static void mtk_pending_work(struct work_struct *work) ...@@ -4007,6 +4012,8 @@ static void mtk_pending_work(struct work_struct *work)
clear_bit(MTK_RESETTING, &eth->state); clear_bit(MTK_RESETTING, &eth->state);
mtk_wed_fe_reset_complete();
rtnl_unlock(); rtnl_unlock();
} }
......
...@@ -206,6 +206,48 @@ mtk_wed_wo_reset(struct mtk_wed_device *dev) ...@@ -206,6 +206,48 @@ mtk_wed_wo_reset(struct mtk_wed_device *dev)
iounmap(reg); iounmap(reg);
} }
void mtk_wed_fe_reset(void)
{
int i;
mutex_lock(&hw_lock);
for (i = 0; i < ARRAY_SIZE(hw_list); i++) {
struct mtk_wed_hw *hw = hw_list[i];
struct mtk_wed_device *dev = hw->wed_dev;
int err;
if (!dev || !dev->wlan.reset)
continue;
/* reset callback blocks until WLAN reset is completed */
err = dev->wlan.reset(dev);
if (err)
dev_err(dev->dev, "wlan reset failed: %d\n", err);
}
mutex_unlock(&hw_lock);
}
void mtk_wed_fe_reset_complete(void)
{
int i;
mutex_lock(&hw_lock);
for (i = 0; i < ARRAY_SIZE(hw_list); i++) {
struct mtk_wed_hw *hw = hw_list[i];
struct mtk_wed_device *dev = hw->wed_dev;
if (!dev || !dev->wlan.reset_complete)
continue;
dev->wlan.reset_complete(dev);
}
mutex_unlock(&hw_lock);
}
static struct mtk_wed_hw * static struct mtk_wed_hw *
mtk_wed_assign(struct mtk_wed_device *dev) mtk_wed_assign(struct mtk_wed_device *dev)
{ {
......
...@@ -128,6 +128,8 @@ void mtk_wed_add_hw(struct device_node *np, struct mtk_eth *eth, ...@@ -128,6 +128,8 @@ void mtk_wed_add_hw(struct device_node *np, struct mtk_eth *eth,
void mtk_wed_exit(void); void mtk_wed_exit(void);
int mtk_wed_flow_add(int index); int mtk_wed_flow_add(int index);
void mtk_wed_flow_remove(int index); void mtk_wed_flow_remove(int index);
void mtk_wed_fe_reset(void);
void mtk_wed_fe_reset_complete(void);
#else #else
static inline void static inline void
mtk_wed_add_hw(struct device_node *np, struct mtk_eth *eth, mtk_wed_add_hw(struct device_node *np, struct mtk_eth *eth,
...@@ -147,6 +149,13 @@ static inline void mtk_wed_flow_remove(int index) ...@@ -147,6 +149,13 @@ static inline void mtk_wed_flow_remove(int index)
{ {
} }
static inline void mtk_wed_fe_reset(void)
{
}
static inline void mtk_wed_fe_reset_complete(void)
{
}
#endif #endif
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
......
...@@ -151,6 +151,8 @@ struct mtk_wed_device { ...@@ -151,6 +151,8 @@ struct mtk_wed_device {
void (*release_rx_buf)(struct mtk_wed_device *wed); void (*release_rx_buf)(struct mtk_wed_device *wed);
void (*update_wo_rx_stats)(struct mtk_wed_device *wed, void (*update_wo_rx_stats)(struct mtk_wed_device *wed,
struct mtk_wed_wo_rx_stats *stats); struct mtk_wed_wo_rx_stats *stats);
int (*reset)(struct mtk_wed_device *wed);
void (*reset_complete)(struct mtk_wed_device *wed);
} wlan; } wlan;
#endif #endif
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment