Skip to content

Commit

Permalink
qmi_rmnet: Do not use alarm timer for DFC
Browse files Browse the repository at this point in the history
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]>
Signed-off-by: Juhyung Park <[email protected]>
Signed-off-by: Adithya R <[email protected]>
Signed-off-by: kawaaii <[email protected]>
  • Loading branch information
Weiyi Chen authored and HELLBOY017 committed Sep 18, 2022
1 parent 693f5ba commit 3856f22
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 61 deletions.
66 changes: 8 additions & 58 deletions drivers/soc/qcom/qmi_rmnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include <trace/events/dfc.h>
#include <linux/ip.h>
#include <linux/ipv6.h>
#include <linux/alarmtimer.h>

#define NLMSG_FLOW_ACTIVATE 1
#define NLMSG_FLOW_DEACTIVATE 2
Expand Down Expand Up @@ -617,7 +616,6 @@ qmi_rmnet_setup_client(void *port, struct qmi_info *qmi, struct tcmsg *tcm)
if (!qmi)
return -ENOMEM;

qmi->ws = wakeup_source_register(NULL, "RMNET_DFC");
rmnet_init_qmi_pt(port, qmi);
}

Expand Down Expand Up @@ -667,7 +665,6 @@ __qmi_rmnet_delete_client(void *port, struct qmi_info *qmi, int idx)

if (!qmi_rmnet_has_client(qmi) && !qmi_rmnet_has_pending(qmi)) {
rmnet_reset_qmi_pt(port);
wakeup_source_unregister(qmi->ws);
kfree(qmi);
return 0;
}
Expand Down Expand Up @@ -737,7 +734,6 @@ void qmi_rmnet_change_link(struct net_device *dev, void *port, void *tcm_pt)
!qmi_rmnet_has_client(qmi) &&
!qmi_rmnet_has_pending(qmi)) {
rmnet_reset_qmi_pt(port);
wakeup_source_unregister(qmi->ws);
kfree(qmi);
}
} else if (tcm->tcm_ifindex & FLAG_POWERSAVE_MASK) {
Expand Down Expand Up @@ -1126,7 +1122,6 @@ static u8 ps_bearer_id[32];

struct rmnet_powersave_work {
struct delayed_work work;
struct alarm atimer;
void *port;
u64 old_rx_pkts;
u64 old_tx_pkts;
Expand Down Expand Up @@ -1211,40 +1206,13 @@ static void qmi_rmnet_work_restart(void *port)
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)
{
struct rmnet_powersave_work *real_work;
struct qmi_info *qmi;
u64 rxd, txd;
u64 rx, tx;
bool dl_msg_active;
bool use_alarm_timer = true;

real_work = container_of(to_delayed_work(work),
struct rmnet_powersave_work, work);
Expand All @@ -1256,8 +1224,6 @@ static void qmi_rmnet_check_stats(struct work_struct *work)
if (unlikely(!qmi))
return;

dfc_wakelock_release(qmi);

rmnet_get_packets(real_work->port, &rx, &tx);
rxd = rx - real_work->old_rx_pkts;
txd = tx - real_work->old_tx_pkts;
Expand Down Expand Up @@ -1292,10 +1258,8 @@ static void qmi_rmnet_check_stats(struct work_struct *work)
* (likely in RLF), no need to enter powersave
*/
if (!dl_msg_active &&
!rmnet_all_flows_enabled(real_work->port)) {
use_alarm_timer = false;
!rmnet_all_flows_enabled(real_work->port))
goto end;
}

/* Deregister to suppress QMI DFC and DL marker */
if (qmi_rmnet_set_powersave_mode(real_work->port, 1) < 0)
Expand All @@ -1319,21 +1283,9 @@ static void qmi_rmnet_check_stats(struct work_struct *work)
}
end:
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);
}
}
if (!rmnet_work_quit)
queue_delayed_work(rmnet_ps_wq, &real_work->work,
PS_INTERVAL);
rcu_read_unlock();
}

Expand Down Expand Up @@ -1404,7 +1356,8 @@ static void qmi_rmnet_check_stats_2(struct work_struct *work)
end:
rcu_read_lock();
if (!rmnet_work_quit)
alarm_start_relative(&real_work->atimer, PS_INTERVAL_KT);
queue_delayed_work(rmnet_ps_wq, &real_work->work,
PS_INTERVAL);

rcu_read_unlock();
}
Expand Down Expand Up @@ -1442,12 +1395,11 @@ void qmi_rmnet_work_init(void *port)
}

if (dfc_qmap && dfc_ps_ext)
INIT_DEFERRABLE_WORK(&rmnet_work->work,
INIT_DELAYED_WORK(&rmnet_work->work,
qmi_rmnet_check_stats_2);
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_get_packets(rmnet_work->port, &rmnet_work->old_rx_pkts,
&rmnet_work->old_tx_pkts);
Expand Down Expand Up @@ -1482,14 +1434,12 @@ void qmi_rmnet_work_exit(void *port)
synchronize_rcu();

rmnet_work_inited = false;
alarm_cancel(&rmnet_work->atimer);
cancel_delayed_work_sync(&rmnet_work->work);
destroy_workqueue(rmnet_ps_wq);
qmi_rmnet_work_set_active(port, 0);
rmnet_ps_wq = NULL;
kfree(rmnet_work);
rmnet_work = NULL;
dfc_wakelock_release((struct qmi_info *)rmnet_get_qmi_pt(port));
}
EXPORT_SYMBOL(qmi_rmnet_work_exit);

Expand Down
3 changes: 0 additions & 3 deletions drivers/soc/qcom/qmi_rmnet_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <linux/netdevice.h>
#include <linux/skbuff.h>
#include <linux/timer.h>
#include <linux/pm_wakeup.h>

#define MAX_MQ_NUM 16
#define MAX_CLIENT_NUM 2
Expand Down Expand Up @@ -100,8 +99,6 @@ struct qmi_info {
bool ps_enabled;
bool dl_msg_active;
bool ps_ignore_grant;
bool wakelock_active;
struct wakeup_source *ws;
int ps_ext;
};

Expand Down

0 comments on commit 3856f22

Please sign in to comment.