netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Michał Pecio" <michal.pecio@gmail.com>
To: aleksander.lobakin@intel.com
Cc: Bo.Jiao@mediatek.com, StanleyYP.Wang@mediatek.com,
	alexander.deucher@amd.com, andrew+netdev@lunn.ch, andrew@lunn.ch,
	angelogioacchino.delregno@collabora.com,
	apais@linux.microsoft.com, chui-hao.chiu@mediatek.com,
	cug_yangyuancong@hotmail.com, daniel@makrotopia.org,
	davem@davemloft.net, deren.wu@mediatek.com,
	dokyungs@yonsei.ac.kr, dsahern@kernel.org, dzm91@hust.edu.cn,
	edumazet@google.com, gch981213@gmail.com, git@qrsnap.io,
	gregkh@linuxfoundation.org, guanwentao@uniontech.com,
	gustavoars@kernel.org, helmut.schaa@googlemail.com,
	horms@kernel.org, jiefeng_li@hust.edu.cn, keescook@chromium.org,
	kuba@kernel.org, kvalo@codeaurora.org, kvalo@kernel.org,
	leit@fb.com, leitao@debian.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org,
	linux-usb@vger.kernel.org, linux-wireless@vger.kernel.org,
	lorenzo.bianconi83@gmail.com, lorenzo.bianconi@redhat.com,
	lorenzo@kernel.org, lynxis@fe80.eu, mailhol.vincent@wanadoo.fr,
	markus.theil@tu-ilmenau.de, matthias.bgg@gmail.com,
	mikhail.v.gavrilov@gmail.com, mingyen.hsieh@mediatek.com,
	mrkiko.rs@gmail.com, nbd@nbd.name, nelson.yu@mediatek.com,
	netdev@vger.kernel.org, oliver@neukum.org, pabeni@redhat.com,
	quan.zhou@mediatek.com, raoxu@uniontech.com,
	rodrigo.vivi@intel.com, romain.perier@gmail.com,
	rong.yan@mediatek.com, ryder.lee@mediatek.com,
	sean.wang@mediatek.com, sgruszka@redhat.com,
	shayne.chen@mediatek.com, sidhayn@gmail.com,
	stern@rowland.harvard.edu, stf_xl@wp.pl,
	sujuan.chen@mediatek.com, wang.zhao@mediatek.com,
	wangyuli@uniontech.com, weiwan@google.com,
	woojung.huh@microchip.com, yn.chen@mediatek.com,
	zhanjun@uniontech.com
Subject: Re: mt76: dealing with disconnections, -ENODEV and -EPROTO
Date: Fri, 20 Dec 2024 00:27:59 +0100	[thread overview]
Message-ID: <20241220002759.34dcfe11@foxbook> (raw)
In-Reply-To: <a2bbdfb4-19ed-461e-a14b-e91a5636cc77@intel.com>

> >  		ret = usb_control_msg(udev, pipe, req, req_type, val,
> >  				      offset, buf, len, MT_VEND_REQ_TOUT_MS);
> > -		if (ret == -ENODEV)
> > +		if (ret == -ENODEV || ret == -EPROTO)
> >  			set_bit(MT76_REMOVED, &dev->phy.state);
> > -		if (ret >= 0 || ret == -ENODEV)
> > +		if (ret >= 0 || ret == -ENODEV || ret == -EPROTO)
> >  			return ret;
> >  		usleep_range(5000, 10000);
> 
> How do other drivers handle this?
> Can -EPROTO happen in other cases, not only unplugging, which this
> patch would break?

Yes, -EPROTO may be a transient error, although they are relatively
rare as some retries are done before the URB fails. This patch will
only break things if things work in the first place, i.e. the driver
has sensible retry policies, the hardware doesn't get confused, etc.

Note that -EPROTO is not guaranteed in this case, see
Documentation/driver-api/usb/error-codes.rst

I know that xHCI gives -EPROTO and it looks like EHCI does too (IDK
if this is reliable), but I just checked that OHCI gives -ETIME.


I don't have this hardware, but I played with some other wired/WiFi
dongles and observed similar problems of varying severity.

It looks to me like USB core doesn't actually return -ENODEV on
disconnected devices, or at least doesn't react to disconnection
until .probe() returns, I am not yet sure which of those.

And drivers don't seem to expect -EPROTO or -ETIME to be fatal.

And maybe they should, if they wouldn't be able to recover from it
anyway, and I know that there are drivers which can't. But I think
this USB subsystem behavior is suboptimal too.

Regards,
Michal

      parent reply	other threads:[~2024-12-19 23:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-18  9:08 [RESEND. PATCH] mt76: mt76u_vendor_request: Do not print error messages when -EPROTO WangYuli
2024-12-18 16:10 ` Alexander Lobakin
2024-12-18 16:50   ` Kalle Valo
2024-12-19  7:11   ` WangYuli
2024-12-19 15:23     ` Alexander Lobakin
2024-12-24  9:01       ` WangYuli
2024-12-19 23:27   ` Michał Pecio [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241220002759.34dcfe11@foxbook \
    --to=michal.pecio@gmail.com \
    --cc=Bo.Jiao@mediatek.com \
    --cc=StanleyYP.Wang@mediatek.com \
    --cc=aleksander.lobakin@intel.com \
    --cc=alexander.deucher@amd.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=andrew@lunn.ch \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=apais@linux.microsoft.com \
    --cc=chui-hao.chiu@mediatek.com \
    --cc=cug_yangyuancong@hotmail.com \
    --cc=daniel@makrotopia.org \
    --cc=davem@davemloft.net \
    --cc=deren.wu@mediatek.com \
    --cc=dokyungs@yonsei.ac.kr \
    --cc=dsahern@kernel.org \
    --cc=dzm91@hust.edu.cn \
    --cc=edumazet@google.com \
    --cc=gch981213@gmail.com \
    --cc=git@qrsnap.io \
    --cc=gregkh@linuxfoundation.org \
    --cc=guanwentao@uniontech.com \
    --cc=gustavoars@kernel.org \
    --cc=helmut.schaa@googlemail.com \
    --cc=horms@kernel.org \
    --cc=jiefeng_li@hust.edu.cn \
    --cc=keescook@chromium.org \
    --cc=kuba@kernel.org \
    --cc=kvalo@codeaurora.org \
    --cc=kvalo@kernel.org \
    --cc=leit@fb.com \
    --cc=leitao@debian.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=lorenzo.bianconi83@gmail.com \
    --cc=lorenzo.bianconi@redhat.com \
    --cc=lorenzo@kernel.org \
    --cc=lynxis@fe80.eu \
    --cc=mailhol.vincent@wanadoo.fr \
    --cc=markus.theil@tu-ilmenau.de \
    --cc=matthias.bgg@gmail.com \
    --cc=mikhail.v.gavrilov@gmail.com \
    --cc=mingyen.hsieh@mediatek.com \
    --cc=mrkiko.rs@gmail.com \
    --cc=nbd@nbd.name \
    --cc=nelson.yu@mediatek.com \
    --cc=netdev@vger.kernel.org \
    --cc=oliver@neukum.org \
    --cc=pabeni@redhat.com \
    --cc=quan.zhou@mediatek.com \
    --cc=raoxu@uniontech.com \
    --cc=rodrigo.vivi@intel.com \
    --cc=romain.perier@gmail.com \
    --cc=rong.yan@mediatek.com \
    --cc=ryder.lee@mediatek.com \
    --cc=sean.wang@mediatek.com \
    --cc=sgruszka@redhat.com \
    --cc=shayne.chen@mediatek.com \
    --cc=sidhayn@gmail.com \
    --cc=stern@rowland.harvard.edu \
    --cc=stf_xl@wp.pl \
    --cc=sujuan.chen@mediatek.com \
    --cc=wang.zhao@mediatek.com \
    --cc=wangyuli@uniontech.com \
    --cc=weiwan@google.com \
    --cc=woojung.huh@microchip.com \
    --cc=yn.chen@mediatek.com \
    --cc=zhanjun@uniontech.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).