> Hello Everybody,
I am very new at windows driver development and I was wondering
whether
an ata miniport driver can request a specific alignment on each
element of
the IDE_SCATTER_GATHER_LIST.
The DMA engine of my controller is unable to read from buffers in host
memory that are across a 4K boundary, so I need each memory area of
the
IDE_SCATTER_GATHER_ELEMENT to be within a 4K page. In other words, for
each IDE_SCATTER_GATHER_ELEMENT (Address+Length) must be not cross a
4K
boundary.
Is there a way I can ask the port driver (?) to do so?
My scsiport drivers require alignment to a 512 byte boundary, and I have
found no way to tell scsiport to enforce that requirement, so I imagine
that ataport will be roughly the same.
Just so I understand, you can support multiple SG entries, as long as
each entry itself doesn’t cross a page? Can you manually break up the
entries yourself and feed them to your hardware that way? You may have
to limit ataport to half the actual number of sg elements that you
support.
What I have found with my scsiport driver is that while I do get some
non-512 byte aligned buffers, apart from a small number of requests at
boot and sometimes during certain operations (format, chkdsk I think),
the buffers are otherwise always aligned to PAGE_SIZE boundaries. So
what I do is declare an srb extension size of PAGE_SIZE * 2 - 1, which
guarantees that there will be at least 1 complete PAGE_SIZE aligned
block in the srb extension, and then use that as a bounce buffer.
Unfortunately you need to break some scsiport rules to do that - you can
tell scsiport to give you the physical address of the buffer, or the
virtual address, but never both. Storport relaxes the restrictions a bit
but is so broken in so many other ways that I went back to scsiport. I’m
not sure how closely related ataport and scsiport are - maybe you don’t
have similar restrictions?
Another option could be to put an upper filter in place that manually
re-allocates non-conforming buffers (again, assuming that that is a rare
event). I’m pretty sure that that would fail under a crash dump scenario
though, but maybe that doesn’t matter for your drivers?
Can you do some testing and establish whether almost all requests fit
your requirements and that it’s only a very small number that don’t? If
you are only handling a corner case then it should be acceptable if
there is a bit of a performance hit in doing so.
My buffer alignment dependency is because my ‘hardware’ is actually a
virtual adapter which talks to a Linux backend under Xen, and Linux
demands the 512 byte alignment.
James