Lines Matching +full:stop +full:- +full:ack
1 // SPDX-License-Identifier: GPL-2.0
5 * Copyright (C) 2016-2018 Linaro Ltd.
7 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
28 if (!q6v5->qmp) in q6v5_load_state_toggle()
31 ret = qmp_send(q6v5->qmp, "{class: image, res: load_state, name: %s, val: %s}", in q6v5_load_state_toggle()
32 q6v5->load_state, enable ? "on" : "off"); in q6v5_load_state_toggle()
34 dev_err(q6v5->dev, "failed to toggle load state\n"); in q6v5_load_state_toggle()
40 * qcom_q6v5_prepare() - reinitialize the qcom_q6v5 context before start
49 ret = icc_set_bw(q6v5->path, 0, UINT_MAX); in qcom_q6v5_prepare()
51 dev_err(q6v5->dev, "failed to set bandwidth request\n"); in qcom_q6v5_prepare()
57 icc_set_bw(q6v5->path, 0, 0); in qcom_q6v5_prepare()
61 reinit_completion(&q6v5->start_done); in qcom_q6v5_prepare()
62 reinit_completion(&q6v5->stop_done); in qcom_q6v5_prepare()
64 q6v5->running = true; in qcom_q6v5_prepare()
65 q6v5->handover_issued = false; in qcom_q6v5_prepare()
67 enable_irq(q6v5->handover_irq); in qcom_q6v5_prepare()
74 * qcom_q6v5_unprepare() - unprepare the qcom_q6v5 context after stop
81 disable_irq(q6v5->handover_irq); in qcom_q6v5_unprepare()
85 icc_set_bw(q6v5->path, 0, 0); in qcom_q6v5_unprepare()
87 return !q6v5->handover_issued; in qcom_q6v5_unprepare()
97 /* Sometimes the stop triggers a watchdog rather than a stop-ack */ in q6v5_wdog_interrupt()
98 if (!q6v5->running) { in q6v5_wdog_interrupt()
99 complete(&q6v5->stop_done); in q6v5_wdog_interrupt()
103 msg = qcom_smem_get(QCOM_SMEM_HOST_ANY, q6v5->crash_reason, &len); in q6v5_wdog_interrupt()
105 dev_err(q6v5->dev, "watchdog received: %s\n", msg); in q6v5_wdog_interrupt()
107 dev_err(q6v5->dev, "watchdog without message\n"); in q6v5_wdog_interrupt()
109 q6v5->running = false; in q6v5_wdog_interrupt()
110 rproc_report_crash(q6v5->rproc, RPROC_WATCHDOG); in q6v5_wdog_interrupt()
121 if (!q6v5->running) in q6v5_fatal_interrupt()
124 msg = qcom_smem_get(QCOM_SMEM_HOST_ANY, q6v5->crash_reason, &len); in q6v5_fatal_interrupt()
126 dev_err(q6v5->dev, "fatal error received: %s\n", msg); in q6v5_fatal_interrupt()
128 dev_err(q6v5->dev, "fatal error without message\n"); in q6v5_fatal_interrupt()
130 q6v5->running = false; in q6v5_fatal_interrupt()
131 rproc_report_crash(q6v5->rproc, RPROC_FATAL_ERROR); in q6v5_fatal_interrupt()
140 complete(&q6v5->start_done); in q6v5_ready_interrupt()
146 * qcom_q6v5_wait_for_start() - wait for remote processor start signal
152 * Return: 0 on success, -ETIMEDOUT on timeout
158 ret = wait_for_completion_timeout(&q6v5->start_done, timeout); in qcom_q6v5_wait_for_start()
160 disable_irq(q6v5->handover_irq); in qcom_q6v5_wait_for_start()
162 return !ret ? -ETIMEDOUT : 0; in qcom_q6v5_wait_for_start()
170 if (q6v5->handover) in q6v5_handover_interrupt()
171 q6v5->handover(q6v5); in q6v5_handover_interrupt()
173 icc_set_bw(q6v5->path, 0, 0); in q6v5_handover_interrupt()
175 q6v5->handover_issued = true; in q6v5_handover_interrupt()
184 complete(&q6v5->stop_done); in q6v5_stop_interrupt()
190 * qcom_q6v5_request_stop() - request the remote processor to stop
200 q6v5->running = false; in qcom_q6v5_request_stop()
203 if (q6v5->rproc->state != RPROC_RUNNING || qcom_sysmon_shutdown_acked(sysmon)) in qcom_q6v5_request_stop()
206 qcom_smem_state_update_bits(q6v5->state, in qcom_q6v5_request_stop()
207 BIT(q6v5->stop_bit), BIT(q6v5->stop_bit)); in qcom_q6v5_request_stop()
209 ret = wait_for_completion_timeout(&q6v5->stop_done, 5 * HZ); in qcom_q6v5_request_stop()
211 qcom_smem_state_update_bits(q6v5->state, BIT(q6v5->stop_bit), 0); in qcom_q6v5_request_stop()
213 return ret == 0 ? -ETIMEDOUT : 0; in qcom_q6v5_request_stop()
218 * qcom_q6v5_panic() - panic handler to invoke a stop on the remote
221 * Set the stop bit and sleep in order to allow the remote processor to flush
228 qcom_smem_state_update_bits(q6v5->state, in qcom_q6v5_panic()
229 BIT(q6v5->stop_bit), BIT(q6v5->stop_bit)); in qcom_q6v5_panic()
236 * qcom_q6v5_init() - initializer of the q6v5 common struct
252 q6v5->rproc = rproc; in qcom_q6v5_init()
253 q6v5->dev = &pdev->dev; in qcom_q6v5_init()
254 q6v5->crash_reason = crash_reason; in qcom_q6v5_init()
255 q6v5->handover = handover; in qcom_q6v5_init()
257 init_completion(&q6v5->start_done); in qcom_q6v5_init()
258 init_completion(&q6v5->stop_done); in qcom_q6v5_init()
260 q6v5->wdog_irq = platform_get_irq_byname(pdev, "wdog"); in qcom_q6v5_init()
261 if (q6v5->wdog_irq < 0) in qcom_q6v5_init()
262 return q6v5->wdog_irq; in qcom_q6v5_init()
264 ret = devm_request_threaded_irq(&pdev->dev, q6v5->wdog_irq, in qcom_q6v5_init()
269 dev_err(&pdev->dev, "failed to acquire wdog IRQ\n"); in qcom_q6v5_init()
273 q6v5->fatal_irq = platform_get_irq_byname(pdev, "fatal"); in qcom_q6v5_init()
274 if (q6v5->fatal_irq < 0) in qcom_q6v5_init()
275 return q6v5->fatal_irq; in qcom_q6v5_init()
277 ret = devm_request_threaded_irq(&pdev->dev, q6v5->fatal_irq, in qcom_q6v5_init()
282 dev_err(&pdev->dev, "failed to acquire fatal IRQ\n"); in qcom_q6v5_init()
286 q6v5->ready_irq = platform_get_irq_byname(pdev, "ready"); in qcom_q6v5_init()
287 if (q6v5->ready_irq < 0) in qcom_q6v5_init()
288 return q6v5->ready_irq; in qcom_q6v5_init()
290 ret = devm_request_threaded_irq(&pdev->dev, q6v5->ready_irq, in qcom_q6v5_init()
295 dev_err(&pdev->dev, "failed to acquire ready IRQ\n"); in qcom_q6v5_init()
299 q6v5->handover_irq = platform_get_irq_byname(pdev, "handover"); in qcom_q6v5_init()
300 if (q6v5->handover_irq < 0) in qcom_q6v5_init()
301 return q6v5->handover_irq; in qcom_q6v5_init()
303 ret = devm_request_threaded_irq(&pdev->dev, q6v5->handover_irq, in qcom_q6v5_init()
308 dev_err(&pdev->dev, "failed to acquire handover IRQ\n"); in qcom_q6v5_init()
311 disable_irq(q6v5->handover_irq); in qcom_q6v5_init()
313 q6v5->stop_irq = platform_get_irq_byname(pdev, "stop-ack"); in qcom_q6v5_init()
314 if (q6v5->stop_irq < 0) in qcom_q6v5_init()
315 return q6v5->stop_irq; in qcom_q6v5_init()
317 ret = devm_request_threaded_irq(&pdev->dev, q6v5->stop_irq, in qcom_q6v5_init()
320 "q6v5 stop", q6v5); in qcom_q6v5_init()
322 dev_err(&pdev->dev, "failed to acquire stop-ack IRQ\n"); in qcom_q6v5_init()
326 q6v5->state = devm_qcom_smem_state_get(&pdev->dev, "stop", &q6v5->stop_bit); in qcom_q6v5_init()
327 if (IS_ERR(q6v5->state)) { in qcom_q6v5_init()
328 dev_err(&pdev->dev, "failed to acquire stop state\n"); in qcom_q6v5_init()
329 return PTR_ERR(q6v5->state); in qcom_q6v5_init()
332 q6v5->load_state = devm_kstrdup_const(&pdev->dev, load_state, GFP_KERNEL); in qcom_q6v5_init()
333 q6v5->qmp = qmp_get(&pdev->dev); in qcom_q6v5_init()
334 if (IS_ERR(q6v5->qmp)) { in qcom_q6v5_init()
335 if (PTR_ERR(q6v5->qmp) != -ENODEV) in qcom_q6v5_init()
336 return dev_err_probe(&pdev->dev, PTR_ERR(q6v5->qmp), in qcom_q6v5_init()
338 q6v5->qmp = NULL; in qcom_q6v5_init()
339 } else if (!q6v5->load_state) { in qcom_q6v5_init()
341 dev_err(&pdev->dev, "load state resource string empty\n"); in qcom_q6v5_init()
343 qmp_put(q6v5->qmp); in qcom_q6v5_init()
344 return load_state ? -ENOMEM : -EINVAL; in qcom_q6v5_init()
347 q6v5->path = devm_of_icc_get(&pdev->dev, NULL); in qcom_q6v5_init()
348 if (IS_ERR(q6v5->path)) in qcom_q6v5_init()
349 return dev_err_probe(&pdev->dev, PTR_ERR(q6v5->path), in qcom_q6v5_init()
357 * qcom_q6v5_deinit() - deinitialize the q6v5 common struct
362 qmp_put(q6v5->qmp); in qcom_q6v5_deinit()