Linux-libre 5.4.49-gnu
[librecmc/linux-libre.git] / drivers / gpu / drm / i915 / i915_memcpy.h
1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Copyright © 2019 Intel Corporation
4  */
5
6 #ifndef __I915_MEMCPY_H__
7 #define __I915_MEMCPY_H__
8
9 #include <linux/types.h>
10
11 struct drm_i915_private;
12
13 void i915_memcpy_init_early(struct drm_i915_private *i915);
14 bool i915_memcpy_from_wc(void *dst, const void *src, unsigned long len);
15
16 /* The movntdqa instructions used for memcpy-from-wc require 16-byte alignment,
17  * as well as SSE4.1 support. i915_memcpy_from_wc() will report if it cannot
18  * perform the operation. To check beforehand, pass in the parameters to
19  * to i915_can_memcpy_from_wc() - since we only care about the low 4 bits,
20  * you only need to pass in the minor offsets, page-aligned pointers are
21  * always valid.
22  *
23  * For just checking for SSE4.1, in the foreknowledge that the future use
24  * will be correctly aligned, just use i915_has_memcpy_from_wc().
25  */
26 #define i915_can_memcpy_from_wc(dst, src, len) \
27         i915_memcpy_from_wc((void *)((unsigned long)(dst) | (unsigned long)(src) | (len)), NULL, 0)
28
29 #define i915_has_memcpy_from_wc() \
30         i915_memcpy_from_wc(NULL, NULL, 0)
31
32 #endif /* __I915_MEMCPY_H__ */