1 /* $NetBSD: drm_lease.c,v 1.5 2021/12/19 11:08:47 riastradh Exp $ */
2
3 /*-
4 * Copyright (c) 2018 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Taylor R. Campbell.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 #include <sys/cdefs.h>
33 __KERNEL_RCSID(0, "$NetBSD: drm_lease.c,v 1.5 2021/12/19 11:08:47 riastradh Exp $");
34
35 #include <sys/types.h>
36 #include <sys/errno.h>
37 #include <sys/systm.h>
38
39 #include <linux/mutex.h>
40
41 #include <drm/drm_auth.h>
42 #include <drm/drm_device.h>
43 #include <drm/drm_file.h>
44 #include <drm/drm_lease.h>
45
46 /*
47 * drm_lease_owner(master)
48 *
49 * Return the root of the lease tree, following parent pointers up
50 * from master.
51 */
52 struct drm_master *
drm_lease_owner(struct drm_master * master)53 drm_lease_owner(struct drm_master *master)
54 {
55 struct drm_master *lessor;
56
57 while ((lessor = master->lessor) != NULL)
58 master = lessor;
59
60 return master;
61 }
62
63 /*
64 * drm_lease_held(file, id)
65 *
66 * XXX
67 */
68 bool
drm_lease_held(struct drm_file * file,int id)69 drm_lease_held(struct drm_file *file, int id)
70 {
71 struct drm_master *master;
72 bool held;
73
74 if (file == NULL || (master = file->master) == NULL)
75 return true;
76
77 mutex_lock(&master->dev->mode_config.idr_mutex);
78 held = _drm_lease_held(file, id);
79 mutex_unlock(&master->dev->mode_config.idr_mutex);
80
81 return held;
82 }
83
84 /*
85 * _drm_lease_held(file, id)
86 *
87 * Same as drm_lease_held but caller must hold file's root
88 * master's dev->mode_config.idr_mutex.
89 */
90 bool
_drm_lease_held(struct drm_file * file,int id)91 _drm_lease_held(struct drm_file *file, int id)
92 {
93 return true;
94 }
95
96 /*
97 * drm_lease_revoke(master)
98 *
99 * XXX
100 */
101 void
drm_lease_revoke(struct drm_master * master)102 drm_lease_revoke(struct drm_master *master)
103 {
104 }
105
106 /*
107 * drm_lease_filter_crtcs(file, crtcs)
108 *
109 * XXX
110 */
111 uint32_t
drm_lease_filter_crtcs(struct drm_file * file,uint32_t crtcs)112 drm_lease_filter_crtcs(struct drm_file *file, uint32_t crtcs)
113 {
114 return crtcs;
115 }
116
117 /*
118 * drm_mode_create_lease_ioctl(dev, data, file)
119 *
120 * DRM_IOCTL_MODE_CREATE_LEASE(struct drm_mode_create_lease) ioctl
121 * implementation.
122 */
123 int
drm_mode_create_lease_ioctl(struct drm_device * dev,void * data,struct drm_file * file)124 drm_mode_create_lease_ioctl(struct drm_device *dev, void *data,
125 struct drm_file *file)
126 {
127 struct drm_mode_create_lease *args __unused = data;
128
129 /* XXX not yet implemented */
130 return -ENODEV;
131 }
132
133 /*
134 * drm_mode_get_lease_ioctl(dev, data, file)
135 *
136 * DRM_IOCTL_MODE_GET_LEASE(struct drm_mode_get_lease) ioctl
137 * implementation.
138 */
139 int
drm_mode_get_lease_ioctl(struct drm_device * dev,void * data,struct drm_file * file)140 drm_mode_get_lease_ioctl(struct drm_device *dev, void *data,
141 struct drm_file *file)
142 {
143 struct drm_mode_get_lease *args __unused = data;
144
145 /* XXX not yet implemented */
146 return -ENODEV;
147 }
148
149 /*
150 * drm_mode_list_lessees_ioctl(dev, data, file)
151 *
152 * DRM_IOCTL_MODE_LIST_LESSEES(struct drm_mode_list_lessees) ioctl
153 * implementation.
154 */
155 int
drm_mode_list_lessees_ioctl(struct drm_device * dev,void * data,struct drm_file * file)156 drm_mode_list_lessees_ioctl(struct drm_device *dev, void *data,
157 struct drm_file *file)
158 {
159 struct drm_mode_list_lessees *args __unused = data;
160
161 /* XXX not yet implemented */
162 return -ENODEV;
163 }
164
165 /*
166 * drm_mode_revoke_lease_ioctl(dev, data, file)
167 *
168 * DRM_IOCTL_MODE_REVOKE_LEASE(struct drm_mode_revoke_lease) ioctl
169 * implementation.
170 */
171 int
drm_mode_revoke_lease_ioctl(struct drm_device * dev,void * data,struct drm_file * file)172 drm_mode_revoke_lease_ioctl(struct drm_device *dev, void *data,
173 struct drm_file *file)
174 {
175 struct drm_mode_revoke_lease *args __unused = data;
176
177 /* XXX not yet implemented */
178 return -ENODEV;
179 }
180
181 /*
182 * drm_lease_destroy(master)
183 *
184 * Notify lessees that master is being destroyed.
185 */
186 void
drm_lease_destroy(struct drm_master * master)187 drm_lease_destroy(struct drm_master *master)
188 {
189 }
190