diff options
author | 2020-06-08 04:47:57 +0000 | |
---|---|---|
committer | 2020-06-08 04:47:57 +0000 | |
commit | c349dbc7938c71a30e13c1be4acc1976165f4630 (patch) | |
tree | 8798187dfd7a927a15123e8dad31b782b074baa8 /sys/dev/pci/drm/include/linux | |
parent | The errcheck() function treats an errno of ERANGE or EDOM as something (diff) | |
download | wireguard-openbsd-c349dbc7938c71a30e13c1be4acc1976165f4630.tar.xz wireguard-openbsd-c349dbc7938c71a30e13c1be4acc1976165f4630.zip |
update drm to linux 5.7
adds kernel support for
amdgpu: vega20, raven2, renoir, navi10, navi14
inteldrm: icelake, tigerlake
Thanks to the OpenBSD Foundation for sponsoring this work, kettenis@ for
helping, patrick@ for helping adapt rockchip drm and many developers for
testing.
Diffstat (limited to 'sys/dev/pci/drm/include/linux')
125 files changed, 1424 insertions, 203 deletions
diff --git a/sys/dev/pci/drm/include/linux/agp_backend.h b/sys/dev/pci/drm/include/linux/agp_backend.h index 452d8e92834..c3f937853a9 100644 --- a/sys/dev/pci/drm/include/linux/agp_backend.h +++ b/sys/dev/pci/drm/include/linux/agp_backend.h @@ -10,4 +10,6 @@ #define AGP_USER_CACHED_MEMORY BUS_DMA_COHERENT #endif +struct drm_agp_head; + #endif diff --git a/sys/dev/pci/drm/include/linux/ascii85.h b/sys/dev/pci/drm/include/linux/ascii85.h new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/dev/pci/drm/include/linux/ascii85.h diff --git a/sys/dev/pci/drm/include/linux/atomic.h b/sys/dev/pci/drm/include/linux/atomic.h index 5e23da1490e..bb43b294c4c 100644 --- a/sys/dev/pci/drm/include/linux/atomic.h +++ b/sys/dev/pci/drm/include/linux/atomic.h @@ -1,4 +1,4 @@ -/* $OpenBSD: atomic.h,v 1.5 2019/08/17 06:07:22 jsg Exp $ */ +/* $OpenBSD: atomic.h,v 1.6 2020/06/08 04:48:14 jsg Exp $ */ /** * \file drm_atomic.h * Atomic operations used in the DRM which may or may not be provided by the OS. @@ -36,8 +36,10 @@ #include <sys/types.h> #include <sys/mutex.h> #include <machine/intr.h> -#include <machine/atomic.h> #include <linux/types.h> +#include <linux/compiler.h> /* via x86/include/asm/atomic.h */ + +#define ATOMIC_INIT(x) (x) #define atomic_set(p, v) (*(p) = (v)) #define atomic_read(p) (*(p)) @@ -45,17 +47,34 @@ #define atomic_dec(p) __sync_fetch_and_sub(p, 1) #define atomic_add(n, p) __sync_fetch_and_add(p, n) #define atomic_sub(n, p) __sync_fetch_and_sub(p, n) +#define atomic_and(n, p) __sync_fetch_and_and(p, n) +#define atomic_or(n, p) atomic_setbits_int(p, n) #define atomic_add_return(n, p) __sync_add_and_fetch(p, n) #define atomic_sub_return(n, p) __sync_sub_and_fetch(p, n) #define atomic_inc_return(v) atomic_add_return(1, (v)) #define atomic_dec_return(v) atomic_sub_return(1, (v)) #define atomic_dec_and_test(v) (atomic_dec_return(v) == 0) #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0) -#define atomic_or(n, p) atomic_setbits_int(p, n) #define atomic_cmpxchg(p, o, n) __sync_val_compare_and_swap(p, o, n) #define cmpxchg(p, o, n) __sync_val_compare_and_swap(p, o, n) #define atomic_set_release(p, v) atomic_set((p), (v)) +#define try_cmpxchg(p, op, n) \ +({ \ + __typeof(p) __op = (__typeof((p)))(op); \ + __typeof(*(p)) __o = *__op; \ + __typeof(*(p)) __p = __sync_val_compare_and_swap((p), (__o), (n)); \ + if (__p != __o) \ + *__op = __p; \ + (__p == __o); \ +}) + +static inline bool +atomic_try_cmpxchg(volatile int *p, int *op, int n) +{ + return try_cmpxchg(p, op, n); +} + static inline int atomic_xchg(volatile int *v, int n) { @@ -99,6 +118,8 @@ atomic_dec_if_positive(volatile int *v) #ifdef __LP64__ typedef int64_t atomic64_t; +#define ATOMIC64_INIT(x) (x) + #define atomic64_set(p, v) (*(p) = (v)) #define atomic64_read(p) (*(p)) @@ -122,6 +143,8 @@ typedef struct { struct mutex lock; } atomic64_t; +#define ATOMIC64_INIT(x) { (x), .lock = MUTEX_INITIALIZER(IPL_HIGH) } + static inline void atomic64_set(atomic64_t *v, int64_t i) { @@ -236,6 +259,13 @@ clear_bit(u_int b, volatile void *p) } static inline void +clear_bit_unlock(u_int b, volatile void *p) +{ + membar_enter(); + clear_bit(b, p); +} + +static inline void set_bit(u_int b, volatile void *p) { atomic_set_int(((volatile u_int *)p) + (b >> 5), 1 << (b & 0x1f)); diff --git a/sys/dev/pci/drm/include/linux/average.h b/sys/dev/pci/drm/include/linux/average.h new file mode 100644 index 00000000000..d78c65b78b4 --- /dev/null +++ b/sys/dev/pci/drm/include/linux/average.h @@ -0,0 +1,38 @@ +/* Public domain. */ + +#ifndef _LINUX_AVERAGE_H +#define _LINUX_AVERAGE_H + +#include <sys/types.h> +#include <lib/libkern/libkern.h> + +#define DECLARE_EWMA(name, precision, recip) \ +struct ewma_##name { \ + u_long value; \ +}; \ + \ +static inline void \ +ewma_##name##_init(struct ewma_##name *p) \ +{ \ + p->value = 0; \ +} \ + \ +static inline void \ +ewma_##name##_add(struct ewma_##name *p, u_long value) \ +{ \ + u_long shift = fls(recip) - 1; \ + \ + if (p->value == 0) \ + p->value = (value << (precision)); \ + else \ + p->value = ((((p->value << shift) - p->value) + \ + (value << (precision))) >> shift); \ +} \ + \ +static inline u_long \ +ewma_##name##_read(struct ewma_##name *p) \ +{ \ + return (p->value >> (precision)); \ +} + +#endif diff --git a/sys/dev/pci/drm/include/linux/backlight.h b/sys/dev/pci/drm/include/linux/backlight.h index fa559dbe047..cfcec3220e9 100644 --- a/sys/dev/pci/drm/include/linux/backlight.h +++ b/sys/dev/pci/drm/include/linux/backlight.h @@ -54,4 +54,9 @@ backlight_force_update(struct backlight_device *bd, int reason) void backlight_schedule_update_status(struct backlight_device *); +int backlight_enable(struct backlight_device *); +int backlight_disable(struct backlight_device *); + +#define devm_of_find_backlight(x) NULL + #endif diff --git a/sys/dev/pci/drm/include/linux/bitfield.h b/sys/dev/pci/drm/include/linux/bitfield.h new file mode 100644 index 00000000000..909ddaa8bac --- /dev/null +++ b/sys/dev/pci/drm/include/linux/bitfield.h @@ -0,0 +1,16 @@ +/* Public domain. */ + +#ifndef _LINUX_BITFIELD_H +#define _LINUX_BITFIELD_H + +#include <asm/byteorder.h> + +#define __bf_shf(x) (__builtin_ffsll(x) - 1) + +#define FIELD_GET(_m, _v) \ + ((typeof(_m))(((_v) & (_m)) >> __bf_shf(_m))) + +#define FIELD_PREP(_m, _v) \ + (((typeof(_m))(_v) << __bf_shf(_m)) & (_m)) + +#endif diff --git a/sys/dev/pci/drm/include/linux/bitmap.h b/sys/dev/pci/drm/include/linux/bitmap.h index dc2055db5d2..c3160639a75 100644 --- a/sys/dev/pci/drm/include/linux/bitmap.h +++ b/sys/dev/pci/drm/include/linux/bitmap.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bitmap.h,v 1.2 2019/07/11 04:26:37 jsg Exp $ */ +/* $OpenBSD: bitmap.h,v 1.3 2020/06/08 04:48:14 jsg Exp $ */ /* * Copyright (c) 2013, 2014, 2015 Mark Kettenis * @@ -64,6 +64,18 @@ bitmap_or(void *d, void *s1, void *s2, u_int n) } static inline void +bitmap_andnot(void *d, void *s1, void *s2, u_int n) +{ + u_int *dst = d; + u_int *src1 = s1; + u_int *src2 = s2; + u_int b; + + for (b = 0; b < n; b += 32) + dst[b >> 5] = src1[b >> 5] & ~src2[b >> 5]; +} + +static inline void bitmap_complement(void *d, void *s, u_int n) { u_int *dst = d; @@ -74,6 +86,17 @@ bitmap_complement(void *d, void *s, u_int n) dst[b >> 5] = ~src[b >> 5]; } +static inline void +bitmap_copy(void *d, void *s, u_int n) +{ + u_int *dst = d; + u_int *src = s; + u_int b; + + for (b = 0; b < n; b += 32) + dst[b >> 5] = src[b >> 5]; +} + static inline int bitmap_weight(void *p, u_int n) { @@ -86,4 +109,7 @@ bitmap_weight(void *p, u_int n) return sum; } +void *bitmap_zalloc(u_int, gfp_t); +void bitmap_free(void *); + #endif diff --git a/sys/dev/pci/drm/include/linux/bitops.h b/sys/dev/pci/drm/include/linux/bitops.h index 73317e1791b..72bf3b79590 100644 --- a/sys/dev/pci/drm/include/linux/bitops.h +++ b/sys/dev/pci/drm/include/linux/bitops.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bitops.h,v 1.2 2019/11/24 02:29:43 jsg Exp $ */ +/* $OpenBSD: bitops.h,v 1.3 2020/06/08 04:48:14 jsg Exp $ */ /* * Copyright (c) 2013, 2014, 2015 Mark Kettenis * @@ -25,13 +25,19 @@ #define BIT(x) (1UL << (x)) #define BIT_ULL(x) (1ULL << (x)) +#define BIT_MASK(x) (1UL << ((x) % BITS_PER_LONG)) #define BITS_PER_BYTE 8 #define GENMASK(h, l) (((~0UL) >> (BITS_PER_LONG - (h) - 1)) & ((~0UL) << (l))) #define GENMASK_ULL(h, l) (((~0ULL) >> (BITS_PER_LONG_LONG - (h) - 1)) & ((~0ULL) << (l))) +#define BITS_PER_TYPE(x) (8 * sizeof(x)) #define BITS_TO_LONGS(x) howmany((x), 8 * sizeof(long)) +/* despite the name these are really ctz */ +#define __ffs(x) __builtin_ctzl(x) +#define __ffs64(x) __builtin_ctzll(x) + static inline uint8_t hweight8(uint32_t x) { diff --git a/sys/dev/pci/drm/include/linux/bits.h b/sys/dev/pci/drm/include/linux/bits.h new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/dev/pci/drm/include/linux/bits.h diff --git a/sys/dev/pci/drm/include/linux/bottom_half.h b/sys/dev/pci/drm/include/linux/bottom_half.h index 1261bf12fe1..9d13c06ac56 100644 --- a/sys/dev/pci/drm/include/linux/bottom_half.h +++ b/sys/dev/pci/drm/include/linux/bottom_half.h @@ -3,6 +3,8 @@ #ifndef _LINUX_BOTTOM_HALF_H #define _LINUX_BOTTOM_HALF_H +#include <linux/preempt.h> + #define local_bh_disable() #define local_bh_enable() diff --git a/sys/dev/pci/drm/include/linux/build_bug.h b/sys/dev/pci/drm/include/linux/build_bug.h new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/dev/pci/drm/include/linux/build_bug.h diff --git a/sys/dev/pci/drm/include/linux/byteorder/generic.h b/sys/dev/pci/drm/include/linux/byteorder/generic.h new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/dev/pci/drm/include/linux/byteorder/generic.h diff --git a/sys/dev/pci/drm/include/linux/compiler.h b/sys/dev/pci/drm/include/linux/compiler.h index c2f09e25afe..6e7c02ddb19 100644 --- a/sys/dev/pci/drm/include/linux/compiler.h +++ b/sys/dev/pci/drm/include/linux/compiler.h @@ -4,11 +4,14 @@ #define _LINUX_COMPILER_H #include <linux/kconfig.h> +#include <sys/atomic.h> /* for READ_ONCE() WRITE_ONCE() */ #define unlikely(x) __builtin_expect(!!(x), 0) #define likely(x) __builtin_expect(!!(x), 1) #define __force +#define __acquires(x) +#define __releases(x) #define __always_unused __unused #define __maybe_unused #define __read_mostly @@ -19,6 +22,7 @@ #define __deprecated #define __always_inline inline #define noinline __attribute__((noinline)) +#define fallthrough do {} while (0) #ifndef __user #define __user @@ -30,4 +34,20 @@ #define uninitialized_var(x) x +/* The Linux code doesn't meet our usual standards! */ +#ifdef __clang__ +#pragma clang diagnostic ignored "-Wenum-conversion" +#pragma clang diagnostic ignored "-Winitializer-overrides" +#pragma clang diagnostic ignored "-Wtautological-compare" +#pragma clang diagnostic ignored "-Wunneeded-internal-declaration" +#pragma clang diagnostic ignored "-Wunused-const-variable" +#pragma clang diagnostic ignored "-Wincompatible-pointer-types-discards-qualifiers" +#pragma clang diagnostic ignored "-Wunused-function" +#pragma clang diagnostic ignored "-Wunused-variable" +#pragma clang diagnostic ignored "-Wparentheses-equality" +#pragma clang diagnostic ignored "-Wmissing-braces" +#else +#pragma GCC diagnostic ignored "-Wformat-zero-length" +#endif + #endif diff --git a/sys/dev/pci/drm/include/linux/completion.h b/sys/dev/pci/drm/include/linux/completion.h index 0fb61e8c288..f1233514f80 100644 --- a/sys/dev/pci/drm/include/linux/completion.h +++ b/sys/dev/pci/drm/include/linux/completion.h @@ -1,4 +1,4 @@ -/* $OpenBSD: completion.h,v 1.3 2019/12/30 09:30:31 mpi Exp $ */ +/* $OpenBSD: completion.h,v 1.4 2020/06/08 04:48:14 jsg Exp $ */ /* * Copyright (c) 2015, 2018 Mark Kettenis * @@ -35,6 +35,12 @@ init_completion(struct completion *x) mtx_init(&x->wait.lock, IPL_TTY); } +static inline void +reinit_completion(struct completion *x) +{ + x->done = 0; +} + static inline u_long wait_for_completion_timeout(struct completion *x, u_long timo) { @@ -57,6 +63,27 @@ wait_for_completion_timeout(struct completion *x, u_long timo) } static inline u_long +wait_for_completion(struct completion *x) +{ + int ret; + + KASSERT(!cold); + + mtx_enter(&x->wait.lock); + while (x->done == 0) { + ret = msleep_nsec(x, &x->wait.lock, 0, "wfci", INFSLP); + if (ret) { + mtx_leave(&x->wait.lock); + return (ret == EWOULDBLOCK) ? 0 : -ret; + } + } + x->done--; + mtx_leave(&x->wait.lock); + + return 0; +} + +static inline u_long wait_for_completion_interruptible(struct completion *x) { int ret; @@ -99,6 +126,16 @@ wait_for_completion_interruptible_timeout(struct completion *x, u_long timo) } static inline void +complete(struct completion *x) +{ + mtx_enter(&x->wait.lock); + if (x->done != UINT_MAX) + x->done++; + mtx_leave(&x->wait.lock); + wakeup(x); +} + +static inline void complete_all(struct completion *x) { mtx_enter(&x->wait.lock); diff --git a/sys/dev/pci/drm/include/linux/component.h b/sys/dev/pci/drm/include/linux/component.h index e69de29bb2d..c20c085a61d 100644 --- a/sys/dev/pci/drm/include/linux/component.h +++ b/sys/dev/pci/drm/include/linux/component.h @@ -0,0 +1,8 @@ +/* Public domain. */ + +#ifndef _LINUX_COMPONENT_H +#define _LINUX_COMPONENT_H + +#define component_del(a, b) + +#endif diff --git a/sys/dev/pci/drm/include/linux/debugfs.h b/sys/dev/pci/drm/include/linux/debugfs.h index e69de29bb2d..bd5fc702ee0 100644 --- a/sys/dev/pci/drm/include/linux/debugfs.h +++ b/sys/dev/pci/drm/include/linux/debugfs.h @@ -0,0 +1,9 @@ +/* Public domain. */ + +#ifndef _LINUX_DEBUGFS_H +#define _LINUX_DEBUGFS_H + +struct debugfs_regset32 { +}; + +#endif diff --git a/sys/dev/pci/drm/include/linux/debugobjects.h b/sys/dev/pci/drm/include/linux/debugobjects.h new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/dev/pci/drm/include/linux/debugobjects.h diff --git a/sys/dev/pci/drm/include/linux/delay.h b/sys/dev/pci/drm/include/linux/delay.h index 157ef90c3f3..19f0ef92204 100644 --- a/sys/dev/pci/drm/include/linux/delay.h +++ b/sys/dev/pci/drm/include/linux/delay.h @@ -31,4 +31,6 @@ mdelay(unsigned long msecs) DELAY(1000); } +#define drm_msleep(x) mdelay(x) + #endif diff --git a/sys/dev/pci/drm/include/linux/device.h b/sys/dev/pci/drm/include/linux/device.h index 21bcf29e1ad..14bf41401dc 100644 --- a/sys/dev/pci/drm/include/linux/device.h +++ b/sys/dev/pci/drm/include/linux/device.h @@ -12,6 +12,8 @@ #include <linux/ioport.h> #include <linux/lockdep.h> #include <linux/pm.h> +#include <linux/kobject.h> +#include <linux/ratelimit.h> /* dev_printk.h -> ratelimit.h */ struct device_node; @@ -20,6 +22,8 @@ struct device_driver { }; struct device_attribute { + struct attribute attr; + ssize_t (*show)(struct device *, struct device_attribute *, char *); }; #define DEVICE_ATTR(_name, _mode, _show, _store) \ @@ -30,7 +34,6 @@ struct device_attribute { #define dev_get_drvdata(x) NULL #define dev_set_drvdata(x, y) -#define dev_name(dev) "" #define dev_pm_set_driver_flags(x, y) @@ -52,6 +55,17 @@ struct device_attribute { printf("drm:pid%d:%s *PRINTK* " fmt, curproc->p_p->ps_pid, \ __func__ , ## arg) +#define dev_warn_ratelimited(dev, fmt, arg...) \ + printf("drm:pid%d:%s *WARNING* " fmt, curproc->p_p->ps_pid, \ + __func__ , ## arg) +#define dev_notice_ratelimited(dev, fmt, arg...) \ + printf("drm:pid%d:%s *NOTICE* " fmt, curproc->p_p->ps_pid, \ + __func__ , ## arg) + +#define dev_err_once(dev, fmt, arg...) \ + printf("drm:pid%d:%s *ERROR* " fmt, curproc->p_p->ps_pid, \ + __func__ , ## arg) + #ifdef DRMDEBUG #define dev_info(dev, fmt, arg...) \ printf("drm: " fmt, ## arg) @@ -65,4 +79,13 @@ struct device_attribute { do { } while(0) #endif +static inline const char * +dev_driver_string(struct device *dev) +{ + return dev->dv_cfdata->cf_driver->cd_name; +} + +/* should be bus id as string, ie 0000:00:02.0 */ +#define dev_name(dev) "" + #endif diff --git a/sys/dev/pci/drm/include/linux/dma-buf.h b/sys/dev/pci/drm/include/linux/dma-buf.h index 69ee26eea33..04fa939f63a 100644 --- a/sys/dev/pci/drm/include/linux/dma-buf.h +++ b/sys/dev/pci/drm/include/linux/dma-buf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dma-buf.h,v 1.1 2019/04/14 10:14:53 jsg Exp $ */ +/* $OpenBSD: dma-buf.h,v 1.2 2020/06/08 04:48:14 jsg Exp $ */ /* * Copyright (c) 2018 Mark Kettenis * @@ -20,7 +20,8 @@ #include <sys/types.h> #include <sys/systm.h> -#include <linux/reservation.h> +#include <linux/dma-resv.h> +#include <linux/list.h> struct dma_buf_ops; @@ -29,9 +30,17 @@ struct dma_buf { void *priv; size_t size; struct file *file; + struct list_head attachments; + struct dma_resv *resv; }; -struct dma_buf_attachment; +struct dma_buf_attachment { + void *importer_priv; +}; + +struct dma_buf_attach_ops { + void (*move_notify)(struct dma_buf_attachment *); +}; void get_dma_buf(struct dma_buf *); struct dma_buf *dma_buf_get(int); @@ -47,7 +56,7 @@ struct dma_buf_export_info { size_t size; int flags; void *priv; - struct reservation_object *resv; + struct dma_resv *resv; }; #define DEFINE_DMA_BUF_EXPORT_INFO(x) struct dma_buf_export_info x diff --git a/sys/dev/pci/drm/include/linux/dma-fence-chain.h b/sys/dev/pci/drm/include/linux/dma-fence-chain.h new file mode 100644 index 00000000000..8d1ac5d5337 --- /dev/null +++ b/sys/dev/pci/drm/include/linux/dma-fence-chain.h @@ -0,0 +1,9 @@ +/* Public domain. */ + +#ifndef _LINUX_DMA_FENCE_CHAIN_H +#define _LINUX_DMA_FENCE_CHAIN_H + +struct dma_fence_chain { +}; + +#endif diff --git a/sys/dev/pci/drm/include/linux/dma-fence.h b/sys/dev/pci/drm/include/linux/dma-fence.h index 5b94d067bb6..5b02546f7f4 100644 --- a/sys/dev/pci/drm/include/linux/dma-fence.h +++ b/sys/dev/pci/drm/include/linux/dma-fence.h @@ -18,16 +18,18 @@ struct dma_fence { struct kref refcount; const struct dma_fence_ops *ops; unsigned long flags; - unsigned int context; - unsigned int seqno; + uint64_t context; + uint64_t seqno; struct mutex *lock; struct list_head cb_list; int error; struct rcu_head rcu; + ktime_t timestamp; }; enum dma_fence_flag_bits { DMA_FENCE_FLAG_SIGNALED_BIT, + DMA_FENCE_FLAG_TIMESTAMP_BIT, DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT, DMA_FENCE_FLAG_USER_BITS, }; @@ -49,7 +51,7 @@ struct dma_fence_cb { dma_fence_func_t func; }; -unsigned int dma_fence_context_alloc(unsigned int); +uint64_t dma_fence_context_alloc(unsigned int); static inline struct dma_fence * dma_fence_get(struct dma_fence *fence) @@ -103,45 +105,43 @@ dma_fence_put(struct dma_fence *fence) } static inline int -dma_fence_signal(struct dma_fence *fence) +dma_fence_signal_locked(struct dma_fence *fence) { + struct dma_fence_cb *cur, *tmp; + struct list_head cb_list; + if (fence == NULL) return -EINVAL; if (test_and_set_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags)) return -EINVAL; - if (test_bit(DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT, &fence->flags)) { - struct dma_fence_cb *cur, *tmp; + list_replace(&fence->cb_list, &cb_list); - mtx_enter(fence->lock); - list_for_each_entry_safe(cur, tmp, &fence->cb_list, node) { - list_del_init(&cur->node); - cur->func(fence, cur); - } - mtx_leave(fence->lock); + fence->timestamp = ktime_get(); + set_bit(DMA_FENCE_FLAG_TIMESTAMP_BIT, &fence->flags); + + list_for_each_entry_safe(cur, tmp, &cb_list, node) { + INIT_LIST_HEAD(&cur->node); + cur->func(fence, cur); } return 0; } static inline int -dma_fence_signal_locked(struct dma_fence *fence) +dma_fence_signal(struct dma_fence *fence) { - struct dma_fence_cb *cur, *tmp; + int r; if (fence == NULL) return -EINVAL; - if (test_and_set_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags)) - return -EINVAL; - - list_for_each_entry_safe(cur, tmp, &fence->cb_list, node) { - list_del_init(&cur->node); - cur->func(fence, cur); - } + mtx_enter(fence->lock); + r = dma_fence_signal_locked(fence); + mtx_leave(fence->lock); - return 0; + return r; } static inline bool @@ -213,7 +213,7 @@ dma_fence_enable_sw_signaling(struct dma_fence *fence) static inline void dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops, - struct mutex *lock, unsigned context, unsigned seqno) + struct mutex *lock, uint64_t context, uint64_t seqno) { fence->ops = ops; fence->lock = lock; @@ -294,4 +294,6 @@ dma_fence_set_error(struct dma_fence *fence, int error) long dma_fence_wait_any_timeout(struct dma_fence **, uint32_t, bool, long, uint32_t *); +struct dma_fence *dma_fence_get_stub(void); + #endif diff --git a/sys/dev/pci/drm/include/linux/dma-mapping.h b/sys/dev/pci/drm/include/linux/dma-mapping.h index 5c33c31c5ea..1e06dac6d3e 100644 --- a/sys/dev/pci/drm/include/linux/dma-mapping.h +++ b/sys/dev/pci/drm/include/linux/dma-mapping.h @@ -4,10 +4,13 @@ #define _LINUX_DMA_MAPPING_H #include <linux/sizes.h> +#include <linux/scatterlist.h> #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : (1ULL<<(n)) -1) #define dma_set_coherent_mask(x, y) 0 #define dma_set_max_seg_size(x, y) 0 +#define dma_set_mask_and_coherent(x, y) 0 +#define dma_addressing_limited(x) false #endif diff --git a/sys/dev/pci/drm/include/linux/reservation.h b/sys/dev/pci/drm/include/linux/dma-resv.h index 02166e815af..ee50d10f052 100644 --- a/sys/dev/pci/drm/include/linux/reservation.h +++ b/sys/dev/pci/drm/include/linux/dma-resv.h @@ -50,102 +50,52 @@ extern struct lock_class_key reservation_seqcount_class; extern const char reservation_seqcount_string[]; /** - * struct reservation_object_list - a list of shared fences + * struct dma_resv_list - a list of shared fences * @rcu: for internal use * @shared_count: table of shared fences * @shared_max: for growing shared fence table * @shared: shared fence table */ -struct reservation_object_list { +struct dma_resv_list { struct rcu_head rcu; u32 shared_count, shared_max; struct dma_fence __rcu *shared[]; }; /** - * struct reservation_object - a reservation object manages fences for a buffer + * struct dma_resv - a reservation object manages fences for a buffer * @lock: update side lock * @seq: sequence count for managing RCU read-side synchronization * @fence_excl: the exclusive fence, if there is one currently * @fence: list of current shared fences - * @staged: staged copy of shared fences for RCU updates */ -struct reservation_object { +struct dma_resv { struct ww_mutex lock; seqcount_t seq; struct dma_fence __rcu *fence_excl; - struct reservation_object_list __rcu *fence; - struct reservation_object_list *staged; + struct dma_resv_list __rcu *fence; }; -#define reservation_object_held(obj) lockdep_is_held(&(obj)->lock.base) -#define reservation_object_assert_held(obj) \ - lockdep_assert_held(&(obj)->lock.base) +#define dma_resv_held(obj) lockdep_is_held(&(obj)->lock.base) +#define dma_resv_assert_held(obj) lockdep_assert_held(&(obj)->lock.base) /** - * reservation_object_init - initialize a reservation object - * @obj: the reservation object - */ -static inline void -reservation_object_init(struct reservation_object *obj) -{ - ww_mutex_init(&obj->lock, &reservation_ww_class); - - __seqcount_init(&obj->seq, reservation_seqcount_string, &reservation_seqcount_class); - RCU_INIT_POINTER(obj->fence, NULL); - RCU_INIT_POINTER(obj->fence_excl, NULL); - obj->staged = NULL; -} - -/** - * reservation_object_fini - destroys a reservation object - * @obj: the reservation object - */ -static inline void -reservation_object_fini(struct reservation_object *obj) -{ - int i; - struct reservation_object_list *fobj; - struct dma_fence *excl; - - /* - * This object should be dead and all references must have - * been released to it, so no need to be protected with rcu. - */ - excl = rcu_dereference_protected(obj->fence_excl, 1); - if (excl) - dma_fence_put(excl); - - fobj = rcu_dereference_protected(obj->fence, 1); - if (fobj) { - for (i = 0; i < fobj->shared_count; ++i) - dma_fence_put(rcu_dereference_protected(fobj->shared[i], 1)); - - kfree(fobj); - } - kfree(obj->staged); - - ww_mutex_destroy(&obj->lock); -} - -/** - * reservation_object_get_list - get the reservation object's + * dma_resv_get_list - get the reservation object's * shared fence list, with update-side lock held * @obj: the reservation object * * Returns the shared fence list. Does NOT take references to * the fence. The obj->lock must be held. */ -static inline struct reservation_object_list * -reservation_object_get_list(struct reservation_object *obj) +static inline struct dma_resv_list *dma_resv_get_list(struct dma_resv *obj) { return rcu_dereference_protected(obj->fence, - reservation_object_held(obj)); + dma_resv_held(obj)); } /** - * reservation_object_lock - lock the reservation object + * dma_resv_lock - lock the reservation object * @obj: the reservation object * @ctx: the locking context * @@ -159,15 +109,14 @@ reservation_object_get_list(struct reservation_object *obj) * is detected. See ww_mutex_lock() and ww_acquire_init(). A reservation * object may be locked by itself by passing NULL as @ctx. */ -static inline int -reservation_object_lock(struct reservation_object *obj, - struct ww_acquire_ctx *ctx) +static inline int dma_resv_lock(struct dma_resv *obj, + struct ww_acquire_ctx *ctx) { return ww_mutex_lock(&obj->lock, ctx); } /** - * reservation_object_lock_interruptible - lock the reservation object + * dma_resv_lock_interruptible - lock the reservation object * @obj: the reservation object * @ctx: the locking context * @@ -181,16 +130,45 @@ reservation_object_lock(struct reservation_object *obj, * is detected. See ww_mutex_lock() and ww_acquire_init(). A reservation * object may be locked by itself by passing NULL as @ctx. */ -static inline int -reservation_object_lock_interruptible(struct reservation_object *obj, - struct ww_acquire_ctx *ctx) +static inline int dma_resv_lock_interruptible(struct dma_resv *obj, + struct ww_acquire_ctx *ctx) { return ww_mutex_lock_interruptible(&obj->lock, ctx); } +/** + * dma_resv_lock_slow - slowpath lock the reservation object + * @obj: the reservation object + * @ctx: the locking context + * + * Acquires the reservation object after a die case. This function + * will sleep until the lock becomes available. See dma_resv_lock() as + * well. + */ +static inline void dma_resv_lock_slow(struct dma_resv *obj, + struct ww_acquire_ctx *ctx) +{ + ww_mutex_lock_slow(&obj->lock, ctx); +} /** - * reservation_object_trylock - trylock the reservation object + * dma_resv_lock_slow_interruptible - slowpath lock the reservation + * object, interruptible + * @obj: the reservation object + * @ctx: the locking context + * + * Acquires the reservation object interruptible after a die case. This function + * will sleep until the lock becomes available. See + * dma_resv_lock_interruptible() as well. + */ +static inline int dma_resv_lock_slow_interruptible(struct dma_resv *obj, + struct ww_acquire_ctx *ctx) +{ + return ww_mutex_lock_slow_interruptible(&obj->lock, ctx); +} + +/** + * dma_resv_trylock - trylock the reservation object * @obj: the reservation object * * Tries to lock the reservation object for exclusive access and modification. @@ -203,44 +181,74 @@ reservation_object_lock_interruptible(struct reservation_object *obj, * * Returns true if the lock was acquired, false otherwise. */ -static inline bool __must_check -reservation_object_trylock(struct reservation_object *obj) +static inline bool __must_check dma_resv_trylock(struct dma_resv *obj) { return ww_mutex_trylock(&obj->lock); } /** - * reservation_object_unlock - unlock the reservation object + * dma_resv_is_locked - is the reservation object locked + * @obj: the reservation object + * + * Returns true if the mutex is locked, false if unlocked. + */ +static inline bool dma_resv_is_locked(struct dma_resv *obj) +{ + return ww_mutex_is_locked(&obj->lock); +} + +/** + * dma_resv_locking_ctx - returns the context used to lock the object + * @obj: the reservation object + * + * Returns the context used to lock a reservation object or NULL if no context + * was used or the object is not locked at all. + */ +static inline struct ww_acquire_ctx *dma_resv_locking_ctx(struct dma_resv *obj) +{ + return READ_ONCE(obj->lock.ctx); +} + +/** + * dma_resv_unlock - unlock the reservation object * @obj: the reservation object * * Unlocks the reservation object following exclusive access. */ -static inline void -reservation_object_unlock(struct reservation_object *obj) +static inline void dma_resv_unlock(struct dma_resv *obj) { +#ifdef CONFIG_DEBUG_MUTEXES + /* Test shared fence slot reservation */ + if (rcu_access_pointer(obj->fence)) { + struct dma_resv_list *fence = dma_resv_get_list(obj); + + fence->shared_max = fence->shared_count; + } +#endif ww_mutex_unlock(&obj->lock); } /** - * reservation_object_get_excl - get the reservation object's + * dma_resv_get_excl - get the reservation object's * exclusive fence, with update-side lock held * @obj: the reservation object * * Returns the exclusive fence (if any). Does NOT take a - * reference. The obj->lock must be held. + * reference. Writers must hold obj->lock, readers may only + * hold a RCU read side lock. * * RETURNS * The exclusive fence or NULL */ static inline struct dma_fence * -reservation_object_get_excl(struct reservation_object *obj) +dma_resv_get_excl(struct dma_resv *obj) { return rcu_dereference_protected(obj->fence_excl, - reservation_object_held(obj)); + dma_resv_held(obj)); } /** - * reservation_object_get_excl_rcu - get the reservation object's + * dma_resv_get_excl_rcu - get the reservation object's * exclusive fence, without lock held. * @obj: the reservation object * @@ -251,7 +259,7 @@ reservation_object_get_excl(struct reservation_object *obj) * The exclusive fence or NULL if none */ static inline struct dma_fence * -reservation_object_get_excl_rcu(struct reservation_object *obj) +dma_resv_get_excl_rcu(struct dma_resv *obj) { struct dma_fence *fence; @@ -265,26 +273,23 @@ reservation_object_get_excl_rcu(struct reservation_object *obj) return fence; } -int reservation_object_reserve_shared(struct reservation_object *obj); -void reservation_object_add_shared_fence(struct reservation_object *obj, - struct dma_fence *fence); +void dma_resv_init(struct dma_resv *obj); +void dma_resv_fini(struct dma_resv *obj); +int dma_resv_reserve_shared(struct dma_resv *obj, unsigned int num_fences); +void dma_resv_add_shared_fence(struct dma_resv *obj, struct dma_fence *fence); -void reservation_object_add_excl_fence(struct reservation_object *obj, - struct dma_fence *fence); +void dma_resv_add_excl_fence(struct dma_resv *obj, struct dma_fence *fence); -int reservation_object_get_fences_rcu(struct reservation_object *obj, - struct dma_fence **pfence_excl, - unsigned *pshared_count, - struct dma_fence ***pshared); +int dma_resv_get_fences_rcu(struct dma_resv *obj, + struct dma_fence **pfence_excl, + unsigned *pshared_count, + struct dma_fence ***pshared); -int reservation_object_copy_fences(struct reservation_object *dst, - struct reservation_object *src); +int dma_resv_copy_fences(struct dma_resv *dst, struct dma_resv *src); -long reservation_object_wait_timeout_rcu(struct reservation_object *obj, - bool wait_all, bool intr, - unsigned long timeout); +long dma_resv_wait_timeout_rcu(struct dma_resv *obj, bool wait_all, bool intr, + unsigned long timeout); -bool reservation_object_test_signaled_rcu(struct reservation_object *obj, - bool test_all); +bool dma_resv_test_signaled_rcu(struct dma_resv *obj, bool test_all); #endif /* _LINUX_RESERVATION_H */ diff --git a/sys/dev/pci/drm/include/linux/errno.h b/sys/dev/pci/drm/include/linux/errno.h index 99c6d662fcf..2a85ac1e7cc 100644 --- a/sys/dev/pci/drm/include/linux/errno.h +++ b/sys/dev/pci/drm/include/linux/errno.h @@ -11,5 +11,6 @@ #define ENOTSUPP ENOTSUP #define ENODATA ENOTSUP #define ECHRNG EINVAL +#define EHWPOISON EIO #endif diff --git a/sys/dev/pci/drm/include/linux/fb.h b/sys/dev/pci/drm/include/linux/fb.h index 463de7f2cf7..70170be0b69 100644 --- a/sys/dev/pci/drm/include/linux/fb.h +++ b/sys/dev/pci/drm/include/linux/fb.h @@ -8,6 +8,14 @@ #include <linux/notifier.h> #include <linux/backlight.h> #include <linux/kgdb.h> +#include <linux/fs.h> + +struct fb_cmap; +struct fb_fillrect; +struct fb_copyarea; +struct fb_image; + +struct apertures_struct; struct fb_var_screeninfo { int pixclock; @@ -21,8 +29,11 @@ struct fb_info { void *par; int fbcon_rotate_hint; bool skip_vt_switch; + int flags; }; +#define KHZ2PICOS(a) (1000000000UL/(a)) + #define FB_BLANK_UNBLANK 0 #define FB_BLANK_NORMAL 1 #define FB_BLANK_HSYNC_SUSPEND 2 @@ -32,14 +43,45 @@ struct fb_info { #define FBINFO_STATE_RUNNING 0 #define FBINFO_STATE_SUSPENDED 1 +#define FBINFO_HIDE_SMEM_START 0 + #define FB_ROTATE_UR 0 #define FB_ROTATE_CW 1 #define FB_ROTATE_UD 2 #define FB_ROTATE_CCW 3 -#define framebuffer_alloc(flags, device) \ - kzalloc(sizeof(struct fb_info), GFP_KERNEL) +static inline struct fb_info * +framebuffer_alloc(size_t size, void *dev) +{ + return kzalloc(sizeof(struct fb_info) + size, GFP_KERNEL); +} + +static inline void +fb_set_suspend(struct fb_info *fbi, int s) +{ +} + +static inline void +framebuffer_release(struct fb_info *fbi) +{ + kfree(fbi); +} + +static inline int +fb_get_options(const char *name, char **opt) +{ + return 0; +} + +static inline int +register_framebuffer(struct fb_info *fbi) +{ + return 0; +} -#define fb_set_suspend(x, y) +static inline void +unregister_framebuffer(struct fb_info *fbi) +{ +} #endif diff --git a/sys/dev/pci/drm/include/linux/firmware.h b/sys/dev/pci/drm/include/linux/firmware.h index 4e24fc963ca..e3406bf6787 100644 --- a/sys/dev/pci/drm/include/linux/firmware.h +++ b/sys/dev/pci/drm/include/linux/firmware.h @@ -7,6 +7,7 @@ #include <sys/malloc.h> #include <sys/device.h> #include <linux/types.h> +#include <linux/gfp.h> #ifndef __DECONST #define __DECONST(type, var) ((type)(__uintptr_t)(const void *)(var)) diff --git a/sys/dev/pci/drm/include/linux/fs.h b/sys/dev/pci/drm/include/linux/fs.h index 19ca23adc33..be033dc5d11 100644 --- a/sys/dev/pci/drm/include/linux/fs.h +++ b/sys/dev/pci/drm/include/linux/fs.h @@ -12,6 +12,8 @@ #include <linux/pid.h> #include <linux/radix-tree.h> #include <linux/wait_bit.h> +#include <linux/err.h> +#include <linux/sched/signal.h> /* via percpu-rwsem.h -> rcuwait.h */ struct address_space; diff --git a/sys/dev/pci/drm/include/linux/ftrace.h b/sys/dev/pci/drm/include/linux/ftrace.h new file mode 100644 index 00000000000..2754e2477b9 --- /dev/null +++ b/sys/dev/pci/drm/include/linux/ftrace.h @@ -0,0 +1,8 @@ +/* Public domain. */ + +#ifndef _LINUX_FTRACE_H +#define _LINUX_FTRACE_H + +#include <linux/kallsyms.h> + +#endif diff --git a/sys/dev/pci/drm/include/linux/gfp.h b/sys/dev/pci/drm/include/linux/gfp.h index dcffa2ef49d..d1c8d60162d 100644 --- a/sys/dev/pci/drm/include/linux/gfp.h +++ b/sys/dev/pci/drm/include/linux/gfp.h @@ -7,6 +7,8 @@ #include <sys/malloc.h> #include <uvm/uvm_extern.h> +#include <linux/mmzone.h> + #define __GFP_ZERO M_ZERO #define __GFP_DMA32 0x00010000 #define __GFP_NOWARN 0 diff --git a/sys/dev/pci/drm/include/linux/hashtable.h b/sys/dev/pci/drm/include/linux/hashtable.h index 26660bf65bf..ccc72458351 100644 --- a/sys/dev/pci/drm/include/linux/hashtable.h +++ b/sys/dev/pci/drm/include/linux/hashtable.h @@ -1,4 +1,4 @@ -/* $OpenBSD: hashtable.h,v 1.1 2019/04/14 10:14:53 jsg Exp $ */ +/* $OpenBSD: hashtable.h,v 1.2 2020/06/08 04:48:14 jsg Exp $ */ /* * Copyright (c) 2017 Mark Kettenis * @@ -19,6 +19,7 @@ #define _LINUX_HASHTABLE_H #include <linux/list.h> +#include <linux/hash.h> #define DECLARE_HASHTABLE(name, bits) struct hlist_head name[1 << (bits)] diff --git a/sys/dev/pci/drm/include/linux/hdmi.h b/sys/dev/pci/drm/include/linux/hdmi.h index 4f3febc0f97..9613d796cfb 100644 --- a/sys/dev/pci/drm/include/linux/hdmi.h +++ b/sys/dev/pci/drm/include/linux/hdmi.h @@ -27,11 +27,27 @@ #include <linux/types.h> #include <linux/device.h> +enum hdmi_packet_type { + HDMI_PACKET_TYPE_NULL = 0x00, + HDMI_PACKET_TYPE_AUDIO_CLOCK_REGEN = 0x01, + HDMI_PACKET_TYPE_AUDIO_SAMPLE = 0x02, + HDMI_PACKET_TYPE_GENERAL_CONTROL = 0x03, + HDMI_PACKET_TYPE_ACP = 0x04, + HDMI_PACKET_TYPE_ISRC1 = 0x05, + HDMI_PACKET_TYPE_ISRC2 = 0x06, + HDMI_PACKET_TYPE_ONE_BIT_AUDIO_SAMPLE = 0x07, + HDMI_PACKET_TYPE_DST_AUDIO = 0x08, + HDMI_PACKET_TYPE_HBR_AUDIO_STREAM = 0x09, + HDMI_PACKET_TYPE_GAMUT_METADATA = 0x0a, + /* + enum hdmi_infoframe_type */ +}; + enum hdmi_infoframe_type { HDMI_INFOFRAME_TYPE_VENDOR = 0x81, HDMI_INFOFRAME_TYPE_AVI = 0x82, HDMI_INFOFRAME_TYPE_SPD = 0x83, HDMI_INFOFRAME_TYPE_AUDIO = 0x84, + HDMI_INFOFRAME_TYPE_DRM = 0x87, }; #define HDMI_IEEE_OUI 0x000c03 @@ -40,6 +56,7 @@ enum hdmi_infoframe_type { #define HDMI_AVI_INFOFRAME_SIZE 13 #define HDMI_SPD_INFOFRAME_SIZE 25 #define HDMI_AUDIO_INFOFRAME_SIZE 10 +#define HDMI_DRM_INFOFRAME_SIZE 26 #define HDMI_INFOFRAME_SIZE(type) \ (HDMI_INFOFRAME_HEADER_SIZE + HDMI_ ## type ## _INFOFRAME_SIZE) @@ -137,6 +154,17 @@ enum hdmi_content_type { HDMI_CONTENT_TYPE_GAME, }; +enum hdmi_metadata_type { + HDMI_STATIC_METADATA_TYPE1 = 1, +}; + +enum hdmi_eotf { + HDMI_EOTF_TRADITIONAL_GAMMA_SDR, + HDMI_EOTF_TRADITIONAL_GAMMA_HDR, + HDMI_EOTF_SMPTE_ST2084, + HDMI_EOTF_BT_2100_HLG, +}; + struct hdmi_avi_infoframe { enum hdmi_infoframe_type type; unsigned char version; @@ -160,9 +188,37 @@ struct hdmi_avi_infoframe { unsigned short right_bar; }; -int hdmi_avi_infoframe_init(struct hdmi_avi_infoframe *frame); +/* DRM Infoframe as per CTA 861.G spec */ +struct hdmi_drm_infoframe { + enum hdmi_infoframe_type type; + unsigned char version; + unsigned char length; + enum hdmi_eotf eotf; + enum hdmi_metadata_type metadata_type; + struct { + u16 x, y; + } display_primaries[3]; + struct { + u16 x, y; + } white_point; + u16 max_display_mastering_luminance; + u16 min_display_mastering_luminance; + u16 max_cll; + u16 max_fall; +}; + +void hdmi_avi_infoframe_init(struct hdmi_avi_infoframe *frame); ssize_t hdmi_avi_infoframe_pack(struct hdmi_avi_infoframe *frame, void *buffer, size_t size); +ssize_t hdmi_avi_infoframe_pack_only(const struct hdmi_avi_infoframe *frame, + void *buffer, size_t size); +int hdmi_avi_infoframe_check(struct hdmi_avi_infoframe *frame); +int hdmi_drm_infoframe_init(struct hdmi_drm_infoframe *frame); +ssize_t hdmi_drm_infoframe_pack(struct hdmi_drm_infoframe *frame, void *buffer, + size_t size); +ssize_t hdmi_drm_infoframe_pack_only(const struct hdmi_drm_infoframe *frame, + void *buffer, size_t size); +int hdmi_drm_infoframe_check(struct hdmi_drm_infoframe *frame); enum hdmi_spd_sdi { HDMI_SPD_SDI_UNKNOWN, @@ -194,6 +250,9 @@ int hdmi_spd_infoframe_init(struct hdmi_spd_infoframe *frame, const char *vendor, const char *product); ssize_t hdmi_spd_infoframe_pack(struct hdmi_spd_infoframe *frame, void *buffer, size_t size); +ssize_t hdmi_spd_infoframe_pack_only(const struct hdmi_spd_infoframe *frame, + void *buffer, size_t size); +int hdmi_spd_infoframe_check(struct hdmi_spd_infoframe *frame); enum hdmi_audio_coding_type { HDMI_AUDIO_CODING_TYPE_STREAM, @@ -272,6 +331,9 @@ struct hdmi_audio_infoframe { int hdmi_audio_infoframe_init(struct hdmi_audio_infoframe *frame); ssize_t hdmi_audio_infoframe_pack(struct hdmi_audio_infoframe *frame, void *buffer, size_t size); +ssize_t hdmi_audio_infoframe_pack_only(const struct hdmi_audio_infoframe *frame, + void *buffer, size_t size); +int hdmi_audio_infoframe_check(struct hdmi_audio_infoframe *frame); enum hdmi_3d_structure { HDMI_3D_STRUCTURE_INVALID = -1, @@ -296,9 +358,39 @@ struct hdmi_vendor_infoframe { unsigned int s3d_ext_data; }; +/* HDR Metadata as per 861.G spec */ +struct hdr_static_metadata { + __u8 eotf; + __u8 metadata_type; + __u16 max_cll; + __u16 max_fall; + __u16 min_cll; +}; + +/** + * struct hdr_sink_metadata - HDR sink metadata + * + * Metadata Information read from Sink's EDID + */ +struct hdr_sink_metadata { + /** + * @metadata_type: Static_Metadata_Descriptor_ID. + */ + __u32 metadata_type; + /** + * @hdmi_type1: HDR Metadata Infoframe. + */ + union { + struct hdr_static_metadata hdmi_type1; + }; +}; + int hdmi_vendor_infoframe_init(struct hdmi_vendor_infoframe *frame); ssize_t hdmi_vendor_infoframe_pack(struct hdmi_vendor_infoframe *frame, void *buffer, size_t size); +ssize_t hdmi_vendor_infoframe_pack_only(const struct hdmi_vendor_infoframe *frame, + void *buffer, size_t size); +int hdmi_vendor_infoframe_check(struct hdmi_vendor_infoframe *frame); union hdmi_vendor_any_infoframe { struct { @@ -317,6 +409,7 @@ union hdmi_vendor_any_infoframe { * @spd: spd infoframe * @vendor: union of all vendor infoframes * @audio: audio infoframe + * @drm: Dynamic Range and Mastering infoframe * * This is used by the generic pack function. This works since all infoframes * have the same header which also indicates which type of infoframe should be @@ -328,12 +421,17 @@ union hdmi_infoframe { struct hdmi_spd_infoframe spd; union hdmi_vendor_any_infoframe vendor; struct hdmi_audio_infoframe audio; + struct hdmi_drm_infoframe drm; }; -ssize_t -hdmi_infoframe_pack(union hdmi_infoframe *frame, void *buffer, size_t size); -int hdmi_infoframe_unpack(union hdmi_infoframe *frame, void *buffer); +ssize_t hdmi_infoframe_pack(union hdmi_infoframe *frame, void *buffer, + size_t size); +ssize_t hdmi_infoframe_pack_only(const union hdmi_infoframe *frame, + void *buffer, size_t size); +int hdmi_infoframe_check(union hdmi_infoframe *frame); +int hdmi_infoframe_unpack(union hdmi_infoframe *frame, + const void *buffer, size_t size); void hdmi_infoframe_log(const char *level, struct device *dev, - union hdmi_infoframe *frame); + const union hdmi_infoframe *frame); #endif /* _DRM_HDMI_H */ diff --git a/sys/dev/pci/drm/include/linux/highmem.h b/sys/dev/pci/drm/include/linux/highmem.h index 39385671748..36405597f9e 100644 --- a/sys/dev/pci/drm/include/linux/highmem.h +++ b/sys/dev/pci/drm/include/linux/highmem.h @@ -1,4 +1,4 @@ -/* $OpenBSD: highmem.h,v 1.1 2019/04/14 10:14:53 jsg Exp $ */ +/* $OpenBSD: highmem.h,v 1.2 2020/06/08 04:48:14 jsg Exp $ */ /* * Copyright (c) 2013, 2014, 2015 Mark Kettenis * @@ -18,6 +18,7 @@ #ifndef _LINUX_HIGHMEM_H #define _LINUX_HIGHMEM_H +#include <sys/param.h> #include <uvm/uvm_extern.h> #include <linux/uaccess.h> diff --git a/sys/dev/pci/drm/include/linux/hmm.h b/sys/dev/pci/drm/include/linux/hmm.h new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/dev/pci/drm/include/linux/hmm.h diff --git a/sys/dev/pci/drm/include/linux/i2c.h b/sys/dev/pci/drm/include/linux/i2c.h index 3a91dc8dcd3..0d0ff3f44be 100644 --- a/sys/dev/pci/drm/include/linux/i2c.h +++ b/sys/dev/pci/drm/include/linux/i2c.h @@ -1,4 +1,4 @@ -/* $OpenBSD: i2c.h,v 1.1 2019/04/14 10:14:53 jsg Exp $ */ +/* $OpenBSD: i2c.h,v 1.2 2020/06/08 04:48:14 jsg Exp $ */ /* * Copyright (c) 2017 Mark Kettenis * @@ -33,6 +33,8 @@ struct i2c_algorithm; #define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0 #define I2C_FUNC_10BIT_ADDR 0 +struct i2c_lock_operations; + struct i2c_adapter { struct i2c_controller ic; @@ -40,10 +42,17 @@ struct i2c_adapter { const struct i2c_algorithm *algo; void *algo_data; int retries; + const struct i2c_lock_operations *lock_ops; void *data; }; +struct i2c_lock_operations { + void (*lock_bus)(struct i2c_adapter *, unsigned int); + int (*trylock_bus)(struct i2c_adapter *, unsigned int); + void (*unlock_bus)(struct i2c_adapter *, unsigned int); +}; + #define I2C_NAME_SIZE 20 struct i2c_msg { diff --git a/sys/dev/pci/drm/include/linux/idr.h b/sys/dev/pci/drm/include/linux/idr.h index 501a89577fa..b327fa9e4a4 100644 --- a/sys/dev/pci/drm/include/linux/idr.h +++ b/sys/dev/pci/drm/include/linux/idr.h @@ -1,4 +1,4 @@ -/* $OpenBSD: idr.h,v 1.2 2019/05/13 16:23:15 jsg Exp $ */ +/* $OpenBSD: idr.h,v 1.3 2020/06/08 04:48:14 jsg Exp $ */ /* * Copyright (c) 2016 Mark Kettenis * @@ -18,8 +18,11 @@ #ifndef _LINUX_IDR_H #define _LINUX_IDR_H +#include <sys/types.h> #include <sys/tree.h> +#include <linux/radix-tree.h> + struct idr_entry { SPLAY_ENTRY(idr_entry) entry; int id; diff --git a/sys/dev/pci/drm/include/linux/init.h b/sys/dev/pci/drm/include/linux/init.h index e69de29bb2d..4f0355101f7 100644 --- a/sys/dev/pci/drm/include/linux/init.h +++ b/sys/dev/pci/drm/include/linux/init.h @@ -0,0 +1,8 @@ +/* Public domain. */ + +#ifndef _LINUX_INIT_H +#define _LINUX_INIT_H + +#define __initconst + +#endif diff --git a/sys/dev/pci/drm/include/linux/intel-iommu.h b/sys/dev/pci/drm/include/linux/intel-iommu.h index e69de29bb2d..9cab2c2a0e8 100644 --- a/sys/dev/pci/drm/include/linux/intel-iommu.h +++ b/sys/dev/pci/drm/include/linux/intel-iommu.h @@ -0,0 +1,8 @@ +/* Public domain. */ + +#ifndef _INTEL_IOMMU_H_ +#define _INTEL_IOMMU_H_ + +#include <linux/dma-mapping.h> /* via linux/iova.h */ + +#endif diff --git a/sys/dev/pci/drm/include/linux/interrupt.h b/sys/dev/pci/drm/include/linux/interrupt.h index 8390fbdf3ca..459fe3341d4 100644 --- a/sys/dev/pci/drm/include/linux/interrupt.h +++ b/sys/dev/pci/drm/include/linux/interrupt.h @@ -10,6 +10,7 @@ #include <linux/irqflags.h> #include <linux/atomic.h> #include <linux/compiler.h> +#include <linux/irqreturn.h> #define IRQF_SHARED 0 @@ -19,6 +20,8 @@ #define request_irq(irq, hdlr, flags, name, dev) (0) #define free_irq(irq, dev) +typedef irqreturn_t (*irq_handler_t)(int, void *); + struct tasklet_struct { void (*func)(unsigned long); unsigned long data; @@ -86,4 +89,18 @@ tasklet_hi_schedule(struct tasklet_struct *ts) task_add(taskletq, &ts->task); } +static inline void +tasklet_disable_nosync(struct tasklet_struct *ts) +{ + atomic_inc(&ts->count); + smp_mb__after_atomic(); +} + +static inline void +tasklet_enable(struct tasklet_struct *ts) +{ + smp_mb__before_atomic(); + atomic_dec(&ts->count); +} + #endif diff --git a/sys/dev/pci/drm/include/linux/io-64-nonatomic-lo-hi.h b/sys/dev/pci/drm/include/linux/io-64-nonatomic-lo-hi.h new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/dev/pci/drm/include/linux/io-64-nonatomic-lo-hi.h diff --git a/sys/dev/pci/drm/include/linux/io.h b/sys/dev/pci/drm/include/linux/io.h index 2b9e956c3fc..b88352f733a 100644 --- a/sys/dev/pci/drm/include/linux/io.h +++ b/sys/dev/pci/drm/include/linux/io.h @@ -3,9 +3,13 @@ #ifndef _LINUX_IO_H #define _LINUX_IO_H +#include <sys/types.h> #include <sys/systm.h> +#include <sys/memrange.h> /* for MDF_WRITECOMBINE */ + #include <linux/types.h> #include <linux/compiler.h> +#include <linux/vmalloc.h> #define memcpy_toio(d, s, n) memcpy(d, s, n) #define memcpy_fromio(d, s, n) memcpy(d, s, n) @@ -68,4 +72,9 @@ iowrite64(u64 val, volatile void __iomem *addr) #define readq(p) ioread64(p) #define writeq(v, p) iowrite64(v, p) +int drm_mtrr_add(unsigned long, size_t, int); +int drm_mtrr_del(int, unsigned long, size_t, int); + +#define DRM_MTRR_WC MDF_WRITECOMBINE + #endif diff --git a/sys/dev/pci/drm/include/linux/ipc.h b/sys/dev/pci/drm/include/linux/ipc.h new file mode 100644 index 00000000000..e738818c92e --- /dev/null +++ b/sys/dev/pci/drm/include/linux/ipc.h @@ -0,0 +1,8 @@ +/* Public domain. */ + +#ifndef _LINUX_IPC_H +#define _LINUX_IPC_H + +#include <linux/workqueue.h> /* via linux/rhashtable-types.h */ + +#endif diff --git a/sys/dev/pci/drm/include/linux/kallsyms.h b/sys/dev/pci/drm/include/linux/kallsyms.h new file mode 100644 index 00000000000..4dc9fabd0d1 --- /dev/null +++ b/sys/dev/pci/drm/include/linux/kallsyms.h @@ -0,0 +1,8 @@ +/* Public domain. */ + +#ifndef _LINUX_KALLSYMS_H +#define _LINUX_KALLSYMS_H + +#include <linux/module.h> + +#endif diff --git a/sys/dev/pci/drm/include/linux/kconfig.h b/sys/dev/pci/drm/include/linux/kconfig.h index 86aa9464a9c..586553e40e9 100644 --- a/sys/dev/pci/drm/include/linux/kconfig.h +++ b/sys/dev/pci/drm/include/linux/kconfig.h @@ -7,8 +7,16 @@ #include <generated/autoconf.h> -#define IS_ENABLED(x) x - 0 -#define IS_BUILTIN(x) 1 +#define __NEWARG1 __newarg, +#define __is_defined(x) __is_defined2(x) +#define __is_defined2(x) __is_defined3(__NEWARG##x) +#define __is_defined3(x) __is_defined4(x 1, 0) +#define __is_defined4(a, b, ...) b + +#define IS_ENABLED(x) __is_defined(x) +#define IS_REACHABLE(x) __is_defined(x) +#define IS_BUILTIN(x) __is_defined(x) +#define IS_MODULE(x) 0 #if BYTE_ORDER == BIG_ENDIAN #define __BIG_ENDIAN diff --git a/sys/dev/pci/drm/include/linux/kernel.h b/sys/dev/pci/drm/include/linux/kernel.h index 99fa7b4bb8b..059680589db 100644 --- a/sys/dev/pci/drm/include/linux/kernel.h +++ b/sys/dev/pci/drm/include/linux/kernel.h @@ -36,8 +36,6 @@ #define U64_C(x) UINT64_C(x) #define U64_MAX UINT64_MAX -#define IS_ALIGNED(x, y) (((x) & ((y) - 1)) == 0) - #define ARRAY_SIZE nitems #define lower_32_bits(n) ((u32)(n)) @@ -66,6 +64,7 @@ #define mult_frac(x, n, d) (((x) * (n)) / (d)) +#define roundup2(x, y) (((x) + ((y) - 1)) & (~((__typeof(x))(y) - 1))) #define round_up(x, y) ((((x) + ((y) - 1)) / (y)) * (y)) #define round_down(x, y) (((x) / (y)) * (y)) /* y is power of two */ #define rounddown(x, y) (((x) / (y)) * (y)) /* arbitary y */ @@ -76,6 +75,9 @@ #define DIV_ROUND_CLOSEST(x, y) (((x) + ((y) / 2)) / (y)) #define DIV_ROUND_CLOSEST_ULL(x, y) DIV_ROUND_CLOSEST(x, y) +#define IS_ALIGNED(x, y) (((x) & ((y) - 1)) == 0) +#define PTR_ALIGN(x, y) ((__typeof(x))roundup2((unsigned long)(x), (y))) + static inline char * kasprintf(int flags, const char *fmt, ...) { @@ -114,6 +116,18 @@ kvasprintf(int flags, const char *fmt, va_list ap) } static inline int +vscnprintf(char *buf, size_t size, const char *fmt, va_list ap) +{ + int nc; + + nc = vsnprintf(buf, size, fmt, ap); + if (nc > (size - 1)) + return (size - 1); + else + return nc; +} + +static inline int _in_dbg_master(void) { #ifdef DDB @@ -129,8 +143,13 @@ _in_dbg_master(void) #define add_taint(x, y) #define TAINT_MACHINE_CHECK 0 +#define TAINT_WARN 1 #define LOCKDEP_STILL_OK 0 #define u64_to_user_ptr(x) ((void *)(uintptr_t)(x)) +#define _RET_IP_ __builtin_return_address(0) + +#define STUB() do { printf("%s: stub\n", __func__); } while(0) + #endif diff --git a/sys/dev/pci/drm/include/linux/kernfs.h b/sys/dev/pci/drm/include/linux/kernfs.h new file mode 100644 index 00000000000..3d24789dfee --- /dev/null +++ b/sys/dev/pci/drm/include/linux/kernfs.h @@ -0,0 +1,9 @@ +/* Public domain. */ + +#ifndef _LINUX_KERNFS_H +#define _LINUX_KERNFS_H + +#include <linux/err.h> +#include <linux/idr.h> + +#endif diff --git a/sys/dev/pci/drm/include/linux/kgdb.h b/sys/dev/pci/drm/include/linux/kgdb.h index 874a0ebe0be..86dee85a2f0 100644 --- a/sys/dev/pci/drm/include/linux/kgdb.h +++ b/sys/dev/pci/drm/include/linux/kgdb.h @@ -3,6 +3,7 @@ #ifndef _LINUX_KGDB_H #define _LINUX_KGDB_H +#include <sys/types.h> #include <sys/systm.h> static inline int diff --git a/sys/dev/pci/drm/include/linux/kmemleak.h b/sys/dev/pci/drm/include/linux/kmemleak.h new file mode 100644 index 00000000000..30857919af2 --- /dev/null +++ b/sys/dev/pci/drm/include/linux/kmemleak.h @@ -0,0 +1,8 @@ +/* Public domain. */ + +#ifndef _LINUX_KMEMLEAK_H +#define _LINUX_KMEMLEAK_H + +#define kmemleak_update_trace(x) + +#endif diff --git a/sys/dev/pci/drm/include/linux/kref.h b/sys/dev/pci/drm/include/linux/kref.h index 1fbf37133cf..4d16577e749 100644 --- a/sys/dev/pci/drm/include/linux/kref.h +++ b/sys/dev/pci/drm/include/linux/kref.h @@ -1,4 +1,4 @@ -/* $OpenBSD: kref.h,v 1.1 2019/04/14 10:14:53 jsg Exp $ */ +/* $OpenBSD: kref.h,v 1.2 2020/06/08 04:48:14 jsg Exp $ */ /* * Copyright (c) 2015 Mark Kettenis * @@ -92,4 +92,21 @@ kref_put_mutex(struct kref *kref, void (*release)(struct kref *kref), return 0; } +static inline int +kref_put_lock(struct kref *kref, void (*release)(struct kref *kref), + struct mutex *lock) +{ + if (!atomic_add_unless(&kref->refcount, -1, 1)) { + mtx_enter(lock); + if (likely(atomic_dec_and_test(&kref->refcount))) { + release(kref); + return 1; + } + mtx_leave(lock); + return 0; + } + + return 0; +} + #endif diff --git a/sys/dev/pci/drm/include/linux/ktime.h b/sys/dev/pci/drm/include/linux/ktime.h index c4e78551b10..7e5ccf322da 100644 --- a/sys/dev/pci/drm/include/linux/ktime.h +++ b/sys/dev/pci/drm/include/linux/ktime.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ktime.h,v 1.1 2019/04/14 10:14:53 jsg Exp $ */ +/* $OpenBSD: ktime.h,v 1.2 2020/06/08 04:48:14 jsg Exp $ */ /* * Copyright (c) 2013, 2014, 2015 Mark Kettenis * @@ -101,6 +101,12 @@ ktime_add(struct timeval a, struct timeval b) } static inline struct timeval +ktime_add_us(struct timeval tv, int64_t us) +{ + return ns_to_timeval(timeval_to_ns(&tv) + (us * NSEC_PER_USEC)); +} + +static inline struct timeval ktime_add_ns(struct timeval tv, int64_t ns) { return ns_to_timeval(timeval_to_ns(&tv) + ns); diff --git a/sys/dev/pci/drm/include/linux/list.h b/sys/dev/pci/drm/include/linux/list.h index cf05e6f7ad7..115580dbc0d 100644 --- a/sys/dev/pci/drm/include/linux/list.h +++ b/sys/dev/pci/drm/include/linux/list.h @@ -1,4 +1,4 @@ -/* $OpenBSD: list.h,v 1.1 2019/04/14 10:14:53 jsg Exp $ */ +/* $OpenBSD: list.h,v 1.2 2020/06/08 04:48:14 jsg Exp $ */ /* drm_linux_list.h -- linux list functions for the BSDs. * Created: Mon Apr 7 14:30:16 1999 by anholt@FreeBSD.org */ @@ -36,6 +36,7 @@ #include <sys/param.h> #include <linux/kernel.h> #include <linux/types.h> +#include <linux/poison.h> #define list_entry(ptr, type, member) container_of(ptr, type, member) @@ -61,6 +62,13 @@ list_is_singular(const struct list_head *head) { } static inline int +list_is_first(const struct list_head *list, + const struct list_head *head) +{ + return list->prev == head; +} + +static inline int list_is_last(const struct list_head *list, const struct list_head *head) { @@ -121,6 +129,18 @@ static inline void list_move_tail(struct list_head *list, } static inline void +list_bulk_move_tail(struct list_head *head, struct list_head *first, + struct list_head *last) +{ + first->prev->next = last->next; + last->next->prev = first->prev; + head->prev->next = first; + first->prev = head->prev; + last->next = head; + head->prev = last; +} + +static inline void list_del_init(struct list_head *entry) { (entry)->next->prev = (entry)->prev; (entry)->prev->next = (entry)->next; @@ -133,6 +153,9 @@ list_del_init(struct list_head *entry) { #define list_prev_entry(pos, member) \ list_entry(((pos)->member.prev), typeof(*(pos)), member) +#define list_safe_reset_next(pos, n, member) \ + n = list_next_entry(pos, member) + #define list_for_each(entry, head) \ for (entry = (head)->next; entry != head; entry = (entry)->next) diff --git a/sys/dev/pci/drm/include/linux/llist.h b/sys/dev/pci/drm/include/linux/llist.h index aea86b4faff..8c0b37da123 100644 --- a/sys/dev/pci/drm/include/linux/llist.h +++ b/sys/dev/pci/drm/include/linux/llist.h @@ -49,6 +49,19 @@ llist_add(struct llist_node *new, struct llist_head *head) return (first == NULL); } +static inline bool +llist_add_batch(struct llist_node *new_first, struct llist_node *new_last, + struct llist_head *head) +{ + struct llist_node *first; + + do { + new_last->next = first = head->first; + } while (atomic_cas_ptr(&head->first, first, new_first) != first); + + return (first == NULL); +} + static inline void init_llist_head(struct llist_head *head) { @@ -61,10 +74,21 @@ llist_empty(struct llist_head *head) return (head->first == NULL); } +#define llist_for_each_safe(pos, n, node) \ + for ((pos) = (node); \ + (pos) != NULL && \ + ((n) = (pos)->next, pos); \ + (pos) = (n)) + #define llist_for_each_entry_safe(pos, n, node, member) \ for (pos = llist_entry((node), __typeof(*pos), member); \ pos != NULL && \ (n = llist_entry(pos->member.next, __typeof(*pos), member), pos); \ pos = n) +#define llist_for_each_entry(pos, node, member) \ + for ((pos) = llist_entry((node), __typeof(*(pos)), member); \ + (pos) != NULL; \ + (pos) = llist_entry((pos)->member.next, __typeof(*(pos)), member)) + #endif diff --git a/sys/dev/pci/drm/include/linux/lockdep.h b/sys/dev/pci/drm/include/linux/lockdep.h index a6407a1d645..afdb6216b3d 100644 --- a/sys/dev/pci/drm/include/linux/lockdep.h +++ b/sys/dev/pci/drm/include/linux/lockdep.h @@ -6,11 +6,30 @@ struct lock_class_key { }; +struct pin_cookie { +}; + #define might_lock(lock) +#define might_lock_nested(lock, subc) #define lockdep_assert_held(lock) do { (void)(lock); } while(0) +#define lockdep_assert_held_once(lock) do { (void)(lock); } while(0) #define lock_acquire(lock, a, b, c, d, e, f) -#define lock_release(lock, a, b) +#define lock_release(lock, a) #define lock_acquire_shared_recursive(lock, a, b, c, d) #define lockdep_set_subclass(a, b) +#define lockdep_unpin_lock(a, b) +#define lockdep_set_class(a, b) +#define lockdep_init_map(a, b, c, d) + +#define mutex_acquire(a, b, c, d) +#define mutex_release(a, b) + +#define SINGLE_DEPTH_NESTING 0 + +#define lockdep_pin_lock(lock) \ +({ \ + struct pin_cookie pc = {}; \ + pc; \ +}) #endif diff --git a/sys/dev/pci/drm/include/linux/log2.h b/sys/dev/pci/drm/include/linux/log2.h index 8351b473b1f..5dc08372cac 100644 --- a/sys/dev/pci/drm/include/linux/log2.h +++ b/sys/dev/pci/drm/include/linux/log2.h @@ -8,6 +8,8 @@ #define ilog2(x) ((sizeof(x) <= 4) ? (fls(x) - 1) : (flsl(x) - 1)) +int drm_order(unsigned long); + #define is_power_of_2(x) (((x) != 0) && (((x) - 1) & (x)) == 0) #define order_base_2(x) drm_order(x) diff --git a/sys/dev/pci/drm/include/linux/math64.h b/sys/dev/pci/drm/include/linux/math64.h index 7ca4f3b5808..8cf96571e94 100644 --- a/sys/dev/pci/drm/include/linux/math64.h +++ b/sys/dev/pci/drm/include/linux/math64.h @@ -56,4 +56,21 @@ mul_u64_u32_div(uint64_t x, uint32_t y, uint32_t div) return (x * y) / div; } +#define DIV64_U64_ROUND_UP(x, y) \ +({ \ + uint64_t _t = (y); \ + div64_u64((x) + _t - 1, _t); \ +}) + +static inline uint64_t +mul_u64_u32_shr(uint64_t x, uint32_t y, unsigned int shift) +{ + uint32_t hi, lo; + hi = x >> 32; + lo = x & 0xffffffff; + + return (mul_u32_u32(lo, y) >> shift) + + (mul_u32_u32(hi, y) << (32 - shift)); +} + #endif diff --git a/sys/dev/pci/drm/include/linux/media-bus-format.h b/sys/dev/pci/drm/include/linux/media-bus-format.h index e69de29bb2d..7ef55e928e4 100644 --- a/sys/dev/pci/drm/include/linux/media-bus-format.h +++ b/sys/dev/pci/drm/include/linux/media-bus-format.h @@ -0,0 +1,8 @@ +/* Public domain. */ + +#ifndef _LINUX_MEDIA_BUS_FORMAT_H +#define _LINUX_MEDIA_BUS_FORMAT_H + +#define MEDIA_BUS_FMT_FIXED 1 + +#endif diff --git a/sys/dev/pci/drm/include/linux/mempolicy.h b/sys/dev/pci/drm/include/linux/mempolicy.h index e69de29bb2d..b987c99da44 100644 --- a/sys/dev/pci/drm/include/linux/mempolicy.h +++ b/sys/dev/pci/drm/include/linux/mempolicy.h @@ -0,0 +1,8 @@ +/* Public domain. */ + +#ifndef _LINUX_MEMPOLICY_H +#define _LINUX_MEMPOLICY_H + +#include <linux/pagemap.h> + +#endif diff --git a/sys/dev/pci/drm/include/linux/mm.h b/sys/dev/pci/drm/include/linux/mm.h index 59b269ae815..fbf230c309d 100644 --- a/sys/dev/pci/drm/include/linux/mm.h +++ b/sys/dev/pci/drm/include/linux/mm.h @@ -12,6 +12,7 @@ #include <uvm/uvm_extern.h> #include <linux/fs.h> #include <linux/shrinker.h> +#include <linux/overflow.h> #include <asm/pgtable.h> #define PageHighMem(x) 0 @@ -21,13 +22,14 @@ #define page_to_pfn(pp) (VM_PAGE_TO_PHYS(pp) / PAGE_SIZE) #define pfn_to_page(pfn) (PHYS_TO_VM_PAGE(ptoa(pfn))) #define nth_page(page, n) (&(page)[(n)]) -#define offset_in_page(off) ((off) & PAGE_MASK) +#define offset_in_page(off) ((vaddr_t)(off) & PAGE_MASK) #define set_page_dirty(page) atomic_clearbits_int(&page->pg_flags, PG_CLEAN) #define PAGE_ALIGN(addr) (((addr) + PAGE_MASK) & ~PAGE_MASK) #define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT) #define PFN_DOWN(x) ((x) >> PAGE_SHIFT) +#define PFN_PHYS(x) ((x) << PAGE_SHIFT) #define is_vmalloc_addr(ptr) true diff --git a/sys/dev/pci/drm/include/linux/mm_types.h b/sys/dev/pci/drm/include/linux/mm_types.h index e69de29bb2d..1fdd4c1b088 100644 --- a/sys/dev/pci/drm/include/linux/mm_types.h +++ b/sys/dev/pci/drm/include/linux/mm_types.h @@ -0,0 +1,11 @@ +/* Public domain. */ + +#ifndef _LINUX_MM_TYPES_H +#define _LINUX_MM_TYPES_H + +#include <linux/workqueue.h> +#include <linux/completion.h> + +#include <uvm/uvm_extern.h> + +#endif diff --git a/sys/dev/pci/drm/include/linux/mmzone.h b/sys/dev/pci/drm/include/linux/mmzone.h new file mode 100644 index 00000000000..f373e2e5896 --- /dev/null +++ b/sys/dev/pci/drm/include/linux/mmzone.h @@ -0,0 +1,8 @@ +/* Public domain. */ + +#ifndef _LINUX_MMZONE_H +#define _LINUX_MMZONE_H + +#include <linux/mm_types.h> + +#endif diff --git a/sys/dev/pci/drm/include/linux/mod_devicetable.h b/sys/dev/pci/drm/include/linux/mod_devicetable.h index 173f3107763..847aaa85cf8 100644 --- a/sys/dev/pci/drm/include/linux/mod_devicetable.h +++ b/sys/dev/pci/drm/include/linux/mod_devicetable.h @@ -40,4 +40,14 @@ struct dmi_system_id { #define DMI_MATCH(a, b) {(a), (b)} #define DMI_EXACT_MATCH(a, b) {(a), (b)} +struct pci_device_id { + uint16_t vendor; + uint16_t device; + uint16_t subvendor; + uint16_t subdevice; + uint32_t class; + uint32_t class_mask; + unsigned long driver_data; +}; + #endif diff --git a/sys/dev/pci/drm/include/linux/module.h b/sys/dev/pci/drm/include/linux/module.h index 416077c072c..d976306e3de 100644 --- a/sys/dev/pci/drm/include/linux/module.h +++ b/sys/dev/pci/drm/include/linux/module.h @@ -5,6 +5,7 @@ #include <linux/export.h> #include <linux/moduleparam.h> +#include <linux/kobject.h> struct module; @@ -17,4 +18,15 @@ struct module; #define module_exit(x) #define symbol_put(x) +static inline bool +try_module_get(struct module *m) +{ + return true; +} + +static inline void +module_put(struct module *m) +{ +} + #endif diff --git a/sys/dev/pci/drm/include/linux/moduleparam.h b/sys/dev/pci/drm/include/linux/moduleparam.h index c94fe7b45ad..7785f976fce 100644 --- a/sys/dev/pci/drm/include/linux/moduleparam.h +++ b/sys/dev/pci/drm/include/linux/moduleparam.h @@ -8,5 +8,6 @@ #define module_param_named(name, value, type, perm) #define module_param_named_unsafe(name, value, type, perm) #define module_param_unsafe(name, type, perm) +#define module_param_string(name, string, len, perm) #endif diff --git a/sys/dev/pci/drm/include/linux/mutex.h b/sys/dev/pci/drm/include/linux/mutex.h index a1436f82228..5910b9743c0 100644 --- a/sys/dev/pci/drm/include/linux/mutex.h +++ b/sys/dev/pci/drm/include/linux/mutex.h @@ -11,6 +11,8 @@ #define DEFINE_MUTEX(x) struct rwlock x #define mutex_lock_interruptible(rwl) -rw_enter(rwl, RW_WRITE | RW_INTR) +#define mutex_lock_interruptible_nested(rwl, subc) \ + -rw_enter(rwl, RW_WRITE | RW_INTR) #define mutex_lock(rwl) rw_enter_write(rwl) #define mutex_lock_nest_lock(rwl, sub) rw_enter_write(rwl) #define mutex_lock_nested(rwl, sub) rw_enter_write(rwl) @@ -35,4 +37,6 @@ mutex_trylock_recursive(struct rwlock *rwl) return MUTEX_TRYLOCK_FAILED; } +int atomic_dec_and_mutex_lock(volatile int *, struct rwlock *); + #endif diff --git a/sys/dev/pci/drm/include/linux/nmi.h b/sys/dev/pci/drm/include/linux/nmi.h new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/dev/pci/drm/include/linux/nmi.h diff --git a/sys/dev/pci/drm/include/linux/of.h b/sys/dev/pci/drm/include/linux/of.h new file mode 100644 index 00000000000..cbac3f60606 --- /dev/null +++ b/sys/dev/pci/drm/include/linux/of.h @@ -0,0 +1,15 @@ +/* Public domain. */ + +#ifndef _LINUX_OF_H +#define _LINUX_OF_H + +#ifdef __macppc__ +static inline int +of_machine_is_compatible(const char *model) +{ + extern char *hw_prod; + return (strcmp(model, hw_prod) == 0); +} +#endif + +#endif diff --git a/sys/dev/pci/drm/include/linux/overflow.h b/sys/dev/pci/drm/include/linux/overflow.h index ea8fa45e399..93615be569b 100644 --- a/sys/dev/pci/drm/include/linux/overflow.h +++ b/sys/dev/pci/drm/include/linux/overflow.h @@ -5,4 +5,7 @@ #define array_size(x, y) ((x) * (y)) +#define struct_size(p, member, n) \ + (sizeof(*(p)) + ((n) * (sizeof(*(p)->member)))) + #endif diff --git a/sys/dev/pci/drm/include/linux/pagemap.h b/sys/dev/pci/drm/include/linux/pagemap.h index e69de29bb2d..92474a244f6 100644 --- a/sys/dev/pci/drm/include/linux/pagemap.h +++ b/sys/dev/pci/drm/include/linux/pagemap.h @@ -0,0 +1,9 @@ +/* Public domain. */ + +#ifndef _LINUX_PAGEMAP_H +#define _LINUX_PAGEMAP_H + +#include <linux/uaccess.h> +#include <linux/highmem.h> + +#endif diff --git a/sys/dev/pci/drm/include/linux/pci.h b/sys/dev/pci/drm/include/linux/pci.h index 4ec8881f8ca..40348ececc0 100644 --- a/sys/dev/pci/drm/include/linux/pci.h +++ b/sys/dev/pci/drm/include/linux/pci.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pci.h,v 1.4 2019/08/28 10:17:59 kettenis Exp $ */ +/* $OpenBSD: pci.h,v 1.5 2020/06/08 04:48:15 jsg Exp $ */ /* * Copyright (c) 2015 Mark Kettenis * @@ -19,22 +19,27 @@ #define _LINUX_PCI_H #include <sys/types.h> -#include <dev/pci/pcireg.h> -#include <dev/pci/pcivar.h> /* sparc64 cpu.h needs time.h and siginfo.h (indirect via param.h) */ #include <sys/param.h> #include <machine/cpu.h> + +#include <dev/pci/pcireg.h> +#include <dev/pci/pcivar.h> +#include <dev/pci/pcidevs.h> #include <uvm/uvm_extern.h> #include <linux/io.h> #include <linux/ioport.h> #include <linux/kobject.h> +#include <linux/dma-mapping.h> /* pci-dma-compat.h -> dma-mapping.h */ +#include <linux/mod_devicetable.h> struct pci_dev; struct pci_bus { pci_chipset_tag_t pc; unsigned char number; + int domain_nr; pcitag_t *bridgetag; struct pci_dev *self; }; @@ -66,6 +71,18 @@ struct pci_dev { }; #define PCI_ANY_ID (uint16_t) (~0U) +#ifndef PCI_MEM_START +#define PCI_MEM_START 0 +#endif + +#ifndef PCI_MEM_END +#define PCI_MEM_END 0xffffffff +#endif + +#ifndef PCI_MEM64_END +#define PCI_MEM64_END 0xffffffffffffffff +#endif + #define PCI_VENDOR_ID_APPLE PCI_VENDOR_APPLE #define PCI_VENDOR_ID_ASUSTEK PCI_VENDOR_ASUSTEK #define PCI_VENDOR_ID_ATI PCI_VENDOR_ATI @@ -95,6 +112,12 @@ struct pci_dev { #define PCI_EXP_LNKCTL 0x10 #define PCI_EXP_LNKCTL_HAWD 0x0200 #define PCI_EXP_LNKCTL2 0x30 +#define PCI_EXP_LNKCTL2_ENTER_COMP 0x0010 +#define PCI_EXP_LNKCTL2_TX_MARGIN 0x0380 +#define PCI_EXP_LNKCTL2_TLS PCI_PCIE_LCSR2_TLS +#define PCI_EXP_LNKCTL2_TLS_2_5GT PCI_PCIE_LCSR2_TLS_2_5 +#define PCI_EXP_LNKCTL2_TLS_5_0GT PCI_PCIE_LCSR2_TLS_5 +#define PCI_EXP_LNKCTL2_TLS_8_0GT PCI_PCIE_LCSR2_TLS_8 #define PCI_COMMAND PCI_COMMAND_STATUS_REG #define PCI_COMMAND_MEMORY PCI_COMMAND_MEM_ENABLE @@ -209,6 +232,12 @@ pci_pcie_cap(struct pci_dev *pdev) } static inline bool +pci_is_pcie(struct pci_dev *pdev) +{ + return (pci_pcie_cap(pdev) > 0); +} + +static inline bool pci_is_root_bus(struct pci_bus *pbus) { return (pbus->bridgetag == NULL); @@ -227,6 +256,51 @@ pcie_capability_read_dword(struct pci_dev *pdev, int off, u32 *val) return 0; } +static inline int +pcie_capability_read_word(struct pci_dev *pdev, int off, u16 *val) +{ + int pos; + if (!pci_get_capability(pdev->pc, pdev->tag, PCI_CAP_PCIEXPRESS, + &pos, NULL)) { + *val = 0; + return -EINVAL; + } + pci_read_config_word(pdev, pos + off, val); + return 0; +} + +static inline int +pcie_capability_write_word(struct pci_dev *pdev, int off, u16 val) +{ + int pos; + if (!pci_get_capability(pdev->pc, pdev->tag, PCI_CAP_PCIEXPRESS, + &pos, NULL)) + return -EINVAL; + pci_write_config_word(pdev, pos + off, val); + return 0; +} + +static inline int +pcie_get_readrq(struct pci_dev *pdev) +{ + uint16_t val; + + pcie_capability_read_word(pdev, PCI_PCIE_DCSR, &val); + + return 128 << ((val & PCI_PCIE_DCSR_MPS) >> 12); +} + +static inline int +pcie_set_readrq(struct pci_dev *pdev, int rrq) +{ + uint16_t val; + + pcie_capability_read_word(pdev, PCI_PCIE_DCSR, &val); + val &= ~PCI_PCIE_DCSR_MPS; + val |= (ffs(rrq) - 8) << 12; + return pcie_capability_write_word(pdev, PCI_PCIE_DCSR, val); +} + #define pci_set_master(x) #define pci_clear_master(x) @@ -267,6 +341,20 @@ enum pci_bus_speed pcie_get_speed_cap(struct pci_dev *); enum pcie_link_width pcie_get_width_cap(struct pci_dev *); int pci_resize_resource(struct pci_dev *, int, int); +static inline void +pcie_bandwidth_available(struct pci_dev *pdev, struct pci_dev **ldev, + enum pci_bus_speed *speed, enum pcie_link_width *width) +{ + struct pci_dev *bdev = pdev->bus->self; + if (bdev == NULL) + return; + + if (speed) + *speed = pcie_get_speed_cap(bdev); + if (width) + *width = pcie_get_width_cap(bdev); +} + #define pci_save_state(x) #define pci_enable_device(x) 0 #define pci_disable_device(x) @@ -274,6 +362,23 @@ int pci_resize_resource(struct pci_dev *, int, int); #define pci_set_drvdata(x, y) static inline int +pci_domain_nr(struct pci_bus *pbus) +{ + return pbus->domain_nr; +} + +static inline int +pci_irq_vector(struct pci_dev *pdev, unsigned int num) +{ + return pdev->irq; +} + +static inline void +pci_free_irq_vectors(struct pci_dev *pdev) +{ +} + +static inline int pci_set_power_state(struct pci_dev *dev, int state) { return 0; diff --git a/sys/dev/pci/drm/include/linux/perf_event.h b/sys/dev/pci/drm/include/linux/perf_event.h index 935fd59b5fb..0f2e67e6542 100644 --- a/sys/dev/pci/drm/include/linux/perf_event.h +++ b/sys/dev/pci/drm/include/linux/perf_event.h @@ -3,6 +3,8 @@ #ifndef _LINUX_PERF_EVENT_H #define _LINUX_PERF_EVENT_H +#include <linux/ftrace.h> + struct pmu { }; diff --git a/sys/dev/pci/drm/include/linux/pfn.h b/sys/dev/pci/drm/include/linux/pfn.h new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/dev/pci/drm/include/linux/pfn.h diff --git a/sys/dev/pci/drm/include/linux/pid.h b/sys/dev/pci/drm/include/linux/pid.h index 5aa09ef5322..8534accfad3 100644 --- a/sys/dev/pci/drm/include/linux/pid.h +++ b/sys/dev/pci/drm/include/linux/pid.h @@ -3,6 +3,8 @@ #ifndef _LINUX_PID_H #define _LINUX_PID_H +#include <linux/rculist.h> + #define put_pid(x) #endif diff --git a/sys/dev/pci/drm/include/linux/pm.h b/sys/dev/pci/drm/include/linux/pm.h index 35c166bf79f..ac202674c7b 100644 --- a/sys/dev/pci/drm/include/linux/pm.h +++ b/sys/dev/pci/drm/include/linux/pm.h @@ -8,4 +8,7 @@ struct dev_pm_domain { }; +typedef struct { +} pm_message_t; + #endif diff --git a/sys/dev/pci/drm/include/linux/pm_qos.h b/sys/dev/pci/drm/include/linux/pm_qos.h index 2a4e938b757..e4bc138a903 100644 --- a/sys/dev/pci/drm/include/linux/pm_qos.h +++ b/sys/dev/pci/drm/include/linux/pm_qos.h @@ -14,4 +14,8 @@ struct pm_qos_request { #define pm_qos_add_request(a, b, c) #define pm_qos_remove_request(a) +#define cpu_latency_qos_update_request(a, b) +#define cpu_latency_qos_add_request(a, b) +#define cpu_latency_qos_remove_request(a) + #endif diff --git a/sys/dev/pci/drm/include/linux/pm_runtime.h b/sys/dev/pci/drm/include/linux/pm_runtime.h index efbcfaa86bb..c692fcec1b3 100644 --- a/sys/dev/pci/drm/include/linux/pm_runtime.h +++ b/sys/dev/pci/drm/include/linux/pm_runtime.h @@ -9,6 +9,7 @@ #define pm_runtime_mark_last_busy(x) #define pm_runtime_use_autosuspend(x) +#define pm_runtime_dont_use_autosuspend(x) #define pm_runtime_put_autosuspend(x) #define pm_runtime_set_autosuspend_delay(x, y) #define pm_runtime_set_active(x) @@ -16,6 +17,7 @@ #define pm_runtime_put_noidle(x) #define pm_runtime_forbid(x) #define pm_runtime_get_noresume(x) +#define pm_runtime_put(x) static inline int pm_runtime_get_sync(struct device *dev) @@ -23,4 +25,10 @@ pm_runtime_get_sync(struct device *dev) return 0; } +static inline int +pm_runtime_get_if_in_use(struct device *dev) +{ + return -EINVAL; +} + #endif diff --git a/sys/dev/pci/drm/include/linux/poison.h b/sys/dev/pci/drm/include/linux/poison.h new file mode 100644 index 00000000000..35ccb5b5499 --- /dev/null +++ b/sys/dev/pci/drm/include/linux/poison.h @@ -0,0 +1,9 @@ +/* Public domain. */ + +#ifndef _LINUX_POISON_H +#define _LINUX_POISON_H + +#define POISON_INUSE 0xdb +#define POISON_FREE 0xdf + +#endif diff --git a/sys/dev/pci/drm/include/linux/poll.h b/sys/dev/pci/drm/include/linux/poll.h index 1ba9509bba9..4998990d29c 100644 --- a/sys/dev/pci/drm/include/linux/poll.h +++ b/sys/dev/pci/drm/include/linux/poll.h @@ -4,5 +4,6 @@ #define _LINUX_POLL_H #include <linux/ktime.h> +#include <linux/uaccess.h> #endif diff --git a/sys/dev/pci/drm/include/linux/preempt.h b/sys/dev/pci/drm/include/linux/preempt.h index c0d8bf6b95d..fdcaf207999 100644 --- a/sys/dev/pci/drm/include/linux/preempt.h +++ b/sys/dev/pci/drm/include/linux/preempt.h @@ -3,6 +3,8 @@ #ifndef _LINUX_PREEMPT_H #define _LINUX_PREEMPT_H +#include <asm/preempt.h> + #define preempt_enable() #define preempt_disable() @@ -19,5 +21,6 @@ in_irq(void) #define in_interrupt() in_irq() #define in_task() (!in_irq()) +#define in_atomic() 0 #endif diff --git a/sys/dev/pci/drm/include/linux/prime_numbers.h b/sys/dev/pci/drm/include/linux/prime_numbers.h new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/dev/pci/drm/include/linux/prime_numbers.h diff --git a/sys/dev/pci/drm/include/linux/printk.h b/sys/dev/pci/drm/include/linux/printk.h index 854cdfb6598..e7fc370f11e 100644 --- a/sys/dev/pci/drm/include/linux/printk.h +++ b/sys/dev/pci/drm/include/linux/printk.h @@ -7,12 +7,16 @@ #include <sys/systm.h> #include <sys/stdarg.h> -#define KERN_INFO "" -#define KERN_WARNING "" -#define KERN_NOTICE "" -#define KERN_DEBUG "" -#define KERN_CRIT "" -#define KERN_ERR "" +#include <linux/init.h> + +#define KERN_CRIT "\0012" +#define KERN_ERR "\0013" +#define KERN_WARNING "\0014" +#define KERN_NOTICE "\0015" +#define KERN_INFO "\0016" +#define KERN_DEBUG "\0017" + +#define KERN_CONT "\001c" #ifndef pr_fmt #define pr_fmt(fmt) fmt @@ -21,25 +25,32 @@ #define printk_once(fmt, arg...) ({ \ static int __warned; \ if (!__warned) { \ - printf(fmt, ## arg); \ + printk(fmt, ## arg); \ __warned = 1; \ } \ }) -#define printk(fmt, arg...) printf(fmt, ## arg) -#define pr_warn(fmt, arg...) printf(pr_fmt(fmt), ## arg) -#define pr_warn_once(fmt, arg...) printk_once(pr_fmt(fmt), ## arg) -#define pr_notice(fmt, arg...) printf(pr_fmt(fmt), ## arg) -#define pr_crit(fmt, arg...) printf(pr_fmt(fmt), ## arg) -#define pr_err(fmt, arg...) printf(pr_fmt(fmt), ## arg) -#define pr_cont(fmt, arg...) printf(pr_fmt(fmt), ## arg) +#define printk_ratelimit() 1 + +int printk(const char *fmt, ...); + +#define pr_warn(fmt, arg...) printk(KERN_WARNING pr_fmt(fmt), ## arg) +#define pr_warn_ratelimited(fmt, arg...) printk(KERN_WARNING pr_fmt(fmt), ## arg) +#define pr_warn_once(fmt, arg...) printk_once(KERN_WARNING pr_fmt(fmt), ## arg) +#define pr_notice(fmt, arg...) printk(KERN_NOTICE pr_fmt(fmt), ## arg) +#define pr_crit(fmt, arg...) printk(KERN_CRIT pr_fmt(fmt), ## arg) +#define pr_err(fmt, arg...) printk(KERN_ERR pr_fmt(fmt), ## arg) +#define pr_err_once(fmt, arg...) printk_once(KERN_ERR pr_fmt(fmt), ## arg) +#define pr_cont(fmt, arg...) printk(KERN_CONT pr_fmt(fmt), ## arg) #ifdef DRMDEBUG -#define pr_info(fmt, arg...) printf(pr_fmt(fmt), ## arg) -#define pr_info_once(fmt, arg...) printk_once(pr_fmt(fmt), ## arg) -#define pr_debug(fmt, arg...) printf(pr_fmt(fmt), ## arg) +#define pr_info(fmt, arg...) printk(KERN_INFO pr_fmt(fmt), ## arg) +#define pr_info_ratelimited(fmt, arg...) printk(KERN_INFO pr_fmt(fmt), ## arg) +#define pr_info_once(fmt, arg...) printk_once(KERN_INFO pr_fmt(fmt), ## arg) +#define pr_debug(fmt, arg...) printk(KERN_DEBUG pr_fmt(fmt), ## arg) #else #define pr_info(fmt, arg...) do { } while(0) +#define pr_info_ratelimited(fmt, arg...) do { } while(0) #define pr_info_once(fmt, arg...) do { } while(0) #define pr_debug(fmt, arg...) do { } while(0) #endif diff --git a/sys/dev/pci/drm/include/linux/pseudo_fs.h b/sys/dev/pci/drm/include/linux/pseudo_fs.h new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/dev/pci/drm/include/linux/pseudo_fs.h diff --git a/sys/dev/pci/drm/include/linux/radix-tree.h b/sys/dev/pci/drm/include/linux/radix-tree.h index 104ebafbe9f..e656a7711c9 100644 --- a/sys/dev/pci/drm/include/linux/radix-tree.h +++ b/sys/dev/pci/drm/include/linux/radix-tree.h @@ -32,6 +32,7 @@ #define _LINUX_RADIX_TREE_H_ #include <linux/types.h> +#include <linux/xarray.h> #define RADIX_TREE_MAP_SHIFT 6 #define RADIX_TREE_MAP_SIZE (1UL << RADIX_TREE_MAP_SHIFT) diff --git a/sys/dev/pci/drm/include/linux/random.h b/sys/dev/pci/drm/include/linux/random.h index 17d3611c862..23286b18fdb 100644 --- a/sys/dev/pci/drm/include/linux/random.h +++ b/sys/dev/pci/drm/include/linux/random.h @@ -27,4 +27,10 @@ get_random_long(void) #endif } +static inline uint32_t +prandom_u32_max(uint32_t x) +{ + return arc4random_uniform(x + 1); +} + #endif diff --git a/sys/dev/pci/drm/include/linux/rbtree.h b/sys/dev/pci/drm/include/linux/rbtree.h index b221ac7a56d..fe45a4eeeb1 100644 --- a/sys/dev/pci/drm/include/linux/rbtree.h +++ b/sys/dev/pci/drm/include/linux/rbtree.h @@ -50,7 +50,7 @@ struct rb_root { }; struct rb_root_cached { - struct rb_node *rb_node; + struct rb_root rb_root; }; /* @@ -77,18 +77,19 @@ RB_PROTOTYPE(linux_root, rb_node, __entry, panic_cmp); #define rb_insert_color(node, root) \ linux_root_RB_INSERT_COLOR((struct linux_root *)(root), (node)) -#define rb_insert_color_cached(node, root, leftmost) \ - linux_root_RB_INSERT_COLOR((struct linux_root *)(root), (node)) #define rb_erase(node, root) \ linux_root_RB_REMOVE((struct linux_root *)(root), (node)) -#define rb_erase_cached(node, root) \ - linux_root_RB_REMOVE((struct linux_root *)(root), (node)) #define rb_next(node) RB_NEXT(linux_root, NULL, (node)) #define rb_prev(node) RB_PREV(linux_root, NULL, (node)) #define rb_first(root) RB_MIN(linux_root, (struct linux_root *)(root)) -#define rb_first_cached(root) RB_MIN(linux_root, (struct linux_root *)(root)) #define rb_last(root) RB_MAX(linux_root, (struct linux_root *)(root)) +#define rb_insert_color_cached(node, root, leftmost) \ + linux_root_RB_INSERT_COLOR((struct linux_root *)(&(root)->rb_root), (node)) +#define rb_erase_cached(node, root) \ + linux_root_RB_REMOVE((struct linux_root *)(&(root)->rb_root), (node)) +#define rb_first_cached(root) RB_MIN(linux_root, (struct linux_root *)(&(root)->rb_root)) + static inline struct rb_node * __rb_deepest_left(struct rb_node *node) { @@ -156,7 +157,11 @@ rb_replace_node(struct rb_node *victim, struct rb_node *new, #undef RB_ROOT #define RB_ROOT (struct rb_root) { NULL } +#ifdef __clang__ #define RB_ROOT_CACHED (struct rb_root_cached) { NULL } +#else +#define RB_ROOT_CACHED (struct rb_root_cached) { { NULL } } +#endif struct interval_tree_node { struct rb_node rb; @@ -165,7 +170,7 @@ struct interval_tree_node { }; static inline struct interval_tree_node * -interval_tree_iter_first(struct rb_root *root, +interval_tree_iter_first(struct rb_root_cached *root, unsigned long start, unsigned long last) { #ifdef DRMDEBUG @@ -175,7 +180,7 @@ interval_tree_iter_first(struct rb_root *root, } static inline void -interval_tree_insert(struct interval_tree_node *node, struct rb_root *root) +interval_tree_insert(struct interval_tree_node *node, struct rb_root_cached *root) { #ifdef DRMDEBUG printf("%s: stub start: 0x%lx last: 0x%lx\n", __func__, node->start, node->last); @@ -183,7 +188,7 @@ interval_tree_insert(struct interval_tree_node *node, struct rb_root *root) } static inline void -interval_tree_remove(struct interval_tree_node *node, struct rb_root *root) +interval_tree_remove(struct interval_tree_node *node, struct rb_root_cached *root) { #ifdef DRMDEBUG printf("%s: stub start: 0x%lx last: 0x%lx\n", __func__, node->start, node->last); diff --git a/sys/dev/pci/drm/include/linux/rculist.h b/sys/dev/pci/drm/include/linux/rculist.h new file mode 100644 index 00000000000..537d6dbf9f9 --- /dev/null +++ b/sys/dev/pci/drm/include/linux/rculist.h @@ -0,0 +1,15 @@ +/* Public domain. */ + +#ifndef _LINUX_RCULIST_H +#define _LINUX_RCULIST_H + +#include <linux/list.h> +#include <linux/rcupdate.h> + +#define list_add_rcu(a, b) list_add(a, b) +#define list_add_tail_rcu(a, b) list_add_tail(a, b) +#define list_del_rcu(a) list_del(a) +#define list_for_each_entry_rcu list_for_each_entry +#define list_for_each_entry_lockless(a, b, c) list_for_each_entry(a, b, c) + +#endif diff --git a/sys/dev/pci/drm/include/linux/rcupdate.h b/sys/dev/pci/drm/include/linux/rcupdate.h index 3bb821befcf..346c87e862a 100644 --- a/sys/dev/pci/drm/include/linux/rcupdate.h +++ b/sys/dev/pci/drm/include/linux/rcupdate.h @@ -18,6 +18,15 @@ struct rcu_head { #define rcu_read_lock() #define rcu_read_unlock() #define rcu_pointer_handoff(p) (p) +#define init_rcu_head(h) +#define destroy_rcu_head(h) + +#define rcu_replace_pointer(rp, p, c) \ +({ \ + __typeof(rp) __r = rp; \ + rp = p; \ + __r; \ +}) #define kfree_rcu(objp, name) do { free((void *)objp, M_DRM, 0); } while(0) @@ -32,5 +41,8 @@ call_rcu(struct rcu_head *head, void (*fn)(struct rcu_head *)) } #define synchronize_rcu() +#define synchronize_rcu_expedited() +#define cond_synchronize_rcu(x) +#define get_state_synchronize_rcu() 0 #endif diff --git a/sys/dev/pci/drm/include/linux/refcount.h b/sys/dev/pci/drm/include/linux/refcount.h index 402a985406e..fea109c5f06 100644 --- a/sys/dev/pci/drm/include/linux/refcount.h +++ b/sys/dev/pci/drm/include/linux/refcount.h @@ -6,10 +6,38 @@ #include <sys/types.h> #include <linux/atomic.h> +typedef atomic_t refcount_t; + static inline bool refcount_dec_and_test(uint32_t *p) { return atomic_dec_and_test(p); } +static inline bool +refcount_inc_not_zero(uint32_t *p) +{ + return atomic_inc_not_zero(p); +} + +static inline void +refcount_set(uint32_t *p, int v) +{ + atomic_set(p, v); +} + +static inline bool +refcount_dec_and_lock_irqsave(volatile int *v, struct mutex *lock, + unsigned long *flags) +{ + if (atomic_add_unless(v, -1, 1)) + return false; + + mtx_enter(lock); + if (atomic_dec_return(v) == 0) + return true; + mtx_leave(lock); + return false; +} + #endif diff --git a/sys/dev/pci/drm/include/linux/rwsem.h b/sys/dev/pci/drm/include/linux/rwsem.h new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/dev/pci/drm/include/linux/rwsem.h diff --git a/sys/dev/pci/drm/include/linux/scatterlist.h b/sys/dev/pci/drm/include/linux/scatterlist.h index 4ec58c80de0..effe1ce499b 100644 --- a/sys/dev/pci/drm/include/linux/scatterlist.h +++ b/sys/dev/pci/drm/include/linux/scatterlist.h @@ -1,4 +1,4 @@ -/* $OpenBSD: scatterlist.h,v 1.1 2019/04/14 10:14:53 jsg Exp $ */ +/* $OpenBSD: scatterlist.h,v 1.2 2020/06/08 04:48:15 jsg Exp $ */ /* * Copyright (c) 2013, 2014, 2015 Mark Kettenis * @@ -22,7 +22,10 @@ #include <sys/param.h> #include <uvm/uvm_extern.h> +#include <linux/mm.h> + struct scatterlist { + struct vm_page *__page; dma_addr_t dma_address; unsigned int offset; unsigned int length; @@ -98,13 +101,20 @@ sg_page_iter_page(struct sg_page_iter *iter) static inline struct vm_page * sg_page(struct scatterlist *sgl) { - return PHYS_TO_VM_PAGE(sgl->dma_address); + return sgl->__page; +} + +static inline void +sg_assign_page(struct scatterlist *sgl, struct vm_page *page) +{ + sgl->__page = page; } static inline void sg_set_page(struct scatterlist *sgl, struct vm_page *page, unsigned int length, unsigned int offset) { + sgl->__page = page; sgl->dma_address = VM_PAGE_TO_PHYS(page); sgl->offset = offset; sgl->length = length; diff --git a/sys/dev/pci/drm/include/linux/sched.h b/sys/dev/pci/drm/include/linux/sched.h index 9def4c4be27..95f074795b1 100644 --- a/sys/dev/pci/drm/include/linux/sched.h +++ b/sys/dev/pci/drm/include/linux/sched.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sched.h,v 1.2 2020/02/18 12:13:40 mpi Exp $ */ +/* $OpenBSD: sched.h,v 1.3 2020/06/08 04:48:15 jsg Exp $ */ /* * Copyright (c) 2013, 2014, 2015 Mark Kettenis * @@ -25,6 +25,7 @@ #include <sys/mutex.h> #include <linux/wait.h> #include <linux/hrtimer.h> +#include <linux/sem.h> #define TASK_NORMAL 1 #define TASK_UNINTERRUPTIBLE 0 @@ -43,6 +44,7 @@ void set_current_state(int); void __set_current_state(int); void schedule(void); long schedule_timeout(long); +long schedule_timeout_uninterruptible(long); #define io_schedule_timeout(x) schedule_timeout(x) diff --git a/sys/dev/pci/drm/include/linux/sched/clock.h b/sys/dev/pci/drm/include/linux/sched/clock.h index 3604ee1ac17..efb3fc2bd00 100644 --- a/sys/dev/pci/drm/include/linux/sched/clock.h +++ b/sys/dev/pci/drm/include/linux/sched/clock.h @@ -4,8 +4,8 @@ #define _LINUX_SCHED_CLOCK_H #include <sys/types.h> -#include <sys/time.h> +#include <linux/time.h> #include <linux/smp.h> static inline uint64_t diff --git a/sys/dev/pci/drm/include/linux/sched/signal.h b/sys/dev/pci/drm/include/linux/sched/signal.h index c201146f159..a405933671d 100644 --- a/sys/dev/pci/drm/include/linux/sched/signal.h +++ b/sys/dev/pci/drm/include/linux/sched/signal.h @@ -3,6 +3,7 @@ #ifndef _LINUX_SCHED_SIGNAL_H #define _LINUX_SCHED_SIGNAL_H +#include <sys/param.h> #include <sys/systm.h> #include <sys/signalvar.h> diff --git a/sys/dev/pci/drm/include/linux/sched/task.h b/sys/dev/pci/drm/include/linux/sched/task.h new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/dev/pci/drm/include/linux/sched/task.h diff --git a/sys/dev/pci/drm/include/linux/sem.h b/sys/dev/pci/drm/include/linux/sem.h new file mode 100644 index 00000000000..6cca4ccef8d --- /dev/null +++ b/sys/dev/pci/drm/include/linux/sem.h @@ -0,0 +1,8 @@ +/* Public domain. */ + +#ifndef _LINUX_SEM_H +#define _LINUX_SEM_H + +#include <linux/ipc.h> /* via uapi/linux/sem.h */ + +#endif diff --git a/sys/dev/pci/drm/include/linux/semaphore.h b/sys/dev/pci/drm/include/linux/semaphore.h new file mode 100644 index 00000000000..f89bbb34443 --- /dev/null +++ b/sys/dev/pci/drm/include/linux/semaphore.h @@ -0,0 +1,9 @@ +/* Public domain. */ + +#ifndef _LINUX_SEMAPHORE_H +#define _LINUX_SEMAPHORE_H + +struct semaphore { +}; + +#endif diff --git a/sys/dev/pci/drm/include/linux/shmem_fs.h b/sys/dev/pci/drm/include/linux/shmem_fs.h index e69de29bb2d..c728c6d8489 100644 --- a/sys/dev/pci/drm/include/linux/shmem_fs.h +++ b/sys/dev/pci/drm/include/linux/shmem_fs.h @@ -0,0 +1,10 @@ +/* Public domain. */ + +#ifndef _LINUX_SHMEM_FS_H +#define _LINUX_SHMEM_FS_H + +#include <linux/mempolicy.h> +#include <linux/swap.h> +#include <linux/file.h> + +#endif diff --git a/sys/dev/pci/drm/include/linux/sizes.h b/sys/dev/pci/drm/include/linux/sizes.h index 01a1dc4a269..4d43eec763b 100644 --- a/sys/dev/pci/drm/include/linux/sizes.h +++ b/sys/dev/pci/drm/include/linux/sizes.h @@ -3,11 +3,17 @@ #ifndef _LINUX_SIZES_H #define _LINUX_SIZES_H +#define SZ_1K (1024 * 1) #define SZ_4K (1024 * 4) #define SZ_8K (1024 * 8) +#define SZ_16K (1024 * 16) #define SZ_32K (1024 * 32) +#define SZ_64K (1024 * 64) #define SZ_128K (1024 * 128) -#define SZ_1M (1024 * 1024) -#define SZ_16M (16 * 1024 * 1024) +#define SZ_256K (1024 * 256) +#define SZ_1M (1024 * 1024 * 1) +#define SZ_2M (1024 * 1024 * 2) +#define SZ_8M (1024 * 1024 * 8) +#define SZ_16M (1024 * 1024 * 16) #endif diff --git a/sys/dev/pci/drm/include/linux/smp.h b/sys/dev/pci/drm/include/linux/smp.h index 354bf92be3c..4db0fee69be 100644 --- a/sys/dev/pci/drm/include/linux/smp.h +++ b/sys/dev/pci/drm/include/linux/smp.h @@ -9,4 +9,7 @@ #define smp_processor_id() (curcpu()->ci_cpuid) +#define get_cpu() cpu_number() +#define put_cpu() + #endif diff --git a/sys/dev/pci/drm/include/linux/spinlock.h b/sys/dev/pci/drm/include/linux/spinlock.h index e40d2872d00..8b1a437e9ae 100644 --- a/sys/dev/pci/drm/include/linux/spinlock.h +++ b/sys/dev/pci/drm/include/linux/spinlock.h @@ -7,6 +7,7 @@ #include <linux/spinlock_types.h> #include <linux/preempt.h> #include <linux/bottom_half.h> +#include <linux/atomic.h> #define spin_lock_irqsave(_mtxp, _flags) do { \ _flags = 0; \ @@ -24,6 +25,28 @@ mtx_leave(_mtxp); \ } while (0) +#define spin_trylock_irqsave(_mtxp, _flags) \ +({ \ + (void)(_flags); \ + mtx_enter_try(_mtxp) ? 1 : 0; \ +}) + +static inline int +atomic_dec_and_lock(volatile int *v, struct mutex *mtxp) +{ + if (*v != 1) { + atomic_dec(v); + return 0; + } + + mtx_enter(mtxp); + atomic_dec(v); + return 1; +} + +#define atomic_dec_and_lock_irqsave(_a, _mtxp, _flags) \ + atomic_dec_and_lock(_a, _mtxp) + #define spin_lock(mtxp) mtx_enter(mtxp) #define spin_lock_nested(mtxp, l) mtx_enter(mtxp) #define spin_unlock(mtxp) mtx_leave(mtxp) diff --git a/sys/dev/pci/drm/include/linux/srcu.h b/sys/dev/pci/drm/include/linux/srcu.h new file mode 100644 index 00000000000..dbabe2f8d6d --- /dev/null +++ b/sys/dev/pci/drm/include/linux/srcu.h @@ -0,0 +1,14 @@ +/* Public domain. */ + +#ifndef _LINUX_SRCU_H +#define _LINUX_SRCU_H + +#define init_srcu_struct(x) +#define cleanup_srcu_struct(x) + +#define srcu_read_lock(x) 0 +#define srcu_read_unlock(x, y) + +#define synchronize_srcu_expedited(x) + +#endif diff --git a/sys/dev/pci/drm/include/linux/stackdepot.h b/sys/dev/pci/drm/include/linux/stackdepot.h new file mode 100644 index 00000000000..2ae1c9b8d31 --- /dev/null +++ b/sys/dev/pci/drm/include/linux/stackdepot.h @@ -0,0 +1,8 @@ +/* Public domain. */ + +#ifndef _LINUX_STACKDEPOT_H +#define _LINUX_STACKDEPOT_H + +typedef uint32_t depot_stack_handle_t; + +#endif diff --git a/sys/dev/pci/drm/include/linux/stacktrace.h b/sys/dev/pci/drm/include/linux/stacktrace.h new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/dev/pci/drm/include/linux/stacktrace.h diff --git a/sys/dev/pci/drm/include/linux/stat.h b/sys/dev/pci/drm/include/linux/stat.h new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/dev/pci/drm/include/linux/stat.h diff --git a/sys/dev/pci/drm/include/linux/string.h b/sys/dev/pci/drm/include/linux/string.h index b77067b1bcc..dc45a038546 100644 --- a/sys/dev/pci/drm/include/linux/string.h +++ b/sys/dev/pci/drm/include/linux/string.h @@ -54,6 +54,9 @@ kstrdup(const char *str, int flags) size_t len; char *p; + if (str == NULL) + return NULL; + len = strlen(str) + 1; p = malloc(len, M_DRM, flags); if (p) diff --git a/sys/dev/pci/drm/include/linux/suspend.h b/sys/dev/pci/drm/include/linux/suspend.h new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/dev/pci/drm/include/linux/suspend.h diff --git a/sys/dev/pci/drm/include/linux/swap.h b/sys/dev/pci/drm/include/linux/swap.h index ce2f8ad9378..d6c8202a5a5 100644 --- a/sys/dev/pci/drm/include/linux/swap.h +++ b/sys/dev/pci/drm/include/linux/swap.h @@ -3,6 +3,18 @@ #ifndef _LINUX_SWAP_H #define _LINUX_SWAP_H +/* + * normally clock.h would be indirectly included via + * + * linux/swap.h + * linux/memcontrol.h + * linux/writeback.h + * linux/blk-cgroup.h + * linux/blkdev.h + * linux/sched/clock.h + */ +#include <linux/sched/clock.h> + #include <uvm/uvm_extern.h> static inline long diff --git a/sys/dev/pci/drm/include/linux/syscalls.h b/sys/dev/pci/drm/include/linux/syscalls.h new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/dev/pci/drm/include/linux/syscalls.h diff --git a/sys/dev/pci/drm/include/linux/sysfs.h b/sys/dev/pci/drm/include/linux/sysfs.h index c9be9a48fba..409373609b0 100644 --- a/sys/dev/pci/drm/include/linux/sysfs.h +++ b/sys/dev/pci/drm/include/linux/sysfs.h @@ -3,9 +3,27 @@ #ifndef _LINUX_SYSFS_H #define _LINUX_SYSFS_H +#include <linux/kernfs.h> + +struct attribute { + const char *name; + int mode; +}; + +struct bin_attribute { +}; + +struct attribute_group { + const char *name; + struct attribute **attrs; + struct bin_attribute **bin_attrs; +}; + #define sysfs_create_link(x, y, z) 0 #define sysfs_remove_link(x, y) #define sysfs_create_group(x, y) 0 #define sysfs_remove_group(x, y) +#define sysfs_remove_file(x, y) +#define sysfs_remove_file_from_group(x, y, z) #endif diff --git a/sys/dev/pci/drm/include/linux/sysrq.h b/sys/dev/pci/drm/include/linux/sysrq.h index 1805e30387a..7cc51b6db6c 100644 --- a/sys/dev/pci/drm/include/linux/sysrq.h +++ b/sys/dev/pci/drm/include/linux/sysrq.h @@ -3,6 +3,19 @@ #ifndef _LINUX_SYSRQ_H #define _LINUX_SYSRQ_H -#define register_sysrq_key(x, y) +struct sysrq_key_op { +}; + +static inline int +register_sysrq_key(int k, struct sysrq_key_op *op) +{ + return 0; +} + +static inline int +unregister_sysrq_key(int k, struct sysrq_key_op *op) +{ + return 0; +} #endif diff --git a/sys/dev/pci/drm/include/linux/thread_info.h b/sys/dev/pci/drm/include/linux/thread_info.h new file mode 100644 index 00000000000..c64eb4ea1bd --- /dev/null +++ b/sys/dev/pci/drm/include/linux/thread_info.h @@ -0,0 +1,8 @@ +/* Public domain. */ + +#ifndef _LINUX_THREAD_INFO_H +#define _LINUX_THREAD_INFO_H + +#include <asm/thread_info.h> + +#endif diff --git a/sys/dev/pci/drm/include/linux/time.h b/sys/dev/pci/drm/include/linux/time.h index c8a97b94b1a..0719b8fce65 100644 --- a/sys/dev/pci/drm/include/linux/time.h +++ b/sys/dev/pci/drm/include/linux/time.h @@ -1,4 +1,4 @@ -/* $OpenBSD: time.h,v 1.1 2019/04/14 10:14:53 jsg Exp $ */ +/* $OpenBSD: time.h,v 1.2 2020/06/08 04:48:15 jsg Exp $ */ /* * Copyright (c) 2013, 2014, 2015 Mark Kettenis * @@ -20,11 +20,15 @@ #include <sys/time.h> #include <linux/math64.h> +#include <linux/seqlock.h> #define NSEC_PER_USEC 1000L #define NSEC_PER_MSEC 1000000L #define NSEC_PER_SEC 1000000000L +#define USEC_PER_MSEC 1000L +#define USEC_PER_SEC 1000000L + extern struct timespec ns_to_timespec(const int64_t); extern int64_t timeval_to_ms(const struct timeval *); extern int64_t timeval_to_ns(const struct timeval *); diff --git a/sys/dev/pci/drm/include/linux/timekeeping.h b/sys/dev/pci/drm/include/linux/timekeeping.h index fc27e921cd5..c6aa77583c7 100644 --- a/sys/dev/pci/drm/include/linux/timekeeping.h +++ b/sys/dev/pci/drm/include/linux/timekeeping.h @@ -18,4 +18,11 @@ ktime_get_real_seconds(void) return ktime_get().tv_sec; } +static inline uint64_t +ktime_get_ns(void) +{ + struct timeval tv = ktime_get(); + return timeval_to_ns(&tv); +} + #endif diff --git a/sys/dev/pci/drm/include/linux/timer.h b/sys/dev/pci/drm/include/linux/timer.h index b1f11a2c916..a475ee10adb 100644 --- a/sys/dev/pci/drm/include/linux/timer.h +++ b/sys/dev/pci/drm/include/linux/timer.h @@ -1,4 +1,4 @@ -/* $OpenBSD: timer.h,v 1.1 2019/04/14 10:14:53 jsg Exp $ */ +/* $OpenBSD: timer.h,v 1.2 2020/06/08 04:48:15 jsg Exp $ */ /* * Copyright (c) 2013, 2014, 2015 Mark Kettenis * @@ -28,6 +28,7 @@ #define mod_timer(x, y) timeout_add((x), (y - jiffies)) #define mod_timer_pinned(x, y) timeout_add((x), (y - jiffies)) #define del_timer_sync(x) timeout_del((x)) +#define del_timer(x) timeout_del((x)) #define timer_pending(x) timeout_pending((x)) static inline unsigned long diff --git a/sys/dev/pci/drm/include/linux/tracepoint.h b/sys/dev/pci/drm/include/linux/tracepoint.h index a28216f65ac..750a63afc6b 100644 --- a/sys/dev/pci/drm/include/linux/tracepoint.h +++ b/sys/dev/pci/drm/include/linux/tracepoint.h @@ -3,6 +3,8 @@ #ifndef _LINUX_TRACEPOINT_H #define _LINUX_TRACEPOINT_H +#include <linux/types.h> + #define TP_PROTO(x...) x #define DEFINE_EVENT(template, name, proto, args) \ diff --git a/sys/dev/pci/drm/include/linux/types.h b/sys/dev/pci/drm/include/linux/types.h index 5ec2b85b594..bc9222ca2ee 100644 --- a/sys/dev/pci/drm/include/linux/types.h +++ b/sys/dev/pci/drm/include/linux/types.h @@ -34,6 +34,8 @@ typedef uint16_t __le16; typedef uint16_t __be16; typedef uint32_t __le32; typedef uint32_t __be32; +typedef uint64_t __le64; +typedef uint64_t __be64; typedef bus_addr_t dma_addr_t; typedef bus_addr_t phys_addr_t; diff --git a/sys/dev/pci/drm/include/linux/uaccess.h b/sys/dev/pci/drm/include/linux/uaccess.h index 1a0325f7f78..459eadf0b21 100644 --- a/sys/dev/pci/drm/include/linux/uaccess.h +++ b/sys/dev/pci/drm/include/linux/uaccess.h @@ -1,4 +1,4 @@ -/* $OpenBSD: uaccess.h,v 1.2 2019/12/18 08:56:19 kettenis Exp $ */ +/* $OpenBSD: uaccess.h,v 1.3 2020/06/08 04:48:15 jsg Exp $ */ /* * Copyright (c) 2015 Mark Kettenis * @@ -22,9 +22,6 @@ #include <sys/systm.h> #include <linux/sched.h> -#define user_access_begin() -#define user_access_end() - static inline unsigned long __copy_to_user(void *to, const void *from, unsigned len) { @@ -70,11 +67,14 @@ copy_from_user(void *to, const void *from, unsigned len) #define VERIFY_READ 0x1 #define VERIFY_WRITE 0x2 static inline int -access_ok(int type, const void *addr, unsigned long size) +access_ok(const void *addr, unsigned long size) { - return true; + return 1; } +#define user_access_begin(addr, size) access_ok(addr, size) +#define user_access_end() + #if defined(__i386__) || defined(__amd64__) static inline void diff --git a/sys/dev/pci/drm/include/linux/uio.h b/sys/dev/pci/drm/include/linux/uio.h new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/dev/pci/drm/include/linux/uio.h diff --git a/sys/dev/pci/drm/include/linux/utsname.h b/sys/dev/pci/drm/include/linux/utsname.h new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/dev/pci/drm/include/linux/utsname.h diff --git a/sys/dev/pci/drm/include/linux/vga_switcheroo.h b/sys/dev/pci/drm/include/linux/vga_switcheroo.h index ccdb11c5a97..30518e24cbb 100644 --- a/sys/dev/pci/drm/include/linux/vga_switcheroo.h +++ b/sys/dev/pci/drm/include/linux/vga_switcheroo.h @@ -3,15 +3,30 @@ #ifndef _LINUX_VGA_SWITCHEROO_H #define _LINUX_VGA_SWITCHEROO_H +#include <linux/fb.h> + +struct pci_dev; + #define vga_switcheroo_register_client(a, b, c) 0 #define vga_switcheroo_unregister_client(a) #define vga_switcheroo_process_delayed_switch() #define vga_switcheroo_fini_domain_pm_ops(x) -#define vga_switcheroo_lock_ddc(x) -#define vga_switcheroo_unlock_ddc(x) #define vga_switcheroo_handler_flags() 0 #define vga_switcheroo_client_fb_set(a, b) +#define vga_switcheroo_init_domain_pm_ops(a, b) #define VGA_SWITCHEROO_CAN_SWITCH_DDC 1 +static inline int +vga_switcheroo_lock_ddc(struct pci_dev *pdev) +{ + return -ENOSYS; +} + +static inline int +vga_switcheroo_unlock_ddc(struct pci_dev *pdev) +{ + return -ENOSYS; +} + #endif diff --git a/sys/dev/pci/drm/include/linux/vgaarb.h b/sys/dev/pci/drm/include/linux/vgaarb.h index 8a5721af5da..9f8ce34c1d4 100644 --- a/sys/dev/pci/drm/include/linux/vgaarb.h +++ b/sys/dev/pci/drm/include/linux/vgaarb.h @@ -18,4 +18,10 @@ vga_client_register(struct pci_dev *a, void *b, void *c, void *d) return -ENODEV; } +static inline int +vga_remove_vgacon(struct pci_dev *a) +{ + return 0; +} + #endif diff --git a/sys/dev/pci/drm/include/linux/wait.h b/sys/dev/pci/drm/include/linux/wait.h index 5860e906a5c..68a6e07ab7f 100644 --- a/sys/dev/pci/drm/include/linux/wait.h +++ b/sys/dev/pci/drm/include/linux/wait.h @@ -1,4 +1,4 @@ -/* $OpenBSD: wait.h,v 1.4 2019/05/08 23:35:23 jsg Exp $ */ +/* $OpenBSD: wait.h,v 1.5 2020/06/08 04:48:15 jsg Exp $ */ /* * Copyright (c) 2013, 2014, 2015 Mark Kettenis * Copyright (c) 2017 Martin Pieuchot @@ -147,10 +147,12 @@ do { \ } while (0) #define wait_event_killable(wq, condition) \ -do { \ +({ \ + int __ret = 0; \ if (!(condition)) \ - __wait_event_intr_timeout(wq, condition, 0, PCATCH); \ -} while (0) + __ret = __wait_event_intr_timeout(wq, condition, 0, PCATCH); \ + __ret; \ +}) #define wait_event_interruptible(wq, condition) \ ({ \ diff --git a/sys/dev/pci/drm/include/linux/wait_bit.h b/sys/dev/pci/drm/include/linux/wait_bit.h index 6f30fdc1ede..2d91c8841b6 100644 --- a/sys/dev/pci/drm/include/linux/wait_bit.h +++ b/sys/dev/pci/drm/include/linux/wait_bit.h @@ -3,8 +3,27 @@ #ifndef _LINUX_WAIT_BIT_H #define _LINUX_WAIT_BIT_H +#include <linux/wait.h> + int wait_on_bit(unsigned long *, int, unsigned); int wait_on_bit_timeout(unsigned long *, int, unsigned, int); void wake_up_bit(void *, int); +void clear_and_wake_up_bit(int, void *); + +wait_queue_head_t *bit_waitqueue(void *, int); + +extern wait_queue_head_t var_waitq; + +static inline void +wake_up_var(void *var) +{ + wake_up(&var_waitq); +} + +#define wait_var_event_interruptible(var, condition) \ + wait_event_interruptible(var_waitq, condition) + +#define wait_var_event_killable(var, condition) \ + wait_event_killable(var_waitq, condition) #endif diff --git a/sys/dev/pci/drm/include/linux/workqueue.h b/sys/dev/pci/drm/include/linux/workqueue.h index 039a0ab9d2a..e2a877d2ab3 100644 --- a/sys/dev/pci/drm/include/linux/workqueue.h +++ b/sys/dev/pci/drm/include/linux/workqueue.h @@ -1,4 +1,4 @@ -/* $OpenBSD: workqueue.h,v 1.2 2019/05/11 14:39:13 jsg Exp $ */ +/* $OpenBSD: workqueue.h,v 1.3 2020/06/08 04:48:15 jsg Exp $ */ /* * Copyright (c) 2015 Mark Kettenis * @@ -32,6 +32,7 @@ struct workqueue_struct; extern struct workqueue_struct *system_wq; +extern struct workqueue_struct *system_highpri_wq; extern struct workqueue_struct *system_unbound_wq; extern struct workqueue_struct *system_long_wq; @@ -39,6 +40,8 @@ extern struct workqueue_struct *system_long_wq; #define WQ_FREEZABLE 2 #define WQ_UNBOUND 4 +#define WQ_UNBOUND_MAX_ACTIVE 4 /* matches nthreads in drm_linux.c */ + static inline struct workqueue_struct * alloc_workqueue(const char *name, int flags, int max_active) { @@ -195,4 +198,21 @@ bool flush_delayed_work(struct delayed_work *); #define destroy_work_on_stack(x) #define destroy_delayed_work_on_stack(x) +struct rcu_work { + struct work_struct work; + struct rcu_head rcu; +}; + +static inline void +INIT_RCU_WORK(struct rcu_work *work, work_func_t func) +{ + INIT_WORK(&work->work, func); +} + +static inline bool +queue_rcu_work(struct workqueue_struct *wq, struct rcu_work *work) +{ + return queue_work(wq, &work->work); +} + #endif diff --git a/sys/dev/pci/drm/include/linux/ww_mutex.h b/sys/dev/pci/drm/include/linux/ww_mutex.h index a38780b8bd5..82018493a67 100644 --- a/sys/dev/pci/drm/include/linux/ww_mutex.h +++ b/sys/dev/pci/drm/include/linux/ww_mutex.h @@ -55,7 +55,7 @@ struct ww_acquire_ctx { struct ww_mutex { struct mutex base; volatile int acquired; - volatile struct ww_acquire_ctx *ctx; + struct ww_acquire_ctx *ctx; volatile struct proc *owner; }; diff --git a/sys/dev/pci/drm/include/linux/xarray.h b/sys/dev/pci/drm/include/linux/xarray.h new file mode 100644 index 00000000000..6aa486be54b --- /dev/null +++ b/sys/dev/pci/drm/include/linux/xarray.h @@ -0,0 +1,58 @@ +/* Public domain. */ + +#ifndef _LINUX_XARRAY_H +#define _LINUX_XARRAY_H + +#include <linux/gfp.h> + +#include <sys/tree.h> +#include <sys/pool.h> + +#define XA_FLAGS_ALLOC 1 +#define XA_FLAGS_ALLOC1 2 + +struct xarray_entry { + SPLAY_ENTRY(xarray_entry) entry; + int id; + void *ptr; +}; + +struct xarray { + gfp_t xa_flags; + SPLAY_HEAD(xarray_tree, xarray_entry) xa_tree; +}; + +void xa_init_flags(struct xarray *, gfp_t); +void xa_destroy(struct xarray *); +int xa_alloc(struct xarray *, u32 *, void *, int, gfp_t); +void *xa_load(struct xarray *, unsigned long); +void *xa_erase(struct xarray *, unsigned long); +void *xa_get_next(struct xarray *, unsigned long *); + +#define xa_for_each(xa, index, entry) \ + for (index = 0; ((entry) = xa_get_next(xa, &(index))) != NULL; index++) + +#define xa_limit_32b 0 + +static inline void * +xa_mk_value(unsigned long v) +{ + unsigned long r = (v << 1) | 1; + return (void *)r; +} + +static inline bool +xa_is_value(const void *e) +{ + unsigned long v = (unsigned long)e; + return v & 1; +} + +static inline unsigned long +xa_to_value(const void *e) +{ + unsigned long v = (unsigned long)e; + return v >> 1; +} + +#endif |