From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5AB2E35F191 for ; Mon, 22 Jun 2026 21:08:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782162537; cv=none; b=N8n+MrD4pk3F9YK5GBxUYAWvXdSJeweEzR+d2LFaklrAgsRLzEYdD5ygghTIXEbiE7jnFP2pEOl7l0mzy/Ao3B558Re+CqFDMdfsgjqn3L0d682vGyi7F84+sGzCaU4qA0l5GRnIQ6pmZVxg9WOKSZOeiGrtoWCgOk9muXnDju8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782162537; c=relaxed/simple; bh=pmBo+w73eRHOywxv/S6NXnxFU3GqCpF8V0YmuW/oaTw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Xw6a8GqtHXR3pXhWEkvUwhaOZc6OZx/BnWXCWShGGszbQ5iWesTGklbY7ynZIXn+vgjXgyF0REoRcLcdhhgNBfH+UuV8IxXhJlOJuMvOjznBEhg8O9rRQ1BcdTWWDBDIisX2KKiMJIa949YHJjzXi76uCXqD5yT3fd1Y2rbACi8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=UhhAbWLN; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=E8uj8FFv; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="UhhAbWLN"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="E8uj8FFv" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782162535; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Q8vqJMSqKfx+sunQXyB2WFWU85NOrm3GPszXiiWd5EI=; b=UhhAbWLNVLWPuHAwk8q1CKMYKkxV8nvH1SqOs+n3rjvit/JKpiRGFvz5bpIRFy5350vl4F Fnf/EcP0TRS00a1IGxzmHke1klKB8B+yRLHzyqyPKWJtwLDAXkVBEZtjDdViAeAUx6rsKA bjDzPrBrbaiuR00VuoXa8peDNl5GRZo= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-423-6Jc7AVI_NpGkfG38YB11iA-1; Mon, 22 Jun 2026 17:08:53 -0400 X-MC-Unique: 6Jc7AVI_NpGkfG38YB11iA-1 X-Mimecast-MFC-AGG-ID: 6Jc7AVI_NpGkfG38YB11iA_1782162533 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-490b61243easo65515125e9.2 for ; Mon, 22 Jun 2026 14:08:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782162532; x=1782767332; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=Q8vqJMSqKfx+sunQXyB2WFWU85NOrm3GPszXiiWd5EI=; b=E8uj8FFv2rlEfiqEBqYwMQ7Wtwc8tAWc3rOni9e2JYwMFEwxB/3bF/u2+BaG8pd1gz 0+7mu3D6B7OZBsB+ksv8y3Dw6I9rrjKInAhv9FM0wPb7fsuA5WZCcT+MKK1HlIzp82fh cbUuCZcrtjaSZzHicOfIRGCZ4cAaogI6QKg38k8vzFDGuHyTjKz1b5RVYgaHSXXJ1elR YN2oiAEjp6EDHNSYf7A8vUBjxN+9UXKhMB9KzPnEZKEV46yaBYja2C396kX8umwF9+el jldoGO0OCWPtWeF458iKZ3du+zmXMs1PHFZzTJ+5UNBa6m4SAVkQ1QRqZ2pLdi/y8yRQ bgMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782162532; x=1782767332; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Q8vqJMSqKfx+sunQXyB2WFWU85NOrm3GPszXiiWd5EI=; b=d07gSF2v4SgipIp7G/hsqTiJwgdQySdjolLIK0lDK+AkbEqiO3saQb2CpnF5I3/X6g kd/D88PN9TWRRiDWppxTbs3SbNvfUk5jLOgHpTh/+sC71Ca3EN76eU8oB5bNSv7uIJHh wj7GAqQM6JgaI7LN5xuAsMYS2IpX2STidJGX0Ct37xZbtseLrV+CC2uasr0fnh3VISJN 6K8kr286zN51r+92O4a0fXhJ1HwQ5gz5SINt806GGH1lUXTBBj3yMit0AaQHJd0lmksH KrfSwh3LEyifAmauHmveoS6cFaN0Wr45zY9I8/vNNi5Hbd1mBJG7qlhLvcZ75USgCX6j EHAA== X-Forwarded-Encrypted: i=1; AFNElJ9sU+4CWs5UL0Ofxs3c4F7lN+kazd2OFfehmoyhIabsFInFvzf+IaLehah/8vCx+XaoJXY0zsstH7C6dPQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yy6huWf+48Ay9P6J3UBrVzAyaj5MpdEdPILSwQmxccufapW7t8V 27GWecuq+6nGt49HSB5itRiQv57jq0slGQRSBQXTic7IAatrnWMna02a/4Z/gEpJb61qiu5ET1m woj/3ROhXTDZ/YoLhTsIOsH2YdmTTJ9jyXF+Hl+qzYeqwrkY+nkUH8xa1/5/4fuxJgw== X-Gm-Gg: AfdE7cmuqf8GXpynM/QRjI37bQgB2xn1tD+CG6mj9sdzNE9R+rNjcqfLAoxpJyl8/sX wqZQOaHvK9tVPgj6HHEQ2ohP6NRqL3GrGEdtzhln8PzVLjdVnMDZ4SW8amBqC8oZOLJxXQ4Cyue LJpzCeGdhO7KtDdhcQbfEv3xivMOpDt31i2uyOPPnjeohmKRp2Ap83K4r6YTYDq7ffHvYZaEsBN yZMfX++ddFhw2syIb5eMCAFHUrgfs3yI6UVaYsrt/XqcNiq5upRAjbwsajyBb/H9eCeVnHpHPNy 1BmY88sTnwE/IJ0ln/kEFhbEROFEJwCzSs0ynx08ZIQPAoEewcIc02IXbur6XcywShRVJ6PCCNn rqSxL1MRXJuoh7Uh4la0WvuaWFpPhA+P1 X-Received: by 2002:a05:600c:3781:b0:490:e104:7943 with SMTP id 5b1f17b1804b1-49240e85dd3mr196042565e9.18.1782162532487; Mon, 22 Jun 2026 14:08:52 -0700 (PDT) X-Received: by 2002:a05:600c:3781:b0:490:e104:7943 with SMTP id 5b1f17b1804b1-49240e85dd3mr196042355e9.18.1782162531951; Mon, 22 Jun 2026 14:08:51 -0700 (PDT) Received: from redhat.com (IGLD-80-230-85-71.inter.net.il. [80.230.85.71]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4924923392dsm448971425e9.2.2026.06.22.14.08.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jun 2026 14:08:51 -0700 (PDT) Date: Mon, 22 Jun 2026 17:08:48 -0400 From: "Michael S. Tsirkin" To: Brian Daniels 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 Subject: Re: [PATCH v4 2/8] media: virtio: Add virtio-media driver structs and function declarations Message-ID: <20260622170708-mutt-send-email-mst@kernel.org> References: <20260622204343.1994418-1-briandaniels@google.com> <20260622204343.1994418-3-briandaniels@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 > > Add the structs and function declarations for the new virtio-media drvier. > > 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". 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