From owner-freebsd-multimedia@FreeBSD.ORG Mon May 9 15:58:24 2011 Return-Path: Delivered-To: multimedia@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 11BA4106566C; Mon, 9 May 2011 15:58:24 +0000 (UTC) (envelope-from alan.l.cox@gmail.com) Received: from mail-iw0-f182.google.com (mail-iw0-f182.google.com [209.85.214.182]) by mx1.freebsd.org (Postfix) with ESMTP id A04BC8FC13; Mon, 9 May 2011 15:58:23 +0000 (UTC) Received: by iwn33 with SMTP id 33so6283675iwn.13 for ; Mon, 09 May 2011 08:58:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:reply-to:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=K5KWMsr9WmnpIDFNhHFnqkFvoXQPsnKJSkkMySXcFoI=; b=bLSVjWYsa5VEvlK7B4Hz8jjb7YE5her0PO8Yt3SEqrBhoq7wuYtB1KoI4TYwACZJg2 D8nuaO+/NacjBXQ/VSkOjutDhFOiKurpurkVE6MT2Z4zVeixYK7uRb/E6Eu5wHjzWpYJ RyODwINNpbSJnJbDhjtmWRkYiIA+9949j9MXA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:reply-to:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; b=J3194H/egRmv3M6t7aeBlWZejtUmwTwf2sJ7/jXG8LskjUQhivpYtDJL9+Q5xR5RNw qkEpCAPU9ZR/u3MqMfHuBfRVm8swbDEd14gHtz7xhsqQn6sLvEwnky35ge5errq/SXj0 fajMUgCJF5905TVtqVPIizs9Kg5C1A6J40jmY= MIME-Version: 1.0 Received: by 10.42.130.72 with SMTP id u8mr6128043ics.379.1304955307841; Mon, 09 May 2011 08:35:07 -0700 (PDT) Received: by 10.42.165.5 with HTTP; Mon, 9 May 2011 08:35:07 -0700 (PDT) In-Reply-To: <201105090945.05130.jhb@freebsd.org> References: <4DC3B764.4030801@FreeBSD.org> <201105061616.41145.jhb@freebsd.org> <20110507191625.GQ48734@deviant.kiev.zoral.com.ua> <201105090945.05130.jhb@freebsd.org> Date: Mon, 9 May 2011 10:35:07 -0500 Message-ID: From: Alan Cox To: John Baldwin Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: freebsd-current@freebsd.org, Andriy Gapon , multimedia@freebsd.org Subject: Re: dsp mmap change X-BeenThere: freebsd-multimedia@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: alc@freebsd.org List-Id: Multimedia discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 May 2011 15:58:24 -0000 On Mon, May 9, 2011 at 8:45 AM, John Baldwin wrote: > On Saturday, May 07, 2011 3:16:25 pm Kostik Belousov wrote: > > On Fri, May 06, 2011 at 04:16:40PM -0400, John Baldwin wrote: > > > On Friday, May 06, 2011 10:04:28 am Kostik Belousov wrote: > > > > On Fri, May 06, 2011 at 04:38:00PM +0300, Andriy Gapon wrote: > > > > > on 06/05/2011 16:32 Kostik Belousov said the following: > > > > > > On Fri, May 06, 2011 at 11:55:00AM +0300, Andriy Gapon wrote: > > > > > >> > > > > > >> I would like to ask for a review and/or testing of the following > patch: > > > > > >> http://people.freebsd.org/~avg/dev_dsp_mmap.diff > > > > > >> > > > > > >> It's supposed to fix an issue described here: > > > > > >> http://lists.freebsd.org/pipermail/freebsd-multimedia/2011- > > > February/011691.html > > > > > >> > > > > > >> In short, the following pseudo-code should do the right thing: > > > > > >> fd = open(/dev/dsp, O_RDWR); > > > > > >> mmap(PROT_READ, fd); > > > > > >> mmap(PROT_WRITE, fd); > > > > > >> > > > > > >> Thank you! > > > > > > > > > > > > I think that you have to call PCM_GIANT_LEAVE() when returning > > > > > > EINVAL on the vm_pager_alloc() failure. > > > > > > > > > > Yes, thank you. > > > > > > > > > > > Your patch hardcodes an assumption that sndbufs are always > > > > > > contiguous. I was unable to convince myself that this is true. > > > > > > > > > > I think that this should be true for the case when DMA is used? > > > > In the current driver, yes, but there is nothing that theoretically > > > > prevents scatter-gather from be used. > > > > > > You could "fix" this by creating an sglist (via sglist_build()) and an > > > OBJT_SG VM object that the d_mmap_single callback returned. I wish > there > > > was a cleaner way to just create a VM object and populate it with pages > > > though, and then use vm_map_insert() to map it into the kernel rather > > > than the more roundabout method of OBJT_SG. > > > > You cannot have one page inserted into two vm objects. Contigmalloc() > > inserts the allocated pages into kernel_object. > > Yes, I would want to allocate N unmapped pages and stuff them into a VM > object that can then be mapped into the kernel and/or into user mappings. > This would be a much cleaner approach for the nvidia driver for example. > > There is a relatively new function, vm_object_populate(), that allocates a collection of pages, inserts them into a vm object, and validates them for use. This function exits in FreeBSD 7.x, 8.x, and HEAD. Alan