/** * DOC: IPA SMP2P communication with the modem * * SMP2P is a primitive communication mechanism available between the AP and * the modem. The IPA driver uses this for two purposes: to enable the modem * to state that the GSI hardware is ready to use; and to communicate the * state of IPA power in the event of a crash. * * GSI needs to have early initialization completed before it can be used. * This initialization is done either by Trust Zone or by the modem. In the * latter case, the modem uses an SMP2P interrupt to tell the AP IPA driver * when the GSI is ready to use. * * The modem is also able to inquire about the current state of IPA * power by trigging another SMP2P interrupt to the AP. We communicate * whether power is enabled using two SMP2P state bits--one to indicate * the power state (on or off), and a second to indicate the power state * bit is valid. The modem will poll the valid bit until it is set, and * at that time records whether the AP has IPA power enabled. * * Finally, if the AP kernel panics, we update the SMP2P state bits even if * we never receive an interrupt from the modem requesting this.
*/
/** * struct ipa_smp2p - IPA SMP2P information * @ipa: IPA pointer * @valid_state: SMEM state indicating enabled state is valid * @enabled_state: SMEM state to indicate power is enabled * @valid_bit: Valid bit in 32-bit SMEM state mask * @enabled_bit: Enabled bit in 32-bit SMEM state mask * @enabled_bit: Enabled bit in 32-bit SMEM state mask * @clock_query_irq: IPA interrupt triggered by modem for power query * @setup_ready_irq: IPA interrupt triggered by modem to signal GSI ready * @power_on: Whether IPA power is on * @notified: Whether modem has been notified of power state * @setup_disabled: Whether setup ready interrupt handler is disabled * @mutex: Mutex protecting ready-interrupt/shutdown interlock * @panic_notifier: Panic notifier structure
*/ struct ipa_smp2p { struct ipa *ipa; struct qcom_smem_state *valid_state; struct qcom_smem_state *enabled_state;
u32 valid_bit;
u32 enabled_bit;
u32 clock_query_irq;
u32 setup_ready_irq; bool power_on; bool notified; bool setup_disabled; struct mutex mutex; struct notifier_block panic_notifier;
};
/** * ipa_smp2p_notify() - use SMP2P to tell modem about IPA power state * @smp2p: SMP2P information * * This is called either when the modem has requested it (by triggering * the modem power query IPA interrupt) or whenever the AP is shutting down * (via a panic notifier). It sets the two SMP2P state bits--one saying * whether the IPA power is on, and the other indicating the first bit * is valid.
*/ staticvoid ipa_smp2p_notify(struct ipa_smp2p *smp2p)
{
u32 value;
u32 mask;
/* Signal whether the IPA power is enabled */
mask = BIT(smp2p->enabled_bit);
value = smp2p->power_on ? mask : 0;
qcom_smem_state_update_bits(smp2p->enabled_state, mask, value);
/* Now indicate that the enabled flag is valid */
mask = BIT(smp2p->valid_bit);
value = mask;
qcom_smem_state_update_bits(smp2p->valid_state, mask, value);
if (smp2p->power_on)
ipa_uc_panic_notifier(smp2p->ipa);
return NOTIFY_DONE;
}
staticint ipa_smp2p_panic_notifier_register(struct ipa_smp2p *smp2p)
{ /* IPA panic handler needs to run before modem shuts down */
smp2p->panic_notifier.notifier_call = ipa_smp2p_panic_notifier;
smp2p->panic_notifier.priority = INT_MAX; /* Do it early */
/* Ignore any (spurious) interrupts received after the first */ if (ipa->setup_complete) return IRQ_HANDLED;
/* Power needs to be active for setup */
dev = ipa->dev;
ret = pm_runtime_get_sync(dev); if (ret < 0) {
dev_err(dev, "error %d getting power for setup\n", ret); goto out_power_put;
}
/* An error here won't cause driver shutdown, so warn if one occurs */
ret = ipa_setup(ipa);
WARN(ret != 0, "error %d from ipa_setup()\n", ret);
/* Drop the power reference if it was taken in ipa_smp2p_notify() */ staticvoid ipa_smp2p_power_release(struct ipa *ipa)
{ struct device *dev = ipa->dev;
valid_state = qcom_smem_state_get(dev, "ipa-clock-enabled-valid",
&valid_bit); if (IS_ERR(valid_state)) return PTR_ERR(valid_state); if (valid_bit >= 32) /* BITS_PER_U32 */ return -EINVAL;
enabled_state = qcom_smem_state_get(dev, "ipa-clock-enabled",
&enabled_bit); if (IS_ERR(enabled_state)) return PTR_ERR(enabled_state); if (enabled_bit >= 32) /* BITS_PER_U32 */ return -EINVAL;
smp2p = kzalloc(sizeof(*smp2p), GFP_KERNEL); if (!smp2p) return -ENOMEM;
smp2p->ipa = ipa;
/* These fields are needed by the power query interrupt * handler, so initialize them now.
*/
mutex_init(&smp2p->mutex);
smp2p->valid_state = valid_state;
smp2p->valid_bit = valid_bit;
smp2p->enabled_state = enabled_state;
smp2p->enabled_bit = enabled_bit;
/* We have enough information saved to handle notifications */
ipa->smp2p = smp2p;
ret = ipa_smp2p_irq_init(smp2p, pdev, "ipa-clock-query",
ipa_smp2p_modem_clk_query_isr); if (ret < 0) goto err_null_smp2p;
smp2p->clock_query_irq = ret;
ret = ipa_smp2p_panic_notifier_register(smp2p); if (ret) goto err_irq_exit;
if (modem_init) { /* Result will be non-zero (negative for error) */
ret = ipa_smp2p_irq_init(smp2p, pdev, "ipa-setup-ready",
ipa_smp2p_modem_setup_ready_isr); if (ret < 0) goto err_notifier_unregister;
smp2p->setup_ready_irq = ret;
}
if (smp2p->setup_ready_irq)
ipa_smp2p_irq_exit(smp2p, smp2p->setup_ready_irq);
ipa_smp2p_panic_notifier_unregister(smp2p);
ipa_smp2p_irq_exit(smp2p, smp2p->clock_query_irq); /* We won't get notified any more; drop power reference (if any) */
ipa_smp2p_power_release(ipa);
ipa->smp2p = NULL;
mutex_destroy(&smp2p->mutex);
kfree(smp2p);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.