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 drm: Work around bus_spa...



details:   https://anonhg.NetBSD.org/src/rev/3e54e013e5d8
branches:  trunk
changeset: 1028972:3e54e013e5d8
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Dec 19 12:36:50 2021 +0000

description:
drm: Work around bus_space_read_8 on LP32.

diffstat:

 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_device.c |  34 ++++++++++++++-
 sys/external/bsd/drm2/dist/drm/i915/intel_uncore.h        |  18 +++++++-
 2 files changed, 49 insertions(+), 3 deletions(-)

diffs (109 lines):

diff -r 3339b78b32c4 -r 3e54e013e5d8 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_device.c
--- a/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_device.c Sun Dec 19 12:36:41 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_device.c Sun Dec 19 12:36:50 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: amdgpu_device.c,v 1.12 2021/12/19 12:36:41 riastradh Exp $     */
+/*     $NetBSD: amdgpu_device.c,v 1.13 2021/12/19 12:36:50 riastradh Exp $     */
 
 /*
  * Copyright 2008 Advanced Micro Devices, Inc.
@@ -28,7 +28,7 @@
  *          Jerome Glisse
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: amdgpu_device.c,v 1.12 2021/12/19 12:36:41 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amdgpu_device.c,v 1.13 2021/12/19 12:36:50 riastradh Exp $");
 
 #include <linux/power_supply.h>
 #include <linux/kthread.h>
@@ -483,9 +483,25 @@
 {
        if (index < adev->doorbell.num_doorbells) {
 #ifdef __NetBSD__
+#ifdef _LP64
                return bus_space_read_8(adev->doorbell.bst, adev->doorbell.bsh,
                    8*index);
 #else
+               uint64_t lo, hi;
+#if _BYTE_ORDER == _LITTLE_ENDIAN
+               lo = bus_space_read_4(adev->doorbell.bst, adev->doorbell.bsh,
+                   8*index);
+               hi = bus_space_read_4(adev->doorbell.bst, adev->doorbell.bsh,
+                   8*index + 4);
+#else
+               hi = bus_space_read_4(adev->doorbell.bst, adev->doorbell.bsh,
+                   8*index);
+               lo = bus_space_read_4(adev->doorbell.bst, adev->doorbell.bsh,
+                   8*index + 4);
+#endif
+               return lo | (hi << 32);
+#endif
+#else
                return atomic64_read((atomic64_t *)(adev->doorbell.ptr + index));
 #endif
        } else {
@@ -508,9 +524,23 @@
 {
        if (index < adev->doorbell.num_doorbells) {
 #ifdef __NetBSD__
+#ifdef _LP64
                bus_space_write_8(adev->doorbell.bst, adev->doorbell.bsh,
                    8*index, v);
 #else
+#if _BYTE_ORDER == _LITTLE_ENDIAN
+               bus_space_write_4(adev->doorbell.bst, adev->doorbell.bsh,
+                   8*index, v & 0xffffffffU);
+               bus_space_write_4(adev->doorbell.bst, adev->doorbell.bsh,
+                   8*index + 4, v >> 32);
+#else
+               bus_space_write_4(adev->doorbell.bst, adev->doorbell.bsh,
+                   8*index, v >> 32);
+               bus_space_write_4(adev->doorbell.bst, adev->doorbell.bsh,
+                   8*index + 4, v & 0xffffffffU);
+#endif
+#endif
+#else
                atomic64_set((atomic64_t *)(adev->doorbell.ptr + index), v);
 #endif
        } else {
diff -r 3339b78b32c4 -r 3e54e013e5d8 sys/external/bsd/drm2/dist/drm/i915/intel_uncore.h
--- a/sys/external/bsd/drm2/dist/drm/i915/intel_uncore.h        Sun Dec 19 12:36:41 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/intel_uncore.h        Sun Dec 19 12:36:50 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: intel_uncore.h,v 1.9 2021/12/19 12:32:15 riastradh Exp $       */
+/*     $NetBSD: intel_uncore.h,v 1.10 2021/12/19 12:36:50 riastradh Exp $      */
 
 /*
  * Copyright © 2017 Intel Corporation
@@ -321,7 +321,16 @@
 }
 static inline uint64_t __raw_uncore_read64(const struct intel_uncore *uncore,
                                                i915_reg_t reg) {
+#ifdef _LP64
        return bus_space_read_8(uncore->regs_bst, uncore->regs_bsh, i915_mmio_reg_offset(reg));
+#else
+       uint64_t lo, hi;
+       lo = bus_space_read_4(uncore->regs_bst, uncore->regs_bsh,
+           i915_mmio_reg_offset(reg));
+       hi = bus_space_read_4(uncore->regs_bst, uncore->regs_bsh,
+           i915_mmio_reg_offset(reg) + 4);
+       return lo | (hi << 32);
+#endif
 }
 static inline void __raw_uncore_write8(const struct intel_uncore *uncore,
                                                i915_reg_t reg, uint8_t val) {
@@ -337,7 +346,14 @@
 }
 static inline void __raw_uncore_write64(const struct intel_uncore *uncore,
                                                i915_reg_t reg, uint64_t val) {
+#ifdef _LP64
        bus_space_write_8(uncore->regs_bst, uncore->regs_bsh, i915_mmio_reg_offset(reg), val);
+#else
+       bus_space_write_4(uncore->regs_bst, uncore->regs_bsh,
+           i915_mmio_reg_offset(reg), val & 0xffffffffU);
+       bus_space_write_4(uncore->regs_bst, uncore->regs_bsh,
+           i915_mmio_reg_offset(reg) + 4, val >> 32);
+#endif
 }
 #endif
 



Home | Main Index | Thread Index | Old Index