Date: Mon, 14 Jul 2008 17:17:13 -0700 (PDT) From: Matthew Dillon <dillon@apollo.backplane.com> To: Jeremy Chadwick <koitsu@freebsd.org> Cc: Dominic Fandrey <kamikaze@bsdforen.de>, freebsd-stable@freebsd.org Subject: Re: dvd dma problems Message-ID: <200807150017.m6F0HD7m000582@apollo.backplane.com> References: <487A18E8.6010809@bsdforen.de> <20080713164033.GA97147@eos.sc1.parodius.com>
next in thread | previous in thread | raw e-mail | index | archive | help
:> quite fine from 5.3 to somewhere in the 6.x branch. Nowadays I have to send :> them to PIO4 to play DVDs, because they'll just throw DMA not aligned errors :> around in UDMA33 or WDMA2 mode. :> :> Should someone be interested in this I'm willing to supply all necessary :> information, such as the exact drives, firmware versions, kernel traces... :> whatever comes to your mind. I'm also willing to test patches. : :Is the problem you're seeing identical to this? : :http://lists.freebsd.org/pipermail/freebsd-hackers/2008-July/025297.html : :-- :| Jeremy Chadwick jdc at parodius.com | One of our guys (in DragonFly-land) tracked this down two two issues, fixing either one will fix the problem. I'd include a patch but he has not finished it yet. Still, anyone with moderate kernel programming skills can probably fix it in an hour or less. physio() - uses vmapbuf(). vmapbuf() does NOT realign the user address, it simply maps it into the buffer and adjusts b_data. So if the user supplies a badly aligned buffer, physio() will happily pass that bad alignment to the driver. physio() could be modified to allocate kernel memory to back the pbuf and copy instead of calling vmapbuf(), for those cases where the user supplied buffer is not well aligned (e.g. not at least 512-byte aligned). The pbuf already reserve KVA so all one would need to do is allocate pages to back the KVA space. I think a couple of other subsystems in the kernel do this with pbufs so there is plenty of example material. -- The ATA driver has an explicit alignment check and also uses BUS_DMA_NOWAIT in its call to bus_dmamap_load() in ata_dmaload(). The ATA driver could be adjusted to remove the alignment check, remove the BUS_DMA_NOWAIT flag, and also not free the bounce buffer when DMA ends (so you don't get allocator deadlocks). You might have other issues related to lock ordering, and this solution would eat a considerable amount of memory (upwards of a megabyte, more if you have more ATA channels), but that's the jist of it. It should be noted that only physio() can supply unaligned BIOs to the driver layer. All other BIO sources (that I know of) will always be at least 512-byte aligned. -- My recommendation is to fix physio(). User programs that do not supply aligned buffers clearly don't care about performance, so the kernel can just back the pbuf with memory and copyin/out the user data. -Matt Matthew Dillon <dillon@backplane.com>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200807150017.m6F0HD7m000582>