Use a dedicated endpoint lock for endpoint manipulation. Fixes the guaranteed

deadlock with the BusManager on setup of the default pipes (for addressing).

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25542 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz 2008-05-18 12:34:40 +00:00
parent a9d7e87d40
commit 0439bcbbbb
2 changed files with 30 additions and 3 deletions

View File

@ -89,6 +89,11 @@ OHCI::OHCI(pci_info *info, Stack *stack)
TRACE(("usb_ohci: constructing new OHCI Host Controller Driver\n"));
fInitOK = false;
if (benaphore_init(&fEndpointLock, "ohci endpoint lock") < B_OK) {
TRACE_ERROR(("usb_ohci: failed to create endpoint lock\n"));
return;
}
// enable busmaster and memory mapped access
uint16 command = sPCIModule->read_pci_config(fPCIInfo->bus,
fPCIInfo->device, fPCIInfo->function, PCI_command, 2);
@ -314,6 +319,9 @@ OHCI::~OHCI()
delete_sem(fFinishTransfersSem);
wait_for_thread(fFinishThread, &result);
_LockEndpoints();
benaphore_destroy(&fEndpointLock);
if (fHccaArea >= B_OK)
delete_area(fHccaArea);
if (fRegisterArea >= B_OK)
@ -1255,7 +1263,7 @@ OHCI::_InsertEndpointForPipe(Pipe *pipe)
endpoint->tail_physical_descriptor = tail->physical_address;
}
if (!Lock()) {
if (!_LockEndpoints()) {
if (endpoint->head_logical_descriptor) {
_FreeGeneralDescriptor(
(ohci_general_td *)endpoint->head_logical_descriptor);
@ -1271,7 +1279,7 @@ OHCI::_InsertEndpointForPipe(Pipe *pipe)
head->next_logical_endpoint = (void *)endpoint;
head->next_physical_endpoint = (uint32)endpoint->physical_address;
Unlock();
_UnlockEndpoints();
return B_OK;
}
@ -1443,6 +1451,20 @@ OHCI::_FreeIsochronousDescriptor(ohci_isochronous_td *descriptor)
}
bool
OHCI::_LockEndpoints()
{
return (benaphore_lock(&fEndpointLock) == B_OK);
}
void
OHCI::_UnlockEndpoints()
{
benaphore_unlock(&fEndpointLock);
}
inline void
OHCI::_WriteReg(uint32 reg, uint32 value)
{

View File

@ -118,6 +118,10 @@ static int32 _FinishThread(void *data);
void _FreeIsochronousDescriptor(
ohci_isochronous_td *descriptor);
// Private locking
bool _LockEndpoints();
void _UnlockEndpoints();
// Register functions
inline void _WriteReg(uint32 reg, uint32 value);
inline uint32 _ReadReg(uint32 reg);
@ -134,7 +138,8 @@ static pci_module_info *sPCIModule;
ohci_hcca *fHcca;
ohci_endpoint_descriptor **fInterruptEndpoints;
// Dummy endpoints
// Endpoint management
benaphore fEndpointLock;
ohci_endpoint_descriptor *fDummyControl;
ohci_endpoint_descriptor *fDummyBulk;
ohci_endpoint_descriptor *fDummyIsochronous;