Kernel: Fix xHCI controller destruction
Port updater task was not actually able to exit without a kernel panic. This patch makes controller wait until port updater exits itself :D
This commit is contained in:
parent
11310e7615
commit
d0452a3510
|
@ -73,10 +73,11 @@ namespace Kernel
|
||||||
|
|
||||||
Mutex m_mutex;
|
Mutex m_mutex;
|
||||||
|
|
||||||
Process* m_port_updater { nullptr };
|
BAN::Atomic<Process*> m_port_updater { nullptr };
|
||||||
ThreadBlocker m_port_thread_blocker;
|
ThreadBlocker m_port_thread_blocker;
|
||||||
BAN::Atomic<bool> m_port_changed { false };
|
BAN::Atomic<bool> m_port_changed { false };
|
||||||
|
|
||||||
|
bool m_running { true };
|
||||||
bool m_ports_initialized { false };
|
bool m_ports_initialized { false };
|
||||||
|
|
||||||
PCI::Device& m_pci_device;
|
PCI::Device& m_pci_device;
|
||||||
|
|
|
@ -16,8 +16,9 @@ namespace Kernel
|
||||||
|
|
||||||
XHCIController::~XHCIController()
|
XHCIController::~XHCIController()
|
||||||
{
|
{
|
||||||
if (m_port_updater)
|
m_running = false;
|
||||||
m_port_updater->exit(0, SIGKILL);
|
while (m_port_updater)
|
||||||
|
Processor::yield();
|
||||||
|
|
||||||
for (auto paddr : m_scratchpad_buffers)
|
for (auto paddr : m_scratchpad_buffers)
|
||||||
if (paddr)
|
if (paddr)
|
||||||
|
@ -308,7 +309,7 @@ namespace Kernel
|
||||||
|
|
||||||
uint64_t last_port_update = SystemTimer::get().ms_since_boot();
|
uint64_t last_port_update = SystemTimer::get().ms_since_boot();
|
||||||
|
|
||||||
while (true)
|
while (m_running)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
bool expected { true };
|
bool expected { true };
|
||||||
|
@ -389,6 +390,8 @@ namespace Kernel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_port_updater = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
BAN::ErrorOr<uint8_t> XHCIController::initialize_device(uint32_t route_string, uint8_t depth, USB::SpeedClass speed_class, XHCIDevice* parent_hub, uint8_t parent_port_id)
|
BAN::ErrorOr<uint8_t> XHCIController::initialize_device(uint32_t route_string, uint8_t depth, USB::SpeedClass speed_class, XHCIDevice* parent_hub, uint8_t parent_port_id)
|
||||||
|
|
Loading…
Reference in New Issue