History

Merge tag 'rproc-v5.1' of git://github.com/andersson/remoteproc

Pull remoteproc updates from Bjorn Andersson: "This contains the last patches in Loic's remoteproc resource table handling changes, a number of updates to documentation, support for invoking the crash handler (for testing purposes), a fix for the handling of virtio devices during recovery, performance state votes in Qualcomm modem driver, support for specifying board specific firmware path for Qualcomm modem driver and improved support for graceful shutdown of Qualcomm remoteprocs" * tag 'rproc-v5.1' of git://github.com/andersson/remoteproc: (33 commits) remoteproc: fix for "dma-mapping: remove the DMA_MEMORY_EXCLUSIVE flag" remoteproc: fix rproc_check_carveout_da() returned error and comments remoteproc: fix trace buffer va initialization remoteproc: fix rproc_alloc_carveout() for rproc with iommu domain remoteproc: add warning on resource table cast remoteproc: fix rproc_alloc_carveout() bad variable cast remoteproc: fix rproc_da_to_va in case of unallocated carveout remoteproc: correct rproc_mem_entry_init() comments remoteproc: fix recovery procedure rpmsg: virtio: change header file sort style rpmsg: virtio: allocate buffer from parent remoteproc: st: add reserved memory support remoteproc: create vdev subdevice with specific dma memory pool remoteproc: q6v5_adsp: Remove voting for lpass_aon clock dt-binding: remoteproc: Remove lpass_aon clock from adsp pil clock list remoteproc: q6v5-mss: Active powerdomain for SDM845 remoteproc: q6v5-mss: Vote for rpmh power domains remoteproc: qcom: Add support for parsing fw dt bindings remoteproc: qcom_q6v5: don't auto boot remote processor remoteproc: qcom: Wait for shutdown-ack/ind on sysmon shutdown ...

Linus Torvalds committed 7 years ago

Commit 2f194642 parents dc2535b d664ce715 files · +706 −120Browse files

Unified · Split

15 files
  1. Documentation/devicetree/bindings/remoteproc/qcom,adsp-pil.txt +2 −3
  2. Documentation/devicetree/bindings/remoteproc/qcom,adsp.txt +20 −3
  3. Documentation/devicetree/bindings/remoteproc/qcom,q6v5.txt +73 −6
  4. drivers/remoteproc/qcom_q6v5_adsp.c +5 −1
  5. drivers/remoteproc/qcom_q6v5_mss.c +194 −15
  6. drivers/remoteproc/qcom_q6v5_pas.c +12 −1
  7. drivers/remoteproc/qcom_sysmon.c +78 −4
  8. drivers/remoteproc/qcom_wcnss.c +5 −1
  9. drivers/remoteproc/remoteproc_core.c +112 −48
  10. drivers/remoteproc/remoteproc_debugfs.c +43 −4
  11. drivers/remoteproc/remoteproc_internal.h +10 −2
  12. drivers/remoteproc/remoteproc_virtio.c +56 −5
  13. drivers/remoteproc/st_remoteproc.c +80 −11
  14. drivers/rpmsg/virtio_rpmsg_bus.c +12 −12
  15. include/linux/remoteproc.h +4 −4
Documentation/devicetree/bindings/remoteproc/qcom,adsp-pil.txt+2−3
@@ -35,7 +35,7 @@ on the Qualcomm Technology Inc. ADSP Hexagon core. · 34 unmodified lines
3535 Value type: <stringlist>
3636 Definition: List of clock input name strings sorted in the same
3737 order as the clocks property. Definition must have
38− "xo", "sway_cbcr", "lpass_aon", "lpass_ahbs_aon_cbcr",
38+ "xo", "sway_cbcr", "lpass_ahbs_aon_cbcr",
3939 "lpass_ahbm_aon_cbcr", "qdsp6ss_xo", "qdsp6ss_sleep"
4040 and "qdsp6ss_core".
4141
@@ -100,13 +100,12 @@ ADSP, as it is found on SDM845 boards. · 58 unmodified lines
100100
101101 clocks = <&rpmhcc RPMH_CXO_CLK>,
102102 <&gcc GCC_LPASS_SWAY_CLK>,
103− <&lpasscc LPASS_AUDIO_WRAPPER_AON_CLK>,
104103 <&lpasscc LPASS_Q6SS_AHBS_AON_CLK>,
105104 <&lpasscc LPASS_Q6SS_AHBM_AON_CLK>,
106105 <&lpasscc LPASS_QDSP6SS_XO_CLK>,
107106 <&lpasscc LPASS_QDSP6SS_SLEEP_CLK>,
108107 <&lpasscc LPASS_QDSP6SS_CORE_CLK>;
109− clock-names = "xo", "sway_cbcr", "lpass_aon",
108+ clock-names = "xo", "sway_cbcr",
110109 "lpass_ahbs_aon_cbcr",
111110 "lpass_ahbm_aon_cbcr", "qdsp6ss_xo",
112111 "qdsp6ss_sleep", "qdsp6ss_core";
Documentation/devicetree/bindings/remoteproc/qcom,adsp.txt+20−3
@@ -19,13 +19,30 @@ on the Qualcomm ADSP Hexagon core. · 18 unmodified lines
1919 - interrupts-extended:
2020 Usage: required
2121 Value type: <prop-encoded-array>
22− Definition: must list the watchdog, fatal IRQs ready, handover and
23− stop-ack IRQs
22+ Definition: reference to the interrupts that match interrupt-names
2423
2524 - interrupt-names:
2625 Usage: required
2726 Value type: <stringlist>
28− Definition: must be "wdog", "fatal", "ready", "handover", "stop-ack"
27+ Definition: The interrupts needed depends on the compatible
28+ string:
29+ qcom,msm8974-adsp-pil:
30+ qcom,msm8996-adsp-pil:
31+ qcom,msm8996-slpi-pil:
32+ qcom,qcs404-adsp-pas:
33+ qcom,qcs404-cdsp-pas:
34+ qcom,sdm845-adsp-pas:
35+ qcom,sdm845-cdsp-pas:
36+ must be "wdog", "fatal", "ready", "handover", "stop-ack"
37+ qcom,qcs404-wcss-pas:
38+ must be "wdog", "fatal", "ready", "handover", "stop-ack",
39+ "shutdown-ack"
40+
41+- firmware-name:
42+ Usage: optional
43+ Value type: <string>
44+ Definition: must list the relative firmware image path for the
45+ Hexagon Core.
2946
3047 - clocks:
3148 Usage: required
Documentation/devicetree/bindings/remoteproc/qcom,q6v5.txt+73−6
@@ -28,24 +28,51 @@ on the Qualcomm Hexagon core. · 27 unmodified lines
2828 - interrupts-extended:
2929 Usage: required
3030 Value type: <prop-encoded-array>
31− Definition: must list the watchdog, fatal IRQs ready, handover and
32− stop-ack IRQs
31+ Definition: reference to the interrupts that match interrupt-names
3332
3433 - interrupt-names:
3534 Usage: required
3635 Value type: <stringlist>
37− Definition: must be "wdog", "fatal", "ready", "handover", "stop-ack"
36+ Definition: The interrupts needed depends on the the compatible
37+ string:
38+ qcom,q6v5-pil:
39+ qcom,ipq8074-wcss-pil:
40+ qcom,msm8916-mss-pil:
41+ qcom,msm8974-mss-pil:
42+ must be "wdog", "fatal", "ready", "handover", "stop-ack"
43+ qcom,msm8996-mss-pil:
44+ qcom,sdm845-mss-pil:
45+ must be "wdog", "fatal", "ready", "handover", "stop-ack",
46+ "shutdown-ack"
47+
48+- firmware-name:
49+ Usage: optional
50+ Value type: <stringlist>
51+ Definition: must list the relative firmware image paths for mba and
52+ modem. They are used for booting and authenticating the
53+ Hexagon core.
3854
3955 - clocks:
4056 Usage: required
4157 Value type: <phandle>
42− Definition: reference to the iface, bus and mem clocks to be held on
43− behalf of the booting of the Hexagon core
58+ Definition: reference to the clocks that match clock-names
4459
4560 - clock-names:
4661 Usage: required
4762 Value type: <stringlist>
48− Definition: must be "iface", "bus", "mem"
63+ Definition: The clocks needed depend on the compatible string:
64+ qcom,ipq8074-wcss-pil:
65+ no clock names required
66+ qcom,q6v5-pil:
67+ qcom,msm8916-mss-pil:
68+ qcom,msm8974-mss-pil:
69+ must be "iface", "bus", "mem", "xo"
70+ qcom,msm8996-mss-pil:
71+ must be "iface", "bus", "mem", "xo", "gpll0_mss",
72+ "snoc_axi", "mnoc_axi", "pnoc", "qdss"
73+ qcom,sdm845-mss-pil:
74+ must be "iface", "bus", "mem", "xo", "gpll0_mss",
75+ "snoc_axi", "mnoc_axi", "prng"
4976
5077 - resets:
5178 Usage: required
@@ -65,6 +92,19 @@ on the Qualcomm Hexagon core. · 13 unmodified lines
6592 must be "mss_restart", "pdc_reset" for the modem
6693 sub-system on SDM845 SoCs
6794
95+For the compatible strings below the following supplies are required:
96+ "qcom,q6v5-pil"
97+ "qcom,msm8916-mss-pil",
98+- cx-supply:
99+- mx-supply:
100+- pll-supply:
101+ Usage: required
102+ Value type: <phandle>
103+ Definition: reference to the regulators to be held on behalf of the
104+ booting of the Hexagon core
105+
106+For the compatible string below the following supplies are required:
107+ "qcom,msm8974-mss-pil"
68108 - cx-supply:
69109 - mss-supply:
70110 - mx-supply:
@@ -74,6 +114,33 @@ on the Qualcomm Hexagon core. · 3 unmodified lines
74114 Definition: reference to the regulators to be held on behalf of the
75115 booting of the Hexagon core
76116
117+For the compatible string below the following supplies are required:
118+ "qcom,msm8996-mss-pil"
119+- pll-supply:
120+ Usage: required
121+ Value type: <phandle>
122+ Definition: reference to the regulators to be held on behalf of the
123+ booting of the Hexagon core
124+
125+- power-domains:
126+ Usage: required
127+ Value type: <phandle>
128+ Definition: reference to power-domains that match power-domain-names
129+
130+- power-domain-names:
131+ Usage: required
132+ Value type: <stringlist>
133+ Definition: The power-domains needed depend on the compatible string:
134+ qcom,q6v5-pil:
135+ qcom,ipq8074-wcss-pil:
136+ qcom,msm8916-mss-pil:
137+ qcom,msm8974-mss-pil:
138+ no power-domain names required
139+ qcom,msm8996-mss-pil:
140+ must be "cx", "mx"
141+ qcom,sdm845-mss-pil:
142+ must be "cx", "mx", "mss", "load_state"
143+
77144 - qcom,smem-states:
78145 Usage: required
79146 Value type: <phandle>
drivers/remoteproc/qcom_q6v5_adsp.c+5−1
@@ -48,7 +48,7 @@ · 47 unmodified lines
4848
4949 /* list of clocks required by ADSP PIL */
5050 static const char * const adsp_clk_id[] = {
51− "sway_cbcr", "lpass_aon", "lpass_ahbs_aon_cbcr", "lpass_ahbm_aon_cbcr",
51+ "sway_cbcr", "lpass_ahbs_aon_cbcr", "lpass_ahbm_aon_cbcr",
5252 "qdsp6ss_xo", "qdsp6ss_sleep", "qdsp6ss_core",
5353 };
5454
@@ -439,6 +439,10 @@ static int adsp_probe(struct platform_device *pdev) · 384 unmodified lines
439439 adsp->sysmon = qcom_add_sysmon_subdev(rproc,
440440 desc->sysmon_name,
441441 desc->ssctl_id);
442+ if (IS_ERR(adsp->sysmon)) {
443+ ret = PTR_ERR(adsp->sysmon);
444+ goto disable_pm;
445+ }
442446
443447 ret = rproc_add(rproc);
444448 if (ret)
drivers/remoteproc/qcom_q6v5_mss.c+194−15
@@ -25,6 +25,8 @@ · 24 unmodified lines
2525 #include <linux/of_address.h>
2626 #include <linux/of_device.h>
2727 #include <linux/platform_device.h>
28+#include <linux/pm_domain.h>
29+#include <linux/pm_runtime.h>
2830 #include <linux/regmap.h>
2931 #include <linux/regulator/consumer.h>
3032 #include <linux/remoteproc.h>
@@ -131,6 +133,8 @@ struct rproc_hexagon_res { · 100 unmodified lines
131133 char **proxy_clk_names;
132134 char **reset_clk_names;
133135 char **active_clk_names;
136+ char **active_pd_names;
137+ char **proxy_pd_names;
134138 int version;
135139 bool need_mem_protection;
136140 bool has_alt_reset;
@@ -156,9 +160,13 @@ struct q6v5 { · 19 unmodified lines
156160 struct clk *active_clks[8];
157161 struct clk *reset_clks[4];
158162 struct clk *proxy_clks[4];
163+ struct device *active_pds[1];
164+ struct device *proxy_pds[3];
159165 int active_clk_count;
160166 int reset_clk_count;
161167 int proxy_clk_count;
168+ int active_pd_count;
169+ int proxy_pd_count;
162170
163171 struct reg_info active_regs[1];
164172 struct reg_info proxy_regs[3];
@@ -188,6 +196,7 @@ struct q6v5 { · 23 unmodified lines
188196 bool has_alt_reset;
189197 int mpss_perm;
190198 int mba_perm;
199+ const char *hexagon_mdt_image;
191200 int version;
192201 };
193202
@@ -321,6 +330,41 @@ static void q6v5_clk_disable(struct device *dev, · 127 unmodified lines
321330 clk_disable_unprepare(clks[i]);
322331 }
323332
333+static int q6v5_pds_enable(struct q6v5 *qproc, struct device **pds,
334+ size_t pd_count)
335+{
336+ int ret;
337+ int i;
338+
339+ for (i = 0; i < pd_count; i++) {
340+ dev_pm_genpd_set_performance_state(pds[i], INT_MAX);
341+ ret = pm_runtime_get_sync(pds[i]);
342+ if (ret < 0)
343+ goto unroll_pd_votes;
344+ }
345+
346+ return 0;
347+
348+unroll_pd_votes:
349+ for (i--; i >= 0; i--) {
350+ dev_pm_genpd_set_performance_state(pds[i], 0);
351+ pm_runtime_put(pds[i]);
352+ }
353+
354+ return ret;
355+};
356+
357+static void q6v5_pds_disable(struct q6v5 *qproc, struct device **pds,
358+ size_t pd_count)
359+{
360+ int i;
361+
362+ for (i = 0; i < pd_count; i++) {
363+ dev_pm_genpd_set_performance_state(pds[i], 0);
364+ pm_runtime_put(pds[i]);
365+ }
366+}
367+
324368 static int q6v5_xfer_mem_ownership(struct q6v5 *qproc, int *current_perm,
325369 bool remote_owner, phys_addr_t addr,
326370 size_t size)
@@ -690,11 +734,23 @@ static int q6v5_mba_load(struct q6v5 *qproc) · 363 unmodified lines
690734
691735 qcom_q6v5_prepare(&qproc->q6v5);
692736
737+ ret = q6v5_pds_enable(qproc, qproc->active_pds, qproc->active_pd_count);
738+ if (ret < 0) {
739+ dev_err(qproc->dev, "failed to enable active power domains\n");
740+ goto disable_irqs;
741+ }
742+
743+ ret = q6v5_pds_enable(qproc, qproc->proxy_pds, qproc->proxy_pd_count);
744+ if (ret < 0) {
745+ dev_err(qproc->dev, "failed to enable proxy power domains\n");
746+ goto disable_active_pds;
747+ }
748+
693749 ret = q6v5_regulator_enable(qproc, qproc->proxy_regs,
694750 qproc->proxy_reg_count);
695751 if (ret) {
696752 dev_err(qproc->dev, "failed to enable proxy supplies\n");
697− goto disable_irqs;
753+ goto disable_proxy_pds;
698754 }
699755
700756 ret = q6v5_clk_enable(qproc->dev, qproc->proxy_clks,
@@ -791,6 +847,10 @@ disable_proxy_clk: · 90 unmodified lines
791847 disable_proxy_reg:
792848 q6v5_regulator_disable(qproc, qproc->proxy_regs,
793849 qproc->proxy_reg_count);
850+disable_proxy_pds:
851+ q6v5_pds_disable(qproc, qproc->proxy_pds, qproc->proxy_pd_count);
852+disable_active_pds:
853+ q6v5_pds_disable(qproc, qproc->active_pds, qproc->active_pd_count);
794854 disable_irqs:
795855 qcom_q6v5_unprepare(&qproc->q6v5);
796856
@@ -830,6 +890,7 @@ static void q6v5_mba_reclaim(struct q6v5 *qproc) · 33 unmodified lines
830890 qproc->active_clk_count);
831891 q6v5_regulator_disable(qproc, qproc->active_regs,
832892 qproc->active_reg_count);
893+ q6v5_pds_disable(qproc, qproc->active_pds, qproc->active_pd_count);
833894
834895 /* In case of failure or coredump scenario where reclaiming MBA memory
835896 * could not happen reclaim it here.
@@ -841,6 +902,8 @@ static void q6v5_mba_reclaim(struct q6v5 *qproc) · 5 unmodified lines
841902
842903 ret = qcom_q6v5_unprepare(&qproc->q6v5);
843904 if (ret) {
905+ q6v5_pds_disable(qproc, qproc->proxy_pds,
906+ qproc->proxy_pd_count);
844907 q6v5_clk_disable(qproc->dev, qproc->proxy_clks,
845908 qproc->proxy_clk_count);
846909 q6v5_regulator_disable(qproc, qproc->proxy_regs,
@@ -860,17 +923,26 @@ static int q6v5_mpss_load(struct q6v5 *qproc) · 13 unmodified lines
860923 phys_addr_t min_addr = PHYS_ADDR_MAX;
861924 phys_addr_t max_addr = 0;
862925 bool relocate = false;
863− char seg_name[10];
926+ char *fw_name;
927+ size_t fw_name_len;
864928 ssize_t offset;
865929 size_t size = 0;
866930 void *ptr;
867931 int ret;
868932 int i;
869933
870− ret = request_firmware(&fw, "modem.mdt", qproc->dev);
934+ fw_name_len = strlen(qproc->hexagon_mdt_image);
935+ if (fw_name_len <= 4)
936+ return -EINVAL;
937+
938+ fw_name = kstrdup(qproc->hexagon_mdt_image, GFP_KERNEL);
939+ if (!fw_name)
940+ return -ENOMEM;
941+
942+ ret = request_firmware(&fw, fw_name, qproc->dev);
871943 if (ret < 0) {
872− dev_err(qproc->dev, "unable to load modem.mdt\n");
873− return ret;
944+ dev_err(qproc->dev, "unable to load %s\n", fw_name);
945+ goto out;
874946 }
875947
876948 /* Initialize the RMB validator */
@@ -918,10 +990,11 @@ static int q6v5_mpss_load(struct q6v5 *qproc) · 41 unmodified lines
918990 ptr = qproc->mpss_region + offset;
919991
920992 if (phdr->p_filesz) {
921− snprintf(seg_name, sizeof(seg_name), "modem.b%02d", i);
922− ret = request_firmware(&seg_fw, seg_name, qproc->dev);
993+ /* Replace "xxx.xxx" with "xxx.bxx" */
994+ sprintf(fw_name + fw_name_len - 3, "b%02d", i);
995+ ret = request_firmware(&seg_fw, fw_name, qproc->dev);
923996 if (ret) {
924− dev_err(qproc->dev, "failed to load %s\n", seg_name);
997+ dev_err(qproc->dev, "failed to load %s\n", fw_name);
925998 goto release_firmware;
926999 }
9271000
@@ -960,6 +1033,8 @@ static int q6v5_mpss_load(struct q6v5 *qproc) · 32 unmodified lines
9601033
9611034 release_firmware:
9621035 release_firmware(fw);
1036+out:
1037+ kfree(fw_name);
9631038
9641039 return ret < 0 ? ret : 0;
9651040 }
@@ -1075,9 +1150,10 @@ static int qcom_q6v5_register_dump_segments(struct rproc *rproc, · 109 unmodified lines
10751150 unsigned long i;
10761151 int ret;
10771152
1078− ret = request_firmware(&fw, "modem.mdt", qproc->dev);
1153+ ret = request_firmware(&fw, qproc->hexagon_mdt_image, qproc->dev);
10791154 if (ret < 0) {
1080− dev_err(qproc->dev, "unable to load modem.mdt\n");
1155+ dev_err(qproc->dev, "unable to load %s\n",
1156+ qproc->hexagon_mdt_image);
10811157 return ret;
10821158 }
10831159
@@ -1121,6 +1197,7 @@ static void qcom_msa_handover(struct qcom_q6v5 *q6v5) · 37 unmodified lines
11211197 qproc->proxy_clk_count);
11221198 q6v5_regulator_disable(qproc, qproc->proxy_regs,
11231199 qproc->proxy_reg_count);
1200+ q6v5_pds_disable(qproc, qproc->proxy_pds, qproc->proxy_pd_count);
11241201 }
11251202
11261203 static int q6v5_init_mem(struct q6v5 *qproc, struct platform_device *pdev)
@@ -1181,6 +1258,45 @@ static int q6v5_init_clocks(struct device *dev, struct clk **clks, · 54 unmodified lines
11811258 return i;
11821259 }
11831260
1261+static int q6v5_pds_attach(struct device *dev, struct device **devs,
1262+ char **pd_names)
1263+{
1264+ size_t num_pds = 0;
1265+ int ret;
1266+ int i;
1267+
1268+ if (!pd_names)
1269+ return 0;
1270+
1271+ while (pd_names[num_pds])
1272+ num_pds++;
1273+
1274+ for (i = 0; i < num_pds; i++) {
1275+ devs[i] = dev_pm_domain_attach_by_name(dev, pd_names[i]);
1276+ if (IS_ERR(devs[i])) {
1277+ ret = PTR_ERR(devs[i]);
1278+ goto unroll_attach;
1279+ }
1280+ }
1281+
1282+ return num_pds;
1283+
1284+unroll_attach:
1285+ for (i--; i >= 0; i--)
1286+ dev_pm_domain_detach(devs[i], false);
1287+
1288+ return ret;
1289+};
1290+
1291+static void q6v5_pds_detach(struct q6v5 *qproc, struct device **pds,
1292+ size_t pd_count)
1293+{
1294+ int i;
1295+
1296+ for (i = 0; i < pd_count; i++)
1297+ dev_pm_domain_detach(pds[i], false);
1298+}
1299+
11841300 static int q6v5_init_reset(struct q6v5 *qproc)
11851301 {
11861302 qproc->mss_restart = devm_reset_control_get_exclusive(qproc->dev,
@@ -1253,6 +1369,7 @@ static int q6v5_probe(struct platform_device *pdev) · 66 unmodified lines
12531369 const struct rproc_hexagon_res *desc;
12541370 struct q6v5 *qproc;
12551371 struct rproc *rproc;
1372+ const char *mba_image;
12561373 int ret;
12571374
12581375 desc = of_device_get_match_data(&pdev->dev);
@@ -1262,16 +1379,30 @@ static int q6v5_probe(struct platform_device *pdev) · 3 unmodified lines
12621379 if (desc->need_mem_protection && !qcom_scm_is_available())
12631380 return -EPROBE_DEFER;
12641381
1382+ mba_image = desc->hexagon_mba_image;
1383+ ret = of_property_read_string_index(pdev->dev.of_node, "firmware-name",
1384+ 0, &mba_image);
1385+ if (ret < 0 && ret != -EINVAL)
1386+ return ret;
1387+
12651388 rproc = rproc_alloc(&pdev->dev, pdev->name, &q6v5_ops,
1266− desc->hexagon_mba_image, sizeof(*qproc));
1389+ mba_image, sizeof(*qproc));
12671390 if (!rproc) {
12681391 dev_err(&pdev->dev, "failed to allocate rproc\n");
12691392 return -ENOMEM;
12701393 }
12711394
1395+ rproc->auto_boot = false;
1396+
12721397 qproc = (struct q6v5 *)rproc->priv;
12731398 qproc->dev = &pdev->dev;
12741399 qproc->rproc = rproc;
1400+ qproc->hexagon_mdt_image = "modem.mdt";
1401+ ret = of_property_read_string_index(pdev->dev.of_node, "firmware-name",
1402+ 1, &qproc->hexagon_mdt_image);
1403+ if (ret < 0 && ret != -EINVAL)
1404+ return ret;
1405+
12751406 platform_set_drvdata(pdev, qproc);
12761407
12771408 ret = q6v5_init_mem(qproc, pdev);
@@ -1322,10 +1453,26 @@ static int q6v5_probe(struct platform_device *pdev) · 44 unmodified lines
13221453 }
13231454 qproc->active_reg_count = ret;
13241455
1456+ ret = q6v5_pds_attach(&pdev->dev, qproc->active_pds,
1457+ desc->active_pd_names);
1458+ if (ret < 0) {
1459+ dev_err(&pdev->dev, "Failed to attach active power domains\n");
1460+ goto free_rproc;
1461+ }
1462+ qproc->active_pd_count = ret;
1463+
1464+ ret = q6v5_pds_attach(&pdev->dev, qproc->proxy_pds,
1465+ desc->proxy_pd_names);
1466+ if (ret < 0) {
1467+ dev_err(&pdev->dev, "Failed to init power domains\n");
1468+ goto detach_active_pds;
1469+ }
1470+ qproc->proxy_pd_count = ret;
1471+
13251472 qproc->has_alt_reset = desc->has_alt_reset;
13261473 ret = q6v5_init_reset(qproc);
13271474 if (ret)
1328− goto free_rproc;
1475+ goto detach_proxy_pds;
13291476
13301477 qproc->version = desc->version;
13311478 qproc->need_mem_protection = desc->need_mem_protection;
@@ -1333,7 +1480,7 @@ static int q6v5_probe(struct platform_device *pdev) · 1 unmodified line
13331480 ret = qcom_q6v5_init(&qproc->q6v5, pdev, rproc, MPSS_CRASH_REASON_SMEM,
13341481 qcom_msa_handover);
13351482 if (ret)
1336− goto free_rproc;
1483+ goto detach_proxy_pds;
13371484
13381485 qproc->mpss_perm = BIT(QCOM_SCM_VMID_HLOS);
13391486 qproc->mba_perm = BIT(QCOM_SCM_VMID_HLOS);
@@ -1341,13 +1488,21 @@ static int q6v5_probe(struct platform_device *pdev) · 1 unmodified line
13411488 qcom_add_smd_subdev(rproc, &qproc->smd_subdev);
13421489 qcom_add_ssr_subdev(rproc, &qproc->ssr_subdev, "mpss");
13431490 qproc->sysmon = qcom_add_sysmon_subdev(rproc, "modem", 0x12);
1491+ if (IS_ERR(qproc->sysmon)) {
1492+ ret = PTR_ERR(qproc->sysmon);
1493+ goto detach_proxy_pds;
1494+ }
13441495
13451496 ret = rproc_add(rproc);
13461497 if (ret)
1347− goto free_rproc;
1498+ goto detach_proxy_pds;
13481499
13491500 return 0;
13501501
1502+detach_proxy_pds:
1503+ q6v5_pds_detach(qproc, qproc->proxy_pds, qproc->proxy_pd_count);
1504+detach_active_pds:
1505+ q6v5_pds_detach(qproc, qproc->active_pds, qproc->active_pd_count);
13511506 free_rproc:
13521507 rproc_free(rproc);
13531508
@@ -1364,6 +1519,10 @@ static int q6v5_remove(struct platform_device *pdev) · 10 unmodified lines
13641519 qcom_remove_glink_subdev(qproc->rproc, &qproc->glink_subdev);
13651520 qcom_remove_smd_subdev(qproc->rproc, &qproc->smd_subdev);
13661521 qcom_remove_ssr_subdev(qproc->rproc, &qproc->ssr_subdev);
1522+
1523+ q6v5_pds_detach(qproc, qproc->active_pds, qproc->active_pd_count);
1524+ q6v5_pds_detach(qproc, qproc->proxy_pds, qproc->proxy_pd_count);
1525+
13671526 rproc_free(qproc->rproc);
13681527
13691528 return 0;
@@ -1388,6 +1547,16 @@ static const struct rproc_hexagon_res sdm845_mss = { · 18 unmodified lines
13881547 "mnoc_axi",
13891548 NULL
13901549 },
1550+ .active_pd_names = (char*[]){
1551+ "load_state",
1552+ NULL
1553+ },
1554+ .proxy_pd_names = (char*[]){
1555+ "cx",
1556+ "mx",
1557+ "mss",
1558+ NULL
1559+ },
13911560 .need_mem_protection = true,
13921561 .has_alt_reset = true,
13931562 .version = MSS_SDM845,
@@ -1395,16 +1564,26 @@ static const struct rproc_hexagon_res sdm845_mss = { · 1 unmodified line
13951564
13961565 static const struct rproc_hexagon_res msm8996_mss = {
13971566 .hexagon_mba_image = "mba.mbn",
1567+ .proxy_supply = (struct qcom_mss_reg_res[]) {
1568+ {
1569+ .supply = "pll",
1570+ .uA = 100000,
1571+ },
1572+ {}
1573+ },
13981574 .proxy_clk_names = (char*[]){
13991575 "xo",
14001576 "pnoc",
1577+ "qdss",
14011578 NULL
14021579 },
14031580 .active_clk_names = (char*[]){
14041581 "iface",
14051582 "bus",
14061583 "mem",
1407− "gpll0_mss_clk",
1584+ "gpll0_mss",
1585+ "snoc_axi",
1586+ "mnoc_axi",
14081587 NULL
14091588 },
14101589 .need_mem_protection = true,
drivers/remoteproc/qcom_q6v5_pas.c+12−1
@@ -258,6 +258,7 @@ static int adsp_probe(struct platform_device *pdev) · 257 unmodified lines
258258 const struct adsp_data *desc;
259259 struct qcom_adsp *adsp;
260260 struct rproc *rproc;
261+ const char *fw_name;
261262 int ret;
262263
263264 desc = of_device_get_match_data(&pdev->dev);
@@ -267,8 +268,14 @@ static int adsp_probe(struct platform_device *pdev) · 3 unmodified lines
267268 if (!qcom_scm_is_available())
268269 return -EPROBE_DEFER;
269270
271+ fw_name = desc->firmware_name;
272+ ret = of_property_read_string(pdev->dev.of_node, "firmware-name",
273+ &fw_name);
274+ if (ret < 0 && ret != -EINVAL)
275+ return ret;
276+
270277 rproc = rproc_alloc(&pdev->dev, pdev->name, &adsp_ops,
271− desc->firmware_name, sizeof(*adsp));
278+ fw_name, sizeof(*adsp));
272279 if (!rproc) {
273280 dev_err(&pdev->dev, "unable to allocate remoteproc\n");
274281 return -ENOMEM;
@@ -304,6 +311,10 @@ static int adsp_probe(struct platform_device *pdev) · 29 unmodified lines
304311 adsp->sysmon = qcom_add_sysmon_subdev(rproc,
305312 desc->sysmon_name,
306313 desc->ssctl_id);
314+ if (IS_ERR(adsp->sysmon)) {
315+ ret = PTR_ERR(adsp->sysmon);
316+ goto free_rproc;
317+ }
307318
308319 ret = rproc_add(rproc);
309320 if (ret)
drivers/remoteproc/qcom_sysmon.c+78−4
@@ -6,8 +6,9 @@ · 5 unmodified lines
66 #include <linux/module.h>
77 #include <linux/notifier.h>
88 #include <linux/slab.h>
9+#include <linux/interrupt.h>
910 #include <linux/io.h>
10−#include <linux/notifier.h>
11+#include <linux/of_irq.h>
1112 #include <linux/of_platform.h>
1213 #include <linux/platform_device.h>
1314 #include <linux/remoteproc/qcom_rproc.h>
@@ -25,6 +26,7 @@ struct qcom_sysmon { · 11 unmodified lines
2526
2627 const char *name;
2728
29+ int shutdown_irq;
2830 int ssctl_version;
2931 int ssctl_instance;
3032
@@ -34,6 +36,8 @@ struct qcom_sysmon { · 3 unmodified lines
3436
3537 struct rpmsg_endpoint *ept;
3638 struct completion comp;
39+ struct completion ind_comp;
40+ struct completion shutdown_comp;
3741 struct mutex lock;
3842
3943 bool ssr_ack;
@@ -137,6 +141,7 @@ static int sysmon_callback(struct rpmsg_device *rpdev, void *data, int count, · 97 unmodified lines
137141 }
138142
139143 #define SSCTL_SHUTDOWN_REQ 0x21
144+#define SSCTL_SHUTDOWN_READY_IND 0x21
140145 #define SSCTL_SUBSYS_EVENT_REQ 0x23
141146
142147 #define SSCTL_MAX_MSG_LEN 7
@@ -252,6 +257,29 @@ static struct qmi_elem_info ssctl_subsys_event_resp_ei[] = { · 109 unmodified lines
252257 {}
253258 };
254259
260+static struct qmi_elem_info ssctl_shutdown_ind_ei[] = {
261+ {}
262+};
263+
264+static void sysmon_ind_cb(struct qmi_handle *qmi, struct sockaddr_qrtr *sq,
265+ struct qmi_txn *txn, const void *data)
266+{
267+ struct qcom_sysmon *sysmon = container_of(qmi, struct qcom_sysmon, qmi);
268+
269+ complete(&sysmon->ind_comp);
270+}
271+
272+static struct qmi_msg_handler qmi_indication_handler[] = {
273+ {
274+ .type = QMI_INDICATION,
275+ .msg_id = SSCTL_SHUTDOWN_READY_IND,
276+ .ei = ssctl_shutdown_ind_ei,
277+ .decoded_size = 0,
278+ .fn = sysmon_ind_cb
279+ },
280+ {}
281+};
282+
255283 /**
256284 * ssctl_request_shutdown() - request shutdown via SSCTL QMI service
257285 * @sysmon: sysmon context
@@ -262,6 +290,8 @@ static void ssctl_request_shutdown(struct qcom_sysmon *sysmon) · 4 unmodified lines
262290 struct qmi_txn txn;
263291 int ret;
264292
293+ reinit_completion(&sysmon->ind_comp);
294+ reinit_completion(&sysmon->shutdown_comp);
265295 ret = qmi_txn_init(&sysmon->qmi, &txn, ssctl_shutdown_resp_ei, &resp);
266296 if (ret < 0) {
267297 dev_err(sysmon->dev, "failed to allocate QMI txn\n");
@@ -283,6 +313,17 @@ static void ssctl_request_shutdown(struct qcom_sysmon *sysmon) · 15 unmodified lines
283313 dev_err(sysmon->dev, "shutdown request failed\n");
284314 else
285315 dev_dbg(sysmon->dev, "shutdown request completed\n");
316+
317+ if (sysmon->shutdown_irq > 0) {
318+ ret = wait_for_completion_timeout(&sysmon->shutdown_comp,
319+ 10 * HZ);
320+ if (!ret) {
321+ ret = try_wait_for_completion(&sysmon->ind_comp);
322+ if (!ret)
323+ dev_err(sysmon->dev,
324+ "timeout waiting for shutdown ack\n");
325+ }
326+ }
286327 }
287328
288329 /**
@@ -432,6 +473,15 @@ static int sysmon_notify(struct notifier_block *nb, unsigned long event, · 143 unmodified lines
432473 return NOTIFY_DONE;
433474 }
434475
476+static irqreturn_t sysmon_shutdown_interrupt(int irq, void *data)
477+{
478+ struct qcom_sysmon *sysmon = data;
479+
480+ complete(&sysmon->shutdown_comp);
481+
482+ return IRQ_HANDLED;
483+}
484+
435485 /**
436486 * qcom_add_sysmon_subdev() - create a sysmon subdev for the given remoteproc
437487 * @rproc: rproc context to associate the subdev with
@@ -449,7 +499,7 @@ struct qcom_sysmon *qcom_add_sysmon_subdev(struct rproc *rproc, · 11 unmodified lines
449499
450500 sysmon = kzalloc(sizeof(*sysmon), GFP_KERNEL);
451501 if (!sysmon)
452− return NULL;
502+ return ERR_PTR(-ENOMEM);
453503
454504 sysmon->dev = rproc->dev.parent;
455505 sysmon->rproc = rproc;
@@ -458,13 +508,37 @@ struct qcom_sysmon *qcom_add_sysmon_subdev(struct rproc *rproc, · 2 unmodified lines
458508 sysmon->ssctl_instance = ssctl_instance;
459509
460510 init_completion(&sysmon->comp);
511+ init_completion(&sysmon->ind_comp);
512+ init_completion(&sysmon->shutdown_comp);
461513 mutex_init(&sysmon->lock);
462514
463− ret = qmi_handle_init(&sysmon->qmi, SSCTL_MAX_MSG_LEN, &ssctl_ops, NULL);
515+ sysmon->shutdown_irq = of_irq_get_byname(sysmon->dev->of_node,
516+ "shutdown-ack");
517+ if (sysmon->shutdown_irq < 0) {
518+ if (sysmon->shutdown_irq != -ENODATA) {
519+ dev_err(sysmon->dev,
520+ "failed to retrieve shutdown-ack IRQ\n");
521+ return ERR_PTR(sysmon->shutdown_irq);
522+ }
523+ } else {
524+ ret = devm_request_threaded_irq(sysmon->dev,
525+ sysmon->shutdown_irq,
526+ NULL, sysmon_shutdown_interrupt,
527+ IRQF_TRIGGER_RISING | IRQF_ONESHOT,
528+ "q6v5 shutdown-ack", sysmon);
529+ if (ret) {
530+ dev_err(sysmon->dev,
531+ "failed to acquire shutdown-ack IRQ\n");
532+ return ERR_PTR(ret);
533+ }
534+ }
535+
536+ ret = qmi_handle_init(&sysmon->qmi, SSCTL_MAX_MSG_LEN, &ssctl_ops,
537+ qmi_indication_handler);
464538 if (ret < 0) {
465539 dev_err(sysmon->dev, "failed to initialize qmi handle\n");
466540 kfree(sysmon);
467− return NULL;
541+ return ERR_PTR(ret);
468542 }
469543
470544 qmi_add_lookup(&sysmon->qmi, 43, 0, 0);
drivers/remoteproc/qcom_wcnss.c+5−1
@@ -553,6 +553,10 @@ static int wcnss_probe(struct platform_device *pdev) · 552 unmodified lines
553553
554554 qcom_add_smd_subdev(rproc, &wcnss->smd_subdev);
555555 wcnss->sysmon = qcom_add_sysmon_subdev(rproc, "wcnss", WCNSS_SSCTL_ID);
556+ if (IS_ERR(wcnss->sysmon)) {
557+ ret = PTR_ERR(wcnss->sysmon);
558+ goto free_rproc;
559+ }
556560
557561 ret = rproc_add(rproc);
558562 if (ret)
@@ -622,5 +626,5 @@ static void __exit wcnss_exit(void) · 63 unmodified lines
622626 }
623627 module_exit(wcnss_exit);
624628
625−MODULE_DESCRIPTION("Qualcomm Peripherial Image Loader for Wireless Subsystem");
629+MODULE_DESCRIPTION("Qualcomm Peripheral Image Loader for Wireless Subsystem");
626630 MODULE_LICENSE("GPL v2");
drivers/remoteproc/remoteproc_core.c+112−48
@@ -39,12 +39,16 @@ · 38 unmodified lines
3939 #include <linux/idr.h>
4040 #include <linux/elf.h>
4141 #include <linux/crc32.h>
42+#include <linux/of_reserved_mem.h>
4243 #include <linux/virtio_ids.h>
4344 #include <linux/virtio_ring.h>
4445 #include <asm/byteorder.h>
46+#include <linux/platform_device.h>
4547
4648 #include "remoteproc_internal.h"
4749
50+#define HIGH_BITS_MASK 0xFFFFFFFF00000000ULL
51+
4852 static DEFINE_MUTEX(rproc_list_mutex);
4953 static LIST_HEAD(rproc_list);
5054
@@ -145,7 +149,7 @@ static void rproc_disable_iommu(struct rproc *rproc) · 94 unmodified lines
145149 iommu_domain_free(domain);
146150 }
147151
148−static phys_addr_t rproc_va_to_pa(void *cpu_addr)
152+phys_addr_t rproc_va_to_pa(void *cpu_addr)
149153 {
150154 /*
151155 * Return physical address according to virtual address location
@@ -160,6 +164,7 @@ static phys_addr_t rproc_va_to_pa(void *cpu_addr) · 8 unmodified lines
160164 WARN_ON(!virt_addr_valid(cpu_addr));
161165 return virt_to_phys(cpu_addr);
162166 }
167+EXPORT_SYMBOL(rproc_va_to_pa);
163168
164169 /**
165170 * rproc_da_to_va() - lookup the kernel virtual address for a remoteproc address
@@ -204,6 +209,10 @@ void *rproc_da_to_va(struct rproc *rproc, u64 da, int len) · 38 unmodified lines
204209 list_for_each_entry(carveout, &rproc->carveouts, node) {
205210 int offset = da - carveout->da;
206211
212+ /* Verify that carveout is allocated */
213+ if (!carveout->va)
214+ continue;
215+
207216 /* try next carveout if da is too small */
208217 if (offset < 0)
209218 continue;
@@ -272,25 +281,27 @@ rproc_find_carveout_by_name(struct rproc *rproc, const char *name, ...) · 62 unmodified lines
272281 * @len: associated area size
273282 *
274283 * This function is a helper function to verify requested device area (couple
275− * da, len) is part of specified carevout.
284+ * da, len) is part of specified carveout.
285+ * If da is not set (defined as FW_RSC_ADDR_ANY), only requested length is
286+ * checked.
276287 *
277− * Return: 0 if carveout match request else -ENOMEM
288+ * Return: 0 if carveout matches request else error
278289 */
279−int rproc_check_carveout_da(struct rproc *rproc, struct rproc_mem_entry *mem,
280− u32 da, u32 len)
290+static int rproc_check_carveout_da(struct rproc *rproc,
291+ struct rproc_mem_entry *mem, u32 da, u32 len)
281292 {
282293 struct device *dev = &rproc->dev;
283− int delta = 0;
294+ int delta;
284295
285296 /* Check requested resource length */
286297 if (len > mem->len) {
287298 dev_err(dev, "Registered carveout doesn't fit len request\n");
288− return -ENOMEM;
299+ return -EINVAL;
289300 }
290301
291302 if (da != FW_RSC_ADDR_ANY && mem->da == FW_RSC_ADDR_ANY) {
292− /* Update existing carveout da */
293− mem->da = da;
303+ /* Address doesn't match registered carveout configuration */
304+ return -EINVAL;
294305 } else if (da != FW_RSC_ADDR_ANY && mem->da != FW_RSC_ADDR_ANY) {
295306 delta = da - mem->da;
296307
@@ -298,13 +309,13 @@ int rproc_check_carveout_da(struct rproc *rproc, struct rproc_mem_entry *mem, · 1 unmodified line
298309 if (delta < 0) {
299310 dev_err(dev,
300311 "Registered carveout doesn't fit da request\n");
301− return -ENOMEM;
312+ return -EINVAL;
302313 }
303314
304315 if (delta + len > mem->len) {
305316 dev_err(dev,
306317 "Registered carveout doesn't fit len request\n");
307− return -ENOMEM;
318+ return -EINVAL;
308319 }
309320 }
310321
@@ -418,8 +429,25 @@ static int rproc_vdev_do_start(struct rproc_subdev *subdev) · 107 unmodified lines
418429 static void rproc_vdev_do_stop(struct rproc_subdev *subdev, bool crashed)
419430 {
420431 struct rproc_vdev *rvdev = container_of(subdev, struct rproc_vdev, subdev);
432+ int ret;
421433
422− rproc_remove_virtio_dev(rvdev);
434+ ret = device_for_each_child(&rvdev->dev, NULL, rproc_remove_virtio_dev);
435+ if (ret)
436+ dev_warn(&rvdev->dev, "can't remove vdev child device: %d\n", ret);
437+}
438+
439+/**
440+ * rproc_rvdev_release() - release the existence of a rvdev
441+ *
442+ * @dev: the subdevice's dev
443+ */
444+static void rproc_rvdev_release(struct device *dev)
445+{
446+ struct rproc_vdev *rvdev = container_of(dev, struct rproc_vdev, dev);
447+
448+ of_reserved_mem_device_release(dev);
449+
450+ kfree(rvdev);
423451 }
424452
425453 /**
@@ -455,6 +483,7 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc, · 29 unmodified lines
455483 struct device *dev = &rproc->dev;
456484 struct rproc_vdev *rvdev;
457485 int i, ret;
486+ char name[16];
458487
459488 /* make sure resource isn't truncated */
460489 if (sizeof(*rsc) + rsc->num_of_vrings * sizeof(struct fw_rsc_vdev_vring)
@@ -488,6 +517,29 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc, · 27 unmodified lines
488517 rvdev->rproc = rproc;
489518 rvdev->index = rproc->nb_vdev++;
490519
520+ /* Initialise vdev subdevice */
521+ snprintf(name, sizeof(name), "vdev%dbuffer", rvdev->index);
522+ rvdev->dev.parent = rproc->dev.parent;
523+ rvdev->dev.release = rproc_rvdev_release;
524+ dev_set_name(&rvdev->dev, "%s#%s", dev_name(rvdev->dev.parent), name);
525+ dev_set_drvdata(&rvdev->dev, rvdev);
526+
527+ ret = device_register(&rvdev->dev);
528+ if (ret) {
529+ put_device(&rvdev->dev);
530+ return ret;
531+ }
532+ /* Make device dma capable by inheriting from parent's capabilities */
533+ set_dma_ops(&rvdev->dev, get_dma_ops(rproc->dev.parent));
534+
535+ ret = dma_coerce_mask_and_coherent(&rvdev->dev,
536+ dma_get_mask(rproc->dev.parent));
537+ if (ret) {
538+ dev_warn(dev,
539+ "Failed to set DMA mask %llx. Trying to continue... %x\n",
540+ dma_get_mask(rproc->dev.parent), ret);
541+ }
542+
491543 /* parse the vrings */
492544 for (i = 0; i < rsc->num_of_vrings; i++) {
493545 ret = rproc_parse_vring(rvdev, rsc, i);
@@ -518,7 +570,7 @@ unwind_vring_allocations: · 24 unmodified lines
518570 for (i--; i >= 0; i--)
519571 rproc_free_vring(&rvdev->vring[i]);
520572 free_rvdev:
521− kfree(rvdev);
573+ device_unregister(&rvdev->dev);
522574 return ret;
523575 }
524576
@@ -536,7 +588,7 @@ void rproc_vdev_release(struct kref *ref) · 11 unmodified lines
536588
537589 rproc_remove_subdev(rproc, &rvdev->subdev);
538590 list_del(&rvdev->node);
539− kfree(rvdev);
591+ device_unregister(&rvdev->dev);
540592 }
541593
542594 /**
@@ -558,9 +610,8 @@ void rproc_vdev_release(struct kref *ref) · 15 unmodified lines
558610 static int rproc_handle_trace(struct rproc *rproc, struct fw_rsc_trace *rsc,
559611 int offset, int avail)
560612 {
561− struct rproc_mem_entry *trace;
613+ struct rproc_debug_trace *trace;
562614 struct device *dev = &rproc->dev;
563− void *ptr;
564615 char name[15];
565616
566617 if (sizeof(*rsc) > avail) {
@@ -574,28 +625,23 @@ static int rproc_handle_trace(struct rproc *rproc, struct fw_rsc_trace *rsc, · 7 unmodified lines
574625 return -EINVAL;
575626 }
576627
577− /* what's the kernel address of this resource ? */
578− ptr = rproc_da_to_va(rproc, rsc->da, rsc->len);
579− if (!ptr) {
580− dev_err(dev, "erroneous trace resource entry\n");
581− return -EINVAL;
582− }
583−
584628 trace = kzalloc(sizeof(*trace), GFP_KERNEL);
585629 if (!trace)
586630 return -ENOMEM;
587631
588632 /* set the trace buffer dma properties */
589− trace->len = rsc->len;
590− trace->va = ptr;
633+ trace->trace_mem.len = rsc->len;
634+ trace->trace_mem.da = rsc->da;
635+
636+ /* set pointer on rproc device */
637+ trace->rproc = rproc;
591638
592639 /* make sure snprintf always null terminates, even if truncating */
593640 snprintf(name, sizeof(name), "trace%d", rproc->num_traces);
594641
595642 /* create the debugfs entry */
596− trace->priv = rproc_create_trace_file(name, rproc, trace);
597− if (!trace->priv) {
598− trace->va = NULL;
643+ trace->tfile = rproc_create_trace_file(name, rproc, trace);
644+ if (!trace->tfile) {
599645 kfree(trace);
600646 return -EINVAL;
601647 }
@@ -604,8 +650,8 @@ static int rproc_handle_trace(struct rproc *rproc, struct fw_rsc_trace *rsc, · 2 unmodified lines
604650
605651 rproc->num_traces++;
606652
607− dev_dbg(dev, "%s added: va %pK, da 0x%x, len 0x%x\n",
608− name, ptr, rsc->da, rsc->len);
653+ dev_dbg(dev, "%s added: da 0x%x, len 0x%x\n",
654+ name, rsc->da, rsc->len);
609655
610656 return 0;
611657 }
@@ -715,6 +761,18 @@ static int rproc_alloc_carveout(struct rproc *rproc, · 103 unmodified lines
715761 dev_dbg(dev, "carveout va %pK, dma %pad, len 0x%x\n",
716762 va, &dma, mem->len);
717763
764+ if (mem->da != FW_RSC_ADDR_ANY && !rproc->domain) {
765+ /*
766+ * Check requested da is equal to dma address
767+ * and print a warn message in case of missalignment.
768+ * Don't stop rproc_start sequence as coprocessor may
769+ * build pa to da translation on its side.
770+ */
771+ if (mem->da != (u32)dma)
772+ dev_warn(dev->parent,
773+ "Allocated carveout doesn't fit device address request\n");
774+ }
775+
718776 /*
719777 * Ok, this is non-standard.
720778 *
@@ -732,15 +790,7 @@ static int rproc_alloc_carveout(struct rproc *rproc, · 11 unmodified lines
732790 * to use the iommu-based DMA API: we expect 'dma' to contain the
733791 * physical address in this case.
734792 */
735−
736− if (mem->da != FW_RSC_ADDR_ANY) {
737− if (!rproc->domain) {
738− dev_err(dev->parent,
739− "Bad carveout rsc configuration\n");
740− ret = -ENOMEM;
741− goto dma_free;
742− }
743−
793+ if (mem->da != FW_RSC_ADDR_ANY && rproc->domain) {
744794 mapping = kzalloc(sizeof(*mapping), GFP_KERNEL);
745795 if (!mapping) {
746796 ret = -ENOMEM;
@@ -767,11 +817,17 @@ static int rproc_alloc_carveout(struct rproc *rproc, · 20 unmodified lines
767817
768818 dev_dbg(dev, "carveout mapped 0x%x to %pad\n",
769819 mem->da, &dma);
770− } else {
820+ }
821+
822+ if (mem->da == FW_RSC_ADDR_ANY) {
823+ /* Update device address as undefined by requester */
824+ if ((u64)dma & HIGH_BITS_MASK)
825+ dev_warn(dev, "DMA address cast in 32bit to fit resource table format\n");
826+
771827 mem->da = (u32)dma;
772828 }
773829
774− mem->dma = (u32)dma;
830+ mem->dma = dma;
775831 mem->va = va;
776832
777833 return 0;
@@ -900,7 +956,8 @@ EXPORT_SYMBOL(rproc_add_carveout); · 122 unmodified lines
900956 * @dma: dma address
901957 * @len: memory carveout length
902958 * @da: device address
903− * @release: memory carveout function
959+ * @alloc: memory carveout allocation function
960+ * @release: memory carveout release function
904961 * @name: carveout name
905962 *
906963 * This function allocates a rproc_mem_entry struct and fill it with parameters
@@ -1110,6 +1167,7 @@ static int rproc_alloc_registered_carveouts(struct rproc *rproc) · 203 unmodified lines
11101167 struct rproc_mem_entry *entry, *tmp;
11111168 struct fw_rsc_carveout *rsc;
11121169 struct device *dev = &rproc->dev;
1170+ u64 pa;
11131171 int ret;
11141172
11151173 list_for_each_entry_safe(entry, tmp, &rproc->carveouts, node) {
@@ -1146,10 +1204,15 @@ static int rproc_alloc_registered_carveouts(struct rproc *rproc) · 30 unmodified lines
11461204
11471205 /* Use va if defined else dma to generate pa */
11481206 if (entry->va)
1149− rsc->pa = (u32)rproc_va_to_pa(entry->va);
1207+ pa = (u64)rproc_va_to_pa(entry->va);
11501208 else
1151− rsc->pa = (u32)entry->dma;
1209+ pa = (u64)entry->dma;
1210+
1211+ if (((u64)pa) & HIGH_BITS_MASK)
1212+ dev_warn(dev,
1213+ "Physical address cast in 32bit to fit resource table format\n");
11521214
1215+ rsc->pa = (u32)pa;
11531216 rsc->da = entry->da;
11541217 rsc->len = entry->len;
11551218 }
@@ -1182,15 +1245,16 @@ static void rproc_coredump_cleanup(struct rproc *rproc) · 26 unmodified lines
11821245 static void rproc_resource_cleanup(struct rproc *rproc)
11831246 {
11841247 struct rproc_mem_entry *entry, *tmp;
1248+ struct rproc_debug_trace *trace, *ttmp;
11851249 struct rproc_vdev *rvdev, *rvtmp;
11861250 struct device *dev = &rproc->dev;
11871251
11881252 /* clean up debugfs trace entries */
1189− list_for_each_entry_safe(entry, tmp, &rproc->traces, node) {
1190− rproc_remove_trace_file(entry->priv);
1253+ list_for_each_entry_safe(trace, ttmp, &rproc->traces, node) {
1254+ rproc_remove_trace_file(trace->tfile);
11911255 rproc->num_traces--;
1192− list_del(&entry->node);
1193− kfree(entry);
1256+ list_del(&trace->node);
1257+ kfree(trace);
11941258 }
11951259
11961260 /* clean up iommu mapping entries */
drivers/remoteproc/remoteproc_debugfs.c+43−4
@@ -47,10 +47,23 @@ static struct dentry *rproc_dbg; · 46 unmodified lines
4747 static ssize_t rproc_trace_read(struct file *filp, char __user *userbuf,
4848 size_t count, loff_t *ppos)
4949 {
50− struct rproc_mem_entry *trace = filp->private_data;
51− int len = strnlen(trace->va, trace->len);
50+ struct rproc_debug_trace *data = filp->private_data;
51+ struct rproc_mem_entry *trace = &data->trace_mem;
52+ void *va;
53+ char buf[100];
54+ int len;
55+
56+ va = rproc_da_to_va(data->rproc, trace->da, trace->len);
5257
53− return simple_read_from_buffer(userbuf, count, ppos, trace->va, len);
58+ if (!va) {
59+ len = scnprintf(buf, sizeof(buf), "Trace %s not available\n",
60+ trace->name);
61+ va = buf;
62+ } else {
63+ len = strnlen(va, trace->len);
64+ }
65+
66+ return simple_read_from_buffer(userbuf, count, ppos, va, len);
5467 }
5568
5669 static const struct file_operations trace_rproc_ops = {
@@ -155,6 +168,30 @@ static const struct file_operations rproc_recovery_ops = { · 98 unmodified lines
155168 .llseek = generic_file_llseek,
156169 };
157170
171+/* expose the crash trigger via debugfs */
172+static ssize_t
173+rproc_crash_write(struct file *filp, const char __user *user_buf,
174+ size_t count, loff_t *ppos)
175+{
176+ struct rproc *rproc = filp->private_data;
177+ unsigned int type;
178+ int ret;
179+
180+ ret = kstrtouint_from_user(user_buf, count, 0, &type);
181+ if (ret < 0)
182+ return ret;
183+
184+ rproc_report_crash(rproc, type);
185+
186+ return count;
187+}
188+
189+static const struct file_operations rproc_crash_ops = {
190+ .write = rproc_crash_write,
191+ .open = simple_open,
192+ .llseek = generic_file_llseek,
193+};
194+
158195 /* Expose resource table content via debugfs */
159196 static int rproc_rsc_table_show(struct seq_file *seq, void *p)
160197 {
@@ -288,7 +325,7 @@ void rproc_remove_trace_file(struct dentry *tfile) · 127 unmodified lines
288325 }
289326
290327 struct dentry *rproc_create_trace_file(const char *name, struct rproc *rproc,
291− struct rproc_mem_entry *trace)
328+ struct rproc_debug_trace *trace)
292329 {
293330 struct dentry *tfile;
294331
@@ -325,6 +362,8 @@ void rproc_create_debug_dir(struct rproc *rproc) · 30 unmodified lines
325362 rproc, &rproc_name_ops);
326363 debugfs_create_file("recovery", 0400, rproc->dbg_dir,
327364 rproc, &rproc_recovery_ops);
365+ debugfs_create_file("crash", 0200, rproc->dbg_dir,
366+ rproc, &rproc_crash_ops);
328367 debugfs_create_file("resource_table", 0400, rproc->dbg_dir,
329368 rproc, &rproc_rsc_table_ops);
330369 debugfs_create_file("carveout_memories", 0400, rproc->dbg_dir,
drivers/remoteproc/remoteproc_internal.h+10−2
@@ -25,6 +25,13 @@ · 24 unmodified lines
2525
2626 struct rproc;
2727
28+struct rproc_debug_trace {
29+ struct rproc *rproc;
30+ struct dentry *tfile;
31+ struct list_head node;
32+ struct rproc_mem_entry trace_mem;
33+};
34+
2835 /* from remoteproc_core.c */
2936 void rproc_release(struct kref *kref);
3037 irqreturn_t rproc_vq_interrupt(struct rproc *rproc, int vq_id);
@@ -32,12 +39,12 @@ void rproc_vdev_release(struct kref *ref); · 1 unmodified line
3239
3340 /* from remoteproc_virtio.c */
3441 int rproc_add_virtio_dev(struct rproc_vdev *rvdev, int id);
35−void rproc_remove_virtio_dev(struct rproc_vdev *rvdev);
42+int rproc_remove_virtio_dev(struct device *dev, void *data);
3643
3744 /* from remoteproc_debugfs.c */
3845 void rproc_remove_trace_file(struct dentry *tfile);
3946 struct dentry *rproc_create_trace_file(const char *name, struct rproc *rproc,
40− struct rproc_mem_entry *trace);
47+ struct rproc_debug_trace *trace);
4148 void rproc_delete_debug_dir(struct rproc *rproc);
4249 void rproc_create_debug_dir(struct rproc *rproc);
4350 void rproc_init_debugfs(void);
@@ -52,6 +59,7 @@ void rproc_free_vring(struct rproc_vring *rvring); · 8 unmodified lines
5259 int rproc_alloc_vring(struct rproc_vdev *rvdev, int i);
5360
5461 void *rproc_da_to_va(struct rproc *rproc, u64 da, int len);
62+phys_addr_t rproc_va_to_pa(void *cpu_addr);
5563 int rproc_trigger_recovery(struct rproc *rproc);
5664
5765 int rproc_elf_sanity_check(struct rproc *rproc, const struct firmware *fw);
drivers/remoteproc/remoteproc_virtio.c+56−5
@@ -17,7 +17,9 @@ · 16 unmodified lines
1717 * GNU General Public License for more details.
1818 */
1919
20+#include <linux/dma-mapping.h>
2021 #include <linux/export.h>
22+#include <linux/of_reserved_mem.h>
2123 #include <linux/remoteproc.h>
2224 #include <linux/virtio.h>
2325 #include <linux/virtio_config.h>
@@ -316,6 +318,8 @@ static void rproc_virtio_dev_release(struct device *dev) · 292 unmodified lines
316318 struct rproc_vdev *rvdev = vdev_to_rvdev(vdev);
317319 struct rproc *rproc = vdev_to_rproc(vdev);
318320
321+ kfree(vdev);
322+
319323 kref_put(&rvdev->refcount, rproc_vdev_release);
320324
321325 put_device(&rproc->dev);
@@ -333,10 +337,53 @@ static void rproc_virtio_dev_release(struct device *dev) · 11 unmodified lines
333337 int rproc_add_virtio_dev(struct rproc_vdev *rvdev, int id)
334338 {
335339 struct rproc *rproc = rvdev->rproc;
336− struct device *dev = &rproc->dev;
337− struct virtio_device *vdev = &rvdev->vdev;
340+ struct device *dev = &rvdev->dev;
341+ struct virtio_device *vdev;
342+ struct rproc_mem_entry *mem;
338343 int ret;
339344
345+ /* Try to find dedicated vdev buffer carveout */
346+ mem = rproc_find_carveout_by_name(rproc, "vdev%dbuffer", rvdev->index);
347+ if (mem) {
348+ phys_addr_t pa;
349+
350+ if (mem->of_resm_idx != -1) {
351+ struct device_node *np = rproc->dev.parent->of_node;
352+
353+ /* Associate reserved memory to vdev device */
354+ ret = of_reserved_mem_device_init_by_idx(dev, np,
355+ mem->of_resm_idx);
356+ if (ret) {
357+ dev_err(dev, "Can't associate reserved memory\n");
358+ goto out;
359+ }
360+ } else {
361+ if (mem->va) {
362+ dev_warn(dev, "vdev %d buffer already mapped\n",
363+ rvdev->index);
364+ pa = rproc_va_to_pa(mem->va);
365+ } else {
366+ /* Use dma address as carveout no memmapped yet */
367+ pa = (phys_addr_t)mem->dma;
368+ }
369+
370+ /* Associate vdev buffer memory pool to vdev subdev */
371+ ret = dma_declare_coherent_memory(dev, pa,
372+ mem->da,
373+ mem->len);
374+ if (ret < 0) {
375+ dev_err(dev, "Failed to associate buffer\n");
376+ goto out;
377+ }
378+ }
379+ }
380+
381+ /* Allocate virtio device */
382+ vdev = kzalloc(sizeof(*vdev), GFP_KERNEL);
383+ if (!vdev) {
384+ ret = -ENOMEM;
385+ goto out;
386+ }
340387 vdev->id.device = id,
341388 vdev->config = &rproc_virtio_config_ops,
342389 vdev->dev.parent = dev;
@@ -370,11 +417,15 @@ out: · 27 unmodified lines
370417
371418 /**
372419 * rproc_remove_virtio_dev() - remove an rproc-induced virtio device
373− * @rvdev: the remote vdev
420+ * @dev: the virtio device
421+ * @data: must be null
374422 *
375423 * This function unregisters an existing virtio device.
376424 */
377−void rproc_remove_virtio_dev(struct rproc_vdev *rvdev)
425+int rproc_remove_virtio_dev(struct device *dev, void *data)
378426 {
379− unregister_virtio_device(&rvdev->vdev);
427+ struct virtio_device *vdev = dev_to_virtio(dev);
428+
429+ unregister_virtio_device(vdev);
430+ return 0;
380431 }
drivers/remoteproc/st_remoteproc.c+80−11
@@ -19,6 +19,7 @@ · 18 unmodified lines
1919 #include <linux/mfd/syscon.h>
2020 #include <linux/module.h>
2121 #include <linux/of.h>
22+#include <linux/of_address.h>
2223 #include <linux/of_device.h>
2324 #include <linux/of_reserved_mem.h>
2425 #include <linux/platform_device.h>
@@ -91,6 +92,77 @@ static void st_rproc_kick(struct rproc *rproc, int vqid) · 66 unmodified lines
9192 dev_err(dev, "failed to send message via mbox: %d\n", ret);
9293 }
9394
95+static int st_rproc_mem_alloc(struct rproc *rproc,
96+ struct rproc_mem_entry *mem)
97+{
98+ struct device *dev = rproc->dev.parent;
99+ void *va;
100+
101+ va = ioremap_wc(mem->dma, mem->len);
102+ if (!va) {
103+ dev_err(dev, "Unable to map memory region: %pa+%zx\n",
104+ &mem->dma, mem->len);
105+ return -ENOMEM;
106+ }
107+
108+ /* Update memory entry va */
109+ mem->va = va;
110+
111+ return 0;
112+}
113+
114+static int st_rproc_mem_release(struct rproc *rproc,
115+ struct rproc_mem_entry *mem)
116+{
117+ iounmap(mem->va);
118+
119+ return 0;
120+}
121+
122+static int st_rproc_parse_fw(struct rproc *rproc, const struct firmware *fw)
123+{
124+ struct device *dev = rproc->dev.parent;
125+ struct device_node *np = dev->of_node;
126+ struct rproc_mem_entry *mem;
127+ struct reserved_mem *rmem;
128+ struct of_phandle_iterator it;
129+ int index = 0;
130+
131+ of_phandle_iterator_init(&it, np, "memory-region", NULL, 0);
132+ while (of_phandle_iterator_next(&it) == 0) {
133+ rmem = of_reserved_mem_lookup(it.node);
134+ if (!rmem) {
135+ dev_err(dev, "unable to acquire memory-region\n");
136+ return -EINVAL;
137+ }
138+
139+ /* No need to map vdev buffer */
140+ if (strcmp(it.node->name, "vdev0buffer")) {
141+ /* Register memory region */
142+ mem = rproc_mem_entry_init(dev, NULL,
143+ (dma_addr_t)rmem->base,
144+ rmem->size, rmem->base,
145+ st_rproc_mem_alloc,
146+ st_rproc_mem_release,
147+ it.node->name);
148+ } else {
149+ /* Register reserved memory for vdev buffer allocation */
150+ mem = rproc_of_resm_mem_entry_init(dev, index,
151+ rmem->size,
152+ rmem->base,
153+ it.node->name);
154+ }
155+
156+ if (!mem)
157+ return -ENOMEM;
158+
159+ rproc_add_carveout(rproc, mem);
160+ index++;
161+ }
162+
163+ return rproc_elf_load_rsc_table(rproc, fw);
164+}
165+
94166 static int st_rproc_start(struct rproc *rproc)
95167 {
96168 struct st_rproc *ddata = rproc->priv;
@@ -158,9 +230,14 @@ static int st_rproc_stop(struct rproc *rproc) · 61 unmodified lines
158230 }
159231
160232 static const struct rproc_ops st_rproc_ops = {
161− .kick = st_rproc_kick,
162− .start = st_rproc_start,
163− .stop = st_rproc_stop,
233+ .kick = st_rproc_kick,
234+ .start = st_rproc_start,
235+ .stop = st_rproc_stop,
236+ .parse_fw = st_rproc_parse_fw,
237+ .load = rproc_elf_load_segments,
238+ .find_loaded_rsc_table = rproc_elf_find_loaded_rsc_table,
239+ .sanity_check = rproc_elf_sanity_check,
240+ .get_boot_addr = rproc_elf_get_boot_addr,
164241 };
165242
166243 /*
@@ -254,12 +331,6 @@ static int st_rproc_parse_dt(struct platform_device *pdev) · 87 unmodified lines
254331 return -EINVAL;
255332 }
256333
257− err = of_reserved_mem_device_init(dev);
258− if (err) {
259− dev_err(dev, "Failed to obtain shared memory\n");
260− return err;
261− }
262−
263334 err = clk_prepare(ddata->clk);
264335 if (err)
265336 dev_err(dev, "failed to get clock\n");
@@ -387,8 +458,6 @@ static int st_rproc_remove(struct platform_device *pdev) · 121 unmodified lines
387458
388459 clk_disable_unprepare(ddata->clk);
389460
390− of_reserved_mem_device_release(&pdev->dev);
391−
392461 for (i = 0; i < ST_RPROC_MAX_VRING * MBOX_MAX; i++)
393462 mbox_free_channel(ddata->mbox_chan[i]);
394463
drivers/rpmsg/virtio_rpmsg_bus.c+12−12
@@ -11,21 +11,21 @@ · 10 unmodified lines
1111
1212 #define pr_fmt(fmt) "%s: " fmt, __func__
1313
14+#include <linux/dma-mapping.h>
15+#include <linux/idr.h>
16+#include <linux/jiffies.h>
1417 #include <linux/kernel.h>
1518 #include <linux/module.h>
16−#include <linux/virtio.h>
17−#include <linux/virtio_ids.h>
18−#include <linux/virtio_config.h>
19+#include <linux/mutex.h>
20+#include <linux/of_device.h>
21+#include <linux/rpmsg.h>
1922 #include <linux/scatterlist.h>
20−#include <linux/dma-mapping.h>
2123 #include <linux/slab.h>
22−#include <linux/idr.h>
23−#include <linux/jiffies.h>
2424 #include <linux/sched.h>
25+#include <linux/virtio.h>
26+#include <linux/virtio_ids.h>
27+#include <linux/virtio_config.h>
2528 #include <linux/wait.h>
26−#include <linux/rpmsg.h>
27−#include <linux/mutex.h>
28−#include <linux/of_device.h>
2929
3030 #include "rpmsg_internal.h"
3131
@@ -912,7 +912,7 @@ static int rpmsg_probe(struct virtio_device *vdev) · 880 unmodified lines
912912 total_buf_space = vrp->num_bufs * vrp->buf_size;
913913
914914 /* allocate coherent memory for the buffers */
915− bufs_va = dma_alloc_coherent(vdev->dev.parent->parent,
915+ bufs_va = dma_alloc_coherent(vdev->dev.parent,
916916 total_buf_space, &vrp->bufs_dma,
917917 GFP_KERNEL);
918918 if (!bufs_va) {
@@ -980,7 +980,7 @@ static int rpmsg_probe(struct virtio_device *vdev) · 61 unmodified lines
980980 return 0;
981981
982982 free_coherent:
983− dma_free_coherent(vdev->dev.parent->parent, total_buf_space,
983+ dma_free_coherent(vdev->dev.parent, total_buf_space,
984984 bufs_va, vrp->bufs_dma);
985985 vqs_del:
986986 vdev->config->del_vqs(vrp->vdev);
@@ -1015,7 +1015,7 @@ static void rpmsg_remove(struct virtio_device *vdev) · 28 unmodified lines
10151015
10161016 vdev->config->del_vqs(vrp->vdev);
10171017
1018− dma_free_coherent(vdev->dev.parent->parent, total_buf_space,
1018+ dma_free_coherent(vdev->dev.parent, total_buf_space,
10191019 vrp->rbufs, vrp->bufs_dma);
10201020
10211021 kfree(vrp);
include/linux/remoteproc.h+4−4
@@ -345,9 +345,9 @@ struct firmware; · 344 unmodified lines
345345 * @stop: power off the device
346346 * @kick: kick a virtqueue (virtqueue id given as a parameter)
347347 * @da_to_va: optional platform hook to perform address translations
348− * @load_rsc_table: load resource table from firmware image
348+ * @parse_fw: parse firmware to extract information (e.g. resource table)
349349 * @find_loaded_rsc_table: find the loaded resouce table
350− * @load: load firmeware to memory, where the remote processor
350+ * @load: load firmware to memory, where the remote processor
351351 * expects to find it
352352 * @sanity_check: sanity check the fw image
353353 * @get_boot_addr: get boot address to entry point specified in firmware
@@ -554,11 +554,11 @@ struct rproc_vdev { · 200 unmodified lines
554554 struct kref refcount;
555555
556556 struct rproc_subdev subdev;
557+ struct device dev;
557558
558559 unsigned int id;
559560 struct list_head node;
560561 struct rproc *rproc;
561− struct virtio_device vdev;
562562 struct rproc_vring vring[RVDEV_NUM_VRINGS];
563563 u32 rsc_offset;
564564 u32 index;
@@ -601,7 +601,7 @@ int rproc_coredump_add_custom_segment(struct rproc *rproc, · 36 unmodified lines
601601
602602 static inline struct rproc_vdev *vdev_to_rvdev(struct virtio_device *vdev)
603603 {
604− return container_of(vdev, struct rproc_vdev, vdev);
604+ return container_of(vdev->dev.parent, struct rproc_vdev, dev);
605605 }
606606
607607 static inline struct rproc *vdev_to_rproc(struct virtio_device *vdev)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t