Parcourir la source

dfc: not using alarm timer

Not using alarm timer for dfc powersave check and eliminate the need
for a wakelock. This allows AP to go to suspend quicker.

Change-Id: I7153055d0231a65125ad88808db9e1d0032f24d9
Signed-off-by: Weiyi Chen <[email protected]>
Weiyi Chen il y a 3 ans
Parent
commit
cdbf46091a
2 fichiers modifiés avec 9 ajouts et 67 suppressions
  1. 8 64
      core/qmi_rmnet.c
  2. 1 3
      core/qmi_rmnet_i.h

+ 8 - 64
core/qmi_rmnet.c

@@ -25,7 +25,6 @@
 #include <linux/moduleparam.h>
 #include <linux/moduleparam.h>
 #include <linux/ip.h>
 #include <linux/ip.h>
 #include <linux/ipv6.h>
 #include <linux/ipv6.h>
-#include <linux/alarmtimer.h>
 
 
 #define NLMSG_FLOW_ACTIVATE 1
 #define NLMSG_FLOW_ACTIVATE 1
 #define NLMSG_FLOW_DEACTIVATE 2
 #define NLMSG_FLOW_DEACTIVATE 2
@@ -623,7 +622,6 @@ qmi_rmnet_setup_client(void *port, struct qmi_info *qmi, struct tcmsg *tcm)
 		if (!qmi)
 		if (!qmi)
 			return -ENOMEM;
 			return -ENOMEM;
 
 
-		qmi->ws = wakeup_source_register(NULL, "RMNET_DFC");
 		rmnet_init_qmi_pt(port, qmi);
 		rmnet_init_qmi_pt(port, qmi);
 	}
 	}
 
 
@@ -673,7 +671,6 @@ __qmi_rmnet_delete_client(void *port, struct qmi_info *qmi, int idx)
 
 
 	if (!qmi_rmnet_has_client(qmi) && !qmi_rmnet_has_pending(qmi)) {
 	if (!qmi_rmnet_has_client(qmi) && !qmi_rmnet_has_pending(qmi)) {
 		rmnet_reset_qmi_pt(port);
 		rmnet_reset_qmi_pt(port);
-		wakeup_source_unregister(qmi->ws);
 		kfree(qmi);
 		kfree(qmi);
 		return 0;
 		return 0;
 	}
 	}
@@ -746,7 +743,6 @@ int qmi_rmnet_change_link(struct net_device *dev, void *port, void *tcm_pt,
 			    !qmi_rmnet_has_client(qmi) &&
 			    !qmi_rmnet_has_client(qmi) &&
 			    !qmi_rmnet_has_pending(qmi)) {
 			    !qmi_rmnet_has_pending(qmi)) {
 				rmnet_reset_qmi_pt(port);
 				rmnet_reset_qmi_pt(port);
-				wakeup_source_unregister(qmi->ws);
 				kfree(qmi);
 				kfree(qmi);
 			}
 			}
 
 
@@ -1147,7 +1143,6 @@ static u8 ps_bearer_id[32];
 
 
 struct rmnet_powersave_work {
 struct rmnet_powersave_work {
 	struct delayed_work work;
 	struct delayed_work work;
-	struct alarm atimer;
 	void *port;
 	void *port;
 	u64 old_rx_pkts;
 	u64 old_rx_pkts;
 	u64 old_tx_pkts;
 	u64 old_tx_pkts;
@@ -1233,32 +1228,6 @@ static void qmi_rmnet_work_restart(void *port)
 	rcu_read_unlock();
 	rcu_read_unlock();
 }
 }
 
 
-static enum alarmtimer_restart qmi_rmnet_work_alarm(struct alarm *atimer,
-						    ktime_t now)
-{
-	struct rmnet_powersave_work *real_work;
-
-	real_work = container_of(atimer, struct rmnet_powersave_work, atimer);
-	qmi_rmnet_work_restart(real_work->port);
-	return ALARMTIMER_NORESTART;
-}
-
-static void dfc_wakelock_acquire(struct qmi_info *qmi)
-{
-	if (qmi && !qmi->wakelock_active) {
-		__pm_stay_awake(qmi->ws);
-		qmi->wakelock_active = true;
-	}
-}
-
-static void dfc_wakelock_release(struct qmi_info *qmi)
-{
-	if (qmi && qmi->wakelock_active) {
-		__pm_relax(qmi->ws);
-		qmi->wakelock_active = false;
-	}
-}
-
 static void qmi_rmnet_check_stats(struct work_struct *work)
 static void qmi_rmnet_check_stats(struct work_struct *work)
 {
 {
 	struct rmnet_powersave_work *real_work;
 	struct rmnet_powersave_work *real_work;
@@ -1266,7 +1235,6 @@ static void qmi_rmnet_check_stats(struct work_struct *work)
 	u64 rxd, txd;
 	u64 rxd, txd;
 	u64 rx, tx;
 	u64 rx, tx;
 	bool dl_msg_active;
 	bool dl_msg_active;
-	bool use_alarm_timer = true;
 
 
 	real_work = container_of(to_delayed_work(work),
 	real_work = container_of(to_delayed_work(work),
 				 struct rmnet_powersave_work, work);
 				 struct rmnet_powersave_work, work);
@@ -1278,8 +1246,6 @@ static void qmi_rmnet_check_stats(struct work_struct *work)
 	if (unlikely(!qmi))
 	if (unlikely(!qmi))
 		return;
 		return;
 
 
-	dfc_wakelock_release(qmi);
-
 	rmnet_get_packets(real_work->port, &rx, &tx);
 	rmnet_get_packets(real_work->port, &rx, &tx);
 	rxd = rx - real_work->old_rx_pkts;
 	rxd = rx - real_work->old_rx_pkts;
 	txd = tx - real_work->old_tx_pkts;
 	txd = tx - real_work->old_tx_pkts;
@@ -1315,10 +1281,8 @@ static void qmi_rmnet_check_stats(struct work_struct *work)
 		 * (likely in RLF), no need to enter powersave
 		 * (likely in RLF), no need to enter powersave
 		 */
 		 */
 		if (!dl_msg_active &&
 		if (!dl_msg_active &&
-		    !rmnet_all_flows_enabled(real_work->port)) {
-			use_alarm_timer = false;
+		    !rmnet_all_flows_enabled(real_work->port))
 			goto end;
 			goto end;
-		}
 
 
 		/* Deregister to suppress QMI DFC and DL marker */
 		/* Deregister to suppress QMI DFC and DL marker */
 		if (qmi_rmnet_set_powersave_mode(real_work->port, 1,
 		if (qmi_rmnet_set_powersave_mode(real_work->port, 1,
@@ -1343,21 +1307,9 @@ static void qmi_rmnet_check_stats(struct work_struct *work)
 	}
 	}
 end:
 end:
 	rcu_read_lock();
 	rcu_read_lock();
-	if (!rmnet_work_quit) {
-		if (use_alarm_timer) {
-			/* Suspend will fail and get delayed for 2s if
-			 * alarmtimer expires within 2s. Hold a wakelock
-			 * for the actual timer duration to prevent suspend
-			 */
-			if (PS_INTERVAL_MS < 2000)
-				dfc_wakelock_acquire(qmi);
-			alarm_start_relative(&real_work->atimer,
-					     PS_INTERVAL_KT);
-		} else {
-			queue_delayed_work(rmnet_ps_wq, &real_work->work,
-					   PS_INTERVAL_JF);
-		}
-	}
+	if (!rmnet_work_quit)
+		queue_delayed_work(rmnet_ps_wq, &real_work->work,
+				   PS_INTERVAL_JF);
 	rcu_read_unlock();
 	rcu_read_unlock();
 }
 }
 
 
@@ -1380,9 +1332,6 @@ static void qmi_rmnet_check_stats_2(struct work_struct *work)
 	if (unlikely(!qmi))
 	if (unlikely(!qmi))
 		return;
 		return;
 
 
-	if (PS_INTERVAL_MS < 2000)
-		dfc_wakelock_acquire(qmi);
-
 	rmnet_get_packets(real_work->port, &rx, &tx);
 	rmnet_get_packets(real_work->port, &rx, &tx);
 	rxd = rx - real_work->old_rx_pkts;
 	rxd = rx - real_work->old_rx_pkts;
 	txd = tx - real_work->old_tx_pkts;
 	txd = tx - real_work->old_tx_pkts;
@@ -1433,15 +1382,13 @@ static void qmi_rmnet_check_stats_2(struct work_struct *work)
 		if (rmnet_get_powersave_notif(real_work->port))
 		if (rmnet_get_powersave_notif(real_work->port))
 			qmi_rmnet_ps_on_notify(real_work->port);
 			qmi_rmnet_ps_on_notify(real_work->port);
 
 
-		dfc_wakelock_release(qmi);
 		return;
 		return;
 	}
 	}
 end:
 end:
 	rcu_read_lock();
 	rcu_read_lock();
 	if (!rmnet_work_quit)
 	if (!rmnet_work_quit)
-		alarm_start_relative(&real_work->atimer, PS_INTERVAL_KT);
-	else
-		dfc_wakelock_release(qmi);
+		queue_delayed_work(rmnet_ps_wq, &real_work->work,
+				   PS_INTERVAL_JF);
 	rcu_read_unlock();
 	rcu_read_unlock();
 }
 }
 
 
@@ -1478,12 +1425,11 @@ void qmi_rmnet_work_init(void *port)
 	}
 	}
 
 
 	if (dfc_ps_ext)
 	if (dfc_ps_ext)
-		INIT_DEFERRABLE_WORK(&rmnet_work->work,
+		INIT_DELAYED_WORK(&rmnet_work->work,
 				     qmi_rmnet_check_stats_2);
 				     qmi_rmnet_check_stats_2);
 	else
 	else
-		INIT_DEFERRABLE_WORK(&rmnet_work->work, qmi_rmnet_check_stats);
+		INIT_DELAYED_WORK(&rmnet_work->work, qmi_rmnet_check_stats);
 
 
-	alarm_init(&rmnet_work->atimer, ALARM_BOOTTIME, qmi_rmnet_work_alarm);
 	rmnet_work->port = port;
 	rmnet_work->port = port;
 	rmnet_get_packets(rmnet_work->port, &rmnet_work->old_rx_pkts,
 	rmnet_get_packets(rmnet_work->port, &rmnet_work->old_rx_pkts,
 			  &rmnet_work->old_tx_pkts);
 			  &rmnet_work->old_tx_pkts);
@@ -1518,14 +1464,12 @@ void qmi_rmnet_work_exit(void *port)
 	synchronize_rcu();
 	synchronize_rcu();
 
 
 	rmnet_work_inited = false;
 	rmnet_work_inited = false;
-	alarm_cancel(&rmnet_work->atimer);
 	cancel_delayed_work_sync(&rmnet_work->work);
 	cancel_delayed_work_sync(&rmnet_work->work);
 	destroy_workqueue(rmnet_ps_wq);
 	destroy_workqueue(rmnet_ps_wq);
 	qmi_rmnet_work_set_active(port, 0);
 	qmi_rmnet_work_set_active(port, 0);
 	rmnet_ps_wq = NULL;
 	rmnet_ps_wq = NULL;
 	kfree(rmnet_work);
 	kfree(rmnet_work);
 	rmnet_work = NULL;
 	rmnet_work = NULL;
-	dfc_wakelock_release((struct qmi_info *)rmnet_get_qmi_pt(port));
 }
 }
 EXPORT_SYMBOL(qmi_rmnet_work_exit);
 EXPORT_SYMBOL(qmi_rmnet_work_exit);
 
 

+ 1 - 3
core/qmi_rmnet_i.h

@@ -1,5 +1,6 @@
 /*
 /*
  * Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
  * Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved.
  *
  *
  * This program is free software; you can redistribute it and/or modify
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
  * it under the terms of the GNU General Public License version 2 and
@@ -17,7 +18,6 @@
 #include <linux/netdevice.h>
 #include <linux/netdevice.h>
 #include <linux/skbuff.h>
 #include <linux/skbuff.h>
 #include <linux/timer.h>
 #include <linux/timer.h>
-#include <linux/pm_wakeup.h>
 #include <uapi/linux/rtnetlink.h>
 #include <uapi/linux/rtnetlink.h>
 #include <linux/soc/qcom/qmi.h>
 #include <linux/soc/qcom/qmi.h>
 
 
@@ -143,8 +143,6 @@ struct qmi_info {
 	bool dl_msg_active;
 	bool dl_msg_active;
 	bool ps_ignore_grant;
 	bool ps_ignore_grant;
 	int ps_ext;
 	int ps_ext;
-	bool wakelock_active;
-	struct wakeup_source *ws;
 };
 };
 
 
 enum data_ep_type_enum_v01 {
 enum data_ep_type_enum_v01 {