Line data Source code
1 : /* $OpenBSD: drm_cache.c,v 1.6 2018/04/25 01:27:46 jsg Exp $ */
2 : /*
3 : * Copyright (c) 2017 Mark Kettenis
4 : *
5 : * Permission to use, copy, modify, and distribute this software for any
6 : * purpose with or without fee is hereby granted, provided that the above
7 : * copyright notice and this permission notice appear in all copies.
8 : *
9 : * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 : * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 : * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 : * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 : * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 : * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 : * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 : */
17 :
18 : #include <dev/pci/drm/drmP.h>
19 :
20 : #if defined(__i386__) || defined(__amd64__)
21 : static void
22 0 : drm_clflush_page(struct vm_page *page)
23 : {
24 : void *addr;
25 :
26 0 : if (page == NULL)
27 0 : return;
28 :
29 0 : addr = kmap_atomic(page);
30 0 : pmap_flush_cache((vaddr_t)addr, PAGE_SIZE);
31 0 : kunmap_atomic(addr);
32 0 : }
33 :
34 : void
35 0 : drm_clflush_pages(struct vm_page *pages[], unsigned long num_pages)
36 : {
37 : unsigned long i;
38 :
39 0 : for (i = 0; i < num_pages; i++)
40 0 : drm_clflush_page(*pages++);
41 0 : }
42 :
43 : void
44 0 : drm_clflush_sg(struct sg_table *st)
45 : {
46 0 : struct sg_page_iter sg_iter;
47 :
48 0 : for_each_sg_page(st->sgl, &sg_iter, st->nents, 0)
49 0 : drm_clflush_page(sg_page_iter_page(&sg_iter));
50 0 : }
51 :
52 : void
53 0 : drm_clflush_virt_range(void *addr, unsigned long length)
54 : {
55 0 : pmap_flush_cache((vaddr_t)addr, length);
56 0 : }
57 : #else
58 : void
59 : drm_clflush_pages(struct vm_page *pages[], unsigned long num_pages)
60 : {
61 : STUB();
62 : }
63 : #endif
|