From: "Michal Suchánek" <msuchanek@suse.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 3/8] usb_kdb: only process events succesfully received
Date: Wed, 3 Jul 2019 13:43:12 +0200 [thread overview]
Message-ID: <20190703134312.0733e1b3@naga> (raw)
In-Reply-To: <66cc8d26-778a-c3b2-4577-6e02dcf43f7c@denx.de>
On Wed, 3 Jul 2019 13:26:50 +0200
Marek Vasut <marex@denx.de> wrote:
> On 7/3/19 11:46 AM, Michal Suchánek wrote:
> > On Tue, 2 Jul 2019 23:20:28 +0200
> > Marek Vasut <marex@denx.de> wrote:
> >
> >> On 7/2/19 9:31 PM, Michal Suchánek wrote:
> >>> On Tue, 2 Jul 2019 20:38:27 +0200
> >>> Marek Vasut <marex@denx.de> wrote:
> >>>
> >>>> On 7/2/19 7:50 PM, Michal Suchánek wrote:
> >>>>> On Tue, 2 Jul 2019 18:58:54 +0200
> >>>>> Marek Vasut <marex@denx.de> wrote:
> >>>>>
> >>>>>> On 7/2/19 4:22 PM, Michal Suchánek wrote:
> >>>>>>> On Tue, 2 Jul 2019 15:11:07 +0200
> >>>>>>> Marek Vasut <marex@denx.de> wrote:
> >>>>>>>
> >>>>>>>> On 7/2/19 3:04 PM, Michal Suchánek wrote:
> >>>>>>>>> On Tue, 2 Jul 2019 13:58:30 +0200
> >>>>>>>>> Marek Vasut <marex@denx.de> wrote:
> >>>>>>>>>
> >>>>>>>>>> On 7/1/19 5:56 PM, Michal Suchanek wrote:
> >>>>>>>>>>> Causes unbound key repeat on error otherwise.
> >>>>>>>>>>>
> >>>>>>>>>>> Signed-off-by: Michal Suchanek <msuchanek@suse.de>
> >>>>>>>>>>> ---
> >>>>>>>>>>> common/usb_kbd.c | 7 +++----
> >>>>>>>>>>> 1 file changed, 3 insertions(+), 4 deletions(-)
> >>>>>>>>>>>
> >>>>>>>>>>> diff --git a/common/usb_kbd.c b/common/usb_kbd.c
> >>>>>>>>>>> index cc99c6be0720..948f9fd68490 100644
> >>>>>>>>>>> --- a/common/usb_kbd.c
> >>>>>>>>>>> +++ b/common/usb_kbd.c
> >>>>>>>>>>> @@ -339,10 +339,9 @@ static inline void usb_kbd_poll_for_event(struct usb_device *dev)
> >>>>>>>>>>> struct usb_kbd_pdata *data = dev->privptr;
> >>>>>>>>>>>
> >>>>>>>>>>> /* Submit a interrupt transfer request */
> >>>>>>>>>>> - usb_submit_int_msg(dev, data->intpipe, &data->new[0], data->intpktsize,
> >>>>>>>>>>> - data->intinterval);
> >>>>>>>>>>> -
> >>>>>>>>>>> - usb_kbd_irq_worker(dev);
> >>>>>>>>>>> + if (!usb_submit_int_msg(dev, data->intpipe, &data->new[0],
> >>>>>>>>>>
> >>>>>>>>>> Shouldn't you propagate return value from this function ? It can return
> >>>>>>>>>> ENOTSUPP.
> >>>>>>>>>>
> >>>>>>>>>
> >>>>>>>>> If it did then probing keyboard would fail and we would not get here.
> >>>>>>>>
> >>>>>>>> So there is no chance this function could return an error here, ever ?
> >>>>>>>> E.g. what if it's implemented and someone yanks the keyboard cable out
> >>>>>>>> just at the right time ?
> >>>>>>>
> >>>>>>> It returns errors all the time with dwc2. That's why we need to check
> >>>>>>> for the error condition. We should not get here if probing the keyboard
> >>>>>>> failed, though. So if the function is not supported we will not get
> >>>>>>> here. Anyway, if it's not supported or the keyboard is missing it by
> >>>>>>> definition cannot provide useful result so we should not process it.
> >>>>>>
> >>>>>> Except you start ignoring the error value from e.g. malfunctioning
> >>>>>> keyboard here, instead of propagating it, correct ?
> >>>>>
> >>>>> It was never propagated to start with. The return value was not checked
> >>>>> at all. What I do here is check the return value and not process the
> >>>>> data on error whatever it contains (like the keypress returned last
> >>>>> time valid data was received).
> >>>>
> >>>> I can see a patch which checks usb_kbd_poll_for_event() return value.
> >>>> Can you add one ?
> >>>
> >>> What for? Apparently the keypress is processed in usb_kbd_irq_worker.
> >>> So checking the return value is needed to decide if the worker should
> >>> run, and is not particularly useful outside usb_kbd_poll_for_event. We
> >>> could signal a getc() failure but do we have any code handling getc()
> >>> failures?
> >>
> >> I presume getc() might signal EOF if the underlying hardware fails.
> >> But in general, it's a good practice to not ignore errors.
> >>
> >
> > It is not such a great idea. You might have multiple input hardware (ie
> > serial and usb keyboard). What does it mean that usb keyboard failed in
> > this context?
>
> I'd say, the behavior is undefined ?
But we need to define it which the code does by ignoring the
device-specific error and relying on devices that are still working
(like a serial port) or for which error detection is not available
(like most serial ports).
>
> > So in my view the ultimate consumer of getc() has no use for the error
> > so there is no point in propagating it.
>
> Ignoring errors and not reporting them isn't nice either, so what other
> option(s) do we have here ?
Ignoring the errors is exactly the desirable behavior when facing
broken hardware like dwc2. On non-broken hardware you will get fewer
errors to ignore. It is up to the device driver to report device
failure with a message when the error condition could be informative to
the user (such as previously working device going away completely).
Thanks
Michal
next prev parent reply other threads:[~2019-07-03 11:43 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-01 15:56 [U-Boot] [PATCH 1/8] usb: r8a66597: return -ENOTSUPP from unimplemented submit_int_msg Michal Suchanek
2019-07-01 15:56 ` [U-Boot] [PATCH 2/8] usb: sl811-hcd: " Michal Suchanek
2019-07-01 15:56 ` [U-Boot] [PATCH 3/8] usb_kdb: only process events succesfully received Michal Suchanek
2019-07-02 11:58 ` Marek Vasut
2019-07-02 13:04 ` Michal Suchánek
2019-07-02 13:11 ` Marek Vasut
2019-07-02 14:22 ` Michal Suchánek
2019-07-02 16:58 ` Marek Vasut
2019-07-02 17:50 ` Michal Suchánek
2019-07-02 18:09 ` Michal Suchánek
2019-07-02 18:38 ` Marek Vasut
2019-07-02 19:31 ` Michal Suchánek
2019-07-02 21:20 ` Marek Vasut
2019-07-03 9:46 ` Michal Suchánek
2019-07-03 11:26 ` Marek Vasut
2019-07-03 11:43 ` Michal Suchánek [this message]
2019-07-03 11:48 ` Marek Vasut
2019-07-03 16:41 ` Michal Suchánek
2019-07-04 15:19 ` Marek Vasut
2019-07-01 15:56 ` [U-Boot] [PATCH 4/8] usb: storage: submit_int_msg -> usb_submit_int_msg Michal Suchanek
2019-07-01 15:56 ` [U-Boot] [PATCH 5/8] usb: Add nonblock argument to submit_int_msg Michal Suchanek
2019-07-01 15:56 ` [U-Boot] [PATCH 6/8] usb: add usb_submit_int_msg_nonblock Michal Suchanek
2019-07-02 11:59 ` Marek Vasut
2019-07-02 14:14 ` Michal Suchánek
2019-07-02 14:16 ` Bin Meng
2019-07-02 14:25 ` Michal Suchánek
2019-07-02 14:29 ` Bin Meng
2019-07-02 14:58 ` Michal Suchánek
2019-07-02 15:11 ` Bin Meng
2019-07-02 15:30 ` Michal Suchánek
2019-07-02 15:39 ` Bin Meng
2019-07-02 15:44 ` Michal Suchánek
2019-07-01 15:56 ` [U-Boot] [PATCH 7/8] usb: kbd: use usb_submit_int_msg_nonblock for polling Michal Suchanek
2019-07-01 15:56 ` [U-Boot] [PATCH 8/8] dwc2: use the nonblock argument in submit_int_msg Michal Suchanek
2019-07-02 11:57 ` [U-Boot] [PATCH 1/8] usb: r8a66597: return -ENOTSUPP from unimplemented submit_int_msg Marek Vasut
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=20190703134312.0733e1b3@naga \
--to=msuchanek@suse.de \
--cc=u-boot@lists.denx.de \
/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