Re: [PATCH net-next 4/6] net: ipa: ensure hardware has power in ipa_start_xmit()

From: Alex Elder
Date: Fri Aug 13 2021 - 22:25:28 EST


On 8/13/21 7:46 PM, Jakub Kicinski wrote:
> On Thu, 12 Aug 2021 14:50:33 -0500 Alex Elder wrote:
>> + /* The hardware must be powered for us to transmit */
>> + dev = &ipa->pdev->dev;
>> + ret = pm_runtime_get(dev);
>> + if (ret < 1) {
>> + /* If a resume won't happen, just drop the packet */
>> + if (ret < 0 && ret != -EINPROGRESS) {
>> + pm_runtime_put_noidle(dev);
>> + goto err_drop_skb;
>> + }
>
> This is racy, what if the pm work gets scheduled on another CPU and
> calls wake right here (i.e. before you call netif_stop_queue())?
> The queue may never get woken up?

I haven't been seeing this happen but I think you may be right.

I did think about this race, but I think I was relying on the
PM work queue to somehow avoid the problem. I need to think
about this again after a good night's sleep. I might need
to add an atomic flag or something.

-Alex

>> + /* No power (yet). Stop the network stack from transmitting
>> + * until we're resumed; ipa_modem_resume() arranges for the
>> + * TX queue to be started again.
>> + */
>> + netif_stop_queue(netdev);
>> +
>> + (void)pm_runtime_put(dev);
>> +
>> + return NETDEV_TX_BUSY;