Module Name: src
Committed By: riastradh
Date: Sun Jun 23 13:01:44 UTC 2024
Modified Files:
src/sys/external/bsd/drm2/dist/drm/i915/gem: i915_gem_mman.c
Log Message:
Revert "i915: Reduce diff in fault routine."
Evidently this had more side effects than I thought:
warning: ../../../../external/bsd/drm2/dist/drm/i915/intel_uncore.c:1197:
Unclaimed read from register 0x61204
...
{drm:netbsd:wait_panel_status+0x74} *ERROR* PPS state mismatch
...
warning: ../../../../external/bsd/drm2/dist/drm/i915/display/intel_dp.c:1175:
eDP powered off while attempting aux channel communication.
...
warning: ../../../../external/bsd/drm2/dist/drm/i915/display/intel_dp.c:5616:
Missing case (((&(dev_priv)->__info)->gen) == 9)
So let's roll it back until I have a better understanding of what
changed.
Between making the change and writing the commit message, I forgot
that the change affected the errno values returned by the fault
routine, which may affect how uvm handles the fault failure --
whether to retry, wait for memory and retry, or fail, or what.
Perhaps that explains the issue.
To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 \
src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_mman.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_mman.c
diff -u src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_mman.c:1.24 src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_mman.c:1.25
--- src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_mman.c:1.24 Sun Jun 23 00:53:16 2024
+++ src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_mman.c Sun Jun 23 13:01:44 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: i915_gem_mman.c,v 1.24 2024/06/23 00:53:16 riastradh Exp $ */
+/* $NetBSD: i915_gem_mman.c,v 1.25 2024/06/23 13:01:44 riastradh Exp $ */
/*
* SPDX-License-Identifier: MIT
@@ -7,7 +7,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i915_gem_mman.c,v 1.24 2024/06/23 00:53:16 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_gem_mman.c,v 1.25 2024/06/23 13:01:44 riastradh Exp $");
#include <linux/anon_inodes.h>
#include <linux/mman.h>
@@ -252,14 +252,14 @@ compute_partial_view(const struct drm_i9
*/
int pmap_enter_default(pmap_t, vaddr_t, paddr_t, vm_prot_t, unsigned);
#define pmap_enter pmap_enter_default
-#endif
-#ifdef __NetBSD__
static int
i915_error_to_vmf_fault(int err)
+{
+ return err;
+}
#else
static vm_fault_t i915_error_to_vmf_fault(int err)
-#endif
{
switch (err) {
default:
@@ -269,19 +269,11 @@ static vm_fault_t i915_error_to_vmf_faul
case -EFAULT: /* purged object */
case -ENODEV: /* bad object, how did you get here! */
case -ENXIO: /* unable to access backing store (on device) */
-#ifdef __NetBSD__
- return EINVAL; /* SIGBUS */
-#else
return VM_FAULT_SIGBUS;
-#endif
case -ENOSPC: /* shmemfs allocation failure */
case -ENOMEM: /* our allocation failure */
-#ifdef __NetBSD__
- return ENOMEM;
-#else
return VM_FAULT_OOM;
-#endif
case 0:
case -EAGAIN:
@@ -292,13 +284,10 @@ static vm_fault_t i915_error_to_vmf_faul
* EBUSY is ok: this just means that another thread
* already did the job.
*/
-#ifdef __NetBSD__
- return 0; /* retry access in userland */
-#else
return VM_FAULT_NOPAGE;
-#endif
}
}
+#endif
#ifdef __NetBSD__
static int
@@ -324,7 +313,7 @@ static vm_fault_t vm_fault_cpu(struct vm
/* Sanity check that we allow writing into this object */
if (unlikely(i915_gem_object_is_readonly(obj) && write))
#ifdef __NetBSD__
- return EINVAL; /* SIGBUS */
+ return -EFAULT;
#else
return VM_FAULT_SIGBUS;
#endif
@@ -431,7 +420,7 @@ static vm_fault_t vm_fault_gtt(struct vm
/* Sanity check that we allow writing into this object */
if (i915_gem_object_is_readonly(obj) && write)
#ifdef __NetBSD__
- return EINVAL; /* SIGBUS */
+ return -EFAULT;
#else
return VM_FAULT_SIGBUS;
#endif
@@ -576,6 +565,7 @@ i915_gem_fault(struct uvm_faultinfo *ufi
struct i915_mmap_offset *mmo =
container_of(uobj, struct i915_mmap_offset, uobj);
struct drm_i915_gem_object *obj = mmo->obj;
+ bool pinned = false;
int error;
KASSERT(rw_lock_held(obj->base.filp->vmobjlock));
@@ -595,15 +585,22 @@ i915_gem_fault(struct uvm_faultinfo *ufi
*/
rw_exit(obj->base.filp->vmobjlock);
+ /* XXX errno Linux->NetBSD */
+ error = -i915_gem_object_pin_pages(obj);
+ if (error)
+ goto out;
+ pinned = true;
+
switch (mmo->mmap_type) {
case I915_MMAP_TYPE_WC:
case I915_MMAP_TYPE_WB:
case I915_MMAP_TYPE_UC:
- error = vm_fault_cpu(ufi, mmo, vaddr, pps, npages, centeridx,
+ /* XXX errno Linux->NetBSD */
+ error = -vm_fault_cpu(ufi, mmo, vaddr, pps, npages, centeridx,
flags);
break;
case I915_MMAP_TYPE_GTT:
- error = vm_fault_gtt(ufi, mmo, vaddr, pps, npages, centeridx,
+ error = -vm_fault_gtt(ufi, mmo, vaddr, pps, npages, centeridx,
flags);
break;
default:
@@ -611,7 +608,19 @@ i915_gem_fault(struct uvm_faultinfo *ufi
mmo->mmap_type);
}
+out: if (pinned)
+ i915_gem_object_unpin_pages(obj);
uvmfault_unlockall(ufi, ufi->entry->aref.ar_amap, NULL);
+
+ /*
+ * Remap EINTR to success, so that we return to userland.
+ * On the way out, we'll deliver the signal, and if the signal
+ * is not fatal then the user code which faulted will most likely
+ * fault again, and we'll come back here for another try.
+ */
+ if (error == EINTR)
+ error = 0;
+
return error;
}