  The Linux Ultra-DMA Mini-Howto
  Brion Vibber, brion@pobox.com
  v1.41, 3 May 1998

  This document is intended to explain how to use Ultra-DMA aka Ultra-
  ATA aka Ultra33 hard drives and controllers with Linux. The most
  recent version of this mini-Howto can be obtained in HTML format at
  http://pobox.com/~brion/linux/Ultra-DMA.html.
  ______________________________________________________________________

  Table of Contents


  1. Introduction

     1.1 Disclaimer
     1.2 Credits
     1.3 Document History
     1.4 Copying

  2. What is Ultra-DMA and why do I want it?

     2.1 IDE, EIDE, & ATAPI
     2.2 Bus Master DMA
     2.3 Ultra-DMA aka Ultra-ATA aka Ultra33 aka...

  3. Using your UDMA Hard Drive with an EIDE Controller

  4. Using your hard drives with a UDMA Controller

  5. The Promise Ultra33 IDE

     5.1 Installing Linux with the Promise
     5.2 Installing Linux Around the Promise
     5.3 Patching for the Promise

  6. Intel TX motherboard onboard UDMA controller

  7. The VIA VP2 and Related Chipsets

  8. UDMA-Generic

  9. If you still can't get it to work!

  10. If you have some information about UDMA stuff that's not in this mini-howto...



  ______________________________________________________________________

  1.  Introduction


  This document is intended to explain how to use Ultra-DMA aka Ultra-
  ATA aka Ultra33 hard drives and controllers with Linux. In some cases
  there is no difficulty in using them, but some tweaking can increase
  performance. In other cases, you need to go to extraordinary lengths
  simply to access your hard drives.


  1.1.  Disclaimer


  The information in this is document is, to the best of my knowledge,
  correct, and should work. However, there may be typos, there may be
  mysterious transmission errors, and there may be strange
  incompatibilities within your own system that prevent the techniques
  described herein from working properly. So... before you go fiddling
  around with you hard drive, BACK UP ANY DATA YOU WANT TO KEEP! If you
  are not already performing regular backups, please start doing so for
  your own good.


  1.2.  Credits


  Brion Vibber (brion@pobox.com) - The document itself

  Gadi Oxman (gadio@netvision.net.il) - The Promise Ultra33 patch &
  finding the secret numbers for the workaround

  John G. (prefect@ipass.net) - VIA VP2 patch & info

  Giovanni (giovanni@sudfr.com) - UDMA-enabled VIA-related patch & more
  info

  Martin Gaitan - Promise ide0/ide1 workaround

  Norman Jacobowitz - Bugged me to add info on the VP3

  Andr Balsa (andrebalsa@altern.org) - Provided some general UDMA info
  and the udma-generic patch for Intel TX, SiS, and VP1.

  Masayoshi Nakano - Japanese translation

  Maxime Baudin - French translation


  1.3.  Document History


  v1.41, 3 May 1998: Fixed a couple of typos, added translators to
  credits.

  v1.4, 28 April 1998: UDMA-Generic patch, some more general info.
  Copying section added.

  v1.3, 5 March 1998: VIA VP3 info, better patching instructions,
  pointer to more recent Promise patch.

  v1.2, 27 January 1998: Additional Promise workaround info.

  v1.1, 21 January 1998: New info about VIA chipset, installing around
  the Promise Ultra33, and enabling Bus Master & UDMA transfer modes.

  v1.0, 19 January 1998: More or less complete, first version done in
  SGML.


  1.4.  Copying


  This document may be freely copied and distributed for informational
  purposes. It may not be modified, except for reformatting, without the
  permission of the author. If you wish to translate this document into
  another language you may do so, however you should contact the author
  first so that updated versions of this document can be sent out to
  translators as well as directly to the Linux Documentation Project.




  2.  What is Ultra-DMA and why do I want it?


  Here's a brief overview of IDE-based drive technologies:


  2.1.  IDE, EIDE, & ATAPI


  These are older drive technologies. Most non-SCSI hard drives and
  drive controllers that you can buy today or are likely to be using are
  EIDE, although many of the larger drives now available are UDMA.


  2.2.  Bus Master DMA


  Bus Master DMA is a technology for increasing the speed of hard disk
  data transfers which requires support from the motherboard and the
  BIOS, and at least some support from the drive.

  You can learn more at
  http://developer.intel.com/design/pcisets/busmastr/FAQs.htm.


  2.3.  Ultra-DMA aka Ultra-ATA aka Ultra33 aka...

  Ultra-DMA has many names, but we'll just call it UDMA in here.

  UDMA is a more advanced technology which provides for even faster
  throughput, up to 33.3 MB/s, twice that of EIDE, for much lower prices
  than SCSI. Many new computers come with large UDMA drives and UDMA
  controllers, and it's possible to add a UDMA controller card (such as
  the Promise Ultra33) to an existing system to boost speed, even on
  older non-UDMA drives.

  You can learn great details about UDMA at
  http://www.quantum.com/src/whitepapers/ultraata/

  Note that cable length should be kept shorter for UDMA, compared to
  plain DMA, preferably less than 30 cm (12") maximum length.


  3.  Using your UDMA Hard Drive with an EIDE Controller


  This is easy to do. Since all UDMA drives are fully EIDE backward-
  compatible, just plunk your drive on your EIDE controller like it was
  any old hard drive & Linux should have no problems detecting or using
  the drive.  However, you will of course be limited to the 16.7 MB/s
  bandwidth of EIDE.


  4.  Using your hard drives with a UDMA Controller


  Well, there is good news and there is bad news. The good news is that
  a UDMA controller can be used with both UDMA hard drives and legacy
  EIDE hard drives, and will be a lot faster than an EIDE controller.

  The bad news is that the stock kernels (as of 2.0.33) do not currently
  support UDMA. The development kernels (current is 2.1.98) and the
  upcoming 2.0.34 do have some UDMA support, however, and there are a
  number of kernel patches available for currently existing kernels. In
  addition, certain UDMA controllers that are add-in cards rather than
  built into the motherboard require either a patch or some trickery to
  use. That is why this document exists - to explain how to get the
  patches and work the trickery.


  5.  The Promise Ultra33 IDE


  This is a PCI card that has two UDMA channels on it, supporting up to
  four drives. You can look up specification & pricing at
  http://www.promise.com.

  This card shipped in early model Gateway 2000 Pentium II systems, and
  may or may not be in more recent models.

  The more recent development kernels (current is 2.1.98) have generic
  PCI IDE controller support, which automatically detects the Promise
  Ultra33.  However, the stable kernels (current is 2.0.33) require a
  patch, and it can be a little difficult to get Linux installed because
  of this.


  5.1.  Installing Linux with the Promise


  Although there is a patch for the Promise controller, it is not very
  easy to apply a patch and recompile your kernel if you have not
  installed Linux yet! So, here is a workaround which allows you to
  install. Thanks to Gadi Oxman for the following information on getting
  the interface settings:



       If we can access the console with the installation disk, we can also
       use "cat /proc/pci" to display the Promise interface settings:

           RAID bus controller: Promise Technology Unknown device (rev 1).
             Vendor id=105a. Device id=4d33.
             Medium devsel.  IRQ 12.  Master Capable.  Latency=32.
             I/O at 0xe000.   (a)
             I/O at 0xd804.   (b)
             I/O at 0xd400.   (c)
             I/O at 0xd004.   (d)
             I/O at 0xc800.   (e)

       and pass "ide2=a,b+2 ide3=c,d+2" as a command line parameter to the kernel.




  Note that the numbers probably are not the same as what you will have.
  Just as an example, the parameters to use for the above set of numbers
  would be ``ide2=0xe000,0xd806 ide3=0xd400,0xd006''. You can also
  specify the IRQ, which would make it ``ide2=0xe000,0xd806,12
  ide3=0xd400,0xd006,12''.  If you are only using the first channel on
  the Promise controller (for instance, if you only have one drive, or
  two if they are master and slave on the same channel, on the Promise),
  then you won't need to specify ide3.

  Under Red Hat 5.0, use the installation boot floppy, and at the boot
  prompt type ``rescue''. It will load the kernel, prompt you for the
  supplemental disk, ask you about your monitor and keyboard, and
  finally put you into a command prompt. Then, run ``cat /proc/pci'',
  write down the numbers as above, and reboot from the boot disk. This
  time, type ``linux ide2=(this is where you put the numbers like shown
  above) ide3=(more numbers)''. It should now be able to install onto
  your hard disk without difficulty.
  Under Slackware 3.4, the process is very similar. Boot with the boot
  disk of your choice, and at the boot prompt, just hit Enter for now.
  It will load the kernel and prompt for the root disk. Insert the root
  disk, wait for it to load, and log in as root. Run ``cat /proc/pci''
  and write down those numbers. Reboot with the boot floppy and at the
  boot prompt type ``ramdisk ide2=(this is where you put the  numbers)
  ide3=(some more numbers)''. You should then be able to install onto
  your hard disk as normal.

  With another Linux distribution you will have to improvise a bit, but
  the process should be about the same as the above.

  IMPORTANT: Without the patch (discussed in the section ``Patching for
  the Promise''), the kernel needs these boot parameters in order to
  access your hard disk! Therefore it is very important that when you
  configure LILO, either on the hard disk or on a boot floppy, that you
  give it the exact same parameters that you gave when installing.
  Otherwise your system won't boot! It should be possible to give them
  to LILO when you boot (ie, press Shift, type in ``linux ide2=.....''
  each time you boot), but only if you kept the numbers! It is
  recommended that you patch your kernel as soon as possible so you will
  not have to worry about that anymore; once you are booting with a
  patched kernel, you can get rid of the boot parameters. Also, as far
  as I know there is no way to pass boot parameters to a plain kernel
  boot floppy (as made with ``make zdisk''), you must use LILO or
  another loader (such as LOADLIN) that lets you pass boot parameters.

  However, unpatched kernels and installation programs often have a
  difficult time actually using ide2 and ide3, even if the drives are
  detected properly.  So if you can't get Linux to install using the
  above technique, try specifying ide0 or ide1 instead of ide2 or ide3
  (thanks to Martin Gaitan for this technique). This essentially
  replaces the on-board controller with the Promise Ultra33 as far as
  the kernel is concerned, and you can follow the directions in the next
  section as if you had physically moved it.  Note that if you're using
  an IDE CD-ROM drive connected to your on-board controller to install
  from, you will want to make sure that you do not take over the
  controller that the CD is on or you will not be able to install! If
  the CD is hda or hdb, use ide1 for your hard drive, and if it is hdc
  or hdd, then use ide0.


  5.2.  Installing Linux Around the Promise


  If you cannot get the software workaround to work, you will have to
  try a more brute force approach. Here's an alternative method that is
  virtually guaranteed to work, but  will require you to open up your
  computer and mess about in it. NOTE: If you are not familiar with the
  process of connecting and disconnecting IDE drives, read the manuals
  that came with your computer, your hard drive, and/or the Promise
  Ultra33 before attempting this! If you screw something up and don't
  know how to put it back, you could end up being sorry!

  That being said, it's all really quite simple. Most motherboards these
  days have built-in EIDE controllers. Disconnect your hard drive from
  the Ultra33 and connect it to the onboard controller. If you have
  other IDE devices, such as a CD-ROM, tape, or ZIP drive, on your
  oboard controller, it is easiest if you either add the hard drive on
  an unused channel (the secondary instead of the primary) or
  temporarily displace a device that you don not need immediately (such
  as ZIP or tape). Install Linux. Download and apply the Promise UDMA
  patch (see next section).

  Now you are ready to move the drive back onto the Promise... almost.
  To be safe, make a kernel-image boot floppy (cd /usr/src/linux ; make
  zdisk), which you  will be able to use to boot your system in case
  LILO doesn't work. Actually, to be very safe, make two and put one
  away for now.

  Okay, now it is time to think a little... if you have just one hard
  drive and it is going to be on the Promise, then it will most likely
  be /dev/hde (a and b are for the primary onboard controller, c and d
  for the secondary onboard controller).  If you are going to put any
  other drives on it, then the slave of the Promise's first channel will
  be /dev/hdf, the master of the second will be /dev/hdg, and the slave
  of the second will be /dev/hdh.

  Edit /etc/fstab, and change all the partitions of the hard drives you
  are moving from the onboard drives (/dev/hda, hdb, etc) to their new
  locations  on the Promise (/dev/hde, hdf, etc). If you had to displace
  any devices (such as a CD-ROM or ZIP drive) that you want to leave on
  the onboard controller, then change them to their new locations as
  well. For instance, if your CD-ROM was originally the master on the
  primary channel (/dev/hda), but you put your hard disk there and had
  to bump the CD to the slave  (/dev/hdb) or to the secondary channel
  (/dev/hdc), and now you want to put  it back, then change it to
  /dev/hda.

  If you are using LILO, reconfigure LILO to use the new location of the
  drive (LILO configuration is beyond the scope of this document, if you
  do not know how, read the LILO mini-HOWTO
  <http://sunsite.unc.edu/LDP/HOWTO/mini/LILO.html>), or else it
  probably will not be able to boot unless you use that boot floppy I
  had you make, which you will also want to configure to boot off the
  new partition. This is done using the rdev command. Put the floppy in
  the drive and type ``rdev /dev/fd0 /dev/hde1''. Of course that's
  assuming your root partition is the first on your first UDMA drive. If
  not (mine is /dev/hde7, for instance), then obviously use the
  appropriate partition number!

  Reboot. Your system should now work fine.


  5.3.  Patching for the Promise


  There is a kernel patch available for the Promise Ultra33, written by
  Gadi Oxman (gadio@netvision.net.il).

  The current version of the patch works on kernel version 2.0.33 and
  can be obtained from Linux Mama
  <http://www.huwig.de/linux/mama/20-newdriver.html>.  Note that you
  will need to use bzip2 <http://www.muraroa.demon.co.uk/> to decompress
  this patch rather than gzip. (Note that this particular version of the
  patch causes the kernel to interpret the Promise as ide0 and ide1,
  rendering the motherboard's IDE controller useless. A slightly hacked
  patch is available here
  <http://pobox.com/~brion/linux/lmpromisehack.bz2> which will allow you
  to use the onboard controller as ide0/ide1 and the Promise as
  ide2/ide3.)

  You can also download a version of the patch for kernel 2.0.30,
  compressed with gzip, from
  http://pobox.com/~brion/linux/promise_update.gz. This version will
  work on 2.0.33 but will result in ``unknown PCI device'' messages
  because of a change in pci.c between 2.0.30 and 2.0.33.

  For instructions on how to patch and compile the kernel, make sure you
  have the kernel source and gcc installed and read
  /usr/src/linux/README.

  Wondering why you should bother with the patch, aside from saving
  yourself the trouble of the boot parameters from the workaround? Well,
  according to the author:



       One advantage of using the kernel patch is that we will be able to use
       bus mastering DMA transfers ("hdparm -d1 /dev/hdx") in case the triton
       driver is compiled into the kernel.




  In other words, you'll not only be able to use your hard drive, you'll
  be able to use it faster! Not full UDMA, but not bad. Note that you
  can use ``hdparm -Tt /dev/hdx'' to test the hard disk transfer speeds.


  6.  Intel TX motherboard onboard UDMA controller


  Thanks again to Gadi for this info:



       Bus mastering DMA support for the Intel TX chipset is available in 2.0.31
       and above.




  In older kernels (such as Slackware 3.4's 2.0.30), the controller will
  be used in the slower EIDE mode.  In either case the controller will
  be automatically detected by the kernel and you should have no trouble
  using it.

  Full UDMA support for the TX chipset is included in the ``UDMA-
  Generic'' patch.


  7.  The VIA VP2 and Related Chipsets


  This controller also can be autodetected and used in EIDE mode by an
  unpatched kernel, but if you have one of these, you will want to grab
  a patch so you can get faster throughput and do away with annoying
  "unkown PCI device" messages.

  One is available at http://www.ipass.net/~prefect/; it is designed for
  the VIA VP2/97 chipset, found on FIC's PA-2007 and PA-2011
  motherboards, but may work on related chipsets.  It has been reported
  that it functions on the newer VIA VP3 chipset, your mileage may vary.

  Note that this patch only supports Bus Mastering mode, not full UDMA
  mode, but it's still better than plain-vanilla EIDE mode.  Follow the
  directions at the patch's site for enabling BMDMA mode.

  There is another patch that supports full UDMA mode at
  http://www.pyreneesweb.com/Udma/udma.html, designed for the VIA
  VT82C586B, and it ought to work on the VP2, VP3, VPX, P6 and AGP
  Apollo chipsets. Follow the directions for installation and UDMA
  enabling there, but it is recommended that you back up any data you
  want to keep, as there are potential problems with incompatible
  motherboards. But, if it does work, it should work without problems.


  Note that the VP1 chipset is not known to work with these patches, but
  is supported by the ``UDMA-Generic'' patch.


  8.  UDMA-Generic


  The UDMA-Generic patch, modified by Andr Balsa
  (andrebalsa@altern.org) from Mark Lord's original Triton DMA driver,
  provides UDMA support for the following chipsets:


    Intel TX

    SiS 5513 (which is integrated in the SiS 5571, 5598 and possibly
     5591 chips)

    VIA VP1 (untested)

  It is also designed to be easy to extend to support other chipsets.
  UDMA-Generic has been tested successfully on kernels 2.0.29 through
  2.0.33, although the patch may require some manual tweaking on kernels
  earlier than 2.0.32.

  You can download the patch from http://pobox.com/~brion/linux/udma-
  generic-latest.tar.gz, see the files INSTALL and UDMA.txt in the
  archive for usage instructions.

  Here are a few notes from the author:



       Performance with IBM UDMA drives on a good motherboard approches the
       maximum head transfer rates: about 10 Mb/s (measured with hdparm -t -T).

       The Intel TX chipset has a single FIFO for hard disk data shared by
       its two IDE controllers, so using 2 UDMA drives will not yield such a
       great improvement over a single UDMA drive.
       However, the SiS5598 has two completely separate controllers, each with
       its own FIFO. Theoretically, one could approach 66Mb/s burt transfer
       rates on motherboards with the SiS5598 chip, using the md driver and
       data striping over two drives. The SiS5571 has the same controller
       architecture, I think. I don't have the VIA chipsets datasheets, so I
       can't say anything about those.

       The Linux IDE (U)DMA kernel driver by Mark Lord has a particularly
       low setup time (i.e. latency for data transfers). It is ideal for
       frequent, small data transfers (such as those in Linux news servers),
       and might be in some cases superior to its SCSI counterparts.






  9.  If you still can't get it to work!


  If nothing in this document proved helpful, or at least not helpful
  enough to get your machine working, your best bet is to write up a
  message that fully describes your difficulty, what type of UDMA
  controller you have, whether it is onboard or on a card, if your drive
  is actually UDMA or plain EIDE, exactly what configuration of drives
  you have, what version (distribution & kernel versions if possible) of
  Linux you are using, and anything else that sounds useful, and post it
  to the newsgroup comp.os.linux.hardware.  You will probably get some
  helpful suggestions soon.


  10.  If you have some information about UDMA stuff that's not in this
  mini-howto...


  Great! If you know something I don't, by all means send it to me
  (brion@pobox.com) and I will put it in this document and update it
  fairly soon.
























































