From: Sergey Senozhatsky <senozhatsky@chromium.org>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Ricardo Ribalda <ribalda@chromium.org>,
Yunke Cao <yunkec@chromium.org>, Max Staudt <mstaudt@google.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
linux-kernel@vger.kernel.org, linux-media@vger.kernel.org
Subject: Re: [PATCH] media: uvcvideo: Do not alloc dev->status
Date: Thu, 15 Dec 2022 10:10:25 +0900 [thread overview]
Message-ID: <Y5p0AfcKaHWxEjGV@google.com> (raw)
In-Reply-To: <Y5nFap/r4OgqgmeK@pendragon.ideasonboard.com>
On (22/12/14 14:45), Laurent Pinchart wrote:
> On Wed, Dec 14, 2022 at 12:23:41PM +0100, Ricardo Ribalda wrote:
> > UVC_MAX_STATUS_SIZE is 16, simplify the code by inlining dev->status.
>
> The reason why uvc_status is allocated dynamically is to ensure cache
> line alignment, as the USB host controller may DMA to the buffer.
Oh, that's a very subtle detail.
> > +struct uvc_status_streaming {
> > + u8 button;
> > +} __packed;
> > +
> > +struct uvc_status_control {
> > + u8 bSelector;
> > + u8 bAttribute;
> > + u8 bValue[11];
> > +} __packed;
> > +
> > +struct uvc_status {
> > + u8 bStatusType;
> > + u8 bOriginator;
> > + u8 bEvent;
> > + union {
> > + struct uvc_status_control control;
> > + struct uvc_status_streaming streaming;
> > + };
> > +} __packed;
> > +
> > struct uvc_device {
> > struct usb_device *udev;
> > struct usb_interface *intf;
> > @@ -559,7 +579,7 @@ struct uvc_device {
> > /* Status Interrupt Endpoint */
> > struct usb_host_endpoint *int_ep;
> > struct urb *int_urb;
> > - u8 *status;
> > + struct uvc_status status;
So we can do something like this maybe?
+ struct uvc_status status ____cacheline_aligned;
And this actually even improves code readability, IMHO, in a
sense that we explicitly say that it has to be cache aligned.
prev parent reply other threads:[~2022-12-15 1:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-14 11:23 [PATCH] media: uvcvideo: Do not alloc dev->status Ricardo Ribalda
2022-12-14 11:26 ` Ricardo Ribalda
2022-12-14 12:45 ` Laurent Pinchart
2022-12-14 12:50 ` Laurent Pinchart
2022-12-15 1:10 ` Sergey Senozhatsky [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=Y5p0AfcKaHWxEjGV@google.com \
--to=senozhatsky@chromium.org \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=mstaudt@google.com \
--cc=ribalda@chromium.org \
--cc=yunkec@chromium.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