summary refs log tree commit diff
path: root/pkgs/os-specific/linux/kernel/0001-CHROMIUM-virtwl-Support-multiple-host-sockets.patch
blob: 3e4e504978cc6289ada1e6b935ac74657e669304 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
From 7f7629cc680bf3c22d547fb5333e521af58c6c9e Mon Sep 17 00:00:00 2001
From: Ryo Hashimoto <hashimoto@google.com>
Date: Wed, 11 Dec 2019 18:32:03 +0900
Subject: [PATCH] CHROMIUM: virtwl: Support multiple host sockets

Add a new argument to VIRTWL_IOCTL_NEW_CTX.
This CL doesn't change the size of structs.

Guest can use this parameter to create a context connected to a host
process other than the compositor.

BUG=b:146100044, b:140202859
TEST=Camera works

Change-Id: I1c6b1a256002a336774a36caf0fe8d18f08c0f56
Signed-off-by: Ryo Hashimoto <hashimoto@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/1962108
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
(cherry picked from commit 5d641a7b7b64664230d2fd2aa1e74dd792b8b7bf)
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/2035921
Tested-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Auto-Submit: Chirantan Ekbote <chirantan@chromium.org>
Signed-off-by: Alyssa Ross <hi@alyssa.is>
---
 drivers/virtio/virtio_wl.c     |  6 ++++++
 include/uapi/linux/virtio_wl.h | 29 +++++++++++++++++------------
 include/uapi/linux/virtwl.h    |  3 +++
 3 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/drivers/virtio/virtio_wl.c b/drivers/virtio/virtio_wl.c
index 1b3f8926519a7..80cf799bed464 100644
--- a/drivers/virtio/virtio_wl.c
+++ b/drivers/virtio/virtio_wl.c
@@ -1024,6 +1024,7 @@ static struct virtwl_vfd *do_new(struct virtwl_info *vi,
 	int ret = 0;
 
 	if (ioctl_new->type != VIRTWL_IOCTL_NEW_CTX &&
+		ioctl_new->type != VIRTWL_IOCTL_NEW_CTX_NAMED &&
 		ioctl_new->type != VIRTWL_IOCTL_NEW_ALLOC &&
 		ioctl_new->type != VIRTWL_IOCTL_NEW_PIPE_READ &&
 		ioctl_new->type != VIRTWL_IOCTL_NEW_PIPE_WRITE &&
@@ -1060,6 +1061,11 @@ static struct virtwl_vfd *do_new(struct virtwl_info *vi,
 		ctrl_new->hdr.type = VIRTIO_WL_CMD_VFD_NEW_CTX;
 		ctrl_new->flags = VIRTIO_WL_VFD_WRITE | VIRTIO_WL_VFD_READ;
 		break;
+	case VIRTWL_IOCTL_NEW_CTX_NAMED:
+		ctrl_new->hdr.type = VIRTIO_WL_CMD_VFD_NEW_CTX_NAMED;
+		ctrl_new->flags = VIRTIO_WL_VFD_WRITE | VIRTIO_WL_VFD_READ;
+		memcpy(ctrl_new->name, ioctl_new->name, sizeof(ctrl_new->name));
+		break;
 	case VIRTWL_IOCTL_NEW_ALLOC:
 		ctrl_new->hdr.type = VIRTIO_WL_CMD_VFD_NEW;
 		ctrl_new->size = PAGE_ALIGN(ioctl_new->size);
diff --git a/include/uapi/linux/virtio_wl.h b/include/uapi/linux/virtio_wl.h
index 1d3ec6b31d4d3..ad9b6dfcd3263 100644
--- a/include/uapi/linux/virtio_wl.h
+++ b/include/uapi/linux/virtio_wl.h
@@ -37,6 +37,7 @@ enum virtio_wl_ctrl_type {
 	VIRTIO_WL_CMD_VFD_NEW_DMABUF, /* virtio_wl_ctrl_vfd_new */
 	VIRTIO_WL_CMD_VFD_DMABUF_SYNC, /* virtio_wl_ctrl_vfd_dmabuf_sync */
 	VIRTIO_WL_CMD_VFD_SEND_FOREIGN_ID, /* virtio_wl_ctrl_vfd_send + data */
+	VIRTIO_WL_CMD_VFD_NEW_CTX_NAMED, /* virtio_wl_ctrl_vfd_new */
 
 	VIRTIO_WL_RESP_OK = 0x1000,
 	VIRTIO_WL_RESP_VFD_NEW = 0x1001, /* virtio_wl_ctrl_vfd_new */
@@ -78,18 +79,22 @@ struct virtio_wl_ctrl_vfd_new {
 	__le32 flags; /* virtio_wl_vfd_flags */
 	__le64 pfn; /* first guest physical page frame number if VFD_MAP */
 	__le32 size; /* size in bytes if VIRTIO_WL_CMD_VFD_NEW* */
-	/* buffer description if VIRTIO_WL_CMD_VFD_NEW_DMABUF */
-	struct {
-		__le32 width; /* width in pixels */
-		__le32 height; /* height in pixels */
-		__le32 format; /* fourcc format */
-		__le32 stride0; /* return stride0 */
-		__le32 stride1; /* return stride1 */
-		__le32 stride2; /* return stride2 */
-		__le32 offset0; /* return offset0 */
-		__le32 offset1; /* return offset1 */
-		__le32 offset2; /* return offset2 */
-	} dmabuf;
+	union {
+		/* buffer description if VIRTIO_WL_CMD_VFD_NEW_DMABUF */
+		struct {
+			__le32 width; /* width in pixels */
+			__le32 height; /* height in pixels */
+			__le32 format; /* fourcc format */
+			__le32 stride0; /* return stride0 */
+			__le32 stride1; /* return stride1 */
+			__le32 stride2; /* return stride2 */
+			__le32 offset0; /* return offset0 */
+			__le32 offset1; /* return offset1 */
+			__le32 offset2; /* return offset2 */
+		} dmabuf;
+		/* name of socket if VIRTIO_WL_CMD_VFD_NEW_CTX_NAMED */
+		char name[32];
+	};
 };
 
 
diff --git a/include/uapi/linux/virtwl.h b/include/uapi/linux/virtwl.h
index 939041389b403..baa9b341377a5 100644
--- a/include/uapi/linux/virtwl.h
+++ b/include/uapi/linux/virtwl.h
@@ -21,6 +21,7 @@ enum virtwl_ioctl_new_type {
 	VIRTWL_IOCTL_NEW_PIPE_WRITE,
 	/* create a new virtwl dmabuf that is writable via the returned fd */
 	VIRTWL_IOCTL_NEW_DMABUF,
+	VIRTWL_IOCTL_NEW_CTX_NAMED, /* open a new named connection context */
 };
 
 struct virtwl_ioctl_new {
@@ -42,6 +43,8 @@ struct virtwl_ioctl_new {
 			__u32 offset1; /* return offset1 */
 			__u32 offset2; /* return offset2 */
 		} dmabuf;
+		/* name of socket if type == VIRTIO_WL_CMD_VFD_NEW_CTX_NAMED */
+		char name[32];
 	};
 };
 
-- 
2.26.2