problems with DMA transfer with size > 4k

Hi there

I’v got to write a WDM driver for a PCI card which is bus master capable
but not scatter/gather. I try to follow the DMA suggestions in the
driver books and I actually could lounge a transfer but just with a size
less than one page. As soon as the size is bigger then one page the data
I observe with a PCI snooper is actually sometimes the data which I
wrote on the last DMA transfer with size under or equal to one page size
(???). But not just the data on the secound page, oddly the whole data
package is not the one it should be! I suspect it has to do with the map
registers. I’m working on a x86 XP system. Could it be that on this
system I can make no bigger DMA transfer than one page size? Would be a
shame!

Thanks for help
Daniel

Daniel,

The PCI hard has limitations. You mention that it has no scatter/gather, so
it’s obviously your task to give it a set of pages to read from. If you try
to transfer “more than 4K”, then the second page will potentially be a
non-consecutive page, i.e. start with page 0xABCD0000, and second page is
0xBDEC4000. To transfer this, you’d have to be able to tell the PCI card two
addresses, one for each page (obviusly, one more for every 4K transferred).

I’m not sure which call you use to get the list of physical pages, but I’m
sure you’ve got that covered, as your hardware must take a physical address
for the transfer.

I don’t know if there is a way to allocate memory that is contiguously
mapped. If not, then you’d have to split it at every 4K boundary.

There’s also the possibility that your hardware isn’t designed for more than
4K pages, so it’s counter of “how far into the page” only has 12-bits (or
less if it’s reading bigger chunks than bytes, say 10 bits of DWORD items).

There may of course be some completely different reason for the trouble
you’re seeing, but these are some ideas.


Mats

-----Original Message-----
From: Daniel Luethi [mailto:xxxxx@psi.ch]
Sent: Friday, January 16, 2004 12:45 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] problems with DMA transfer with size > 4k

Hi there

I’v got to write a WDM driver for a PCI card which is bus
master capable
but not scatter/gather. I try to follow the DMA suggestions in the
driver books and I actually could lounge a transfer but just
with a size
less than one page. As soon as the size is bigger then one
page the data
I observe with a PCI snooper is actually sometimes the data which I
wrote on the last DMA transfer with size under or equal to
one page size
(???). But not just the data on the secound page, oddly the
whole data
package is not the one it should be! I suspect it has to do
with the map
registers. I’m working on a x86 XP system. Could it be that on this
system I can make no bigger DMA transfer than one page size?
Would be a
shame!

Thanks for help
Daniel


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@3dlabs.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Mats

Thanks for your answer. It seems logical what you said, but I thought
these map registers kind of replacing the scatter/gather “disability”
from the PCI bus master card, so that the card simply can transmit with
an incrementing address starting with that address I got from
MapTransfer() even if the size is bigger than one page (4k). Or am I
wrong and misunderstood the sense of these map registers completely?

Daniel

xxxxx@3Dlabs.com wrote:

Daniel,

The PCI hard has limitations. You mention that it has no scatter/gather, so
it’s obviously your task to give it a set of pages to read from. If you try
to transfer “more than 4K”, then the second page will potentially be a
non-consecutive page, i.e. start with page 0xABCD0000, and second page is
0xBDEC4000. To transfer this, you’d have to be able to tell the PCI card two
addresses, one for each page (obviusly, one more for every 4K transferred).

I’m not sure which call you use to get the list of physical pages, but I’m
sure you’ve got that covered, as your hardware must take a physical address
for the transfer.

I don’t know if there is a way to allocate memory that is contiguously
mapped. If not, then you’d have to split it at every 4K boundary.

There’s also the possibility that your hardware isn’t designed for more than
4K pages, so it’s counter of “how far into the page” only has 12-bits (or
less if it’s reading bigger chunks than bytes, say 10 bits of DWORD items).

There may of course be some completely different reason for the trouble
you’re seeing, but these are some ideas.


Mats

>-----Original Message-----
>From: Daniel Luethi [mailto:xxxxx@psi.ch]
>Sent: Friday, January 16, 2004 12:45 PM
>To: Windows System Software Devs Interest List
>Subject: [ntdev] problems with DMA transfer with size > 4k
>
>
>Hi there
>
>I’v got to write a WDM driver for a PCI card which is bus
>master capable
>but not scatter/gather. I try to follow the DMA suggestions in the
>driver books and I actually could lounge a transfer but just
>with a size
>less than one page. As soon as the size is bigger then one
>page the data
>I observe with a PCI snooper is actually sometimes the data which I
>wrote on the last DMA transfer with size under or equal to
>one page size
>(???). But not just the data on the secound page, oddly the
>whole data
>package is not the one it should be! I suspect it has to do
>with the map
>registers. I’m working on a x86 XP system. Could it be that on this
>system I can make no bigger DMA transfer than one page size?
>Would be a
>shame!
>
>Thanks for help
>Daniel
>
>
>—
>Questions? First check the Kernel Driver FAQ at

http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@3dlabs.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Daniel,

Can’t comment on how map registers work, but thinking about it logically:
You HAVE to get the different mapped regions over to the hardware. I’m not
familiar with the exact behaviour of the calls you use, but you should be
able to at least figure out from the HW specs of your device if it’s ABLE to
take more than one address for the data to be transmitted. If it’s only got
ONE address register (per transfer entry), then you’d have to make sure that
all the data is in sequential memory, or split it into smaller chunks.

Our devices have scatter/gather mechanism, so we don’t have to worry about
what pages are where in memory except for the setup.

Another way to do it would of course be to map a region of memory that is
contiguous, and then move your data from the original location to the
contiguous section. This would not be a performance option, but if the
overhead of setting up the transfer is really big, it may be beneficial to
do this. [If you do, you may want map this memory as
unchachable/writecombined, unless you’re also going to read from it, as this
will help the performance of the system]. Note: I’m not sure if there is a
way to allocate memory that is contiguous.


Mats

-----Original Message-----
From: Daniel Luethi [mailto:xxxxx@psi.ch]
Sent: Friday, January 16, 2004 1:24 PM
To: Windows System Software Devs Interest List
Cc: xxxxx@lists.osr.com
Subject: Re:[ntdev] problems with DMA transfer with size > 4k

Mats

Thanks for your answer. It seems logical what you said, but I thought
these map registers kind of replacing the scatter/gather “disability”
from the PCI bus master card, so that the card simply can
transmit with
an incrementing address starting with that address I got from
MapTransfer() even if the size is bigger than one page (4k). Or am I
wrong and misunderstood the sense of these map registers completely?

Daniel

xxxxx@3Dlabs.com wrote:

> Daniel,
>
> The PCI hard has limitations. You mention that it has no
scatter/gather, so
> it’s obviously your task to give it a set of pages to read
from. If you try
> to transfer “more than 4K”, then the second page will
potentially be a
> non-consecutive page, i.e. start with page 0xABCD0000, and
second page is
> 0xBDEC4000. To transfer this, you’d have to be able to tell
the PCI card two
> addresses, one for each page (obviusly, one more for every
4K transferred).
>
> I’m not sure which call you use to get the list of physical
pages, but I’m
> sure you’ve got that covered, as your hardware must take a
physical address
> for the transfer.
>
> I don’t know if there is a way to allocate memory that is
contiguously
> mapped. If not, then you’d have to split it at every 4K boundary.
>
> There’s also the possibility that your hardware isn’t
designed for more than
> 4K pages, so it’s counter of “how far into the page” only
has 12-bits (or
> less if it’s reading bigger chunks than bytes, say 10 bits
of DWORD items).
>
> There may of course be some completely different reason for
the trouble
> you’re seeing, but these are some ideas.
>
> –
> Mats
>
>
>
>>-----Original Message-----
>>From: Daniel Luethi [mailto:xxxxx@psi.ch]
>>Sent: Friday, January 16, 2004 12:45 PM
>>To: Windows System Software Devs Interest List
>>Subject: [ntdev] problems with DMA transfer with size > 4k
>>
>>
>>Hi there
>>
>>I’v got to write a WDM driver for a PCI card which is bus
>>master capable
>>but not scatter/gather. I try to follow the DMA suggestions in the
>>driver books and I actually could lounge a transfer but just
>>with a size
>>less than one page. As soon as the size is bigger then one
>>page the data
>>I observe with a PCI snooper is actually sometimes the data which I
>>wrote on the last DMA transfer with size under or equal to
>>one page size
>>(???). But not just the data on the secound page, oddly the
>>whole data
>>package is not the one it should be! I suspect it has to do
>>with the map
>>registers. I’m working on a x86 XP system. Could it be that on this
>>system I can make no bigger DMA transfer than one page size?
>>Would be a
>>shame!
>>
>>Thanks for help
>>Daniel
>>
>>
>>—
>>Questions? First check the Kernel Driver FAQ at
>
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@3dlabs.com
> To unsubscribe send a blank email to
xxxxx@lists.osr.com
>


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@3dlabs.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Dear Mat

Unfortunately our device is NOT able to perform scatter/gather which
means, there is just one TAP address (Target address pointer) which we
hand over to our hardware. I read again in Peter Viscarolas book
carefully and with a dissapointment I think I missunderstood the use of
map registers especially if the HAL doesn’t support hardware system
scatter/gather. In this case the HAL copies simply the memory from the
contigous driver buffer to the paged user buffer as you said, but this
is a big loss of performance and out of question. I wonder if I can
allocate contigous memory from user mode???

thx
Daniel

xxxxx@3Dlabs.com wrote:

Daniel,

Can’t comment on how map registers work, but thinking about it logically:
You HAVE to get the different mapped regions over to the hardware. I’m not
familiar with the exact behaviour of the calls you use, but you should be
able to at least figure out from the HW specs of your device if it’s ABLE to
take more than one address for the data to be transmitted. If it’s only got
ONE address register (per transfer entry), then you’d have to make sure that
all the data is in sequential memory, or split it into smaller chunks.

Our devices have scatter/gather mechanism, so we don’t have to worry about
what pages are where in memory except for the setup.

Another way to do it would of course be to map a region of memory that is
contiguous, and then move your data from the original location to the
contiguous section. This would not be a performance option, but if the
overhead of setting up the transfer is really big, it may be beneficial to
do this. [If you do, you may want map this memory as
unchachable/writecombined, unless you’re also going to read from it, as this
will help the performance of the system]. Note: I’m not sure if there is a
way to allocate memory that is contiguous.


Mats

>-----Original Message-----
>From: Daniel Luethi [mailto:xxxxx@psi.ch]
>Sent: Friday, January 16, 2004 1:24 PM
>To: Windows System Software Devs Interest List
>Cc: xxxxx@lists.osr.com
>Subject: Re:[ntdev] problems with DMA transfer with size > 4k
>
>
>Mats
>
>Thanks for your answer. It seems logical what you said, but I thought
>these map registers kind of replacing the scatter/gather “disability”
>from the PCI bus master card, so that the card simply can
>transmit with
>an incrementing address starting with that address I got from
>MapTransfer() even if the size is bigger than one page (4k). Or am I
>wrong and misunderstood the sense of these map registers completely?
>
>Daniel
>
>
>
>
>
>
>xxxxx@3Dlabs.com wrote:
>
>
>>Daniel,
>>
>>The PCI hard has limitations. You mention that it has no
>
>scatter/gather, so
>
>>it’s obviously your task to give it a set of pages to read
>
>from. If you try
>
>>to transfer “more than 4K”, then the second page will
>
>potentially be a
>
>>non-consecutive page, i.e. start with page 0xABCD0000, and
>
>second page is
>
>>0xBDEC4000. To transfer this, you’d have to be able to tell
>
>the PCI card two
>
>>addresses, one for each page (obviusly, one more for every
>
>4K transferred).
>
>>I’m not sure which call you use to get the list of physical
>
>pages, but I’m
>
>>sure you’ve got that covered, as your hardware must take a
>
>physical address
>
>>for the transfer.
>>
>>I don’t know if there is a way to allocate memory that is
>
>contiguously
>
>>mapped. If not, then you’d have to split it at every 4K boundary.
>>
>>There’s also the possibility that your hardware isn’t
>
>designed for more than
>
>>4K pages, so it’s counter of “how far into the page” only
>
>has 12-bits (or
>
>>less if it’s reading bigger chunks than bytes, say 10 bits
>
>of DWORD items).
>
>>There may of course be some completely different reason for
>
>the trouble
>
>>you’re seeing, but these are some ideas.
>>
>>–
>>Mats
>>
>>
>>
>>
>>>-----Original Message-----
>>>From: Daniel Luethi [mailto:xxxxx@psi.ch]
>>>Sent: Friday, January 16, 2004 12:45 PM
>>>To: Windows System Software Devs Interest List
>>>Subject: [ntdev] problems with DMA transfer with size > 4k
>>>
>>>
>>>Hi there
>>>
>>>I’v got to write a WDM driver for a PCI card which is bus
>>>master capable
>>>but not scatter/gather. I try to follow the DMA suggestions in the
>>>driver books and I actually could lounge a transfer but just
>>>with a size
>>>less than one page. As soon as the size is bigger then one
>>>page the data
>>>I observe with a PCI snooper is actually sometimes the data which I
>>>wrote on the last DMA transfer with size under or equal to
>>>one page size
>>>(???). But not just the data on the secound page, oddly the
>>>whole data
>>>package is not the one it should be! I suspect it has to do
>>>with the map
>>>registers. I’m working on a x86 XP system. Could it be that on this
>>>system I can make no bigger DMA transfer than one page size?
>>>Would be a
>>>shame!
>>>
>>>Thanks for help
>>>Daniel
>>>
>>>
>>>—
>>>Questions? First check the Kernel Driver FAQ at
>>
>>http://www.osronline.com/article.cfm?id=256
>>
>>You are currently subscribed to ntdev as: xxxxx@3dlabs.com
>>To unsubscribe send a blank email to
>
>xxxxx@lists.osr.com
>
>
>—
>Questions? First check the Kernel Driver FAQ at

http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@3dlabs.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Haven’t read Peter’s book (I’d be surprised if it covers much about graphics
anyways, most driver books don’t. No offense intended to Peter, I know how
many graphics chip companies there are and how many “other” chip companies
there are, and the latter is more than one order of magnitude bigger!).

Are you writing a generic driver, or something for a private purpose?

If you’re writing a generic driver, you probably can’t rely on the user
allocating the memory in a particular way, so you’d have to perform some
sort of copy at some point or another. OR just send a page at a time. This
would seem the easiest way to me.


Mats

-----Original Message-----
From: Daniel Luethi [mailto:xxxxx@psi.ch]
Sent: Friday, January 16, 2004 2:22 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] problems with DMA transfer with size > 4k

Dear Mat

Unfortunately our device is NOT able to perform scatter/gather which
means, there is just one TAP address (Target address pointer)
which we
hand over to our hardware. I read again in Peter Viscarolas book
carefully and with a dissapointment I think I missunderstood
the use of
map registers especially if the HAL doesn’t support hardware system
scatter/gather. In this case the HAL copies simply the memory
from the
contigous driver buffer to the paged user buffer as you said,
but this
is a big loss of performance and out of question. I wonder if I can
allocate contigous memory from user mode???

thx
Daniel

xxxxx@3Dlabs.com wrote:

> Daniel,
>
> Can’t comment on how map registers work, but thinking about
it logically:
> You HAVE to get the different mapped regions over to the
hardware. I’m not
> familiar with the exact behaviour of the calls you use, but
you should be
> able to at least figure out from the HW specs of your
device if it’s ABLE to
> take more than one address for the data to be transmitted.
If it’s only got
> ONE address register (per transfer entry), then you’d have
to make sure that
> all the data is in sequential memory, or split it into
smaller chunks.
>
> Our devices have scatter/gather mechanism, so we don’t have
to worry about
> what pages are where in memory except for the setup.
>
> Another way to do it would of course be to map a region of
memory that is
> contiguous, and then move your data from the original
location to the
> contiguous section. This would not be a performance option,
but if the
> overhead of setting up the transfer is really big, it may
be beneficial to
> do this. [If you do, you may want map this memory as
> unchachable/writecombined, unless you’re also going to read
from it, as this
> will help the performance of the system]. Note: I’m not
sure if there is a
> way to allocate memory that is contiguous.
>
> –
> Mats
>
>
>
>>-----Original Message-----
>>From: Daniel Luethi [mailto:xxxxx@psi.ch]
>>Sent: Friday, January 16, 2004 1:24 PM
>>To: Windows System Software Devs Interest List
>>Cc: xxxxx@lists.osr.com
>>Subject: Re:[ntdev] problems with DMA transfer with size > 4k
>>
>>
>>Mats
>>
>>Thanks for your answer. It seems logical what you said, but
I thought
>>these map registers kind of replacing the scatter/gather
“disability”
>>from the PCI bus master card, so that the card simply can
>>transmit with
>>an incrementing address starting with that address I got from
>>MapTransfer() even if the size is bigger than one page
(4k). Or am I
>>wrong and misunderstood the sense of these map registers completely?
>>
>>Daniel
>>
>>
>>
>>
>>
>>
>>xxxxx@3Dlabs.com wrote:
>>
>>
>>>Daniel,
>>>
>>>The PCI hard has limitations. You mention that it has no
>>
>>scatter/gather, so
>>
>>>it’s obviously your task to give it a set of pages to read
>>
>>from. If you try
>>
>>>to transfer “more than 4K”, then the second page will
>>
>>potentially be a
>>
>>>non-consecutive page, i.e. start with page 0xABCD0000, and
>>
>>second page is
>>
>>>0xBDEC4000. To transfer this, you’d have to be able to tell
>>
>>the PCI card two
>>
>>>addresses, one for each page (obviusly, one more for every
>>
>>4K transferred).
>>
>>>I’m not sure which call you use to get the list of physical
>>
>>pages, but I’m
>>
>>>sure you’ve got that covered, as your hardware must take a
>>
>>physical address
>>
>>>for the transfer.
>>>
>>>I don’t know if there is a way to allocate memory that is
>>
>>contiguously
>>
>>>mapped. If not, then you’d have to split it at every 4K boundary.
>>>
>>>There’s also the possibility that your hardware isn’t
>>
>>designed for more than
>>
>>>4K pages, so it’s counter of “how far into the page” only
>>
>>has 12-bits (or
>>
>>>less if it’s reading bigger chunks than bytes, say 10 bits
>>
>>of DWORD items).
>>
>>>There may of course be some completely different reason for
>>
>>the trouble
>>
>>>you’re seeing, but these are some ideas.
>>>
>>>–
>>>Mats
>>>
>>>
>>>
>>>
>>>>-----Original Message-----
>>>>From: Daniel Luethi [mailto:xxxxx@psi.ch]
>>>>Sent: Friday, January 16, 2004 12:45 PM
>>>>To: Windows System Software Devs Interest List
>>>>Subject: [ntdev] problems with DMA transfer with size > 4k
>>>>
>>>>
>>>>Hi there
>>>>
>>>>I’v got to write a WDM driver for a PCI card which is bus
>>>>master capable
>>>>but not scatter/gather. I try to follow the DMA
suggestions in the
>>>>driver books and I actually could lounge a transfer but just
>>>>with a size
>>>>less than one page. As soon as the size is bigger then one
>>>>page the data
>>>>I observe with a PCI snooper is actually sometimes the
data which I
>>>>wrote on the last DMA transfer with size under or equal to
>>>>one page size
>>>>(???). But not just the data on the secound page, oddly the
>>>>whole data
>>>>package is not the one it should be! I suspect it has to do
>>>>with the map
>>>>registers. I’m working on a x86 XP system. Could it be
that on this
>>>>system I can make no bigger DMA transfer than one page size?
>>>>Would be a
>>>>shame!
>>>>
>>>>Thanks for help
>>>>Daniel
>>>>
>>>>
>>>>—
>>>>Questions? First check the Kernel Driver FAQ at
>>>
>>>http://www.osronline.com/article.cfm?id=256
>>>
>>>You are currently subscribed to ntdev as: xxxxx@3dlabs.com
>>>To unsubscribe send a blank email to
>>
>>xxxxx@lists.osr.com
>>
>>
>>—
>>Questions? First check the Kernel Driver FAQ at
>
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@3dlabs.com
> To unsubscribe send a blank email to
xxxxx@lists.osr.com
>


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@3dlabs.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

----- Original Message -----
From: “Daniel Luethi”
Newsgroups: ntdev
To: “Windows System Software Devs Interest List”
Sent: Friday, January 16, 2004 9:21 AM
Subject: Re:[ntdev] problems with DMA transfer with size > 4k

> Dear Mat
>
> Unfortunately our device is NOT able to perform scatter/gather which
> means, there is just one TAP address (Target address pointer) which we
> hand over to our hardware. I read again in Peter Viscarolas book
> carefully and with a dissapointment I think I missunderstood the use of
> map registers especially if the HAL doesn’t support hardware system
> scatter/gather. In this case the HAL copies simply the memory from the
> contigous driver buffer to the paged user buffer as you said, but this
> is a big loss of performance and out of question. I wonder if I can
> allocate contigous memory from user mode???
>
> thx
> Daniel
>
[snip]
I’m hardly the DMA expert, but I think AllocateCommonBuffer is what you need
to look into. The memory so allocated will be contiguous as viewed from the
device, and perhaps the CPU as well depending on the system architecture.
This way you can allocate “logically contiguous” (viewed from I/O space)
buffer sizes larger than 1 page.

Philip Lukidis

If the OP allocated his adapter object correctly then the ‘map register’
physical address and length returned by MapTransfer will be physically
contiguous and suitable for a DMA operation. Yes this will be a bounce
buffer with copyin/copyout semantics, but the OP has shape-shifted his
original complaint that >4K DMA doesn’t work into ‘its too slow to copy the
data’. What is too slow here is a modern PCI device that can’t do
scatter/gather.

=====================
Mark Roddy

-----Original Message-----
From: Philip Lukidis [mailto:xxxxx@hotmail.com]
Sent: Friday, January 16, 2004 10:04 AM
To: Windows System Software Devs Interest List
Subject: Re: Re:[ntdev] problems with DMA transfer with size > 4k

----- Original Message -----
From: “Daniel Luethi”
> Newsgroups: ntdev
> To: “Windows System Software Devs Interest List”
> Sent: Friday, January 16, 2004 9:21 AM
> Subject: Re:[ntdev] problems with DMA transfer with size > 4k
>
>
> > Dear Mat
> >
> > Unfortunately our device is NOT able to perform scatter/gather which
> > means, there is just one TAP address (Target address
> pointer) which we
> > hand over to our hardware. I read again in Peter Viscarolas book
> > carefully and with a dissapointment I think I
> missunderstood the use of
> > map registers especially if the HAL doesn’t support hardware system
> > scatter/gather. In this case the HAL copies simply the
> memory from the
> > contigous driver buffer to the paged user buffer as you
> said, but this
> > is a big loss of performance and out of question. I wonder if I can
> > allocate contigous memory from user mode???
> >
> > thx
> > Daniel
> >
> [snip]
> I’m hardly the DMA expert, but I think AllocateCommonBuffer
> is what you need
> to look into. The memory so allocated will be contiguous as
> viewed from the
> device, and perhaps the CPU as well depending on the system
> architecture.
> This way you can allocate “logically contiguous” (viewed from
> I/O space)
> buffer sizes larger than 1 page.
>
> Philip Lukidis
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@stratus.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>

First suggestion is to place the toe of your boot, while moving at a
prodigious speed, firmly in the ass of the “designer” that chose or designed
the card.

You could pre-allocate multiple contiguous buffers and place them in a round
robin queue. Copy data into a buffer and trigger DMA, then copy data into
the next buffer on the queue. When DMA completes, start DMA on the next
buffer. Continue this till all data is done. You might go back and look at
the book by Viscarola and Mason. It has a good write-up on doing this method
of DMA.

Map registers on an x86 processor are not used.


Gary G. Little
Seagate Technologies, LLC

“Daniel Luethi” wrote in message news:xxxxx@ntdev…
> Hi there
>
> I’v got to write a WDM driver for a PCI card which is bus master capable
> but not scatter/gather. I try to follow the DMA suggestions in the
> driver books and I actually could lounge a transfer but just with a size
> less than one page. As soon as the size is bigger then one page the data
> I observe with a PCI snooper is actually sometimes the data which I
> wrote on the last DMA transfer with size under or equal to one page size
> (???). But not just the data on the secound page, oddly the whole data
> package is not the one it should be! I suspect it has to do with the map
> registers. I’m working on a x86 XP system. Could it be that on this
> system I can make no bigger DMA transfer than one page size? Would be a
> shame!
>
> Thanks for help
> Daniel
>
>

Dear Philip

That might be a good idea, but I think the memory allocated this way is
not accessable from user mode.

D.

Philip Lukidis wrote:

----- Original Message -----
From: “Daniel Luethi”
> Newsgroups: ntdev
> To: “Windows System Software Devs Interest List”
> Sent: Friday, January 16, 2004 9:21 AM
> Subject: Re:[ntdev] problems with DMA transfer with size > 4k
>
>
>
>>Dear Mat
>>
>>Unfortunately our device is NOT able to perform scatter/gather which
>>means, there is just one TAP address (Target address pointer) which we
>>hand over to our hardware. I read again in Peter Viscarolas book
>>carefully and with a dissapointment I think I missunderstood the use of
>>map registers especially if the HAL doesn’t support hardware system
>>scatter/gather. In this case the HAL copies simply the memory from the
>>contigous driver buffer to the paged user buffer as you said, but this
>>is a big loss of performance and out of question. I wonder if I can
>>allocate contigous memory from user mode???
>>
>>thx
>>Daniel
>>
>
> [snip]
> I’m hardly the DMA expert, but I think AllocateCommonBuffer is what you need
> to look into. The memory so allocated will be contiguous as viewed from the
> device, and perhaps the CPU as well depending on the system architecture.
> This way you can allocate “logically contiguous” (viewed from I/O space)
> buffer sizes larger than 1 page.
>
> Philip Lukidis
>

Hi

I think Common Buffer DMA model should help you.
Use AllocateCommonBuffer in your StartDevice.
This function gives the contiguous physical memory, than you map this memory
to User Mode

But, the trouble is that Windows can refuse to allocate the memory sometime,
if you need too large contiguous buffer.

Good Luck
Nikolay

“Daniel Luethi” wrote in message news:xxxxx@ntdev…
> Hi there
>
> I’v got to write a WDM driver for a PCI card which is bus master capable
> but not scatter/gather. I try to follow the DMA suggestions in the
> driver books and I actually could lounge a transfer but just with a size
> less than one page. As soon as the size is bigger then one page the data
> I observe with a PCI snooper is actually sometimes the data which I
> wrote on the last DMA transfer with size under or equal to one page size
> (???). But not just the data on the secound page, oddly the whole data
> package is not the one it should be! I suspect it has to do with the map
> registers. I’m working on a x86 XP system. Could it be that on this
> system I can make no bigger DMA transfer than one page size? Would be a
> shame!
>
> Thanks for help
> Daniel
>
>

There is a call that does something like that maps memory into user space.
In Video miniport you can use: VideoPortMapMemory

I’m sure there is a similar call for other types of drivers.


Mats

-----Original Message-----
From: Daniel Luethi [mailto:xxxxx@psi.ch]
Sent: Friday, January 16, 2004 4:23 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] problems with DMA transfer with size > 4k

Dear Philip

That might be a good idea, but I think the memory allocated
this way is
not accessable from user mode.

D.

Philip Lukidis wrote:

> ----- Original Message -----
> From: “Daniel Luethi”
> > Newsgroups: ntdev
> > To: “Windows System Software Devs Interest List”
>
> > Sent: Friday, January 16, 2004 9:21 AM
> > Subject: Re:[ntdev] problems with DMA transfer with size > 4k
> >
> >
> >
> >>Dear Mat
> >>
> >>Unfortunately our device is NOT able to perform scatter/gather which
> >>means, there is just one TAP address (Target address
> pointer) which we
> >>hand over to our hardware. I read again in Peter Viscarolas book
> >>carefully and with a dissapointment I think I
> missunderstood the use of
> >>map registers especially if the HAL doesn’t support hardware system
> >>scatter/gather. In this case the HAL copies simply the
> memory from the
> >>contigous driver buffer to the paged user buffer as you
> said, but this
> >>is a big loss of performance and out of question. I wonder if I can
> >>allocate contigous memory from user mode???
> >>
> >>thx
> >>Daniel
> >>
> >
> > [snip]
> > I’m hardly the DMA expert, but I think AllocateCommonBuffer
> is what you need
> > to look into. The memory so allocated will be contiguous
> as viewed from the
> > device, and perhaps the CPU as well depending on the system
> architecture.
> > This way you can allocate “logically contiguous” (viewed
> from I/O space)
> > buffer sizes larger than 1 page.
> >
> > Philip Lukidis
> >
>
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@3dlabs.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

At 07:28 PM 1/16/2004 +0300, you wrote:

Hi

I think Common Buffer DMA model should help you.
Use AllocateCommonBuffer in your StartDevice.
This function gives the contiguous physical memory, than you map this memory
to User Mode

Isn’t a common buffer allocated from the non-paged pool? If so, you have to
be careful with how large a buffer you allocate. Mapping it back to the
user program sounds like a bad idea. I would think you want to copy it to
the users buffer before completing the IRP.

Russ Poffenberger
NPTest, Inc.
xxxxx@NPTest.com

Can’t he use double buffering ? While one buffer’s DMA’ing, the other’s
being filled, and the time it takes to move the data is hidden by the other
buffer’s i/o.

Alberto.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Russ Poffenberger
Sent: Friday, January 16, 2004 11:42 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] problems with DMA transfer with size > 4k

At 07:28 PM 1/16/2004 +0300, you wrote:

Hi

I think Common Buffer DMA model should help you.
Use AllocateCommonBuffer in your StartDevice.
This function gives the contiguous physical memory, than you map this
memory
to User Mode

Isn’t a common buffer allocated from the non-paged pool? If so, you have to
be careful with how large a buffer you allocate. Mapping it back to the
user program sounds like a bad idea. I would think you want to copy it to
the users buffer before completing the IRP.

Russ Poffenberger
NPTest, Inc.
xxxxx@NPTest.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@compuware.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or disclose
it to anyone else. If you received it in error please notify us immediately
and then destroy it.