All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Marek Marczykowski-Górecki" <marmarek@invisiblethingslab.com>
To: Suwan Kim <suwan.kim027@gmail.com>
Cc: linux-usb@vger.kernel.org, Shuah Khan <skhan@linuxfoundation.org>,
	Valentina Manea <valentina.manea.m@gmail.com>
Subject: Re: "usbip: Implement SG support to vhci-hcd and stub driver" causes a deadlock
Date: Wed, 11 Dec 2019 12:01:30 +0100	[thread overview]
Message-ID: <20191211110130.GN11116@mail-itl> (raw)
In-Reply-To: <20191211062705.GA11367@localhost.localdomain>

[-- Attachment #1: Type: text/plain, Size: 2595 bytes --]

On Wed, Dec 11, 2019 at 03:27:05PM +0900, Suwan Kim wrote:
> On Wed, Dec 11, 2019 at 04:20:32AM +0100, Marek Marczykowski-Górecki wrote:
> > On Wed, Dec 11, 2019 at 12:07:54PM +0900, Suwan Kim wrote:
> > > HCD should giveback URB to driver calling usb_hcd_giveback_urb().
> > > But in the case of transaction error, vhci_recv_ret_submit()
> > > terminates without giveback URB. So, I think the error path in
> > > usbip_recv_xbuff and usbip_recv_iso should unlink URB from ep and
> > > insert proper error code in urb->status that indicates error
> > > status to driver and handle giveback URB to driver.
> > > 
> > > Then hub_irq doesn't need to flush error URB.
> > > That will be helpful to graceful connection shutdown.
> > > 
> > > 
> > > static void vhci_recv_ret_submit(struct vhci_device *vdev,
> > > 				 struct usbip_header *pdu)
> > > ...
> > > ...
> > > 	if (usbip_recv_xbuff(ud, urb) < 0) {
> > > 		urb->status = -EPIPE;
> > > 		goto error;	// goto error path
> > > 	}
> > > 
> > > 	/* recv iso_packet_descriptor */
> > > 	if (usbip_recv_iso(ud, urb) < 0) {
> > > 		urb->status = -EPIPE;
> > > 		goto error;	// goto error path
> > > 	}
> > > ...
> > > ...
> > > error://error path
> > > 	spin_lock_irqsave(&vhci->lock, flags);
> > > 	usb_hcd_unlink_urb_from_ep(vhci_hcd_to_hcd(vhci_hcd), urb);
> > > 	spin_unlock_irqrestore(&vhci->lock, flags);
> > > 
> > > 	usb_hcd_giveback_urb(vhci_hcd_to_hcd(vhci_hcd), urb, urb->status);
> > > 
> > > 	usbip_dbg_vhci_rx("Leave\n");
> > > }
> > 
> > Yup, that works! Now the error is handled gracefully instead of hanging.
> 
> Marek, Could you test if it works too?

Yes, this seems to work too.


> Regards,
> Suwan Kim
> 
> 
> diff --git a/drivers/usb/usbip/vhci_rx.c b/drivers/usb/usbip/vhci_rx.c
> index 33f8972ba842..19a807e398eb 100644
> --- a/drivers/usb/usbip/vhci_rx.c
> +++ b/drivers/usb/usbip/vhci_rx.c
> @@ -78,11 +78,11 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
> 
>         /* recv transfer buffer */
>         if (usbip_recv_xbuff(ud, urb) < 0)
> -               return;
> +               urb->status = -EPIPE;
> 
>         /* recv iso_packet_descriptor */
>         if (usbip_recv_iso(ud, urb) < 0)
> -               return;
> +               urb->status = -EPIPE;
> 
>         /* restore the padding in iso packets */
>         usbip_pad_iso(ud, urb);

-- 
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

      reply	other threads:[~2019-12-11 11:01 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-06  3:24 "usbip: Implement SG support to vhci-hcd and stub driver" causes a deadlock Marek Marczykowski-Górecki
2019-12-06  6:50 ` Suwan Kim
2019-12-06 20:57   ` Marek Marczykowski-Górecki
2019-12-06 21:12     ` Shuah Khan
2019-12-07  0:58       ` Marek Marczykowski-Górecki
2019-12-07 18:45         ` Marek Marczykowski-Górecki
2019-12-09  2:01     ` Suwan Kim
2019-12-09  3:37       ` Marek Marczykowski-Górecki
2019-12-09  6:35         ` Suwan Kim
2019-12-09 14:19           ` Marek Marczykowski-Górecki
2019-12-10 14:25             ` Suwan Kim
2019-12-10 15:32               ` Marek Marczykowski-Górecki
2019-12-11  3:07                 ` Suwan Kim
2019-12-11  3:20                   ` Marek Marczykowski-Górecki
2019-12-11  4:53                     ` Suwan Kim
2019-12-11  6:27                     ` Suwan Kim
2019-12-11 11:01                       ` Marek Marczykowski-Górecki [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=20191211110130.GN11116@mail-itl \
    --to=marmarek@invisiblethingslab.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=suwan.kim027@gmail.com \
    --cc=valentina.manea.m@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.