From owner-freebsd-hackers Tue Mar 12 16: 2:56 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from a.mx.canon.com.au (bergeron.research.canon.com.au [203.12.172.124]) by hub.freebsd.org (Postfix) with ESMTP id 9277837B400 for ; Tue, 12 Mar 2002 16:02:50 -0800 (PST) Received: from bellmann.research.canon.com.au (kwanon.research.canon.com.au [203.12.172.254]) by a.mx.canon.com.au (Postfix) with ESMTP id 8C5363391B for ; Wed, 13 Mar 2002 00:02:45 +0000 (GMT) Received: from brixi.research.canon.com.au (brixi.research.canon.com.au [10.8.1.11]) by bellmann.research.canon.com.au (Postfix) with ESMTP id 251088BE3 for ; Wed, 13 Mar 2002 10:39:17 +1100 (EST) Received: by brixi.research.canon.com.au (Postfix, from userid 452) id 0B01F540D0; Wed, 13 Mar 2002 11:02:43 +1100 (EST) Subject: DMA memory allocation/deallocation To: freebsd-hackers@freebsd.org Date: Wed, 13 Mar 2002 11:02:43 +1100 (EST) X-Mailer: ELM [version 2.5 PL6] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20020313000243.0B01F540D0@brixi.research.canon.com.au> From: gjohnson@research.canon.com.au (Greg Johnson) Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Hi there FreeBSD guys, I am having some memory allocation woes in my FreeBSD kernel device driver. I allocate DMAable memory with something like: retval = bus_dma_tag_create ( NULL, 4, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, (1 << 20), 1, (1 << 20), 0, &memtag ); retval = bus_dmamem_alloc ( memtag, (void **) &vaddr, BUS_DMA_WAITOK, &memmap ); retval = bus_dmamap_load ( memtag, memmap, vaddr, (1 << 20), my_callback, NULL, 0 ); which seems to succeed/work. But when I attempt to release the allocated memory like this: bus_dmamap_unload(memtag, memmap); bus_dmamem_free(memtag, (void *) vaddr, memmap); bus_dmamap_destroy(memtag, memmap); bus_dma_tag_destroy(memtag); The actual memory does not seem to get released. If I continually load and unload the driver, the physical addresses allocated keep increasing by the amount I am trying to allocate and never seem to get re-used. In addition, after enough load/unloads 'bus_dmamem_alloc' returns ENOMEM! So to mem it does not look like the deallocation incantation is actually releasing the allocated memory back to the system. Any ideas would be appreciated. Further information: Machine: P4 1.4 GHz 512MB memory OS: FreeBSD 4.5 Thank you. Greg. -- +------------------------------------------------------+ | Do you want to know more? www.geocities.com/worfsom/ | | ..ooOO Greg Johnson OOoo.. | | HW/SW Engineer gjohnson@research.canon.COM.Au | | Canon Information Systems Research Australia (CISRA) | | 1 Thomas Holt Dr., North Ryde, NSW, 2113, Australia | | "I FLEXed my BISON and it went YACC!" - me. | +------------------------------------------------------+ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message