3 * Copyright(c) 2006-2007 Tungsten Graphics, Inc., Cedar Park, TX., USA
4 * Copyright (c) 2009, Intel Corporation.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files(the
9 * "Software"), to deal in the Software without restriction, including
10 * without limitation the rights to use, copy, modify, merge, publish,
11 * distribute, sub license, and/or sell copies of the Software, and to
12 * permit persons to whom the Software is furnished to do so, subject to
13 * the following conditions:
15 * The above copyright notice and this permission notice(including the
16 * next paragraph) shall be included in all copies or substantial portions
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
22 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
23 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
25 * USE OR OTHER DEALINGS IN THE SOFTWARE.
29 * Authors: Thomas Hellström <thomas-at-tungstengraphics-dot-com>
33 * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
36 #include <sys/x86_archext.h>
37 #include <vm/seg_kmem.h>
40 extern void clflush_insn(caddr_t addr
);
41 extern void mfence_insn(void);
44 drm_clflush_page(caddr_t page
)
51 for (i
= 0; i
< PAGE_SIZE
; i
+= x86_clflush_size
)
52 clflush_insn(page
+ i
);
57 drm_clflush_pages(caddr_t
*pages
, unsigned long num_pages
)
60 if (is_x86_feature(x86_featureset
, X86FSET_CLFSH
)) {
63 for (i
= 0; i
< num_pages
; i
++)
64 drm_clflush_page(pages
[i
]);