blob: fe7eff0436d2a7091b5391afcb47d7aa3186ccfa [file] [log] [blame]
miao chen - Sun Microsystems - Beijing China0035d212009-12-05 13:25:40 +08001/*
2 *
3 * Copyright(c) 2006-2007 Tungsten Graphics, Inc., Cedar Park, TX., USA
4 * Copyright (c) 2009, Intel Corporation.
5 * All Rights Reserved.
6 *
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:
14 *
15 * The above copyright notice and this permission notice(including the
16 * next paragraph) shall be included in all copies or substantial portions
17 * of the Software.
18 *
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.
26 *
27 */
28/*
29 * Authors: Thomas Hellström <thomas-at-tungstengraphics-dot-com>
30 */
31
32/*
Kuriakose Kuruvilla7417cfd2010-07-14 15:47:07 -070033 * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
miao chen - Sun Microsystems - Beijing China0035d212009-12-05 13:25:40 +080034 */
35
36#include <sys/x86_archext.h>
37#include <vm/seg_kmem.h>
38#include "drmP.h"
39
40extern void clflush_insn(caddr_t addr);
41extern void mfence_insn(void);
42
43static void
44drm_clflush_page(caddr_t page)
45{
46 unsigned int i;
47
48 if (page == NULL)
49 return;
50
51 for (i = 0; i < PAGE_SIZE; i += x86_clflush_size)
52 clflush_insn(page + i);
53 mfence_insn();
54}
55
56void
57drm_clflush_pages(caddr_t *pages, unsigned long num_pages)
58{
59
Kuriakose Kuruvilla7417cfd2010-07-14 15:47:07 -070060 if (is_x86_feature(x86_featureset, X86FSET_CLFSH)) {
miao chen - Sun Microsystems - Beijing China0035d212009-12-05 13:25:40 +080061 unsigned long i;
62
63 for (i = 0; i < num_pages; i++)
64 drm_clflush_page(pages[i]);
65 }
66}