From patchwork Tue Mar 24 05:29:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 11454497 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1E85C1392 for ; Tue, 24 Mar 2020 05:29:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F343420663 for ; Tue, 24 Mar 2020 05:29:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="AeJERwRS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725905AbgCXF3L (ORCPT ); Tue, 24 Mar 2020 01:29:11 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:43882 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725869AbgCXF3L (ORCPT ); Tue, 24 Mar 2020 01:29:11 -0400 Received: by mail-pf1-f193.google.com with SMTP id f206so8722499pfa.10 for ; Mon, 23 Mar 2020 22:29:10 -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 :mime-version:content-transfer-encoding; bh=GksRJuQygj8iEw4+FLEhSTTKNuAXjcLxWomfet7/TQc=; b=AeJERwRSpJgnUUI1sktI8LwnrhuSGSz3vYH1BFGxcVqWMRFulqPzEU+WQgIDtowBid DY0kGUla4Ru00rBlZA6ZdZE8lKd1/wJoWuf0lfY+cj2pDSnteABWfDjOZQsvKM+QFXa3 sMkhhNfGBHxaoBmA97f4vTJUIS1/CiwlZbeWU+TAt0eAlf/M7HCTuKV4oURSn8ECY4sC iX3F68HmPtaSvXgjFbClRcp4WaMOa4pIhb2bRBGX1JuaJ2bryB0/Lnge5pkrunV1IAMe 3x+OLXURB5P9kmJSJkyX2vCL4/RwyaFE97vy31wFojuM9pWgkikB1TK966do/hubMOas w5LQ== 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=GksRJuQygj8iEw4+FLEhSTTKNuAXjcLxWomfet7/TQc=; b=lRi47HmIoxFIJu41yxmLnYlP8swfCJOH8cwNBgirxJXPpC9CPRYq+AfscOCMCzMUvr SgWp2ydMh2y0c84KbdQndkUnTt6e/KX1PEvAhhjsKa7/C0MMFgY8u5I1+Os1wYBa8TKt ZR1sNd7C1Wq/iyD+K5xiIVlmvUaaUTJ/lCMqJq9ntSH3vLGZL8b4i3Ys+gcK7ieHKF8q zIgNKmTFvFmKxX8lIovv8nRbUjQ7H1qduF5ivrPXTCsnTjxOna21Lba9T7b0Z6w5ZYKU WXIq9p+tQrcikVxMvpkoX1cJC7S5pN9KRSjG+I1nu5UWOXfpWAy/ZQ1ev05upu2oIKrA IcVg== X-Gm-Message-State: ANhLgQ3T5GTEz7l1mCVWbcSBi5owBzeKdKAyKc2+v+ESp+XU6om5p1UI 1nFeED/4LNRDl1/7q75CSruPOA== X-Google-Smtp-Source: ADFU+vvQ57kvoZi+N9uQpIwZoXOTeauhh9IYgweVQ3UD9AqMO2B6kX+AF3DFoI0AvOUD007/H1wUOw== X-Received: by 2002:a62:4e4c:: with SMTP id c73mr28422516pfb.254.1585027750135; Mon, 23 Mar 2020 22:29:10 -0700 (PDT) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id j14sm2795413pgk.74.2020.03.23.22.29.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Mar 2020 22:29:09 -0700 (PDT) From: Bjorn Andersson To: Andy Gross , Bjorn Andersson , Ohad Ben-Cohen Cc: linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, Mathieu Poirier Subject: [PATCH v5 1/4] remoteproc: Traverse rproc_list under RCU read lock Date: Mon, 23 Mar 2020 22:29:01 -0700 Message-Id: <20200324052904.738594-2-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200324052904.738594-1-bjorn.andersson@linaro.org> References: <20200324052904.738594-1-bjorn.andersson@linaro.org> MIME-Version: 1.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org In order to be able to traverse the mostly read-only rproc_list without locking during panic migrate traversal to be done under rcu_read_lock(). Mutual exclusion for modifications of the list continues to be handled by the rproc_list_mutex and a synchronization point is added before releasing objects that are popped from the list. Reviewed-by: Mathieu Poirier Signed-off-by: Bjorn Andersson --- Changes since v4: - Added rculist include - Picked up Mathieu's r-b drivers/remoteproc/remoteproc_core.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index a9ac1d01e09b..7ee976ee2044 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -1868,8 +1869,8 @@ struct rproc *rproc_get_by_phandle(phandle phandle) if (!np) return NULL; - mutex_lock(&rproc_list_mutex); - list_for_each_entry(r, &rproc_list, node) { + rcu_read_lock(); + list_for_each_entry_rcu(r, &rproc_list, node) { if (r->dev.parent && r->dev.parent->of_node == np) { /* prevent underlying implementation from being removed */ if (!try_module_get(r->dev.parent->driver->owner)) { @@ -1882,7 +1883,7 @@ struct rproc *rproc_get_by_phandle(phandle phandle) break; } } - mutex_unlock(&rproc_list_mutex); + rcu_read_unlock(); of_node_put(np); @@ -1939,7 +1940,7 @@ int rproc_add(struct rproc *rproc) /* expose to rproc_get_by_phandle users */ mutex_lock(&rproc_list_mutex); - list_add(&rproc->node, &rproc_list); + list_add_rcu(&rproc->node, &rproc_list); mutex_unlock(&rproc_list_mutex); return 0; @@ -2156,9 +2157,12 @@ int rproc_del(struct rproc *rproc) /* the rproc is downref'ed as soon as it's removed from the klist */ mutex_lock(&rproc_list_mutex); - list_del(&rproc->node); + list_del_rcu(&rproc->node); mutex_unlock(&rproc_list_mutex); + /* Ensure that no readers of rproc_list are still active */ + synchronize_rcu(); + device_del(&rproc->dev); return 0; From patchwork Tue Mar 24 05:29:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 11454509 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CE4CF1667 for ; Tue, 24 Mar 2020 05:29:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A60D320663 for ; Tue, 24 Mar 2020 05:29:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Xws2Re/9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727289AbgCXF3W (ORCPT ); Tue, 24 Mar 2020 01:29:22 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:44162 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726257AbgCXF3N (ORCPT ); Tue, 24 Mar 2020 01:29:13 -0400 Received: by mail-pg1-f194.google.com with SMTP id 142so3212027pgf.11 for ; Mon, 23 Mar 2020 22:29:12 -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 :mime-version:content-transfer-encoding; bh=iOae39ZLxu99CuZ+vnrVCDxAqMUSZVQXhKOAdACPP94=; b=Xws2Re/9sTHSdvoLV1C/OerGG2vrUwlHjn8SkyO979v8vRK17RnFwVd3H0acHLdvvg ZlupQaefxjOxmlP6rH7S9z+erIBgb5jDsaiC4qPL4xgg5/ukdWnLlklzlsap8kqfZHE4 Y8po/0ZCrNbzx01lbbpLT58UlLKiR8ru+Yj6BTL8p785C0X/WDf3O2qjYzxDw0CzX7ch YJy5tbj5pI48qsGcNyz8pI8JbBK5ZZhX1v6PUwRubyVrKwZDnwXm4HliHhut+xtEJHFO XSaeXnVeU0U1s8EB7CUwrGeEFvV4MklAh6mouf1ZBIRhTcKdRvAnLvI2IxGlryOwr1je nWFw== 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=iOae39ZLxu99CuZ+vnrVCDxAqMUSZVQXhKOAdACPP94=; b=Ij0KuqbOCR+45diGbbd3MAKOXz8nKp2NigTLOrTaN06jljbVDDcU+ZS1WN45IjTW+q Ow8RaHTIkyxxJijpZ/3pC42QBx2kPtPH3weRtvUdkdtRcStPK7//Zq/qJiHTut+BHC2q jQdC1NS08h2Hv4tf114qKYmL/1d29+deg5SqQHOZkd8c+QWa6P0LLibgjpLDwOUyUljW gH21Q73gWSXo8sSSbOQct6g2QTUyJRIANtDRELli6b1qW6Va2U33kln7NQDkqCZeLWpi UuK84LMdWvDgVY3ErKalu4k18KZfGIfyWw6l0OqZ8G5/hyRP7pQQFEbSnDfX6zn24s7q l8+g== X-Gm-Message-State: ANhLgQ2t+Sxo+JTKo3fE/zJ03t60HaZ//BaqXWouWJ0kpRLQTfD8VRaI OVY0UjCum/75JnqyHcm6LUWAO8JB6VM= X-Google-Smtp-Source: ADFU+vsfiadgTn+esHQ2mswkV7PB2b9HK3iPvH/04B892CZM07osWa4KTdOAk/ZNirsq9SaTD4Tadg== X-Received: by 2002:aa7:9f42:: with SMTP id h2mr13546696pfr.22.1585027751538; Mon, 23 Mar 2020 22:29:11 -0700 (PDT) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id j14sm2795413pgk.74.2020.03.23.22.29.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Mar 2020 22:29:10 -0700 (PDT) From: Bjorn Andersson To: Andy Gross , Bjorn Andersson , Ohad Ben-Cohen Cc: linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, Mathieu Poirier Subject: [PATCH v5 2/4] remoteproc: Introduce "panic" callback in ops Date: Mon, 23 Mar 2020 22:29:02 -0700 Message-Id: <20200324052904.738594-3-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200324052904.738594-1-bjorn.andersson@linaro.org> References: <20200324052904.738594-1-bjorn.andersson@linaro.org> MIME-Version: 1.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Introduce generic support for handling kernel panics in remoteproc drivers, in order to allow operations needed for aiding in post mortem system debugging, such as flushing caches etc. The function can return a number of milliseconds needed by the remote to "settle" and the core will wait the longest returned duration before returning from the panic handler. Reviewed-by: Mathieu Poirier Signed-off-by: Bjorn Andersson --- Changes since v4: - Reworded comment about delay - Picked up Mathieu's r-b drivers/remoteproc/remoteproc_core.c | 43 ++++++++++++++++++++++++++++ include/linux/remoteproc.h | 3 ++ 2 files changed, 46 insertions(+) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 7ee976ee2044..e12a54e67588 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -16,6 +16,7 @@ #define pr_fmt(fmt) "%s: " fmt, __func__ +#include #include #include #include @@ -45,6 +46,7 @@ static DEFINE_MUTEX(rproc_list_mutex); static LIST_HEAD(rproc_list); +static struct notifier_block rproc_panic_nb; typedef int (*rproc_handle_resource_t)(struct rproc *rproc, void *, int offset, int avail); @@ -2236,10 +2238,50 @@ void rproc_report_crash(struct rproc *rproc, enum rproc_crash_type type) } EXPORT_SYMBOL(rproc_report_crash); +static int rproc_panic_handler(struct notifier_block *nb, unsigned long event, + void *ptr) +{ + unsigned int longest = 0; + struct rproc *rproc; + unsigned int d; + + rcu_read_lock(); + list_for_each_entry_rcu(rproc, &rproc_list, node) { + if (!rproc->ops->panic || rproc->state != RPROC_RUNNING) + continue; + + d = rproc->ops->panic(rproc); + longest = max(longest, d); + } + rcu_read_unlock(); + + /* + * Delay for the longest requested duration before returning. This can + * be used by the remoteproc drivers to give the remote processor time + * to perform any requested operations (such as flush caches), when + * it's not possible to signal the Linux side due to the panic. + */ + mdelay(longest); + + return NOTIFY_DONE; +} + +static void __init rproc_init_panic(void) +{ + rproc_panic_nb.notifier_call = rproc_panic_handler; + atomic_notifier_chain_register(&panic_notifier_list, &rproc_panic_nb); +} + +static void __exit rproc_exit_panic(void) +{ + atomic_notifier_chain_unregister(&panic_notifier_list, &rproc_panic_nb); +} + static int __init remoteproc_init(void) { rproc_init_sysfs(); rproc_init_debugfs(); + rproc_init_panic(); return 0; } @@ -2249,6 +2291,7 @@ static void __exit remoteproc_exit(void) { ida_destroy(&rproc_dev_index); + rproc_exit_panic(); rproc_exit_debugfs(); rproc_exit_sysfs(); } diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index ed127b2d35ca..9c07d7958c53 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -369,6 +369,8 @@ enum rsc_handling_status { * expects to find it * @sanity_check: sanity check the fw image * @get_boot_addr: get boot address to entry point specified in firmware + * @panic: optional callback to react to system panic, core will delay + * panic at least the returned number of milliseconds */ struct rproc_ops { int (*start)(struct rproc *rproc); @@ -383,6 +385,7 @@ struct rproc_ops { int (*load)(struct rproc *rproc, const struct firmware *fw); int (*sanity_check)(struct rproc *rproc, const struct firmware *fw); u64 (*get_boot_addr)(struct rproc *rproc, const struct firmware *fw); + unsigned long (*panic)(struct rproc *rproc); }; /** From patchwork Tue Mar 24 05:29:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 11454501 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 856BD6CA for ; Tue, 24 Mar 2020 05:29:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 65A8620724 for ; Tue, 24 Mar 2020 05:29:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="hEM/rlGO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727283AbgCXF3O (ORCPT ); Tue, 24 Mar 2020 01:29:14 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:42883 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727064AbgCXF3N (ORCPT ); Tue, 24 Mar 2020 01:29:13 -0400 Received: by mail-pf1-f193.google.com with SMTP id 22so5125166pfa.9 for ; Mon, 23 Mar 2020 22:29:13 -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 :mime-version:content-transfer-encoding; bh=prgc5yenFbqVYl3a5KSc8kSrf0HkGH2FfV3zRCvqmKU=; b=hEM/rlGONfHazJadGQTiOmWEjAXm+vqSTfam1wcplNH/Q+O2ztDaFBFhwMOXpkHSfD uuYUDr2Kd4VIN3SYFxZa2n/0SfPhX4KVBJ+zsS9ydwuzklU5ahb6KHiH9whRc/hDkOlu UAk/4bXjXKiKat4+ig6OgvxgoOgjI+S1WSwW5do5L8dDH2+XMbOvo+DodnHyUGgMHgOD KNPwc0fUdvDZG3yEUWniIG/YNqBiKOT5fIefa0zVBZLgLpDLvTe3/w2B0h/qCPCCcDdx 1pU0J5yqCCONt/pov1CbLsk2VtWgOAbg4M1sBE8G3pYh17w9zom/Cn0d9ZMV3MtyTggK uU4A== 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=prgc5yenFbqVYl3a5KSc8kSrf0HkGH2FfV3zRCvqmKU=; b=TFYVBbh538bS4psB6CdQnYi/436X/yOTYE0EuHLxkdAQVHVK+MsSJ9DQLf8PUDpxIL 5GhQLl2LIiYlbwWrcqCdx8dZ1W8m7DUFb+5DZwn7p4sNTh10mFMpl1Sru18BONWkioi6 Zp+YW51XNsOVVDICxNpQVQqC0GiGrrNr7l/A9hJRNeSFLhOJJ/tb+iwBNxq0cPVqA2TF Bsa9CYJVkMip3tMkqNCwLKlzB300S6CYE4c8rpLGi0tag2YymsM0TVLVfmkWkeUyUXU9 xCkZoaa+VOYFs6oDhytbxe2lQNCjHuoafchSTRYhGlcnIk9GOh/0u+4+A7waFc1ah15p wb5w== X-Gm-Message-State: ANhLgQ1AEjX9Hfe4ao6lPMLFeL4fp7W0t1g96BiIv0bngzhc4krxjox1 j+t10mUhAgzL3jmmOeQVqiNf2w== X-Google-Smtp-Source: ADFU+vtgBsqLCxc1WIyurKzcIGq00eupxNzzBQUA9Hm7fC7RVe5GrYL7SrWGnfmVf04T87Ro1s1FLg== X-Received: by 2002:a63:fd0d:: with SMTP id d13mr22612146pgh.302.1585027752740; Mon, 23 Mar 2020 22:29:12 -0700 (PDT) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id j14sm2795413pgk.74.2020.03.23.22.29.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Mar 2020 22:29:12 -0700 (PDT) From: Bjorn Andersson To: Andy Gross , Bjorn Andersson , Ohad Ben-Cohen Cc: linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, Mathieu Poirier Subject: [PATCH v5 3/4] remoteproc: qcom: q6v5: Add common panic handler Date: Mon, 23 Mar 2020 22:29:03 -0700 Message-Id: <20200324052904.738594-4-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200324052904.738594-1-bjorn.andersson@linaro.org> References: <20200324052904.738594-1-bjorn.andersson@linaro.org> MIME-Version: 1.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Add a common panic handler that invokes a stop request and sleep enough to let the remoteproc flush it's caches etc in order to aid post mortem debugging. For now a hard coded 200ms is returned to the remoteproc core, this value is taken from the downstream kernel. Reviewed-by: Mathieu Poirier Signed-off-by: Bjorn Andersson --- Changes since v4: - Picked up Mathieu's r-b drivers/remoteproc/qcom_q6v5.c | 20 ++++++++++++++++++++ drivers/remoteproc/qcom_q6v5.h | 1 + 2 files changed, 21 insertions(+) diff --git a/drivers/remoteproc/qcom_q6v5.c b/drivers/remoteproc/qcom_q6v5.c index cb0f4a0be032..111a442c993c 100644 --- a/drivers/remoteproc/qcom_q6v5.c +++ b/drivers/remoteproc/qcom_q6v5.c @@ -15,6 +15,8 @@ #include #include "qcom_q6v5.h" +#define Q6V5_PANIC_DELAY_MS 200 + /** * qcom_q6v5_prepare() - reinitialize the qcom_q6v5 context before start * @q6v5: reference to qcom_q6v5 context to be reinitialized @@ -162,6 +164,24 @@ int qcom_q6v5_request_stop(struct qcom_q6v5 *q6v5) } EXPORT_SYMBOL_GPL(qcom_q6v5_request_stop); +/** + * qcom_q6v5_panic() - panic handler to invoke a stop on the remote + * @q6v5: reference to qcom_q6v5 context + * + * Set the stop bit and sleep in order to allow the remote processor to flush + * its caches etc for post mortem debugging. + * + * Return: 200ms + */ +unsigned long qcom_q6v5_panic(struct qcom_q6v5 *q6v5) +{ + qcom_smem_state_update_bits(q6v5->state, + BIT(q6v5->stop_bit), BIT(q6v5->stop_bit)); + + return Q6V5_PANIC_DELAY_MS; +} +EXPORT_SYMBOL_GPL(qcom_q6v5_panic); + /** * qcom_q6v5_init() - initializer of the q6v5 common struct * @q6v5: handle to be initialized diff --git a/drivers/remoteproc/qcom_q6v5.h b/drivers/remoteproc/qcom_q6v5.h index 7ac92c1e0f49..c4ed887c1499 100644 --- a/drivers/remoteproc/qcom_q6v5.h +++ b/drivers/remoteproc/qcom_q6v5.h @@ -42,5 +42,6 @@ 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_wait_for_start(struct qcom_q6v5 *q6v5, int timeout); +unsigned long qcom_q6v5_panic(struct qcom_q6v5 *q6v5); #endif From patchwork Tue Mar 24 05:29:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 11454505 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C4F001392 for ; Tue, 24 Mar 2020 05:29:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A48C220724 for ; Tue, 24 Mar 2020 05:29:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="iMrML+KB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727064AbgCXF3S (ORCPT ); Tue, 24 Mar 2020 01:29:18 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:44070 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727107AbgCXF3O (ORCPT ); Tue, 24 Mar 2020 01:29:14 -0400 Received: by mail-pf1-f195.google.com with SMTP id b72so8716955pfb.11 for ; Mon, 23 Mar 2020 22:29:14 -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 :mime-version:content-transfer-encoding; bh=VWBRcEyMTW+WEEQt5SQF5x0ROI7z/m3lM/vgJNL3hXc=; b=iMrML+KBB5l6Ri6XlYTp/N4rYhFdoHCnP7QF50uxsXOpRFiKMrfs0dVaox9kc0xcpk hDjTamvLPXs8Upj4Txl/ZHG7p5o0uh/h4CBrV7yV+cqh9b2XxArrbKrfNKS7mThX4n87 lh8OPKocwkJvWLbmZX6QAE0HQHdUs3bpdkUs/OgRPxtXRRP9LCE32J1PWeMPGXIhfLO3 fbLOb+gkZJEbUiZtlW1cDNsxO/3I7cck8/8NDOeazkFQSG+hVXlbBRhsRG4hIBNxfSBd WF/XUlVoJlJVU4w5XTa67bZLj16R7bdlhJiwPTYveSpjX/bQIMr8cOg1aIx8hJF/Edc6 nD5A== 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=VWBRcEyMTW+WEEQt5SQF5x0ROI7z/m3lM/vgJNL3hXc=; b=ZYwpFJRYLzGoQTwXHrSIJPSstiDfDjMlblSRFTLmweHPMUdW+lrd5hiUH8j48uy7Go WkQDjsPnKOT0Z13tXnx8LPUptO+aZbtBj1TxK50wFO4rkfA//hW24sY8d5JKyl/Mik3z ru/6JsycuUIAL3Db5KG/aEuCXXtjmnv32V9e347E2eEOpvEJ0wQruDzIpsb+dGuDJnjG lry2+FqXizw9npEgyy18Oti3Sta2rl8aFgBc6rqLpMiOsDl0hBm9x38d47AkeF7+WJkj 2cutdE7cH70LiDJxHPpD7UMn/YClqNpSrNsFAzr2Xo3bkp+ZJKma/n1cUkUM4X3ODxKf BBdw== X-Gm-Message-State: ANhLgQ2459FGjErmPQQMvXXttZYv0zFXL6Rmmgzrwxto8h3npWzaBT51 cUx9zccM9SFFvuBAVCdf4TC0CQ== X-Google-Smtp-Source: ADFU+vtOqgoS3fw1vbaf1mdZpAWooFoKkJLbDx+LEZkLb5acpopnw2DgJmwSlrkhIO+GwxuRyZ3Fww== X-Received: by 2002:a63:6a4a:: with SMTP id f71mr26576969pgc.365.1585027753896; Mon, 23 Mar 2020 22:29:13 -0700 (PDT) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id j14sm2795413pgk.74.2020.03.23.22.29.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Mar 2020 22:29:13 -0700 (PDT) From: Bjorn Andersson To: Andy Gross , Bjorn Andersson , Ohad Ben-Cohen Cc: linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, Mathieu Poirier Subject: [PATCH v5 4/4] remoteproc: qcom: Introduce panic handler for PAS and ADSP Date: Mon, 23 Mar 2020 22:29:04 -0700 Message-Id: <20200324052904.738594-5-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200324052904.738594-1-bjorn.andersson@linaro.org> References: <20200324052904.738594-1-bjorn.andersson@linaro.org> MIME-Version: 1.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Make the PAS and ADSP/CDSP remoteproc drivers implement the panic handler that will invoke a stop to prepare the remoteprocs for post mortem debugging. Reviewed-by: Mathieu Poirier Signed-off-by: Bjorn Andersson --- Changes since v4: - Picked up Mathieu's r-b drivers/remoteproc/qcom_q6v5_adsp.c | 8 ++++++++ drivers/remoteproc/qcom_q6v5_pas.c | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/drivers/remoteproc/qcom_q6v5_adsp.c b/drivers/remoteproc/qcom_q6v5_adsp.c index 2b01f2282062..24a3db961d5e 100644 --- a/drivers/remoteproc/qcom_q6v5_adsp.c +++ b/drivers/remoteproc/qcom_q6v5_adsp.c @@ -282,12 +282,20 @@ static void *adsp_da_to_va(struct rproc *rproc, u64 da, size_t len) return adsp->mem_region + offset; } +static unsigned long adsp_panic(struct rproc *rproc) +{ + struct qcom_adsp *adsp = rproc->priv; + + return qcom_q6v5_panic(&adsp->q6v5); +} + static const struct rproc_ops adsp_ops = { .start = adsp_start, .stop = adsp_stop, .da_to_va = adsp_da_to_va, .parse_fw = qcom_register_dump_segments, .load = adsp_load, + .panic = adsp_panic, }; static int adsp_init_clock(struct qcom_adsp *adsp, const char **clk_ids) diff --git a/drivers/remoteproc/qcom_q6v5_pas.c b/drivers/remoteproc/qcom_q6v5_pas.c index a41860d2243a..7a63efb85405 100644 --- a/drivers/remoteproc/qcom_q6v5_pas.c +++ b/drivers/remoteproc/qcom_q6v5_pas.c @@ -234,12 +234,20 @@ static void *adsp_da_to_va(struct rproc *rproc, u64 da, size_t len) return adsp->mem_region + offset; } +static unsigned long adsp_panic(struct rproc *rproc) +{ + struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv; + + return qcom_q6v5_panic(&adsp->q6v5); +} + static const struct rproc_ops adsp_ops = { .start = adsp_start, .stop = adsp_stop, .da_to_va = adsp_da_to_va, .parse_fw = qcom_register_dump_segments, .load = adsp_load, + .panic = adsp_panic, }; static int adsp_init_clock(struct qcom_adsp *adsp)