[PATCH 1/4] mt76: mt7921e: fix race issue between reset and suspend/resume

sean.wang at mediatek.com sean.wang at mediatek.com
Tue Jul 19 13:44:53 PDT 2022


From: Sean Wang <sean.wang at mediatek.com>

>> From: Sean Wang <sean.wang at mediatek.com>
>>
>> It is unexpected that the reset work is running simultaneously with
>> the suspend or resume context and it is possible that reset work is

<snip>

>> @@ -363,6 +363,7 @@ static int mt7921_pci_suspend(struct device *device)
>>	int i, err;
>>
>>	pm->suspended = true;
>> +	cancel_work_sync(&dev->reset_work);
>
>should we just wait for the reset to complete here instead of cancelling? (e.g. flush_work)
>

yes, that seemed look better to me. It would wait until the queued reset request finishes.

>Regards,
>Lorenzo
>
>>	cancel_delayed_work_sync(&pm->ps_work);
>>	cancel_work_sync(&pm->wake_work);
>>
>> @@ -424,6 +425,9 @@ static int mt7921_pci_suspend(struct device
>> *device)
>>  restore_suspend:
>>	pm->suspended = false;
>>
>> +	if (err < 0)
>> +		mt7921_reset(&dev->mt76);
>> +
>>	return err;
>>  }
>>
>> @@ -437,7 +441,7 @@ static int mt7921_pci_resume(struct device
>> *device)
>>
>>	err = mt7921_mcu_drv_pmctrl(dev);
>>	if (err < 0)
>> -		return err;
>> +		goto failed;
>>
>>	mt7921_wpdma_reinit_cond(dev);
>>
>> @@ -467,11 +471,12 @@ static int mt7921_pci_resume(struct device *device)
>>		mt76_connac_mcu_set_deep_sleep(&dev->mt76, false);
>>
>>	err = mt76_connac_mcu_set_hif_suspend(mdev, false);
>> -	if (err)
>> -		return err;
>> -
>> +failed:
>>	pm->suspended = false;
>>
>> +	if (err < 0)
>> +		mt7921_reset(&dev->mt76);
>> +
>>	return err;
>>  }
>>
>> --
>> 2.25.1
>>
>
>



More information about the Linux-mediatek mailing list