VOGONS


DMA on PIIX3?

Topic actions

Reply 20 of 31, by douglar

User metadata
Rank l33t
Rank
l33t

I asked ChatGPT for some into about the command translation that occurs in a Sata-Pata bridge and the differences between WDMA and UDMA. Can anyone here comment on the AI accuracy on this?

-----------------------------------------------------------------------

Command conversion between SATA and PATA (IDE) is a critical function of the JMicron bridge, enabling communication between devices that use fundamentally different protocols. Here's a closer look at how this process works:

PATA (Parallel ATA):

  • Command Register Block: PATA devices use an 8-bit command register, which is part of the Command Block Registers (CBR). This set of registers is used to send commands and receive status from the drive.
  • Task File: The Task File in PATA is a set of registers (like the command register, feature register, etc.) through which the CPU sends commands and receives data/status from the drive. Commands include read, write, identify, and others.
  • PIO & DMA: PATA uses Programmed Input/Output (PIO) and Direct Memory Access (DMA) modes for data transfer, which are initiated by commands sent through the Task File.

SATA (Serial ATA):

  • FIS (Frame Information Structure): SATA uses FIS packets for communication. The host sends commands to the device using a Register FIS, which includes the command, features, sector count, and more.
  • AHCI (Advanced Host Controller Interface): SATA devices commonly use AHCI, which allows for advanced features like native command queuing (NCQ). AHCI sends commands through the Command List and Command Table structures.
  • SATA Commands: Similar to PATA, SATA has commands for read, write, identify, etc., but they are encapsulated in FIS structures.

Command Conversion Process

The JMicron bridge plays the role of an interpreter between the two protocols. Here's how it handles command conversion:

Command Translation:
When the PATA controller sends a command to a device (e.g., a read or write command), the bridge intercepts this command.
The bridge converts the PATA command from the Task File format into the equivalent SATA command in a Register FIS format.
For example, a PATA read command might be converted into a SATA FIS that includes the necessary parameters (LBA, sector count, etc.).

Feature and Mode Conversion:
Some features and modes supported by PATA, like different DMA modes, are converted to their SATA equivalents.
The bridge ensures compatibility by translating commands related to features like power management, data transfer modes, and error handling.

Data Transfer Coordination:

  • The bridge manages data flow between the PATA controller and the SATA device. For instance, if the PATA controller expects data in a PIO mode, the bridge handles the conversion to ensure the SATA device delivers the data appropriately.
  • In the case of DMA, the bridge also ensures that the data transfer occurs at the correct speeds and in the correct format.

Status Reporting:

  • After executing the command, the SATA device sends a status report back to the bridge.
  • The bridge converts this status from the SATA format (e.g., through a Status FIS) back into the PATA format (e.g., updating the status register in the Task File), so the PATA controller understands the outcome of the command.

Example: A Read Command

  • PATA Command: The PATA controller sends a read command to the Task File, specifying the LBA (Logical Block Address) and the number of sectors to read.
  • Bridge Conversion: The JMicron bridge intercepts this command, translates it into a SATA FIS, and sends it to the SATA device.
  • SATA Device Response: The SATA device processes the command, reads the data, and sends it back to the bridge in the SATA format.
  • PATA Data Transfer: The bridge converts the SATA data back into the parallel format expected by the PATA controller, which then receives the data as if it came from a native PATA device.

Challenges and Solutions

  • Protocol Differences: PATA and SATA have different methods for handling things like error reporting, queuing, and command completion. The bridge needs to manage these differences without causing delays or errors.
  • Performance Matching: While SATA devices may be faster, the bridge needs to ensure that the data transfer occurs within the capabilities of the PATA interface, often requiring buffering or other techniques to handle speed mismatches.

In summary, command conversion in the JMicron bridge involves translating, adapting, and managing the communication between two very different storage protocols, ensuring that the legacy PATA interface can effectively control and communicate with a modern SATA device.

------------------------------

When using DMA (Direct Memory Access) modes, especially Multi-Word DMA and Ultra DMA, command translation by a SATA to PATA bridge like the JMicron involves different handling due to the distinct ways these modes operate. Here's how the translation process differs between Multi-Word DMA and Ultra DMA:

Understanding Multi-Word DMA and Ultra DMA

Multi-Word DMA (MWDMA):

  • Data Transfer: Multi-Word DMA is an older DMA mode used in PATA devices. It transfers data in bursts, with each burst consisting of multiple 16-bit words. MWDMA has three main modes: MWDMA 0, 1, and 2, with MWDMA 2 being the fastest at 16.7 MB/s.
  • Control Signals: Data transfer in MWDMA mode is managed by the PATA controller using the I/O read and write control signals, with data strobed by the DIOW and DIOR signals.

Ultra DMA (UDMA):

  • Data Transfer: Ultra DMA is a more advanced and faster DMA mode, which uses double data rate (DDR) signaling, transferring data on both the rising and falling edges of the clock signal. UDMA modes range from UDMA 0 (16.7 MB/s) to UDMA 6 (133 MB/s).
  • CRC Checking: UDMA includes a cyclic redundancy check (CRC) for error detection, adding a layer of data integrity verification that MWDMA does not have.

Command Translation in Multi-Word DMA Modes

Command Setup:

  • The PATA controller sends a command to the drive, specifying that data transfer will occur using Multi-Word DMA. This command includes the mode (e.g., MWDMA 2) and the address for data transfer.
  • The JMicron bridge receives this command and translates it into the equivalent SATA command format. SATA doesn’t differentiate between different types of DMA modes (as it only supports one DMA mode with varying speeds), so the bridge must ensure that the data transfer method used by the SATA device is compatible with the expectations of MWDMA.

Data Transfer Handling:

  • The bridge emulates the Multi-Word DMA timing and control signals for the PATA controller. It manages the handshaking between the PATA controller’s expectations (using the DIOW and DIOR signals) and the SATA device’s signaling.
  • The bridge controls the data flow, ensuring that data is transferred in bursts that align with the PATA controller's MWDMA expectations, even though the SATA device might be capable of faster or more complex data transfers.

Error Handling:

  • Since MWDMA doesn’t use CRC checking, the bridge ensures that the data transfer integrity is maintained according to MWDMA’s simpler error-handling mechanisms. The SATA device’s response is translated into the expected status for MWDMA operations.

Command Translation in Ultra DMA Modes

Command Setup:

  • Similar to MWDMA, the PATA controller sends a command specifying Ultra DMA mode. The bridge translates this command into a SATA command format, ensuring that the SATA device is prepared for a high-speed data transfer.
  • UDMA requires more precise timing control, so the bridge needs to manage the transition between the PATA controller’s timing requirements and the SATA device's capabilities.

Data Transfer Handling:

  • The bridge emulates the UDMA protocol, including the double data rate (DDR) signaling that UDMA uses. This requires the bridge to match the timing of data transfers closely, ensuring that data is transferred on both the rising and falling edges of the clock signal.
  • The bridge also handles the CRC generation and checking, which is a key feature of UDMA. If the SATA device supports similar error-checking, the bridge will ensure that this information is passed back to the PATA controller in a way that it understands.

Error Handling:

  • If an error is detected during a UDMA transfer (using CRC), the bridge translates this into the appropriate error status for the PATA controller.
  • The bridge also manages the retry mechanisms if necessary, coordinating between the PATA controller’s retry logic and the SATA device’s error-handling protocols.

Differences in Command Translation

  • Data Integrity: The biggest difference between MWDMA and UDMA command translation is the handling of data integrity. UDMA includes CRC checking, which the bridge must manage, whereas MWDMA relies on simpler error detection methods.
  • Timing and Control: UDMA's use of double data rate signaling requires more precise timing control from the bridge compared to MWDMA’s simpler burst mode. This involves more complex command translation and signal emulation by the bridge.
  • Speed Handling: UDMA supports much higher data transfer rates than MWDMA, so the bridge must ensure that data is transferred at the appropriate speed while maintaining compatibility with the PATA controller's expectations.

Summary
The JMicron bridge performs different command translations for Multi-Word DMA and Ultra DMA modes due to the differences in data transfer methods, timing, and error handling. The bridge must adapt the simpler, burst-oriented MWDMA transfers to the more sophisticated, high-speed UDMA transfers while ensuring that the PATA controller receives the expected responses and status updates from the SATA device.

Reply 21 of 31, by mockingbird

User metadata
Rank Oldbie
Rank
Oldbie
douglar wrote on 2024-08-15, 12:22:

When I was testing on the Promise 20630, I was using the dos driver with the /m08 flag.

http://vogonsdrivers.com/getfile.php?fileid=2076

Ok, I'll partially assemble my VLB system together and test it out. I hope the CPU won't influence the results... I switched to a 486DX from a Cyrix 5x86.

mslrlv.png
(Decommissioned:)
7ivtic.png

Reply 22 of 31, by douglar

User metadata
Rank l33t
Rank
l33t
mockingbird wrote on 2024-08-15, 21:34:
douglar wrote on 2024-08-15, 12:22:

When I was testing on the Promise 20630, I was using the dos driver with the /m08 flag.

http://vogonsdrivers.com/getfile.php?fileid=2076

Ok, I'll partially assemble my VLB system together and test it out. I hope the CPU won't influence the results... I switched to a 486DX from a Cyrix 5x86.

I tested the stability using Speedsys 4.78. Let me know if you can complete the read only disk test.

Reply 23 of 31, by mockingbird

User metadata
Rank Oldbie
Rank
Oldbie
douglar wrote on 2024-08-18, 17:44:

I tested the stability using Speedsys 4.78. Let me know if you can complete the read only disk test.

Yes, perfectly stable... I'm not using Promise's BIOS, I have that disabled and it is detected through the motherboard's BIOS.

The attachment 20630_R.png is no longer available

Are you experiencing instability?

mslrlv.png
(Decommissioned:)
7ivtic.png

Reply 24 of 31, by douglar

User metadata
Rank l33t
Rank
l33t
mockingbird wrote on 2024-08-19, 20:12:
Yes, perfectly stable... I'm not using Promise's BIOS, I have that disabled and it is detected through the motherboard's BIOS. […]
Show full quote
douglar wrote on 2024-08-18, 17:44:

I tested the stability using Speedsys 4.78. Let me know if you can complete the read only disk test.

Yes, perfectly stable... I'm not using Promise's BIOS, I have that disabled and it is detected through the motherboard's BIOS.

The attachment 20630_R.png is no longer available

Are you experiencing instability?

I get instability.

I have one of these with a MARVELL 88SA8052 bridge.
https://www.amazon.com/Ableconn-IIDE-MSAT-2-5 … B017VQT5YW?th=1

I'm using it with a "MZ-MPC032D" Samsung PM830 32GB MLC mSATA Internal Solid State Drive (SSD) 6Gbps

Came from a G3 mac.

Do you have a Marvell 88SA8040 or a 88SA8052 ?

The attachment Photo Aug 24 2024, 4 55 11 PM.jpg is no longer available
The attachment Photo Aug 24 2024, 4 54 14 PM.jpg is no longer available

Reply 25 of 31, by mockingbird

User metadata
Rank Oldbie
Rank
Oldbie
douglar wrote on 2024-08-24, 21:01:
I get instability. […]
Show full quote

I get instability.

I have one of these with a MARVELL 88SA8052 bridge.
https://www.amazon.com/Ableconn-IIDE-MSAT-2-5 … B017VQT5YW?th=1

I'm using it with a "MZ-MPC032D" Samsung PM830 32GB MLC mSATA Internal Solid State Drive (SSD) 6Gbps

Came from a G3 mac.

Do you have a Marvell 88SA8040 or a 88SA8052 ?

The attachment Photo Aug 24 2024, 4 55 11 PM.jpg is no longer available
The attachment Photo Aug 24 2024, 4 54 14 PM.jpg is no longer available

See my post here on the matter. I tested with both 88SA8040 and 88SA8052. Both worked.

mslrlv.png
(Decommissioned:)
7ivtic.png

Reply 26 of 31, by douglar

User metadata
Rank l33t
Rank
l33t

The 4GB msata device has a single flash chip that isn't too fast. When attached to a contemporary PC via a USB3 adapter, it tops out about 16-17MB/s.

I ran some benchmarks with:

ATTO Results with Marvell & DMA:

The attachment 4g-marvell-dma.png is no longer available

ATTO Results with Marvell & no DMA:

The attachment 4g-marvell-nodma.png is no longer available

ATTO Results with JM0330 & no DMA:

The attachment 4g-JM0330-nodma.png is no longer available

Windows 98se with JM0330 & DMA didn't work. The drive activity light would flash like it was trying to work, and numlock worked, but I powered it off after 10 minutes because windows had not booted yet. So maybe DMA worked, but it was just really really slow.

MR BIOS identified the msata device as ATA4 / 16.7mbs capable, but the auto speed selected ATA3.
I tried to manually set ATA 4 13.3 which was the only ATA 4 setting available and the drive would not function.

The speedsys numbers look about right for ATA3

The attachment 4giger-Marvel.jpg is no longer available

Reply 27 of 31, by douglar

User metadata
Rank l33t
Rank
l33t
The attachment Photo Sep 07 2024, 3 44 24 PM.jpg is no longer available

Tested some mSata devices

  • 4GB Advantech SQF-SHMM1-4G-S9C
    Phison rs3109-s9 controller
    S9FMV026 Firmware
    1 Flash chip w/o dram buffer
    Works with DMA on a Marvell Bridge
    Speedsys: 0.55ms seek time
    ------------------------------
  • 32GB Generic "BR 32G"
    Phison ps3111-s11 Controller
    SBFC21.2 Firmware
    1 Flash chip w/o dram buffer
    Errors when using DMA on a Marvell Bridge
    Speedsys: 0.08ms seek time
    ------------------------------
  • 32GB Samsung PM830 mSATA
    Samsung N4Tanic controller
    CXM13D1Q Firmware
    4 flash chips with dram buffer
    Works with DMA on a Marvell Bridge
    Speedsys: 0.12ms seek time
    ------------------------------
  • LITEONIT LMS-32L6M-HP
    Marvell 88s89182-bjm2 controller
    DM51707 firmware
    Works with DMA on a Marvell Bridge
    4 flash chips with dram buffer
    Speedsys: 0.17ms seek time
    ------------------------------
  • 16GB SanDisk SDSA4DH-016G
    SanDisk 20 82 00253-2 controller
    2 flash chips w/o dram buffer
    Doesn't work reliably with the Marvell adapter
The attachment Atto.png is no longer available
The attachment Samsung.jpg is no longer available
The attachment LITEON.jpg is no longer available
The attachment BR32GB.jpg is no longer available

Reply 28 of 31, by douglar

User metadata
Rank l33t
Rank
l33t

And one last follow up-- Why not try a UDMA card to see if avoiding the PIIX controller entirely is the best route to happiness?

Below are the numbers when I add a Promise Technology FastTrak SATA150 TX2plus Controller based on the PDC20375 chip. You will notice that the UDMA numbers have an extra digit. Impressive improvements in synthetics, no doubt.

The attachment LITEON6.jpg is no longer available
The attachment ATTO UDMA.png is no longer available

What is the real world impact? I set up a program to track the elapsed time between when the autoexec.bat is processed and when the windows startup folder is executed in Win98se. There was some variability, so I did a number of tests, discarded the top and bottom before averaging the rest.

Boot Time:

  • UDMA6 on PDC20375: 14.2 Seconds
  • UDMA2 on PDC20375: 14.3 Seconds
  • WDMA on PIIX: 16.1 Seconds
  • PIO3 on PIIX: 16.1 Seconds

So >10% faster boot times with the add-in board controller. That's not going to change the world, but it is almost sort of noticeable.

Why are UDMA 2 and UDMA 6 in a dead heat? Maybe the 166MMX isn't fast enough to take advantage of the extra bandwidth provided by UDMA6 in this test.

Why do WDMA and PIO3 tie? My guess is that the 25% bandwidth gain on large transfers is offset by the slightly higher latency on small transfers. But don't get me wrong. There is definitely a better feel about the computer when DMA is in use. UDMA > DMA >>>> PIO. I'd say that adding a UDMA controller is the way to go if you got one sitting in your tool box and you are using sata storage. I don't see the down side. Would I pay > $20 to buy one just because I have a PIIX controller? Ehhh? That's a more difficult proposition if I already have WDMA working. I could probably get a bigger boost in performance by putting that money towards a 233MMX than I could by purchasing the PCI card. But if I am using SATA storage with a J-micron PATA-Sata bridge (no DMA), it's likely cheaper cheaper to buy a used UDMA card than it is to buy a new Marvell bridge. Just make sure you get one with a bootable BIOS on it.

p.s. I'm open to any recommendation for a better windows "real world" test. Unzipping a large archive? Installing .Net? Those would probably be good tests.

Reply 29 of 31, by jakethompson1

User metadata
Rank Oldbie
Rank
Oldbie

I may have MWDMA2 through the JMicron on PIIX3 partially working.

Via NetBSD, I found that at least in my configuration (430HX with a Toshiba DT01ACA100 1TB spinning disk on the other end of the JMicron), it's MWDMA2 writes that don't work reliably. MWDMA2 reads do work as do PIO4 writes.

I have been able to replicate this in Windows 95 via two steps.

YOU COULD LOSE ALL DATA ATTEMPTING THIS DUE TO MASSIVE DATA CORRUPTION IF IT DOESN'T WORK

1. At least on my system, neither the BIOS nor Win95 initialize the drive to MWDMA2 mode. A very quick and dirty (no compatibility delays or error handling) .COM file to call from autoexec.bat to do this on each boot is attached. Without this, enabling DMA in Win95 results in read corruption and an unusable system as things crash randomly.

2. C:\windows\system\iosubsys\esdi_506.pdr needs to be patched to suppress DMA writes. To do that, use a disassembler (e.g., objdump -b binary -m i386:intel -D esdi_506.pdr) to locate the mov al,0cah instruction. In the version that ships with Win95C, it's at offset f5a:

     f4d:       74 16                   je     0xf65
f4f: e8 8f 03 00 00 call 0x12e3
f54: 72 0f jb 0xf65
f56: 80 4f 2e 04 or BYTE PTR [edi+0x2e],0x4
f5a: b0 ca mov al,0xca

Looking above that, the je 0xf65 instruction needs to be changed to jmp to skip over the attempt at setting up DMA (which 0x12e3 is). So, at offset f4d, for this copy of esdi_506.pdr, use a hex editor to change 74 to eb to always do PIO writes. After patching esdi_506.pdr as such, and calling mwdma2.com from autoexec.bat, you should be able to check the DMA box if your system works the way mine does:

The attachment roadkil.png is no longer available

Reply 30 of 31, by douglar

User metadata
Rank l33t
Rank
l33t
jakethompson1 wrote on 2025-09-06, 20:40:

I may have MWDMA2 through the JMicron on PIIX3 partially working.

....

YOU COULD LOSE ALL DATA ATTEMPTING THIS DUE TO MASSIVE DATA CORRUPTION IF IT DOESN'T WORK

That's a very daring binary patch there. How did you know that the the branch was near call 0x12e3 ?

Reply 31 of 31, by jakethompson1

User metadata
Rank Oldbie
Rank
Oldbie
douglar wrote on 2025-09-08, 13:49:
jakethompson1 wrote on 2025-09-06, 20:40:

I may have MWDMA2 through the JMicron on PIIX3 partially working.

....

YOU COULD LOSE ALL DATA ATTEMPTING THIS DUE TO MASSIVE DATA CORRUPTION IF IT DOESN'T WORK

That's a very daring binary patch there. How did you know that the the branch was near call 0x12e3 ?

CA is the ATA command for Write DMA, so that is the part that needs to be not-taken.
Also, the Windows 98 DDK version has symbols, and has a close enough structure that it can be located using the mov al,0cah in other versions