diff mbox series

[1/7,SRU,M,N] Revert "UBUNTU: SAUCE: net: wwan: t7xx: PCIe reset rescan"

Message ID 20240509003623.1115600-2-acelan.kao@canonical.com
State New
Headers show
Series mtk_t7xx WWAN module fails to probe with: Invalid device status 0x1 | expand

Commit Message

AceLan Kao May 9, 2024, 12:36 a.m. UTC
From: "Chia-Lin Kao (AceLan)" <acelan.kao@canonical.com>

BugLink: https://bugs.launchpad.net/bugs/2049358

This reverts commit 811b348542b87b9776e8a14b4bb97cbdd7e1a84f.
This patch have been reverted by the upstream commit
(bf294c3feafe "Revert \"Merge branch 'wwan-t7xx-fw-flashing-and-coredump-support'\")

Signed-off-by: Chia-Lin Kao (AceLan) <acelan.kao@canonical.com>
---
 drivers/net/wwan/t7xx/Makefile          |  3 +-
 drivers/net/wwan/t7xx/t7xx_modem_ops.c  |  3 -
 drivers/net/wwan/t7xx/t7xx_pci.c        | 56 +--------------
 drivers/net/wwan/t7xx/t7xx_pci_rescan.c | 96 -------------------------
 drivers/net/wwan/t7xx/t7xx_pci_rescan.h | 28 --------
 5 files changed, 2 insertions(+), 184 deletions(-)
 delete mode 100644 drivers/net/wwan/t7xx/t7xx_pci_rescan.c
 delete mode 100644 drivers/net/wwan/t7xx/t7xx_pci_rescan.h
diff mbox series

Patch

diff --git a/drivers/net/wwan/t7xx/Makefile b/drivers/net/wwan/t7xx/Makefile
index b5e1946ac8af0..2652cd00504e6 100644
--- a/drivers/net/wwan/t7xx/Makefile
+++ b/drivers/net/wwan/t7xx/Makefile
@@ -15,8 +15,7 @@  mtk_t7xx-y:=	t7xx_pci.o \
 		t7xx_hif_dpmaif_tx.o \
 		t7xx_hif_dpmaif_rx.o  \
 		t7xx_dpmaif.o \
-		t7xx_netdev.o \
-		t7xx_pci_rescan.o
+		t7xx_netdev.o
 
 mtk_t7xx-$(CONFIG_WWAN_DEBUGFS) += \
 		t7xx_port_trace.o \
diff --git a/drivers/net/wwan/t7xx/t7xx_modem_ops.c b/drivers/net/wwan/t7xx/t7xx_modem_ops.c
index e34d93bd4e2c3..24e7d491468e0 100644
--- a/drivers/net/wwan/t7xx/t7xx_modem_ops.c
+++ b/drivers/net/wwan/t7xx/t7xx_modem_ops.c
@@ -37,7 +37,6 @@ 
 #include "t7xx_modem_ops.h"
 #include "t7xx_netdev.h"
 #include "t7xx_pci.h"
-#include "t7xx_pci_rescan.h"
 #include "t7xx_pcie_mac.h"
 #include "t7xx_port.h"
 #include "t7xx_port_proxy.h"
@@ -195,8 +194,6 @@  static irqreturn_t t7xx_rgu_isr_thread(int irq, void *data)
 
 	msleep(RGU_RESET_DELAY_MS);
 	t7xx_reset_device_via_pmic(t7xx_dev);
-	t7xx_rescan_queue_work(t7xx_dev->pdev);
-
 	return IRQ_HANDLED;
 }
 
diff --git a/drivers/net/wwan/t7xx/t7xx_pci.c b/drivers/net/wwan/t7xx/t7xx_pci.c
index 4c8ccf90170b4..91256e005b846 100644
--- a/drivers/net/wwan/t7xx/t7xx_pci.c
+++ b/drivers/net/wwan/t7xx/t7xx_pci.c
@@ -38,7 +38,6 @@ 
 #include "t7xx_mhccif.h"
 #include "t7xx_modem_ops.h"
 #include "t7xx_pci.h"
-#include "t7xx_pci_rescan.h"
 #include "t7xx_pcie_mac.h"
 #include "t7xx_reg.h"
 #include "t7xx_state_monitor.h"
@@ -736,7 +735,6 @@  static int t7xx_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 		return ret;
 	}
 
-	t7xx_rescan_done();
 	t7xx_pcie_mac_set_int(t7xx_dev, MHCCIF_INT);
 	t7xx_pcie_mac_interrupts_en(t7xx_dev);
 
@@ -776,59 +774,7 @@  static struct pci_driver t7xx_pci_driver = {
 	.shutdown = t7xx_pci_shutdown,
 };
 
-static int __init t7xx_pci_init(void)
-{
-	int ret;
-
-	t7xx_pci_dev_rescan();
-	ret = t7xx_rescan_init();
-	if (ret) {
-		pr_err("Failed to init t7xx rescan work\n");
-		return ret;
-	}
-
-	return pci_register_driver(&t7xx_pci_driver);
-}
-module_init(t7xx_pci_init);
-
-static int t7xx_always_match(struct device *dev, const void *data)
-{
-	struct pci_dev *pdev = to_pci_dev(dev);
-	const struct pci_device_id *id = data;
-
-	if (pci_match_id(id, pdev))
-		return 1;
-
-	return 0;
-}
-
-static void __exit t7xx_pci_cleanup(void)
-{
-	int remove_flag = 0;
-	struct device *dev;
-
-	dev = driver_find_device(&t7xx_pci_driver.driver, NULL, &t7xx_pci_table[0],
-				 t7xx_always_match);
-	if (dev) {
-		pr_debug("unregister t7xx PCIe driver while device is still exist.\n");
-		put_device(dev);
-		remove_flag = 1;
-	} else {
-		pr_debug("no t7xx PCIe driver found.\n");
-	}
-
-	pci_lock_rescan_remove();
-	pci_unregister_driver(&t7xx_pci_driver);
-	pci_unlock_rescan_remove();
-
-	t7xx_rescan_deinit();
-	if (remove_flag) {
-		pr_debug("remove t7xx PCI device\n");
-		pci_stop_and_remove_bus_device_locked(to_pci_dev(dev));
-	}
-}
-
-module_exit(t7xx_pci_cleanup);
+module_pci_driver(t7xx_pci_driver);
 
 MODULE_AUTHOR("MediaTek Inc");
 MODULE_DESCRIPTION("MediaTek PCIe 5G WWAN modem T7xx driver");
diff --git a/drivers/net/wwan/t7xx/t7xx_pci_rescan.c b/drivers/net/wwan/t7xx/t7xx_pci_rescan.c
deleted file mode 100644
index 67f13c0358461..0000000000000
--- a/drivers/net/wwan/t7xx/t7xx_pci_rescan.c
+++ /dev/null
@@ -1,96 +0,0 @@ 
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Copyright (c) 2021, MediaTek Inc.
- * Copyright (c) 2021-2023, Intel Corporation.
- */
-
-#define pr_fmt(fmt) KBUILD_MODNAME ":t7xx:%s: " fmt, __func__
-#define dev_fmt(fmt) "t7xx: " fmt
-
-#include <linux/delay.h>
-#include <linux/pci.h>
-#include <linux/spinlock.h>
-#include <linux/workqueue.h>
-
-#include "t7xx_pci.h"
-#include "t7xx_pci_rescan.h"
-
-static struct remove_rescan_context t7xx_rescan_ctx;
-
-void t7xx_pci_dev_rescan(void)
-{
-	struct pci_bus *b = NULL;
-
-	pci_lock_rescan_remove();
-	while ((b = pci_find_next_bus(b)))
-		pci_rescan_bus(b);
-	pci_unlock_rescan_remove();
-}
-
-void t7xx_rescan_done(void)
-{
-	if (!atomic_read(&t7xx_rescan_ctx.rescan_done)) {
-		atomic_set(&t7xx_rescan_ctx.rescan_done, 1);
-		pr_debug("Rescan probe\n");
-	} else {
-		pr_debug("Init probe\n");
-	}
-}
-
-static void t7xx_remove_rescan(struct work_struct *work)
-{
-	int num_retries = RESCAN_RETRIES;
-	struct pci_dev *pdev;
-
-	atomic_set(&t7xx_rescan_ctx.rescan_done, 0);
-	pdev = t7xx_rescan_ctx.dev;
-
-	if (pdev) {
-		pci_stop_and_remove_bus_device_locked(pdev);
-		pr_debug("start remove and rescan flow\n");
-	}
-
-	do {
-		t7xx_pci_dev_rescan();
-
-		if (atomic_read(&t7xx_rescan_ctx.rescan_done))
-			break;
-
-		msleep(DELAY_RESCAN_MTIME);
-	} while (num_retries--);
-}
-
-void t7xx_rescan_queue_work(struct pci_dev *pdev)
-{
-	if (!atomic_read(&t7xx_rescan_ctx.rescan_done)) {
-		dev_err(&pdev->dev, "Rescan failed\n");
-		return;
-	}
-
-	t7xx_rescan_ctx.dev = pdev;
-	queue_work(t7xx_rescan_ctx.pcie_rescan_wq, &t7xx_rescan_ctx.service_task);
-}
-
-int t7xx_rescan_init(void)
-{
-	atomic_set(&t7xx_rescan_ctx.rescan_done, 1);
-	t7xx_rescan_ctx.dev = NULL;
-
-	t7xx_rescan_ctx.pcie_rescan_wq = create_singlethread_workqueue(MTK_RESCAN_WQ);
-	if (!t7xx_rescan_ctx.pcie_rescan_wq) {
-		pr_err("Failed to create workqueue: %s\n", MTK_RESCAN_WQ);
-		return -ENOMEM;
-	}
-
-	INIT_WORK(&t7xx_rescan_ctx.service_task, t7xx_remove_rescan);
-
-	return 0;
-}
-
-void t7xx_rescan_deinit(void)
-{
-	t7xx_rescan_ctx.dev = NULL;
-	atomic_set(&t7xx_rescan_ctx.rescan_done, 0);
-	cancel_work_sync(&t7xx_rescan_ctx.service_task);
-	destroy_workqueue(t7xx_rescan_ctx.pcie_rescan_wq);
-}
diff --git a/drivers/net/wwan/t7xx/t7xx_pci_rescan.h b/drivers/net/wwan/t7xx/t7xx_pci_rescan.h
deleted file mode 100644
index 80b25c44151c9..0000000000000
--- a/drivers/net/wwan/t7xx/t7xx_pci_rescan.h
+++ /dev/null
@@ -1,28 +0,0 @@ 
-/* SPDX-License-Identifier: GPL-2.0-only
- *
- * Copyright (c) 2021, MediaTek Inc.
- * Copyright (c) 2021-2023, Intel Corporation.
- */
-
-#ifndef __T7XX_PCI_RESCAN_H__
-#define __T7XX_PCI_RESCAN_H__
-
-#define MTK_RESCAN_WQ "mtk_rescan_wq"
-
-#define DELAY_RESCAN_MTIME 1000
-#define RESCAN_RETRIES 35
-
-struct remove_rescan_context {
-	struct work_struct service_task;
-	struct workqueue_struct *pcie_rescan_wq;
-	struct pci_dev *dev;
-	atomic_t rescan_done;
-};
-
-void t7xx_pci_dev_rescan(void);
-void t7xx_rescan_queue_work(struct pci_dev *pdev);
-int t7xx_rescan_init(void);
-void t7xx_rescan_deinit(void);
-void t7xx_rescan_done(void);
-
-#endif	/* __T7XX_PCI_RESCAN_H__ */