From patchwork Tue Jul 25 05:56:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 108615 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp179179qge; Mon, 24 Jul 2017 22:57:17 -0700 (PDT) X-Received: by 10.99.9.69 with SMTP id 66mr17995815pgj.178.1500962237060; Mon, 24 Jul 2017 22:57:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500962237; cv=none; d=google.com; s=arc-20160816; b=K9DUPeMI5rzhoz6m8sLL0s9pW+76CkrSkRz0pF67iQdIVtrY/efbLfNgk81qchdVmR QEnliJu12CslFPSKPlPL2irfQCuaC1c40VsstyewH//A6f3BWdwCojbIjmXyKhTh8Xct 1MqfwTLMO0OJe2YKIWYvGbZC5sRpfBzhuPzJQXoze0TKPVGKlryB+SYMOCihyVYwxao5 bBdw7uPKu5vqPGM/0tyZvZSnhSi7yon5vmJqoD9z+1z1vt3f1vTi4SKW6pBk5otMfAQe IHYG5AE4iKOMX4/uaDiASrY1xdp3efftkznJHlvGybrDEfiZC+eqZEmYthzFfvn9L5Ms pJ+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=HSnMMDSjQaaG7Ap05raEjRYMgato5Y3xLNb5ulmHdSo=; b=LnEOde8lCrT5mAIJb3GLX+KfYzTtPYhrJMqVrX8NQnefJp0t9lM/C0QxaS1+cKPOh7 cXLENRRVdJlaNJ1QkB6JSEKVSKvyzJl7GIhsynPc0vRsvsunUAM1NUuXqiH6OPPX5F7n j/XvY/L+3gj1u3DA+kiBRSqsMBUJUc9fV5qCt5KRgOP+5pbUNBXbgQcfFLcp/di8F8b/ 5wh1USAbQsp4qJsXn5bHj1uMbweZpqgnNDuqg6v1iuRNwQnpoY5pX6HAMbjD9N5y0A82 pgqoOZwzhkH1I+5Pd7MXVI8a7sNUg8F+jQeyQX6giqeEmAuoVGok8W/P5g68f3uvOrjY Jt0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=iN2Sb6g7; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z28si7573406pfi.507.2017.07.24.22.57.16; Mon, 24 Jul 2017 22:57:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=iN2Sb6g7; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751074AbdGYF5P (ORCPT + 10 others); Tue, 25 Jul 2017 01:57:15 -0400 Received: from mail-pf0-f173.google.com ([209.85.192.173]:35064 "EHLO mail-pf0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750802AbdGYF4u (ORCPT ); Tue, 25 Jul 2017 01:56:50 -0400 Received: by mail-pf0-f173.google.com with SMTP id h29so20056308pfd.2 for ; Mon, 24 Jul 2017 22:56:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vRSYt05sGGzMq0CmnDNecVEpI4y8holubXz21ptiU1Y=; b=iN2Sb6g73nlCNdcHG9KY44kMNtoXVM95Yzoxt+owh67l8RlbYLYs9UcqbXwnkEYzAk 2bV3CJzs9D+2CYPW9tHRG4Hw6Jwu+DhR+GG8bsvvuRTzJnSqOgntcQ/xnrCeszXfgzgN ybB2GXaAS6WEL+fMYnd1KItVbGVSbUO+gdnO8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vRSYt05sGGzMq0CmnDNecVEpI4y8holubXz21ptiU1Y=; b=pDUHpHXK6jQSRJFkbprvHWQF6M3IJL4dCJn+JvHQHVxLJ47XXZcnBoY1meUiiK8hiI MpKgEcIx2Mi/GblIZT1XkKjVaqmWUc6KLGJ16DFPkobk0kbF83AkyR3ffL7UpiqykFME ocGfh9vq7jBROTmgBScKbhAbmNJG1cu8tYh/pteTv29HJK3DG94TXQuLFFJRLCfDjwGc HnJoNYXYfadzRGFE7lT79zSIHrtRZ4LWWdD/S/S/ZYH8/0oRIIviUAz1xvzNAV1fGj/z joFw9Rxyt6Z8BqqIv0KUfJqaPU/F77lHrvrlIra+IUzASbtppMTGee8Mmkii6G2ZeI4Q gDQA== X-Gm-Message-State: AIVw112+y766SbOv1YTFKGVZBEnlQ7yAvCnKlFhnVKW1QHbWbA35E6II Y7kuy4OfzI9pFWAF X-Received: by 10.99.109.5 with SMTP id i5mr13654844pgc.440.1500962209633; Mon, 24 Jul 2017 22:56:49 -0700 (PDT) Received: from localhost.localdomain (ip68-111-217-79.sd.sd.cox.net. [68.111.217.79]) by smtp.gmail.com with ESMTPSA id a6sm25323438pfj.136.2017.07.24.22.56.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Jul 2017 22:56:49 -0700 (PDT) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson , Andy Gross Cc: David Brown , linux-kernel@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org Subject: [PATCH 1/2] remoteproc: qcom: Add support for SSR notifications Date: Mon, 24 Jul 2017 22:56:43 -0700 Message-Id: <20170725055644.20947-2-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170725055644.20947-1-bjorn.andersson@linaro.org> References: <20170725055644.20947-1-bjorn.andersson@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org This adds the remoteproc part of subsystem restart, which is responsible for emitting notifications to other processors in the system about a dying remoteproc instance. These notifications are propagated to the various communication systems in the various remote processors to shut down communication links that was left in a dangling state as the remoteproc was stopped (or crashed). Signed-off-by: Bjorn Andersson --- drivers/remoteproc/qcom_adsp_pil.c | 6 +++ drivers/remoteproc/qcom_common.c | 71 +++++++++++++++++++++++++++++++++++ drivers/remoteproc/qcom_common.h | 10 +++++ drivers/remoteproc/qcom_q6v5_pil.c | 3 ++ include/linux/remoteproc/qcom_rproc.h | 22 +++++++++++ 5 files changed, 112 insertions(+) create mode 100644 include/linux/remoteproc/qcom_rproc.h -- 2.12.0 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/remoteproc/qcom_adsp_pil.c b/drivers/remoteproc/qcom_adsp_pil.c index 49fe2f807e1d..a41d399766fd 100644 --- a/drivers/remoteproc/qcom_adsp_pil.c +++ b/drivers/remoteproc/qcom_adsp_pil.c @@ -38,6 +38,7 @@ struct adsp_data { const char *firmware_name; int pas_id; bool has_aggre2_clk; + const char *ssr_name; }; struct qcom_adsp { @@ -72,6 +73,7 @@ struct qcom_adsp { size_t mem_size; struct qcom_rproc_subdev smd_subdev; + struct qcom_rproc_ssr ssr_subdev; }; static int adsp_load(struct rproc *rproc, const struct firmware *fw) @@ -402,6 +404,7 @@ static int adsp_probe(struct platform_device *pdev) } qcom_add_smd_subdev(rproc, &adsp->smd_subdev); + qcom_add_ssr_subdev(rproc, &adsp->ssr_subdev, desc->ssr_name); ret = rproc_add(rproc); if (ret) @@ -423,6 +426,7 @@ static int adsp_remove(struct platform_device *pdev) rproc_del(adsp->rproc); qcom_remove_smd_subdev(adsp->rproc, &adsp->smd_subdev); + qcom_remove_ssr_subdev(adsp->rproc, &adsp->ssr_subdev); rproc_free(adsp->rproc); return 0; @@ -433,6 +437,7 @@ static const struct adsp_data adsp_resource_init = { .firmware_name = "adsp.mdt", .pas_id = 1, .has_aggre2_clk = false, + .ssr_name = "lpass", }; static const struct adsp_data slpi_resource_init = { @@ -440,6 +445,7 @@ static const struct adsp_data slpi_resource_init = { .firmware_name = "slpi.mdt", .pas_id = 12, .has_aggre2_clk = true, + .ssr_name = "dsps", }; static const struct of_device_id adsp_of_match[] = { diff --git a/drivers/remoteproc/qcom_common.c b/drivers/remoteproc/qcom_common.c index bb90481215c6..5556e767d65b 100644 --- a/drivers/remoteproc/qcom_common.c +++ b/drivers/remoteproc/qcom_common.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -25,6 +26,9 @@ #include "qcom_common.h" #define to_smd_subdev(d) container_of(d, struct qcom_rproc_subdev, subdev) +#define to_ssr_subdev(d) container_of(d, struct qcom_rproc_ssr, subdev) + +BLOCKING_NOTIFIER_HEAD(ssr_notifiers); /** * qcom_mdt_find_rsc_table() - provide dummy resource table for remoteproc @@ -92,5 +96,72 @@ void qcom_remove_smd_subdev(struct rproc *rproc, struct qcom_rproc_subdev *smd) } EXPORT_SYMBOL_GPL(qcom_remove_smd_subdev); +/** + * qcom_register_ssr_notifier() - register SSR notification handler + * @nb: notifier_block to notify for restart notifications + * + * Returns 0 on success, negative errno on failure. + * + * This register the @notify function as handler for restart notifications. As + * remote processors are stopped this function will be called, with the SSR + * name passed as a parameter. + */ +int qcom_register_ssr_notifier(struct notifier_block *nb) +{ + return blocking_notifier_chain_register(&ssr_notifiers, nb); +} +EXPORT_SYMBOL_GPL(qcom_register_ssr_notifier); + +/** + * qcom_unregister_ssr_notifier() - unregister SSR notification handler + * @nb: notifier_block to unregister + */ +void qcom_unregister_ssr_notifier(struct notifier_block *nb) +{ + blocking_notifier_chain_unregister(&ssr_notifiers, nb); +} +EXPORT_SYMBOL_GPL(qcom_unregister_ssr_notifier); + +static int ssr_notify_start(struct rproc_subdev *subdev) +{ + return 0; +} + +static void ssr_notify_stop(struct rproc_subdev *subdev) +{ + struct qcom_rproc_ssr *ssr = to_ssr_subdev(subdev); + + blocking_notifier_call_chain(&ssr_notifiers, 0, (void *)ssr->name); +} + +/** + * qcom_add_ssr_subdev() - register subdevice as restart notification source + * @rproc: rproc handle + * @ssr: SSR subdevice handle + * @ssr_name: identifier to use for notifications originating from @rproc + * + * As the @ssr is registered with the @rproc SSR events will be sent to all + * registered listeners in the system as the remoteproc is shut down. + */ +void qcom_add_ssr_subdev(struct rproc *rproc, struct qcom_rproc_ssr *ssr, + const char *ssr_name) +{ + ssr->name = ssr_name; + + rproc_add_subdev(rproc, &ssr->subdev, ssr_notify_start, ssr_notify_stop); +} +EXPORT_SYMBOL_GPL(qcom_add_ssr_subdev); + +/** + * qcom_remove_ssr_subdev() - remove subdevice as restart notification source + * @rproc: rproc handle + * @ssr: SSR subdevice handle + */ +void qcom_remove_ssr_subdev(struct rproc *rproc, struct qcom_rproc_ssr *ssr) +{ + rproc_remove_subdev(rproc, &ssr->subdev); +} +EXPORT_SYMBOL_GPL(qcom_remove_ssr_subdev); + MODULE_DESCRIPTION("Qualcomm Remoteproc helper driver"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/remoteproc/qcom_common.h b/drivers/remoteproc/qcom_common.h index db5c826d5cd4..fab28b64b8ea 100644 --- a/drivers/remoteproc/qcom_common.h +++ b/drivers/remoteproc/qcom_common.h @@ -12,6 +12,12 @@ struct qcom_rproc_subdev { struct qcom_smd_edge *edge; }; +struct qcom_rproc_ssr { + struct rproc_subdev subdev; + + const char *name; +}; + struct resource_table *qcom_mdt_find_rsc_table(struct rproc *rproc, const struct firmware *fw, int *tablesz); @@ -19,4 +25,8 @@ struct resource_table *qcom_mdt_find_rsc_table(struct rproc *rproc, void qcom_add_smd_subdev(struct rproc *rproc, struct qcom_rproc_subdev *smd); void qcom_remove_smd_subdev(struct rproc *rproc, struct qcom_rproc_subdev *smd); +void qcom_add_ssr_subdev(struct rproc *rproc, struct qcom_rproc_ssr *ssr, + const char *ssr_name); +void qcom_remove_ssr_subdev(struct rproc *rproc, struct qcom_rproc_ssr *ssr); + #endif diff --git a/drivers/remoteproc/qcom_q6v5_pil.c b/drivers/remoteproc/qcom_q6v5_pil.c index 8fd697a3cf8f..fc3ef1e81433 100644 --- a/drivers/remoteproc/qcom_q6v5_pil.c +++ b/drivers/remoteproc/qcom_q6v5_pil.c @@ -153,6 +153,7 @@ struct q6v5 { size_t mpss_size; struct qcom_rproc_subdev smd_subdev; + struct qcom_rproc_ssr ssr_subdev; }; static int q6v5_regulator_init(struct device *dev, struct reg_info *regs, @@ -1038,6 +1039,7 @@ static int q6v5_probe(struct platform_device *pdev) } qcom_add_smd_subdev(rproc, &qproc->smd_subdev); + qcom_add_ssr_subdev(rproc, &qproc->ssr_subdev, "mpss"); ret = rproc_add(rproc); if (ret) @@ -1058,6 +1060,7 @@ static int q6v5_remove(struct platform_device *pdev) rproc_del(qproc->rproc); qcom_remove_smd_subdev(qproc->rproc, &qproc->smd_subdev); + qcom_remove_ssr_subdev(qproc->rproc, &qproc->ssr_subdev); rproc_free(qproc->rproc); return 0; diff --git a/include/linux/remoteproc/qcom_rproc.h b/include/linux/remoteproc/qcom_rproc.h new file mode 100644 index 000000000000..fa8e38681b4b --- /dev/null +++ b/include/linux/remoteproc/qcom_rproc.h @@ -0,0 +1,22 @@ +#ifndef __QCOM_RPROC_H__ +#define __QCOM_RPROC_H__ + +struct notifier_block; + +#if IS_ENABLED(CONFIG_QCOM_RPROC_COMMON) + +int qcom_register_ssr_notifier(struct notifier_block *nb); +void qcom_unregister_ssr_notifier(struct notifier_block *nb); + +#else + +static inline int qcom_register_ssr_notifier(struct notifier_block *nb) +{ + return 0; +} + +static inline void qcom_unregister_ssr_notifier(struct notifier_block *nb) {} + +#endif + +#endif