From owner-freebsd-current@FreeBSD.ORG Tue Jun 30 05:13:42 2009 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C8E891065670 for ; Tue, 30 Jun 2009 05:13:42 +0000 (UTC) (envelope-from alc@cs.rice.edu) Received: from mail.cs.rice.edu (mail.cs.rice.edu [128.42.1.31]) by mx1.freebsd.org (Postfix) with ESMTP id 9229B8FC0A for ; Tue, 30 Jun 2009 05:13:42 +0000 (UTC) (envelope-from alc@cs.rice.edu) Received: from mail.cs.rice.edu (localhost.localdomain [127.0.0.1]) by mail.cs.rice.edu (Postfix) with ESMTP id B91692C2AD0; Tue, 30 Jun 2009 00:13:41 -0500 (CDT) X-Virus-Scanned: by amavis-2.4.0 at mail.cs.rice.edu Received: from mail.cs.rice.edu ([127.0.0.1]) by mail.cs.rice.edu (mail.cs.rice.edu [127.0.0.1]) (amavisd-new, port 10024) with LMTP id MdbdDKejuXs7; Tue, 30 Jun 2009 00:13:34 -0500 (CDT) Received: from adsl-216-63-78-18.dsl.hstntx.swbell.net (adsl-216-63-78-18.dsl.hstntx.swbell.net [216.63.78.18]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.cs.rice.edu (Postfix) with ESMTP id ADA732C2A8E; Tue, 30 Jun 2009 00:13:33 -0500 (CDT) Message-ID: <4A499EFD.9080509@cs.rice.edu> Date: Tue, 30 Jun 2009 00:13:33 -0500 From: Alan Cox User-Agent: Thunderbird 2.0.0.22 (X11/20090626) MIME-Version: 1.0 To: Hans Petter Selasky References: <200906292005.18629.hselasky@c2i.net> <4A4907AE.1080303@cs.rice.edu> <200906292130.16718.hselasky@c2i.net> In-Reply-To: <200906292130.16718.hselasky@c2i.net> Content-Type: multipart/mixed; boundary="------------050406050609020409080608" Cc: freebsd-current@freebsd.org, Alan Cox Subject: Re: Contigmalloc regression seen on latest 7.x and 8.x branches X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Jun 2009 05:13:43 -0000 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: 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--