Re: Contigmalloc regression seen on latest 7.x and 8.x branches

From: Alan Cox <alc_at_cs.rice.edu>
Date: Tue, 30 Jun 2009 00:13:33 -0500
Hans Petter Selasky wrote:
> On Monday 29 June 2009 20:27:58 Alan Cox wrote:
>   
>> "ret" is a virtual address.  What is the underlying physical address?
>>     
>
> Hi,
>
> It looks like the physical address is correct according to my printouts.
>
> The regression issue boils down to misleading printouts from the following 
> files, which should/can then be removed:
>
> /usr/8-current/src/sys/amd64/amd64/busdma_machdep.c:            
> printf("bus_dmamem_alloc failed to align memory properly.\n");
> /usr/8-current/src/sys/i386/i386/busdma_machdep.c:              
> printf("bus_dmamem_alloc failed to align memory properly.\n");
> /usr/8-current/src/sys/ia64/ia64/busdma_machdep.c:              
> printf("bus_dmamem_alloc failed to align memory properly.\n");
>
> contigmalloc: size=0x00008000, flag=2, low=0x00000000 high=0xffffffff 
> alignment=0x00008000 boundary=
> 0x00000000
> contigmalloc: ret=0xe5af2000
> contigmalloc: vtophys(ret)=0x01670000
> contigmalloc: vtophys(ret)=0x01671000
> contigmalloc: vtophys(ret)=0x01672000
> contigmalloc: vtophys(ret)=0x01673000
> contigmalloc: vtophys(ret)=0x01674000
> contigmalloc: vtophys(ret)=0x01675000
> contigmalloc: vtophys(ret)=0x01676000
> contigmalloc: vtophys(ret)=0x01677000
> bus_dmamem_alloc failed to align memory properly.
> bus_dmamem_alloc = 0
> pg->physaddr = 0x01670000, nseg=1
> bus_dmamap_load = 0
> 0x01670000, 0xe5af2000
> ihfc1: <HFC-2BDS0 128K PCI ISDN adapter> port 0xa400-0xa407 mem 
> 0xf5004000-0xf50040ff irq 18 at devi
> ce 8.0 on pci1
> ihfc1: [ITHREAD]
> ihfc1: Attaching I4B controller 1.
> ihfc1: Creating /dev/ihfc1.X.
>
>   

After looking at r159130 and the comments in the code, I don't think it 
would be appropriate to remove the printf()s.  However, the logic that 
determines whether printf() is called is flawed.  I believe that the 
attached patch should eliminate the incorrect printf()s that you are seeing.

Regards,
Alan


Index: amd64/amd64/busdma_machdep.c
===================================================================
--- amd64/amd64/busdma_machdep.c	(revision 195132)
+++ amd64/amd64/busdma_machdep.c	(working copy)
_at__at_ -527,7 +527,7 _at__at_
 		CTR4(KTR_BUSDMA, "%s: tag %p tag flags 0x%x error %d",
 		    __func__, dmat, dmat->flags, ENOMEM);
 		return (ENOMEM);
-	} else if ((uintptr_t)*vaddr & (dmat->alignment - 1)) {
+	} else if (pmap_kextract((vm_offset_t)*vaddr) & (dmat->alignment - 1)) {
 		printf("bus_dmamem_alloc failed to align memory properly.\n");
 	}
 	if (flags & BUS_DMA_NOCACHE)
Index: i386/i386/busdma_machdep.c
===================================================================
--- i386/i386/busdma_machdep.c	(revision 195132)
+++ i386/i386/busdma_machdep.c	(working copy)
_at__at_ -540,7 +540,7 _at__at_
 		CTR4(KTR_BUSDMA, "%s: tag %p tag flags 0x%x error %d",
 		    __func__, dmat, dmat->flags, ENOMEM);
 		return (ENOMEM);
-	} else if ((uintptr_t)*vaddr & (dmat->alignment - 1)) {
+	} else if (pmap_kextract((vm_offset_t)*vaddr) & (dmat->alignment - 1)) {
 		printf("bus_dmamem_alloc failed to align memory properly.\n");
 	}
 	if (flags & BUS_DMA_NOCACHE)
Index: ia64/ia64/busdma_machdep.c
===================================================================
--- ia64/ia64/busdma_machdep.c	(revision 195132)
+++ ia64/ia64/busdma_machdep.c	(working copy)
_at__at_ -455,7 +455,7 _at__at_
 	}
 	if (*vaddr == NULL)
 		return (ENOMEM);
-	else if ((uintptr_t)*vaddr & (dmat->alignment - 1))
+	else if (pmap_kextract((vm_offset_t)*vaddr) & (dmat->alignment - 1))
 		printf("bus_dmamem_alloc failed to align memory properly.\n");
 	return (0);
 }
Received on Tue Jun 30 2009 - 03:13:42 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:50 UTC