diff --git a/core/cds/inc/cds_api.h b/core/cds/inc/cds_api.h index 2c9add63a1ae..64f5842c3933 100644 --- a/core/cds/inc/cds_api.h +++ b/core/cds/inc/cds_api.h @@ -72,7 +72,8 @@ enum cds_driver_state { CDS_DRIVER_STATE_LOADING = BIT(1), CDS_DRIVER_STATE_UNLOADING = BIT(2), CDS_DRIVER_STATE_RECOVERING = BIT(3), - CDS_DRIVER_STATE_BAD = BIT(4) + CDS_DRIVER_STATE_BAD = BIT(4), + CDS_DRIVER_STATE_FW_READY = BIT(5), }; #define __CDS_IS_DRIVER_STATE(_state, _mask) (((_state) & (_mask)) == (_mask)) @@ -224,6 +225,18 @@ static inline void cds_set_fw_down(uint8_t value) cds_clear_fw_state(CDS_FW_STATE_DOWN); } +/** + * cds_is_target_ready() - Is target is in ready state + * + * Return: true if target is in ready state and false otherwise. + */ +static inline bool cds_is_target_ready(void) +{ + enum cds_driver_state state = cds_get_driver_state(); + + return __CDS_IS_DRIVER_STATE(state, CDS_DRIVER_STATE_FW_READY); +} + /** * cds_set_recovery_in_progress() - Set recovery in progress * @value: value to set @@ -252,6 +265,20 @@ static inline void cds_set_driver_in_bad_state(uint8_t value) cds_clear_driver_state(CDS_DRIVER_STATE_BAD); } +/** + * cds_set_target_ready() - Set target ready state + * @value: value to set + * + * Return: none + */ +static inline void cds_set_target_ready(uint8_t value) +{ + if (value) + cds_set_driver_state(CDS_DRIVER_STATE_FW_READY); + else + cds_clear_driver_state(CDS_DRIVER_STATE_FW_READY); +} + /** * cds_set_load_in_progress() - Set load in progress * @value: value to set diff --git a/core/hdd/src/wlan_hdd_driver_ops.c b/core/hdd/src/wlan_hdd_driver_ops.c index 9b4636e43b2e..eb169533dbc5 100644 --- a/core/hdd/src/wlan_hdd_driver_ops.c +++ b/core/hdd/src/wlan_hdd_driver_ops.c @@ -123,6 +123,17 @@ static bool hdd_is_recovery_in_progress(void *data) return cds_is_driver_recovering(); } +/** + * hdd_is_target_ready() - API to query if target is in ready state + * @data: Private Data + * + * Return: bool + */ +static bool hdd_is_target_ready(void *data) +{ + return cds_is_target_ready(); +} + /** * hdd_hif_init_driver_state_callbacks() - API to initialize HIF callbacks * @data: Private Data @@ -141,6 +152,7 @@ static void hdd_hif_init_driver_state_callbacks(void *data, cbk->is_recovery_in_progress = hdd_is_recovery_in_progress; cbk->is_load_unload_in_progress = hdd_is_load_or_unload_in_progress; cbk->is_driver_unloading = hdd_is_driver_unloading; + cbk->is_target_ready = hdd_is_target_ready; } /** @@ -1436,11 +1448,18 @@ static void wlan_hdd_purge_notifier(void) static void wlan_hdd_pld_uevent(struct device *dev, struct pld_uevent_data *uevent) { - if (uevent->uevent == PLD_RECOVERY) { + switch (uevent->uevent) { + case PLD_RECOVERY: cds_set_recovery_in_progress(true); hdd_pld_ipa_uc_shutdown_pipes(); - } else if (uevent->uevent == PLD_FW_DOWN) { + break; + case PLD_FW_DOWN: cds_set_fw_state(CDS_FW_STATE_DOWN); + cds_set_target_ready(false); + break; + case PLD_FW_READY: + cds_set_target_ready(true); + break; } wlan_hdd_purge_notifier(); diff --git a/core/pld/inc/pld_common.h b/core/pld/inc/pld_common.h index d632904274f2..cf4f1d8357dd 100644 --- a/core/pld/inc/pld_common.h +++ b/core/pld/inc/pld_common.h @@ -147,6 +147,7 @@ enum pld_driver_status { enum pld_uevent { PLD_RECOVERY, PLD_FW_DOWN, + PLD_FW_READY, }; /** diff --git a/core/pld/src/pld_snoc.c b/core/pld/src/pld_snoc.c index daabfb0b0d14..1c0b14cddf2d 100644 --- a/core/pld/src/pld_snoc.c +++ b/core/pld/src/pld_snoc.c @@ -263,6 +263,10 @@ static int pld_snoc_uevent(struct device *dev, data.uevent = PLD_FW_DOWN; data.fw_down.crashed = uevent_data->crashed; break; + case ICNSS_UEVENT_FW_READY: + data.uevent = PLD_FW_READY; + break; + default: goto out; }