Skip to content

Commit a96e73f

Browse files
Alex Elderdavem330
authored andcommitted
net: ipa: re-enable transmit in PM WQ context
Create a new work structure in the modem private data, and use it to re-enable the modem network device transmit queue when resuming. This is needed by the next patch, which stops the TX queue if IPA power isn't active when a transmit request arrives. Packets will start arriving the instant the TX queue is enabled, but resuming isn't complete until ipa_modem_resume() returns. This way we're sure to be resumed before transmits are allowed again. Cancel it before calling ipa_stop() in ipa_modem_stop() to ensure the transmit queue restart completes before it gets stopped there. Signed-off-by: Alex Elder <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b9c532c commit a96e73f

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

drivers/net/ipa/ipa_modem.c

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <linux/netdevice.h>
1010
#include <linux/skbuff.h>
1111
#include <linux/if_rmnet.h>
12+
#include <linux/pm_runtime.h>
1213
#include <linux/remoteproc/qcom_rproc.h>
1314

1415
#include "ipa.h"
@@ -33,9 +34,14 @@ enum ipa_modem_state {
3334
IPA_MODEM_STATE_STOPPING,
3435
};
3536

36-
/** struct ipa_priv - IPA network device private data */
37+
/**
38+
* struct ipa_priv - IPA network device private data
39+
* @ipa: IPA pointer
40+
* @work: Work structure used to wake the modem netdev TX queue
41+
*/
3742
struct ipa_priv {
3843
struct ipa *ipa;
44+
struct work_struct work;
3945
};
4046

4147
/** ipa_open() - Opens the modem network interface */
@@ -189,6 +195,21 @@ void ipa_modem_suspend(struct net_device *netdev)
189195
ipa_endpoint_suspend_one(ipa->name_map[IPA_ENDPOINT_AP_MODEM_TX]);
190196
}
191197

198+
/**
199+
* ipa_modem_wake_queue_work() - enable modem netdev queue
200+
* @work: Work structure
201+
*
202+
* Re-enable transmit on the modem network device. This is called
203+
* in (power management) work queue context, scheduled when resuming
204+
* the modem.
205+
*/
206+
static void ipa_modem_wake_queue_work(struct work_struct *work)
207+
{
208+
struct ipa_priv *priv = container_of(work, struct ipa_priv, work);
209+
210+
netif_wake_queue(priv->ipa->modem_netdev);
211+
}
212+
192213
/** ipa_modem_resume() - resume callback for runtime_pm
193214
* @dev: pointer to device
194215
*
@@ -205,7 +226,8 @@ void ipa_modem_resume(struct net_device *netdev)
205226
ipa_endpoint_resume_one(ipa->name_map[IPA_ENDPOINT_AP_MODEM_TX]);
206227
ipa_endpoint_resume_one(ipa->name_map[IPA_ENDPOINT_AP_MODEM_RX]);
207228

208-
netif_wake_queue(netdev);
229+
/* Arrange for the TX queue to be restarted */
230+
(void)queue_pm_work(&priv->work);
209231
}
210232

211233
int ipa_modem_start(struct ipa *ipa)
@@ -233,6 +255,7 @@ int ipa_modem_start(struct ipa *ipa)
233255
SET_NETDEV_DEV(netdev, &ipa->pdev->dev);
234256
priv = netdev_priv(netdev);
235257
priv->ipa = ipa;
258+
INIT_WORK(&priv->work, ipa_modem_wake_queue_work);
236259
ipa->name_map[IPA_ENDPOINT_AP_MODEM_TX]->netdev = netdev;
237260
ipa->name_map[IPA_ENDPOINT_AP_MODEM_RX]->netdev = netdev;
238261
ipa->modem_netdev = netdev;
@@ -277,6 +300,9 @@ int ipa_modem_stop(struct ipa *ipa)
277300

278301
/* Clean up the netdev and endpoints if it was started */
279302
if (netdev) {
303+
struct ipa_priv *priv = netdev_priv(netdev);
304+
305+
cancel_work_sync(&priv->work);
280306
/* If it was opened, stop it first */
281307
if (netdev->flags & IFF_UP)
282308
(void)ipa_stop(netdev);

0 commit comments

Comments
 (0)