mirror of https://github.com/acidanthera/audk.git
Revert "EhciDxe: Use common buffer for AsyncInterruptTransfer"
There is concern at the thread
https://lists.01.org/pipermail/edk2-devel/2018-November/031951.html.
And the time point is a little sensitive as it is near edk2-stable201811.
This reverts commit 0cd6452503
.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
This commit is contained in:
parent
1ed6498c4a
commit
f87db25620
|
@ -763,7 +763,6 @@ EhcControlTransfer (
|
||||||
Translator,
|
Translator,
|
||||||
EHC_CTRL_TRANSFER,
|
EHC_CTRL_TRANSFER,
|
||||||
Request,
|
Request,
|
||||||
FALSE,
|
|
||||||
Data,
|
Data,
|
||||||
*DataLength,
|
*DataLength,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -907,7 +906,6 @@ EhcBulkTransfer (
|
||||||
Translator,
|
Translator,
|
||||||
EHC_BULK_TRANSFER,
|
EHC_BULK_TRANSFER,
|
||||||
NULL,
|
NULL,
|
||||||
FALSE,
|
|
||||||
Data[0],
|
Data[0],
|
||||||
*DataLength,
|
*DataLength,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -1165,7 +1163,6 @@ EhcSyncInterruptTransfer (
|
||||||
Translator,
|
Translator,
|
||||||
EHC_INT_TRANSFER_SYNC,
|
EHC_INT_TRANSFER_SYNC,
|
||||||
NULL,
|
NULL,
|
||||||
FALSE,
|
|
||||||
Data,
|
Data,
|
||||||
*DataLength,
|
*DataLength,
|
||||||
NULL,
|
NULL,
|
||||||
|
|
|
@ -778,6 +778,7 @@ EhciDelAsyncIntTransfer (
|
||||||
EhcUnlinkQhFromPeriod (Ehc, Urb->Qh);
|
EhcUnlinkQhFromPeriod (Ehc, Urb->Qh);
|
||||||
RemoveEntryList (&Urb->UrbList);
|
RemoveEntryList (&Urb->UrbList);
|
||||||
|
|
||||||
|
gBS->FreePool (Urb->Data);
|
||||||
EhcFreeUrb (Ehc, Urb);
|
EhcFreeUrb (Ehc, Urb);
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -808,6 +809,7 @@ EhciDelAllAsyncIntTransfers (
|
||||||
EhcUnlinkQhFromPeriod (Ehc, Urb->Qh);
|
EhcUnlinkQhFromPeriod (Ehc, Urb->Qh);
|
||||||
RemoveEntryList (&Urb->UrbList);
|
RemoveEntryList (&Urb->UrbList);
|
||||||
|
|
||||||
|
gBS->FreePool (Urb->Data);
|
||||||
EhcFreeUrb (Ehc, Urb);
|
EhcFreeUrb (Ehc, Urb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -846,8 +848,16 @@ EhciInsertAsyncIntTransfer (
|
||||||
IN UINTN Interval
|
IN UINTN Interval
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
VOID *Data;
|
||||||
URB *Urb;
|
URB *Urb;
|
||||||
|
|
||||||
|
Data = AllocatePool (DataLen);
|
||||||
|
|
||||||
|
if (Data == NULL) {
|
||||||
|
DEBUG ((DEBUG_ERROR, "%a: failed to allocate buffer\n", __FUNCTION__));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
Urb = EhcCreateUrb (
|
Urb = EhcCreateUrb (
|
||||||
Ehc,
|
Ehc,
|
||||||
DevAddr,
|
DevAddr,
|
||||||
|
@ -858,8 +868,7 @@ EhciInsertAsyncIntTransfer (
|
||||||
Hub,
|
Hub,
|
||||||
EHC_INT_TRANSFER_ASYNC,
|
EHC_INT_TRANSFER_ASYNC,
|
||||||
NULL,
|
NULL,
|
||||||
TRUE,
|
Data,
|
||||||
NULL,
|
|
||||||
DataLen,
|
DataLen,
|
||||||
Callback,
|
Callback,
|
||||||
Context,
|
Context,
|
||||||
|
@ -868,6 +877,7 @@ EhciInsertAsyncIntTransfer (
|
||||||
|
|
||||||
if (Urb == NULL) {
|
if (Urb == NULL) {
|
||||||
DEBUG ((DEBUG_ERROR, "%a: failed to create URB\n", __FUNCTION__));
|
DEBUG ((DEBUG_ERROR, "%a: failed to create URB\n", __FUNCTION__));
|
||||||
|
gBS->FreePool (Data);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -881,6 +891,60 @@ EhciInsertAsyncIntTransfer (
|
||||||
return Urb;
|
return Urb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Flush data from PCI controller specific address to mapped system
|
||||||
|
memory address.
|
||||||
|
|
||||||
|
@param Ehc The EHCI device.
|
||||||
|
@param Urb The URB to unmap.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Success to flush data to mapped system memory.
|
||||||
|
@retval EFI_DEVICE_ERROR Fail to flush data to mapped system memory.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EhcFlushAsyncIntMap (
|
||||||
|
IN USB2_HC_DEV *Ehc,
|
||||||
|
IN URB *Urb
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
EFI_PHYSICAL_ADDRESS PhyAddr;
|
||||||
|
EFI_PCI_IO_PROTOCOL_OPERATION MapOp;
|
||||||
|
EFI_PCI_IO_PROTOCOL *PciIo;
|
||||||
|
UINTN Len;
|
||||||
|
VOID *Map;
|
||||||
|
|
||||||
|
PciIo = Ehc->PciIo;
|
||||||
|
Len = Urb->DataLen;
|
||||||
|
|
||||||
|
if (Urb->Ep.Direction == EfiUsbDataIn) {
|
||||||
|
MapOp = EfiPciIoOperationBusMasterWrite;
|
||||||
|
} else {
|
||||||
|
MapOp = EfiPciIoOperationBusMasterRead;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = PciIo->Unmap (PciIo, Urb->DataMap);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
goto ON_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
Urb->DataMap = NULL;
|
||||||
|
|
||||||
|
Status = PciIo->Map (PciIo, MapOp, Urb->Data, &Len, &PhyAddr, &Map);
|
||||||
|
if (EFI_ERROR (Status) || (Len != Urb->DataLen)) {
|
||||||
|
goto ON_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
Urb->DataPhy = (VOID *) ((UINTN) PhyAddr);
|
||||||
|
Urb->DataMap = Map;
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
|
||||||
|
ON_ERROR:
|
||||||
|
return EFI_DEVICE_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Update the queue head for next round of asynchronous transfer.
|
Update the queue head for next round of asynchronous transfer.
|
||||||
|
|
||||||
|
@ -986,6 +1050,7 @@ EhcMonitorAsyncRequests (
|
||||||
BOOLEAN Finished;
|
BOOLEAN Finished;
|
||||||
UINT8 *ProcBuf;
|
UINT8 *ProcBuf;
|
||||||
URB *Urb;
|
URB *Urb;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
OldTpl = gBS->RaiseTPL (EHC_TPL);
|
OldTpl = gBS->RaiseTPL (EHC_TPL);
|
||||||
Ehc = (USB2_HC_DEV *) Context;
|
Ehc = (USB2_HC_DEV *) Context;
|
||||||
|
@ -1003,6 +1068,15 @@ EhcMonitorAsyncRequests (
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Flush any PCI posted write transactions from a PCI host
|
||||||
|
// bridge to system memory.
|
||||||
|
//
|
||||||
|
Status = EhcFlushAsyncIntMap (Ehc, Urb);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
DEBUG ((EFI_D_ERROR, "EhcMonitorAsyncRequests: Fail to Flush AsyncInt Mapped Memeory\n"));
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Allocate a buffer then copy the transferred data for user.
|
// Allocate a buffer then copy the transferred data for user.
|
||||||
// If failed to allocate the buffer, update the URB for next
|
// If failed to allocate the buffer, update the URB for next
|
||||||
|
|
|
@ -339,14 +339,6 @@ EhcFreeUrb (
|
||||||
PciIo->Unmap (PciIo, Urb->DataMap);
|
PciIo->Unmap (PciIo, Urb->DataMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Urb->AllocateCommonBuffer) {
|
|
||||||
PciIo->FreeBuffer (
|
|
||||||
PciIo,
|
|
||||||
EFI_SIZE_TO_PAGES (Urb->DataLen),
|
|
||||||
Urb->Data
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Urb->Qh != NULL) {
|
if (Urb->Qh != NULL) {
|
||||||
//
|
//
|
||||||
// Ensure that this queue head has been unlinked from the
|
// Ensure that this queue head has been unlinked from the
|
||||||
|
@ -537,8 +529,7 @@ ON_ERROR:
|
||||||
@param Hub The transaction translator to use.
|
@param Hub The transaction translator to use.
|
||||||
@param Type The transaction type.
|
@param Type The transaction type.
|
||||||
@param Request The standard USB request for control transfer.
|
@param Request The standard USB request for control transfer.
|
||||||
@param AllocateCommonBuffer Indicate whether need to allocate common buffer for data transfer.
|
@param Data The user data to transfer.
|
||||||
@param Data The user data to transfer, NULL if AllocateCommonBuffer is TRUE.
|
|
||||||
@param DataLen The length of data buffer.
|
@param DataLen The length of data buffer.
|
||||||
@param Callback The function to call when data is transferred.
|
@param Callback The function to call when data is transferred.
|
||||||
@param Context The context to the callback.
|
@param Context The context to the callback.
|
||||||
|
@ -558,7 +549,6 @@ EhcCreateUrb (
|
||||||
IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Hub,
|
IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Hub,
|
||||||
IN UINTN Type,
|
IN UINTN Type,
|
||||||
IN EFI_USB_DEVICE_REQUEST *Request,
|
IN EFI_USB_DEVICE_REQUEST *Request,
|
||||||
IN BOOLEAN AllocateCommonBuffer,
|
|
||||||
IN VOID *Data,
|
IN VOID *Data,
|
||||||
IN UINTN DataLen,
|
IN UINTN DataLen,
|
||||||
IN EFI_ASYNC_USB_TRANSFER_CALLBACK Callback,
|
IN EFI_ASYNC_USB_TRANSFER_CALLBACK Callback,
|
||||||
|
@ -606,24 +596,8 @@ EhcCreateUrb (
|
||||||
Ep->PollRate = EhcConvertPollRate (Interval);
|
Ep->PollRate = EhcConvertPollRate (Interval);
|
||||||
|
|
||||||
Urb->Request = Request;
|
Urb->Request = Request;
|
||||||
if (AllocateCommonBuffer) {
|
|
||||||
ASSERT (Data == NULL);
|
|
||||||
Status = Ehc->PciIo->AllocateBuffer (
|
|
||||||
Ehc->PciIo,
|
|
||||||
AllocateAnyPages,
|
|
||||||
EfiBootServicesData,
|
|
||||||
EFI_SIZE_TO_PAGES (DataLen),
|
|
||||||
&Data,
|
|
||||||
0
|
|
||||||
);
|
|
||||||
if (EFI_ERROR (Status) || (Data == NULL)) {
|
|
||||||
FreePool (Urb);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Urb->Data = Data;
|
Urb->Data = Data;
|
||||||
Urb->DataLen = DataLen;
|
Urb->DataLen = DataLen;
|
||||||
Urb->AllocateCommonBuffer = AllocateCommonBuffer;
|
|
||||||
Urb->Callback = Callback;
|
Urb->Callback = Callback;
|
||||||
Urb->Context = Context;
|
Urb->Context = Context;
|
||||||
|
|
||||||
|
@ -653,14 +627,10 @@ EhcCreateUrb (
|
||||||
if (Data != NULL) {
|
if (Data != NULL) {
|
||||||
Len = DataLen;
|
Len = DataLen;
|
||||||
|
|
||||||
if (Urb->AllocateCommonBuffer) {
|
if (Ep->Direction == EfiUsbDataIn) {
|
||||||
MapOp = EfiPciIoOperationBusMasterCommonBuffer;
|
MapOp = EfiPciIoOperationBusMasterWrite;
|
||||||
} else {
|
} else {
|
||||||
if (Ep->Direction == EfiUsbDataIn) {
|
MapOp = EfiPciIoOperationBusMasterRead;
|
||||||
MapOp = EfiPciIoOperationBusMasterWrite;
|
|
||||||
} else {
|
|
||||||
MapOp = EfiPciIoOperationBusMasterRead;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = PciIo->Map (PciIo, MapOp, Data, &Len, &PhyAddr, &Map);
|
Status = PciIo->Map (PciIo, MapOp, Data, &Len, &PhyAddr, &Map);
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
This file contains URB request, each request is warpped in a
|
This file contains URB request, each request is warpped in a
|
||||||
URB (Usb Request Block).
|
URB (Usb Request Block).
|
||||||
|
|
||||||
Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -216,7 +216,6 @@ struct _URB {
|
||||||
EFI_USB_DEVICE_REQUEST *Request; // Control transfer only
|
EFI_USB_DEVICE_REQUEST *Request; // Control transfer only
|
||||||
VOID *RequestPhy; // Address of the mapped request
|
VOID *RequestPhy; // Address of the mapped request
|
||||||
VOID *RequestMap;
|
VOID *RequestMap;
|
||||||
BOOLEAN AllocateCommonBuffer;
|
|
||||||
VOID *Data;
|
VOID *Data;
|
||||||
UINTN DataLen;
|
UINTN DataLen;
|
||||||
VOID *DataPhy; // Address of the mapped user data
|
VOID *DataPhy; // Address of the mapped user data
|
||||||
|
@ -299,21 +298,20 @@ EhcFreeUrb (
|
||||||
/**
|
/**
|
||||||
Create a new URB and its associated QTD.
|
Create a new URB and its associated QTD.
|
||||||
|
|
||||||
@param Ehc The EHCI device.
|
@param Ehc The EHCI device.
|
||||||
@param DevAddr The device address.
|
@param DevAddr The device address.
|
||||||
@param EpAddr Endpoint addrress & its direction.
|
@param EpAddr Endpoint addrress & its direction.
|
||||||
@param DevSpeed The device speed.
|
@param DevSpeed The device speed.
|
||||||
@param Toggle Initial data toggle to use.
|
@param Toggle Initial data toggle to use.
|
||||||
@param MaxPacket The max packet length of the endpoint.
|
@param MaxPacket The max packet length of the endpoint.
|
||||||
@param Hub The transaction translator to use.
|
@param Hub The transaction translator to use.
|
||||||
@param Type The transaction type.
|
@param Type The transaction type.
|
||||||
@param Request The standard USB request for control transfer.
|
@param Request The standard USB request for control transfer.
|
||||||
@param AllocateCommonBuffer Indicate whether need to allocate common buffer for data transfer.
|
@param Data The user data to transfer.
|
||||||
@param Data The user data to transfer, NULL if AllocateCommonBuffer is TRUE.
|
@param DataLen The length of data buffer.
|
||||||
@param DataLen The length of data buffer.
|
@param Callback The function to call when data is transferred.
|
||||||
@param Callback The function to call when data is transferred.
|
@param Context The context to the callback.
|
||||||
@param Context The context to the callback.
|
@param Interval The interval for interrupt transfer.
|
||||||
@param Interval The interval for interrupt transfer.
|
|
||||||
|
|
||||||
@return Created URB or NULL.
|
@return Created URB or NULL.
|
||||||
|
|
||||||
|
@ -329,7 +327,6 @@ EhcCreateUrb (
|
||||||
IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Hub,
|
IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Hub,
|
||||||
IN UINTN Type,
|
IN UINTN Type,
|
||||||
IN EFI_USB_DEVICE_REQUEST *Request,
|
IN EFI_USB_DEVICE_REQUEST *Request,
|
||||||
IN BOOLEAN AllocateCommonBuffer,
|
|
||||||
IN VOID *Data,
|
IN VOID *Data,
|
||||||
IN UINTN DataLen,
|
IN UINTN DataLen,
|
||||||
IN EFI_ASYNC_USB_TRANSFER_CALLBACK Callback,
|
IN EFI_ASYNC_USB_TRANSFER_CALLBACK Callback,
|
||||||
|
|
Loading…
Reference in New Issue