-
David Mosberger authored
I was in need of a 3.3V/dual-voltage-capable PCI sound-card and, as luck would have it, the only card of that sort in the local computer store was one that _still_ has a DMA engine that cannot even DMA to all 32 bits (it's limited to 28 bits). Hard to believe, but true (the card in question is a "SoundBlaster Live! 24-bit" with a CA0106 chip; stay away from that one if you can...). Anyhow, since I don't like it when PCI cards don't work in my machine, I created the attached patch which adds a new machine-vector to enable support of such broken cards. With the patch applied, you can either configure the kernel for "HP-zx1/sx1000+swiotlb" or configure for "generic" and boot with option "machvec=hpzx1_swiotlb" to enable support for broken PCI devices. The patch works as follows: the new machvec implements a I/O MMU which will use the hardware I/O MMU whenever possible but fall back on the software I/O TLB when encountering a device that can't be supported by the hardware I/O MMU. Fortunately, we don't have to mess with MAX_DMA_ADDRESS or create a new zone: the software I/O TLB allocates its memory as low as possible and early in the boot-process, so on any machine with low memory, we're pretty much guaranteed that we'll get a reasonable amount of low memory, which is all we need to properly support broken PCI cards. Note that I made a small change to swiotlb.c: I added a swiotlb_init_with_default_size() function to let the new I/O MMU initialize the software I/O TLB with less than 64MB (which is way too much for the limited uses we'll see for the broken PCI devices; for example, the CA0106 chip allocates only coherent buffers of about 128KB). The patch has been tested on a zx1 machine in the generic, hpzx1, and hpzx1_swiotlb configuration. Thanks to Alex Williamson for the suggestion of doing this via a completely separate machvec. Signed-off-by: David Mosberger-Tang <davidm@hpl.hp.com> Signed-off-by: Tony Luck <tony.luck@intel.com>
b733ce21