Skip to content

Commit 31880b2

Browse files
lumagminlexx
authored andcommitted
UPSTREAM: remoteproc: qcom: enable in-kernel PD mapper
Request in-kernel protection domain mapper to be started before starting Qualcomm DSP and release it once DSP is stopped. Once all DSPs are stopped, the PD mapper will be stopped too. Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Tested-by: Steev Klimaszewski <steev@kali.org>
1 parent 30065ef commit 31880b2

File tree

6 files changed

+109
-0
lines changed

6 files changed

+109
-0
lines changed

drivers/remoteproc/qcom_common.c

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <linux/notifier.h>
1414
#include <linux/remoteproc.h>
1515
#include <linux/remoteproc/qcom_rproc.h>
16+
#include <linux/auxiliary_bus.h>
1617
#include <linux/rpmsg/qcom_glink.h>
1718
#include <linux/rpmsg/qcom_smd.h>
1819
#include <linux/slab.h>
@@ -25,6 +26,7 @@
2526
#define to_glink_subdev(d) container_of(d, struct qcom_rproc_glink, subdev)
2627
#define to_smd_subdev(d) container_of(d, struct qcom_rproc_subdev, subdev)
2728
#define to_ssr_subdev(d) container_of(d, struct qcom_rproc_ssr, subdev)
29+
#define to_pdm_subdev(d) container_of(d, struct qcom_rproc_pdm, subdev)
2830

2931
#define MAX_NUM_OF_SS 10
3032
#define MAX_REGION_NAME_LENGTH 16
@@ -519,5 +521,90 @@ void qcom_remove_ssr_subdev(struct rproc *rproc, struct qcom_rproc_ssr *ssr)
519521
}
520522
EXPORT_SYMBOL_GPL(qcom_remove_ssr_subdev);
521523

524+
static void pdm_dev_release(struct device *dev)
525+
{
526+
struct auxiliary_device *adev = to_auxiliary_dev(dev);
527+
528+
kfree(adev);
529+
}
530+
531+
static int pdm_notify_prepare(struct rproc_subdev *subdev)
532+
{
533+
struct qcom_rproc_pdm *pdm = to_pdm_subdev(subdev);
534+
struct auxiliary_device *adev;
535+
int ret;
536+
537+
adev = kzalloc(sizeof(*adev), GFP_KERNEL);
538+
if (!adev)
539+
return -ENOMEM;
540+
541+
adev->dev.parent = pdm->dev;
542+
adev->dev.release = pdm_dev_release;
543+
adev->name = "pd-mapper";
544+
adev->id = pdm->index;
545+
546+
ret = auxiliary_device_init(adev);
547+
if (ret) {
548+
kfree(adev);
549+
return ret;
550+
}
551+
552+
ret = auxiliary_device_add(adev);
553+
if (ret) {
554+
auxiliary_device_uninit(adev);
555+
return ret;
556+
}
557+
558+
pdm->adev = adev;
559+
560+
return 0;
561+
}
562+
563+
564+
static void pdm_notify_unprepare(struct rproc_subdev *subdev)
565+
{
566+
struct qcom_rproc_pdm *pdm = to_pdm_subdev(subdev);
567+
568+
if (!pdm->adev)
569+
return;
570+
571+
auxiliary_device_delete(pdm->adev);
572+
auxiliary_device_uninit(pdm->adev);
573+
pdm->adev = NULL;
574+
}
575+
576+
/**
577+
* qcom_add_pdm_subdev() - register PD Mapper subdevice
578+
* @rproc: rproc handle
579+
* @pdm: PDM subdevice handle
580+
*
581+
* Register @pdm so that Protection Device mapper service is started when the
582+
* DSP is started too.
583+
*/
584+
void qcom_add_pdm_subdev(struct rproc *rproc, struct qcom_rproc_pdm *pdm)
585+
{
586+
pdm->dev = &rproc->dev;
587+
pdm->index = rproc->index;
588+
589+
pdm->subdev.prepare = pdm_notify_prepare;
590+
pdm->subdev.unprepare = pdm_notify_unprepare;
591+
592+
rproc_add_subdev(rproc, &pdm->subdev);
593+
}
594+
EXPORT_SYMBOL_GPL(qcom_add_pdm_subdev);
595+
596+
/**
597+
* qcom_remove_pdm_subdev() - remove PD Mapper subdevice
598+
* @rproc: rproc handle
599+
* @pdm: PDM subdevice handle
600+
*
601+
* Remove the PD Mapper subdevice.
602+
*/
603+
void qcom_remove_pdm_subdev(struct rproc *rproc, struct qcom_rproc_pdm *pdm)
604+
{
605+
rproc_remove_subdev(rproc, &pdm->subdev);
606+
}
607+
EXPORT_SYMBOL_GPL(qcom_remove_pdm_subdev);
608+
522609
MODULE_DESCRIPTION("Qualcomm Remoteproc helper driver");
523610
MODULE_LICENSE("GPL v2");

drivers/remoteproc/qcom_common.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ struct qcom_rproc_ssr {
3434
struct qcom_ssr_subsystem *info;
3535
};
3636

37+
struct qcom_rproc_pdm {
38+
struct rproc_subdev subdev;
39+
struct device *dev;
40+
int index;
41+
struct auxiliary_device *adev;
42+
};
43+
3744
void qcom_minidump(struct rproc *rproc, unsigned int minidump_id,
3845
void (*rproc_dumpfn_t)(struct rproc *rproc,
3946
struct rproc_dump_segment *segment, void *dest, size_t offset,
@@ -52,6 +59,9 @@ void qcom_add_ssr_subdev(struct rproc *rproc, struct qcom_rproc_ssr *ssr,
5259
const char *ssr_name);
5360
void qcom_remove_ssr_subdev(struct rproc *rproc, struct qcom_rproc_ssr *ssr);
5461

62+
void qcom_add_pdm_subdev(struct rproc *rproc, struct qcom_rproc_pdm *pdm);
63+
void qcom_remove_pdm_subdev(struct rproc *rproc, struct qcom_rproc_pdm *pdm);
64+
5565
#if IS_ENABLED(CONFIG_QCOM_SYSMON)
5666
struct qcom_sysmon *qcom_add_sysmon_subdev(struct rproc *rproc,
5767
const char *name,

drivers/remoteproc/qcom_q6v5_adsp.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ struct qcom_adsp {
112112
struct dev_pm_domain_list *pd_list;
113113

114114
struct qcom_rproc_glink glink_subdev;
115+
struct qcom_rproc_pdm pdm_subdev;
115116
struct qcom_rproc_ssr ssr_subdev;
116117
struct qcom_sysmon *sysmon;
117118

@@ -726,6 +727,7 @@ static int adsp_probe(struct platform_device *pdev)
726727
goto disable_pm;
727728

728729
qcom_add_glink_subdev(rproc, &adsp->glink_subdev, desc->ssr_name);
730+
qcom_add_pdm_subdev(rproc, &adsp->pdm_subdev);
729731
qcom_add_ssr_subdev(rproc, &adsp->ssr_subdev, desc->ssr_name);
730732
adsp->sysmon = qcom_add_sysmon_subdev(rproc,
731733
desc->sysmon_name,
@@ -755,6 +757,7 @@ static void adsp_remove(struct platform_device *pdev)
755757

756758
qcom_q6v5_deinit(&adsp->q6v5);
757759
qcom_remove_glink_subdev(adsp->rproc, &adsp->glink_subdev);
760+
qcom_remove_pdm_subdev(adsp->rproc, &adsp->pdm_subdev);
758761
qcom_remove_sysmon_subdev(adsp->sysmon);
759762
qcom_remove_ssr_subdev(adsp->rproc, &adsp->ssr_subdev);
760763
qcom_rproc_pds_detach(adsp);

drivers/remoteproc/qcom_q6v5_mss.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ struct q6v5 {
228228

229229
struct qcom_rproc_glink glink_subdev;
230230
struct qcom_rproc_subdev smd_subdev;
231+
struct qcom_rproc_pdm pdm_subdev;
231232
struct qcom_rproc_ssr ssr_subdev;
232233
struct qcom_sysmon *sysmon;
233234
struct platform_device *bam_dmux;
@@ -2102,6 +2103,7 @@ static int q6v5_probe(struct platform_device *pdev)
21022103
qproc->mba_perm = BIT(QCOM_SCM_VMID_HLOS);
21032104
qcom_add_glink_subdev(rproc, &qproc->glink_subdev, "mpss");
21042105
qcom_add_smd_subdev(rproc, &qproc->smd_subdev);
2106+
qcom_add_pdm_subdev(rproc, &qproc->pdm_subdev);
21052107
qcom_add_ssr_subdev(rproc, &qproc->ssr_subdev, "mpss");
21062108
qproc->sysmon = qcom_add_sysmon_subdev(rproc, "modem", 0x12);
21072109
if (IS_ERR(qproc->sysmon)) {
@@ -2143,6 +2145,7 @@ static void q6v5_remove(struct platform_device *pdev)
21432145
qcom_q6v5_deinit(&qproc->q6v5);
21442146
qcom_remove_sysmon_subdev(qproc->sysmon);
21452147
qcom_remove_ssr_subdev(rproc, &qproc->ssr_subdev);
2148+
qcom_remove_pdm_subdev(rproc, &qproc->pdm_subdev);
21462149
qcom_remove_smd_subdev(rproc, &qproc->smd_subdev);
21472150
qcom_remove_glink_subdev(rproc, &qproc->glink_subdev);
21482151

drivers/remoteproc/qcom_q6v5_pas.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ struct qcom_adsp {
111111

112112
struct qcom_rproc_glink glink_subdev;
113113
struct qcom_rproc_subdev smd_subdev;
114+
struct qcom_rproc_pdm pdm_subdev;
114115
struct qcom_rproc_ssr ssr_subdev;
115116
struct qcom_sysmon *sysmon;
116117

@@ -777,6 +778,7 @@ static int adsp_probe(struct platform_device *pdev)
777778

778779
qcom_add_glink_subdev(rproc, &adsp->glink_subdev, desc->ssr_name);
779780
qcom_add_smd_subdev(rproc, &adsp->smd_subdev);
781+
qcom_add_pdm_subdev(rproc, &adsp->pdm_subdev);
780782
adsp->sysmon = qcom_add_sysmon_subdev(rproc,
781783
desc->sysmon_name,
782784
desc->ssctl_id);
@@ -811,6 +813,7 @@ static void adsp_remove(struct platform_device *pdev)
811813
qcom_remove_glink_subdev(adsp->rproc, &adsp->glink_subdev);
812814
qcom_remove_sysmon_subdev(adsp->sysmon);
813815
qcom_remove_smd_subdev(adsp->rproc, &adsp->smd_subdev);
816+
qcom_remove_pdm_subdev(adsp->rproc, &adsp->pdm_subdev);
814817
qcom_remove_ssr_subdev(adsp->rproc, &adsp->ssr_subdev);
815818
adsp_pds_detach(adsp, adsp->proxy_pds, adsp->proxy_pd_count);
816819
device_init_wakeup(adsp->dev, false);

drivers/remoteproc/qcom_q6v5_wcss.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ struct q6v5_wcss {
148148
bool requires_force_stop;
149149

150150
struct qcom_rproc_glink glink_subdev;
151+
struct qcom_rproc_pdm pdm_subdev;
151152
struct qcom_rproc_ssr ssr_subdev;
152153
};
153154

@@ -1052,6 +1053,7 @@ static int q6v5_wcss_probe(struct platform_device *pdev)
10521053
return ret;
10531054

10541055
qcom_add_glink_subdev(rproc, &wcss->glink_subdev, "q6wcss");
1056+
qcom_add_pdm_subdev(rproc, &wcss->pdm_subdev);
10551057
qcom_add_ssr_subdev(rproc, &wcss->ssr_subdev, "q6wcss");
10561058

10571059
if (desc->ssctl_id)
@@ -1074,6 +1076,7 @@ static void q6v5_wcss_remove(struct platform_device *pdev)
10741076
struct q6v5_wcss *wcss = rproc->priv;
10751077

10761078
qcom_q6v5_deinit(&wcss->q6v5);
1079+
qcom_remove_pdm_subdev(rproc, &wcss->pdm_subdev);
10771080
rproc_del(rproc);
10781081
}
10791082

0 commit comments

Comments
 (0)