We should not call nhi_shutdown() before the domain structure and the
control channel rings are completely released. Otherwise we might
release resources like the nhi->msix_ida that are still referenced in
tb_domain_release(). For this reason wait for the tb_domain_release() to
be completed before continuing to nhi_shutdown() and eventually
releasing of the rest of the data structures.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
static void tb_domain_release(struct device *dev)
{
struct tb *tb = container_of(dev, struct tb, dev);
+ struct tb_nhi *nhi = tb->nhi;
tb_ctl_free(tb->ctl);
destroy_workqueue(tb->wq);
ida_free(&tb_domain_ida, tb->index);
mutex_destroy(&tb->lock);
kfree(tb);
+
+ complete(&nhi->domain_released);
}
const struct device_type tb_domain_type = {
dev_dbg(dev, "NHI initialized, starting thunderbolt\n");
+ init_completion(&nhi->domain_released);
+
res = tb_domain_add(tb, host_reset);
if (res) {
/*
* activated. Do a proper shutdown.
*/
tb_domain_put(tb);
+ wait_for_completion(&nhi->domain_released);
nhi_shutdown(nhi);
return res;
}
pm_runtime_forbid(&pdev->dev);
tb_domain_remove(tb);
+ wait_for_completion(&nhi->domain_released);
nhi_shutdown(nhi);
}
* MSI-X is used.
* @hop_count: Number of rings (end point hops) supported by NHI.
* @quirks: NHI specific quirks if any
+ * @domain_released: Completed when domain has been fully released
*/
struct tb_nhi {
spinlock_t lock;
struct work_struct interrupt_work;
u32 hop_count;
unsigned long quirks;
+ struct completion domain_released;
};
/**