From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: f4bug@amsat.org, qemu-devel@nongnu.org,
zhenwei pi <pizhenwei@bytedance.com>,
kraxel@redhat.com
Subject: Re: [PATCH] usb: allow max 8192 bytes for desc
Date: Tue, 11 Jan 2022 12:25:24 +0000 [thread overview]
Message-ID: <Yd13NAsHpuRCMJRy@redhat.com> (raw)
In-Reply-To: <CAFEAcA9d4X+pobnz2vA_hTwDBuGRBTjjnD_CgKmsKuCAjH-ZNQ@mail.gmail.com>
On Tue, Jan 11, 2022 at 12:21:42PM +0000, Peter Maydell wrote:
> On Tue, 11 Jan 2022 at 10:54, zhenwei pi <pizhenwei@bytedance.com> wrote:
> >
> > A device of USB video class usually uses larger desc structure, so
> > use larger buffer to avoid failure. (dev-video.c is ready)
> >
> > Allocating memory dynamically by g_malloc of the orignal version of
> > this change, Philippe suggested just using the stack. Test the two
> > versions of qemu binary, the size of stack gets no change.
> >
> > CC: Philippe Mathieu-Daudé <f4bug@amsat.org>
> > Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
> > ---
> > hw/usb/desc.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/hw/usb/desc.c b/hw/usb/desc.c
> > index 8b6eaea407..57d2aedba1 100644
> > --- a/hw/usb/desc.c
> > +++ b/hw/usb/desc.c
> > @@ -632,7 +632,7 @@ int usb_desc_get_descriptor(USBDevice *dev, USBPacket *p,
> > bool msos = (dev->flags & (1 << USB_DEV_FLAG_MSOS_DESC_IN_USE));
> > const USBDesc *desc = usb_device_get_usb_desc(dev);
> > const USBDescDevice *other_dev;
> > - uint8_t buf[256];
> > + uint8_t buf[8192];
> > uint8_t type = value >> 8;
> > uint8_t index = value & 0xff;
> > int flags, ret = -1;
>
> I think 8K is too large to be allocating as an array on
> the stack, so if we need this buffer to be larger we should
> switch to some other allocation strategy for it.
IIUC, querying USB device descriptors is not a hot path, so using
heap allocation feels sufficient.
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
next prev parent reply other threads:[~2022-01-11 12:28 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-11 10:49 [PATCH] usb: allow max 8192 bytes for desc zhenwei pi
2022-01-11 12:07 ` Philippe Mathieu-Daudé
2022-01-11 12:21 ` Peter Maydell
2022-01-11 12:25 ` Daniel P. Berrangé [this message]
2022-01-11 12:27 ` zhenwei pi
2022-01-11 12:38 ` Daniel P. Berrangé
2022-01-11 12:39 ` zhenwei pi
2022-01-11 12:59 ` Philippe Mathieu-Daudé
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=Yd13NAsHpuRCMJRy@redhat.com \
--to=berrange@redhat.com \
--cc=f4bug@amsat.org \
--cc=kraxel@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=pizhenwei@bytedance.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 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.