All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Brian Daniels <briandaniels@google.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
	acourbot@google.com, adelva@google.com, aesteve@redhat.com,
	changyeon@google.com, daniel.almeida@collabora.com,
	eperezma@redhat.com, gnurou@gmail.com, gurchetansingh@google.com,
	hverkuil@xs4all.nl, jasowang@redhat.com,
	linux-kernel@vger.kernel.org, linux-media@vger.kernel.org,
	nicolas.dufresne@collabora.com, virtualization@lists.linux.dev,
	xuanzhuo@linux.alibaba.com
Subject: Re: [PATCH v4 2/8] media: virtio: Add virtio-media driver structs and function declarations
Date: Mon, 22 Jun 2026 17:08:48 -0400	[thread overview]
Message-ID: <20260622170708-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20260622204343.1994418-3-briandaniels@google.com>

On Mon, Jun 22, 2026 at 04:43:37PM -0400, Brian Daniels wrote:
> From: Alexandre Courbot <gnurou@gmail.com>
> 
> Add the structs and function declarations for the new virtio-media drvier.
> 
> Signed-off-by: Alexandre Courbot <gnurou@gmail.com>
> Co-developed-by: Brian Daniels <briandaniels@google.com>
> Signed-off-by: Brian Daniels <briandaniels@google.com>
> ---
>  drivers/media/virtio/virtio_media.h | 95 +++++++++++++++++++++++++++++
>  1 file changed, 95 insertions(+)
>  create mode 100644 drivers/media/virtio/virtio_media.h
> 
> diff --git a/drivers/media/virtio/virtio_media.h b/drivers/media/virtio/virtio_media.h
> new file mode 100644
> index 000000000..52809d4e9
> --- /dev/null
> +++ b/drivers/media/virtio/virtio_media.h
> @@ -0,0 +1,95 @@
> +/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0+ */
> +
> +/*
> + * Virtio-media structures & functions declarations.
> + *
> + * Copyright (c) 2024-2025 Google LLC.
> + */
> +
> +#ifndef __VIRTIO_MEDIA_H
> +#define __VIRTIO_MEDIA_H
> +
> +#include <linux/virtio_config.h>
> +#include <media/v4l2-device.h>
> +
> +#include "protocol.h"
> +
> +#define DESC_CHAIN_MAX_LEN SG_MAX_SINGLE_ALLOC
> +
> +#define VIRTIO_MEDIA_DEFAULT_DRIVER_NAME "virtio-media"
> +
> +extern char *virtio_media_driver_name;
> +extern bool virtio_media_allow_userptr;
> +
> +/**
> + * struct virtio_media - Virtio-media device.
> + * @v4l2_dev: v4l2_device for the media device.
> + * @video_dev: video_device for the media device.
> + * @virtio_dev: virtio device for the media device.
> + * @commandq: virtio command queue.
> + * @eventq: virtio event queue.
> + * @eventq_work: work to run when events are received on @eventq.
> + * @mmap_region: region into which MMAP buffers are mapped by the host.
> + * @event_buffer: buffer for event descriptors.
> + * @sessions: list of active sessions on the device.
> + * @sessions_lock: protects @sessions and ``virtio_media_session::list``.
> + * @events_lock: prevents concurrent processing of events.
> + * @cmd: union of the device commands "open" and "munmap". The other
> + *       commands are handled by @struct virtio_media_session
> + * @resp: union of responses.to device commands "open" and "munmap". The
> + *        other responses are handled by @struct virtio_media_session
> + * @vlock: serializes access to the command queue.
> + * @wq: waitqueue for host responses on the command queue.
> + */
> +struct virtio_media {
> +	struct v4l2_device v4l2_dev;
> +	struct video_device video_dev;
> +
> +	struct virtio_device *virtio_dev;
> +	struct virtqueue *commandq;
> +	struct virtqueue *eventq;
> +	struct work_struct eventq_work;
> +
> +	struct virtio_shm_region mmap_region;
> +
> +	void *event_buffer;
> +
> +	struct list_head sessions;
> +	struct mutex sessions_lock; /* protects sessions list */
> +
> +	struct mutex events_lock; /* prevents concurrent event processing */
> +
> +	union {
> +		struct virtio_media_cmd_open open;
> +		struct virtio_media_cmd_munmap munmap;
> +	} cmd;
> +
> +	union {
> +		struct virtio_media_resp_open open;
> +		struct virtio_media_resp_munmap munmap;
> +	} resp;


You need DMA alignment padding for these things.

Which one can only see when I reads the actual driver 8 patches down.
Which is why it's not a sensible way to split patches.

A sensible way is to have a driver then add functionality
in logical pieces gradually.


> +
> +	struct mutex vlock; /* serializes command queue access */
> +	wait_queue_head_t wq;
> +};
> +
> +static inline struct virtio_media *
> +to_virtio_media(struct video_device *video_dev)
> +{
> +	return container_of(video_dev, struct virtio_media, video_dev);
> +}
> +
> +/* virtio_media_driver.c */
> +
> +int virtio_media_send_command(struct virtio_media *vv, struct scatterlist **sgs,
> +			      const size_t out_sgs, const size_t in_sgs,
> +			      size_t minimum_resp_len, size_t *resp_len);
> +void virtio_media_process_events(struct virtio_media *vv);
> +
> +/* virtio_media_ioctls.c */
> +
> +long virtio_media_device_ioctl(struct file *file, unsigned int cmd,
> +			       unsigned long arg);
> +extern const struct v4l2_ioctl_ops virtio_media_ioctl_ops;
> +
> +#endif // __VIRTIO_MEDIA_H
> -- 
> 2.55.0.rc0.799.gd6f94ed593-goog


  reply	other threads:[~2026-06-22 21:08 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-22 20:43 [PATCH v4 0/8] media: add virtio-media driver Brian Daniels
2026-06-22 20:43 ` [PATCH v4 1/8] media: virtio: Add protocol Brian Daniels
2026-06-22 21:05   ` Michael S. Tsirkin
2026-06-23  0:57   ` Bryan O'Donoghue
2026-06-22 20:43 ` [PATCH v4 2/8] media: virtio: Add virtio-media driver structs and function declarations Brian Daniels
2026-06-22 21:08   ` Michael S. Tsirkin [this message]
2026-06-23  1:09   ` Bryan O'Donoghue
2026-06-22 20:43 ` [PATCH v4 3/8] media: virtio: Add virtio-media session related structures Brian Daniels
2026-06-22 20:43 ` [PATCH v4 4/8] media: virtio: Add scatterlist_builder Brian Daniels
2026-06-22 20:43 ` [PATCH v4 5/8] media: virtio: Add virtio_media_ioctls Brian Daniels
2026-06-22 20:43 ` [PATCH v4 6/8] media: virtio: Add virtio_media_driver Brian Daniels
2026-06-22 21:21   ` Michael S. Tsirkin
2026-06-22 20:43 ` [PATCH v4 7/8] media: virtio: Add virtio-media to the build system Brian Daniels
2026-06-22 20:43 ` [PATCH v4 8/8] media: virtio: Add MAINTAINERS entry Brian Daniels
2026-06-22 21:23   ` Michael S. Tsirkin
2026-06-22 21:09 ` [PATCH v4 0/8] media: add virtio-media driver Michael S. Tsirkin

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=20260622170708-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=acourbot@google.com \
    --cc=adelva@google.com \
    --cc=aesteve@redhat.com \
    --cc=briandaniels@google.com \
    --cc=changyeon@google.com \
    --cc=daniel.almeida@collabora.com \
    --cc=eperezma@redhat.com \
    --cc=gnurou@gmail.com \
    --cc=gurchetansingh@google.com \
    --cc=hverkuil@xs4all.nl \
    --cc=jasowang@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=nicolas.dufresne@collabora.com \
    --cc=virtualization@lists.linux.dev \
    --cc=xuanzhuo@linux.alibaba.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.