18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: MIT */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright © 2019 Intel Corporation
48c2ecf20Sopenharmony_ci */
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci#ifndef __I915_MEMCPY_H__
78c2ecf20Sopenharmony_ci#define __I915_MEMCPY_H__
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#include <linux/types.h>
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_cistruct drm_i915_private;
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_civoid i915_memcpy_init_early(struct drm_i915_private *i915);
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_cibool i915_memcpy_from_wc(void *dst, const void *src, unsigned long len);
168c2ecf20Sopenharmony_civoid i915_unaligned_memcpy_from_wc(void *dst, void *src, unsigned long len);
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci/* The movntdqa instructions used for memcpy-from-wc require 16-byte alignment,
198c2ecf20Sopenharmony_ci * as well as SSE4.1 support. i915_memcpy_from_wc() will report if it cannot
208c2ecf20Sopenharmony_ci * perform the operation. To check beforehand, pass in the parameters to
218c2ecf20Sopenharmony_ci * to i915_can_memcpy_from_wc() - since we only care about the low 4 bits,
228c2ecf20Sopenharmony_ci * you only need to pass in the minor offsets, page-aligned pointers are
238c2ecf20Sopenharmony_ci * always valid.
248c2ecf20Sopenharmony_ci *
258c2ecf20Sopenharmony_ci * For just checking for SSE4.1, in the foreknowledge that the future use
268c2ecf20Sopenharmony_ci * will be correctly aligned, just use i915_has_memcpy_from_wc().
278c2ecf20Sopenharmony_ci */
288c2ecf20Sopenharmony_ci#define i915_can_memcpy_from_wc(dst, src, len) \
298c2ecf20Sopenharmony_ci	i915_memcpy_from_wc((void *)((unsigned long)(dst) | (unsigned long)(src) | (len)), NULL, 0)
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci#define i915_has_memcpy_from_wc() \
328c2ecf20Sopenharmony_ci	i915_memcpy_from_wc(NULL, NULL, 0)
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci#endif /* __I915_MEMCPY_H__ */
35