bud_dmamap_load_buffer()

Konstantin Belousov kostikbel at gmail.com
Thu Jan 31 19:24:31 UTC 2013


I noted that arm/busdma_machdep.c uses essentially inlined pmap_kextract()
to get the physical address from the kernel address.  I consulted with
gonzo, who said that he does not see a reason for inlining the code.

My theory is that before r240983, pmap_kextract() locked the pmap, which
caused unneeded and probably wrong locking in the busdma load path. Since
this issue is fixed, I see no reason for directly walking the page tables.

Could somebody please review and test the patch ? v6 busdma already uses
pmap_kextract().

Do not remove me from Cc:.

diff --git a/sys/arm/arm/busdma_machdep.c b/sys/arm/arm/busdma_machdep.c
index 42566e8..8f49300 100644
--- a/sys/arm/arm/busdma_machdep.c
+++ b/sys/arm/arm/busdma_machdep.c
@@ -849,9 +849,6 @@ bus_dmamap_load_buffer(bus_dma_tag_t dmat, bus_dma_segment_t *segs,
 	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);
@@ -873,29 +870,7 @@ bus_dmamap_load_buffer(bus_dma_tag_t dmat, bus_dma_segment_t *segs,
 		 * 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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 834 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-arm/attachments/20130131/ac653ec6/attachment.sig>


More information about the freebsd-arm mailing list