1450N/A/*
1450N/A * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
1450N/A */
1450N/A
1450N/A/*
1450N/A * Copyright(c) 2006-2007 Tungsten Graphics, Inc., Cedar Park, TX., USA
1450N/A * Copyright (c) 2009, 2012, Intel Corporation.
1450N/A * All Rights Reserved.
1450N/A *
1450N/A * Permission is hereby granted, free of charge, to any person obtaining a
1450N/A * copy of this software and associated documentation files(the
1450N/A * "Software"), to deal in the Software without restriction, including
1450N/A * without limitation the rights to use, copy, modify, merge, publish,
1450N/A * distribute, sub license, and/or sell copies of the Software, and to
1450N/A * permit persons to whom the Software is furnished to do so, subject to
1450N/A * the following conditions:
1450N/A *
1450N/A * The above copyright notice and this permission notice(including the
1450N/A * next paragraph) shall be included in all copies or substantial portions
1450N/A * of the Software.
1450N/A *
1450N/A * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1450N/A * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1450N/A * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
1450N/A * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
1450N/A * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
1450N/A * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
1450N/A * USE OR OTHER DEALINGS IN THE SOFTWARE.
1450N/A *
1450N/A */
1450N/A/*
1450N/A * Authors: Thomas Hellström <thomas-at-tungstengraphics-dot-com>
1450N/A */
1450N/A
1450N/A#include <sys/x86_archext.h>
1450N/A#include <vm/seg_kmem.h>
1450N/A#include "drmP.h"
1450N/A
1450N/Aextern void clflush_insn(caddr_t addr);
1450N/Aextern void mfence_insn(void);
1450N/A
1450N/Astatic void
1450N/Adrm_clflush_page(caddr_t page)
1450N/A{
1450N/A unsigned int i;
1450N/A
1450N/A if (page == NULL)
1450N/A return;
1450N/A
1450N/A for (i = 0; i < PAGE_SIZE; i += x86_clflush_size)
1450N/A clflush_insn(page + i);
1450N/A mfence_insn();
1450N/A}
1450N/A
1450N/Avoid
1450N/Adrm_clflush_pages(caddr_t *pages, unsigned long num_pages)
1450N/A{
1450N/A
1450N/A if (is_x86_feature(x86_featureset, X86FSET_CLFSH)) {
1450N/A unsigned long i;
1450N/A
1450N/A for (i = 0; i < num_pages; i++)
1450N/A drm_clflush_page(pages[i]);
1450N/A }
1450N/A}