From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6DF63306754 for ; Fri, 17 Jul 2026 19:46:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=209.85.214.173 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784317610; cv=pass; b=dcfr2KOBX3iYzJLemMuSwBhKjQJNdazBGAyAJi8Ds/eNHA+2nsEPTFTwi6rL47WPLmvb4mJ3WgY9R093AgEXM7UNH1wMqBLktwnHUC+wOgEoLI55+XScByHY/LJ7d45WHoaETsPY8K4CxUPW293ykxDypSvLdrpgoSnwuRnKhHo= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784317610; c=relaxed/simple; bh=zoiSF3JeQIqnQcvMW43JD4qB9vpjOVAXImiebAn+BPg=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=EoUzz50Kr7hhe1qSF6SrKMj2ejJWt6PNW03gqYa2hSa0fAZTGcP1m76nck6dHqSiD9K82rZRbJzmgcminMbCqY5+eZGoIzTIPtY6ESW9FcXkKyvqFsAybBvgl6AjWfv6Ckm+dBWuZh0bxjDDBZ0cJrp2CKEHyfRd3/OqPi+wd/Q= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=EDioRuZn; arc=pass smtp.client-ip=209.85.214.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="EDioRuZn" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-2cab97c86bdso220195ad.1 for ; Fri, 17 Jul 2026 12:46:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1784317609; cv=none; d=google.com; s=arc-20260327; b=KWVMRxEXWpAiBZgjIJSwxgxpg7I6lK4k64F2j60nWjehyVpQuo6uim7TKvewsYbhkQ GbYmdk9xx1fV89axmI4SxHqJlijMqaWoQrdVOVoyfKsp8RlwM/AAvbIZvDcuDtm4SYaz L3vdTr/paAwY+nOqp9juPCXhCBvpWLHfcA0VkohN4t0QADBUCZcUxz05/7d6Tu4VORu0 5dBxP4IHs/VNUoUO6ZKVWg4BH+Kfp3K5yFulQjOAXbe/Jv5kd74QgtNaWV+Z7BfmYT+R fbUS5O02dGeItyZH6V6ajAa2tF/cAn0va06046fxuktMEybKb6kFYGJUanO4DnakDZbQ /EsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=nsZo6eYxZiNwWUFhdwOagBZhkMfykQcqUISKPpPxaDA=; fh=YJ9C2mNJ5hI3VuX6coPHfyU0V1+qixu+l4jvVob63Y4=; b=cbgchqvertQrfXTAlhdGaV3gv4Vp+wbSVELXB8gggLCAKsiZ85dJfOZYq4aPxX6wgS b8HrlZeBRYAJwDAJQq4HQDvsqGh+USJ+upaackfAF0YP6Z9Ts/cmyyix4Y5sy9R7MsOX gKMPvKrWmOxKed+YNFGnMAiYvlbD/293qDMABdlVZpmAnnA7tLWJjP7wmHlMj1vVZ0GH Znsf6z6AB6pMDVoFEOzYpxMxo8SNLyfh6OMBm/7gmJOnl49yx8jxlDIYN2gUDJKzVyfS gP8WMRObpe0Z4Py5vbWB7qtgKMtWUZkzQd8FjWCk3QyS/Bu+vcvLyH3rIuOz9F0/fJ3e +y6w==; darn=vger.kernel.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1784317609; x=1784922409; darn=vger.kernel.org; h=content-transfer-encoding:content-type:cc:to:subject:message-id :date:from:in-reply-to:references:mime-version:from:to:cc:subject :date:message-id:reply-to:content-type; bh=nsZo6eYxZiNwWUFhdwOagBZhkMfykQcqUISKPpPxaDA=; b=EDioRuZnBOU5ftZKBHP8WH8A4n6Vpk77Txp583Tr1oKTkoeqb75S4tTtKHvnxdeZOg j1RZPgDRwNNVAlYpyoKg1tJNRg+lRBn+6v2U4IBNRw2CouS2eqZNWGPjCL07bYm5cJn2 Hu9V60PtnziRZqDPrgA5T5QXEn5pHxsNvb/UteXTOfmC7ZqS1N2HBxy6OaYdYOJFlDvq 1/Ww+rBy/OzT9dGTnkptsEXpO/eK6pvhMrmEsa4CKiAOxpo4jzUPXJQEPoA8W3HCTRRA iokeH0wiqOpGsmsd/FyaVgfOpWiB5GiL58ROaUR+vDX3S/sSRTesvYxI6l8aqQ7Ot3gS f/NQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784317609; x=1784922409; h=content-transfer-encoding:content-type:cc:to:subject:message-id :date:from:in-reply-to:references:mime-version:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=nsZo6eYxZiNwWUFhdwOagBZhkMfykQcqUISKPpPxaDA=; b=rDtgZPeVOShRpzXwuej+9ZWwZNRiQU+UhcxXB7+YSyxU54zAxH/BbMv8gpYkelDojE Q12615x+5Fu/J/5oH9QgEBRe6pLXyCEUbnjchzjf9I9LlhML53p5bUxQBUUoBsQV/b4I PI7w1OxbD95095jSsaMRMwMP6YCiAx1nP1x4Z1gzuM1fcmKqDn/UOY8+6v/NFfje1td0 PG4E1p4REIRQlug3eIGg3kYNPBgDcQRmJufPUv/gyGVbtYNwg1lAFT28QTpyPkDvHOJ4 1q0UhUdzKd+APMa/W8atr0M1SA0+KIQdSAcyDlcIzJwY9SMY3/luTSB6vbYTeqDL+KTp yKng== X-Forwarded-Encrypted: i=1; AHgh+RptbvI2YsTW75K4K4/w0XFDgdSgAAXJLCzEOS6j/kRR+MrMWJ1ORhVJp16gb+FlliEJ0xUIyUaO/D/VE04=@vger.kernel.org X-Gm-Message-State: AOJu0Yzm1/uKz8NQKDod8ARsUlLuHIiYtgAJLJx2ThPMCkC/kzhSV3Os IRewPpFMbkHhN2HUGkNW4GUGOT4qxgeWCbsqjbnbZ6WRWj/BLYUsFElLYxtHV+4oyDQSMj0ZH1s qwtpNyvDd+Dq2/63esLtoftyZbSryA6nNUMxsQm8= X-Gm-Gg: AfdE7cnJ6thFHSxM3esrI8wqLOwrC+5DJFz9sAoZc+lrYdxw04rjodHr8MK6p+77u0U QenXaQafEEA+fxjFo6K9EwAlGPsnN0LlD5UWxLuQdT3FKTvp4bf4+7wAdm1qmZphTXUteilkM3E HDQZcXGAqk2mcrZfrHXCZD2cQfVRR9dHNHvDP6scwMiF6ZVMHw5kTrtZTQ4X5TSYw6roP1rR/4w K27YR7VUWi8hdSLczaTFkzPxUz1eplph6yqtTtI5iUk6wbWOj/aJ6WKtLp1FP+iRSdigwc= X-Received: by 2002:a17:902:cec8:b0:2cf:41ba:96b8 with SMTP id d9443c01a7336-2cf45301963mr639285ad.6.1784317608017; Fri, 17 Jul 2026 12:46:48 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20260622204343.1994418-1-briandaniels@google.com> <20260622204343.1994418-3-briandaniels@google.com> <20260622170708-mutt-send-email-mst@kernel.org> In-Reply-To: <20260622170708-mutt-send-email-mst@kernel.org> From: Brian Daniels Date: Fri, 17 Jul 2026 15:46:36 -0400 X-Gm-Features: AUfX_mw74d-5_R4YCuTDMGPYdle20s2YGu2aL-50gbj-ggLz6JZziwCSX5CR83w Message-ID: Subject: Re: [PATCH v4 2/8] media: virtio: Add virtio-media driver structs and function declarations To: "Michael S. Tsirkin" Cc: Mauro Carvalho Chehab , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Jun 22, 2026 at 5:08=E2=80=AFPM Michael S. Tsirkin = wrote: > > On Mon, Jun 22, 2026 at 04:43:37PM -0400, Brian Daniels wrote: > > From: Alexandre Courbot > > > > Add the structs and function declarations for the new virtio-media drvi= er. > > > > Signed-off-by: Alexandre Courbot > > Co-developed-by: Brian Daniels > > Signed-off-by: Brian Daniels > > --- > > 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 > > +#include > > + > > +#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". T= he > > + * 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. Each member of the above unions is already padded to 64-bit alignment, is that sufficient? If not, could you tell me what else is necessary? > 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. > Appreciate the feedback. There was a previous comment requesting to split the patch into c/h file pairs, but I can try reformatting it as you suggest for v5. > > + > > + 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 scatterl= ist **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 >