- Don't use buffered I/O, to prevent some lag

- mouclass: Change the critical section place, to follow changes done in kbdclass in r19322

svn path=/trunk/; revision=19325
This commit is contained in:
Hervé Poussineau 2005-11-18 17:28:19 +00:00
parent 162952722e
commit e253c1b277
2 changed files with 26 additions and 19 deletions

View file

@ -329,7 +329,7 @@ cleanup:
DeviceExtension->ReadIsPending = FALSE;
DeviceExtension->InputCount = 0;
DeviceExtension->PortData = ExAllocatePool(NonPagedPool, DeviceExtension->DriverExtension->DataQueueSize * sizeof(KEYBOARD_INPUT_DATA));
Fdo->Flags |= DO_POWER_PAGABLE | DO_BUFFERED_IO;
Fdo->Flags |= DO_POWER_PAGABLE;
Fdo->Flags &= ~DO_DEVICE_INITIALIZING;
/* Add entry entry to HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\[DeviceBaseName] */
@ -384,10 +384,8 @@ ClassCallback(
/* A read request is waiting for input, so go straight to it */
/* FIXME: use SEH */
DPRINT("Immediate Completion: %x\n", DataStart->MakeCode);
RtlCopyMemory(
Irp->MdlAddress ? MmGetSystemAddressForMdlSafe(Irp->MdlAddress, NormalPagePriority) : Irp->AssociatedIrp.SystemBuffer,
Irp->MdlAddress ? MmGetSystemAddressForMdlSafe(Irp->MdlAddress, NormalPagePriority) : Irp->UserBuffer,
DataStart,
sizeof(KEYBOARD_INPUT_DATA));
@ -523,7 +521,6 @@ ClassAddDevice(
RtlZeroMemory(DeviceExtension, sizeof(CLASS_DEVICE_EXTENSION));
DeviceExtension->Common.IsClassDO = FALSE;
DeviceExtension->PnpState = dsStopped;
Fdo->Flags |= DO_POWER_PAGABLE;
Status = IoAttachDeviceToDeviceStackSafe(Fdo, Pdo, &DeviceExtension->LowerDevice);
if (!NT_SUCCESS(Status))
{
@ -531,7 +528,10 @@ ClassAddDevice(
IoDeleteDevice(Fdo);
return Status;
}
Fdo->Flags |= DO_BUFFERED_IO;
if (DeviceExtension->LowerDevice->Flags & DO_POWER_PAGABLE)
Fdo->Flags |= DO_POWER_PAGABLE;
if (DeviceExtension->LowerDevice->Flags & DO_BUFFERED_IO)
Fdo->Flags |= DO_BUFFERED_IO;
if (DriverExtension->ConnectMultiplePorts)
Status = ConnectPortDriver(Fdo, DriverExtension->MainClassDeviceObject);
@ -578,17 +578,16 @@ ClassStartIo(
KeAcquireSpinLock(&DeviceExtension->SpinLock, &oldIrql);
DPRINT("Mdl: %x, UserBuffer: %x, InputCount: %d, Data: %x\n",
Irp->MdlAddress,
Irp->UserBuffer,
DeviceExtension->InputCount,
(DeviceExtension->PortData-DeviceExtension->InputCount)->MakeCode);
DPRINT("Mdl: %p, UserBuffer: %p, InputCount: %lu\n",
Irp->MdlAddress,
Irp->UserBuffer,
DeviceExtension->InputCount);
/* FIXME: use SEH */
RtlCopyMemory(
Irp->AssociatedIrp.SystemBuffer,
DeviceExtension->PortData - DeviceExtension->InputCount,
sizeof(KEYBOARD_INPUT_DATA));
Irp->MdlAddress ? MmGetSystemAddressForMdlSafe(Irp->MdlAddress, NormalPagePriority) : Irp->UserBuffer,
DeviceExtension->PortData - DeviceExtension->InputCount,
sizeof(KEYBOARD_INPUT_DATA));
if (DeviceExtension->InputCount > 1)
{

View file

@ -359,6 +359,8 @@ ClassCallback(
ASSERT(ClassDeviceExtension->Common.IsClassDO);
KeAcquireSpinLock(&ClassDeviceExtension->SpinLock, &OldIrql);
DPRINT("ClassCallback()\n");
/* A filter driver might have consumed all the data already; I'm
* not sure if they are supposed to move the packets when they
@ -393,8 +395,6 @@ ClassCallback(
/* If we have data from the port driver and a higher service to send the data to */
if (InputCount != 0)
{
KeAcquireSpinLock(&ClassDeviceExtension->SpinLock, &OldIrql);
if (ClassDeviceExtension->InputCount + InputCount > ClassDeviceExtension->DriverExtension->DataQueueSize)
ReadSize = ClassDeviceExtension->DriverExtension->DataQueueSize - ClassDeviceExtension->InputCount;
else
@ -418,7 +418,6 @@ ClassCallback(
ClassDeviceExtension->PortData += ReadSize;
ClassDeviceExtension->InputCount += ReadSize;
KeReleaseSpinLock(&ClassDeviceExtension->SpinLock, OldIrql);
(*ConsumedCount) += ReadSize;
}
else
@ -426,6 +425,8 @@ ClassCallback(
DPRINT("ClassCallBack() entered, InputCount = %lu - DOING NOTHING\n", InputCount);
}
KeReleaseSpinLock(&ClassDeviceExtension->SpinLock, OldIrql);
if (Irp != NULL)
{
IoStartNextPacket(ClassDeviceObject, FALSE);
@ -510,7 +511,6 @@ ClassAddDevice(
RtlZeroMemory(DeviceExtension, sizeof(CLASS_DEVICE_EXTENSION));
DeviceExtension->Common.IsClassDO = FALSE;
DeviceExtension->PnpState = dsStopped;
Fdo->Flags |= DO_POWER_PAGABLE;
Status = IoAttachDeviceToDeviceStackSafe(Fdo, Pdo, &DeviceExtension->LowerDevice);
if (!NT_SUCCESS(Status))
{
@ -518,7 +518,10 @@ ClassAddDevice(
IoDeleteDevice(Fdo);
return Status;
}
Fdo->Flags |= DO_BUFFERED_IO;
if (DeviceExtension->LowerDevice->Flags & DO_POWER_PAGABLE)
Fdo->Flags |= DO_POWER_PAGABLE;
if (DeviceExtension->LowerDevice->Flags & DO_BUFFERED_IO)
Fdo->Flags |= DO_BUFFERED_IO;
if (DriverExtension->ConnectMultiplePorts)
Status = ConnectPortDriver(Fdo, DriverExtension->MainClassDeviceObject);
@ -565,6 +568,11 @@ ClassStartIo(
KeAcquireSpinLock(&DeviceExtension->SpinLock, &oldIrql);
DPRINT("Mdl: %p, UserBuffer: %p, InputCount: %lu\n",
Irp->MdlAddress,
Irp->UserBuffer,
DeviceExtension->InputCount);
/* FIXME: use SEH */
RtlCopyMemory(
Irp->MdlAddress ? MmGetSystemAddressForMdlSafe(Irp->MdlAddress, NormalPagePriority) : Irp->UserBuffer,