From owner-freebsd-hackers@FreeBSD.ORG Fri Jan 8 14:14:38 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4B05F1065670 for ; Fri, 8 Jan 2010 14:14:38 +0000 (UTC) (envelope-from tinguely@casselton.net) Received: from casselton.net (casselton.net [63.165.140.2]) by mx1.freebsd.org (Postfix) with ESMTP id 072DB8FC15 for ; Fri, 8 Jan 2010 14:14:37 +0000 (UTC) Received: from casselton.net (localhost [127.0.0.1]) by casselton.net (8.14.3/8.14.3) with ESMTP id o08EEaar053149; Fri, 8 Jan 2010 08:14:36 -0600 (CST) (envelope-from tinguely@casselton.net) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=casselton.net; s=ccnMail; t=1262960077; bh=7hdP1o7tbkuEyU9slUmlkuTMW0JCB08bfW7DM105mYY=; h=Date:From:Message-Id:To:Subject:Cc:In-Reply-To; b=L9EUoxaJREt5eM8knriXcJ4auY/T09HctmxWe9GtkH5SJnZTX70engtSfzPGZQVRq /PhtIePZWC/hj2vzPSYG40jHy+iPJh+n6HWlqSDv6QB5/udRibuGD1cF4G/pB6qy7C aDqpPL/gjiaFxd/YCksCGApLYPCNAHGvQ1I8REA8= Received: (from tinguely@localhost) by casselton.net (8.14.3/8.14.2/Submit) id o08EEaBM053148; Fri, 8 Jan 2010 08:14:36 -0600 (CST) (envelope-from tinguely) Date: Fri, 8 Jan 2010 08:14:36 -0600 (CST) From: Mark Tinguely Message-Id: <201001081414.o08EEaBM053148@casselton.net> To: freebsd-hackers@freebsd.org, jhb@freebsd.org In-Reply-To: <201001080833.49246.jhb@freebsd.org> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.3.2 (casselton.net [127.0.0.1]); Fri, 08 Jan 2010 08:14:37 -0600 (CST) X-Mailman-Approved-At: Fri, 08 Jan 2010 14:22:55 +0000 Cc: tinguely@casselton.net Subject: Re: bus_dmamap_load_uio() and user data X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Jan 2010 14:14:38 -0000 > You should use the pmap from the thread in the uio structure. Similar to > this from the x86 bus_dma code: > > if (uio->uio_segflg == UIO_USERSPACE) { > KASSERT(uio->uio_td != NULL, > ("bus_dmamap_load_uio: USERSPACE but no proc")); > pmap = vmspace_pmap(uio->uio_td->td_proc->p_vmspace); > } else > pmap = NULL; > > Later when doing VA -> PA conversions the code does this: > > if (pmap) > paddr = pmap_extract(pmap, vaddr); > else > paddr = pmap_kextract(vaddr); > We do that, but I notice that all the architecture that implement bounce buffers assume the VA is in the current map. Most of the addresses are KVA, but bus_dmamap_load_uio() can be in the user space. I was wondering about the sequence: bus_dmamap_load_uio() user space dma_load_buffer() add bounce page save UVA (in caller user map) later: bus_dma_sync copies bounce buffer from saved UVA. <- here is my concern. The user pmap is not remembered use current pmap. Since the bounce buffer copy routines have been running in other architectures for years without corruption, I was wondering we can safely assume that the dma sync is running in the same thread/address space as the bus_dmamap_load_uio call. I was hoping you would say, don't worry the scheduler would always reload the same thread to execute the dma sync code ... Thank-you, --Mark Tinguely