Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp31649pxu; Sat, 21 Nov 2020 21:44:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJzKLwBrPA2CShBw9JMQirqP6iocGgH//96LKOPfuJr5zSaZFqnAMRF7FLt3+Pp9hQdXNBEA X-Received: by 2002:a17:906:4699:: with SMTP id a25mr37918442ejr.284.1606023864605; Sat, 21 Nov 2020 21:44:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606023864; cv=none; d=google.com; s=arc-20160816; b=cW8QgDV1cpkjCo/9CzP5nsfkPcSgPJxMgRcS/PWWNDix/gQOD1Vvvm/oxdyM/abWIh G29UFv8n9XRVwrSis32O8teR2m6XYTkXx7mUXp5D69MSZd48m83MYbN4Q10CHa1rsWeA U0nuZErcDafO34U9mnHxl0uvJUqDpadWqhCTrxB4J2AKR6m4BWTy4IWlbFtoCRhUttYN wAOi4/UrHI+1ZFOSEXW67CcnM5LhRwSd2qH0k9aaQrDWpdTmClOkRq4xK0ixS345IOcC z+fd9M3cdeZKIPldZoNtpZxaO8xyTFIAzKmgY+uUbT0p7AxqNzSIrHAkNap1F/Spg0j8 nhUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8Mu+dWZCO3tL9VhrtmkYCgByiYUNNJtCg8o7EBl4LbY=; b=MJ4rFtldojXcq+xVtE/qUSy2GXvFTFWTrI4bhi0xND2PiN44Em8PvvOAJ//nA+Sc0T s3A+FQFt/jloI3GQfZrJwDOw3sCiMgytqETpPO21tS1RM8woPeikZ2DOWU5ctkDrrIJh tCd/XoBDa5qGJ8vJR5R3MVqnlZEYM0T9ypJ1az9i0WW4OuMWj4SgfONwNfdN6qhoRvgY 0jV9rlmLMQ/1QE9xF7QUo6d/ECfGUZOIc+sPGWjZChyYeuq2e2hUp66lerPJ/fQ35u4C kZrh77ra3KSOoyInEOiGa6BBwvEzeVP8GSwCq453fpvh5eXaR/g/JVT11a84yJ56yzEH Bl9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Dw43r0cp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e24si748902ejh.235.2020.11.21.21.44.02; Sat, 21 Nov 2020 21:44:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Dw43r0cp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727391AbgKVFlk (ORCPT + 99 others); Sun, 22 Nov 2020 00:41:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727367AbgKVFli (ORCPT ); Sun, 22 Nov 2020 00:41:38 -0500 Received: from mail-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE59BC061A4C for ; Sat, 21 Nov 2020 21:41:36 -0800 (PST) Received: by mail-ot1-x344.google.com with SMTP id n11so12892584ota.2 for ; Sat, 21 Nov 2020 21:41:36 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=8Mu+dWZCO3tL9VhrtmkYCgByiYUNNJtCg8o7EBl4LbY=; b=Dw43r0cpkVNP4J6hIFwMxTkUOA20gaysCq4H+9QCOnXZSbp7ee/b7HZ5k6XHdg6TL3 8j9tw8ef9qwdjWzsYYEpo6XRpa5cpL+ekwgtNWGdKEIjRt9vtlh7s7576moo5iDUwl8m st1XacbCo2mD9HTFL0bh8fW6TGVcAYuxCZGwjkVHDEx66cC4Gj9jJtyfCq+xU1bU6yh0 bAsqlGVsZC5MFcZV4zgzLhco2l9t/1kLOTRGHBxZMcgj3cGuoVJ52de1rYWxEChEMQyp iCuuuJ3A1JsHDhqJvu/JT1jl0WD4eYpAS8bEXHuAdD6gSvf3Z3zPnvqk4X+GVuPAcZOE GLcg== 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:mime-version:content-transfer-encoding; bh=8Mu+dWZCO3tL9VhrtmkYCgByiYUNNJtCg8o7EBl4LbY=; b=fGKDKTqtJNt5Mbwsf+WpiSvqDTfStb0Yn9Jn5WxIevmEIfjwFlWyAnOa1Pnh9CVqzB uq377uhIE2C0v187VKdiGVZeuG4jOEd4Q67WLlMoIJksIyIC+WW59VqjPUkRhmMD5xx9 5MyO0xnuh5+DJqfrA5nfmVINSI4TkSs0gjOKvlO+HbXtIL0V4kUhkCXQ8lfTigl0grZi xnoGUc7DawbHG36dMu5BiyUzdrOlsTMS8dIs5ZXZGWieEnyAmof28e+Q1K5fRtfpH2r3 RsGR1l9WZveLdL5krzXRZ+UWQkuDDXh6jqsAIS6OkB7GS95Uat/U3wCwdk5n6qcYclKa 1saQ== X-Gm-Message-State: AOAM532n9h1ZabftJeLEQsqcbx5wY/Y6g0wIvMpivmebBMFv21niEdRt Kf/UjKmfa4SFtpBJe0Jt9xCgcw== X-Received: by 2002:a05:6830:12c2:: with SMTP id a2mr19346062otq.162.1606023696218; Sat, 21 Nov 2020 21:41:36 -0800 (PST) Received: from localhost.localdomain (104-57-184-186.lightspeed.austtx.sbcglobal.net. [104.57.184.186]) by smtp.gmail.com with ESMTPSA id s28sm4303132otr.4.2020.11.21.21.41.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Nov 2020 21:41:35 -0800 (PST) From: Bjorn Andersson To: Andy Gross , Bjorn Andersson , Ohad Ben-Cohen , Siddharth Gupta Cc: Mathieu Poirier , linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, Steev Klimaszewski , Rishabh Bhatnagar Subject: [PATCH v3 3/4] remoteproc: qcom: q6v5: Query sysmon before graceful shutdown Date: Sat, 21 Nov 2020 21:41:34 -0800 Message-Id: <20201122054135.802935-4-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201122054135.802935-1-bjorn.andersson@linaro.org> References: <20201122054135.802935-1-bjorn.andersson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Requesting a graceful shutdown through the shared memory state signals will not be acked in the event that sysmon has already successfully shut down the remote firmware. So extend the stop request API to optionally take the remoteproc's sysmon instance and query if there's already been a successful shutdown attempt, before doing the signal dance. Tested-by: Steev Klimaszewski Reviewed-by: Rishabh Bhatnagar Signed-off-by: Bjorn Andersson --- Change since v2: - Fixed spelling of optionally in commit message drivers/remoteproc/qcom_q6v5.c | 8 +++++++- drivers/remoteproc/qcom_q6v5.h | 3 ++- drivers/remoteproc/qcom_q6v5_adsp.c | 2 +- drivers/remoteproc/qcom_q6v5_mss.c | 2 +- drivers/remoteproc/qcom_q6v5_pas.c | 2 +- drivers/remoteproc/qcom_q6v5_wcss.c | 2 +- 6 files changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/remoteproc/qcom_q6v5.c b/drivers/remoteproc/qcom_q6v5.c index fd6fd36268d9..9627a950928e 100644 --- a/drivers/remoteproc/qcom_q6v5.c +++ b/drivers/remoteproc/qcom_q6v5.c @@ -13,6 +13,7 @@ #include #include #include +#include "qcom_common.h" #include "qcom_q6v5.h" #define Q6V5_PANIC_DELAY_MS 200 @@ -146,15 +147,20 @@ static irqreturn_t q6v5_stop_interrupt(int irq, void *data) /** * qcom_q6v5_request_stop() - request the remote processor to stop * @q6v5: reference to qcom_q6v5 context + * @sysmon: reference to the remote's sysmon instance, or NULL * * Return: 0 on success, negative errno on failure */ -int qcom_q6v5_request_stop(struct qcom_q6v5 *q6v5) +int qcom_q6v5_request_stop(struct qcom_q6v5 *q6v5, struct qcom_sysmon *sysmon) { int ret; q6v5->running = false; + /* Don't perform SMP2P dance if sysmon already shut down the remote */ + if (qcom_sysmon_shutdown_acked(sysmon)) + return 0; + qcom_smem_state_update_bits(q6v5->state, BIT(q6v5->stop_bit), BIT(q6v5->stop_bit)); diff --git a/drivers/remoteproc/qcom_q6v5.h b/drivers/remoteproc/qcom_q6v5.h index c4ed887c1499..1c212f670cbc 100644 --- a/drivers/remoteproc/qcom_q6v5.h +++ b/drivers/remoteproc/qcom_q6v5.h @@ -8,6 +8,7 @@ struct rproc; struct qcom_smem_state; +struct qcom_sysmon; struct qcom_q6v5 { struct device *dev; @@ -40,7 +41,7 @@ int qcom_q6v5_init(struct qcom_q6v5 *q6v5, struct platform_device *pdev, int qcom_q6v5_prepare(struct qcom_q6v5 *q6v5); int qcom_q6v5_unprepare(struct qcom_q6v5 *q6v5); -int qcom_q6v5_request_stop(struct qcom_q6v5 *q6v5); +int qcom_q6v5_request_stop(struct qcom_q6v5 *q6v5, struct qcom_sysmon *sysmon); int qcom_q6v5_wait_for_start(struct qcom_q6v5 *q6v5, int timeout); unsigned long qcom_q6v5_panic(struct qcom_q6v5 *q6v5); diff --git a/drivers/remoteproc/qcom_q6v5_adsp.c b/drivers/remoteproc/qcom_q6v5_adsp.c index f0b7363b5b26..2f8f38408eb7 100644 --- a/drivers/remoteproc/qcom_q6v5_adsp.c +++ b/drivers/remoteproc/qcom_q6v5_adsp.c @@ -266,7 +266,7 @@ static int adsp_stop(struct rproc *rproc) int handover; int ret; - ret = qcom_q6v5_request_stop(&adsp->q6v5); + ret = qcom_q6v5_request_stop(&adsp->q6v5, adsp->sysmon); if (ret == -ETIMEDOUT) dev_err(adsp->dev, "timed out on wait\n"); diff --git a/drivers/remoteproc/qcom_q6v5_mss.c b/drivers/remoteproc/qcom_q6v5_mss.c index ac289e08062e..55f7c5740920 100644 --- a/drivers/remoteproc/qcom_q6v5_mss.c +++ b/drivers/remoteproc/qcom_q6v5_mss.c @@ -1373,7 +1373,7 @@ static int q6v5_stop(struct rproc *rproc) struct q6v5 *qproc = (struct q6v5 *)rproc->priv; int ret; - ret = qcom_q6v5_request_stop(&qproc->q6v5); + ret = qcom_q6v5_request_stop(&qproc->q6v5, qproc->sysmon); if (ret == -ETIMEDOUT) dev_err(qproc->dev, "timed out on wait\n"); diff --git a/drivers/remoteproc/qcom_q6v5_pas.c b/drivers/remoteproc/qcom_q6v5_pas.c index 0678b417707e..49ea0133ff04 100644 --- a/drivers/remoteproc/qcom_q6v5_pas.c +++ b/drivers/remoteproc/qcom_q6v5_pas.c @@ -217,7 +217,7 @@ static int adsp_stop(struct rproc *rproc) int handover; int ret; - ret = qcom_q6v5_request_stop(&adsp->q6v5); + ret = qcom_q6v5_request_stop(&adsp->q6v5, adsp->sysmon); if (ret == -ETIMEDOUT) dev_err(adsp->dev, "timed out on wait\n"); diff --git a/drivers/remoteproc/qcom_q6v5_wcss.c b/drivers/remoteproc/qcom_q6v5_wcss.c index 8846ef0b0f1a..d6639856069b 100644 --- a/drivers/remoteproc/qcom_q6v5_wcss.c +++ b/drivers/remoteproc/qcom_q6v5_wcss.c @@ -390,7 +390,7 @@ static int q6v5_wcss_stop(struct rproc *rproc) int ret; /* WCSS powerdown */ - ret = qcom_q6v5_request_stop(&wcss->q6v5); + ret = qcom_q6v5_request_stop(&wcss->q6v5, wcss->sysmon); if (ret == -ETIMEDOUT) { dev_err(wcss->dev, "timed out on wait\n"); return ret; -- 2.28.0