Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 78467a8d authored by Houston Hoffman's avatar Houston Hoffman Committed by Akash Patel
Browse files

qcacld-3.0: Move runtime pm bookkeeping out of hdd

Move state machine and stat logging for runtime pm feature out of hdd.

Change-Id: I2699905d9c238a1402eac11c1107b44bb9e617e4
CRs-Fixed: 935300
parent f4607859
Loading
Loading
Loading
Loading
+11 −20
Original line number Diff line number Diff line
@@ -527,7 +527,6 @@ static int wlan_hdd_bus_resume(void)
}

#ifdef FEATURE_RUNTIME_PM

/**
 * __wlan_hdd_runtime_suspend() - suspend the wlan bus without apps suspend
 *
@@ -542,21 +541,16 @@ static int __wlan_hdd_runtime_suspend(void)
	void *hdd_ctx = cds_get_context(CDF_MODULE_ID_HDD);
	int status = wlan_hdd_validate_context(hdd_ctx);

	if (0 != status) {
		hif_log_runtime_suspend_failure();
		return status;
	}
	if (0 != status)
		goto process_failure;

	if (!hif_can_suspend_link()) {
		hdd_err("Runtime PM not supported for link up suspend");
		hif_log_runtime_suspend_failure();
		return -EINVAL;
	}
	status = hif_pre_runtime_suspend();
	if (status)
		goto process_failure;

	hif_runtime_pm_set_state_inprogress();
	status = htc_runtime_suspend();
	if (status)
		goto set_state;
		goto process_failure;

	status = wma_runtime_suspend();
	if (status)
@@ -570,8 +564,7 @@ static int __wlan_hdd_runtime_suspend(void)
	if (status)
		goto resume_hif;

	hif_runtime_pm_set_state_suspended();
	hif_log_runtime_suspend_success();
	hif_process_runtime_suspend_success();
	return status;

resume_hif:
@@ -580,9 +573,8 @@ static int __wlan_hdd_runtime_suspend(void)
	CDF_BUG(!wma_runtime_resume());
resume_htc:
	CDF_BUG(!htc_runtime_resume());
set_state:
	hif_log_runtime_suspend_failure();
	hif_runtime_pm_set_state_on();
process_failure:
	hif_process_runtime_suspend_failure();
	return status;
}

@@ -616,13 +608,12 @@ static int wlan_hdd_runtime_suspend(void)
 */
static int __wlan_hdd_runtime_resume(void)
{
	hif_runtime_pm_set_state_inprogress();
	hif_pre_runtime_resume();
	CDF_BUG(!cnss_auto_resume());
	CDF_BUG(!hif_runtime_resume());
	CDF_BUG(!wma_runtime_resume());
	CDF_BUG(!htc_runtime_resume());
	hif_log_runtime_resume_success();
	hif_runtime_pm_set_state_on();
	hif_process_runtime_resume_success();
	return 0;
}

+11 −13
Original line number Diff line number Diff line
@@ -685,26 +685,24 @@ static inline int hif_pm_runtime_prevent_suspend_timeout(void *ol_sc,
{ return 0; }
#endif

void hif_runtime_pm_set_state_inprogress(void);
void hif_runtime_pm_set_state_on(void);

void hif_enable_power_management(void *hif_ctx);
void hif_disable_power_management(void *hif_ctx);
int hif_runtime_suspend(void);
int hif_runtime_resume(void);
int hif_bus_resume(void);
int hif_bus_suspend(void);

void hif_vote_link_down(void);
void hif_vote_link_up(void);
bool hif_can_suspend_link(void);
void hif_runtime_pm_set_state_inprogress(void);
void hif_runtime_pm_set_state_on(void);
void hif_runtime_pm_set_state_suspended(void);

int hif_bus_resume(void);
int hif_bus_suspend(void);

#ifdef FEATURE_RUNTIME_PM
void hif_log_runtime_suspend_success(void);
void hif_log_runtime_suspend_failure(void);
void hif_log_runtime_resume_success(void);
int hif_pre_runtime_suspend(void);
void hif_pre_runtime_resume(void);
int hif_runtime_suspend(void);
int hif_runtime_resume(void);
void hif_process_runtime_suspend_success(void);
void hif_process_runtime_suspend_failure(void);
void hif_process_runtime_resume_success(void);
#endif

int dump_ce_register(struct ol_softc *scn);
+84 −14
Original line number Diff line number Diff line
@@ -1896,19 +1896,16 @@ static void __hif_runtime_pm_set_state(enum hif_pm_runtime_state state)
	sc = scn->hif_sc;
	cdf_atomic_set(&sc->pm_state, state);

}
#else
static void __hif_runtime_pm_set_state(enum hif_pm_runtime_state state)
{
}
#endif

#ifdef FEATURE_RUNTIME_PM
/**
 * hif_runtime_pm_set_state_inprogress(): adjust runtime pm state
 *
 * Notify hif that a runtime pm opperation has started
 */
void hif_runtime_pm_set_state_inprogress(void)
static void hif_runtime_pm_set_state_inprogress(void)
{
	__hif_runtime_pm_set_state(HIF_PM_RUNTIME_STATE_INPROGRESS);
}
@@ -1918,7 +1915,7 @@ void hif_runtime_pm_set_state_inprogress(void)
 *
 * Notify hif that a the runtime pm state should be on
 */
void hif_runtime_pm_set_state_on(void)
static void hif_runtime_pm_set_state_on(void)
{
	__hif_runtime_pm_set_state(HIF_PM_RUNTIME_STATE_ON);
}
@@ -1928,13 +1925,11 @@ void hif_runtime_pm_set_state_on(void)
 *
 * Notify hif that a runtime suspend attempt has been completed successfully
 */
void hif_runtime_pm_set_state_suspended(void)
static void hif_runtime_pm_set_state_suspended(void)
{
	__hif_runtime_pm_set_state(HIF_PM_RUNTIME_STATE_SUSPENDED);
}


#ifdef FEATURE_RUNTIME_PM
static inline struct hif_pci_softc *get_sc(void)
{
	struct ol_softc *scn = cds_get_context(CDF_MODULE_ID_HIF);
@@ -1951,7 +1946,7 @@ static inline struct hif_pci_softc *get_sc(void)
/**
 * hif_log_runtime_suspend_success() - log a successful runtime suspend
 */
void hif_log_runtime_suspend_success(void)
static void hif_log_runtime_suspend_success(void)
{
	struct hif_pci_softc *sc = get_sc();
	if (sc == NULL)
@@ -1967,14 +1962,13 @@ void hif_log_runtime_suspend_success(void)
 * log a failed runtime suspend
 * mark last busy to prevent immediate runtime suspend
 */
void hif_log_runtime_suspend_failure(void)
static void hif_log_runtime_suspend_failure(void)
{
	struct hif_pci_softc *sc = get_sc();
	if (sc == NULL)
		return;

	sc->pm_stats.suspend_err++;
	hif_pm_runtime_mark_last_busy(sc->dev);
}

/**
@@ -1983,14 +1977,90 @@ void hif_log_runtime_suspend_failure(void)
 * log a successfull runtime resume
 * mark last busy to prevent immediate runtime suspend
 */
void hif_log_runtime_resume_success(void)
static void hif_log_runtime_resume_success(void)
{
	struct hif_pci_softc *sc = get_sc();
	if (sc == NULL)
		return;

	sc->pm_stats.resumed++;
}

/**
 * hif_process_runtime_suspend_failure() - bookkeeping of suspend failure
 *
 * Record the failure.
 * mark last busy to delay a retry.
 * adjust the runtime_pm state.
 */
void hif_process_runtime_suspend_failure(void)
{
	struct hif_pci_softc *sc = get_sc();

	hif_log_runtime_suspend_failure();
	if (sc != NULL)
		hif_pm_runtime_mark_last_busy(sc->dev);
	hif_runtime_pm_set_state_on();
}

/**
 * hif_pre_runtime_suspend() - bookkeeping before beginning runtime suspend
 *
 * Makes sure that the pci link will be taken down by the suspend opperation.
 * If the hif layer is configured to leave the bus on, runtime suspend will
 * not save any power.
 *
 * Set the runtime suspend state to in progress.
 *
 * return -EINVAL if the bus won't go down.  otherwise return 0
 */
int hif_pre_runtime_suspend(void)
{
	if (!hif_can_suspend_link()) {
		HIF_ERROR("Runtime PM not supported for link up suspend");
		return -EINVAL;
	}

	hif_runtime_pm_set_state_inprogress();
	return 0;
}

/**
 * hif_process_runtime_suspend_success() - bookkeeping of suspend success
 *
 * Record the success.
 * adjust the runtime_pm state
 */
void hif_process_runtime_suspend_success(void)
{
	hif_runtime_pm_set_state_suspended();
	hif_log_runtime_suspend_success();
}

/**
 * hif_pre_runtime_resume() - bookkeeping before beginning runtime resume
 *
 * update the runtime pm state.
 */
void hif_pre_runtime_resume(void)
{
	hif_runtime_pm_set_state_inprogress();
}

/**
 * hif_process_runtime_resume_success() - bookkeeping after a runtime resume
 *
 * record the success.
 * adjust the runtime_pm state
 */
void hif_process_runtime_resume_success(void)
{
	struct hif_pci_softc *sc = get_sc();

	hif_log_runtime_resume_success();
	if (sc != NULL)
		hif_pm_runtime_mark_last_busy(sc->dev);
	hif_runtime_pm_set_state_on();
}
#endif

+0 −46
Original line number Diff line number Diff line
@@ -114,42 +114,6 @@ void dump_ce_debug_register(struct ol_softc *scn)
	return;
}

/**
 * hif_runtime_pm_set_state_inprogress() - dummy function
 *
 * currently runtime pm only supported in pci
 */
void hif_runtime_pm_set_state_inprogress(void)
{
}

/**
 * hif_runtime_pm_set_state_on() - dummy function
 *
 * currently runtime pm only supported in pci
 */
void hif_runtime_pm_set_state_on(void)
{
}

/**
 * hif_runtime_pm_set_state_suspended() - dummy function
 *
 * currently runtime pm only supported in pci
 */
void hif_runtime_pm_set_state_on(void)
{
}

/**
 * hif_runtime_pm_set_state_suspended() - dummy function
 *
 * currently runtime pm only supported in pci
 */
void hif_runtime_pm_set_state_suspended(void)
{
}

/**
 * hif_bus_suspend() - suspend the bus
 *
@@ -176,16 +140,6 @@ int hif_bus_resume(void)
	return 0;
}

static int hif_runtime_suspend(void)
{
	return hif_bus_suspend();
}

static int hif_runtime_resume(void)
{
	return hif_bus_resume();
}

/**
 * hif_enable_power_gating(): enable HW power gating
 *