From patchwork Tue Nov 20 21:02:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sibi Sankar X-Patchwork-Id: 10691213 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C7D1317FE for ; Tue, 20 Nov 2018 21:02:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B8E542AE34 for ; Tue, 20 Nov 2018 21:02:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AD3D82AE54; Tue, 20 Nov 2018 21:02:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 57F062AE66 for ; Tue, 20 Nov 2018 21:02:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727355AbeKUHd2 (ORCPT ); Wed, 21 Nov 2018 02:33:28 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:57168 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725957AbeKUHd2 (ORCPT ); Wed, 21 Nov 2018 02:33:28 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 7797F60A98; Tue, 20 Nov 2018 21:02:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1542747743; bh=vpCe+qDKmHLQstiaQD+RyJ0UqS515TxF5XvadJurUnA=; h=From:To:Cc:Subject:Date:From; b=H727aQIDK31KEvAw5D9gTMCCfKxKC0H1lEN8FfkNqV/agUpfgkHkurgLIRioFVw0y bfiqLat9d5eEXe9A1I1N+PA6d3o5G2WeHahVI0Apa9juWKmPnDnN2O8MwC1WUTaal/ r9MUeyrhfzHmLdXvzO7LnE9laXJjfRnCCpcV1MOI= Received: from blr-ubuntu-87.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.18.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sibis@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 475CA60452; Tue, 20 Nov 2018 21:02:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1542747743; bh=vpCe+qDKmHLQstiaQD+RyJ0UqS515TxF5XvadJurUnA=; h=From:To:Cc:Subject:Date:From; b=H727aQIDK31KEvAw5D9gTMCCfKxKC0H1lEN8FfkNqV/agUpfgkHkurgLIRioFVw0y bfiqLat9d5eEXe9A1I1N+PA6d3o5G2WeHahVI0Apa9juWKmPnDnN2O8MwC1WUTaal/ r9MUeyrhfzHmLdXvzO7LnE9laXJjfRnCCpcV1MOI= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 475CA60452 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=sibis@codeaurora.org From: Sibi Sankar To: bjorn.andersson@linaro.org, robh+dt@kernel.org, andy.gross@linaro.org, david.brown@linaro.org Cc: linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, tsoni@codeaurora.org, clew@codeaurora.org, akdwived@codeaurora.org, ohad@wizery.com, mark.rutland@arm.com, linux-remoteproc@vger.kernel.org, Sibi Sankar Subject: [PATCH 1/2] dt-bindings: remoteproc: qcom: Add shutdown-ack irq for Q6v5 Date: Wed, 21 Nov 2018 02:32:07 +0530 Message-Id: <20181120210209.9029-1-sibis@codeaurora.org> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add optional shutdown-irq binding required for sysmon shutdown on SDM845/MSM8996/QCS404 SoCs. Signed-off-by: Sibi Sankar Reviewed-by: Rob Herring --- Documentation/devicetree/bindings/remoteproc/qcom,q6v5.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/remoteproc/qcom,q6v5.txt b/Documentation/devicetree/bindings/remoteproc/qcom,q6v5.txt index 9ff5b0309417..14947562bc67 100644 --- a/Documentation/devicetree/bindings/remoteproc/qcom,q6v5.txt +++ b/Documentation/devicetree/bindings/remoteproc/qcom,q6v5.txt @@ -29,12 +29,13 @@ on the Qualcomm Hexagon core. Usage: required Value type: Definition: must list the watchdog, fatal IRQs ready, handover and - stop-ack IRQs + stop-ack IRQs and may optionally list shutdown-ack IRQ - interrupt-names: Usage: required Value type: - Definition: must be "wdog", "fatal", "ready", "handover", "stop-ack" + Definition: must be "wdog", "fatal", "ready", "handover", "stop-ack", + "shutdown-ack" - clocks: Usage: required From patchwork Tue Nov 20 21:02:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sibi Sankar X-Patchwork-Id: 10691211 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0935F1869 for ; Tue, 20 Nov 2018 21:02:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB3DE2AC1E for ; Tue, 20 Nov 2018 21:02:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DF7802AE92; Tue, 20 Nov 2018 21:02:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A6532AE9B for ; Tue, 20 Nov 2018 21:02:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727501AbeKUHdg (ORCPT ); Wed, 21 Nov 2018 02:33:36 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:58586 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725957AbeKUHdg (ORCPT ); Wed, 21 Nov 2018 02:33:36 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 1171F61330; Tue, 20 Nov 2018 21:02:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1542747750; bh=z9iISowz0UE7V4J9mu66FmJX13ikLoZKIGWsV2hTo2g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lVJtaYc4De0FyJZuvBIg3jBZoU50M80pezjzprqygoxRcEQPnku2hwv+2R5tmfWa1 le034WIpm93xDFDhqxJBS64fCy7wgNDX3XzlsMYzQHX/K04WavAqN3AAQi5/JsZ3+x FWZqj68NCrsjCRwizjXaGSJevlGR4F2S6P+IxOWo= Received: from blr-ubuntu-87.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.18.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sibis@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 2FA6660C8B; Tue, 20 Nov 2018 21:02:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1542747749; bh=z9iISowz0UE7V4J9mu66FmJX13ikLoZKIGWsV2hTo2g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lGYBs8ydxJEohpej9NCbB+M62hk5VuRR7CF9eo/Oy/sYuwo4S5CicqCQNbb8JW225 6Rd0kOAKz6M4pOtbRE5aR4LIATdDUy/uPpii1413b5LnHHbHvBJSzGryNsVQvWf1AD Mcu0YHCiB9jC+zn0VmqI0f/BMqpigwuVGC9wgfQ8= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 2FA6660C8B Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=sibis@codeaurora.org From: Sibi Sankar To: bjorn.andersson@linaro.org, robh+dt@kernel.org, andy.gross@linaro.org, david.brown@linaro.org Cc: linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, tsoni@codeaurora.org, clew@codeaurora.org, akdwived@codeaurora.org, ohad@wizery.com, mark.rutland@arm.com, linux-remoteproc@vger.kernel.org, Sibi Sankar Subject: [PATCH 2/2] remoteproc: sysmon: Wait for shutdown-ack/ind on sysmon shutdown Date: Wed, 21 Nov 2018 02:32:08 +0530 Message-Id: <20181120210209.9029-2-sibis@codeaurora.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181120210209.9029-1-sibis@codeaurora.org> References: <20181120210209.9029-1-sibis@codeaurora.org> MIME-Version: 1.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP After sending a sysmon shutdown request to the SSCTL service on the subsystem, wait for the service to send shutdown-ack interrupt or an indication message back. Signed-off-by: Sibi Sankar --- drivers/remoteproc/qcom_sysmon.c | 59 +++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/drivers/remoteproc/qcom_sysmon.c b/drivers/remoteproc/qcom_sysmon.c index e976a602b015..a545181341d1 100644 --- a/drivers/remoteproc/qcom_sysmon.c +++ b/drivers/remoteproc/qcom_sysmon.c @@ -3,6 +3,7 @@ * Copyright (c) 2017, Linaro Ltd. */ #include +#include #include #include #include @@ -25,6 +26,7 @@ struct qcom_sysmon { const char *name; + int shutdown_irq; int ssctl_version; int ssctl_instance; @@ -34,6 +36,7 @@ struct qcom_sysmon { struct rpmsg_endpoint *ept; struct completion comp; + struct completion shutdown_comp; struct mutex lock; bool ssr_ack; @@ -137,6 +140,7 @@ static int sysmon_callback(struct rpmsg_device *rpdev, void *data, int count, } #define SSCTL_SHUTDOWN_REQ 0x21 +#define SSCTL_SHUTDOWN_READY_IND 0x21 #define SSCTL_SUBSYS_EVENT_REQ 0x23 #define SSCTL_MAX_MSG_LEN 7 @@ -252,6 +256,29 @@ static struct qmi_elem_info ssctl_subsys_event_resp_ei[] = { {} }; +static struct qmi_elem_info ssctl_shutdown_ind_ei[] = { + {} +}; + +static void sysmon_ind_cb(struct qmi_handle *qmi, struct sockaddr_qrtr *sq, + struct qmi_txn *txn, const void *data) +{ + struct qcom_sysmon *sysmon = container_of(qmi, struct qcom_sysmon, qmi); + + complete(&sysmon->shutdown_comp); +} + +static struct qmi_msg_handler qmi_indication_handler[] = { + { + .type = QMI_INDICATION, + .msg_id = SSCTL_SHUTDOWN_READY_IND, + .ei = ssctl_shutdown_ind_ei, + .decoded_size = 0, + .fn = sysmon_ind_cb + }, + {} +}; + /** * ssctl_request_shutdown() - request shutdown via SSCTL QMI service * @sysmon: sysmon context @@ -262,6 +289,7 @@ static void ssctl_request_shutdown(struct qcom_sysmon *sysmon) struct qmi_txn txn; int ret; + reinit_completion(&sysmon->shutdown_comp); ret = qmi_txn_init(&sysmon->qmi, &txn, ssctl_shutdown_resp_ei, &resp); if (ret < 0) { dev_err(sysmon->dev, "failed to allocate QMI txn\n"); @@ -283,6 +311,14 @@ static void ssctl_request_shutdown(struct qcom_sysmon *sysmon) dev_err(sysmon->dev, "shutdown request failed\n"); else dev_dbg(sysmon->dev, "shutdown request completed\n"); + + if (sysmon->shutdown_irq > 0) { + ret = wait_for_completion_timeout(&sysmon->shutdown_comp, + msecs_to_jiffies(5000)); + if (!ret) + dev_err(sysmon->dev, + "timeout waiting for shutdown ack\n"); + } } /** @@ -432,6 +468,15 @@ static int sysmon_notify(struct notifier_block *nb, unsigned long event, return NOTIFY_DONE; } +static irqreturn_t sysmon_shutdown_interrupt(int irq, void *data) +{ + struct qcom_sysmon *sysmon = data; + + complete(&sysmon->shutdown_comp); + + return IRQ_HANDLED; +} + /** * qcom_add_sysmon_subdev() - create a sysmon subdev for the given remoteproc * @rproc: rproc context to associate the subdev with @@ -445,6 +490,7 @@ struct qcom_sysmon *qcom_add_sysmon_subdev(struct rproc *rproc, int ssctl_instance) { struct qcom_sysmon *sysmon; + struct platform_device *pdev; int ret; sysmon = kzalloc(sizeof(*sysmon), GFP_KERNEL); @@ -453,14 +499,25 @@ struct qcom_sysmon *qcom_add_sysmon_subdev(struct rproc *rproc, sysmon->dev = rproc->dev.parent; sysmon->rproc = rproc; + pdev = container_of(sysmon->dev, struct platform_device, dev); sysmon->name = name; sysmon->ssctl_instance = ssctl_instance; init_completion(&sysmon->comp); + init_completion(&sysmon->shutdown_comp); mutex_init(&sysmon->lock); - ret = qmi_handle_init(&sysmon->qmi, SSCTL_MAX_MSG_LEN, &ssctl_ops, NULL); + sysmon->shutdown_irq = platform_get_irq_byname(pdev, "shutdown-ack"); + ret = devm_request_threaded_irq(sysmon->dev, sysmon->shutdown_irq, + NULL, sysmon_shutdown_interrupt, + IRQF_TRIGGER_RISING | IRQF_ONESHOT, + "q6v5 shutdown-ack", sysmon); + if (ret) + dev_err(sysmon->dev, "failed to acquire shutdown-ack IRQ\n"); + + ret = qmi_handle_init(&sysmon->qmi, SSCTL_MAX_MSG_LEN, &ssctl_ops, + qmi_indication_handler); if (ret < 0) { dev_err(sysmon->dev, "failed to initialize qmi handle\n"); kfree(sysmon);