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