From owner-freebsd-arch@FreeBSD.ORG Sun Apr 26 20:08:32 2015 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id BD0285B4 for ; Sun, 26 Apr 2015 20:08:32 +0000 (UTC) Received: from mail-ig0-x22c.google.com (mail-ig0-x22c.google.com [IPv6:2607:f8b0:4001:c05::22c]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 85D391C5A for ; Sun, 26 Apr 2015 20:08:32 +0000 (UTC) Received: by igblo3 with SMTP id lo3so47489264igb.0 for ; Sun, 26 Apr 2015 13:08:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=ew0Pl0XNmqlrtlmVQVnPc6VrSdMW/fv2qSkUlO+6kxs=; b=R4dkHDhHs1q//jbNSohF1lTMWlGN0osEnGlEwx0KKEi8Yc5Nwol2j0uzj6D5l4WK2b smiXJqs5WibhKV+96DI4MtI0nyBJG08FBoh7gMAqZKPwurjeQ2y8j4YpSJp8RL7mRm9r jzRyDLWOwFiADB0yLlghS532uJ41rXuLARxTapoj3QfZN+OeGmwpQnjM6ywJPHyc+N5U N/aoPSeb4Y1faeCEyUol6eQzwm0dyBXWYyGmgZyFsMM/1EU55bHWfzutWZMoLWJyxumy 7IFXImhmdGpGCXnmZJsf3kiYaPxUAOOfOnn9r+WStPY7oUMUjqu4WQKtCwCxWRlRF9W3 WUiA== MIME-Version: 1.0 X-Received: by 10.50.102.68 with SMTP id fm4mr9502079igb.25.1430078911984; Sun, 26 Apr 2015 13:08:31 -0700 (PDT) Received: by 10.64.13.81 with HTTP; Sun, 26 Apr 2015 13:08:31 -0700 (PDT) In-Reply-To: <20150425172833.GM2390@kib.kiev.ua> References: <20150425094152.GE2390@kib.kiev.ua> <553B9E64.8030907@gmail.com> <20150425163444.GL2390@kib.kiev.ua> <553BC9D1.1070502@gmail.com> <20150425172833.GM2390@kib.kiev.ua> Date: Sun, 26 Apr 2015 22:08:31 +0200 Message-ID: Subject: Re: bus_dmamap_sync() for bounced client buffers from user address space From: Svatopluk Kraus To: Konstantin Belousov Cc: Jason Harmening , FreeBSD Arch Content-Type: text/plain; charset=UTF-8 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: Sun, 26 Apr 2015 20:08:32 -0000 On Sat, Apr 25, 2015 at 7:28 PM, Konstantin Belousov wrote: > 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. > > But if the buffer bounces, then some KVA must be allocated temporarily for physcopyin/physcopyout. FYI, we are in the following situation in ARM arch. (1) The DMA in not cache coherent, and (2) cache maintainance operations are done on virtual addresses. It means that cache maintainance must be done for cached memory. Moreover, it must be done even for unmapped buffers and they must be mapped for that. Thus it could be of much help if we can used UVA for that if context is correct.