Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp177357ybv; Wed, 19 Feb 2020 18:58:35 -0800 (PST) X-Google-Smtp-Source: APXvYqyT9O+GtbZYErnV4Z2KNuga3vaIClfrU6xK9LzR1teS0lag5vjlZiihFwjtOz7fLGB0KJ+m X-Received: by 2002:aca:b70a:: with SMTP id h10mr629310oif.20.1582167515577; Wed, 19 Feb 2020 18:58:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582167515; cv=none; d=google.com; s=arc-20160816; b=MYlxbeSKaVg5KT+Yl3ZD6H8Zljnbjog4s4f10BdKLw8tYj/3x/TH3j2RPSZvpyIxcf FH5PoEdRDnSmf8Tmbs79YcAsZTcdkp2hecN5puOw0HFo9UFvHdSHAI20fOH/LSK97zpk 1+WhgZDGNThJcWis5EUJ54KQvanXX4wEnAE1J9KMpzQrmIxT2qv4UsPHdQ2v6H3a0b05 vdIIMpqpVjhk6pNORcIRpW/bmJhHc37HMAiDIOVSWTvwmoLXSTtu2BknMbCKtMMjgYzG z/7nEgbtGSBors0BzSK9MmVaamNHuap3UhtZMcnC88/EIB82c2fCPZuqO/lhHQMYJQ9A hkoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dmarc-filter:dkim-signature; bh=5JIRtNHluZr5GIQ50gh49RvAzL0md3OiFBvUWmipEzo=; b=R1+sXTveHvRn1852VGtZ8SuKJLtKORohPxy0D5CoFRGz6ip7LU4UER2F6h2yQ3relN 0NRyuvlbj1CZU2B3FzC5+ynifZby4aSpzD6Sf4E67/lpdiOqIBgjie24hScuQMVJ0gIF H28qD8G7l7zCsP5CXHCIp0EYbuMlCkd29Wmf9cDqms2ibiW2hEW3C7y+LvDc/Ziu+Qal PeDnxz+fLejju8q/z5V+uGTq1bEX/iknESVAluJoaagddAQPnErIL9eTxNXpwlDsClZS ULbRyIb7OL7EtytuZph27Z2YE/cPaY2lroiGYRagD3V/NRlV8OHjGcNmIdJ4CVy61rTt ANPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=MvYPf8Da; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w1si2595524oih.173.2020.02.19.18.58.24; Wed, 19 Feb 2020 18:58: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=fail header.i=@mg.codeaurora.org header.s=smtp header.b=MvYPf8Da; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727940AbgBTC6L (ORCPT + 99 others); Wed, 19 Feb 2020 21:58:11 -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) 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 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