Deleted Added
full compact
busdma_machdep-v4.c (188350) busdma_machdep-v4.c (188403)
1/*-
2 * Copyright (c) 2004 Olivier Houchard
3 * Copyright (c) 2002 Peter Grehan
4 * Copyright (c) 1997, 1998 Justin T. Gibbs.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 15 unchanged lines hidden (view full) ---

24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 *
28 * From i386/busdma_machdep.c,v 1.26 2002/04/19 22:58:09 alfred
29 */
30
31#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2004 Olivier Houchard
3 * Copyright (c) 2002 Peter Grehan
4 * Copyright (c) 1997, 1998 Justin T. Gibbs.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 15 unchanged lines hidden (view full) ---

24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 *
28 * From i386/busdma_machdep.c,v 1.26 2002/04/19 22:58:09 alfred
29 */
30
31#include <sys/cdefs.h>
32__FBSDID("$FreeBSD: head/sys/arm/arm/busdma_machdep.c 188350 2009-02-08 22:54:58Z imp $");
32__FBSDID("$FreeBSD: head/sys/arm/arm/busdma_machdep.c 188403 2009-02-09 18:03:31Z cognet $");
33
34/*
35 * ARM bus dma support routines
36 */
37
38#define _ARM32_BUS_DMA_PRIVATE
39#include <sys/param.h>
40#include <sys/systm.h>

--- 66 unchanged lines hidden (view full) ---

107 STAILQ_ENTRY(bounce_zone) links;
108 STAILQ_HEAD(bp_list, bounce_page) bounce_page_list;
109 int total_bpages;
110 int free_bpages;
111 int reserved_bpages;
112 int active_bpages;
113 int total_bounced;
114 int total_deferred;
33
34/*
35 * ARM bus dma support routines
36 */
37
38#define _ARM32_BUS_DMA_PRIVATE
39#include <sys/param.h>
40#include <sys/systm.h>

--- 66 unchanged lines hidden (view full) ---

107 STAILQ_ENTRY(bounce_zone) links;
108 STAILQ_HEAD(bp_list, bounce_page) bounce_page_list;
109 int total_bpages;
110 int free_bpages;
111 int reserved_bpages;
112 int active_bpages;
113 int total_bounced;
114 int total_deferred;
115 int map_count;
115 bus_size_t alignment;
116 bus_size_t boundary;
117 bus_addr_t lowaddr;
118 char zoneid[8];
119 char lowaddrid[20];
120 struct sysctl_ctx_list sysctl_tree;
121 struct sysctl_oid *sysctl_tree_top;
122};

--- 395 unchanged lines hidden (view full) ---

518 STAILQ_INIT(&((*mapp)->bpages));
519
520 /*
521 * Attempt to add pages to our pool on a per-instance
522 * basis up to a sane limit.
523 */
524 maxpages = MAX_BPAGES;
525 if ((dmat->flags & BUS_DMA_MIN_ALLOC_COMP) == 0
116 bus_size_t alignment;
117 bus_size_t boundary;
118 bus_addr_t lowaddr;
119 char zoneid[8];
120 char lowaddrid[20];
121 struct sysctl_ctx_list sysctl_tree;
122 struct sysctl_oid *sysctl_tree_top;
123};

--- 395 unchanged lines hidden (view full) ---

519 STAILQ_INIT(&((*mapp)->bpages));
520
521 /*
522 * Attempt to add pages to our pool on a per-instance
523 * basis up to a sane limit.
524 */
525 maxpages = MAX_BPAGES;
526 if ((dmat->flags & BUS_DMA_MIN_ALLOC_COMP) == 0
526 || (dmat->map_count > 0 && bz->total_bpages < maxpages)) {
527 || (bz->map_count > 0 && bz->total_bpages < maxpages)) {
527 int pages;
528
529 pages = MAX(atop(dmat->maxsize), 1);
530 pages = MIN(maxpages - bz->total_bpages, pages);
531 pages = MAX(pages, 1);
532 if (alloc_bounce_pages(dmat, pages) < pages)
533 error = ENOMEM;
534
535 if ((dmat->flags & BUS_DMA_MIN_ALLOC_COMP) == 0) {
536 if (error == 0)
537 dmat->flags |= BUS_DMA_MIN_ALLOC_COMP;
538 } else {
539 error = 0;
540 }
541 }
528 int pages;
529
530 pages = MAX(atop(dmat->maxsize), 1);
531 pages = MIN(maxpages - bz->total_bpages, pages);
532 pages = MAX(pages, 1);
533 if (alloc_bounce_pages(dmat, pages) < pages)
534 error = ENOMEM;
535
536 if ((dmat->flags & BUS_DMA_MIN_ALLOC_COMP) == 0) {
537 if (error == 0)
538 dmat->flags |= BUS_DMA_MIN_ALLOC_COMP;
539 } else {
540 error = 0;
541 }
542 }
543 bz->map_count++;
542 }
543 CTR4(KTR_BUSDMA, "%s: tag %p tag flags 0x%x error %d",
544 __func__, dmat, dmat->flags, error);
545
546 return (0);
547}
548
549/*

--- 5 unchanged lines hidden (view full) ---

555{
556
557 _busdma_free_dmamap(map);
558 if (STAILQ_FIRST(&map->bpages) != NULL) {
559 CTR3(KTR_BUSDMA, "%s: tag %p error %d",
560 __func__, dmat, EBUSY);
561 return (EBUSY);
562 }
544 }
545 CTR4(KTR_BUSDMA, "%s: tag %p tag flags 0x%x error %d",
546 __func__, dmat, dmat->flags, error);
547
548 return (0);
549}
550
551/*

--- 5 unchanged lines hidden (view full) ---

557{
558
559 _busdma_free_dmamap(map);
560 if (STAILQ_FIRST(&map->bpages) != NULL) {
561 CTR3(KTR_BUSDMA, "%s: tag %p error %d",
562 __func__, dmat, EBUSY);
563 return (EBUSY);
564 }
565 if (dmat->bounce_zone)
566 dmat->bounce_zone->map_count--;
563 dmat->map_count--;
564 CTR2(KTR_BUSDMA, "%s: tag %p error 0", __func__, dmat);
565 return (0);
566}
567
568/*
569 * Allocate a piece of memory that can be efficiently mapped into
570 * bus device space based on the constraints lited in the dma tag.

--- 701 unchanged lines hidden (view full) ---

1272
1273 STAILQ_INIT(&bz->bounce_page_list);
1274 bz->free_bpages = 0;
1275 bz->reserved_bpages = 0;
1276 bz->active_bpages = 0;
1277 bz->lowaddr = dmat->lowaddr;
1278 bz->alignment = dmat->alignment;
1279 bz->boundary = dmat->boundary;
567 dmat->map_count--;
568 CTR2(KTR_BUSDMA, "%s: tag %p error 0", __func__, dmat);
569 return (0);
570}
571
572/*
573 * Allocate a piece of memory that can be efficiently mapped into
574 * bus device space based on the constraints lited in the dma tag.

--- 701 unchanged lines hidden (view full) ---

1276
1277 STAILQ_INIT(&bz->bounce_page_list);
1278 bz->free_bpages = 0;
1279 bz->reserved_bpages = 0;
1280 bz->active_bpages = 0;
1281 bz->lowaddr = dmat->lowaddr;
1282 bz->alignment = dmat->alignment;
1283 bz->boundary = dmat->boundary;
1284 bz->map_count = 0;
1280 snprintf(bz->zoneid, 8, "zone%d", busdma_zonecount);
1281 busdma_zonecount++;
1282 snprintf(bz->lowaddrid, 18, "%#jx", (uintmax_t)bz->lowaddr);
1283 STAILQ_INSERT_TAIL(&bounce_zone_list, bz, links);
1284 dmat->bounce_zone = bz;
1285
1286 sysctl_ctx_init(&bz->sysctl_tree);
1287 bz->sysctl_tree_top = SYSCTL_ADD_NODE(&bz->sysctl_tree,

--- 191 unchanged lines hidden ---
1285 snprintf(bz->zoneid, 8, "zone%d", busdma_zonecount);
1286 busdma_zonecount++;
1287 snprintf(bz->lowaddrid, 18, "%#jx", (uintmax_t)bz->lowaddr);
1288 STAILQ_INSERT_TAIL(&bounce_zone_list, bz, links);
1289 dmat->bounce_zone = bz;
1290
1291 sysctl_ctx_init(&bz->sysctl_tree);
1292 bz->sysctl_tree_top = SYSCTL_ADD_NODE(&bz->sysctl_tree,

--- 191 unchanged lines hidden ---