Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/external/bsd/drm2/vmwgfx drm/vmwgfx: First draft. Passe...
details: https://anonhg.NetBSD.org/src/rev/e63c17d95d9d
branches: trunk
changeset: 361600:e63c17d95d9d
user: riastradh <riastradh%NetBSD.org@localhost>
date: Thu Feb 17 01:21:02 2022 +0000
description:
drm/vmwgfx: First draft. Passes make depend, doesn't build yet.
diffstat:
sys/external/bsd/common/include/linux/compiler.h | 4 +-
sys/external/bsd/drm2/dist/drm/vmwgfx/ttm_lock.c | 55 +-
sys/external/bsd/drm2/dist/drm/vmwgfx/ttm_lock.h | 8 +-
sys/external/bsd/drm2/dist/drm/vmwgfx/ttm_object.c | 18 +-
sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_cmdbuf.c | 6 +-
sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_drv.c | 14 +-
sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_drv.h | 50 +-
sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_resource.c | 10 +-
sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_validation.h | 4 +-
sys/external/bsd/drm2/pci/files.drmkms_pci | 3 +-
sys/external/bsd/drm2/vmwgfx/files.vmwgfx | 69 ++
sys/external/bsd/drm2/vmwgfx/vmware_pack_begin.h | 1 +
sys/external/bsd/drm2/vmwgfx/vmware_pack_end.h | 1 +
sys/external/bsd/drm2/vmwgfx/vmwgfx2netbsd | 65 ++
sys/external/bsd/drm2/vmwgfx/vmwgfx_module.c | 133 +++++
sys/external/bsd/drm2/vmwgfx/vmwgfx_pci.c | 336 ++++++++++++++
sys/external/bsd/drm2/vmwgfx/vmwgfx_task.h | 52 ++
sys/external/bsd/drm2/vmwgfx/vmwgfxfb.c | 210 ++++++++
sys/external/bsd/drm2/vmwgfx/vmwgfxfb.h | 43 +
19 files changed, 1041 insertions(+), 41 deletions(-)
diffs (truncated from 1488 to 300 lines):
diff -r 0a2fc299c8b4 -r e63c17d95d9d sys/external/bsd/common/include/linux/compiler.h
--- a/sys/external/bsd/common/include/linux/compiler.h Thu Feb 17 00:54:51 2022 +0000
+++ b/sys/external/bsd/common/include/linux/compiler.h Thu Feb 17 01:21:02 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compiler.h,v 1.6 2021/12/19 11:26:57 riastradh Exp $ */
+/* $NetBSD: compiler.h,v 1.7 2022/02/17 01:21:02 riastradh Exp $ */
/*-
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -50,6 +50,8 @@
#define __maybe_unused __unused
#define noinline __noinline
#define __deprecated /* nothing */
+#define __acquire(X) /* nothing */
+#define __release(X) /* nothing */
#define barrier() __insn_barrier()
#define likely(X) __predict_true(X)
diff -r 0a2fc299c8b4 -r e63c17d95d9d sys/external/bsd/drm2/dist/drm/vmwgfx/ttm_lock.c
--- a/sys/external/bsd/drm2/dist/drm/vmwgfx/ttm_lock.c Thu Feb 17 00:54:51 2022 +0000
+++ b/sys/external/bsd/drm2/dist/drm/vmwgfx/ttm_lock.c Thu Feb 17 01:21:02 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ttm_lock.c,v 1.2 2021/12/18 23:45:45 riastradh Exp $ */
+/* $NetBSD: ttm_lock.c,v 1.3 2022/02/17 01:21:02 riastradh Exp $ */
/* SPDX-License-Identifier: GPL-2.0 OR MIT */
/**************************************************************************
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ttm_lock.c,v 1.2 2021/12/18 23:45:45 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ttm_lock.c,v 1.3 2022/02/17 01:21:02 riastradh Exp $");
#include <linux/atomic.h>
#include <linux/errno.h>
@@ -50,7 +50,7 @@
void ttm_lock_init(struct ttm_lock *lock)
{
spin_lock_init(&lock->lock);
- init_waitqueue_head(&lock->queue);
+ DRM_INIT_WAITQUEUE(&lock->queue, "ttmlock");
lock->rw = 0;
lock->flags = 0;
}
@@ -59,7 +59,7 @@
{
spin_lock(&lock->lock);
if (--lock->rw == 0)
- wake_up_all(&lock->queue);
+ DRM_SPIN_WAKEUP_ALL(&lock->queue, &lock->lock);
spin_unlock(&lock->lock);
}
@@ -67,12 +67,10 @@
{
bool locked = false;
- spin_lock(&lock->lock);
if (lock->rw >= 0 && lock->flags == 0) {
++lock->rw;
locked = true;
}
- spin_unlock(&lock->lock);
return locked;
}
@@ -80,11 +78,15 @@
{
int ret = 0;
+ spin_lock(&lock->lock);
if (interruptible)
- ret = wait_event_interruptible(lock->queue,
- __ttm_read_lock(lock));
+ DRM_SPIN_WAIT_UNTIL(ret, &lock->queue, &lock->lock,
+ __ttm_read_lock(lock));
else
- wait_event(lock->queue, __ttm_read_lock(lock));
+ DRM_SPIN_WAIT_NOINTR_UNTIL(ret, &lock->queue, &lock->lock,
+ __ttm_read_lock(lock));
+ spin_unlock(&lock->lock);
+
return ret;
}
@@ -112,11 +114,14 @@
int ret = 0;
bool locked;
+ spin_lock(&lock->lock);
if (interruptible)
- ret = wait_event_interruptible
- (lock->queue, __ttm_read_trylock(lock, &locked));
+ DRM_SPIN_WAIT_UNTIL(ret, &lock->queue, &lock->lock,
+ __ttm_read_trylock(lock, &locked));
else
- wait_event(lock->queue, __ttm_read_trylock(lock, &locked));
+ DRM_SPIN_WAIT_NOINTR_UNTIL(ret, &lock->queue, &lock->lock,
+ __ttm_read_trylock(lock, &locked));
+ spin_unlock(&lock->lock);
if (unlikely(ret != 0)) {
BUG_ON(locked);
@@ -130,7 +135,7 @@
{
spin_lock(&lock->lock);
lock->rw = 0;
- wake_up_all(&lock->queue);
+ DRM_SPIN_WAKEUP_ALL(&lock->queue, &lock->lock);
spin_unlock(&lock->lock);
}
@@ -154,17 +159,18 @@
{
int ret = 0;
+ spin_lock(&lock->lock);
if (interruptible) {
- ret = wait_event_interruptible(lock->queue,
- __ttm_write_lock(lock));
+ DRM_SPIN_WAIT_UNTIL(ret, &lock->queue, &lock->lock,
+ __ttm_write_lock(lock));
if (unlikely(ret != 0)) {
- spin_lock(&lock->lock);
lock->flags &= ~TTM_WRITE_LOCK_PENDING;
- wake_up_all(&lock->queue);
- spin_unlock(&lock->lock);
+ DRM_SPIN_WAKEUP_ONE(&lock->queue, &lock->lock);
}
} else
- wait_event(lock->queue, __ttm_write_lock(lock));
+ DRM_SPIN_WAIT_NOINTR_UNTIL(ret, &lock->queue, &lock->lock,
+ __ttm_write_lock(lock));
+ spin_unlock(&lock->lock);
return ret;
}
@@ -173,7 +179,7 @@
{
spin_lock(&lock->lock);
lock->flags &= ~TTM_SUSPEND_LOCK;
- wake_up_all(&lock->queue);
+ DRM_SPIN_WAKEUP_ALL(&lock->queue, &lock->lock);
spin_unlock(&lock->lock);
}
@@ -181,7 +187,6 @@
{
bool locked = false;
- spin_lock(&lock->lock);
if (lock->rw == 0) {
lock->flags &= ~TTM_SUSPEND_LOCK_PENDING;
lock->flags |= TTM_SUSPEND_LOCK;
@@ -189,11 +194,15 @@
} else {
lock->flags |= TTM_SUSPEND_LOCK_PENDING;
}
- spin_unlock(&lock->lock);
return locked;
}
void ttm_suspend_lock(struct ttm_lock *lock)
{
- wait_event(lock->queue, __ttm_suspend_lock(lock));
+ int ret;
+
+ spin_lock(&lock->lock);
+ DRM_SPIN_WAIT_UNTIL(ret, &lock->queue, &lock->lock,
+ __ttm_suspend_lock(lock));
+ spin_unlock(&lock->lock);
}
diff -r 0a2fc299c8b4 -r e63c17d95d9d sys/external/bsd/drm2/dist/drm/vmwgfx/ttm_lock.h
--- a/sys/external/bsd/drm2/dist/drm/vmwgfx/ttm_lock.h Thu Feb 17 00:54:51 2022 +0000
+++ b/sys/external/bsd/drm2/dist/drm/vmwgfx/ttm_lock.h Thu Feb 17 01:21:02 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ttm_lock.h,v 1.2 2021/12/18 23:45:45 riastradh Exp $ */
+/* $NetBSD: ttm_lock.h,v 1.3 2022/02/17 01:21:02 riastradh Exp $ */
/**************************************************************************
*
@@ -56,6 +56,10 @@
#include "ttm_object.h"
+#ifdef __NetBSD__
+#include "drm_wait_netbsd.h" /* XXX */
+#endif
+
/**
* struct ttm_lock
*
@@ -69,7 +73,7 @@
struct ttm_lock {
struct ttm_base_object base;
- wait_queue_head_t queue;
+ drm_waitqueue_t queue;
spinlock_t lock;
int32_t rw;
uint32_t flags;
diff -r 0a2fc299c8b4 -r e63c17d95d9d sys/external/bsd/drm2/dist/drm/vmwgfx/ttm_object.c
--- a/sys/external/bsd/drm2/dist/drm/vmwgfx/ttm_object.c Thu Feb 17 00:54:51 2022 +0000
+++ b/sys/external/bsd/drm2/dist/drm/vmwgfx/ttm_object.c Thu Feb 17 01:21:02 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ttm_object.c,v 1.2 2021/12/18 23:45:45 riastradh Exp $ */
+/* $NetBSD: ttm_object.c,v 1.3 2022/02/17 01:21:02 riastradh Exp $ */
/* SPDX-License-Identifier: GPL-2.0 OR MIT */
/**************************************************************************
@@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ttm_object.c,v 1.2 2021/12/18 23:45:45 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ttm_object.c,v 1.3 2022/02/17 01:21:02 riastradh Exp $");
#define pr_fmt(fmt) "[TTM] " fmt
@@ -71,6 +71,8 @@
#include <linux/atomic.h>
#include "ttm_object.h"
+#include <linux/nbsd-namespace.h>
+
struct ttm_object_file {
struct ttm_object_device *tdev;
spinlock_t lock;
@@ -586,7 +588,19 @@
*/
static bool __must_check get_dma_buf_unless_doomed(struct dma_buf *dmabuf)
{
+#ifdef __NetBSD__
+ /* XXX move this to linux_dma_buf.c */
+ unsigned cnt;
+
+ do {
+ cnt = atomic_load_relaxed(&dmabuf->db_refcnt);
+ if (cnt == 0)
+ return false;
+ } while (atomic_cas_uint(&dmabuf->db_refcnt, cnt, cnt + 1) != cnt);
+ return true;
+#else
return atomic_long_inc_not_zero(&dmabuf->file->f_count) != 0L;
+#endif
}
/**
diff -r 0a2fc299c8b4 -r e63c17d95d9d sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_cmdbuf.c
--- a/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_cmdbuf.c Thu Feb 17 00:54:51 2022 +0000
+++ b/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_cmdbuf.c Thu Feb 17 01:21:02 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vmwgfx_cmdbuf.c,v 1.3 2021/12/18 23:45:45 riastradh Exp $ */
+/* $NetBSD: vmwgfx_cmdbuf.c,v 1.4 2022/02/17 01:21:02 riastradh Exp $ */
// SPDX-License-Identifier: GPL-2.0 OR MIT
/**************************************************************************
@@ -28,7 +28,7 @@
**************************************************************************/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vmwgfx_cmdbuf.c,v 1.3 2021/12/18 23:45:45 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vmwgfx_cmdbuf.c,v 1.4 2022/02/17 01:21:02 riastradh Exp $");
#include <linux/dmapool.h>
#include <linux/pci.h>
@@ -37,6 +37,8 @@
#include "vmwgfx_drv.h"
+#include <linux/nbsd-namespace.h>
+
/*
* Size of inline command buffers. Try to make sure that a page size is a
* multiple of the DMA pool allocation size.
diff -r 0a2fc299c8b4 -r e63c17d95d9d sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_drv.c
--- a/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_drv.c Thu Feb 17 00:54:51 2022 +0000
+++ b/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_drv.c Thu Feb 17 01:21:02 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vmwgfx_drv.c,v 1.4 2021/12/18 23:45:45 riastradh Exp $ */
+/* $NetBSD: vmwgfx_drv.c,v 1.5 2022/02/17 01:21:02 riastradh Exp $ */
// SPDX-License-Identifier: GPL-2.0 OR MIT
/**************************************************************************
@@ -28,7 +28,7 @@
**************************************************************************/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vmwgfx_drv.c,v 1.4 2021/12/18 23:45:45 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vmwgfx_drv.c,v 1.5 2022/02/17 01:21:02 riastradh Exp $");
#include <linux/console.h>
#include <linux/dma-mapping.h>
@@ -1430,6 +1430,14 @@
.patchlevel = VMWGFX_DRIVER_PATCHLEVEL
};
+#ifdef __NetBSD__
+
Home |
Main Index |
Thread Index |
Old Index