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/dist/drm/i915 Sync i915_gem_fault. Hac...
details: https://anonhg.NetBSD.org/src/rev/f790c14d6cb7
branches: trunk
changeset: 1027998:f790c14d6cb7
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sun Dec 19 01:34:08 2021 +0000
description:
Sync i915_gem_fault. Hack up the rest of i915_gem.c enough to build.
diffstat:
sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_object.c | 6 +-
sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_pages.c | 44 ++++++++++++++-
sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_phys.c | 14 ++++-
sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_shmem.c | 24 +++++++-
sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_wait.c | 15 ++++-
sys/external/bsd/drm2/dist/drm/i915/i915_gem.c | 8 ++-
sys/external/bsd/drm2/dist/drm/i915/i915_gem_fence_reg.h | 9 ++-
7 files changed, 107 insertions(+), 13 deletions(-)
diffs (truncated from 337 to 300 lines):
diff -r 29977642fa8e -r f790c14d6cb7 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 01:33:59 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_object.c Sun Dec 19 01:34:08 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: i915_gem_object.c,v 1.2 2021/12/18 23:45:30 riastradh Exp $ */
+/* $NetBSD: i915_gem_object.c,v 1.3 2021/12/19 01:34:08 riastradh Exp $ */
/*
* Copyright © 2017 Intel Corporation
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i915_gem_object.c,v 1.2 2021/12/18 23:45:30 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_gem_object.c,v 1.3 2021/12/19 01:34:08 riastradh Exp $");
#include <linux/sched/mm.h>
@@ -75,8 +75,10 @@
obj->ops = ops;
obj->mm.madv = I915_MADV_WILLNEED;
+#ifndef __NetBSD__
INIT_RADIX_TREE(&obj->mm.get_page.radix, GFP_KERNEL | __GFP_NOWARN);
mutex_init(&obj->mm.get_page.lock);
+#endif
}
/**
diff -r 29977642fa8e -r f790c14d6cb7 sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_pages.c
--- a/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_pages.c Sun Dec 19 01:33:59 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_pages.c Sun Dec 19 01:34:08 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: i915_gem_pages.c,v 1.3 2021/12/19 01:24:25 riastradh Exp $ */
+/* $NetBSD: i915_gem_pages.c,v 1.4 2021/12/19 01:34:08 riastradh Exp $ */
/*
* SPDX-License-Identifier: MIT
@@ -7,7 +7,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i915_gem_pages.c,v 1.3 2021/12/19 01:24:25 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_gem_pages.c,v 1.4 2021/12/19 01:34:08 riastradh Exp $");
#include "i915_drv.h"
#include "i915_gem_object.h"
@@ -421,6 +421,7 @@
}
}
+#ifndef __NetBSD__
struct scatterlist *
i915_gem_object_get_sg(struct drm_i915_gem_object *obj,
unsigned int n,
@@ -533,10 +534,35 @@
return sg;
}
+#endif
struct page *
i915_gem_object_get_page(struct drm_i915_gem_object *obj, unsigned int n)
{
+#ifdef __NetBSD__
+ struct vm_page *page;
+
+ if (obj->phys_handle) {
+ vaddr_t va = (vaddr_t)obj->phys_handle->vaddr;
+ paddr_t pa;
+ if (!pmap_extract(pmap_kernel(), va + n*PAGE_SIZE, &pa))
+ panic("i915 gem object phys-attached but not mapped:"
+ " obj=%p pgno=%d va=%p", obj, n,
+ obj->phys_handle->vaddr);
+ page = PHYS_TO_VM_PAGE(pa);
+ } else {
+ /*
+ * Pages must be pinned so that we need not hold the
+ * lock to prevent them from disappearing.
+ */
+ KASSERT(obj->mm.pages != NULL);
+ mutex_enter(obj->base.filp->vmobjlock);
+ page = uvm_pagelookup(obj->base.filp, ptoa(n));
+ mutex_exit(obj->base.filp->vmobjlock);
+ }
+ KASSERT(page != NULL);
+ return container_of(page, struct page, p_vmp);
+#else
struct scatterlist *sg;
unsigned int offset;
@@ -544,6 +570,7 @@
sg = i915_gem_object_get_sg(obj, n, &offset);
return nth_page(sg_page(sg), offset);
+#endif
}
/* Like i915_gem_object_get_page(), but mark the returned page dirty */
@@ -565,6 +592,18 @@
unsigned long n,
unsigned int *len)
{
+#ifdef __NetBSD__
+ bus_addr_t poff = (bus_addr_t)n << PAGE_SHIFT;
+ unsigned seg;
+
+ for (seg = 0; seg < obj->mm.pages->dm_nsegs; seg++) {
+ if (poff <= obj->mm.pages->dm_segs[seg].ds_len)
+ return obj->mm.pages->dm_segs[seg].ds_addr + poff;
+ poff -= obj->mm.pages->dm_segs[seg].ds_len;
+ }
+ KASSERT(0);
+ return 0;
+#else
struct scatterlist *sg;
unsigned int offset;
@@ -574,6 +613,7 @@
*len = sg_dma_len(sg) - (offset << PAGE_SHIFT);
return sg_dma_address(sg) + (offset << PAGE_SHIFT);
+#endif
}
dma_addr_t
diff -r 29977642fa8e -r f790c14d6cb7 sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_phys.c
--- a/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_phys.c Sun Dec 19 01:33:59 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_phys.c Sun Dec 19 01:34:08 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: i915_gem_phys.c,v 1.2 2021/12/18 23:45:30 riastradh Exp $ */
+/* $NetBSD: i915_gem_phys.c,v 1.3 2021/12/19 01:34:08 riastradh Exp $ */
/*
* SPDX-License-Identifier: MIT
@@ -7,7 +7,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i915_gem_phys.c,v 1.2 2021/12/18 23:45:30 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_gem_phys.c,v 1.3 2021/12/19 01:34:08 riastradh Exp $");
#include <linux/highmem.h>
#include <linux/shmem_fs.h>
@@ -155,7 +155,11 @@
int i915_gem_object_attach_phys(struct drm_i915_gem_object *obj, int align)
{
+#ifdef __NetBSD__
+ bus_dmamap_t pages;
+#else
struct sg_table *pages;
+#endif
int err;
if (align > obj->base.size)
@@ -209,7 +213,13 @@
err_xfer:
obj->ops = &i915_gem_shmem_ops;
if (!IS_ERR_OR_NULL(pages)) {
+#ifdef __NetBSD__
+ unsigned int sg_page_sizes = 0, seg;
+ for (seg = 0; seg < pages->dm_nsegs; seg++)
+ sg_page_sizes |= pages->dm_segs[seg].ds_len;
+#else
unsigned int sg_page_sizes = i915_sg_page_sizes(pages->sgl);
+#endif
__i915_gem_object_set_pages(obj, pages, sg_page_sizes);
}
diff -r 29977642fa8e -r f790c14d6cb7 sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_shmem.c
--- a/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_shmem.c Sun Dec 19 01:33:59 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_shmem.c Sun Dec 19 01:34:08 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: i915_gem_shmem.c,v 1.3 2021/12/19 01:24:25 riastradh Exp $ */
+/* $NetBSD: i915_gem_shmem.c,v 1.4 2021/12/19 01:34:08 riastradh Exp $ */
/*
* SPDX-License-Identifier: MIT
@@ -7,7 +7,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i915_gem_shmem.c,v 1.3 2021/12/19 01:24:25 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_gem_shmem.c,v 1.4 2021/12/19 01:34:08 riastradh Exp $");
#include <linux/pagevec.h>
#include <linux/swap.h>
@@ -557,8 +557,19 @@
const void *data, resource_size_t size)
{
struct drm_i915_gem_object *obj;
+#ifdef __NetBSD__
+ struct iovec iov = { .iov_base = __UNCONST(data), .iov_len = size };
+ struct uio uio = {
+ .uio_iov = &iov,
+ .uio_iovcnt = 1,
+ .uio_offset = 0,
+ .uio_resid = size,
+ .uio_rw = UIO_WRITE,
+ };
+#else
struct file *file;
resource_size_t offset;
+#endif
int err;
obj = i915_gem_object_create_shmem(dev_priv, round_up(size, PAGE_SIZE));
@@ -567,6 +578,14 @@
GEM_BUG_ON(obj->write_domain != I915_GEM_DOMAIN_CPU);
+#ifdef __NetBSD__
+ UIO_SETUP_SYSSPACE(&uio);
+ /* XXX errno NetBSD->Linux */
+ err = -ubc_uiomove(obj->base.filp, &uio, size, UVM_ADV_NORMAL,
+ UBC_WRITE);
+ if (err)
+ goto fail;
+#else
file = obj->base.filp;
offset = 0;
do {
@@ -594,6 +613,7 @@
data += len;
offset += len;
} while (size);
+#endif
return obj;
diff -r 29977642fa8e -r f790c14d6cb7 sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_wait.c
--- a/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_wait.c Sun Dec 19 01:33:59 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_wait.c Sun Dec 19 01:34:08 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: i915_gem_wait.c,v 1.2 2021/12/18 23:45:30 riastradh Exp $ */
+/* $NetBSD: i915_gem_wait.c,v 1.3 2021/12/19 01:34:08 riastradh Exp $ */
/*
* SPDX-License-Identifier: MIT
@@ -7,7 +7,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i915_gem_wait.c,v 1.2 2021/12/18 23:45:30 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_gem_wait.c,v 1.3 2021/12/19 01:34:08 riastradh Exp $");
#include <linux/dma-fence-array.h>
#include <linux/jiffies.h>
@@ -103,6 +103,9 @@
{
struct i915_request *rq;
struct intel_engine_cs *engine;
+#ifdef __NetBSD__
+ int s;
+#endif
if (dma_fence_is_signaled(fence) || !dma_fence_is_i915(fence))
return;
@@ -110,12 +113,20 @@
rq = to_request(fence);
engine = rq->engine;
+#ifdef __NetBSD__
+ s = splsoftserial();
+#else
local_bh_disable();
+#endif
rcu_read_lock(); /* RCU serialisation for set-wedged protection */
if (engine->schedule)
engine->schedule(rq, attr);
rcu_read_unlock();
+#ifdef __NetBSD__
+ splx(s);
+#else
local_bh_enable(); /* kick the tasklets if queues were reprioritised */
+#endif
}
static void fence_set_priority(struct dma_fence *fence,
diff -r 29977642fa8e -r f790c14d6cb7 sys/external/bsd/drm2/dist/drm/i915/i915_gem.c
--- a/sys/external/bsd/drm2/dist/drm/i915/i915_gem.c Sun Dec 19 01:33:59 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/i915_gem.c Sun Dec 19 01:34:08 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: i915_gem.c,v 1.63 2021/12/19 01:24:25 riastradh Exp $ */
+/* $NetBSD: i915_gem.c,v 1.64 2021/12/19 01:34:08 riastradh Exp $ */
/*
* Copyright © 2008-2015 Intel Corporation
@@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i915_gem.c,v 1.63 2021/12/19 01:24:25 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_gem.c,v 1.64 2021/12/19 01:34:08 riastradh Exp $");
#ifdef __NetBSD__
#if 0 /* XXX uvmhist option? */
@@ -283,7 +283,11 @@
}
Home |
Main Index |
Thread Index |
Old Index