From owner-svn-src-head@FreeBSD.ORG Wed Sep 15 17:11:16 2010 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 20E5A106564A; Wed, 15 Sep 2010 17:11:16 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 110778FC18; Wed, 15 Sep 2010 17:11:16 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o8FHBFAK043819; Wed, 15 Sep 2010 17:11:15 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o8FHBFQu043816; Wed, 15 Sep 2010 17:11:15 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201009151711.o8FHBFQu043816@svn.freebsd.org> From: Marius Strobl Date: Wed, 15 Sep 2010 17:11:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r212676 - in head/sys: sparc64/sparc64 sun4v/sun4v X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Sep 2010 17:11:16 -0000 Author: marius Date: Wed Sep 15 17:11:15 2010 New Revision: 212676 URL: http://svn.freebsd.org/changeset/base/212676 Log: Sync with other platforms: - make dflt_lock() always panic, - add kludge to use contigmalloc() when the alignment is larger than the size and print a diagnostic when we didn't satisfy the alignment. Modified: head/sys/sparc64/sparc64/bus_machdep.c head/sys/sun4v/sun4v/bus_machdep.c Modified: head/sys/sparc64/sparc64/bus_machdep.c ============================================================================== --- head/sys/sparc64/sparc64/bus_machdep.c Wed Sep 15 16:42:57 2010 (r212675) +++ head/sys/sparc64/sparc64/bus_machdep.c Wed Sep 15 17:11:15 2010 (r212676) @@ -182,11 +182,8 @@ busdma_lock_mutex(void *arg, bus_dma_loc static void dflt_lock(void *arg, bus_dma_lock_op_t op) { -#ifdef INVARIANTS + panic("driver error: busdma dflt_lock called"); -#else - printf("DRIVER_ERROR: busdma dflt_lock called\n"); -#endif } /* @@ -631,9 +628,18 @@ nexus_dmamem_alloc(bus_dma_tag_t dmat, v if (flags & BUS_DMA_ZERO) mflags |= M_ZERO; - if ((dmat->dt_maxsize <= PAGE_SIZE)) { + /* + * XXX: + * (dmat->dt_alignment < dmat->dt_maxsize) is just a quick hack; the + * exact alignment guarantees of malloc need to be nailed down, and + * the code below should be rewritten to take that into account. + * + * In the meantime, we'll warn the user if malloc gets it wrong. + */ + if (dmat->dt_maxsize <= PAGE_SIZE && + dmat->dt_alignment < dmat->dt_maxsize) *vaddr = malloc(dmat->dt_maxsize, M_DEVBUF, mflags); - } else { + else { /* * XXX use contigmalloc until it is merged into this * facility and handles multi-seg allocations. Nobody @@ -646,6 +652,8 @@ nexus_dmamem_alloc(bus_dma_tag_t dmat, v } if (*vaddr == NULL) return (ENOMEM); + if ((uintptr_t)*vaddr % dmat->dt_alignment) + printf("%s: failed to align memory properly.\n", __func__); return (0); } @@ -657,11 +665,11 @@ static void nexus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map) { - if ((dmat->dt_maxsize <= PAGE_SIZE)) + if (dmat->dt_maxsize <= PAGE_SIZE && + dmat->dt_alignment < dmat->dt_maxsize) free(vaddr, M_DEVBUF); - else { + else contigfree(vaddr, dmat->dt_maxsize, M_DEVBUF); - } } struct bus_dma_methods nexus_dma_methods = { Modified: head/sys/sun4v/sun4v/bus_machdep.c ============================================================================== --- head/sys/sun4v/sun4v/bus_machdep.c Wed Sep 15 16:42:57 2010 (r212675) +++ head/sys/sun4v/sun4v/bus_machdep.c Wed Sep 15 17:11:15 2010 (r212676) @@ -181,11 +181,8 @@ busdma_lock_mutex(void *arg, bus_dma_loc static void dflt_lock(void *arg, bus_dma_lock_op_t op) { -#ifdef INVARIANTS + panic("driver error: busdma dflt_lock called"); -#else - printf("DRIVER_ERROR: busdma dflt_lock called\n"); -#endif } /* @@ -647,9 +644,18 @@ nexus_dmamem_alloc(bus_dma_tag_t dmat, v if (flags & BUS_DMA_ZERO) mflags |= M_ZERO; - if ((dmat->dt_maxsize <= PAGE_SIZE)) { + /* + * XXX: + * (dmat->dt_alignment < dmat->dt_maxsize) is just a quick hack; the + * exact alignment guarantees of malloc need to be nailed down, and + * the code below should be rewritten to take that into account. + * + * In the meantime, we'll warn the user if malloc gets it wrong. + */ + if (dmat->dt_maxsize <= PAGE_SIZE && + dmat->dt_alignment < dmat->dt_maxsize) *vaddr = malloc(dmat->dt_maxsize, M_DEVBUF, mflags); - } else { + else { /* * XXX use contigmalloc until it is merged into this * facility and handles multi-seg allocations. Nobody @@ -662,6 +668,8 @@ nexus_dmamem_alloc(bus_dma_tag_t dmat, v } if (*vaddr == NULL) return (ENOMEM); + if ((uintptr_t)*vaddr % dmat->dt_alignment) + printf("%s: failed to align memory properly.\n", __func__); return (0); } @@ -673,11 +681,11 @@ static void nexus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map) { - if ((dmat->dt_maxsize <= PAGE_SIZE)) + if (dmat->dt_maxsize <= PAGE_SIZE && + dmat->dt_alignment < dmat->dt_maxsize) free(vaddr, M_DEVBUF); - else { + else contigfree(vaddr, dmat->dt_maxsize, M_DEVBUF); - } } struct bus_dma_methods nexus_dma_methods = {