From owner-freebsd-arch@FreeBSD.ORG Sat Apr 25 17:28:40 2015 Return-Path: Delivered-To: freebsd-arch@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 8D256C5B for ; Sat, 25 Apr 2015 17:28:40 +0000 (UTC) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F34A91691 for ; Sat, 25 Apr 2015 17:28:39 +0000 (UTC) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.14.9/8.14.9) with ESMTP id t3PHSYbL018846 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Sat, 25 Apr 2015 20:28:34 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.9.2 kib.kiev.ua t3PHSYbL018846 Received: (from kostik@localhost) by tom.home (8.14.9/8.14.9/Submit) id t3PHSXJn018845; Sat, 25 Apr 2015 20:28:33 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sat, 25 Apr 2015 20:28:33 +0300 From: Konstantin Belousov To: Jason Harmening Cc: Svatopluk Kraus , FreeBSD Arch Subject: Re: bus_dmamap_sync() for bounced client buffers from user address space Message-ID: <20150425172833.GM2390@kib.kiev.ua> References: <20150425094152.GE2390@kib.kiev.ua> <553B9E64.8030907@gmail.com> <20150425163444.GL2390@kib.kiev.ua> <553BC9D1.1070502@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <553BC9D1.1070502@gmail.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on tom.home X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Apr 2015 17:28:40 -0000 On Sat, Apr 25, 2015 at 12:07:29PM -0500, Jason Harmening wrote: > > On 04/25/15 11:34, Konstantin Belousov wrote: > > I believe UIO_USERSPACE is almost unused, it might be there for some > > obscure (and buggy) driver. > It may be nearly unused, but we still document it in busdma.9, and we > still explicitly check for it when setting the pmap in > _bus_dmamap_load_uio. If it's not safe to use, then it's not OK for us > to do that. > We need to either a) remove support for it by adding a failure/KASSERT > on UIO_USERSPACE in _busdmamap_load_uio() and remove the paragraph on it > from busdma.9, or b) make it safe. > > I'd be in favor of b), because I think it is still valid to support some > non-painful way of using DMA with userspace buffers. Right now, the > only safe way to do that seems to be: > 1) vm_fault_quick_hold_pages > 2) kva_alloc > 3) pmap_qenter > 4) bus_dmamap_load 1. vm_fault_quick_hold 2. bus_dmamap_load_ma > > That seems both unnecessarily complex and wasteful of KVA space. > The above sequence does not need a KVA allocation.