Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp247826pxb; Wed, 4 Nov 2020 21:37:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJzBqEVAtQFeHiaeer9+Wx8mr1/O2gjl1MMbNciiFwU/4hX/rjOMnghNb4ly9h/wln242b6K X-Received: by 2002:a05:6402:88d:: with SMTP id e13mr905892edy.366.1604554631827; Wed, 04 Nov 2020 21:37:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604554631; cv=none; d=google.com; s=arc-20160816; b=AgrrQSySmmFZ7UvzCWVzoYBbZXPfAB7O2p2ve13rKUd7+ncZxRZeuZXvbS8Pf6ZQ98 C4AZ3+bHgumGVoCVy8oQ0q5oJ5isNny9Q5P/EZ6QMCCRS5GHKZuLRit9sT+ouZ6TX7WP ZC416Gyhc0+AO1NMHC714BNMRQcQiTBdz09ErOT+wAfmaRN3r87cJKBYo8fy5spHVlfP 79Biw/HkufWeVEwEXxU58bzVO5VW5jbUHBk1JbE0tFtiE66rlgbu3mHyCLwpWzj+7UkP gTBBilPSSHHK0cgnH73A7e89UE719AHvguFHJnu85ovbxcwdoDqXvQrBsykDYgHl9Q4I w/Tw== 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=gB/8DdyhYbLhO5Kc+ec+n/kffS9x3KIVkFEGOmCDRJQ=; b=APGNisaFz6YPiyuo/pz5k1LzXZRdHwZYup80myEbmiO4Pr9iFX4d9SwX6TfdGE+Scx Qk2sNlaDEwWu7jo3Jw2bOEzjyZB9w0kJiLiqWpaoANVoqw9e6yxTrHk6wJD63nTxyyIP 5GUVHhuAAGXXOtyGJG8v1I72qnY6ncwwu0MRW09ZkZo8n3uCfJclGKTm1tPRZ2yd5BP6 Bkpjy/RbcG4brCxfQQARB3ebcY5PcLO82qVTFYH4X9S8PeUfGc37Ec9DZpAcQkKtWFCu CbZiZPnhag8QTIKGqJ07SMt/o16myVvfHoHXyxzpDlkEXT8/vHLuMxtltBVyEfiwnTkt jGRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="T/12uOtj"; 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 a14si435625edn.216.2020.11.04.21.36.49; Wed, 04 Nov 2020 21:37:11 -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="T/12uOtj"; 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 S1731121AbgKEEug (ORCPT + 99 others); Wed, 4 Nov 2020 23:50:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730941AbgKEEue (ORCPT ); Wed, 4 Nov 2020 23:50:34 -0500 Received: from mail-oo1-xc44.google.com (mail-oo1-xc44.google.com [IPv6:2607:f8b0:4864:20::c44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0B07C0613D2 for ; Wed, 4 Nov 2020 20:50:34 -0800 (PST) Received: by mail-oo1-xc44.google.com with SMTP id j41so119360oof.12 for ; Wed, 04 Nov 2020 20:50:34 -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=gB/8DdyhYbLhO5Kc+ec+n/kffS9x3KIVkFEGOmCDRJQ=; b=T/12uOtjxpMBCy+hcNVksK0w3Ds/WMLclOhdA8ZQlboyiWlsCIWN7K9VOfFekbEmsG DRdkefILdU8kv15wz0+46STpmtYnXqjCjY+XobWRyrBufATbkeL6mMeYyAnMZrJAUH6x Opm7dQKE+Y9ecV6Q/pTeklabK81olgrqfyU2yZipE1bu1IVuFgInoCro/maggP4Vv+7/ O2OEUQwgm0gx/sVLlPsRdQElJzd0N6alU3U1nLwos1brzE9ZWhLm36cvUsYjp2W8oodn Uhnl8nwir1KQlC4M4XLjv41+9OP5B4Hl1U2TaRi04XzxV/cFs0PBhH6rUx+fxYSsKfJp lGoQ== 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=gB/8DdyhYbLhO5Kc+ec+n/kffS9x3KIVkFEGOmCDRJQ=; b=oVeKJObSgmLIGG2JICzkdAwdzA4h2A7K1WHyt8Y0pdqjuxQlVhgYKzvkM4bV16L1ug daoFQEEUl3BPhtUj40anjSeEGCi/yCU1suaVGKZ0A83QirYg6psMsSeNMIf5g+gwASNe S7NqxPxz03qxBhf62BKKlCgZVTpKB2eFbvA6UzgS03zY4FFyVPGroHVeLx1EXbV7/sLu HDkSQ/s4ItkFt7Ep9l4At7K5kbX8fXrBtNMwNHJzEaxwodjlNJFafYKA01DxRUC4kb7F KAXyZcclbrjLnHKwg19qSe/Xyus61zjP2kMCZYpy8ADSRzlDNPWQhTm89ZEqhN3wT7ol z6Mw== X-Gm-Message-State: AOAM5332Iu44HVjwdAU8mHFSPD9l9EF8bNtZ2ShM9jB47TwVGTKS2aQV uI+BT8sm0p55Gltan7daSZqhrg== X-Received: by 2002:a4a:9cc3:: with SMTP id d3mr561837ook.4.1604551834112; Wed, 04 Nov 2020 20:50:34 -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 k13sm100553ooi.41.2020.11.04.20.50.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Nov 2020 20:50:33 -0800 (PST) From: Bjorn Andersson To: Andy Gross , Bjorn Andersson , Ohad Ben-Cohen , Siddharth Gupta , Sibi Sankar Cc: linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/4] remoteproc: qcom: q6v5: Query sysmon before graceful shutdown Date: Wed, 4 Nov 2020 20:50:50 -0800 Message-Id: <20201105045051.1365780-4-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201105045051.1365780-1-bjorn.andersson@linaro.org> References: <20201105045051.1365780-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 optinally take the remoteproc's sysmon instance and query if there's already been a successful shutdown attempt, before doing the signal dance. Signed-off-by: Bjorn Andersson --- Changes since v1: - New patch 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 efb2c1aa80a3..9db0380236e7 100644 --- a/drivers/remoteproc/qcom_q6v5_adsp.c +++ b/drivers/remoteproc/qcom_q6v5_adsp.c @@ -264,7 +264,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 9a473cfef758..501764934014 100644 --- a/drivers/remoteproc/qcom_q6v5_mss.c +++ b/drivers/remoteproc/qcom_q6v5_mss.c @@ -1370,7 +1370,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 3837f23995e0..ed1772bfa55d 100644 --- a/drivers/remoteproc/qcom_q6v5_pas.c +++ b/drivers/remoteproc/qcom_q6v5_pas.c @@ -214,7 +214,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