linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Boyd <swboyd@chromium.org>
To: Bjorn Andersson <bjorn.andersson@linaro.org>,
	Ohad Ben-Cohen <ohad@wizery.com>
Cc: Andy Gross <agross@kernel.org>, Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	Sibi Sankar <sibis@codeaurora.org>,
	Rishabh Bhatnagar <rishabhb@codeaurora.org>
Subject: Re: [PATCH v3 6/8] remoteproc: Introduce "panic" callback in ops
Date: Thu, 13 Feb 2020 18:41:08 -0800	[thread overview]
Message-ID: <158164806895.184098.244699295706516537@swboyd.mtv.corp.google.com> (raw)
In-Reply-To: <20200211005059.1377279-7-bjorn.andersson@linaro.org>

Quoting Bjorn Andersson (2020-02-10 16:50:57)
> diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
> index 097f33e4f1f3..8b6932027d36 100644
> --- a/drivers/remoteproc/remoteproc_core.c
> +++ b/drivers/remoteproc/remoteproc_core.c
> @@ -2216,10 +2218,53 @@ 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;
> +       int locked;
> +
> +       locked = mutex_trylock(&rproc_list_mutex);
> +       if (!locked) {
> +               pr_err("Failed to acquire rproc list lock, won't call panic functions\n");
> +               return NOTIFY_DONE;
> +       }
> +
> +       list_for_each_entry(rproc, &rproc_list, node) {
> +               if (!rproc->ops->panic || rproc->state != RPROC_RUNNING)
> +                       continue;
> +
> +               d = rproc->ops->panic(rproc);
> +               if (d > longest)
> +                       longest = d;

Could be

	d = max(longest, d);

> +       }
> +
> +       mutex_unlock(&rproc_list_mutex);
> +
> +       /* Delay panic for the longest requested duration */
> +       mdelay(longest);

Is this to flush caches? Maybe indicate that in the comment.

> +
> +       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);

This is an atomic notifier, but the notifier function takes a mutex,
which sleeps. It should use spinlocks, and never sleep, given that panic
can be called from anywhere.

> +}
> +
> diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h
> index 16ad66683ad0..14f05f26cbcd 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);
>         u32 (*get_boot_addr)(struct rproc *rproc, const struct firmware *fw);
> +       unsigned int (*panic)(struct rproc *rproc);

Maybe should be unsigned long to match other "timeouts" in the kernel.

  parent reply	other threads:[~2020-02-14  2:41 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-11  0:50 [PATCH v3 0/8] remoteproc: qcom: post mortem debug support Bjorn Andersson
2020-02-11  0:50 ` [PATCH v3 1/8] dt-bindings: remoteproc: Add Qualcomm PIL info binding Bjorn Andersson
2020-02-14  2:24   ` Stephen Boyd
2020-02-14  4:58     ` Bjorn Andersson
2020-02-20 17:59   ` Mathieu Poirier
2020-02-11  0:50 ` [PATCH v3 2/8] remoteproc: qcom: Introduce driver to store pil info in IMEM Bjorn Andersson
2020-02-14  2:35   ` Stephen Boyd
2020-02-14  4:57     ` Bjorn Andersson
2020-02-20 19:01   ` Mathieu Poirier
2020-02-11  0:50 ` [PATCH v3 3/8] remoteproc: qcom: Update IMEM PIL info on load Bjorn Andersson
2020-02-20 20:42   ` Mathieu Poirier
2020-02-11  0:50 ` [PATCH v3 4/8] arm64: dts: qcom: qcs404: Add IMEM and PIL info region Bjorn Andersson
2020-02-14  2:37   ` Stephen Boyd
2020-02-14  4:40     ` Bjorn Andersson
2020-02-20 20:47   ` Mathieu Poirier
2020-02-11  0:50 ` [PATCH v3 5/8] arm64: dts: qcom: sdm845: " Bjorn Andersson
2020-02-20 20:48   ` Mathieu Poirier
2020-02-11  0:50 ` [PATCH v3 6/8] remoteproc: Introduce "panic" callback in ops Bjorn Andersson
2020-02-13 16:00   ` Arnaud POULIQUEN
2020-02-14  2:41   ` Stephen Boyd [this message]
2020-02-14  4:37     ` Bjorn Andersson
2020-02-11  0:50 ` [PATCH v3 7/8] remoteproc: qcom: q6v5: Add common panic handler Bjorn Andersson
2020-02-11  0:50 ` [PATCH v3 8/8] remoteproc: qcom: Introduce panic handler for PAS and ADSP Bjorn Andersson
2020-02-14  2:43   ` Stephen Boyd

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=158164806895.184098.244699295706516537@swboyd.mtv.corp.google.com \
    --to=swboyd@chromium.org \
    --cc=agross@kernel.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-remoteproc@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=ohad@wizery.com \
    --cc=rishabhb@codeaurora.org \
    --cc=robh+dt@kernel.org \
    --cc=sibis@codeaurora.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).