| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: bus_dma.c,v 1.8 2009/11/07 07:27:45 cegger Exp $ */ | | 1 | /* $NetBSD: bus_dma.c,v 1.9 2010/03/21 13:10:38 nonaka Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2005 NONAKA Kimihiro | | 4 | * Copyright (c) 2005 NONAKA Kimihiro |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -16,27 +16,27 @@ | | | @@ -16,27 +16,27 @@ |
16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | | 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | | 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | | 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | | 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | | 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | | 21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | | 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | | 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | | 26 | */ |
27 | | | 27 | |
28 | #include <sys/cdefs.h> | | 28 | #include <sys/cdefs.h> |
29 | __KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.8 2009/11/07 07:27:45 cegger Exp $"); | | 29 | __KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.9 2010/03/21 13:10:38 nonaka Exp $"); |
30 | | | 30 | |
31 | #include <sys/param.h> | | 31 | #include <sys/param.h> |
32 | #include <sys/systm.h> | | 32 | #include <sys/systm.h> |
33 | #include <sys/kernel.h> | | 33 | #include <sys/kernel.h> |
34 | #include <sys/device.h> | | 34 | #include <sys/device.h> |
35 | #include <sys/malloc.h> | | 35 | #include <sys/malloc.h> |
36 | #include <sys/mbuf.h> | | 36 | #include <sys/mbuf.h> |
37 | | | 37 | |
38 | #include <uvm/uvm_extern.h> | | 38 | #include <uvm/uvm_extern.h> |
39 | | | 39 | |
40 | #include <sh3/cache.h> | | 40 | #include <sh3/cache.h> |
41 | | | 41 | |
42 | #include <machine/autoconf.h> | | 42 | #include <machine/autoconf.h> |
| @@ -675,27 +675,27 @@ _bus_dmamem_map(bus_dma_tag_t t, bus_dma | | | @@ -675,27 +675,27 @@ _bus_dmamem_map(bus_dma_tag_t t, bus_dma |
675 | else | | 675 | else |
676 | *kvap = (void *)SH3_PHYS_TO_P1SEG(segs[0].ds_addr); | | 676 | *kvap = (void *)SH3_PHYS_TO_P1SEG(segs[0].ds_addr); |
677 | | | 677 | |
678 | DPRINTF(("%s: addr = 0x%08lx, kva = %p\n", | | 678 | DPRINTF(("%s: addr = 0x%08lx, kva = %p\n", |
679 | __func__, segs[0].ds_addr, *kvap)); | | 679 | __func__, segs[0].ds_addr, *kvap)); |
680 | return 0; | | 680 | return 0; |
681 | } | | 681 | } |
682 | | | 682 | |
683 | | | 683 | |
684 | /* Always round the size. */ | | 684 | /* Always round the size. */ |
685 | size = round_page(size); | | 685 | size = round_page(size); |
686 | | | 686 | |
687 | va = uvm_km_alloc(kernel_map, size, 0, UVM_KMF_VAONLY | | 687 | va = uvm_km_alloc(kernel_map, size, 0, UVM_KMF_VAONLY |
688 | | (flags & BUS_DMA_NOWAIT) ? UVM_KMF_NOWAIT : 0); | | 688 | | ((flags & BUS_DMA_NOWAIT) ? UVM_KMF_NOWAIT : 0)); |
689 | if (va == 0) | | 689 | if (va == 0) |
690 | return (ENOMEM); | | 690 | return (ENOMEM); |
691 | | | 691 | |
692 | for (curseg = 0; curseg < nsegs; curseg++) { | | 692 | for (curseg = 0; curseg < nsegs; curseg++) { |
693 | DPRINTF(("%s: segs[%d]: ds_addr = 0x%08lx, ds_len = %ld\n", | | 693 | DPRINTF(("%s: segs[%d]: ds_addr = 0x%08lx, ds_len = %ld\n", |
694 | __func__, curseg, | | 694 | __func__, curseg, |
695 | segs[curseg].ds_addr, segs[curseg].ds_len)); | | 695 | segs[curseg].ds_addr, segs[curseg].ds_len)); |
696 | | | 696 | |
697 | for (addr = segs[curseg].ds_addr; | | 697 | for (addr = segs[curseg].ds_addr; |
698 | addr < segs[curseg].ds_addr + segs[curseg].ds_len; | | 698 | addr < segs[curseg].ds_addr + segs[curseg].ds_len; |
699 | addr += PAGE_SIZE, va += PAGE_SIZE, size -= PAGE_SIZE) | | 699 | addr += PAGE_SIZE, va += PAGE_SIZE, size -= PAGE_SIZE) |
700 | { | | 700 | { |
701 | if (__predict_false(size == 0)) | | 701 | if (__predict_false(size == 0)) |