From patchwork Thu Feb 20 02:57:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddharth Gupta X-Patchwork-Id: 11393133 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 75154930 for ; Thu, 20 Feb 2020 02:59:16 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5281E24658 for ; Thu, 20 Feb 2020 02:59:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="NBD/MLfp"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mg.codeaurora.org header.i=@mg.codeaurora.org header.b="FLaxEvb1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5281E24658 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=/C0vDBIrK1rVgHYjiTl/3qDSDsZlH/oMxhOFSPjryK0=; b=NBD/MLfp2UWYzYGjqEb1ZCFUIN 2GA8DWJaVnNAXb1O8N/MVFCfZwbGQEZEVy4nGKwvsFtxOaNHqf0u+/3u7jFCQJUnDw12GJszZS2oQ X/j0EI2ojQSL9gR9QCzdXZcQdTSMqN3gE6ySFgBg6PahLQSOmaDMLR3CqXYs6wgHAovfkVJgCaH7e 9plC3PzChdFq2KWF/FbkybGmGlDBeAfv8vvr4lhNRwP/e9r9A+0zzgq72J4f45zBLzpe3d84jXnIb 4NkRD02bL0aNyQFMmDM+cNiuHrzDDK3X6Jqx/BOCufOe0+mTqV/gd7+9WNBQ/rJeX6Qq+y8WFhr7z xwlFgk1A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j4c3X-0001b4-JA; Thu, 20 Feb 2020 02:59:15 +0000 Received: from mail26.static.mailgun.info ([104.130.122.26]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j4c2L-0000NX-9x for linux-arm-kernel@lists.infradead.org; Thu, 20 Feb 2020 02:58:08 +0000 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1582167485; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=bml65BiZKqC8La35iek9YW4e+KEfIXfCCZ0eFO8GDNY=; b=FLaxEvb17W5LKFlgHxwmwVf6mQIwLNPG6mgp9Hk0ozhPI8LhzDKE5XGjnwm7vrJcxV2d1sOb JWd4///RMo/EPIN6T7no+U5acQXD8kndWcOBBDdVvuFfHUdFVAZKwNUI7+44hzb9Sbf0GoeS lMkAmauNvyM9LfS/YB8Q7917IXQ= X-Mailgun-Sending-Ip: 104.130.122.26 X-Mailgun-Sid: WyJiYzAxZiIsICJsaW51eC1hcm0ta2VybmVsQGxpc3RzLmluZnJhZGVhZC5vcmciLCAiYmU5ZTRhIl0= Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by mxa.mailgun.org with ESMTP id 5e4df5b3.7fa3ae4723e8-smtp-out-n02; Thu, 20 Feb 2020 02:57:55 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 406A7C447A4; Thu, 20 Feb 2020 02:57:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from sidgup-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sidgup) by smtp.codeaurora.org (Postfix) with ESMTPSA id 02FFDC4479C; Thu, 20 Feb 2020 02:57:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 02FFDC4479C Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=sidgup@codeaurora.org From: Siddharth Gupta To: agross@kernel.org, bjorn.andersson@linaro.org, ohad@wizery.com Subject: [PATCH 1/6] remoteproc: sysmon: Add ability to send type of notification Date: Wed, 19 Feb 2020 18:57:40 -0800 Message-Id: <1582167465-2549-2-git-send-email-sidgup@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1582167465-2549-1-git-send-email-sidgup@codeaurora.org> References: <1582167465-2549-1-git-send-email-sidgup@codeaurora.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200219_185805_654030_2213F831 X-CRM114-Status: GOOD ( 17.13 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [104.130.122.26 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: tsoni@codeaurora.org, linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, rishabhb@codeaurora.org, Siddharth Gupta , psodagud@codeaurora.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Current implementation of the sysmon driver does not support adding notifications for other remoteproc events - prepare, start, unprepare. Clients on the remoteproc side might be interested in knowing when a remoteproc boots up. This change adds the ability to send the notification type along with the name. For example, audio DSP is interested in knowing when modem has crashed so that it can perform cleanup and wait for modem to boot up before it starts processing data again. Signed-off-by: Siddharth Gupta --- drivers/remoteproc/qcom_sysmon.c | 54 +++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 17 deletions(-) diff --git a/drivers/remoteproc/qcom_sysmon.c b/drivers/remoteproc/qcom_sysmon.c index faf3822..1366050 100644 --- a/drivers/remoteproc/qcom_sysmon.c +++ b/drivers/remoteproc/qcom_sysmon.c @@ -46,6 +46,25 @@ struct qcom_sysmon { struct sockaddr_qrtr ssctl; }; +enum { + SSCTL_SSR_EVENT_BEFORE_POWERUP, + SSCTL_SSR_EVENT_AFTER_POWERUP, + SSCTL_SSR_EVENT_BEFORE_SHUTDOWN, + SSCTL_SSR_EVENT_AFTER_SHUTDOWN, +}; + +static const char * const sysmon_state_string[] = { + [SSCTL_SSR_EVENT_BEFORE_POWERUP] = "before_powerup", + [SSCTL_SSR_EVENT_AFTER_POWERUP] = "after_powerup", + [SSCTL_SSR_EVENT_BEFORE_SHUTDOWN] = "before_shutdown", + [SSCTL_SSR_EVENT_AFTER_SHUTDOWN] = "after_shutdown", +}; + +struct sysmon_event { + const char *subsys_name; + u32 ssr_event; +}; + static DEFINE_MUTEX(sysmon_lock); static LIST_HEAD(sysmon_list); @@ -54,13 +73,15 @@ static LIST_HEAD(sysmon_list); * @sysmon: sysmon context * @name: other remote's name */ -static void sysmon_send_event(struct qcom_sysmon *sysmon, const char *name) +static void sysmon_send_event(struct qcom_sysmon *sysmon, + const struct sysmon_event *event) { char req[50]; int len; int ret; - len = snprintf(req, sizeof(req), "ssr:%s:before_shutdown", name); + len = snprintf(req, sizeof(req), "ssr:%s:%s", event->subsys_name, + sysmon_state_string[event->ssr_event]); if (len >= sizeof(req)) return; @@ -149,13 +170,6 @@ static int sysmon_callback(struct rpmsg_device *rpdev, void *data, int count, #define SSCTL_SUBSYS_NAME_LENGTH 15 enum { - SSCTL_SSR_EVENT_BEFORE_POWERUP, - SSCTL_SSR_EVENT_AFTER_POWERUP, - SSCTL_SSR_EVENT_BEFORE_SHUTDOWN, - SSCTL_SSR_EVENT_AFTER_SHUTDOWN, -}; - -enum { SSCTL_SSR_EVENT_FORCED, SSCTL_SSR_EVENT_GRACEFUL, }; @@ -331,7 +345,8 @@ static void ssctl_request_shutdown(struct qcom_sysmon *sysmon) * @sysmon: sysmon context * @name: other remote's name */ -static void ssctl_send_event(struct qcom_sysmon *sysmon, const char *name) +static void ssctl_send_event(struct qcom_sysmon *sysmon, + const struct sysmon_event *event) { struct ssctl_subsys_event_resp resp; struct ssctl_subsys_event_req req; @@ -346,9 +361,9 @@ static void ssctl_send_event(struct qcom_sysmon *sysmon, const char *name) } memset(&req, 0, sizeof(req)); - strlcpy(req.subsys_name, name, sizeof(req.subsys_name)); + strlcpy(req.subsys_name, event->subsys_name, sizeof(req.subsys_name)); req.subsys_name_len = strlen(req.subsys_name); - req.event = SSCTL_SSR_EVENT_BEFORE_SHUTDOWN; + req.event = event->ssr_event; req.evt_driven_valid = true; req.evt_driven = SSCTL_SSR_EVENT_FORCED; @@ -432,8 +447,12 @@ static int sysmon_start(struct rproc_subdev *subdev) static void sysmon_stop(struct rproc_subdev *subdev, bool crashed) { struct qcom_sysmon *sysmon = container_of(subdev, struct qcom_sysmon, subdev); + struct sysmon_event event = { + .subsys_name = sysmon->name, + .ssr_event = SSCTL_SSR_EVENT_BEFORE_SHUTDOWN + }; - blocking_notifier_call_chain(&sysmon_notifiers, 0, (void *)sysmon->name); + blocking_notifier_call_chain(&sysmon_notifiers, 0, (void *)&event); /* Don't request graceful shutdown if we've crashed */ if (crashed) @@ -456,19 +475,20 @@ static int sysmon_notify(struct notifier_block *nb, unsigned long event, { struct qcom_sysmon *sysmon = container_of(nb, struct qcom_sysmon, nb); struct rproc *rproc = sysmon->rproc; - const char *ssr_name = data; + struct sysmon_event *sysmon_event = data; /* Skip non-running rprocs and the originating instance */ - if (rproc->state != RPROC_RUNNING || !strcmp(data, sysmon->name)) { + if (rproc->state != RPROC_RUNNING || + !strcmp(sysmon_event->subsys_name, sysmon->name)) { dev_dbg(sysmon->dev, "not notifying %s\n", sysmon->name); return NOTIFY_DONE; } /* Only SSCTL version 2 supports SSR events */ if (sysmon->ssctl_version == 2) - ssctl_send_event(sysmon, ssr_name); + ssctl_send_event(sysmon, sysmon_event); else if (sysmon->ept) - sysmon_send_event(sysmon, ssr_name); + sysmon_send_event(sysmon, sysmon_event); return NOTIFY_DONE; } From patchwork Thu Feb 20 02:57:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddharth Gupta X-Patchwork-Id: 11393129 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 D5914930 for ; Thu, 20 Feb 2020 02:58:54 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A027424658 for ; Thu, 20 Feb 2020 02:58:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="py3jXyjY"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mg.codeaurora.org header.i=@mg.codeaurora.org header.b="sWVUv5TF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A027424658 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=O3MSnkKJMTenQPGn7//Bvy1I6kK9D72OP5h2XgCu7wg=; b=py3jXyjYkJJCZ+zS0cTUqdPc5i E2IK7e1M8Mm/PJCaDceidUqccMjT6KlYR3QReesBwuNgnhDuPRJsWWNaBii4DJ/iy0DElhHmI46wC WZt3i1hl9Rx6O882dwg+Bv9/VEoMSkaZK/AbScXy/8JLx0wXDvQ0OEUqYqzcSBcpjEQ07IiPr7n// LqMt5vK30Zm1TcIh+anjSulmOqMnmZogz6Fn7nAqPBQ/38yTI74xEwQ1vWEkyNiT45FGlVjN4mm7/ dkxoqlu+OEopSz73z5W2Fddsw/OD4knhthi+ModNgQJSDlDWSvaKxc/3PPXke1Z2OC8FPHmKWVbOi 2jGindtg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j4c36-00018Q-My; Thu, 20 Feb 2020 02:58:48 +0000 Received: from mail26.static.mailgun.info ([104.130.122.26]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j4c2M-0000Nk-3r for linux-arm-kernel@lists.infradead.org; Thu, 20 Feb 2020 02:58:07 +0000 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1582167485; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=sd4ovfJpZhdxAUPqCMdrQUjnd3KMRkpIg+xta7RYHBA=; b=sWVUv5TFEw0tHGBeVfSxLAnQrqkrajRW4oHAMyOprkb0eIRATYvL01v8c+5tvKu2ic8CSZwf 1KFY7VyrLoLgs7zDpeaGX0VOkn0wYrg4ApwUw8+UsFpZuOxcW4uWfCttcTHjj6Rec6Zka+3W gbbj8ZzFNno93+aaEg/hl+UuEjU= X-Mailgun-Sending-Ip: 104.130.122.26 X-Mailgun-Sid: WyJiYzAxZiIsICJsaW51eC1hcm0ta2VybmVsQGxpc3RzLmluZnJhZGVhZC5vcmciLCAiYmU5ZTRhIl0= Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by mxa.mailgun.org with ESMTP id 5e4df5b2.7f5b2567f650-smtp-out-n03; Thu, 20 Feb 2020 02:57:54 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 9ED23C447A0; Thu, 20 Feb 2020 02:57:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from sidgup-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sidgup) by smtp.codeaurora.org (Postfix) with ESMTPSA id A0C0FC433A2; Thu, 20 Feb 2020 02:57:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org A0C0FC433A2 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=sidgup@codeaurora.org From: Siddharth Gupta To: agross@kernel.org, bjorn.andersson@linaro.org, ohad@wizery.com Subject: [PATCH 2/6] remoteproc: sysmon: Add notifications for events Date: Wed, 19 Feb 2020 18:57:41 -0800 Message-Id: <1582167465-2549-3-git-send-email-sidgup@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1582167465-2549-1-git-send-email-sidgup@codeaurora.org> References: <1582167465-2549-1-git-send-email-sidgup@codeaurora.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200219_185805_512339_D90B9C81 X-CRM114-Status: GOOD ( 13.12 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [104.130.122.26 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: tsoni@codeaurora.org, linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, rishabhb@codeaurora.org, Siddharth Gupta , psodagud@codeaurora.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Add notification for other stages of remoteproc boot and shutdown. This includes adding callback functions for the prepare and unprepare events, and fleshing out the callback function for start. Signed-off-by: Siddharth Gupta --- drivers/remoteproc/qcom_sysmon.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/remoteproc/qcom_sysmon.c b/drivers/remoteproc/qcom_sysmon.c index 1366050..851664e 100644 --- a/drivers/remoteproc/qcom_sysmon.c +++ b/drivers/remoteproc/qcom_sysmon.c @@ -439,8 +439,31 @@ static const struct qmi_ops ssctl_ops = { .del_server = ssctl_del_server, }; +static int sysmon_prepare(struct rproc_subdev *subdev) +{ + struct qcom_sysmon *sysmon = container_of(subdev, struct qcom_sysmon, + subdev); + struct sysmon_event event = { + .subsys_name = sysmon->name, + .ssr_event = SSCTL_SSR_EVENT_BEFORE_POWERUP + }; + + blocking_notifier_call_chain(&sysmon_notifiers, 0, (void *)&event); + + return 0; +} + static int sysmon_start(struct rproc_subdev *subdev) { + struct qcom_sysmon *sysmon = container_of(subdev, struct qcom_sysmon, + subdev); + struct sysmon_event event = { + .subsys_name = sysmon->name, + .ssr_event = SSCTL_SSR_EVENT_AFTER_POWERUP + }; + + blocking_notifier_call_chain(&sysmon_notifiers, 0, (void *)&event); + return 0; } @@ -464,6 +487,18 @@ static void sysmon_stop(struct rproc_subdev *subdev, bool crashed) sysmon_request_shutdown(sysmon); } +static void sysmon_unprepare(struct rproc_subdev *subdev) +{ + struct qcom_sysmon *sysmon = container_of(subdev, struct qcom_sysmon, + subdev); + struct sysmon_event event = { + .subsys_name = sysmon->name, + .ssr_event = SSCTL_SSR_EVENT_AFTER_SHUTDOWN + }; + + blocking_notifier_call_chain(&sysmon_notifiers, 0, (void *)&event); +} + /** * sysmon_notify() - notify sysmon target of another's SSR * @nb: notifier_block associated with sysmon instance @@ -563,8 +598,10 @@ struct qcom_sysmon *qcom_add_sysmon_subdev(struct rproc *rproc, qmi_add_lookup(&sysmon->qmi, 43, 0, 0); + sysmon->subdev.prepare = sysmon_prepare; sysmon->subdev.start = sysmon_start; sysmon->subdev.stop = sysmon_stop; + sysmon->subdev.unprepare = sysmon_unprepare; rproc_add_subdev(rproc, &sysmon->subdev); From patchwork Thu Feb 20 02:57:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddharth Gupta X-Patchwork-Id: 11393131 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 DE7E1930 for ; Thu, 20 Feb 2020 02:59:00 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B576D24658 for ; Thu, 20 Feb 2020 02:59:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="HovnaEfr"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mg.codeaurora.org header.i=@mg.codeaurora.org header.b="uOhZtIkR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B576D24658 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=vWcoPBUo1s8n90BDRKZ77ofEWrzLnMbvjYXE3V1Gl2Q=; b=HovnaEfrc+RywEI4u1Xmg6EASG EYasw3z+xBik0l+eJWXVQbAcPcbeqZtvJWkctU5mSNUUQFojggZYuictVGgtVOPev4bXKSANvLocJ J7sGbEcEn3WKXpweyYNBIKo2+xil4k54kCNMJM2r3lIYjNo+ftgjoFNmUNlPrHWoHsPbf3FoLNQYW 5gcncXHuqG/slRXogSJFrQ3MQultMKtspK49SkI6eTBcGd3yfnymNJMfWzYK9bgBuzZQMVtnJWkbQ 8vMAyIwvYzCsKlsb1IvDRQaU3Dwey7V4ucY4D+aQ7Ps2712emNwnZEQ/h+vZgLKkJFsBDsjDEFeBx 1Oxyz6GQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j4c3H-0001Ki-Qv; Thu, 20 Feb 2020 02:58:59 +0000 Received: from mail27.static.mailgun.info ([104.130.122.27]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j4c2L-0000NH-Js for linux-arm-kernel@lists.infradead.org; Thu, 20 Feb 2020 02:58:07 +0000 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1582167485; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=5ceaaMSCCm3YPAR+D5NLBko4BNHYVXjbzI5l1pQJZTg=; b=uOhZtIkRUF6YbbN43ipUd0oAuZgLikYHQLey8dOGrBT/8/lOUdbXlUv3IVUopMhIRnHS+Pjp vRJZacN9h/z+FbOGx7sC7vM8EicLO2dhQwkZpvodVODUfYZpvNdXV6ZdXH/U6McjWcxyHrdF QTNcUS8/7PIgcvh8BKENYcKL7Xo= X-Mailgun-Sending-Ip: 104.130.122.27 X-Mailgun-Sid: WyJiYzAxZiIsICJsaW51eC1hcm0ta2VybmVsQGxpc3RzLmluZnJhZGVhZC5vcmciLCAiYmU5ZTRhIl0= Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by mxa.mailgun.org with ESMTP id 5e4df5b3.7f63e7bc9a08-smtp-out-n01; Thu, 20 Feb 2020 02:57:55 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 30074C447A2; Thu, 20 Feb 2020 02:57:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from sidgup-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sidgup) by smtp.codeaurora.org (Postfix) with ESMTPSA id 4A719C4479F; Thu, 20 Feb 2020 02:57:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 4A719C4479F Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=sidgup@codeaurora.org From: Siddharth Gupta To: agross@kernel.org, bjorn.andersson@linaro.org, ohad@wizery.com Subject: [PATCH 3/6] remoteproc: sysmon: Inform current rproc about all active rprocs Date: Wed, 19 Feb 2020 18:57:42 -0800 Message-Id: <1582167465-2549-4-git-send-email-sidgup@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1582167465-2549-1-git-send-email-sidgup@codeaurora.org> References: <1582167465-2549-1-git-send-email-sidgup@codeaurora.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200219_185805_358402_676E39E9 X-CRM114-Status: GOOD ( 13.79 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [104.130.122.27 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: tsoni@codeaurora.org, linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, rishabhb@codeaurora.org, Siddharth Gupta , psodagud@codeaurora.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org A remoteproc that has just recovered from a crash will not be aware of the state of other remoteprocs. Send sysmon notifications on behalf of all the active/online remoteprocs to the one that just booted up. Signed-off-by: Siddharth Gupta --- drivers/remoteproc/qcom_sysmon.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/remoteproc/qcom_sysmon.c b/drivers/remoteproc/qcom_sysmon.c index 851664e..d0d59d5 100644 --- a/drivers/remoteproc/qcom_sysmon.c +++ b/drivers/remoteproc/qcom_sysmon.c @@ -457,6 +457,7 @@ static int sysmon_start(struct rproc_subdev *subdev) { struct qcom_sysmon *sysmon = container_of(subdev, struct qcom_sysmon, subdev); + struct qcom_sysmon *target; struct sysmon_event event = { .subsys_name = sysmon->name, .ssr_event = SSCTL_SSR_EVENT_AFTER_POWERUP @@ -464,6 +465,17 @@ static int sysmon_start(struct rproc_subdev *subdev) blocking_notifier_call_chain(&sysmon_notifiers, 0, (void *)&event); + mutex_lock(&sysmon_lock); + list_for_each_entry(target, &sysmon_list, node) { + if (target == sysmon || + target->rproc->state != RPROC_RUNNING) + continue; + + event.subsys_name = target->name; + ssctl_send_event(sysmon, &event); + } + mutex_unlock(&sysmon_lock); + return 0; } From patchwork Thu Feb 20 02:57:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddharth Gupta X-Patchwork-Id: 11393115 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 F3A7F17EF for ; Thu, 20 Feb 2020 02:58:17 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BCEE924658 for ; Thu, 20 Feb 2020 02:58:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="MXGrNLHn"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mg.codeaurora.org header.i=@mg.codeaurora.org header.b="dqvqspdW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BCEE924658 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=0t67Q5nauwSsKG7Oz7qiCzoxUWpmPFDRBxahxka7DCY=; b=MXGrNLHnYOcXmujSKCE6ktAb5D GkU037rgVSjZfx6hslpRV7aJIVlWBSQp/DfAvGt1qkASV6s8UscXWdDnRQeM9Fap8xH3B3t75tj4k FVBAV9/83o2Awme/8Rkddc+v/JE6LTKqUSQA3XRzoYOqTbgb2qD7oS/gMlTheqcbzsy1wlB+QgNrT 5AA8CPji0px4oXIbjcCXmVB+tN8J1A7iwoIrjjct5wqmYNoeFm9VnWXOHHk+GnrghGlv8SmZb6m3U 8mI6G4QekoaTqITeULh54xXB3LLkXYhBMNDxaj/uJR3+SuKuJ6i9WA2c9y6Q0nMTqL5p8hbltNmez PwQrWCTQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j4c2a-0000ZD-HJ; Thu, 20 Feb 2020 02:58:16 +0000 Received: from mail27.static.mailgun.info ([104.130.122.27]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j4c2L-0000NI-Jt for linux-arm-kernel@lists.infradead.org; Thu, 20 Feb 2020 02:58:03 +0000 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1582167479; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=9u8BlgWrFHwG4Ht6CWfv3d3zqguh9fPrghJWyshx0+Y=; b=dqvqspdWTu/u6HDe5uyFGXoHRdRjCSa1i+dcU6gjC+tpoxY/SUgKb1hRvfwMpRUN07K6ODm0 OMwzyisUafeULzS8fIbMRDFjnlLPqOpSoQqaht/rVI3NX0662/gry4YZGYY72ZZimWKKLHYV HFYqy/a0I3lCiuiCt0nTRRt6Rx8= X-Mailgun-Sending-Ip: 104.130.122.27 X-Mailgun-Sid: WyJiYzAxZiIsICJsaW51eC1hcm0ta2VybmVsQGxpc3RzLmluZnJhZGVhZC5vcmciLCAiYmU5ZTRhIl0= Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by mxa.mailgun.org with ESMTP id 5e4df5b5.7f4a2daad570-smtp-out-n03; Thu, 20 Feb 2020 02:57:57 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 06A68C447A3; Thu, 20 Feb 2020 02:57:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from sidgup-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sidgup) by smtp.codeaurora.org (Postfix) with ESMTPSA id E6962C43383; Thu, 20 Feb 2020 02:57:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org E6962C43383 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=sidgup@codeaurora.org From: Siddharth Gupta To: agross@kernel.org, bjorn.andersson@linaro.org, ohad@wizery.com Subject: [PATCH 4/6] drivers: remoteproc: Add name field for every subdevice Date: Wed, 19 Feb 2020 18:57:43 -0800 Message-Id: <1582167465-2549-5-git-send-email-sidgup@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1582167465-2549-1-git-send-email-sidgup@codeaurora.org> References: <1582167465-2549-1-git-send-email-sidgup@codeaurora.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200219_185801_710716_D899E603 X-CRM114-Status: GOOD ( 13.60 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [104.130.122.27 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: tsoni@codeaurora.org, linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, Rishabh Bhatnagar , Siddharth Gupta , psodagud@codeaurora.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Rishabh Bhatnagar When a client driver wishes to utilize functionality from a particular subdevice of a remoteproc, it cannot differentiate between the subdevices that have been added. This patch allows the client driver to distinguish between subdevices and thus utilize their functionality. Signed-off-by: Rishabh Bhatnagar Signed-off-by: Siddharth Gupta --- drivers/remoteproc/qcom_common.c | 6 ++++++ include/linux/remoteproc.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/drivers/remoteproc/qcom_common.c b/drivers/remoteproc/qcom_common.c index 60650bc..5d59538 100644 --- a/drivers/remoteproc/qcom_common.c +++ b/drivers/remoteproc/qcom_common.c @@ -58,6 +58,7 @@ void qcom_add_glink_subdev(struct rproc *rproc, struct qcom_rproc_glink *glink) glink->dev = dev; glink->subdev.start = glink_subdev_start; glink->subdev.stop = glink_subdev_stop; + glink->subdev.name = kstrdup("glink", GFP_KERNEL); rproc_add_subdev(rproc, &glink->subdev); } @@ -73,6 +74,7 @@ void qcom_remove_glink_subdev(struct rproc *rproc, struct qcom_rproc_glink *glin if (!glink->node) return; + kfree(glink->subdev.name); rproc_remove_subdev(rproc, &glink->subdev); of_node_put(glink->node); } @@ -154,6 +156,7 @@ void qcom_add_smd_subdev(struct rproc *rproc, struct qcom_rproc_subdev *smd) smd->dev = dev; smd->subdev.start = smd_subdev_start; smd->subdev.stop = smd_subdev_stop; + smd->subdev.name = kstrdup("smd", GFP_KERNEL); rproc_add_subdev(rproc, &smd->subdev); } @@ -169,6 +172,7 @@ void qcom_remove_smd_subdev(struct rproc *rproc, struct qcom_rproc_subdev *smd) if (!smd->node) return; + kfree(smd->subdev.name); rproc_remove_subdev(rproc, &smd->subdev); of_node_put(smd->node); } @@ -220,6 +224,7 @@ void qcom_add_ssr_subdev(struct rproc *rproc, struct qcom_rproc_ssr *ssr, const char *ssr_name) { ssr->name = ssr_name; + ssr->subdev.name = kstrdup("ssr_notifs", GFP_KERNEL); ssr->subdev.unprepare = ssr_notify_unprepare; rproc_add_subdev(rproc, &ssr->subdev); @@ -233,6 +238,7 @@ EXPORT_SYMBOL_GPL(qcom_add_ssr_subdev); */ void qcom_remove_ssr_subdev(struct rproc *rproc, struct qcom_rproc_ssr *ssr) { + kfree(ssr->subdev.name); rproc_remove_subdev(rproc, &ssr->subdev); } EXPORT_SYMBOL_GPL(qcom_remove_ssr_subdev); diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index e2eaba9..e2f60cc 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -519,6 +519,7 @@ struct rproc { /** * struct rproc_subdev - subdevice tied to a remoteproc * @node: list node related to the rproc subdevs list + * @name: name of the subdevice * @prepare: prepare function, called before the rproc is started * @start: start function, called after the rproc has been started * @stop: stop function, called before the rproc is stopped; the @crashed @@ -527,6 +528,7 @@ struct rproc { */ struct rproc_subdev { struct list_head node; + char *name; int (*prepare)(struct rproc_subdev *subdev); int (*start)(struct rproc_subdev *subdev); From patchwork Thu Feb 20 02:57:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddharth Gupta X-Patchwork-Id: 11393135 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 D38F3930 for ; Thu, 20 Feb 2020 02:59:29 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B0F9D24658 for ; Thu, 20 Feb 2020 02:59:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="qVsvbqCE"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mg.codeaurora.org header.i=@mg.codeaurora.org header.b="jRVZqIo9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B0F9D24658 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=KfBizovAp3JKJH4U41LyaEQ5iw+6z5W1HCLEvM76/Wg=; b=qVsvbqCEybZ5VJOL9jXZenMbQE kJHfZ8twxMrIs6lprm0a6rmWxPaoqKLcOJIcnxcZ7CBlFpkXazcRBWzIpduM+FHBALMYcVT2KKKaG PyAzNRlFUSBKAo7sp59jl9+QJmpleTa3suGINetVP0z1LCyb6Km+ThcvIGYDMXZQ2E2Ynqew7JKOl /HL3YxUdQn9DRWq+ZnV+bQjZTviSsz57PB0BkoZL9bLpTt13AxPKQFwSbVe0qU81KmWET+rgz/0dC Y4hZNslkBTpBVpRwvIK/zD6SmhFt5VugUbz60oLRuIH9kHT6XSYg6GUxXBoE10iylCuSXYu4wpEjP yAqh9qIA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j4c3k-0001oR-Gj; Thu, 20 Feb 2020 02:59:28 +0000 Received: from mail26.static.mailgun.info ([104.130.122.26]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j4c2Q-0000NJ-Ew for linux-arm-kernel@lists.infradead.org; Thu, 20 Feb 2020 02:58:13 +0000 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1582167491; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=iuWKVPRXslKzC7/ZGLleZutVx9tH9oVwDuvKGKDkAFg=; b=jRVZqIo9YUNU0U5xjbWgLTIc1EBpIgvhxvhbPPb/4OZJTDrxHth74iDTtuH3H8ahESk21hNY yrgWBNAQcfDqVJry2Iy7VfgNTKEBIouQWaQ9Zw7S3LA6q9IzJnSmO5zQTR4xysQxB2fIL+uH 1RLmMTuWKlE1zCnr5qYOcHLTbbA= X-Mailgun-Sending-Ip: 104.130.122.26 X-Mailgun-Sid: WyJiYzAxZiIsICJsaW51eC1hcm0ta2VybmVsQGxpc3RzLmluZnJhZGVhZC5vcmciLCAiYmU5ZTRhIl0= Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by mxa.mailgun.org with ESMTP id 5e4df5b4.7f59f52a8180-smtp-out-n02; Thu, 20 Feb 2020 02:57:56 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id CC099C4479F; Thu, 20 Feb 2020 02:57:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from sidgup-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sidgup) by smtp.codeaurora.org (Postfix) with ESMTPSA id 8ECE4C4479C; Thu, 20 Feb 2020 02:57:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 8ECE4C4479C Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=sidgup@codeaurora.org From: Siddharth Gupta To: agross@kernel.org, bjorn.andersson@linaro.org, ohad@wizery.com Subject: [PATCH 5/6] remoteproc: qcom: Add per subsystem SSR notification Date: Wed, 19 Feb 2020 18:57:44 -0800 Message-Id: <1582167465-2549-6-git-send-email-sidgup@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1582167465-2549-1-git-send-email-sidgup@codeaurora.org> References: <1582167465-2549-1-git-send-email-sidgup@codeaurora.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200219_185811_532879_893D42E0 X-CRM114-Status: GOOD ( 21.10 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [104.130.122.26 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: tsoni@codeaurora.org, linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, rishabhb@codeaurora.org, Siddharth Gupta , psodagud@codeaurora.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Currently there is a global notification chain which is called whenever any remoteproc shuts down. This leads to all the listeners being notified, and is not an optimal design as kernel drivers might only be interested in listening to notifications from a particular remoteproc. Create an individual notifier chain for every SSR subdevice, and modify the notification registration API to include the remoteproc struct as an argument. Update the existing user of the registration API to get the phandle of the remoteproc dt node to register for SSR notifications. Signed-off-by: Rishabh Bhatnagar Signed-off-by: Siddharth Gupta --- drivers/remoteproc/qcom_common.c | 49 +++++++++++++++++++++++++++-------- drivers/remoteproc/qcom_common.h | 1 + drivers/soc/qcom/glink_ssr.c | 20 ++++++++++++-- include/linux/remoteproc/qcom_rproc.h | 17 ++++++++---- 4 files changed, 69 insertions(+), 18 deletions(-) diff --git a/drivers/remoteproc/qcom_common.c b/drivers/remoteproc/qcom_common.c index 5d59538..6714f27 100644 --- a/drivers/remoteproc/qcom_common.c +++ b/drivers/remoteproc/qcom_common.c @@ -23,8 +23,6 @@ #define to_smd_subdev(d) container_of(d, struct qcom_rproc_subdev, subdev) #define to_ssr_subdev(d) container_of(d, struct qcom_rproc_ssr, subdev) -static BLOCKING_NOTIFIER_HEAD(ssr_notifiers); - static int glink_subdev_start(struct rproc_subdev *subdev) { struct qcom_rproc_glink *glink = to_glink_subdev(subdev); @@ -180,27 +178,52 @@ EXPORT_SYMBOL_GPL(qcom_remove_smd_subdev); /** * qcom_register_ssr_notifier() - register SSR notification handler + * @rproc: pointer to the remoteproc structure * @nb: notifier_block to notify for restart notifications * - * Returns 0 on success, negative errno on failure. + * Returns pointer to srcu notifier head on success, ERR_PTR on failure. * - * This register the @notify function as handler for restart notifications. As - * remote processors are stopped this function will be called, with the SSR - * name passed as a parameter. + * This registers the @notify function as handler for restart notifications. As + * remote processors are stopped this function will be called, with the rproc + * pointer passed as a parameter. */ -int qcom_register_ssr_notifier(struct notifier_block *nb) +void *qcom_register_ssr_notifier(struct rproc *rproc, struct notifier_block *nb) { - return blocking_notifier_chain_register(&ssr_notifiers, nb); + struct rproc_subdev *subdev; + struct qcom_rproc_ssr *ssr; + int ret; + + if (!rproc) + return ERR_PTR(-EINVAL); + + mutex_lock(&rproc->lock); + list_for_each_entry(subdev, &rproc->subdevs, node) { + ret = strcmp(subdev->name, "ssr_notifs"); + if (!ret) + break; + } + mutex_unlock(&rproc->lock); + if (ret) + return ERR_PTR(-ENOENT); + + ssr = to_ssr_subdev(subdev); + srcu_notifier_chain_register(ssr->rproc_notif_list, nb); + + return ssr->rproc_notif_list; } EXPORT_SYMBOL_GPL(qcom_register_ssr_notifier); /** * qcom_unregister_ssr_notifier() - unregister SSR notification handler + * @notify: pointer to srcu notifier head * @nb: notifier_block to unregister */ -void qcom_unregister_ssr_notifier(struct notifier_block *nb) +int qcom_unregister_ssr_notifier(void *notify, struct notifier_block *nb) { - blocking_notifier_chain_unregister(&ssr_notifiers, nb); + if (!notify) + return -EINVAL; + + return srcu_notifier_chain_unregister(notify, nb); } EXPORT_SYMBOL_GPL(qcom_unregister_ssr_notifier); @@ -208,7 +231,7 @@ static void ssr_notify_unprepare(struct rproc_subdev *subdev) { struct qcom_rproc_ssr *ssr = to_ssr_subdev(subdev); - blocking_notifier_call_chain(&ssr_notifiers, 0, (void *)ssr->name); + srcu_notifier_call_chain(ssr->rproc_notif_list, 0, (void *)ssr->name); } /** @@ -226,6 +249,9 @@ void qcom_add_ssr_subdev(struct rproc *rproc, struct qcom_rproc_ssr *ssr, ssr->name = ssr_name; ssr->subdev.name = kstrdup("ssr_notifs", GFP_KERNEL); ssr->subdev.unprepare = ssr_notify_unprepare; + ssr->rproc_notif_list = kzalloc(sizeof(struct srcu_notifier_head), + GFP_KERNEL); + srcu_init_notifier_head(ssr->rproc_notif_list); rproc_add_subdev(rproc, &ssr->subdev); } @@ -239,6 +265,7 @@ EXPORT_SYMBOL_GPL(qcom_add_ssr_subdev); void qcom_remove_ssr_subdev(struct rproc *rproc, struct qcom_rproc_ssr *ssr) { kfree(ssr->subdev.name); + kfree(ssr->rproc_notif_list); rproc_remove_subdev(rproc, &ssr->subdev); } EXPORT_SYMBOL_GPL(qcom_remove_ssr_subdev); diff --git a/drivers/remoteproc/qcom_common.h b/drivers/remoteproc/qcom_common.h index 58de71e..7792691 100644 --- a/drivers/remoteproc/qcom_common.h +++ b/drivers/remoteproc/qcom_common.h @@ -27,6 +27,7 @@ struct qcom_rproc_subdev { struct qcom_rproc_ssr { struct rproc_subdev subdev; + struct srcu_notifier_head *rproc_notif_list; const char *name; }; diff --git a/drivers/soc/qcom/glink_ssr.c b/drivers/soc/qcom/glink_ssr.c index d7babe3..2b39683 100644 --- a/drivers/soc/qcom/glink_ssr.c +++ b/drivers/soc/qcom/glink_ssr.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -49,6 +50,7 @@ struct glink_ssr { struct rpmsg_endpoint *ept; struct notifier_block nb; + void *notifier_head; u32 seq_num; struct completion completion; @@ -112,6 +114,7 @@ static int qcom_glink_ssr_notify(struct notifier_block *nb, unsigned long event, static int qcom_glink_ssr_probe(struct rpmsg_device *rpdev) { struct glink_ssr *ssr; + struct rproc *rproc; ssr = devm_kzalloc(&rpdev->dev, sizeof(*ssr), GFP_KERNEL); if (!ssr) @@ -125,14 +128,27 @@ static int qcom_glink_ssr_probe(struct rpmsg_device *rpdev) dev_set_drvdata(&rpdev->dev, ssr); - return qcom_register_ssr_notifier(&ssr->nb); + rproc = rproc_get_by_child(&rpdev->dev); + if (!rproc) { + dev_err(&rpdev->dev, "glink device not child of rproc\n"); + return -EINVAL; + } + + ssr->notifier_head = qcom_register_ssr_notifier(rproc, &ssr->nb); + if (IS_ERR(ssr->notifier_head)) { + dev_err(&rpdev->dev, + "failed to register for ssr notifications\n"); + return PTR_ERR(ssr->notifier_head); + } + + return 0; } static void qcom_glink_ssr_remove(struct rpmsg_device *rpdev) { struct glink_ssr *ssr = dev_get_drvdata(&rpdev->dev); - qcom_unregister_ssr_notifier(&ssr->nb); + qcom_unregister_ssr_notifier(ssr->notifier_head, &ssr->nb); } static const struct rpmsg_device_id qcom_glink_ssr_match[] = { diff --git a/include/linux/remoteproc/qcom_rproc.h b/include/linux/remoteproc/qcom_rproc.h index fa8e386..89e830a 100644 --- a/include/linux/remoteproc/qcom_rproc.h +++ b/include/linux/remoteproc/qcom_rproc.h @@ -2,20 +2,27 @@ #define __QCOM_RPROC_H__ struct notifier_block; +struct rproc; #if IS_ENABLED(CONFIG_QCOM_RPROC_COMMON) -int qcom_register_ssr_notifier(struct notifier_block *nb); -void qcom_unregister_ssr_notifier(struct notifier_block *nb); +void *qcom_register_ssr_notifier(struct rproc *rproc, + struct notifier_block *nb); +int qcom_unregister_ssr_notifier(void *notify, struct notifier_block *nb); #else -static inline int qcom_register_ssr_notifier(struct notifier_block *nb) +static inline void *qcom_register_ssr_notifier(struct rproc *rproc, + struct notifier_block *nb) { - return 0; + return NULL; } -static inline void qcom_unregister_ssr_notifier(struct notifier_block *nb) {} +static inline int qcom_unregister_ssr_notifier(void *notify, + struct notifier_block *nb) +{ + return 0; +} #endif From patchwork Thu Feb 20 02:57:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddharth Gupta X-Patchwork-Id: 11393107 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 998D6139A for ; Thu, 20 Feb 2020 02:58:10 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 76E5424658 for ; Thu, 20 Feb 2020 02:58:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Df51fV+w"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mg.codeaurora.org header.i=@mg.codeaurora.org header.b="Lx8OB55s" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 76E5424658 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=CFyjWr7fkYjxGCA2zsseDrEaGmDc9SytDcmDHGIdwzE=; b=Df51fV+wwfbEzJak7UNkNGngyE U9y1eQFnFu3dvcKvEuj9Ez0eHFA4/E3yACKSCuaXWqRGU8oDUDpBO8CF8OZF34G7ScCnh9WRu1Bbi cgePl5RzPDseG3p/wZKQTXP+dxPHAvqDtX373Dg5WjnWaNdxN2MTEIJGhDn6jOoHYRemCcqEtwn55 nSbpgM5YpT3dyxlR+PGD1mglWrKGwO1UrCj5oakNP0N6pMNl4ZKYrIuFbsyuRjlMxfhfjkoX7mcqR M8jDfVMeN4Q4z2eTZkA4ApLYzRdTI7KNjhP+UMJeB2sKggT777PwvIvzZAblYk+Qbv/ZgwcJ5L8KC VnxlBXPA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j4c2N-0000OV-SS; Thu, 20 Feb 2020 02:58:03 +0000 Received: from mail26.static.mailgun.info ([104.130.122.26]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j4c2K-0000NJ-5A for linux-arm-kernel@lists.infradead.org; Thu, 20 Feb 2020 02:58:01 +0000 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1582167480; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=5JIRtNHluZr5GIQ50gh49RvAzL0md3OiFBvUWmipEzo=; b=Lx8OB55sdf5aMMN1oRBXOO3FFtoo9T+uPOyQVRgdVkw7o3W+gCNf2UMXha3egguf6uDMVDol EHtrhngBUCjFOZyEK8akJu7sEZQ/W/ASUrqdZCWqQWokj/cTjBj7mCAQ91aRihu1DFNcOlO8 YA5r92B1tJeWTyDctH5gcodIP+0= X-Mailgun-Sending-Ip: 104.130.122.26 X-Mailgun-Sid: WyJiYzAxZiIsICJsaW51eC1hcm0ta2VybmVsQGxpc3RzLmluZnJhZGVhZC5vcmciLCAiYmU5ZTRhIl0= Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by mxa.mailgun.org with ESMTP id 5e4df5b6.7f8e94fc1ce0-smtp-out-n03; Thu, 20 Feb 2020 02:57:58 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id A2594C43383; Thu, 20 Feb 2020 02:57:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from sidgup-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sidgup) by smtp.codeaurora.org (Postfix) with ESMTPSA id 37EC0C447A0; Thu, 20 Feb 2020 02:57:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 37EC0C447A0 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=sidgup@codeaurora.org From: Siddharth Gupta To: agross@kernel.org, bjorn.andersson@linaro.org, ohad@wizery.com Subject: [PATCH 6/6] remoteproc: qcom: Add notification types to SSR Date: Wed, 19 Feb 2020 18:57:45 -0800 Message-Id: <1582167465-2549-7-git-send-email-sidgup@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1582167465-2549-1-git-send-email-sidgup@codeaurora.org> References: <1582167465-2549-1-git-send-email-sidgup@codeaurora.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200219_185800_367475_27DE1B97 X-CRM114-Status: GOOD ( 15.01 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [104.130.122.26 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: tsoni@codeaurora.org, linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, rishabhb@codeaurora.org, Siddharth Gupta , psodagud@codeaurora.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org The SSR subdevice only adds callback for the unprepare event. Add callbacks for unprepare, start and prepare events. The client driver for a particular remoteproc might be interested in knowing the status of the remoteproc while undergoing SSR, not just when the remoteproc has finished shutting down. Signed-off-by: Siddharth Gupta --- drivers/remoteproc/qcom_common.c | 39 +++++++++++++++++++++++++++++++++++---- include/linux/remoteproc.h | 15 +++++++++++++++ 2 files changed, 50 insertions(+), 4 deletions(-) diff --git a/drivers/remoteproc/qcom_common.c b/drivers/remoteproc/qcom_common.c index 6714f27..6f04a5b 100644 --- a/drivers/remoteproc/qcom_common.c +++ b/drivers/remoteproc/qcom_common.c @@ -183,9 +183,9 @@ EXPORT_SYMBOL_GPL(qcom_remove_smd_subdev); * * Returns pointer to srcu notifier head on success, ERR_PTR on failure. * - * This registers the @notify function as handler for restart notifications. As - * remote processors are stopped this function will be called, with the rproc - * pointer passed as a parameter. + * This registers the @notify function as handler for powerup/shutdown + * notifications. This function will be invoked inside the callbacks registered + * for the ssr subdevice, with the rproc pointer passed as a parameter. */ void *qcom_register_ssr_notifier(struct rproc *rproc, struct notifier_block *nb) { @@ -227,11 +227,39 @@ int qcom_unregister_ssr_notifier(void *notify, struct notifier_block *nb) } EXPORT_SYMBOL_GPL(qcom_unregister_ssr_notifier); +static int ssr_notify_prepare(struct rproc_subdev *subdev) +{ + struct qcom_rproc_ssr *ssr = to_ssr_subdev(subdev); + + srcu_notifier_call_chain(ssr->rproc_notif_list, + RPROC_BEFORE_POWERUP, (void *)ssr->name); + return 0; +} + +static int ssr_notify_start(struct rproc_subdev *subdev) +{ + struct qcom_rproc_ssr *ssr = to_ssr_subdev(subdev); + + srcu_notifier_call_chain(ssr->rproc_notif_list, + RPROC_AFTER_POWERUP, (void *)ssr->name); + return 0; +} + +static void ssr_notify_stop(struct rproc_subdev *subdev, bool crashed) +{ + struct qcom_rproc_ssr *ssr = to_ssr_subdev(subdev); + + srcu_notifier_call_chain(ssr->rproc_notif_list, + RPROC_BEFORE_SHUTDOWN, (void *)ssr->name); +} + + static void ssr_notify_unprepare(struct rproc_subdev *subdev) { struct qcom_rproc_ssr *ssr = to_ssr_subdev(subdev); - srcu_notifier_call_chain(ssr->rproc_notif_list, 0, (void *)ssr->name); + srcu_notifier_call_chain(ssr->rproc_notif_list, + RPROC_AFTER_SHUTDOWN, (void *)ssr->name); } /** @@ -248,6 +276,9 @@ void qcom_add_ssr_subdev(struct rproc *rproc, struct qcom_rproc_ssr *ssr, { ssr->name = ssr_name; ssr->subdev.name = kstrdup("ssr_notifs", GFP_KERNEL); + ssr->subdev.prepare = ssr_notify_prepare; + ssr->subdev.start = ssr_notify_start; + ssr->subdev.stop = ssr_notify_stop; ssr->subdev.unprepare = ssr_notify_unprepare; ssr->rproc_notif_list = kzalloc(sizeof(struct srcu_notifier_head), GFP_KERNEL); diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index e2f60cc..4be4478 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -449,6 +449,21 @@ struct rproc_dump_segment { }; /** + * enum rproc_notif_type - Different stages of remoteproc notifications + * @RPROC_BEFORE_SHUTDOWN: unprepare stage of remoteproc + * @RPROC_AFTER_SHUTDOWN: stop stage of remoteproc + * @RPROC_BEFORE_POWERUP: prepare stage of remoteproc + * @RPROC_AFTER_POWERUP: start stage of remoteproc + */ +enum rproc_notif_type { + RPROC_BEFORE_SHUTDOWN, + RPROC_AFTER_SHUTDOWN, + RPROC_BEFORE_POWERUP, + RPROC_AFTER_POWERUP, + RPROC_MAX +}; + +/** * struct rproc - represents a physical remote processor device * @node: list node of this rproc object * @domain: iommu domain