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/gt i915: Spruce up asser...



details:   https://anonhg.NetBSD.org/src/rev/b4033a6678a4
branches:  trunk
changeset: 1028909:b4033a6678a4
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Dec 19 12:27:25 2021 +0000

description:
i915: Spruce up assertion in gen6_ppgtt.c pd_vma_bind.

diffstat:

 sys/external/bsd/drm2/dist/drm/i915/gt/gen6_ppgtt.c |  33 +++++++++++---------
 1 files changed, 18 insertions(+), 15 deletions(-)

diffs (60 lines):

diff -r 2615930a8e42 -r b4033a6678a4 sys/external/bsd/drm2/dist/drm/i915/gt/gen6_ppgtt.c
--- a/sys/external/bsd/drm2/dist/drm/i915/gt/gen6_ppgtt.c       Sun Dec 19 12:27:17 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/gt/gen6_ppgtt.c       Sun Dec 19 12:27:25 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gen6_ppgtt.c,v 1.6 2021/12/19 12:07:47 riastradh Exp $ */
+/*     $NetBSD: gen6_ppgtt.c,v 1.7 2021/12/19 12:27:25 riastradh Exp $ */
 
 // SPDX-License-Identifier: MIT
 /*
@@ -6,7 +6,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gen6_ppgtt.c,v 1.6 2021/12/19 12:07:47 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gen6_ppgtt.c,v 1.7 2021/12/19 12:27:25 riastradh Exp $");
 
 #include <linux/log2.h>
 
@@ -347,25 +347,28 @@
        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 ggtt_offset_bytes =
+           (bus_size_t)ggtt_offset * sizeof(gen6_pte_t);
        int ret;
-       ppgtt->pd_bst = ggtt->gsmt;
-       KASSERTMSG((sizeof(gen6_pte_t) * (ggtt->vm.total >> PAGE_SHIFT) <=
-               ggtt->gsmsz - (sizeof(gen6_pte_t) * ggtt_offset)),
-           "oversize ggtt vm total %"PRIx64
-           " requiring %"PRIx64" bytes of ptes,"
-           " gsm has %"PRIx64" bytes for ptes",
-           ggtt->vm.total,
-           sizeof(gen6_pte_t) * (ggtt->vm.total >> PAGE_SHIFT),
-           ggtt->gsmsz - (sizeof(gen6_pte_t) * ggtt_offset));
-       ret = -bus_space_subregion(ggtt->gsmt, ggtt->gsmh,
-           sizeof(gen6_pte_t) * ggtt_offset,
-           MIN(sizeof(gen6_pte_t) * (ggtt->vm.total >> PAGE_SHIFT),
-               ggtt->gsmsz - (sizeof(gen6_pte_t) * ggtt_offset)),
+
+       KASSERTMSG(gtt_nbytes <= ggtt->gsmsz - ggtt_offset_bytes,
+           "oversize ggtt vm total 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);
+       ret = -bus_space_subregion(ggtt->gsmt, ggtt->gsmh, ggtt_offset_bytes,
+           MIN(gtt_nbytes, ggtt->gsmsz - ggtt_offset_bytes),
            &ppgtt->pd_bsh);
        if (ret) {
                DRM_ERROR("Unable to subregion the GGTT: %d\n", ret);
                return ret;
        }
+       ppgtt->pd_bst = ggtt->gsmt;
     }
 #else
        ppgtt->pd_addr = (gen6_pte_t __iomem *)ggtt->gsm + ggtt_offset;



Home | Main Index | Thread Index | Old Index