drm: Work around bus_space_read_8 on LP32.

This commit is contained in:
riastradh 2021-12-19 12:36:50 +00:00
parent ffec59cdef
commit b545a4ab1d
2 changed files with 49 additions and 3 deletions

View File

@ -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,8 +483,24 @@ u64 amdgpu_mm_rdoorbell64(struct amdgpu_device *adev, u32 index)
{
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
@ -508,8 +524,22 @@ void amdgpu_mm_wdoorbell64(struct amdgpu_device *adev, u32 index, u64 v)
{
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

View File

@ -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 uint32_t __raw_uncore_read32(const struct intel_uncore *uncore,
}
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_write32(const struct intel_uncore *uncore,
}
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