浏览代码

Merge "ipa: Add late init module"

qctecmdr 4 年之前
父节点
当前提交
01e242c631

+ 3 - 0
drivers/platform/msm/ipa/Makefile

@@ -45,7 +45,10 @@ ipam-$(CONFIG_IPA_UT) += test/ipa_ut_framework.o test/ipa_test_example.o \
 	test/ipa_test_hw_stats.o test/ipa_pm_ut.o \
 	test/ipa_test_wdi3.o
 
+ipanetm-y += ipa_v3/ipa_net.o
+
 obj-$(CONFIG_IPA3) += ipam.o
+obj-$(CONFIG_IPA3) += ipanetm.o
 
 obj-y += ipa_v3/ ipa_clients/
 

+ 51 - 0
drivers/platform/msm/ipa/ipa_v3/ipa_net.c

@@ -0,0 +1,51 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2020, The Linux Foundation. All rights reserved.
+ */
+
+/*
+ * This module is dedicated for operations that must be performed at
+ * init stage later than the main IPA driver and IPA clients manager init.
+ *
+ * E.g.:
+ * Both net_dev driver and ipa driver are initialized during
+ * the subsys_initcall, and the rmnet_ipa driver probe is called
+ * by the ipa_pre_init or ipa_post_init or ipa_clients_manager_init,
+ * the register_netdev() call will cause a kernel bug.
+ *
+ */
+
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/ipa.h>
+#include "ipa_i.h"
+#include "ipa_qmi_service.h"
+
+static int __init ipa_late_init(void)
+{
+	int rc = 0;
+
+	IPADBG("IPA late init\n");
+
+	rc = ipa3_wwan_platform_driver_register();
+	if (rc) {
+		IPAERR("ipa3_wwan_platform_driver_register failed: %d\n",
+			   rc);
+		ipa3_wwan_cleanup();
+	}
+
+	return rc;
+}
+fs_initcall(ipa_late_init);
+
+static void __exit ipa_late_exit(void)
+{
+	IPADBG("IPA late exit\n");
+	ipa3_wwan_cleanup();
+}
+module_exit(ipa_late_exit);
+
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("IPA late init module");
+

+ 7 - 0
drivers/platform/msm/ipa/ipa_v3/ipa_qmi_service.h

@@ -343,6 +343,8 @@ void ipa3_qmi_init(void);
 
 void ipa3_qmi_cleanup(void);
 
+int ipa3_wwan_platform_driver_register(void);
+
 int ipa3_wwan_init(void);
 
 void ipa3_wwan_cleanup(void);
@@ -525,6 +527,11 @@ static inline void ipa3_qmi_cleanup(void)
 
 }
 
+static inline int ipa3_wwan_platform_driver_register(void)
+{
+	return -EPERM;
+}
+
 static inline int ipa3_wwan_init(void)
 {
 	return -EPERM;

+ 8 - 12
drivers/platform/msm/ipa/ipa_v3/rmnet_ipa.c

@@ -4846,7 +4846,14 @@ static void rmnet_ipa_debugfs_init(void){}
 static void rmnet_ipa_debugfs_remove(void){}
 #endif /* CONFIG_DEBUG_FS */
 
+int ipa3_wwan_platform_driver_register(void)
+{
+	int rc = platform_driver_register(&rmnet_ipa_driver);
+	if (rc)
+		IPAWANERR_RL("rmnet_ipa driver register fail rc=%d\n", rc);
 
+	return rc;
+}
 
 int ipa3_wwan_init(void)
 {
@@ -4915,21 +4922,10 @@ int ipa3_wwan_init(void)
 		rmnet_ipa3_ctx->rmt_mdm_subsys_notify_handle = ssr_hdl;
 	}
 
-	rc = platform_driver_register(&rmnet_ipa_driver);
-	if (rc) {
-		IPAWANERR_RL("rmnet_ipa driver register fail rc=%d\n", rc);
-		goto fail_unreg_rmt_mdm_ssr;
-	}
+	/* The platform driver register is done later in the ipa_late_init */
 
 	return 0;
 
-fail_unreg_rmt_mdm_ssr:
-	if (ipa3_ctx_get_type(PLATFORM_TYPE) == IPA_PLAT_TYPE_APQ) {
-		subsys_notif_unregister_notifier(
-			rmnet_ipa3_ctx->rmt_mdm_subsys_notify_handle,
-			&ipa3_rmt_mdm_ssr_notifier);
-		rmnet_ipa3_ctx->rmt_mdm_subsys_notify_handle = NULL;
-	}
 fail_unreg_lcl_mdm_ssr:
 	if (rmnet_ipa3_ctx->lcl_mdm_subsys_notify_handle) {
 		subsys_notif_unregister_notifier(