From: Junjie Cao <junjie.cao@linux.dev>
To: jamin_lin@aspeedtech.com
Cc: marcandre.lureau@redhat.com, clg@kaod.org,
peter.maydell@linaro.org, steven_lee@aspeedtech.com,
leetroy@gmail.com, kane_chen@aspeedtech.com,
andrew@codeconstruct.com.au, joel@jms.id.au, qemu-arm@nongnu.org,
qemu-devel@nongnu.org, troy_lee@aspeedtech.com,
junjie.cao@intel.com
Subject: Re: [PATCH v5 5/8] hw/usb/redirect-server: Implement control transfers
Date: Fri, 16 Oct 2026 08:01:24 +0000 [thread overview]
Message-ID: <20261016080125.418342-1-junjie.cao@linux.dev> (raw)
In-Reply-To: <20261015093417.573063-6-jamin_lin@aspeedtech.com>
From: Junjie Cao <junjie.cao@intel.com>
Hi Jamin,
The tests below were run on v4; patches 5 and 6 are unchanged in v5.
> + usbredir_server_do_control(priv, id, hdr, data, data_len,
> + USBREDIR_SERVER_REPLY_CONTROL);
The callback owns data, but do_control() copies it without freeing the
original buffer. In a test with usb-storage, 100 vendor control OUT
requests carrying 64 bytes each complete with STALL, but LSan reports
6,400 bytes leaked in 100 parser allocations.
Could we call usbredirparser_free_packet_data() after do_control()
returns, and free data on every exit from the bulk and interrupt
callbacks in patch 6?
> + QTAILQ_REMOVE(&s->inflight, rp, next);
> + usb_packet_cleanup(&rp->pkt);
A test device returning async IOERROR for the first of two bulk OUT
requests reproduces an assertion here. The core calls back for the
second packet with USB_RET_REMOVE_FROM_QUEUE, but leaves it QUEUED on
ep->queue. usb_packet_cleanup() then hits its
!usb_packet_is_inflight() assertion.
Could we call usb_cancel_packet() for that status before cleanup?
For a QUEUED packet it removes the core queue entry without calling
the device's cancel callback.
In the not-found case of usbredir_server_cancel_data_packet():
> + usbredirparser_send_control_packet(s->parser, id, &resp, NULL, 0);
If the original reply is already queued when the cancel arrives, the
QEMU client consumes its cancelled-ID entry when it receives that
reply. The extra control packet then sends a second reply for the
same ID.
Could we omit this reply when the transfer is not found?
usbredirhost_cancel_data_packet() also sends no additional reply
in that case.
next prev parent reply other threads:[~2026-10-16 13:02 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 9:34 [PATCH v5 0/8] hw/usb: Add a usbredir server transport Jamin Lin
2026-10-15 9:34 ` [PATCH v5 1/8] hw/usb/bus: Let a bus opt out of automatic hub insertion Jamin Lin
2026-10-15 9:34 ` [PATCH v5 2/8] hw/usb/redirect-server: Add a usbredir server device Jamin Lin
2026-10-15 9:34 ` [PATCH v5 3/8] hw/usb/redirect-server: Connect usbredirparser to a chardev Jamin Lin
2026-10-15 9:34 ` [PATCH v5 4/8] hw/usb/redirect-server: Announce the exported device Jamin Lin
2026-10-15 9:34 ` [PATCH v5 5/8] hw/usb/redirect-server: Implement control transfers Jamin Lin
2026-10-16 8:01 ` Junjie Cao [this message]
2026-10-19 6:17 ` Jamin Lin
2026-10-16 9:26 ` Jamin Lin
2026-10-16 9:27 ` Jamin Lin
2026-10-15 9:34 ` [PATCH v5 6/8] hw/usb/redirect-server: Implement bulk and interrupt transfers Jamin Lin
2026-10-15 9:34 ` [PATCH v5 7/8] hw/usb/redirect-server: Stream interrupt IN endpoints Jamin Lin
2026-10-16 8:01 ` Junjie Cao
2026-10-19 6:58 ` Jamin Lin
2026-10-16 8:21 ` marcandre.lureau
2026-10-19 6:56 ` Jamin Lin
2026-10-15 9:34 ` [PATCH v5 8/8] hw/arm/aspeed: Enable the usbredir server transport Jamin Lin
2026-10-16 6:31 ` [PATCH v5 0/8] hw/usb: Add a " Jamin Lin
2026-10-16 6:38 ` Cédric Le Goater
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=20261016080125.418342-1-junjie.cao@linux.dev \
--to=junjie.cao@linux.dev \
--cc=andrew@codeconstruct.com.au \
--cc=clg@kaod.org \
--cc=jamin_lin@aspeedtech.com \
--cc=joel@jms.id.au \
--cc=junjie.cao@intel.com \
--cc=kane_chen@aspeedtech.com \
--cc=leetroy@gmail.com \
--cc=marcandre.lureau@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=steven_lee@aspeedtech.com \
--cc=troy_lee@aspeedtech.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