xref: /titanic_41/usr/src/uts/common/io/drm/drm_cache.c (revision 82629e3015252bf18319ba3815c773df23e21436)
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 2009 Sun Microsystems, Inc.  All rights reserved.
34  * Use is subject to license terms.
35  */
36 
37 #include <sys/x86_archext.h>
38 #include <vm/seg_kmem.h>
39 #include "drmP.h"
40 
41 extern void clflush_insn(caddr_t addr);
42 extern void mfence_insn(void);
43 
44 static void
45 drm_clflush_page(caddr_t page)
46 {
47 	unsigned int i;
48 
49 	if (page == NULL)
50 		return;
51 
52 	for (i = 0; i < PAGE_SIZE; i += x86_clflush_size)
53 		clflush_insn(page + i);
54 	mfence_insn();
55 }
56 
57 void
58 drm_clflush_pages(caddr_t *pages, unsigned long num_pages)
59 {
60 
61 	if (x86_feature & X86_CLFSH) {
62 		unsigned long i;
63 
64 		for (i = 0; i < num_pages; i++)
65 			drm_clflush_page(pages[i]);
66 	}
67 }
68