| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: xen_bus_dma.c,v 1.19 2010/03/02 00:13:50 jym Exp $ */ | | 1 | /* $NetBSD: xen_bus_dma.c,v 1.20 2010/03/09 23:12:06 jym Exp $ */ |
2 | /* NetBSD bus_dma.c,v 1.21 2005/04/16 07:53:35 yamt Exp */ | | 2 | /* NetBSD bus_dma.c,v 1.21 2005/04/16 07:53:35 yamt Exp */ |
3 | | | 3 | |
4 | /*- | | 4 | /*- |
5 | * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. | | 5 | * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. |
6 | * All rights reserved. | | 6 | * All rights reserved. |
7 | * | | 7 | * |
8 | * This code is derived from software contributed to The NetBSD Foundation | | 8 | * This code is derived from software contributed to The NetBSD Foundation |
9 | * by Charles M. Hannum and by Jason R. Thorpe of the Numerical Aerospace | | 9 | * by Charles M. Hannum and by Jason R. Thorpe of the Numerical Aerospace |
10 | * Simulation Facility, NASA Ames Research Center. | | 10 | * Simulation Facility, NASA Ames Research Center. |
11 | * | | 11 | * |
12 | * Redistribution and use in source and binary forms, with or without | | 12 | * Redistribution and use in source and binary forms, with or without |
13 | * modification, are permitted provided that the following conditions | | 13 | * modification, are permitted provided that the following conditions |
14 | * are met: | | 14 | * are met: |
| @@ -22,27 +22,27 @@ | | | @@ -22,27 +22,27 @@ |
22 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 22 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
23 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 23 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
24 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 24 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
31 | * POSSIBILITY OF SUCH DAMAGE. | | 31 | * POSSIBILITY OF SUCH DAMAGE. |
32 | */ | | 32 | */ |
33 | | | 33 | |
34 | #include <sys/cdefs.h> | | 34 | #include <sys/cdefs.h> |
35 | __KERNEL_RCSID(0, "$NetBSD: xen_bus_dma.c,v 1.19 2010/03/02 00:13:50 jym Exp $"); | | 35 | __KERNEL_RCSID(0, "$NetBSD: xen_bus_dma.c,v 1.20 2010/03/09 23:12:06 jym Exp $"); |
36 | | | 36 | |
37 | #include <sys/param.h> | | 37 | #include <sys/param.h> |
38 | #include <sys/systm.h> | | 38 | #include <sys/systm.h> |
39 | #include <sys/kernel.h> | | 39 | #include <sys/kernel.h> |
40 | #include <sys/mbuf.h> | | 40 | #include <sys/mbuf.h> |
41 | #include <sys/proc.h> | | 41 | #include <sys/proc.h> |
42 | | | 42 | |
43 | #include <machine/bus.h> | | 43 | #include <machine/bus.h> |
44 | #include <machine/bus_private.h> | | 44 | #include <machine/bus_private.h> |
45 | | | 45 | |
46 | #include <uvm/uvm_extern.h> | | 46 | #include <uvm/uvm_extern.h> |
47 | | | 47 | |
48 | extern paddr_t avail_end; | | 48 | extern paddr_t avail_end; |
| @@ -85,26 +85,27 @@ _xen_alloc_contig(bus_size_t size, bus_s | | | @@ -85,26 +85,27 @@ _xen_alloc_contig(bus_size_t size, bus_s |
85 | error = uvm_pglistalloc(((psize_t)npages) << PAGE_SHIFT, | | 85 | error = uvm_pglistalloc(((psize_t)npages) << PAGE_SHIFT, |
86 | 0, avail_end, 0, 0, mlistp, npages, (flags & BUS_DMA_NOWAIT) == 0); | | 86 | 0, avail_end, 0, 0, mlistp, npages, (flags & BUS_DMA_NOWAIT) == 0); |
87 | if (error) | | 87 | if (error) |
88 | return (error); | | 88 | return (error); |
89 | | | 89 | |
90 | for (pg = mlistp->tqh_first; pg != NULL; pg = pg->pageq.queue.tqe_next) { | | 90 | for (pg = mlistp->tqh_first; pg != NULL; pg = pg->pageq.queue.tqe_next) { |
91 | pa = VM_PAGE_TO_PHYS(pg); | | 91 | pa = VM_PAGE_TO_PHYS(pg); |
92 | mfn = xpmap_ptom(pa) >> PAGE_SHIFT; | | 92 | mfn = xpmap_ptom(pa) >> PAGE_SHIFT; |
93 | xpmap_phys_to_machine_mapping[ | | 93 | xpmap_phys_to_machine_mapping[ |
94 | (pa - XPMAP_OFFSET) >> PAGE_SHIFT] = INVALID_P2M_ENTRY; | | 94 | (pa - XPMAP_OFFSET) >> PAGE_SHIFT] = INVALID_P2M_ENTRY; |
95 | xenguest_handle(res.extent_start) = &mfn; | | 95 | xenguest_handle(res.extent_start) = &mfn; |
96 | res.nr_extents = 1; | | 96 | res.nr_extents = 1; |
97 | res.extent_order = 0; | | 97 | res.extent_order = 0; |
| | | 98 | res.address_bits = 0; |
98 | res.domid = DOMID_SELF; | | 99 | res.domid = DOMID_SELF; |
99 | error = HYPERVISOR_memory_op(XENMEM_decrease_reservation, &res); | | 100 | error = HYPERVISOR_memory_op(XENMEM_decrease_reservation, &res); |
100 | if (error != 1) { | | 101 | if (error != 1) { |
101 | #ifdef DEBUG | | 102 | #ifdef DEBUG |
102 | printf("xen_alloc_contig: XENMEM_decrease_reservation " | | 103 | printf("xen_alloc_contig: XENMEM_decrease_reservation " |
103 | "failed: err %d (pa %#" PRIxPADDR " mfn %#lx)\n", | | 104 | "failed: err %d (pa %#" PRIxPADDR " mfn %#lx)\n", |
104 | error, pa, mfn); | | 105 | error, pa, mfn); |
105 | #endif | | 106 | #endif |
106 | xpmap_phys_to_machine_mapping[ | | 107 | xpmap_phys_to_machine_mapping[ |
107 | (pa - XPMAP_OFFSET) >> PAGE_SHIFT] = mfn; | | 108 | (pa - XPMAP_OFFSET) >> PAGE_SHIFT] = mfn; |
108 | | | 109 | |
109 | error = ENOMEM; | | 110 | error = ENOMEM; |
110 | goto failed; | | 111 | goto failed; |