qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 1/8] usb: Add packet combining functions
Date: Thu, 01 Nov 2012 14:28:32 +0100	[thread overview]
Message-ID: <50927900.8000301@redhat.com> (raw)
In-Reply-To: <509275CC.1090309@redhat.com>

Hi,

On 11/01/2012 02:14 PM, Hans de Goede wrote:
> Hi,
>
> On 11/01/2012 11:08 AM, Gerd Hoffmann wrote:
>> On 10/31/12 13:47, Hans de Goede wrote:
>>> +    /*
>>> +     * If we had leftover packets the hcd driver will have cancelled them
>>> +     * and usb_combined_packet_cancel has already freed combined!
>>> +     */
>>> +    if (state != leftover) {
>>> +        g_free(combined);
>>> +    }
>>
>> This calls for reference-counting USBCombinedPacket IMHO.
>
> Why? We call packet_complete with a status if USB_RET_REMOVE_FROM_QUEUE
> if we've left-over packets, the hcd code will cancel these, and
> usb_combined_packet_cancel will free the combined packet when the
> last packet of it gets cancelled, which *will* happen as we're
> always processing *all* packets in combined here. There is no
> scenario here where one or the other party wants to keep the
> combined packet around any longer...
>
> The only reason this is a bit non straightforward is that
> normally packets get freed either on completion or cancellation,
> but here we've a partial completion and a partial cancellation.

Also note that reference counting will not make the special case
go away, as for combined packets without any leftover packets the
packet_complete (status == USB_RET_REMOVE_FROM_QUEUE) -> cancel
-> free/unref will never happen.

So simply taking a ref at the beginning of usb_combined_input_packet_complete
and then doing unref at the end will not help. Because for combined-packets
where all packets where used we then would need to do unref twice, once
to drop the local ref, and once to drop the final ref.

Regards,

Hans

  reply	other threads:[~2012-11-01 13:26 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-31 12:47 [Qemu-devel] usb input pipelining patches v3 Hans de Goede
2012-10-31 12:47 ` [Qemu-devel] [PATCH 1/8] usb: Add packet combining functions Hans de Goede
2012-11-01 10:08   ` Gerd Hoffmann
2012-11-01 13:14     ` Hans de Goede
2012-11-01 13:28       ` Hans de Goede [this message]
2012-11-01 13:59     ` Hans de Goede
2012-11-01 14:23       ` Gerd Hoffmann
2012-11-01 16:17         ` Hans de Goede
2012-11-01 16:42           ` Gerd Hoffmann
2012-11-01 19:07             ` Hans de Goede
2012-10-31 12:47 ` [Qemu-devel] [PATCH 2/8] combined-packet: Add a workaround for Linux usbfs + live migration Hans de Goede
2012-10-31 12:47 ` [Qemu-devel] [PATCH 3/8] usb-redir: Add support for 32 bits bulk packet length Hans de Goede
2012-10-31 12:47 ` [Qemu-devel] [PATCH 4/8] usb-redir: Add support for input pipelining Hans de Goede
2012-11-01 10:10   ` Gerd Hoffmann
2012-11-01 13:16     ` Hans de Goede
2012-10-31 12:47 ` [Qemu-devel] [PATCH 5/8] usb-redir: Add an usbredir_setup_usb_eps() helper function Hans de Goede
2012-10-31 12:47 ` [Qemu-devel] [PATCH 6/8] usb-redir: Use reject rather the disconnect on bad ep info Hans de Goede
2012-10-31 12:47 ` [Qemu-devel] [PATCH 7/8] usb-redir: Allow to attach USB 2.0 devices to 1.1 host controller Hans de Goede
2012-10-31 12:47 ` [Qemu-devel] [PATCH 8/8] usb-redir: Allow redirecting super speed devices to high speed controllers Hans de Goede

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=50927900.8000301@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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).