All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] remoteproc: convert IPA to use new notifications
@ 2020-07-24 18:11 Alex Elder
  2020-07-24 18:11 ` [PATCH 1/2] net: ipa: new notification infrastructure Alex Elder
  2020-07-24 18:11 ` [PATCH 2/2] remoteproc: kill IPA notify code Alex Elder
  0 siblings, 2 replies; 6+ messages in thread
From: Alex Elder @ 2020-07-24 18:11 UTC (permalink / raw)
  To: bjorn.andersson, ohad, davem, kuba
  Cc: agross, evgreen, subashab, cpratapa, linux-remoteproc,
	linux-arm-msm, netdev, linux-kernel

The IPA driver needs to be notified about changes to the state of
the modem (starting, shutting down, etc.).  A notification mechanism
was put in place for that purpose, but a more general system has now
been accepted:
  https://lore.kernel.org/linux-remoteproc/1592965408-16908-1-git-send-email-rishabhb@codeaurora.org/

The first patch in this series converts the IPA driver to use the
new notification mechanism.  The second removes the temporary
system that was put in place for IPA use only.

					-Alex

  --> David:  Bjorn has agreed to take both of these patches through
      the remoteproc tree.  They should be merged together, and the
      first has a build-time dependency on patches in rproc-next.
      I'd appreciate an ack from you so he can merge it.

Alex Elder (2):
  net: ipa: new notification infrastructure
  remoteproc: kill IPA notify code

 drivers/net/ipa/ipa.h                         |  3 +
 drivers/net/ipa/ipa_modem.c                   | 56 +++++++-----
 drivers/remoteproc/Kconfig                    |  4 -
 drivers/remoteproc/Makefile                   |  1 -
 drivers/remoteproc/qcom_q6v5_ipa_notify.c     | 85 -------------------
 drivers/remoteproc/qcom_q6v5_mss.c            | 38 ---------
 .../linux/remoteproc/qcom_q6v5_ipa_notify.h   | 82 ------------------
 7 files changed, 38 insertions(+), 231 deletions(-)
 delete mode 100644 drivers/remoteproc/qcom_q6v5_ipa_notify.c
 delete mode 100644 include/linux/remoteproc/qcom_q6v5_ipa_notify.h

-- 
2.20.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] net: ipa: new notification infrastructure
  2020-07-24 18:11 [PATCH 0/2] remoteproc: convert IPA to use new notifications Alex Elder
@ 2020-07-24 18:11 ` Alex Elder
  2020-07-24 20:05   ` Bjorn Andersson
  2020-07-25  0:33   ` David Miller
  2020-07-24 18:11 ` [PATCH 2/2] remoteproc: kill IPA notify code Alex Elder
  1 sibling, 2 replies; 6+ messages in thread
From: Alex Elder @ 2020-07-24 18:11 UTC (permalink / raw)
  To: davem, kuba
  Cc: evgreen, subashab, cpratapa, bjorn.andersson, netdev, linux-kernel

Use the new SSR notifier infrastructure to request notifications of
modem events, rather than the remoteproc IPA notification system.
The latter was put in place temporarily with the knowledge that the
new mechanism would become available.

Signed-off-by: Alex Elder <elder@linaro.org>
---
David:  If you approve, please only ACK; Bjorn will merge.

 drivers/net/ipa/ipa.h       |  3 ++
 drivers/net/ipa/ipa_modem.c | 56 +++++++++++++++++++++++--------------
 2 files changed, 38 insertions(+), 21 deletions(-)

diff --git a/drivers/net/ipa/ipa.h b/drivers/net/ipa/ipa.h
index b10a853929525..55115cfb29720 100644
--- a/drivers/net/ipa/ipa.h
+++ b/drivers/net/ipa/ipa.h
@@ -10,6 +10,7 @@
 #include <linux/device.h>
 #include <linux/notifier.h>
 #include <linux/pm_wakeup.h>
+#include <linux/notifier.h>
 
 #include "ipa_version.h"
 #include "gsi.h"
@@ -73,6 +74,8 @@ struct ipa {
 	enum ipa_version version;
 	struct platform_device *pdev;
 	struct rproc *modem_rproc;
+	struct notifier_block nb;
+	void *notifier;
 	struct ipa_smp2p *smp2p;
 	struct ipa_clock *clock;
 	atomic_t suspend_ref;
diff --git a/drivers/net/ipa/ipa_modem.c b/drivers/net/ipa/ipa_modem.c
index ed10818dd99f2..e34fe2d77324e 100644
--- a/drivers/net/ipa/ipa_modem.c
+++ b/drivers/net/ipa/ipa_modem.c
@@ -9,7 +9,7 @@
 #include <linux/netdevice.h>
 #include <linux/skbuff.h>
 #include <linux/if_rmnet.h>
-#include <linux/remoteproc/qcom_q6v5_ipa_notify.h>
+#include <linux/remoteproc/qcom_rproc.h>
 
 #include "ipa.h"
 #include "ipa_data.h"
@@ -311,43 +311,40 @@ static void ipa_modem_crashed(struct ipa *ipa)
 		dev_err(dev, "error %d zeroing modem memory regions\n", ret);
 }
 
-static void ipa_modem_notify(void *data, enum qcom_rproc_event event)
+static int ipa_modem_notify(struct notifier_block *nb, unsigned long action,
+			    void *data)
 {
-	struct ipa *ipa = data;
-	struct device *dev;
+	struct ipa *ipa = container_of(nb, struct ipa, nb);
+	struct qcom_ssr_notify_data *notify_data = data;
+	struct device *dev = &ipa->pdev->dev;
 
-	dev = &ipa->pdev->dev;
-	switch (event) {
-	case MODEM_STARTING:
+	switch (action) {
+	case QCOM_SSR_BEFORE_POWERUP:
 		dev_info(dev, "received modem starting event\n");
 		ipa_smp2p_notify_reset(ipa);
 		break;
 
-	case MODEM_RUNNING:
+	case QCOM_SSR_AFTER_POWERUP:
 		dev_info(dev, "received modem running event\n");
 		break;
 
-	case MODEM_STOPPING:
-	case MODEM_CRASHED:
+	case QCOM_SSR_BEFORE_SHUTDOWN:
 		dev_info(dev, "received modem %s event\n",
-			 event == MODEM_STOPPING ? "stopping"
-						 : "crashed");
+			 notify_data->crashed ? "crashed" : "stopping");
 		if (ipa->setup_complete)
 			ipa_modem_crashed(ipa);
 		break;
 
-	case MODEM_OFFLINE:
+	case QCOM_SSR_AFTER_SHUTDOWN:
 		dev_info(dev, "received modem offline event\n");
 		break;
 
-	case MODEM_REMOVING:
-		dev_info(dev, "received modem stopping event\n");
-		break;
-
 	default:
-		dev_err(&ipa->pdev->dev, "unrecognized event %u\n", event);
+		dev_err(dev, "received unrecognized event %lu\n", action);
 		break;
 	}
+
+	return NOTIFY_OK;
 }
 
 int ipa_modem_init(struct ipa *ipa, bool modem_init)
@@ -362,13 +359,30 @@ void ipa_modem_exit(struct ipa *ipa)
 
 int ipa_modem_config(struct ipa *ipa)
 {
-	return qcom_register_ipa_notify(ipa->modem_rproc, ipa_modem_notify,
-					ipa);
+	void *notifier;
+
+	ipa->nb.notifier_call = ipa_modem_notify;
+
+	notifier = qcom_register_ssr_notifier("mpss", &ipa->nb);
+	if (IS_ERR(notifier))
+		return PTR_ERR(notifier);
+
+	ipa->notifier = notifier;
+
+	return 0;
 }
 
 void ipa_modem_deconfig(struct ipa *ipa)
 {
-	qcom_deregister_ipa_notify(ipa->modem_rproc);
+	struct device *dev = &ipa->pdev->dev;
+	int ret;
+
+	ret = qcom_unregister_ssr_notifier(ipa->notifier, &ipa->nb);
+	if (ret)
+		dev_err(dev, "error %d unregistering notifier", ret);
+
+	ipa->notifier = NULL;
+	memset(&ipa->nb, 0, sizeof(ipa->nb));
 }
 
 int ipa_modem_setup(struct ipa *ipa)
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] remoteproc: kill IPA notify code
  2020-07-24 18:11 [PATCH 0/2] remoteproc: convert IPA to use new notifications Alex Elder
  2020-07-24 18:11 ` [PATCH 1/2] net: ipa: new notification infrastructure Alex Elder
@ 2020-07-24 18:11 ` Alex Elder
  2020-07-24 20:06   ` Bjorn Andersson
  1 sibling, 1 reply; 6+ messages in thread
From: Alex Elder @ 2020-07-24 18:11 UTC (permalink / raw)
  To: bjorn.andersson, ohad
  Cc: agross, linux-remoteproc, linux-arm-msm, linux-kernel

The IPA code now uses the generic remoteproc SSR notification
mechanism.  This makes the original IPA notification code unused
and unnecessary, so get rid of it.

This is effectively a revert of commit d7f5f3c89c1a ("remoteproc:
add IPA notification to q6v5 driver").

Signed-off-by: Alex Elder <elder@linaro.org>
---
 drivers/remoteproc/Kconfig                    |  4 -
 drivers/remoteproc/Makefile                   |  1 -
 drivers/remoteproc/qcom_q6v5_ipa_notify.c     | 85 -------------------
 drivers/remoteproc/qcom_q6v5_mss.c            | 38 ---------
 .../linux/remoteproc/qcom_q6v5_ipa_notify.h   | 82 ------------------
 5 files changed, 210 deletions(-)
 delete mode 100644 drivers/remoteproc/qcom_q6v5_ipa_notify.c
 delete mode 100644 include/linux/remoteproc/qcom_q6v5_ipa_notify.h

diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
index 3e8d5d1a2b9ee..45f1f1e728823 100644
--- a/drivers/remoteproc/Kconfig
+++ b/drivers/remoteproc/Kconfig
@@ -154,7 +154,6 @@ config QCOM_Q6V5_MSS
 	select QCOM_MDT_LOADER
 	select QCOM_PIL_INFO
 	select QCOM_Q6V5_COMMON
-	select QCOM_Q6V5_IPA_NOTIFY
 	select QCOM_RPROC_COMMON
 	select QCOM_SCM
 	help
@@ -196,9 +195,6 @@ config QCOM_Q6V5_WCSS
 	  Say y here to support the Qualcomm Peripheral Image Loader for the
 	  Hexagon V5 based WCSS remote processors.
 
-config QCOM_Q6V5_IPA_NOTIFY
-	tristate
-
 config QCOM_SYSMON
 	tristate "Qualcomm sysmon driver"
 	depends on RPMSG
diff --git a/drivers/remoteproc/Makefile b/drivers/remoteproc/Makefile
index a4c1397d63673..8c056920b4006 100644
--- a/drivers/remoteproc/Makefile
+++ b/drivers/remoteproc/Makefile
@@ -24,7 +24,6 @@ obj-$(CONFIG_QCOM_Q6V5_ADSP)		+= qcom_q6v5_adsp.o
 obj-$(CONFIG_QCOM_Q6V5_MSS)		+= qcom_q6v5_mss.o
 obj-$(CONFIG_QCOM_Q6V5_PAS)		+= qcom_q6v5_pas.o
 obj-$(CONFIG_QCOM_Q6V5_WCSS)		+= qcom_q6v5_wcss.o
-obj-$(CONFIG_QCOM_Q6V5_IPA_NOTIFY)	+= qcom_q6v5_ipa_notify.o
 obj-$(CONFIG_QCOM_SYSMON)		+= qcom_sysmon.o
 obj-$(CONFIG_QCOM_WCNSS_PIL)		+= qcom_wcnss_pil.o
 qcom_wcnss_pil-y			+= qcom_wcnss.o
diff --git a/drivers/remoteproc/qcom_q6v5_ipa_notify.c b/drivers/remoteproc/qcom_q6v5_ipa_notify.c
deleted file mode 100644
index e1c10a128bfdb..0000000000000
--- a/drivers/remoteproc/qcom_q6v5_ipa_notify.c
+++ /dev/null
@@ -1,85 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-
-/*
- * Qualcomm IPA notification subdev support
- *
- * Copyright (C) 2019 Linaro Ltd.
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/remoteproc.h>
-#include <linux/remoteproc/qcom_q6v5_ipa_notify.h>
-
-static void
-ipa_notify_common(struct rproc_subdev *subdev, enum qcom_rproc_event event)
-{
-	struct qcom_rproc_ipa_notify *ipa_notify;
-	qcom_ipa_notify_t notify;
-
-	ipa_notify = container_of(subdev, struct qcom_rproc_ipa_notify, subdev);
-	notify = ipa_notify->notify;
-	if (notify)
-		notify(ipa_notify->data, event);
-}
-
-static int ipa_notify_prepare(struct rproc_subdev *subdev)
-{
-	ipa_notify_common(subdev, MODEM_STARTING);
-
-	return 0;
-}
-
-static int ipa_notify_start(struct rproc_subdev *subdev)
-{
-	ipa_notify_common(subdev, MODEM_RUNNING);
-
-	return 0;
-}
-
-static void ipa_notify_stop(struct rproc_subdev *subdev, bool crashed)
-
-{
-	ipa_notify_common(subdev, crashed ? MODEM_CRASHED : MODEM_STOPPING);
-}
-
-static void ipa_notify_unprepare(struct rproc_subdev *subdev)
-{
-	ipa_notify_common(subdev, MODEM_OFFLINE);
-}
-
-static void ipa_notify_removing(struct rproc_subdev *subdev)
-{
-	ipa_notify_common(subdev, MODEM_REMOVING);
-}
-
-/* Register the IPA notification subdevice with the Q6V5 MSS remoteproc */
-void qcom_add_ipa_notify_subdev(struct rproc *rproc,
-		struct qcom_rproc_ipa_notify *ipa_notify)
-{
-	ipa_notify->notify = NULL;
-	ipa_notify->data = NULL;
-	ipa_notify->subdev.prepare = ipa_notify_prepare;
-	ipa_notify->subdev.start = ipa_notify_start;
-	ipa_notify->subdev.stop = ipa_notify_stop;
-	ipa_notify->subdev.unprepare = ipa_notify_unprepare;
-
-	rproc_add_subdev(rproc, &ipa_notify->subdev);
-}
-EXPORT_SYMBOL_GPL(qcom_add_ipa_notify_subdev);
-
-/* Remove the IPA notification subdevice */
-void qcom_remove_ipa_notify_subdev(struct rproc *rproc,
-		struct qcom_rproc_ipa_notify *ipa_notify)
-{
-	struct rproc_subdev *subdev = &ipa_notify->subdev;
-
-	ipa_notify_removing(subdev);
-
-	rproc_remove_subdev(rproc, subdev);
-	ipa_notify->notify = NULL;	/* Make it obvious */
-}
-EXPORT_SYMBOL_GPL(qcom_remove_ipa_notify_subdev);
-
-MODULE_LICENSE("GPL v2");
-MODULE_DESCRIPTION("Qualcomm IPA notification remoteproc subdev");
diff --git a/drivers/remoteproc/qcom_q6v5_mss.c b/drivers/remoteproc/qcom_q6v5_mss.c
index 718acebae777f..eb2a0d7dea1c7 100644
--- a/drivers/remoteproc/qcom_q6v5_mss.c
+++ b/drivers/remoteproc/qcom_q6v5_mss.c
@@ -23,7 +23,6 @@
 #include <linux/regmap.h>
 #include <linux/regulator/consumer.h>
 #include <linux/remoteproc.h>
-#include "linux/remoteproc/qcom_q6v5_ipa_notify.h"
 #include <linux/reset.h>
 #include <linux/soc/qcom/mdt_loader.h>
 #include <linux/iopoll.h>
@@ -199,7 +198,6 @@ struct q6v5 {
 	struct qcom_rproc_glink glink_subdev;
 	struct qcom_rproc_subdev smd_subdev;
 	struct qcom_rproc_ssr ssr_subdev;
-	struct qcom_rproc_ipa_notify ipa_notify_subdev;
 	struct qcom_sysmon *sysmon;
 	bool need_mem_protection;
 	bool has_alt_reset;
@@ -1585,39 +1583,6 @@ static int q6v5_alloc_memory_region(struct q6v5 *qproc)
 	return 0;
 }
 
-#if IS_ENABLED(CONFIG_QCOM_Q6V5_IPA_NOTIFY)
-
-/* Register IPA notification function */
-int qcom_register_ipa_notify(struct rproc *rproc, qcom_ipa_notify_t notify,
-			     void *data)
-{
-	struct qcom_rproc_ipa_notify *ipa_notify;
-	struct q6v5 *qproc = rproc->priv;
-
-	if (!notify)
-		return -EINVAL;
-
-	ipa_notify = &qproc->ipa_notify_subdev;
-	if (ipa_notify->notify)
-		return -EBUSY;
-
-	ipa_notify->notify = notify;
-	ipa_notify->data = data;
-
-	return 0;
-}
-EXPORT_SYMBOL_GPL(qcom_register_ipa_notify);
-
-/* Deregister IPA notification function */
-void qcom_deregister_ipa_notify(struct rproc *rproc)
-{
-	struct q6v5 *qproc = rproc->priv;
-
-	qproc->ipa_notify_subdev.notify = NULL;
-}
-EXPORT_SYMBOL_GPL(qcom_deregister_ipa_notify);
-#endif /* !IS_ENABLED(CONFIG_QCOM_Q6V5_IPA_NOTIFY) */
-
 static int q6v5_probe(struct platform_device *pdev)
 {
 	const struct rproc_hexagon_res *desc;
@@ -1744,7 +1709,6 @@ static int q6v5_probe(struct platform_device *pdev)
 	qcom_add_glink_subdev(rproc, &qproc->glink_subdev, "mpss");
 	qcom_add_smd_subdev(rproc, &qproc->smd_subdev);
 	qcom_add_ssr_subdev(rproc, &qproc->ssr_subdev, "mpss");
-	qcom_add_ipa_notify_subdev(rproc, &qproc->ipa_notify_subdev);
 	qproc->sysmon = qcom_add_sysmon_subdev(rproc, "modem", 0x12);
 	if (IS_ERR(qproc->sysmon)) {
 		ret = PTR_ERR(qproc->sysmon);
@@ -1760,7 +1724,6 @@ static int q6v5_probe(struct platform_device *pdev)
 remove_sysmon_subdev:
 	qcom_remove_sysmon_subdev(qproc->sysmon);
 remove_subdevs:
-	qcom_remove_ipa_notify_subdev(qproc->rproc, &qproc->ipa_notify_subdev);
 	qcom_remove_ssr_subdev(rproc, &qproc->ssr_subdev);
 	qcom_remove_smd_subdev(rproc, &qproc->smd_subdev);
 	qcom_remove_glink_subdev(rproc, &qproc->glink_subdev);
@@ -1782,7 +1745,6 @@ static int q6v5_remove(struct platform_device *pdev)
 	rproc_del(rproc);
 
 	qcom_remove_sysmon_subdev(qproc->sysmon);
-	qcom_remove_ipa_notify_subdev(rproc, &qproc->ipa_notify_subdev);
 	qcom_remove_ssr_subdev(rproc, &qproc->ssr_subdev);
 	qcom_remove_smd_subdev(rproc, &qproc->smd_subdev);
 	qcom_remove_glink_subdev(rproc, &qproc->glink_subdev);
diff --git a/include/linux/remoteproc/qcom_q6v5_ipa_notify.h b/include/linux/remoteproc/qcom_q6v5_ipa_notify.h
deleted file mode 100644
index 0820edc0ab7df..0000000000000
--- a/include/linux/remoteproc/qcom_q6v5_ipa_notify.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-
-/* Copyright (C) 2019 Linaro Ltd. */
-
-#ifndef __QCOM_Q6V5_IPA_NOTIFY_H__
-#define __QCOM_Q6V5_IPA_NOTIFY_H__
-
-#if IS_ENABLED(CONFIG_QCOM_Q6V5_IPA_NOTIFY)
-
-#include <linux/remoteproc.h>
-
-enum qcom_rproc_event {
-	MODEM_STARTING	= 0,	/* Modem is about to be started */
-	MODEM_RUNNING	= 1,	/* Startup complete; modem is operational */
-	MODEM_STOPPING	= 2,	/* Modem is about to shut down */
-	MODEM_CRASHED	= 3,	/* Modem has crashed (implies stopping) */
-	MODEM_OFFLINE	= 4,	/* Modem is now offline */
-	MODEM_REMOVING	= 5,	/* Modem is about to be removed */
-};
-
-typedef void (*qcom_ipa_notify_t)(void *data, enum qcom_rproc_event event);
-
-struct qcom_rproc_ipa_notify {
-	struct rproc_subdev subdev;
-
-	qcom_ipa_notify_t notify;
-	void *data;
-};
-
-/**
- * qcom_add_ipa_notify_subdev() - Register IPA notification subdevice
- * @rproc:	rproc handle
- * @ipa_notify:	IPA notification subdevice handle
- *
- * Register the @ipa_notify subdevice with the @rproc so modem events
- * can be sent to IPA when they occur.
- *
- * This is defined in "qcom_q6v5_ipa_notify.c".
- */
-void qcom_add_ipa_notify_subdev(struct rproc *rproc,
-		struct qcom_rproc_ipa_notify *ipa_notify);
-
-/**
- * qcom_remove_ipa_notify_subdev() - Remove IPA SSR subdevice
- * @rproc:	rproc handle
- * @ipa_notify:	IPA notification subdevice handle
- *
- * This is defined in "qcom_q6v5_ipa_notify.c".
- */
-void qcom_remove_ipa_notify_subdev(struct rproc *rproc,
-		struct qcom_rproc_ipa_notify *ipa_notify);
-
-/**
- * qcom_register_ipa_notify() - Register IPA notification function
- * @rproc:	Remote processor handle
- * @notify:	Non-null IPA notification callback function pointer
- * @data:	Data supplied to IPA notification callback function
- *
- * @Return: 0 if successful, or a negative error code otherwise
- *
- * This is defined in "qcom_q6v5_mss.c".
- */
-int qcom_register_ipa_notify(struct rproc *rproc, qcom_ipa_notify_t notify,
-			     void *data);
-/**
- * qcom_deregister_ipa_notify() - Deregister IPA notification function
- * @rproc:	Remote processor handle
- *
- * This is defined in "qcom_q6v5_mss.c".
- */
-void qcom_deregister_ipa_notify(struct rproc *rproc);
-
-#else /* !IS_ENABLED(CONFIG_QCOM_Q6V5_IPA_NOTIFY) */
-
-struct qcom_rproc_ipa_notify { /* empty */ };
-
-#define qcom_add_ipa_notify_subdev(rproc, ipa_notify)		/* no-op */
-#define qcom_remove_ipa_notify_subdev(rproc, ipa_notify)	/* no-op */
-
-#endif /* !IS_ENABLED(CONFIG_QCOM_Q6V5_IPA_NOTIFY) */
-
-#endif /* !__QCOM_Q6V5_IPA_NOTIFY_H__ */
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] net: ipa: new notification infrastructure
  2020-07-24 18:11 ` [PATCH 1/2] net: ipa: new notification infrastructure Alex Elder
@ 2020-07-24 20:05   ` Bjorn Andersson
  2020-07-25  0:33   ` David Miller
  1 sibling, 0 replies; 6+ messages in thread
From: Bjorn Andersson @ 2020-07-24 20:05 UTC (permalink / raw)
  To: Alex Elder; +Cc: davem, kuba, evgreen, subashab, cpratapa, netdev, linux-kernel

On Fri 24 Jul 11:11 PDT 2020, Alex Elder wrote:

> Use the new SSR notifier infrastructure to request notifications of
> modem events, rather than the remoteproc IPA notification system.
> The latter was put in place temporarily with the knowledge that the
> new mechanism would become available.
> 

Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>

> Signed-off-by: Alex Elder <elder@linaro.org>
> ---
> David:  If you approve, please only ACK; Bjorn will merge.
> 

David, this depends on changes I carry in the rproc-next tree, so if
you're okay with it I can pick this patch through my tree.

Otherwise it will have to wait until 5.9 is out and I won't be able to
remove the old ipa_notify code that this depends on until 5.11...

Thanks,
Bjorn

>  drivers/net/ipa/ipa.h       |  3 ++
>  drivers/net/ipa/ipa_modem.c | 56 +++++++++++++++++++++++--------------
>  2 files changed, 38 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/net/ipa/ipa.h b/drivers/net/ipa/ipa.h
> index b10a853929525..55115cfb29720 100644
> --- a/drivers/net/ipa/ipa.h
> +++ b/drivers/net/ipa/ipa.h
> @@ -10,6 +10,7 @@
>  #include <linux/device.h>
>  #include <linux/notifier.h>
>  #include <linux/pm_wakeup.h>
> +#include <linux/notifier.h>
>  
>  #include "ipa_version.h"
>  #include "gsi.h"
> @@ -73,6 +74,8 @@ struct ipa {
>  	enum ipa_version version;
>  	struct platform_device *pdev;
>  	struct rproc *modem_rproc;
> +	struct notifier_block nb;
> +	void *notifier;
>  	struct ipa_smp2p *smp2p;
>  	struct ipa_clock *clock;
>  	atomic_t suspend_ref;
> diff --git a/drivers/net/ipa/ipa_modem.c b/drivers/net/ipa/ipa_modem.c
> index ed10818dd99f2..e34fe2d77324e 100644
> --- a/drivers/net/ipa/ipa_modem.c
> +++ b/drivers/net/ipa/ipa_modem.c
> @@ -9,7 +9,7 @@
>  #include <linux/netdevice.h>
>  #include <linux/skbuff.h>
>  #include <linux/if_rmnet.h>
> -#include <linux/remoteproc/qcom_q6v5_ipa_notify.h>
> +#include <linux/remoteproc/qcom_rproc.h>
>  
>  #include "ipa.h"
>  #include "ipa_data.h"
> @@ -311,43 +311,40 @@ static void ipa_modem_crashed(struct ipa *ipa)
>  		dev_err(dev, "error %d zeroing modem memory regions\n", ret);
>  }
>  
> -static void ipa_modem_notify(void *data, enum qcom_rproc_event event)
> +static int ipa_modem_notify(struct notifier_block *nb, unsigned long action,
> +			    void *data)
>  {
> -	struct ipa *ipa = data;
> -	struct device *dev;
> +	struct ipa *ipa = container_of(nb, struct ipa, nb);
> +	struct qcom_ssr_notify_data *notify_data = data;
> +	struct device *dev = &ipa->pdev->dev;
>  
> -	dev = &ipa->pdev->dev;
> -	switch (event) {
> -	case MODEM_STARTING:
> +	switch (action) {
> +	case QCOM_SSR_BEFORE_POWERUP:
>  		dev_info(dev, "received modem starting event\n");
>  		ipa_smp2p_notify_reset(ipa);
>  		break;
>  
> -	case MODEM_RUNNING:
> +	case QCOM_SSR_AFTER_POWERUP:
>  		dev_info(dev, "received modem running event\n");
>  		break;
>  
> -	case MODEM_STOPPING:
> -	case MODEM_CRASHED:
> +	case QCOM_SSR_BEFORE_SHUTDOWN:
>  		dev_info(dev, "received modem %s event\n",
> -			 event == MODEM_STOPPING ? "stopping"
> -						 : "crashed");
> +			 notify_data->crashed ? "crashed" : "stopping");
>  		if (ipa->setup_complete)
>  			ipa_modem_crashed(ipa);
>  		break;
>  
> -	case MODEM_OFFLINE:
> +	case QCOM_SSR_AFTER_SHUTDOWN:
>  		dev_info(dev, "received modem offline event\n");
>  		break;
>  
> -	case MODEM_REMOVING:
> -		dev_info(dev, "received modem stopping event\n");
> -		break;
> -
>  	default:
> -		dev_err(&ipa->pdev->dev, "unrecognized event %u\n", event);
> +		dev_err(dev, "received unrecognized event %lu\n", action);
>  		break;
>  	}
> +
> +	return NOTIFY_OK;
>  }
>  
>  int ipa_modem_init(struct ipa *ipa, bool modem_init)
> @@ -362,13 +359,30 @@ void ipa_modem_exit(struct ipa *ipa)
>  
>  int ipa_modem_config(struct ipa *ipa)
>  {
> -	return qcom_register_ipa_notify(ipa->modem_rproc, ipa_modem_notify,
> -					ipa);
> +	void *notifier;
> +
> +	ipa->nb.notifier_call = ipa_modem_notify;
> +
> +	notifier = qcom_register_ssr_notifier("mpss", &ipa->nb);
> +	if (IS_ERR(notifier))
> +		return PTR_ERR(notifier);
> +
> +	ipa->notifier = notifier;
> +
> +	return 0;
>  }
>  
>  void ipa_modem_deconfig(struct ipa *ipa)
>  {
> -	qcom_deregister_ipa_notify(ipa->modem_rproc);
> +	struct device *dev = &ipa->pdev->dev;
> +	int ret;
> +
> +	ret = qcom_unregister_ssr_notifier(ipa->notifier, &ipa->nb);
> +	if (ret)
> +		dev_err(dev, "error %d unregistering notifier", ret);
> +
> +	ipa->notifier = NULL;
> +	memset(&ipa->nb, 0, sizeof(ipa->nb));
>  }
>  
>  int ipa_modem_setup(struct ipa *ipa)
> -- 
> 2.20.1
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] remoteproc: kill IPA notify code
  2020-07-24 18:11 ` [PATCH 2/2] remoteproc: kill IPA notify code Alex Elder
@ 2020-07-24 20:06   ` Bjorn Andersson
  0 siblings, 0 replies; 6+ messages in thread
From: Bjorn Andersson @ 2020-07-24 20:06 UTC (permalink / raw)
  To: Alex Elder; +Cc: ohad, agross, linux-remoteproc, linux-arm-msm, linux-kernel

On Fri 24 Jul 11:11 PDT 2020, Alex Elder wrote:

> The IPA code now uses the generic remoteproc SSR notification
> mechanism.  This makes the original IPA notification code unused
> and unnecessary, so get rid of it.
> 
> This is effectively a revert of commit d7f5f3c89c1a ("remoteproc:
> add IPA notification to q6v5 driver").
> 
> Signed-off-by: Alex Elder <elder@linaro.org>

Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>

Regards,
Bjorn

> ---
>  drivers/remoteproc/Kconfig                    |  4 -
>  drivers/remoteproc/Makefile                   |  1 -
>  drivers/remoteproc/qcom_q6v5_ipa_notify.c     | 85 -------------------
>  drivers/remoteproc/qcom_q6v5_mss.c            | 38 ---------
>  .../linux/remoteproc/qcom_q6v5_ipa_notify.h   | 82 ------------------
>  5 files changed, 210 deletions(-)
>  delete mode 100644 drivers/remoteproc/qcom_q6v5_ipa_notify.c
>  delete mode 100644 include/linux/remoteproc/qcom_q6v5_ipa_notify.h
> 
> diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
> index 3e8d5d1a2b9ee..45f1f1e728823 100644
> --- a/drivers/remoteproc/Kconfig
> +++ b/drivers/remoteproc/Kconfig
> @@ -154,7 +154,6 @@ config QCOM_Q6V5_MSS
>  	select QCOM_MDT_LOADER
>  	select QCOM_PIL_INFO
>  	select QCOM_Q6V5_COMMON
> -	select QCOM_Q6V5_IPA_NOTIFY
>  	select QCOM_RPROC_COMMON
>  	select QCOM_SCM
>  	help
> @@ -196,9 +195,6 @@ config QCOM_Q6V5_WCSS
>  	  Say y here to support the Qualcomm Peripheral Image Loader for the
>  	  Hexagon V5 based WCSS remote processors.
>  
> -config QCOM_Q6V5_IPA_NOTIFY
> -	tristate
> -
>  config QCOM_SYSMON
>  	tristate "Qualcomm sysmon driver"
>  	depends on RPMSG
> diff --git a/drivers/remoteproc/Makefile b/drivers/remoteproc/Makefile
> index a4c1397d63673..8c056920b4006 100644
> --- a/drivers/remoteproc/Makefile
> +++ b/drivers/remoteproc/Makefile
> @@ -24,7 +24,6 @@ obj-$(CONFIG_QCOM_Q6V5_ADSP)		+= qcom_q6v5_adsp.o
>  obj-$(CONFIG_QCOM_Q6V5_MSS)		+= qcom_q6v5_mss.o
>  obj-$(CONFIG_QCOM_Q6V5_PAS)		+= qcom_q6v5_pas.o
>  obj-$(CONFIG_QCOM_Q6V5_WCSS)		+= qcom_q6v5_wcss.o
> -obj-$(CONFIG_QCOM_Q6V5_IPA_NOTIFY)	+= qcom_q6v5_ipa_notify.o
>  obj-$(CONFIG_QCOM_SYSMON)		+= qcom_sysmon.o
>  obj-$(CONFIG_QCOM_WCNSS_PIL)		+= qcom_wcnss_pil.o
>  qcom_wcnss_pil-y			+= qcom_wcnss.o
> diff --git a/drivers/remoteproc/qcom_q6v5_ipa_notify.c b/drivers/remoteproc/qcom_q6v5_ipa_notify.c
> deleted file mode 100644
> index e1c10a128bfdb..0000000000000
> --- a/drivers/remoteproc/qcom_q6v5_ipa_notify.c
> +++ /dev/null
> @@ -1,85 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0
> -
> -/*
> - * Qualcomm IPA notification subdev support
> - *
> - * Copyright (C) 2019 Linaro Ltd.
> - */
> -
> -#include <linux/kernel.h>
> -#include <linux/module.h>
> -#include <linux/remoteproc.h>
> -#include <linux/remoteproc/qcom_q6v5_ipa_notify.h>
> -
> -static void
> -ipa_notify_common(struct rproc_subdev *subdev, enum qcom_rproc_event event)
> -{
> -	struct qcom_rproc_ipa_notify *ipa_notify;
> -	qcom_ipa_notify_t notify;
> -
> -	ipa_notify = container_of(subdev, struct qcom_rproc_ipa_notify, subdev);
> -	notify = ipa_notify->notify;
> -	if (notify)
> -		notify(ipa_notify->data, event);
> -}
> -
> -static int ipa_notify_prepare(struct rproc_subdev *subdev)
> -{
> -	ipa_notify_common(subdev, MODEM_STARTING);
> -
> -	return 0;
> -}
> -
> -static int ipa_notify_start(struct rproc_subdev *subdev)
> -{
> -	ipa_notify_common(subdev, MODEM_RUNNING);
> -
> -	return 0;
> -}
> -
> -static void ipa_notify_stop(struct rproc_subdev *subdev, bool crashed)
> -
> -{
> -	ipa_notify_common(subdev, crashed ? MODEM_CRASHED : MODEM_STOPPING);
> -}
> -
> -static void ipa_notify_unprepare(struct rproc_subdev *subdev)
> -{
> -	ipa_notify_common(subdev, MODEM_OFFLINE);
> -}
> -
> -static void ipa_notify_removing(struct rproc_subdev *subdev)
> -{
> -	ipa_notify_common(subdev, MODEM_REMOVING);
> -}
> -
> -/* Register the IPA notification subdevice with the Q6V5 MSS remoteproc */
> -void qcom_add_ipa_notify_subdev(struct rproc *rproc,
> -		struct qcom_rproc_ipa_notify *ipa_notify)
> -{
> -	ipa_notify->notify = NULL;
> -	ipa_notify->data = NULL;
> -	ipa_notify->subdev.prepare = ipa_notify_prepare;
> -	ipa_notify->subdev.start = ipa_notify_start;
> -	ipa_notify->subdev.stop = ipa_notify_stop;
> -	ipa_notify->subdev.unprepare = ipa_notify_unprepare;
> -
> -	rproc_add_subdev(rproc, &ipa_notify->subdev);
> -}
> -EXPORT_SYMBOL_GPL(qcom_add_ipa_notify_subdev);
> -
> -/* Remove the IPA notification subdevice */
> -void qcom_remove_ipa_notify_subdev(struct rproc *rproc,
> -		struct qcom_rproc_ipa_notify *ipa_notify)
> -{
> -	struct rproc_subdev *subdev = &ipa_notify->subdev;
> -
> -	ipa_notify_removing(subdev);
> -
> -	rproc_remove_subdev(rproc, subdev);
> -	ipa_notify->notify = NULL;	/* Make it obvious */
> -}
> -EXPORT_SYMBOL_GPL(qcom_remove_ipa_notify_subdev);
> -
> -MODULE_LICENSE("GPL v2");
> -MODULE_DESCRIPTION("Qualcomm IPA notification remoteproc subdev");
> diff --git a/drivers/remoteproc/qcom_q6v5_mss.c b/drivers/remoteproc/qcom_q6v5_mss.c
> index 718acebae777f..eb2a0d7dea1c7 100644
> --- a/drivers/remoteproc/qcom_q6v5_mss.c
> +++ b/drivers/remoteproc/qcom_q6v5_mss.c
> @@ -23,7 +23,6 @@
>  #include <linux/regmap.h>
>  #include <linux/regulator/consumer.h>
>  #include <linux/remoteproc.h>
> -#include "linux/remoteproc/qcom_q6v5_ipa_notify.h"
>  #include <linux/reset.h>
>  #include <linux/soc/qcom/mdt_loader.h>
>  #include <linux/iopoll.h>
> @@ -199,7 +198,6 @@ struct q6v5 {
>  	struct qcom_rproc_glink glink_subdev;
>  	struct qcom_rproc_subdev smd_subdev;
>  	struct qcom_rproc_ssr ssr_subdev;
> -	struct qcom_rproc_ipa_notify ipa_notify_subdev;
>  	struct qcom_sysmon *sysmon;
>  	bool need_mem_protection;
>  	bool has_alt_reset;
> @@ -1585,39 +1583,6 @@ static int q6v5_alloc_memory_region(struct q6v5 *qproc)
>  	return 0;
>  }
>  
> -#if IS_ENABLED(CONFIG_QCOM_Q6V5_IPA_NOTIFY)
> -
> -/* Register IPA notification function */
> -int qcom_register_ipa_notify(struct rproc *rproc, qcom_ipa_notify_t notify,
> -			     void *data)
> -{
> -	struct qcom_rproc_ipa_notify *ipa_notify;
> -	struct q6v5 *qproc = rproc->priv;
> -
> -	if (!notify)
> -		return -EINVAL;
> -
> -	ipa_notify = &qproc->ipa_notify_subdev;
> -	if (ipa_notify->notify)
> -		return -EBUSY;
> -
> -	ipa_notify->notify = notify;
> -	ipa_notify->data = data;
> -
> -	return 0;
> -}
> -EXPORT_SYMBOL_GPL(qcom_register_ipa_notify);
> -
> -/* Deregister IPA notification function */
> -void qcom_deregister_ipa_notify(struct rproc *rproc)
> -{
> -	struct q6v5 *qproc = rproc->priv;
> -
> -	qproc->ipa_notify_subdev.notify = NULL;
> -}
> -EXPORT_SYMBOL_GPL(qcom_deregister_ipa_notify);
> -#endif /* !IS_ENABLED(CONFIG_QCOM_Q6V5_IPA_NOTIFY) */
> -
>  static int q6v5_probe(struct platform_device *pdev)
>  {
>  	const struct rproc_hexagon_res *desc;
> @@ -1744,7 +1709,6 @@ static int q6v5_probe(struct platform_device *pdev)
>  	qcom_add_glink_subdev(rproc, &qproc->glink_subdev, "mpss");
>  	qcom_add_smd_subdev(rproc, &qproc->smd_subdev);
>  	qcom_add_ssr_subdev(rproc, &qproc->ssr_subdev, "mpss");
> -	qcom_add_ipa_notify_subdev(rproc, &qproc->ipa_notify_subdev);
>  	qproc->sysmon = qcom_add_sysmon_subdev(rproc, "modem", 0x12);
>  	if (IS_ERR(qproc->sysmon)) {
>  		ret = PTR_ERR(qproc->sysmon);
> @@ -1760,7 +1724,6 @@ static int q6v5_probe(struct platform_device *pdev)
>  remove_sysmon_subdev:
>  	qcom_remove_sysmon_subdev(qproc->sysmon);
>  remove_subdevs:
> -	qcom_remove_ipa_notify_subdev(qproc->rproc, &qproc->ipa_notify_subdev);
>  	qcom_remove_ssr_subdev(rproc, &qproc->ssr_subdev);
>  	qcom_remove_smd_subdev(rproc, &qproc->smd_subdev);
>  	qcom_remove_glink_subdev(rproc, &qproc->glink_subdev);
> @@ -1782,7 +1745,6 @@ static int q6v5_remove(struct platform_device *pdev)
>  	rproc_del(rproc);
>  
>  	qcom_remove_sysmon_subdev(qproc->sysmon);
> -	qcom_remove_ipa_notify_subdev(rproc, &qproc->ipa_notify_subdev);
>  	qcom_remove_ssr_subdev(rproc, &qproc->ssr_subdev);
>  	qcom_remove_smd_subdev(rproc, &qproc->smd_subdev);
>  	qcom_remove_glink_subdev(rproc, &qproc->glink_subdev);
> diff --git a/include/linux/remoteproc/qcom_q6v5_ipa_notify.h b/include/linux/remoteproc/qcom_q6v5_ipa_notify.h
> deleted file mode 100644
> index 0820edc0ab7df..0000000000000
> --- a/include/linux/remoteproc/qcom_q6v5_ipa_notify.h
> +++ /dev/null
> @@ -1,82 +0,0 @@
> -/* SPDX-License-Identifier: GPL-2.0 */
> -
> -/* Copyright (C) 2019 Linaro Ltd. */
> -
> -#ifndef __QCOM_Q6V5_IPA_NOTIFY_H__
> -#define __QCOM_Q6V5_IPA_NOTIFY_H__
> -
> -#if IS_ENABLED(CONFIG_QCOM_Q6V5_IPA_NOTIFY)
> -
> -#include <linux/remoteproc.h>
> -
> -enum qcom_rproc_event {
> -	MODEM_STARTING	= 0,	/* Modem is about to be started */
> -	MODEM_RUNNING	= 1,	/* Startup complete; modem is operational */
> -	MODEM_STOPPING	= 2,	/* Modem is about to shut down */
> -	MODEM_CRASHED	= 3,	/* Modem has crashed (implies stopping) */
> -	MODEM_OFFLINE	= 4,	/* Modem is now offline */
> -	MODEM_REMOVING	= 5,	/* Modem is about to be removed */
> -};
> -
> -typedef void (*qcom_ipa_notify_t)(void *data, enum qcom_rproc_event event);
> -
> -struct qcom_rproc_ipa_notify {
> -	struct rproc_subdev subdev;
> -
> -	qcom_ipa_notify_t notify;
> -	void *data;
> -};
> -
> -/**
> - * qcom_add_ipa_notify_subdev() - Register IPA notification subdevice
> - * @rproc:	rproc handle
> - * @ipa_notify:	IPA notification subdevice handle
> - *
> - * Register the @ipa_notify subdevice with the @rproc so modem events
> - * can be sent to IPA when they occur.
> - *
> - * This is defined in "qcom_q6v5_ipa_notify.c".
> - */
> -void qcom_add_ipa_notify_subdev(struct rproc *rproc,
> -		struct qcom_rproc_ipa_notify *ipa_notify);
> -
> -/**
> - * qcom_remove_ipa_notify_subdev() - Remove IPA SSR subdevice
> - * @rproc:	rproc handle
> - * @ipa_notify:	IPA notification subdevice handle
> - *
> - * This is defined in "qcom_q6v5_ipa_notify.c".
> - */
> -void qcom_remove_ipa_notify_subdev(struct rproc *rproc,
> -		struct qcom_rproc_ipa_notify *ipa_notify);
> -
> -/**
> - * qcom_register_ipa_notify() - Register IPA notification function
> - * @rproc:	Remote processor handle
> - * @notify:	Non-null IPA notification callback function pointer
> - * @data:	Data supplied to IPA notification callback function
> - *
> - * @Return: 0 if successful, or a negative error code otherwise
> - *
> - * This is defined in "qcom_q6v5_mss.c".
> - */
> -int qcom_register_ipa_notify(struct rproc *rproc, qcom_ipa_notify_t notify,
> -			     void *data);
> -/**
> - * qcom_deregister_ipa_notify() - Deregister IPA notification function
> - * @rproc:	Remote processor handle
> - *
> - * This is defined in "qcom_q6v5_mss.c".
> - */
> -void qcom_deregister_ipa_notify(struct rproc *rproc);
> -
> -#else /* !IS_ENABLED(CONFIG_QCOM_Q6V5_IPA_NOTIFY) */
> -
> -struct qcom_rproc_ipa_notify { /* empty */ };
> -
> -#define qcom_add_ipa_notify_subdev(rproc, ipa_notify)		/* no-op */
> -#define qcom_remove_ipa_notify_subdev(rproc, ipa_notify)	/* no-op */
> -
> -#endif /* !IS_ENABLED(CONFIG_QCOM_Q6V5_IPA_NOTIFY) */
> -
> -#endif /* !__QCOM_Q6V5_IPA_NOTIFY_H__ */
> -- 
> 2.20.1
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] net: ipa: new notification infrastructure
  2020-07-24 18:11 ` [PATCH 1/2] net: ipa: new notification infrastructure Alex Elder
  2020-07-24 20:05   ` Bjorn Andersson
@ 2020-07-25  0:33   ` David Miller
  1 sibling, 0 replies; 6+ messages in thread
From: David Miller @ 2020-07-25  0:33 UTC (permalink / raw)
  To: elder
  Cc: kuba, evgreen, subashab, cpratapa, bjorn.andersson, netdev, linux-kernel

From: Alex Elder <elder@linaro.org>
Date: Fri, 24 Jul 2020 13:11:41 -0500

> Use the new SSR notifier infrastructure to request notifications of
> modem events, rather than the remoteproc IPA notification system.
> The latter was put in place temporarily with the knowledge that the
> new mechanism would become available.
> 
> Signed-off-by: Alex Elder <elder@linaro.org>
> ---
> David:  If you approve, please only ACK; Bjorn will merge.

Acked-by: David S. Miller <davem@davemloft.net>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-07-25  0:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-24 18:11 [PATCH 0/2] remoteproc: convert IPA to use new notifications Alex Elder
2020-07-24 18:11 ` [PATCH 1/2] net: ipa: new notification infrastructure Alex Elder
2020-07-24 20:05   ` Bjorn Andersson
2020-07-25  0:33   ` David Miller
2020-07-24 18:11 ` [PATCH 2/2] remoteproc: kill IPA notify code Alex Elder
2020-07-24 20:06   ` Bjorn Andersson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.