Re: Cancel Sub-Irps within a complete routine by Doron
Doron
Fri Feb 08 13:10:48 CST 2008
that is not enough. you must also guard against the subirp completing back
to your driver (and being freed or completed up the stack) in another
context while you are attempting to cancel the irp. oney's book has a
solution on how to synchronize the cancelation with the completion of the
irp so you are not touching a freed irp
d
--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.
"Vetzak" <ptrshrn@gmail.com> wrote in message
news:2207fba0-3bcc-4869-8e71-780825af96d1@q21g2000hsa.googlegroups.com...
> On Feb 8, 10:17 am, "Christoph Diener" <c.die...@crossmatch.com>
> wrote:
>> Hmm, I was doing so, but my screen turned into blue. Some interrupt
>> request
>> level
>> was too high or low and so I was believing that this kind of recursively
>> calling of
>> the same function could be not the thing drivers like to do.
>>
>> "Mark Roddy" <ma...@hollistech.com> schrieb im
>> Newsbeitragnews:a0cbf2fc-a23e-41c2-b5d2-de849d1f6233@e25g2000prg.googlegroups.com...
>> On Feb 7, 8:46 am, "Christoph Diener" <c.die...@crossmatch.com> wrote:
>>
>>
>>
>> > The situation:
>> > I have a USB driver using Bulk transfers. Large Bulk requests are
>> > splitted
>> > into 512KB chunks.
>> > To do so, the main Irp creates multiple sub Irps with a completion
>> > routine
>> > down the USB stack.
>> > After the last sub Irp completes, I complete the main Irp too.
>>
>> > Since the device is sometimes not able to deliver enough data, I like
>> > to
>> > complete the main IRP of this
>> > incomplete USB transfer as soon as possible then (so the device would
>> > be
>> > able to send
>> > immediately fresh data for the next overlapped request - in our case an
>> > image).
>>
>> > The problem:
>> > I detect a short transfer in my completion routine of a sub-irp and
>> > have
>> > to
>> > cancel immediately
>> > all other sub-irps as well. I know that this is usually done by
>> > IoCancelIrp,
>> > but I am in an
>> > awkward situation here, because I am already in a complete routine.
>> > How can I complete the other sub-irps and the main irp from a
>> > completion
>> > routine?
>>
>> > Thanks in advance,
>> > Christoph
>>
>> At the risk of stating the obvious: call IoCancelIrp for each of the
>> sub irps in your completion routine and then let the completion of all
>> those sub irps cause the completion of the original irp. Of course you
>> have to be able to find all of the sub irps.
>
> You have to move out the (sub)IRPs from your device context (device
> extension) to local thread-safe variables in the spin-locked section,
> and then call IoCancelIrp() outside the spin-locked section.