[PATCH 1/2] mt76: mt7663: handle failure event for patch semaphore cmd

Lorenzo Bianconi lorenzo at kernel.org
Fri Oct 16 11:45:56 EDT 2020


> From: Sean Wang <objelf at gmail.com>
> 
> Just follow up vendor driver to retry a few times obtaining patch
> semaphore when the event is PATCH_NOT_DL_SEM_FAIL. That usually
> happens in Bluetooth and Wifi driver contends to download patch
> simultaneously.
> 
> Co-developed-by: YN Chen <YN.Chen at mediatek.com>
> Signed-off-by: YN Chen <YN.Chen at mediatek.com>
> Signed-off-by:  Sean Wang <sean.wang at mediatek.com>
> ---
>  drivers/net/wireless/mediatek/mt76/mt7615/mcu.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
> index 2b17bd1c2a32..c990ccd6f472 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
> @@ -1945,14 +1945,21 @@ static int mt7615_load_patch(struct mt7615_dev *dev, u32 addr, const char *name)
>  {
>  	const struct mt7615_patch_hdr *hdr;
>  	const struct firmware *fw = NULL;
> -	int len, ret, sem;
> +	int len, ret, sem, c = 50;
>  
> +retry:
>  	sem = mt7615_mcu_patch_sem_ctrl(dev, 1);
>  	switch (sem) {
>  	case PATCH_IS_DL:
>  		return 0;
>  	case PATCH_NOT_DL_SEM_SUCCESS:
>  		break;
> +	case PATCH_NOT_DL_SEM_FAIL:
> +		if (is_mt7663(&dev->mt76) && c--) {
> +			msleep(100);
> +			goto retry;
> +		}
> +		fallthrough;

I guess it is more clear to have a dedicated routine for this. E.g:

int mt7615_mcu_get_patch_semaphore()
{
	....
}

Regards,
Lorenzo

>  	default:
>  		dev_err(dev->mt76.dev, "Failed to get patch semaphore\n");
>  		return -EAGAIN;
> -- 
> 2.25.1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-mediatek/attachments/20201016/a428a539/attachment.sig>


More information about the Linux-mediatek mailing list