Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1229966ybv; Thu, 13 Feb 2020 18:41:35 -0800 (PST) X-Google-Smtp-Source: APXvYqw0UGTOLxesWQm8MbA4s/B/wy79o+OHExYCF2bZqTbAF6sDhaXUocC6mtsFlLIO017fxsih X-Received: by 2002:aca:5486:: with SMTP id i128mr454819oib.12.1581648095578; Thu, 13 Feb 2020 18:41:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581648095; cv=none; d=google.com; s=arc-20160816; b=WWiQI0JmWEaAicCgQa5pHEBuSImelwhwxcT7ZyLAlpX9uCi29m1smsLwbLxDUX4IEp qivW73p7ib9rO5XyisWxbhlpm9Uqfpw2CqF6JPtX5KWNqK/2qTIU+iamrox3GSGcOeoI kcOFM0R8111qP7soQTL3hBlmYakhDvKwkQhgcaHnDWw5k/AVHVvsGd5XS2mRSsh5wA8E ho5DdhWICrY40qE6fRPhWGIKj5po8kXnCRUj2hOTlC6MgjixcDAUNhJje+cSDjWdWDWW DrYcVXXo9Wx0oVixpliWhnEx8XmFl6PszeScMNBfXQPBs9nxopTQvodUgEeMWWMBirR+ TePA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:date:to:cc:from :subject:references:in-reply-to:content-transfer-encoding :mime-version:dkim-signature; bh=eCyRMSwDhUx3DYVZzm+7HHgO3GMTp1RY7+uRcyHTPeI=; b=CEJrmIpgMrVsZCXPzSooj/yz5cme4PFM+c8RONOy+xjp/Yt96UiT4cHSoWUSCB82cK lFdtRT6mj+7l9Gtq+lY/NGI5Eii0Wa/OFpSvoLKFA5HoVCwg/aXLlYsZSPPcTLiJ8yg9 SJdeFCW712XXueZh+j3nMFMDQvFyL1IXzsrhVVuCt8i62BtN7Cwij+EFtMubUkUmg3fG EBOWqI35IdgWAm2vPgXQZM5O7F+ODokkomSB0Go6jE2l8voiTlgb/ayny8YjQpO+UpZV /35+zCzG171vPocUF85ca5utMdPYCmxmruOrGzwA/fcS07VbqGGXBRl0/mDZLSUt4i5F 6zXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=jWCAMo8E; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i8si2025187oih.206.2020.02.13.18.41.22; Thu, 13 Feb 2020 18:41:35 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=jWCAMo8E; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728216AbgBNClM (ORCPT + 99 others); Thu, 13 Feb 2020 21:41:12 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:40606 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728141AbgBNClM (ORCPT ); Thu, 13 Feb 2020 21:41:12 -0500 Received: by mail-pf1-f196.google.com with SMTP id q8so4104735pfh.7 for ; Thu, 13 Feb 2020 18:41:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:content-transfer-encoding:in-reply-to:references :subject:from:cc:to:date:message-id:user-agent; bh=eCyRMSwDhUx3DYVZzm+7HHgO3GMTp1RY7+uRcyHTPeI=; b=jWCAMo8EQdcK5KgJsuy4ct3kIXs800bHvuwy7eaSvUJ6vjxd0uxMYlrTzk5OJ+nIaG hRxdpE5zgAApIeCCKctakaQV1rb1+CevGAxyZKAg44aai2FNZQ/+Ye1//HuoTs4/jNqS PGaecUCEUoOntwF63nWtLazgkvgSU2eX7Ts/Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:content-transfer-encoding :in-reply-to:references:subject:from:cc:to:date:message-id :user-agent; bh=eCyRMSwDhUx3DYVZzm+7HHgO3GMTp1RY7+uRcyHTPeI=; b=hayGdqp91zVVJZoKxFl4lwF4dl9794706rAXreiYAJZqgfo3C/0FNV6zGAvqWGQLuc 8wPUcIA9lBljM9YS1N2ayL/POyNSGR6gDuo6ZH1+DivMdLHd+hkeFyOFOsWnEC+RUv3Y 90amxdu6ojK/0OrC4mfSwS5jukyq5nQXKvq67TK/1hO7QahN8DlO2Qr0MBSx3lK7yHkC usoqyyO51hC+UErG21c9bse6L0EyvJig0INYSGLEw3Pb0TRRrJXy4KVTrDPyWplII1k8 Vo8RkgarVCJ1pXLa1TmZSqCazrLf0hHCQYXXh85h/lQCwxPjWyR3tsq4eonHVjVKtgvD 8DGA== X-Gm-Message-State: APjAAAX5eDiutRIz1nPqmyKOHZSh4PhmElc0cToM/vYCTmopGDElsuBx TiKtfp2PJCNN1iV2l5GkTG3xEQ== X-Received: by 2002:a63:ca04:: with SMTP id n4mr1083967pgi.110.1581648070461; Thu, 13 Feb 2020 18:41:10 -0800 (PST) Received: from chromium.org ([2620:15c:202:1:fa53:7765:582b:82b9]) by smtp.gmail.com with ESMTPSA id b12sm4758285pfr.26.2020.02.13.18.41.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Feb 2020 18:41:09 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: <20200211005059.1377279-7-bjorn.andersson@linaro.org> References: <20200211005059.1377279-1-bjorn.andersson@linaro.org> <20200211005059.1377279-7-bjorn.andersson@linaro.org> Subject: Re: [PATCH v3 6/8] remoteproc: Introduce "panic" callback in ops From: Stephen Boyd Cc: Andy Gross , Rob Herring , Mark Rutland , linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Sibi Sankar , Rishabh Bhatnagar To: Bjorn Andersson , Ohad Ben-Cohen Date: Thu, 13 Feb 2020 18:41:08 -0800 Message-ID: <158164806895.184098.244699295706516537@swboyd.mtv.corp.google.com> User-Agent: alot/0.9 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Bjorn Andersson (2020-02-10 16:50:57) > diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/re= moteproc_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); > =20 > +static int rproc_panic_handler(struct notifier_block *nb, unsigned long = event, > + void *ptr) > +{ > + unsigned int longest =3D 0; > + struct rproc *rproc; > + unsigned int d; > + int locked; > + > + locked =3D mutex_trylock(&rproc_list_mutex); > + if (!locked) { > + pr_err("Failed to acquire rproc list lock, won't call pan= ic functions\n"); > + return NOTIFY_DONE; > + } > + > + list_for_each_entry(rproc, &rproc_list, node) { > + if (!rproc->ops->panic || rproc->state !=3D RPROC_RUNNING) > + continue; > + > + d =3D rproc->ops->panic(rproc); > + if (d > longest) > + longest =3D d; Could be d =3D 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 =3D 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 firm= ware > + * @panic: optional callback to react to system panic, core will del= ay > + * 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 *f= w); > 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.