aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Clark2014-01-12 07:27:36 -0600
committerRob Clark2014-01-12 08:00:51 -0600
commit8279c8fb498785ea2700c6cc4a3456d7e1134665 (patch)
tree3c18768a0b69bf294fd0bc3db5d59d3dbacdbc07 /freedreno/freedreno_device.c
parentde0970203091618834e4753c14d5169770797800 (diff)
downloadexternal-libdrm-8279c8fb498785ea2700c6cc4a3456d7e1134665.tar.gz
external-libdrm-8279c8fb498785ea2700c6cc4a3456d7e1134665.tar.xz
external-libdrm-8279c8fb498785ea2700c6cc4a3456d7e1134665.zip
freedreno: add fd_device_new_dup()
There seem to be some cases (I've noticed this switching resolution in some games, for example) where the fd can get closed() before the device and all it's bo's are destroyed. Which, if the drm device is opened again and bo's are allocated with the same handles, results that when the first pipe_screen/pipe_context is destroyed causes the first dev to close handles for bo's allocated by the second device. The easy solution to that is to add a mode where the fd_device creates it's own private fd (a dup()). Signed-off-by: Rob Clark <robclark@freedesktop.org>
Diffstat (limited to 'freedreno/freedreno_device.c')
-rw-r--r--freedreno/freedreno_device.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/freedreno/freedreno_device.c b/freedreno/freedreno_device.c
index 6486983d..23e086bb 100644
--- a/freedreno/freedreno_device.c
+++ b/freedreno/freedreno_device.c
@@ -135,6 +135,16 @@ struct fd_device * fd_device_new(int fd)
135 return dev; 135 return dev;
136} 136}
137 137
138/* like fd_device_new() but creates it's own private dup() of the fd
139 * which is close()d when the device is finalized.
140 */
141struct fd_device * fd_device_new_dup(int fd)
142{
143 struct fd_device *dev = fd_device_new(dup(fd));
144 dev->closefd = 1;
145 return dev;
146}
147
138struct fd_device * fd_device_ref(struct fd_device *dev) 148struct fd_device * fd_device_ref(struct fd_device *dev)
139{ 149{
140 atomic_inc(&dev->refcnt); 150 atomic_inc(&dev->refcnt);
@@ -147,6 +157,8 @@ static void fd_device_del_impl(struct fd_device *dev)
147 drmHashDestroy(dev->handle_table); 157 drmHashDestroy(dev->handle_table);
148 drmHashDestroy(dev->name_table); 158 drmHashDestroy(dev->name_table);
149 drmHashDelete(dev_table, dev->fd); 159 drmHashDelete(dev_table, dev->fd);
160 if (dev->closefd)
161 close(dev->fd);
150 dev->funcs->destroy(dev); 162 dev->funcs->destroy(dev);
151} 163}
152 164