mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 01:55:51 +02:00
slimbus: qcom-ngd-ctrl: Initialize controller resources in controller
The work structs and work queue are controller resources, create and
destroy them in the controller context. Creating them as part of the
child device's probe path seems to be okay now that the controller's
probe has been updated, but if for some reason the child does not probe
successfully a SSR or PDR notification will schedule_work() on an
uninitialized "ngd_up_work".
Move the initialization of these controller resources to the controller
probe function to avoid any issues, and to clarify the ownership.
Fixes: 917809e228 ("slimbus: ngd: Add qcom SLIMBus NGD driver")
Cc: stable@vger.kernel.org
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Reviewed-by: Mukesh Ojha <mukesh.ojha@oss.qualcomm.com>
Signed-off-by: Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>
Signed-off-by: Srinivas Kandagatla <srini@kernel.org>
Link: https://patch.msgid.link/20260530204421.116824-7-srini@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
2a9d50e9ea
commit
07c564ea5f
|
|
@ -1582,25 +1582,8 @@ static int qcom_slim_ngd_probe(struct platform_device *pdev)
|
|||
pm_runtime_enable(dev);
|
||||
pm_runtime_get_noresume(dev);
|
||||
ret = qcom_slim_ngd_qmi_svc_event_init(ctrl);
|
||||
if (ret) {
|
||||
if (ret)
|
||||
dev_err(&pdev->dev, "QMI service registration failed:%d", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
INIT_WORK(&ctrl->m_work, qcom_slim_ngd_master_worker);
|
||||
INIT_WORK(&ctrl->ngd_up_work, qcom_slim_ngd_up_worker);
|
||||
ctrl->mwq = create_singlethread_workqueue("ngd_master");
|
||||
if (!ctrl->mwq) {
|
||||
dev_err(&pdev->dev, "Failed to start master worker\n");
|
||||
ret = -ENOMEM;
|
||||
goto wq_err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
wq_err:
|
||||
qcom_slim_ngd_qmi_svc_event_deinit(&ctrl->qmi);
|
||||
if (ctrl->mwq)
|
||||
destroy_workqueue(ctrl->mwq);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -1653,9 +1636,18 @@ static int qcom_slim_ngd_ctrl_probe(struct platform_device *pdev)
|
|||
init_completion(&ctrl->qmi.qmi_comp);
|
||||
init_completion(&ctrl->qmi_up);
|
||||
|
||||
INIT_WORK(&ctrl->m_work, qcom_slim_ngd_master_worker);
|
||||
INIT_WORK(&ctrl->ngd_up_work, qcom_slim_ngd_up_worker);
|
||||
|
||||
ctrl->mwq = create_singlethread_workqueue("ngd_master");
|
||||
if (!ctrl->mwq)
|
||||
return dev_err_probe(dev, -ENOMEM, "Failed to start master worker\n");
|
||||
|
||||
ctrl->pdr = pdr_handle_alloc(slim_pd_status, ctrl);
|
||||
if (IS_ERR(ctrl->pdr))
|
||||
return dev_err_probe(dev, PTR_ERR(ctrl->pdr), "Failed to init PDR handle\n");
|
||||
if (IS_ERR(ctrl->pdr)) {
|
||||
ret = dev_err_probe(dev, PTR_ERR(ctrl->pdr), "Failed to init PDR handle\n");
|
||||
goto err_destroy_mwq;
|
||||
}
|
||||
|
||||
ret = of_qcom_slim_ngd_register(dev, ctrl);
|
||||
if (ret)
|
||||
|
|
@ -1682,6 +1674,8 @@ static int qcom_slim_ngd_ctrl_probe(struct platform_device *pdev)
|
|||
qcom_slim_ngd_unregister(ctrl);
|
||||
err_pdr_release:
|
||||
pdr_handle_release(ctrl->pdr);
|
||||
err_destroy_mwq:
|
||||
destroy_workqueue(ctrl->mwq);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -1694,6 +1688,8 @@ static void qcom_slim_ngd_ctrl_remove(struct platform_device *pdev)
|
|||
qcom_unregister_ssr_notifier(ctrl->notifier, &ctrl->nb);
|
||||
|
||||
qcom_slim_ngd_unregister(ctrl);
|
||||
|
||||
destroy_workqueue(ctrl->mwq);
|
||||
}
|
||||
|
||||
static void qcom_slim_ngd_remove(struct platform_device *pdev)
|
||||
|
|
@ -1704,8 +1700,6 @@ static void qcom_slim_ngd_remove(struct platform_device *pdev)
|
|||
qcom_slim_ngd_enable(ctrl, false);
|
||||
qcom_slim_ngd_exit_dma(ctrl);
|
||||
qcom_slim_ngd_qmi_svc_event_deinit(&ctrl->qmi);
|
||||
if (ctrl->mwq)
|
||||
destroy_workqueue(ctrl->mwq);
|
||||
|
||||
kfree(ctrl->ngd);
|
||||
ctrl->ngd = NULL;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user