tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
pmap nocache
Hi,
Attached x86_nocache.diff removes the TLB flush
when mapping dma-safe memory.
Attached pmap_md.diff adds a PMAP_MD_MASK.
For x86 PAT feature you need six MD PMAP types.
Comments?
Christoph
Index: sys/uvm/uvm_pmap.h
===================================================================
RCS file: /cvsroot/src/sys/uvm/uvm_pmap.h,v
retrieving revision 1.25
diff -u -p -r1.25 uvm_pmap.h
--- sys/uvm/uvm_pmap.h 10 Dec 2008 11:10:20 -0000 1.25
+++ sys/uvm/uvm_pmap.h 16 Apr 2009 20:26:53 -0000
@@ -99,6 +99,9 @@ typedef struct pmap_statistics *pmap_sta
*/
#define PMAP_WIRED 0x00000010 /* wired mapping */
#define PMAP_CANFAIL 0x00000020 /* can fail if resource
shortage */
+
+#define PMAP_MD_MASK 0x0000ff00 /* Machine-dependent bits */
+
/*
* Flags passed to pmap_kenter_pa(). Note the bottom 3 bits are VM_PROT_*
* bits, used to indicate the access type.
Index: sys/arch/x86/include/pmap.h
===================================================================
RCS file: /cvsroot/src/sys/arch/x86/include/pmap.h,v
retrieving revision 1.22
diff -u -p -r1.22 pmap.h
--- sys/arch/x86/include/pmap.h 21 Mar 2009 14:41:30 -0000 1.22
+++ sys/arch/x86/include/pmap.h 16 Apr 2009 20:26:51 -0000
@@ -176,6 +176,11 @@ struct pmap {
#endif
/*
+ * MD flags that we use for pmap_enter:
+ */
+#define PMAP_NOCACHE 0x00000100 /* set the non-cacheable bit */
+
+/*
* global kernel variables
*/
Index: sys/arch/x86/x86/bus_dma.c
===================================================================
RCS file: /cvsroot/src/sys/arch/x86/x86/bus_dma.c,v
retrieving revision 1.49
diff -u -p -r1.49 bus_dma.c
--- sys/arch/x86/x86/bus_dma.c 14 Mar 2009 14:46:08 -0000 1.49
+++ sys/arch/x86/x86/bus_dma.c 16 Apr 2009 20:26:51 -0000
@@ -1017,26 +1017,23 @@ int
_bus_dmamem_map(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs,
size_t size, void **kvap, int flags)
{
- vaddr_t sva, va, eva;
+ vaddr_t va;
bus_addr_t addr;
int curseg;
- int nocache;
- pt_entry_t *pte, opte, xpte;
const uvm_flag_t kmflags =
(flags & BUS_DMA_NOWAIT) != 0 ? UVM_KMF_NOWAIT : 0;
+ int pmapflags = PMAP_WIRED | VM_PROT_READ | VM_PROT_WRITE;
size = round_page(size);
- nocache = (flags & BUS_DMA_NOCACHE) != 0;
+ if (flags & BUS_DMA_NOCACHE)
+ pmapflags |= PMAP_NOCACHE;
va = uvm_km_alloc(kernel_map, size, 0, UVM_KMF_VAONLY | kmflags);
if (va == 0)
- return (ENOMEM);
+ return ENOMEM;
*kvap = (void *)va;
- sva = va;
- eva = sva + size;
- xpte = 0;
for (curseg = 0; curseg < nsegs; curseg++) {
for (addr = segs[curseg].ds_addr;
@@ -1046,30 +1043,12 @@ _bus_dmamem_map(bus_dma_tag_t t, bus_dma
panic("_bus_dmamem_map: size botch");
_BUS_PMAP_ENTER(pmap_kernel(), va, addr,
VM_PROT_READ | VM_PROT_WRITE,
- PMAP_WIRED | VM_PROT_READ | VM_PROT_WRITE);
- /*
- * mark page as non-cacheable
- */
- if (nocache) {
- pte = kvtopte(va);
- opte = *pte;
- if ((opte & PG_N) == 0) {
- pmap_pte_setbits(pte, PG_N);
- xpte |= opte;
- }
- }
+ pmapflags);
}
}
-#ifndef XEN /* XXX */
- if ((xpte & (PG_V | PG_U)) == (PG_V | PG_U)) {
- kpreempt_disable();
- pmap_tlb_shootdown(pmap_kernel(), sva, eva, xpte);
- kpreempt_enable();
- }
pmap_update(pmap_kernel());
-#endif
- return (0);
+ return 0;
}
/*
Index: sys/arch/x86/x86/pmap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/x86/x86/pmap.c,v
retrieving revision 1.82
diff -u -p -r1.82 pmap.c
--- sys/arch/x86/x86/pmap.c 21 Mar 2009 22:55:08 -0000 1.82
+++ sys/arch/x86/x86/pmap.c 16 Apr 2009 20:26:52 -0000
@@ -4044,6 +4044,8 @@ pmap_enter(struct pmap *pmap, vaddr_t va
npte = ma | protection_codes[prot] | PG_V;
if (wired)
npte |= PG_W;
+ if (flags & PMAP_NOCACHE)
+ npte |= PG_N;
if (va < VM_MAXUSER_ADDRESS)
npte |= PG_u;
else if (va < VM_MAX_ADDRESS)
Home |
Main Index |
Thread Index |
Old Index