Cancel/flush DMA transaction

Windows 7, KMDF, PCIe, DMA, ScatterGather

We have a driver that can queue up multiple DMA transaction request from a user application.

The user application can issue a cancel DMA transaction request at any time.

Most cases there are DMA transaction requests sitting on a queue waiting to be processed, when a user makes a flush/cancel request.

Is there a way to cancel/flush a requested dma transaction that has been referenced in EvtProgramDmaFunction then it was placed on a queue but hasn’t been called with wdfDmaTransactionExecute?

–hlf

  1. Are the requests queued in the hardware, or in the software queue?
  2. Is data flow steady, which will make the requests complete in finite time, or it’s possible that a request could be waiting for long time to complete?
  3. Do you have to queue multiple requests in your DMA queue to avoid data loss, or you could have a single transaction in DMA queue?

I’m working off memory here, but I believe that in Windows 8 we added a DMA function to allow cancellation, that I believe will work with the regular scatter-gather APIs. But you need to request a version 3 DMA adapter (rather than version 2) and use the new function. And I believe the version of KMDF that shipped with 8 has the cancellation support.

I do not believe that it’s available in Windows 7, and I’m not sure if it works with KMDF 1.13 on Windows 7.

-p

From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Ford, Harry L
Sent: Wednesday, December 10, 2014 1:45 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Cancel/flush DMA transaction

Windows 7, KMDF, PCIe, DMA, ScatterGather

We have a driver that can queue up multiple DMA transaction request from a user application.

The user application can issue a cancel DMA transaction request at any time.

Most cases there are DMA transaction requests sitting on a queue waiting to be processed, when a user makes a flush/cancel request.

Is there a way to cancel/flush a requested dma transaction that has been referenced in EvtProgramDmaFunction then it was placed on a queue but hasn’t been called with wdfDmaTransactionExecute?

–hlf


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

@Peter:

Do you mean a function to cancel a pending GetScatterGatherList?

How much delay are you SEEING that would make this worthwhile even considering?

Why not just consider anything after starting the transaction to be “missed” by the user?

In my experience, it is almost always a mistake to attempt to cancel in-progress DMA transactions. I did it for years, until I *finally* came to the realization that doing so wasn’t accomplishing anything actually useful.

If you have a very special case where this is required, I’d like to learn about it.

Peter
OSR
@OSRDrivers

It’s not the delay that is at issue but the use of materials. This involves a process where (depending on customer) the cost of materials could be very expensive.

-hlf
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@osr.com
Sent: Thursday, December 11, 2014 5:23 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Cancel/flush DMA transaction

How much delay are you SEEING that would make this worthwhile even considering?

Why not just consider anything after starting the transaction to be “missed” by the user?

In my experience, it is almost always a mistake to attempt to cancel in-progress DMA transactions. I did it for years, until I *finally* came to the realization that doing so wasn’t accomplishing anything actually useful.

If you have a very special case where this is required, I’d like to learn about it.

Peter
OSR
@OSRDrivers


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

DMA-programmed jevelry work? :slight_smile:

One of the solutions is to have a reset path to your HW.

Just reset it by a register write, and then issue commands to return it physically to initial state. Ping the registers in progress of this to ensure the HW is really in initial state, with all DMA engines idle.

After this, complete all pending DMA xacts as cancelled.


Maxim S. Shatskih
Microsoft MVP on File System And Storage
xxxxx@storagecraft.com
http://www.storagecraft.com

“Ford, Harry L” wrote in message news:xxxxx@ntdev…
It’s not the delay that is at issue but the use of materials. This involves a process where (depending on customer) the cost of materials could be very expensive.

-hlf
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@osr.com
Sent: Thursday, December 11, 2014 5:23 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Cancel/flush DMA transaction



How much delay are you SEEING that would make this worthwhile even considering?

Why not just consider anything after starting the transaction to be “missed” by the user?

In my experience, it is almost always a mistake to attempt to cancel in-progress DMA transactions. I did it for years, until I finally came to the realization that doing so wasn’t accomplishing anything actually useful.

If you have a very special case where this is required, I’d like to learn about it.

Peter
OSR
@OSRDrivers


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Yes, I read that there and tired the cancel in windows 7 but it didn’t work though I don’t know what version of DMA adapter I have I’ll try and figure that out and then upgrade to 3 and give a try again.

Thanks,
-hlf

From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Peter Wieland
Sent: Wednesday, December 10, 2014 5:19 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Cancel/flush DMA transaction

I’m working off memory here, but I believe that in Windows 8 we added a DMA function to allow cancellation, that I believe will work with the regular scatter-gather APIs. But you need to request a version 3 DMA adapter (rather than version 2) and use the new function. And I believe the version of KMDF that shipped with 8 has the cancellation support.

I do not believe that it’s available in Windows 7, and I’m not sure if it works with KMDF 1.13 on Windows 7.

-p

From: xxxxx@lists.osr.commailto:xxxxx [mailto:xxxxx@lists.osr.com] On Behalf Of Ford, Harry L
Sent: Wednesday, December 10, 2014 1:45 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Cancel/flush DMA transaction

Windows 7, KMDF, PCIe, DMA, ScatterGather

We have a driver that can queue up multiple DMA transaction request from a user application.

The user application can issue a cancel DMA transaction request at any time.

Most cases there are DMA transaction requests sitting on a queue waiting to be processed, when a user makes a flush/cancel request.

Is there a way to cancel/flush a requested dma transaction that has been referenced in EvtProgramDmaFunction then it was placed on a queue but hasn’t been called with wdfDmaTransactionExecute?

–hlf


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer</mailto:xxxxx>

  1. Software queue

  2. Requests are processed quickly by the external hardware attached to the PCIe, data flow is steady. There are physical processes happening resulting in material($Cost) being used.

  3. Yes, there are multiple requests queued that for all intent and purposes could be infinite, very rarely will there be a single transaction.

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@broadcom.com
Sent: Wednesday, December 10, 2014 4:16 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Cancel/flush DMA transaction

  1. Are the requests queued in the hardware, or in the software queue?
  2. Is data flow steady, which will make the requests complete in finite time, or it’s possible that a request could be waiting for long time to complete?
  3. Do you have to queue multiple requests in your DMA queue to avoid data loss, or you could have a single transaction in DMA queue?

NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

What causes the waste of materials? The delay in waiting for the command to be aborted, or the flow of bytes to the target?

With bus-mastering DMA your driver controls the flow of bytes to the target. WdfDmaTransactionExecute() will call your driver back to trigger the actual DMA operation. So you could mark the request context associated with the DMA such that your DmaTransactionExecute will skip the DMA transfer, report a DMA error and complete the request.

Just because you called Execute doesn’t mean you must transfer the bytes.

-p

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Ford, Harry L
Sent: Thursday, December 11, 2014 6:01 AM
To: Windows System Software Devs Interest List
Subject: RE: RE:[ntdev] Cancel/flush DMA transaction

It’s not the delay that is at issue but the use of materials. This involves a process where (depending on customer) the cost of materials could be very expensive.

-hlf
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@osr.com
Sent: Thursday, December 11, 2014 5:23 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Cancel/flush DMA transaction

How much delay are you SEEING that would make this worthwhile even considering?

Why not just consider anything after starting the transaction to be “missed” by the user?

In my experience, it is almost always a mistake to attempt to cancel in-progress DMA transactions. I did it for years, until I *finally* came to the realization that doing so wasn’t accomplishing anything actually useful.

If you have a very special case where this is required, I’d like to learn about it.

Peter
OSR
@OSRDrivers


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

The only valid versions on Windows 7 are 1 and 2, and probably only 2 since 1 was a LONG time ago. The default is 2.

Version 3 isn’t valid until Windows 8.

-p

From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Ford, Harry L
Sent: Thursday, December 11, 2014 6:32 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Cancel/flush DMA transaction

Yes, I read that there and tired the cancel in windows 7 but it didn’t work though I don’t know what version of DMA adapter I have I’ll try and figure that out and then upgrade to 3 and give a try again.

Thanks,
-hlf

From: xxxxx@lists.osr.commailto:xxxxx [mailto:xxxxx@lists.osr.com] On Behalf Of Peter Wieland
Sent: Wednesday, December 10, 2014 5:19 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Cancel/flush DMA transaction

I’m working off memory here, but I believe that in Windows 8 we added a DMA function to allow cancellation, that I believe will work with the regular scatter-gather APIs. But you need to request a version 3 DMA adapter (rather than version 2) and use the new function. And I believe the version of KMDF that shipped with 8 has the cancellation support.

I do not believe that it’s available in Windows 7, and I’m not sure if it works with KMDF 1.13 on Windows 7.

-p

From: xxxxx@lists.osr.commailto:xxxxx [mailto:xxxxx@lists.osr.com] On Behalf Of Ford, Harry L
Sent: Wednesday, December 10, 2014 1:45 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Cancel/flush DMA transaction

Windows 7, KMDF, PCIe, DMA, ScatterGather

We have a driver that can queue up multiple DMA transaction request from a user application.

The user application can issue a cancel DMA transaction request at any time.

Most cases there are DMA transaction requests sitting on a queue waiting to be processed, when a user makes a flush/cancel request.

Is there a way to cancel/flush a requested dma transaction that has been referenced in EvtProgramDmaFunction then it was placed on a queue but hasn’t been called with wdfDmaTransactionExecute?

–hlf


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer</mailto:xxxxx></mailto:xxxxx>

What causes the waste of materials? Flow of bytes to the target.

Thanks for the idea I’ll implement that with lots of comments so, if I come back I won’t wonder why I didn’t just cancel the DMA.

-hlf

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Peter Wieland
Sent: Thursday, December 11, 2014 12:28 PM
To: Windows System Software Devs Interest List
Subject: RE: RE:[ntdev] Cancel/flush DMA transaction

What causes the waste of materials? The delay in waiting for the command to be aborted, or the flow of bytes to the target?

With bus-mastering DMA your driver controls the flow of bytes to the target. WdfDmaTransactionExecute() will call your driver back to trigger the actual DMA operation. So you could mark the request context associated with the DMA such that your DmaTransactionExecute will skip the DMA transfer, report a DMA error and complete the request.

Just because you called Execute doesn’t mean you must transfer the bytes.

-p

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Ford, Harry L
Sent: Thursday, December 11, 2014 6:01 AM
To: Windows System Software Devs Interest List
Subject: RE: RE:[ntdev] Cancel/flush DMA transaction

It’s not the delay that is at issue but the use of materials. This involves a process where (depending on customer) the cost of materials could be very expensive.

-hlf
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@osr.com
Sent: Thursday, December 11, 2014 5:23 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Cancel/flush DMA transaction

How much delay are you SEEING that would make this worthwhile even considering?

Why not just consider anything after starting the transaction to be “missed” by the user?

In my experience, it is almost always a mistake to attempt to cancel in-progress DMA transactions. I did it for years, until I *finally* came to the realization that doing so wasn’t accomplishing anything actually useful.

If you have a very special case where this is required, I’d like to learn about it.

Peter
OSR
@OSRDrivers


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Thanks for giving us the background, Mr. Ford. I *particularly* appreciate it, because it gives me a concrete example to cite in class about the rare cases when you would want to cancel a DMA operation.

Peter
OSR
@OSRDrivers

I assume your device uses PCIe bus master, not ISA system DMA. For a bus master device, there is no “cancel DMA” concept. You stop an operation in progress in the device-specific way. If there are more requests queued, and they are marked for cancellation, you just short-circuit them to completion, without actually posting to the device hardware.