Commit 688de12f authored by Alex Elder's avatar Alex Elder Committed by Jakub Kicinski

net: ipa: kill the STARTED IPA power flag

A transmit on the modem netdev can only complete if the IPA hardware
is powered.  Currently, if a transmit request arrives when the
hardware was not powered, further transmits are be stopped to allow
power-up to complete.  Once power-up completes, transmits are once
again enabled.

Runtime resume can complete at the same time a transmit request is
being handled, and previously there was a race between stopping and
restarting transmits.  The STARTED flag was used to ensure the
stop request in the transmit path was skipped if the start request
in the runtime resume path had already occurred.

Now, the queue is *always* stopped in the transmit path, *before*
determining whether power is ACTIVE.  If power is found to already
be active (or if the socket buffer is gets dropped), transmit is
re-enabled.  Otherwise it will (always) be enabled after runtime
resume completes.

The race between transmit and runtime resume no longer exists, so
there is no longer any need to maintain the STARTED flag.
Signed-off-by: default avatarAlex Elder <elder@linaro.org>
Link: https://lore.kernel.org/r/20240130192305.250915-4-elder@linaro.orgSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 844ecc4a
...@@ -39,14 +39,12 @@ ...@@ -39,14 +39,12 @@
* @IPA_POWER_FLAG_RESUMED: Whether resume from suspend has been signaled * @IPA_POWER_FLAG_RESUMED: Whether resume from suspend has been signaled
* @IPA_POWER_FLAG_SYSTEM: Hardware is system (not runtime) suspended * @IPA_POWER_FLAG_SYSTEM: Hardware is system (not runtime) suspended
* @IPA_POWER_FLAG_STOPPED: Modem TX is disabled by ipa_start_xmit() * @IPA_POWER_FLAG_STOPPED: Modem TX is disabled by ipa_start_xmit()
* @IPA_POWER_FLAG_STARTED: Modem TX was enabled by ipa_runtime_resume()
* @IPA_POWER_FLAG_COUNT: Number of defined power flags * @IPA_POWER_FLAG_COUNT: Number of defined power flags
*/ */
enum ipa_power_flag { enum ipa_power_flag {
IPA_POWER_FLAG_RESUMED, IPA_POWER_FLAG_RESUMED,
IPA_POWER_FLAG_SYSTEM, IPA_POWER_FLAG_SYSTEM,
IPA_POWER_FLAG_STOPPED, IPA_POWER_FLAG_STOPPED,
IPA_POWER_FLAG_STARTED,
IPA_POWER_FLAG_COUNT, /* Last; not a flag */ IPA_POWER_FLAG_COUNT, /* Last; not a flag */
}; };
...@@ -64,7 +62,7 @@ struct ipa_power { ...@@ -64,7 +62,7 @@ struct ipa_power {
struct device *dev; struct device *dev;
struct clk *core; struct clk *core;
struct qmp *qmp; struct qmp *qmp;
spinlock_t spinlock; /* used with STOPPED/STARTED power flags */ spinlock_t spinlock; /* used with STOPPED power flag */
DECLARE_BITMAP(flags, IPA_POWER_FLAG_COUNT); DECLARE_BITMAP(flags, IPA_POWER_FLAG_COUNT);
u32 interconnect_count; u32 interconnect_count;
struct icc_bulk_data interconnect[] __counted_by(interconnect_count); struct icc_bulk_data interconnect[] __counted_by(interconnect_count);
...@@ -242,23 +240,16 @@ void ipa_power_suspend_handler(struct ipa *ipa, enum ipa_irq_id irq_id) ...@@ -242,23 +240,16 @@ void ipa_power_suspend_handler(struct ipa *ipa, enum ipa_irq_id irq_id)
* gets sent (or dropped). If power is not ACTIVE, it will eventually * gets sent (or dropped). If power is not ACTIVE, it will eventually
* be, and transmits stay disabled until after it is. * be, and transmits stay disabled until after it is.
* *
* Two flags and a spinlock are used when managing this. If the queue * A flag and a spinlock are used when managing this. If the queue gets
* is stopped, the STOPPED power flag is set. And if the queue is * stopped, the STOPPED power flag is set.
* started, the STARTED flag is set.
* *
* The first function stops the modem netdev transmit queue, but only if * The first function stops the modem netdev transmit queue. The second
* the STARTED flag is *not* set. This previously avoided a race where * function starts the transmit queue, but only if the STOPPED flag is
* the TX path stops further transmits after power has become ACTIVE. * set. This avoids enabling transmits repeatedly immediately after
* The STARTED flag is cleared by this function. * power has become ACTIVE (not really a big deal). If the STOPPED flag
* was set, it is cleared by this function.
* *
* The second function starts the transmit queue, but only if the * The third function just enables transmits again.
* STOPPED flag is set. This avoids enabling transmits repeatedly
* immediately after power has become ACTIVE (not really a big deal).
* If the STOPPED flag was set, it is cleared and the STARTED flag
* is set by this function.
*
* The third function enables transmits again and clears the STARTED
* flag in case it was set, to return it to initial state.
*/ */
void ipa_power_modem_queue_stop(struct ipa *ipa) void ipa_power_modem_queue_stop(struct ipa *ipa)
{ {
...@@ -267,18 +258,14 @@ void ipa_power_modem_queue_stop(struct ipa *ipa) ...@@ -267,18 +258,14 @@ void ipa_power_modem_queue_stop(struct ipa *ipa)
spin_lock_irqsave(&power->spinlock, flags); spin_lock_irqsave(&power->spinlock, flags);
if (!__test_and_clear_bit(IPA_POWER_FLAG_STARTED, power->flags)) { netif_stop_queue(ipa->modem_netdev);
netif_stop_queue(ipa->modem_netdev); __set_bit(IPA_POWER_FLAG_STOPPED, power->flags);
__set_bit(IPA_POWER_FLAG_STOPPED, power->flags);
}
spin_unlock_irqrestore(&power->spinlock, flags); spin_unlock_irqrestore(&power->spinlock, flags);
} }
/* This function starts the modem netdev transmit queue, but only if the /* This function starts the modem netdev transmit queue, but only if the
* STOPPED flag is set. That flag is cleared if it was set. If the queue * STOPPED flag is set. That flag is cleared if it was set.
* was restarted, the STARTED flag is set; this allows ipa_start_xmit()
* to skip stopping the queue in the event of a race.
*/ */
void ipa_power_modem_queue_wake(struct ipa *ipa) void ipa_power_modem_queue_wake(struct ipa *ipa)
{ {
...@@ -287,22 +274,16 @@ void ipa_power_modem_queue_wake(struct ipa *ipa) ...@@ -287,22 +274,16 @@ void ipa_power_modem_queue_wake(struct ipa *ipa)
spin_lock_irqsave(&power->spinlock, flags); spin_lock_irqsave(&power->spinlock, flags);
if (__test_and_clear_bit(IPA_POWER_FLAG_STOPPED, power->flags)) { if (__test_and_clear_bit(IPA_POWER_FLAG_STOPPED, power->flags))
__set_bit(IPA_POWER_FLAG_STARTED, power->flags);
netif_wake_queue(ipa->modem_netdev); netif_wake_queue(ipa->modem_netdev);
}
spin_unlock_irqrestore(&power->spinlock, flags); spin_unlock_irqrestore(&power->spinlock, flags);
} }
/* This function is run after power has become ACTIVE. It enables transmits /* This function enables transmits again after power has become ACTIVE. */
* again clears the STARTED flag to indicate the TX queue is operating and
* can be stopped again if necessary.
*/
void ipa_power_modem_queue_active(struct ipa *ipa) void ipa_power_modem_queue_active(struct ipa *ipa)
{ {
netif_wake_queue(ipa->modem_netdev); netif_wake_queue(ipa->modem_netdev);
clear_bit(IPA_POWER_FLAG_STARTED, ipa->power->flags);
} }
static int ipa_power_retention_init(struct ipa_power *power) static int ipa_power_retention_init(struct ipa_power *power)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment