162306a36Sopenharmony_ci/* SPDX-License-Identifier: MIT */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Copyright © 2019 Intel Corporation
462306a36Sopenharmony_ci */
562306a36Sopenharmony_ci
662306a36Sopenharmony_ci#ifndef __I915_MEMCPY_H__
762306a36Sopenharmony_ci#define __I915_MEMCPY_H__
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci#include <linux/types.h>
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_cistruct drm_i915_private;
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_civoid i915_memcpy_init_early(struct drm_i915_private *i915);
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_cibool i915_memcpy_from_wc(void *dst, const void *src, unsigned long len);
1662306a36Sopenharmony_civoid i915_unaligned_memcpy_from_wc(void *dst, const void *src, unsigned long len);
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci/* The movntdqa instructions used for memcpy-from-wc require 16-byte alignment,
1962306a36Sopenharmony_ci * as well as SSE4.1 support. i915_memcpy_from_wc() will report if it cannot
2062306a36Sopenharmony_ci * perform the operation. To check beforehand, pass in the parameters to
2162306a36Sopenharmony_ci * to i915_can_memcpy_from_wc() - since we only care about the low 4 bits,
2262306a36Sopenharmony_ci * you only need to pass in the minor offsets, page-aligned pointers are
2362306a36Sopenharmony_ci * always valid.
2462306a36Sopenharmony_ci *
2562306a36Sopenharmony_ci * For just checking for SSE4.1, in the foreknowledge that the future use
2662306a36Sopenharmony_ci * will be correctly aligned, just use i915_has_memcpy_from_wc().
2762306a36Sopenharmony_ci */
2862306a36Sopenharmony_ci#define i915_can_memcpy_from_wc(dst, src, len) \
2962306a36Sopenharmony_ci	i915_memcpy_from_wc((void *)((unsigned long)(dst) | (unsigned long)(src) | (len)), NULL, 0)
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ci#define i915_has_memcpy_from_wc() \
3262306a36Sopenharmony_ci	i915_memcpy_from_wc(NULL, NULL, 0)
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_ci#endif /* __I915_MEMCPY_H__ */
35