Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 30 Jun 2009 00:13:33 -0500
From:      Alan Cox <alc@cs.rice.edu>
To:        Hans Petter Selasky <hselasky@c2i.net>
Cc:        freebsd-current@freebsd.org, Alan Cox <alc@cs.rice.edu>
Subject:   Re: Contigmalloc regression seen on latest 7.x and 8.x branches
Message-ID:  <4A499EFD.9080509@cs.rice.edu>
In-Reply-To: <200906292130.16718.hselasky@c2i.net>
References:  <200906292005.18629.hselasky@c2i.net> <4A4907AE.1080303@cs.rice.edu> <200906292130.16718.hselasky@c2i.net>

next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------050406050609020409080608
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

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


--------------050406050609020409080608
Content-Type: text/plain;
 name="align.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="align.patch"

Index: amd64/amd64/busdma_machdep.c
===================================================================
--- amd64/amd64/busdma_machdep.c	(revision 195132)
+++ amd64/amd64/busdma_machdep.c	(working copy)
@@ -527,7 +527,7 @@
 		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)
@@ -540,7 +540,7 @@
 		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)
@@ -455,7 +455,7 @@
 	}
 	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);
 }

--------------050406050609020409080608--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4A499EFD.9080509>