Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/external/bsd i915: More progress.
details: https://anonhg.NetBSD.org/src/rev/5d504c456319
branches: trunk
changeset: 1028664:5d504c456319
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sun Dec 19 11:37:41 2021 +0000
description:
i915: More progress.
diffstat:
sys/external/bsd/common/include/linux/list.h | 18 ++++-
sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_object.c | 5 +-
sys/external/bsd/drm2/dist/drm/i915/i915_scheduler.c | 27 ++++++-
sys/external/bsd/drm2/dist/drm/i915/i915_utils.c | 8 +-
sys/external/bsd/drm2/dist/drm/i915/i915_vgpu.c | 59 ++++++++++----
sys/external/bsd/drm2/dist/drm/i915/i915_vma.c | 20 +++-
sys/external/bsd/drm2/dist/drm/i915/i915_vma.h | 6 +-
sys/external/bsd/drm2/i915drm/files.i915drmkms | 5 +-
sys/external/bsd/drm2/i915drm/i915_switcheroo.c | 43 ++++++++++
sys/external/bsd/drm2/i915drm/i915_sysfs.c | 6 +-
sys/external/bsd/drm2/include/linux/atomic.h | 19 ++++-
11 files changed, 176 insertions(+), 40 deletions(-)
diffs (truncated from 533 to 300 lines):
diff -r 868d991b9e92 -r 5d504c456319 sys/external/bsd/common/include/linux/list.h
--- a/sys/external/bsd/common/include/linux/list.h Sun Dec 19 11:37:29 2021 +0000
+++ b/sys/external/bsd/common/include/linux/list.h Sun Dec 19 11:37:41 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: list.h,v 1.29 2021/12/19 11:36:32 riastradh Exp $ */
+/* $NetBSD: list.h,v 1.30 2021/12/19 11:37:41 riastradh Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -132,6 +132,22 @@
}
static inline void
+list_add_rcu(struct list_head *node, struct list_head *head)
+{
+ struct list_head *next = head->next;
+
+ /* Initialize the new node first. */
+ node->next = next;
+ node->prev = head;
+
+ /* Now publish it. */
+ atomic_store_release(&head->next, node);
+
+ /* Fix up back pointers, not protected by RCU. */
+ next->prev = node;
+}
+
+static inline void
list_add_tail(struct list_head *node, struct list_head *head)
{
__list_add_between(head->prev, node, head);
diff -r 868d991b9e92 -r 5d504c456319 sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_object.c
--- a/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_object.c Sun Dec 19 11:37:29 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_object.c Sun Dec 19 11:37:41 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: i915_gem_object.c,v 1.4 2021/12/19 11:33:30 riastradh Exp $ */
+/* $NetBSD: i915_gem_object.c,v 1.5 2021/12/19 11:37:41 riastradh Exp $ */
/*
* Copyright © 2017 Intel Corporation
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i915_gem_object.c,v 1.4 2021/12/19 11:33:30 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_gem_object.c,v 1.5 2021/12/19 11:37:41 riastradh Exp $");
#include <linux/bitmap.h>
#include <linux/sched/mm.h>
@@ -65,6 +65,7 @@
spin_lock_init(&obj->vma.lock);
INIT_LIST_HEAD(&obj->vma.list);
+ i915_vma_tree_init(obj);
INIT_LIST_HEAD(&obj->mm.link);
diff -r 868d991b9e92 -r 5d504c456319 sys/external/bsd/drm2/dist/drm/i915/i915_scheduler.c
--- a/sys/external/bsd/drm2/dist/drm/i915/i915_scheduler.c Sun Dec 19 11:37:29 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/i915_scheduler.c Sun Dec 19 11:37:41 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: i915_scheduler.c,v 1.3 2021/12/19 11:37:05 riastradh Exp $ */
+/* $NetBSD: i915_scheduler.c,v 1.4 2021/12/19 11:37:41 riastradh Exp $ */
/*
* SPDX-License-Identifier: MIT
@@ -7,7 +7,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i915_scheduler.c,v 1.3 2021/12/19 11:37:05 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_scheduler.c,v 1.4 2021/12/19 11:37:41 riastradh Exp $");
#include <linux/mutex.h>
@@ -16,6 +16,8 @@
#include "i915_request.h"
#include "i915_scheduler.h"
+#include <linux/nbsd-namespace.h>
+
static struct i915_global_scheduler {
struct i915_global base;
struct kmem_cache *slab_dependencies;
@@ -62,7 +64,9 @@
rb_first(&execlists->queue.rb_root));
last_prio = (INT_MAX >> I915_USER_PRIORITY_SHIFT) + 1;
- for (rb = rb_first_cached(&execlists->queue); rb; rb = rb_next(rb)) {
+ for (rb = rb_first_cached(&execlists->queue);
+ rb;
+ rb = rb_next2(&execlists->queue.rb_root, rb)) {
const struct i915_priolist *p = to_priolist(rb);
GEM_BUG_ON(p->priority >= last_prio);
@@ -97,6 +101,15 @@
prio = I915_PRIORITY_NORMAL;
find_priolist:
+#ifdef __NetBSD__
+ /* XXX */
+ __USE(first);
+ __USE(parent);
+ __USE(rb);
+ p = rb_tree_find_node(&execlists->queue.rb_root.rbr_tree, &prio);
+ if (p)
+ goto out;
+#else
/* most positive priority is scheduled first, equal priorities fifo */
rb = NULL;
parent = &execlists->queue.rb_root.rb_node;
@@ -112,6 +125,7 @@
goto out;
}
}
+#endif
if (prio == I915_PRIORITY_NORMAL) {
p = &execlists->default_priolist;
@@ -137,8 +151,15 @@
p->priority = prio;
for (i = 0; i < ARRAY_SIZE(p->requests); i++)
INIT_LIST_HEAD(&p->requests[i]);
+#ifdef __NetBSD__
+ struct i915_priolist *collision __diagused;
+ collision = rb_tree_insert_node(&execlists->queue.rb_root.rbr_tree,
+ p);
+ KASSERT(collision == p);
+#else
rb_link_node(&p->node, rb, parent);
rb_insert_color_cached(&p->node, &execlists->queue, first);
+#endif
p->used = 0;
out:
diff -r 868d991b9e92 -r 5d504c456319 sys/external/bsd/drm2/dist/drm/i915/i915_utils.c
--- a/sys/external/bsd/drm2/dist/drm/i915/i915_utils.c Sun Dec 19 11:37:29 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/i915_utils.c Sun Dec 19 11:37:41 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: i915_utils.c,v 1.3 2021/12/19 01:24:26 riastradh Exp $ */
+/* $NetBSD: i915_utils.c,v 1.4 2021/12/19 11:37:41 riastradh Exp $ */
// SPDX-License-Identifier: MIT
/*
@@ -6,7 +6,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i915_utils.c,v 1.3 2021/12/19 01:24:26 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_utils.c,v 1.4 2021/12/19 11:37:41 riastradh Exp $");
#include <drm/drm_drv.h>
@@ -105,11 +105,15 @@
void cancel_timer(struct timer_list *t)
{
+#ifndef __NetBSD__
if (!READ_ONCE(t->expires))
return;
+#endif
del_timer(t);
+#ifndef __NetBSD__
WRITE_ONCE(t->expires, 0);
+#endif
}
void set_timer_ms(struct timer_list *t, unsigned long timeout)
diff -r 868d991b9e92 -r 5d504c456319 sys/external/bsd/drm2/dist/drm/i915/i915_vgpu.c
--- a/sys/external/bsd/drm2/dist/drm/i915/i915_vgpu.c Sun Dec 19 11:37:29 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/i915_vgpu.c Sun Dec 19 11:37:41 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: i915_vgpu.c,v 1.5 2021/12/18 23:45:28 riastradh Exp $ */
+/* $NetBSD: i915_vgpu.c,v 1.6 2021/12/19 11:37:41 riastradh Exp $ */
/*
* Copyright(c) 2011-2015 Intel Corporation. All rights reserved.
@@ -24,10 +24,12 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i915_vgpu.c,v 1.5 2021/12/18 23:45:28 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_vgpu.c,v 1.6 2021/12/19 11:37:41 riastradh Exp $");
#include "i915_vgpu.h"
+#include <linux/nbsd-namespace.h>
+
/**
* DOC: Intel GVT-g guest support
*
@@ -67,7 +69,14 @@
struct pci_dev *pdev = dev_priv->drm.pdev;
u64 magic;
u16 version_major;
+#ifdef __NetBSD__
+ bus_space_tag_t bst;
+ bus_space_handle_t bsh;
+ bus_size_t off = VGT_PVINFO_PAGE;
+ bus_size_t size = VGT_PVINFO_SIZE;
+#else
void __iomem *shared_area;
+#endif
BUILD_BUG_ON(sizeof(struct vgt_if) != VGT_PVINFO_SIZE);
@@ -80,31 +89,38 @@
if (INTEL_GEN(dev_priv) < 6)
return;
+#ifdef __NetBSD__
+ bst = pdev->pd_pa.pa_memt;
+ if (off > pdev->pd_resources[0].size ||
+ size > pdev->pd_resources[0].size - off ||
+ bus_space_map(bst, pdev->pd_resources[0].addr + off, size,
+ pdev->pd_resources[0].flags, &bsh)) {
+ DRM_ERROR("failed to map MMIO bar to check for VGT\n");
+ return;
+ }
+# ifdef _LP64
+ magic = bus_space_read_8(bst, bsh, (bus_size_t)vgtif_offset(magic));
+# else
+ magic = bus_space_read_4(bst, bsh, (bus_size_t)vgtif_offset(magic));
+ magic |= (uint64_t)bus_space_read_4(bst, bsh,
+ (bus_size_t)vgtif_offset(magic) + 4)
+ << 32;
+# endif
+#else
shared_area = pci_iomap_range(pdev, 0, VGT_PVINFO_PAGE, VGT_PVINFO_SIZE);
if (!shared_area) {
DRM_ERROR("failed to map MMIO bar to check for VGT\n");
return;
}
-
-#ifdef __NetBSD__
-# ifdef _LP64
- magic = bus_space_read_8(dev_priv->regs_bst, dev_priv->regs_bsh,
- vgtif_reg(magic));
-# else
- magic = bus_space_read_4(dev_priv->regs_bst, dev_priv->regs_bsh,
- vgtif_reg(magic));
- magic |= (uint64_t)bus_space_read_4(dev_priv->regs_bst,
- dev_priv->regs_bsh, vgtif_reg(magic) + 4) << 32;
-# endif
-#else
magic = readq(shared_area + vgtif_offset(magic));
#endif
+
if (magic != VGT_MAGIC)
goto out;
#ifdef __NetBSD__
- version_major = bus_space_read_2(dev_priv->regs_bst, dev_priv->regs_bsh,
- vgtif_reg(version_major));
+ version_major = bus_space_read_2(bst, bsh,
+ (bus_size_t)vgtif_offset(version_major));
#else
version_major = readw(shared_area + vgtif_offset(version_major));
#endif
@@ -113,14 +129,23 @@
goto out;
}
+#ifdef __NetBSD__
+ dev_priv->vgpu.caps = bus_space_read_4(bst, bsh,
+ (bus_size_t)vgtif_offset(vgt_caps));
+#else
dev_priv->vgpu.caps = readl(shared_area + vgtif_offset(vgt_caps));
+#endif
dev_priv->vgpu.active = true;
mutex_init(&dev_priv->vgpu.lock);
DRM_INFO("Virtual GPU for Intel GVT-g detected.\n");
out:
+#ifdef __NetBSD__
+ bus_space_unmap(bst, bsh, size);
+#else
pci_iounmap(pdev, shared_area);
+#endif
}
bool intel_vgpu_has_full_ppgtt(struct drm_i915_private *dev_priv)
@@ -145,7 +170,7 @@
if (!drm_mm_node_allocated(node))
return;
- DRM_DEBUG_DRIVER("deballoon space: range [0x%llx - 0x%llx] %llu KiB.\n",
+ DRM_DEBUG_DRIVER("deballoon space: range [0x%"PRIx64" - 0x%"PRIx64"] %"PRIu64" KiB.\n",
node->start,
node->start + node->size,
node->size / 1024);
diff -r 868d991b9e92 -r 5d504c456319 sys/external/bsd/drm2/dist/drm/i915/i915_vma.c
--- a/sys/external/bsd/drm2/dist/drm/i915/i915_vma.c Sun Dec 19 11:37:29 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/i915_vma.c Sun Dec 19 11:37:41 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: i915_vma.c,v 1.5 2021/12/19 01:44:57 riastradh Exp $ */
+/* $NetBSD: i915_vma.c,v 1.6 2021/12/19 11:37:41 riastradh Exp $ */
Home |
Main Index |
Thread Index |
Old Index