svn commit: r251873 - stable/9/sys/arm/arm
Scott Long
scottl at FreeBSD.org
Mon Jun 17 23:21:19 UTC 2013
Author: scottl
Date: Mon Jun 17 23:21:18 2013
New Revision: 251873
URL: http://svnweb.freebsd.org/changeset/base/251873
Log:
MFC r244575:
The manpage states that bus_dmamap_create(9) returns ENOMEM if it can't
allocate a map or mapping resources. That seems to imply that any memory
allocations it does must use M_NOWAIT and check for NULL.
MFC 246158:
Use pmap_kextract() instead of inlining the page table walk.
Remove the comment referencing non-existing code.
Submitted by: kib, cognet
Approved by: marius
Obtained from: Netflix
Modified:
stable/9/sys/arm/arm/busdma_machdep.c
Directory Properties:
stable/9/sys/ (props changed)
Modified: stable/9/sys/arm/arm/busdma_machdep.c
==============================================================================
--- stable/9/sys/arm/arm/busdma_machdep.c Mon Jun 17 22:59:47 2013 (r251872)
+++ stable/9/sys/arm/arm/busdma_machdep.c Mon Jun 17 23:21:18 2013 (r251873)
@@ -567,16 +567,24 @@ bus_dmamap_create(bus_dma_tag_t dmat, in
bus_dmamap_t map;
int error = 0;
- map = uma_zalloc_arg(dmamap_zone, dmat, M_WAITOK);
+ map = uma_zalloc_arg(dmamap_zone, dmat, M_NOWAIT);
*mapp = map;
+ if (map == NULL)
+ return (ENOMEM);
/*
* If the tag's segments haven't been allocated yet we need to do it
* now, because we can't sleep for resources at map load time.
*/
- if (dmat->segments == NULL)
+ if (dmat->segments == NULL) {
dmat->segments = malloc(dmat->nsegments *
- sizeof(*dmat->segments), M_DEVBUF, M_WAITOK);
+ sizeof(*dmat->segments), M_DEVBUF, M_NOWAIT);
+ if (dmat->segments == NULL) {
+ uma_zfree(dmamap_zone, map);
+ *mapp = NULL;
+ return (ENOMEM);
+ }
+ }
/*
* Bouncing might be required if the driver asks for an active
@@ -841,9 +849,6 @@ bus_dmamap_load_buffer(bus_dma_tag_t dma
vm_offset_t vaddr = (vm_offset_t)buf;
int seg;
int error = 0;
- pd_entry_t *pde;
- pt_entry_t pte;
- pt_entry_t *ptep;
lastaddr = *lastaddrp;
bmask = ~(dmat->boundary - 1);
@@ -860,34 +865,9 @@ bus_dmamap_load_buffer(bus_dma_tag_t dma
for (seg = *segp; buflen > 0 ; ) {
/*
* Get the physical address for this segment.
- *
- * XXX Don't support checking for coherent mappings
- * XXX in user address space.
*/
if (__predict_true(pmap == pmap_kernel())) {
- if (pmap_get_pde_pte(pmap, vaddr, &pde, &ptep) == FALSE)
- return (EFAULT);
-
- if (__predict_false(pmap_pde_section(pde))) {
- if (*pde & L1_S_SUPERSEC)
- curaddr = (*pde & L1_SUP_FRAME) |
- (vaddr & L1_SUP_OFFSET);
- else
- curaddr = (*pde & L1_S_FRAME) |
- (vaddr & L1_S_OFFSET);
- } else {
- pte = *ptep;
- KASSERT((pte & L2_TYPE_MASK) != L2_TYPE_INV,
- ("INV type"));
- if (__predict_false((pte & L2_TYPE_MASK)
- == L2_TYPE_L)) {
- curaddr = (pte & L2_L_FRAME) |
- (vaddr & L2_L_OFFSET);
- } else {
- curaddr = (pte & L2_S_FRAME) |
- (vaddr & L2_S_OFFSET);
- }
- }
+ curaddr = pmap_kextract(vaddr);
} else {
curaddr = pmap_extract(pmap, vaddr);
map->flags &= ~DMAMAP_COHERENT;
More information about the svn-src-stable-9
mailing list