xref: /titanic_41/usr/src/uts/common/io/drm/drm_cache.c (revision 6a3e8e8695d5c7d1d18c6800d676990d7f61a2a4)
1 /*
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 /*
33  * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
34  */
35 
36 #include <sys/x86_archext.h>
37 #include <vm/seg_kmem.h>
38 #include "drmP.h"
39 
40 extern void clflush_insn(caddr_t addr);
41 extern void mfence_insn(void);
42 
43 static void
44 drm_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 
56 void
57 drm_clflush_pages(caddr_t *pages, unsigned long num_pages)
58 {
59 
60 	if (is_x86_feature(x86_featureset, X86FSET_CLFSH)) {
61 		unsigned long i;
62 
63 		for (i = 0; i < num_pages; i++)
64 			drm_clflush_page(pages[i]);
65 	}
66 }
67