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

Commit d577af90 authored by Aditya Bavanari's avatar Aditya Bavanari
Browse files

asoc: codecs: Check for core votes count before accessing registers



Check for core votes count before accessing swrm registers
to avoid NOC errors.

Change-Id: I5689d6a6db0886ed4cc791738a28290f3d953412
Signed-off-by: default avatarAditya Bavanari <abavanar@codeaurora.org>
parent ae5dca48
Loading
Loading
Loading
Loading
+15 −0
Original line number Original line Diff line number Diff line
@@ -1180,6 +1180,21 @@ int bolero_runtime_suspend(struct device *dev)
}
}
EXPORT_SYMBOL(bolero_runtime_suspend);
EXPORT_SYMBOL(bolero_runtime_suspend);


bool bolero_check_core_votes(struct device *dev)
{
	struct bolero_priv *priv = dev_get_drvdata(dev->parent);
	bool ret = true;

	mutex_lock(&priv->vote_lock);
	if ((priv->lpass_core_hw_vote && !priv->core_hw_vote_count) ||
		(priv->lpass_audio_hw_vote && !priv->core_audio_vote_count))
		ret = false;
	mutex_unlock(&priv->vote_lock);

	return ret;
}
EXPORT_SYMBOL(bolero_check_core_votes);

static const struct of_device_id bolero_dt_match[] = {
static const struct of_device_id bolero_dt_match[] = {
	{.compatible = "qcom,bolero-codec"},
	{.compatible = "qcom,bolero-codec"},
	{}
	{}
+6 −0
Original line number Original line Diff line number Diff line
@@ -84,6 +84,7 @@ int bolero_tx_clk_switch(struct snd_soc_component *component);
int bolero_register_event_listener(struct snd_soc_component *component,
int bolero_register_event_listener(struct snd_soc_component *component,
				   bool enable);
				   bool enable);
void bolero_wsa_pa_on(struct device *dev);
void bolero_wsa_pa_on(struct device *dev);
bool bolero_check_core_votes(struct device *dev);
#else
#else
static inline int bolero_register_res_clk(struct device *dev, rsc_clk_cb_t cb)
static inline int bolero_register_res_clk(struct device *dev, rsc_clk_cb_t cb)
{
{
@@ -158,5 +159,10 @@ static inline int bolero_register_event_listener(
static void bolero_wsa_pa_on(struct device *dev)
static void bolero_wsa_pa_on(struct device *dev)
{
{
}
}

static inline bool bolero_check_core_votes(struct device *dev)
{
	return false;
}
#endif /* CONFIG_SND_SOC_BOLERO */
#endif /* CONFIG_SND_SOC_BOLERO */
#endif /* BOLERO_CDC_H */
#endif /* BOLERO_CDC_H */
+4 −1
Original line number Original line Diff line number Diff line
@@ -3499,7 +3499,10 @@ static int rx_macro_core_vote(void *handle, bool enable)
		pm_runtime_mark_last_busy(rx_priv->dev);
		pm_runtime_mark_last_busy(rx_priv->dev);
	}
	}


	if (bolero_check_core_votes(rx_priv->dev))
		return 0;
		return 0;
	else
		return -EINVAL;
}
}


static int rx_swrm_clock(void *handle, bool enable)
static int rx_swrm_clock(void *handle, bool enable)
+4 −2
Original line number Original line Diff line number Diff line
@@ -1952,7 +1952,6 @@ static int tx_macro_clk_switch(struct snd_soc_component *component)
static int tx_macro_core_vote(void *handle, bool enable)
static int tx_macro_core_vote(void *handle, bool enable)
{
{
	struct tx_macro_priv *tx_priv = (struct tx_macro_priv *) handle;
	struct tx_macro_priv *tx_priv = (struct tx_macro_priv *) handle;
	int ret = 0;


	if (tx_priv == NULL) {
	if (tx_priv == NULL) {
		pr_err("%s: tx priv data is NULL\n", __func__);
		pr_err("%s: tx priv data is NULL\n", __func__);
@@ -1964,7 +1963,10 @@ static int tx_macro_core_vote(void *handle, bool enable)
		pm_runtime_mark_last_busy(tx_priv->dev);
		pm_runtime_mark_last_busy(tx_priv->dev);
	}
	}


	return ret;
	if (bolero_check_core_votes(tx_priv->dev))
		return 0;
	else
		return -EINVAL;
}
}


static int tx_macro_swrm_clock(void *handle, bool enable)
static int tx_macro_swrm_clock(void *handle, bool enable)
+4 −2
Original line number Original line Diff line number Diff line
@@ -2802,7 +2802,6 @@ static void wsa_macro_init_reg(struct snd_soc_component *component)
static int wsa_macro_core_vote(void *handle, bool enable)
static int wsa_macro_core_vote(void *handle, bool enable)
{
{
	struct wsa_macro_priv *wsa_priv = (struct wsa_macro_priv *) handle;
	struct wsa_macro_priv *wsa_priv = (struct wsa_macro_priv *) handle;
	int ret = 0;


	if (wsa_priv == NULL) {
	if (wsa_priv == NULL) {
		pr_err("%s: wsa priv data is NULL\n", __func__);
		pr_err("%s: wsa priv data is NULL\n", __func__);
@@ -2814,7 +2813,10 @@ static int wsa_macro_core_vote(void *handle, bool enable)
		pm_runtime_mark_last_busy(wsa_priv->dev);
		pm_runtime_mark_last_busy(wsa_priv->dev);
	}
	}


	return ret;
	if (bolero_check_core_votes(wsa_priv->dev))
		return 0;
	else
		return -EINVAL;
}
}


static int wsa_swrm_clock(void *handle, bool enable)
static int wsa_swrm_clock(void *handle, bool enable)