Module Name:    src
Committed By:   riastradh
Date:           Sun Dec 19 12:27:32 UTC 2021

Modified Files:
        src/sys/external/bsd/drm2/dist/drm/i915/gt: gen6_ppgtt.c

Log Message:
i915: Fix gen6 pd_vma_bind.

We only need space for the ppgtt in this vma, not space for the whole
VM.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 \
    src/sys/external/bsd/drm2/dist/drm/i915/gt/gen6_ppgtt.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/gt/gen6_ppgtt.c
diff -u src/sys/external/bsd/drm2/dist/drm/i915/gt/gen6_ppgtt.c:1.7 src/sys/external/bsd/drm2/dist/drm/i915/gt/gen6_ppgtt.c:1.8
--- src/sys/external/bsd/drm2/dist/drm/i915/gt/gen6_ppgtt.c:1.7	Sun Dec 19 12:27:25 2021
+++ src/sys/external/bsd/drm2/dist/drm/i915/gt/gen6_ppgtt.c	Sun Dec 19 12:27:32 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: gen6_ppgtt.c,v 1.7 2021/12/19 12:27:25 riastradh Exp $	*/
+/*	$NetBSD: gen6_ppgtt.c,v 1.8 2021/12/19 12:27:32 riastradh Exp $	*/
 
 // SPDX-License-Identifier: MIT
 /*
@@ -6,7 +6,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gen6_ppgtt.c,v 1.7 2021/12/19 12:27:25 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gen6_ppgtt.c,v 1.8 2021/12/19 12:27:32 riastradh Exp $");
 
 #include <linux/log2.h>
 
@@ -347,23 +347,23 @@ static int pd_vma_bind(struct i915_vma *
 	px_base(ppgtt->base.pd)->ggtt_offset = ggtt_offset * sizeof(gen6_pte_t);
 #ifdef __NetBSD__
     {
-	bus_size_t vm_nbytes = ggtt->vm.total;
-	bus_size_t vm_npgs = vm_nbytes >> PAGE_SHIFT;
-	bus_size_t gtt_nbytes = vm_npgs * sizeof(gen6_pte_t);
+	bus_size_t npgs = vma->size >> PAGE_SHIFT;
+	bus_size_t gtt_nbytes = npgs * sizeof(gen6_pte_t);
 	bus_size_t ggtt_offset_bytes =
 	    (bus_size_t)ggtt_offset * sizeof(gen6_pte_t);
 	int ret;
 
 	KASSERTMSG(gtt_nbytes <= ggtt->gsmsz - ggtt_offset_bytes,
-	    "oversize ggtt vm total 0x%"PRIx64" bytes 0x%"PRIx64" pgs,"
+	    "oversize ppgtt size 0x%"PRIx64" bytes 0x%"PRIx64" pgs,"
 	    " requiring 0x%"PRIx64" bytes of ptes at 0x%"PRIx64";"
-	    " gsm has 0x%"PRIx64" bytes total with only 0x%"PRIx64" for ptes",
-	    vm_nbytes, vm_npgs,
-	    gtt_nbytes, ggtt_offset_bytes,
-	    ggtt->gsmsz, ggtt->gsmsz - ggtt_offset_bytes);
+	    " gsm has 0x%"PRIx64" bytes total"
+	    " with only 0x%"PRIx64" for ptes",
+	    (uint64_t)vma->size, (uint64_t)npgs,
+	    (uint64_t)gtt_nbytes, (uint64_t)ggtt_offset_bytes,
+	    (uint64_t)ggtt->gsmsz,
+	    (uint64_t)(ggtt->gsmsz - ggtt_offset_bytes));
 	ret = -bus_space_subregion(ggtt->gsmt, ggtt->gsmh, ggtt_offset_bytes,
-	    MIN(gtt_nbytes, ggtt->gsmsz - ggtt_offset_bytes),
-	    &ppgtt->pd_bsh);
+	    gtt_nbytes, &ppgtt->pd_bsh);
 	if (ret) {
 		DRM_ERROR("Unable to subregion the GGTT: %d\n", ret);
 		return ret;

Reply via email to