[Solved] ATA DMA Multitasking

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
Agola
Member
Member
Posts: 155
Joined: Sun Nov 20, 2016 7:26 am
Location: Somewhere

[Solved] ATA DMA Multitasking

Post by Agola »

Hi, finally I've completely finished my multitasking and scheduler code.
It works fast, supports V8086 mode tasks and ring changes.

Now, for ATA, can I do a new DMA read while other is working? I couldn't find anything about it in Busmaster DMA documentation. (Documentation is: http://www.osdever.net/downloads/docs/idems100.zip)

Or should I wait a transfer to complete, then start a new one? In other words can I do more than two transfers same time / one is not completed yet? Or should I only do one transfer at a time, and wait transfer to finish with a semaphore, mutex, etc.

If I can do more than two transfers same time, should I do anything special? Is running it as usual enough?

Thanks in advance :|
Last edited by Agola on Mon Mar 13, 2017 1:09 pm, edited 1 time in total.
Keyboard not found!

Press F1 to run setup.
Press F2 to continue.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: ATA DMA Multitasking

Post by Brendan »

Hi,
Agola wrote:Now, for ATA, can I do a new DMA read while other is working? I couldn't find anything about it in Busmaster DMA documentation. (Documentation is: http://www.osdever.net/downloads/docs/idems100.zip)
That depends. Typically there are 2 ATA controllers (primary and secondary) that are considered "independent" (even though it's likely they're both part of the same chip), where each controller can have 2 drives (master and slave), and each controller has its own bus mastering.

There are 4 cases:
  • You can't do multiple DMA transfers at the same time from the same drive (but may be able to queue up multiple transfers to run one after the other, if both transfers are "read" or if both are "write").
  • You can't do multiple DMA transfers at the same time from different drives that are attached to the same ATA controller. This is a restriction caused by "2 devices share the same cable".
  • You should (if the hardware isn't buggy) be able to do multiple DMA transfers at the same time from drives that are attached to different ATA controllers; because the ATA controllers are independent.
  • If I remember correctly (unfortunately I can't find where I read this); there are some buggy ATA controllers where you can't do multiple DMA transfers at the same time using different ATA controllers without problems.
Agola wrote:Or should I wait a transfer to complete, then start a new one? In other words can I do more than two transfers same time / one is not completed yet? Or should I only do one transfer at a time, and wait transfer to finish with a semaphore, mutex, etc.
While one command is in progress you shouldn't touch any of the bus master's registers. This means that you can't/shouldn't add a second transfer after setting the "start/stop bus master" flag and before the IRQ occurs.


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
User avatar
Agola
Member
Member
Posts: 155
Joined: Sun Nov 20, 2016 7:26 am
Location: Somewhere

Re: ATA DMA Multitasking

Post by Agola »

Brendan wrote:Hi,
Agola wrote:Now, for ATA, can I do a new DMA read while other is working? I couldn't find anything about it in Busmaster DMA documentation. (Documentation is: http://www.osdever.net/downloads/docs/idems100.zip)
That depends. Typically there are 2 ATA controllers (primary and secondary) that are considered "independent" (even though it's likely they're both part of the same chip), where each controller can have 2 drives (master and slave), and each controller has its own bus mastering.

There are 4 cases:
  • You can't do multiple DMA transfers at the same time from the same drive (but may be able to queue up multiple transfers to run one after the other, if both transfers are "read" or if both are "write").
  • You can't do multiple DMA transfers at the same time from different drives that are attached to the same ATA controller. This is a restriction caused by "2 devices share the same cable".
  • You should (if the hardware isn't buggy) be able to do multiple DMA transfers at the same time from drives that are attached to different ATA controllers; because the ATA controllers are independent.
  • If I remember correctly (unfortunately I can't find where I read this); there are some buggy ATA controllers where you can't do multiple DMA transfers at the same time using different ATA controllers without problems.
Agola wrote:Or should I wait a transfer to complete, then start a new one? In other words can I do more than two transfers same time / one is not completed yet? Or should I only do one transfer at a time, and wait transfer to finish with a semaphore, mutex, etc.
While one command is in progress you shouldn't touch any of the bus master's registers. This means that you can't/shouldn't add a second transfer after setting the "start/stop bus master" flag and before the IRQ occurs.


Cheers,

Brendan
That was really clear. Thanks.
Keyboard not found!

Press F1 to run setup.
Press F2 to continue.
Post Reply