From owner-svn-src-all@FreeBSD.ORG Wed Jun 10 22:33:57 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 82C33EC6; Wed, 10 Jun 2015 22:33:57 +0000 (UTC) (envelope-from marcel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 571D4188F; Wed, 10 Jun 2015 22:33:57 +0000 (UTC) (envelope-from marcel@FreeBSD.org) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t5AMXv0m017121; Wed, 10 Jun 2015 22:33:57 GMT (envelope-from marcel@FreeBSD.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t5AMXucv017119; Wed, 10 Jun 2015 22:33:56 GMT (envelope-from marcel@FreeBSD.org) Message-Id: <201506102233.t5AMXucv017119@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: marcel set sender to marcel@FreeBSD.org using -f From: Marcel Moolenaar Date: Wed, 10 Jun 2015 22:33:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r284246 - head/sys/dev/proto X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Jun 2015 22:33:57 -0000 Author: marcel Date: Wed Jun 10 22:33:56 2015 New Revision: 284246 URL: https://svnweb.freebsd.org/changeset/base/284246 Log: Load the allocated memory and return both the physical address and the bus address to the application. Modified: head/sys/dev/proto/proto_busdma.c head/sys/dev/proto/proto_dev.h Modified: head/sys/dev/proto/proto_busdma.c ============================================================================== --- head/sys/dev/proto/proto_busdma.c Wed Jun 10 20:43:07 2015 (r284245) +++ head/sys/dev/proto/proto_busdma.c Wed Jun 10 22:33:56 2015 (r284246) @@ -129,6 +129,16 @@ proto_busdma_tag_lookup(struct proto_bus return (NULL); } +static void +proto_busdma_mem_alloc_callback(void *arg, bus_dma_segment_t *segs, int nseg, + int error) +{ + struct proto_ioc_busdma *ioc = arg; + + ioc->u.mem.bus_nsegs = nseg; + ioc->u.mem.bus_addr = segs[0].ds_addr; +} + static int proto_busdma_mem_alloc(struct proto_busdma *busdma, struct proto_tag *tag, struct proto_ioc_busdma *ioc) @@ -153,10 +163,18 @@ proto_busdma_mem_alloc(struct proto_busd return (error); } md->physaddr = pmap_kextract((uintptr_t)(md->virtaddr)); + error = bus_dmamap_load(md->bd_tag, md->bd_map, md->virtaddr, + tag->maxsz, proto_busdma_mem_alloc_callback, ioc, BUS_DMA_NOWAIT); + if (error) { + bus_dmamem_free(md->bd_tag, md->virtaddr, md->bd_map); + bus_dma_tag_destroy(md->bd_tag); + free(md, M_PROTO_BUSDMA); + return (error); + } LIST_INSERT_HEAD(&tag->mds, md, peers); LIST_INSERT_HEAD(&busdma->mds, md, mds); - ioc->u.mem.nsegs = 1; - ioc->u.mem.physaddr = md->physaddr; + ioc->u.mem.phys_nsegs = 1; + ioc->u.mem.phys_addr = md->physaddr; ioc->result = (uintptr_t)(void *)md; return (0); } Modified: head/sys/dev/proto/proto_dev.h ============================================================================== --- head/sys/dev/proto/proto_dev.h Wed Jun 10 20:43:07 2015 (r284245) +++ head/sys/dev/proto/proto_dev.h Wed Jun 10 22:33:56 2015 (r284246) @@ -62,8 +62,10 @@ struct proto_ioc_busdma { struct { unsigned long tag; unsigned int flags; - unsigned int nsegs; - unsigned long physaddr; + unsigned int phys_nsegs; + unsigned long phys_addr; + unsigned long bus_addr; + unsigned int bus_nsegs; } mem; } u; unsigned long result;