From owner-freebsd-current@FreeBSD.ORG Fri Sep 4 05:31:19 2009 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 07686106566C; Fri, 4 Sep 2009 05:31:19 +0000 (UTC) (envelope-from scottl@samsco.org) Received: from pooker.samsco.org (pooker.samsco.org [168.103.85.57]) by mx1.freebsd.org (Postfix) with ESMTP id AF6C58FC12; Fri, 4 Sep 2009 05:31:18 +0000 (UTC) Received: from [IPv6:::1] (pooker.samsco.org [168.103.85.57]) (authenticated bits=0) by pooker.samsco.org (8.14.2/8.14.2) with ESMTP id n845V7xU092195; Thu, 3 Sep 2009 23:31:07 -0600 (MDT) (envelope-from scottl@samsco.org) Mime-Version: 1.0 (Apple Message framework v1075.2) Content-Type: text/plain; charset=us-ascii; format=flowed; delsp=yes From: Scott Long In-Reply-To: <200909032210.n83MA67F059073@apollo.backplane.com> Date: Thu, 3 Sep 2009 23:31:07 -0600 Content-Transfer-Encoding: 7bit Message-Id: References: <4AA03346.5010608@FreeBSD.org> <200909032210.n83MA67F059073@apollo.backplane.com> To: Matthew Dillon X-Mailer: Apple Mail (2.1075.2) X-Spam-Status: No, score=-2.2 required=3.8 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.1.8 X-Spam-Checker-Version: SpamAssassin 3.1.8 (2007-02-13) on pooker.samsco.org Cc: Ryan Rogers , Alexander Motin , current@freebsd.org Subject: Re: non aligned DMA transfer attempted X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2009 05:31:19 -0000 On Sep 3, 2009, at 4:10 PM, Matthew Dillon wrote: > This is a known problem with physio and/or the ATA driver, > depending > on your viewpoint. See kern/kern_physio.c. > > The physio code directly maps the userland buffer via vmapbuf() and > supplies it as a BIO to the device. The ATA driver does not use > BUSDMA (and never has)... it assumes BIOs are minimally aligned. > Wrong. > But BIOs generated from kern_physio.c use user addresses directly > and > thus might only be byte-aligned. > > The CAM pass-through device has the same problem. > Huh? Are you confused by the physaddr interface of CAM? > The problem occurs most often when running a cd/dvd player or > burner > which declares operational structures it intends to read() or > write() > on the stack, sometimes even with char[] arrays. > > The solution I came up for with DFly was to implement bounce > buffers > manually in kern_physio.c and the CAM pass-through device for any > user data that was not 16-byte aligned. I considered implementing > bounce buffers in all the disk drivers that were missing it but > there are other serious problems trying to bounce dma buffers > that deep > in the device hierarchy... you can hit low-memory deadlocks if the > driver isn't written carefully enough (and most aren't). The > BUSDMA > API has never been easy to work with for anyone trying to use the > async data buffer bouncing load feature... most drivers just > force it > to run synchronously and thus hit the deadlock issues. > Wrong. Scott