From owner-freebsd-current@FreeBSD.ORG Thu Sep 3 22:20:46 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 BB3871065670 for ; Thu, 3 Sep 2009 22:20:46 +0000 (UTC) (envelope-from dillon@apollo.backplane.com) Received: from apollo.backplane.com (apollo.backplane.com [216.240.41.2]) by mx1.freebsd.org (Postfix) with ESMTP id 9451C8FC18 for ; Thu, 3 Sep 2009 22:20:46 +0000 (UTC) Received: from apollo.backplane.com (localhost [127.0.0.1]) by apollo.backplane.com (8.14.2/8.14.1) with ESMTP id n83MA6NO059074; Thu, 3 Sep 2009 15:10:07 -0700 (PDT) Received: (from dillon@localhost) by apollo.backplane.com (8.14.2/8.13.4/Submit) id n83MA67F059073; Thu, 3 Sep 2009 15:10:06 -0700 (PDT) Date: Thu, 3 Sep 2009 15:10:06 -0700 (PDT) From: Matthew Dillon Message-Id: <200909032210.n83MA67F059073@apollo.backplane.com> To: Alexander Motin References: <4AA03346.5010608@FreeBSD.org> Cc: Ryan Rogers , 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: Thu, 03 Sep 2009 22:20:46 -0000 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. 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. 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. I seem to recall that the same issue popped up a few months ago on these lists, too. -Matt