OHCI USB: disable MSI on destruction

* also remove interrupt handler and put the PCI x86 module.
This commit is contained in:
Jerome Duval
2013-07-31 00:40:16 +02:00
committed by Jérôme Duval
parent 010b06a16e
commit b3dbb4d23b
2 changed files with 22 additions and 5 deletions
+19 -5
View File
@@ -76,7 +76,9 @@ OHCI::OHCI(pci_info *info, Stack *stack)
fProcessingPipe(NULL), fProcessingPipe(NULL),
fRootHub(NULL), fRootHub(NULL),
fRootHubAddress(0), fRootHubAddress(0),
fPortCount(0) fPortCount(0),
fIRQ(0),
fUseMSI(false)
{ {
if (!fInitOK) { if (!fInitOK) {
TRACE_ERROR("bus manager failed to init\n"); TRACE_ERROR("bus manager failed to init\n");
@@ -323,7 +325,7 @@ OHCI::OHCI(pci_info *info, Stack *stack)
resume_thread(fFinishThread); resume_thread(fFinishThread);
// Find the right interrupt vector, using MSIs if available. // Find the right interrupt vector, using MSIs if available.
uint8 interruptVector = fPCIInfo->u.h0.interrupt_line; fIRQ = fPCIInfo->u.h0.interrupt_line;
if (sPCIx86Module != NULL && sPCIx86Module->get_msi_count(fPCIInfo->bus, if (sPCIx86Module != NULL && sPCIx86Module->get_msi_count(fPCIInfo->bus,
fPCIInfo->device, fPCIInfo->function) >= 1) { fPCIInfo->device, fPCIInfo->function) >= 1) {
uint8 msiVector = 0; uint8 msiVector = 0;
@@ -332,14 +334,14 @@ OHCI::OHCI(pci_info *info, Stack *stack)
&& sPCIx86Module->enable_msi(fPCIInfo->bus, fPCIInfo->device, && sPCIx86Module->enable_msi(fPCIInfo->bus, fPCIInfo->device,
fPCIInfo->function) == B_OK) { fPCIInfo->function) == B_OK) {
TRACE_ALWAYS("using message signaled interrupts\n"); TRACE_ALWAYS("using message signaled interrupts\n");
interruptVector = msiVector; fIRQ = msiVector;
fUseMSI = true;
} }
} }
// Install the interrupt handler // Install the interrupt handler
TRACE("installing interrupt handler\n"); TRACE("installing interrupt handler\n");
install_io_interrupt_handler(interruptVector, _InterruptHandler, install_io_interrupt_handler(fIRQ, _InterruptHandler, (void *)this, 0);
(void *)this, 0);
// Enable interesting interrupts now that the handler is in place // Enable interesting interrupts now that the handler is in place
_WriteReg(OHCI_INTERRUPT_ENABLE, OHCI_NORMAL_INTERRUPTS _WriteReg(OHCI_INTERRUPT_ENABLE, OHCI_NORMAL_INTERRUPTS
@@ -357,6 +359,8 @@ OHCI::~OHCI()
delete_sem(fFinishTransfersSem); delete_sem(fFinishTransfersSem);
wait_for_thread(fFinishThread, &result); wait_for_thread(fFinishThread, &result);
remove_io_interrupt_handler(fIRQ, _InterruptHandler, (void *)this);
_LockEndpoints(); _LockEndpoints();
mutex_destroy(&fEndpointLock); mutex_destroy(&fEndpointLock);
@@ -377,7 +381,17 @@ OHCI::~OHCI()
delete [] fInterruptEndpoints; delete [] fInterruptEndpoints;
delete fRootHub; delete fRootHub;
if (fUseMSI && sPCIx86Module != NULL) {
sPCIx86Module->disable_msi(fPCIInfo->bus,
fPCIInfo->device, fPCIInfo->function);
sPCIx86Module->unconfigure_msi(fPCIInfo->bus,
fPCIInfo->device, fPCIInfo->function);
}
put_module(B_PCI_MODULE_NAME); put_module(B_PCI_MODULE_NAME);
if (sPCIx86Module != NULL) {
sPCIx86Module = NULL;
put_module(B_PCI_X86_MODULE_NAME);
}
} }
+3
View File
@@ -174,6 +174,9 @@ static pci_x86_module_info * sPCIx86Module;
// Port management // Port management
uint8 fPortCount; uint8 fPortCount;
uint8 fIRQ;
bool fUseMSI;
}; };