ath11k: mhi cleanup
cover ath11k: mhi cleanup
From: Kalle Valo <[email protected]>
Some minor cleanup to mhi.c, please review.
Kalle Valo (3):
ath11k: mhi: remove state machine
ath11k: mhi: add error handling for suspend and resume
ath11k: mhi: remove unnecessary goto from ath11k_mhi_start()
drivers/net/wireless/ath/ath11k/mhi.c | 222 ++++---------------------- drivers/net/wireless/ath/ath11k/mhi.h | 17 +- drivers/net/wireless/ath/ath11k/pci.c | 8 +- drivers/net/wireless/ath/ath11k/pci.h | 1 - 4 files changed, 38 insertions(+), 210 deletions(-)
base-commit: 57b7042c114767b7330b14a260f61732e556742e
Signature · 1 line
2.30.2
PATCH 1/3 ath11k: mhi: remove state machine
From: Kalle Valo <[email protected]>
State machines are difficult to understand and in this case it's just useless, which is shown by the diffstat. So remove it entirely to make the code simpler.
No functional changes.
Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03003-QCAHSPSWPL_V1_V2_SILICONZ_LITE-2
--- drivers/net/wireless/ath/ath11k/mhi.c | 194 ++------------------------ drivers/net/wireless/ath/ath11k/mhi.h | 13 -- drivers/net/wireless/ath/ath11k/pci.h | 1 - 3 files changed, 10 insertions(+), 198 deletions(-)
drivers/net/wireless/ath/ath11k/mhi.c +10 -184
@@ -461,195 +461,17 @@ void ath11k_mhi_unregister(struct ath11k_pci *ab_pci)mhi_free_controller (mhi_ctrl); } -static char *ath11k_mhi_state_to_str (enum ath11k_mhi_state mhi_state) -{ -switch (mhi_state) { -case ATH11K_MHI_INIT : -return "INIT" ; -case ATH11K_MHI_DEINIT : -return "DEINIT" ; -case ATH11K_MHI_POWER_ON : -return "POWER_ON" ; -case ATH11K_MHI_POWER_OFF : -return "POWER_OFF" ; -case ATH11K_MHI_FORCE_POWER_OFF : -return "FORCE_POWER_OFF" ; -case ATH11K_MHI_SUSPEND : -return "SUSPEND" ; -case ATH11K_MHI_RESUME : -return "RESUME" ; -case ATH11K_MHI_TRIGGER_RDDM : -return "TRIGGER_RDDM" ; -case ATH11K_MHI_RDDM_DONE : -return "RDDM_DONE" ; -default : -return "UNKNOWN" ; - } -}; - -static void ath11k_mhi_set_state_bit (struct ath11k_pci *ab_pci, -enum ath11k_mhi_state mhi_state) -{ -struct ath11k_base *ab = ab_pci->ab; - -switch (mhi_state) { -case ATH11K_MHI_INIT : -set_bit (ATH11K_MHI_INIT , &ab_pci->mhi_state); -break ; -case ATH11K_MHI_DEINIT : -clear_bit (ATH11K_MHI_INIT , &ab_pci->mhi_state); -break ; -case ATH11K_MHI_POWER_ON : -set_bit (ATH11K_MHI_POWER_ON , &ab_pci->mhi_state); -break ; -case ATH11K_MHI_POWER_OFF : -case ATH11K_MHI_FORCE_POWER_OFF : -clear_bit (ATH11K_MHI_POWER_ON , &ab_pci->mhi_state); -clear_bit (ATH11K_MHI_TRIGGER_RDDM , &ab_pci->mhi_state); -clear_bit (ATH11K_MHI_RDDM_DONE , &ab_pci->mhi_state); -break ; -case ATH11K_MHI_SUSPEND : -set_bit (ATH11K_MHI_SUSPEND , &ab_pci->mhi_state); -break ; -case ATH11K_MHI_RESUME : -clear_bit (ATH11K_MHI_SUSPEND , &ab_pci->mhi_state); -break ; -case ATH11K_MHI_TRIGGER_RDDM : -set_bit (ATH11K_MHI_TRIGGER_RDDM , &ab_pci->mhi_state); -break ; -case ATH11K_MHI_RDDM_DONE : -set_bit (ATH11K_MHI_RDDM_DONE , &ab_pci->mhi_state); -break ; -default : -ath11k_err (ab,"unhandled mhi state (%d)\n" , mhi_state); - } -} - -static int ath11k_mhi_check_state_bit (struct ath11k_pci *ab_pci, -enum ath11k_mhi_state mhi_state) -{ -struct ath11k_base *ab = ab_pci->ab; - -switch (mhi_state) { -case ATH11K_MHI_INIT : -if (!test_bit (ATH11K_MHI_INIT , &ab_pci->mhi_state)) -return 0 ; -break ; -case ATH11K_MHI_DEINIT : -case ATH11K_MHI_POWER_ON : -if (test_bit (ATH11K_MHI_INIT , &ab_pci->mhi_state) && - !test_bit (ATH11K_MHI_POWER_ON , &ab_pci->mhi_state)) -return 0 ; -break ; -case ATH11K_MHI_FORCE_POWER_OFF : -if (test_bit (ATH11K_MHI_POWER_ON , &ab_pci->mhi_state)) -return 0 ; -break ; -case ATH11K_MHI_POWER_OFF : -case ATH11K_MHI_SUSPEND : -if (test_bit (ATH11K_MHI_POWER_ON , &ab_pci->mhi_state) && - !test_bit (ATH11K_MHI_SUSPEND , &ab_pci->mhi_state)) -return 0 ; -break ; -case ATH11K_MHI_RESUME : -if (test_bit (ATH11K_MHI_SUSPEND , &ab_pci->mhi_state)) -return 0 ; -break ; -case ATH11K_MHI_TRIGGER_RDDM : -if (test_bit (ATH11K_MHI_POWER_ON , &ab_pci->mhi_state) && - !test_bit (ATH11K_MHI_TRIGGER_RDDM , &ab_pci->mhi_state)) -return 0 ; -break ; -case ATH11K_MHI_RDDM_DONE : -return 0 ; -default : -ath11k_err (ab,"unhandled mhi state: %s(%d)\n" , -ath11k_mhi_state_to_str (mhi_state), mhi_state); - } - -ath11k_err (ab,"failed to set mhi state %s(%d) in current mhi state (0x%lx)\n" , -ath11k_mhi_state_to_str (mhi_state), mhi_state, - ab_pci->mhi_state); - -return -EINVAL ; -} - -static int ath11k_mhi_set_state (struct ath11k_pci *ab_pci, -enum ath11k_mhi_state mhi_state) -{ -struct ath11k_base *ab = ab_pci->ab; -int ret; - - ret =ath11k_mhi_check_state_bit (ab_pci, mhi_state); -if (ret) - goto out; - -ath11k_dbg (ab,ATH11K_DBG_PCI ,"setting mhi state: %s(%d)\n" , -ath11k_mhi_state_to_str (mhi_state), mhi_state); - -switch (mhi_state) { -case ATH11K_MHI_INIT : - ret =mhi_prepare_for_power_up (ab_pci->mhi_ctrl); -break ; -case ATH11K_MHI_DEINIT : -mhi_unprepare_after_power_down (ab_pci->mhi_ctrl); - ret =0 ; -break ; -case ATH11K_MHI_POWER_ON : - ret =mhi_sync_power_up (ab_pci->mhi_ctrl); -break ; -case ATH11K_MHI_POWER_OFF : -mhi_power_down (ab_pci->mhi_ctrl, true); - ret =0 ; -break ; -case ATH11K_MHI_FORCE_POWER_OFF : -mhi_power_down (ab_pci->mhi_ctrl, false); - ret =0 ; -break ; -case ATH11K_MHI_SUSPEND : - ret =mhi_pm_suspend (ab_pci->mhi_ctrl); -break ; -case ATH11K_MHI_RESUME : -/* Do force MHI resume as some devices like QCA6390, WCN6855 -* are not in M3 state but they are functional. So just ignore -* the MHI state while resuming. -*/ - ret =mhi_pm_resume_force (ab_pci->mhi_ctrl); -break ; -case ATH11K_MHI_TRIGGER_RDDM : - ret =mhi_force_rddm_mode (ab_pci->mhi_ctrl); -break ; -case ATH11K_MHI_RDDM_DONE : -break ; -default : -ath11k_err (ab,"unhandled MHI state (%d)\n" , mhi_state); - ret = -EINVAL ; - } - -if (ret) - goto out; - -ath11k_mhi_set_state_bit (ab_pci, mhi_state); - -return 0 ; - -out: -ath11k_err (ab,"failed to set mhi state: %s(%d)\n" , -ath11k_mhi_state_to_str (mhi_state), mhi_state); -return ret; -} -int ath11k_mhi_start (struct ath11k_pci *ab_pci) {int ret; ab_pci->mhi_ctrl->timeout_ms =MHI_TIMEOUT_DEFAULT_MS ; - ret =ath11k_mhi_set_state (ab_pci,ATH11K_MHI_INIT ); + ret =mhi_prepare_for_power_up (ab_pci->mhi_ctrl);if (ret) goto out; - ret =ath11k_mhi_set_state (ab_pci,ATH11K_MHI_POWER_ON ); + ret =mhi_sync_power_up (ab_pci->mhi_ctrl);if (ret) goto out;
@@ -661,16 +483,20 @@ int ath11k_mhi_start(struct ath11k_pci *ab_pci)void ath11k_mhi_stop (struct ath11k_pci *ab_pci) { -ath11k_mhi_set_state (ab_pci,ATH11K_MHI_POWER_OFF ); -ath11k_mhi_set_state (ab_pci,ATH11K_MHI_DEINIT ); +mhi_power_down (ab_pci->mhi_ctrl, true); +mhi_unprepare_after_power_down (ab_pci->mhi_ctrl); }void ath11k_mhi_suspend (struct ath11k_pci *ab_pci) { -ath11k_mhi_set_state (ab_pci,ATH11K_MHI_SUSPEND ); +mhi_pm_suspend (ab_pci->mhi_ctrl); }void ath11k_mhi_resume (struct ath11k_pci *ab_pci) { -ath11k_mhi_set_state (ab_pci,ATH11K_MHI_RESUME ); +/* Do force MHI resume as some devices like QCA6390, WCN6855 +* are not in M3 state but they are functional. So just ignore +* the MHI state while resuming. +*/ +mhi_pm_resume_force (ab_pci->mhi_ctrl); }
drivers/net/wireless/ath/ath11k/mhi.h +0 -13
@@ -16,19 +16,6 @@#define MHICTRL 0x38#define MHICTRL_RESET_MASK 0x2 -enum ath11k_mhi_state { -ATH11K_MHI_INIT , -ATH11K_MHI_DEINIT , -ATH11K_MHI_POWER_ON , -ATH11K_MHI_POWER_OFF , -ATH11K_MHI_FORCE_POWER_OFF , -ATH11K_MHI_SUSPEND , -ATH11K_MHI_RESUME , -ATH11K_MHI_TRIGGER_RDDM , -ATH11K_MHI_RDDM , -ATH11K_MHI_RDDM_DONE , -}; -int ath11k_mhi_start (struct ath11k_pci *ar_pci);void ath11k_mhi_stop (struct ath11k_pci *ar_pci);int ath11k_mhi_register (struct ath11k_pci *ar_pci);
drivers/net/wireless/ath/ath11k/pci.h +0 -1
@@ -79,7 +79,6 @@ struct ath11k_pci {u32 msi_ep_base_data;struct mhi_controller *mhi_ctrl;const struct ath11k_msi_config *msi_config; -unsigned long mhi_state;u32 register_window;/* protects register_window above */
Signature · 1 line
2.30.2
Re: [PATCH 1/3] ath11k: mhi: remove state machine
Quoted 7 lines · Kalle Valo
State machines are difficult to understand and in this case it's just useless, which is shown by the diffstat. So remove it entirely to make the code simpler.
No functional changes.
Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03003-QCAHSPSWPL_V1_V2_SILICONZ_LITE-2
Signed-off-by Kalle Valo <[email protected]>
3 patches applied to ath-next branch of ath.git, thanks.
5fe7847bb63b ath11k: mhi: remove state machine4afe7c40380e ath11k: mhi: add error handling for suspend and resume 7dabaa64c04a ath11k: mhi: remove unnecessary goto from ath11k_mhi_start()
Signature · 9 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches -- ath11k mailing list [email protected] http://lists.infradead.org/mailman/listinfo/ath11k
Re: [PATCH 1/3] ath11k: mhi: remove state machine
Quoted 7 lines · Kalle Valo
Quoted 5 lines · Kalle Valo
State machines are difficult to understand and in this case it's just useless, which is shown by the diffstat. So remove it entirely to make the code simpler.
No functional changes.
Quoted 8 lines
Quoted 2 lines
Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03003-QCAHSPSWPL_V1_V2_SILICONZ_LITE-2
Signed-off-by Kalle Valo <[email protected]>3 patches applied to ath-next branch of ath.git, thanks.
5fe7847bb63bath11k: mhi: remove state machine4afe7c40380eath11k: mhi: add error handling for suspend and resume7dabaa64c04aath11k: mhi: remove unnecessary goto fromath11k_mhi_start()
I accidentally had a wrong commit in ath-next so to remove that I had to rebase these three commits. The new commit ids are:
121210ec935c ath11k: mhi: remove state machine3e80fcbca372 ath11k: mhi: add error handling for suspend and resume b9e34ba6b314 ath11k: mhi: remove unnecessary goto from ath11k_mhi_start()
Signature · 8 lines
https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches -- ath11k mailing list [email protected] http://lists.infradead.org/mailman/listinfo/ath11k
PATCH 2/3 ath11k: mhi: add error handling for suspend and resume
In reply to Kalle ValoFrom: Kalle Valo <[email protected]>
While reviewing the mhi.c I noticed we were just ignoring the errors coming from MHI subsystem during suspend and resume. Add proper checks and warning messages. Also pass the error value to callers.
Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03003-QCAHSPSWPL_V1_V2_SILICONZ_LITE-2
--- drivers/net/wireless/ath/ath11k/mhi.c | 26 ++++++++++++++++++++++---- drivers/net/wireless/ath/ath11k/mhi.h | 4 ++-- drivers/net/wireless/ath/ath11k/pci.c | 8 ++------ 3 files changed, 26 insertions(+), 12 deletions(-)
drivers/net/wireless/ath/ath11k/mhi.c +22 -4
@@ -487,16 +487,34 @@ void ath11k_mhi_stop(struct ath11k_pci *ab_pci)mhi_unprepare_after_power_down (ab_pci->mhi_ctrl); } -void ath11k_mhi_suspend (struct ath11k_pci *ab_pci) +int ath11k_mhi_suspend (struct ath11k_pci *ab_pci) { -mhi_pm_suspend (ab_pci->mhi_ctrl); +struct ath11k_base *ab = ab_pci->ab; +int ret; + + ret =mhi_pm_suspend (ab_pci->mhi_ctrl); +if (ret) { +ath11k_warn (ab,"failed to suspend mhi: %d" , ret); +return ret; + } + +return 0 ; } -void ath11k_mhi_resume (struct ath11k_pci *ab_pci) +int ath11k_mhi_resume (struct ath11k_pci *ab_pci) { +struct ath11k_base *ab = ab_pci->ab; +int ret; +/* Do force MHI resume as some devices like QCA6390, WCN6855 * are not in M3 state but they are functional. So just ignore * the MHI state while resuming. */ -mhi_pm_resume_force (ab_pci->mhi_ctrl); + ret =mhi_pm_resume_force (ab_pci->mhi_ctrl); +if (ret) { +ath11k_warn (ab,"failed to resume mhi: %d" , ret); +return ret; + } + +return 0 ; }
drivers/net/wireless/ath/ath11k/mhi.h +2 -2
@@ -23,7 +23,7 @@ void ath11k_mhi_unregister(struct ath11k_pci *ar_pci);void ath11k_mhi_set_mhictrl_reset (struct ath11k_base *ab);void ath11k_mhi_clear_vector (struct ath11k_base *ab); -void ath11k_mhi_suspend (struct ath11k_pci *ar_pci); -void ath11k_mhi_resume (struct ath11k_pci *ar_pci); +int ath11k_mhi_suspend (struct ath11k_pci *ar_pci); +int ath11k_mhi_resume (struct ath11k_pci *ar_pci);#endif
drivers/net/wireless/ath/ath11k/pci.c +2 -6
@@ -1206,18 +1206,14 @@ static int ath11k_pci_hif_suspend(struct ath11k_base *ab) {struct ath11k_pci *ar_pci =ath11k_pci_priv (ab); -ath11k_mhi_suspend (ar_pci); - -return 0 ; +return ath11k_mhi_suspend (ar_pci); }static int ath11k_pci_hif_resume (struct ath11k_base *ab) {struct ath11k_pci *ar_pci =ath11k_pci_priv (ab); -ath11k_mhi_resume (ar_pci); - -return 0 ; +return ath11k_mhi_resume (ar_pci); }static void ath11k_pci_kill_tasklets (struct ath11k_base *ab)
Signature · 1 line
2.30.2
PATCH 3/3 ath11k: mhi: remove unnecessary goto from ath11k_mhi_start()
In reply to Kalle ValoFrom: Kalle Valo <[email protected]>
No need to have goto for a return statement, so simplify the code. While at it, print warning messages if power up calls fail.
No functional changes.
Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03003-QCAHSPSWPL_V1_V2_SILICONZ_LITE-2
--- drivers/net/wireless/ath/ath11k/mhi.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/net/wireless/ath/ath11k/mhi.c +9 -7
@@ -463,22 +463,24 @@ void ath11k_mhi_unregister(struct ath11k_pci *ab_pci)int ath11k_mhi_start (struct ath11k_pci *ab_pci) { +struct ath11k_base *ab = ab_pci->ab;int ret; ab_pci->mhi_ctrl->timeout_ms =MHI_TIMEOUT_DEFAULT_MS ; ret =mhi_prepare_for_power_up (ab_pci->mhi_ctrl); -if (ret) - goto out; +if (ret) { +ath11k_warn (ab,"failed to prepare mhi: %d" , ret); +return ret; + } ret =mhi_sync_power_up (ab_pci->mhi_ctrl); -if (ret) - goto out; +if (ret) { +ath11k_warn (ab,"failed to power up mhi: %d" , ret); +return ret; + }return 0 ; - -out: -return ret; }void ath11k_mhi_stop (struct ath11k_pci *ab_pci)
Signature · 1 line
2.30.2
Quoted 9 lines · Kalle Valo
From: Kalle Valo <[email protected]>
Some minor cleanup to
mhi.c, please review.Kalle Valo (3):
ath11k: mhi: remove state machine
ath11k: mhi: add error handling for suspend and resume
ath11k: mhi: remove unnecessary goto fromath11k_mhi_start()
Quoted 8 lines
drivers/net/wireless/ath/ath11k/mhi.c | 222 ++++---------------------- drivers/net/wireless/ath/ath11k/mhi.h | 17 +- drivers/net/wireless/ath/ath11k/pci.c | 8 +- drivers/net/wireless/ath/ath11k/pci.h | 1 - 4 files changed, 38 insertions(+), 210 deletions(-)base-commit:
57b7042c114767b7330b14a260f61732e556742e
For entire series: