From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3BB65C11D01 for ; Thu, 20 Feb 2020 02:58:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0CC102465D for ; Thu, 20 Feb 2020 02:58:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mg.codeaurora.org header.i=@mg.codeaurora.org header.b="MvYPf8Da" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728000AbgBTC6M (ORCPT ); Wed, 19 Feb 2020 21:58:12 -0500 Received: from mail26.static.mailgun.info ([104.130.122.26]:43998 "EHLO mail26.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727943AbgBTC6J (ORCPT ); Wed, 19 Feb 2020 21:58:09 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1582167488; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=5JIRtNHluZr5GIQ50gh49RvAzL0md3OiFBvUWmipEzo=; b=MvYPf8DavRoZQy/haG+KpMgXo+S8JoWvyNEuIBuOz4uyBfrxKCK/Oe2fJ67ZWHZFKJrDVGej SFM5VprYsQp0GLtZja3ZBB3wbavZahG9f+pqXbAgi6VzU4OCqFv5KhQrRHixl6xKI8QtwBMD DiLl7vlasKvnRp81Ute4yWeeCTc= X-Mailgun-Sending-Ip: 104.130.122.26 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd 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.7faad1eb2c70-smtp-out-n01; Thu, 20 Feb 2020 02:57:57 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 3E049C4479C; Thu, 20 Feb 2020 02:57:57 +0000 (UTC) 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 Cc: Siddharth Gupta , linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, tsoni@codeaurora.org, psodagud@codeaurora.org, rishabhb@codeaurora.org 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 -- Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project