From owner-freebsd-current@FreeBSD.ORG Sat Sep 5 15:56:59 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 869211065670; Sat, 5 Sep 2009 15:56:59 +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 5D0618FC17; Sat, 5 Sep 2009 15:56:59 +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 n85Futln080959; Sat, 5 Sep 2009 08:56:55 -0700 (PDT) Received: (from dillon@localhost) by apollo.backplane.com (8.14.2/8.13.4/Submit) id n85Futap080958; Sat, 5 Sep 2009 08:56:55 -0700 (PDT) Date: Sat, 5 Sep 2009 08:56:55 -0700 (PDT) From: Matthew Dillon Message-Id: <200909051556.n85Futap080958@apollo.backplane.com> To: Alexander Motin , Scott Long , Ryan Rogers , current@FreeBSD.org References: <4AA03346.5010608@FreeBSD.org> <200909032210.n83MA67F059073@apollo.backplane.com> <200909042314.n84NEMAS072077@apollo.backplane.com> <4AA1FA41.1030804@FreeBSD.org> Cc: 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: Sat, 05 Sep 2009 15:56:59 -0000 Ah, I found the code reference. This is something I had to throw into DFly's version of the ATA driver: /* * Don't allow DMA for requests with length not multiple of 16 bytes. * Some ATAPI devices don't like it. */ if ((softc->atadev[tid]->mode >= ATA_DMA) && len > 0 && !(len & 15)) request_flags |= ATA_R_DMA; It turns out that for non-SATA (older) chipsets ATAPI command DMA is speced to only run in multiples of 16 bytes. If an ATAPI request buffer is not a multiple of 16 bytes the two choices are to either (1) PAD the request buffer to 16 bytes or (2) Not use a DMA transfer mode. I eventually chose (2). The issue with (1) is that the busdma subsystem doesn't really have a way to specify a length alignment requirement, only a base offset alignment requirement, and buffer passed from userland might be declared on the stack so unlike buffers passed by the kernel there may not be any extra play in the buffer which allows one to simply DMA a little bit more into it. I'm fairly sure that SATA chipsets don't care, this seems to be an issue with pre-SATA chipsets. -Matt