From 6dcb992b79af3e66b981c1bfc656752c959789bd Mon Sep 17 00:00:00 2001 From: Vaisakh Murali Date: Sun, 11 Jul 2021 20:36:01 +0530 Subject: [PATCH] drivers: ipa_v3: Conditionally compile out ipa wakelock code * This is spurious and does not get destroyed, which keeps this wakelock as pending. Remove this code to save power. * To enable these wakelocks again, pass `-DIPA_WAKELOCKS` as a cflag. Signed-off-by: Vaisakh Murali Signed-off-by: Panchajanya1999 Signed-off-by: azrim --- drivers/platform/msm/ipa/ipa_v3/ipa.c | 10 ++++++++-- drivers/platform/msm/ipa/ipa_v3/ipa_dp.c | 10 ++++++++-- drivers/platform/msm/ipa/ipa_v3/ipa_i.h | 4 ++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa.c b/drivers/platform/msm/ipa/ipa_v3/ipa.c index 372e762a9897..13c4efeb69aa 100644 --- a/drivers/platform/msm/ipa/ipa_v3/ipa.c +++ b/drivers/platform/msm/ipa/ipa_v3/ipa.c @@ -5600,6 +5600,7 @@ void ipa3_dec_client_disable_clks_no_block( &ipa_dec_clients_disable_clks_on_wq_work, 0); } +#ifdef IPA_WAKELOCKS /** * ipa3_inc_acquire_wakelock() - Increase active clients counter, and * acquire wakelock if necessary @@ -5640,6 +5641,7 @@ void ipa3_dec_release_wakelock(void) __pm_relax(&ipa3_ctx->w_lock); spin_unlock_irqrestore(&ipa3_ctx->wakelock_ref_cnt.spinlock, flags); } +#endif int ipa3_set_clock_plan_from_pm(int idx) { @@ -5837,11 +5839,13 @@ void ipa3_suspend_handler(enum ipa_irq_type interrupt, atomic_set( &ipa3_ctx->transport_pm.dec_clients, 1); + #ifdef IPA_WAKELOCKS /* * acquire wake lock as long as suspend * vote is held */ ipa3_inc_acquire_wakelock(); + #endif ipa3_process_irq_schedule_rel(); } mutex_unlock(pm_mutex_ptr); @@ -5918,7 +5922,9 @@ static void ipa3_transport_release_resource(struct work_struct *work) ipa3_process_irq_schedule_rel(); } else { atomic_set(&ipa3_ctx->transport_pm.dec_clients, 0); + #ifdef IPA_WAKELOCKS ipa3_dec_release_wakelock(); + #endif IPA_ACTIVE_CLIENTS_DEC_SPECIAL("TRANSPORT_RESOURCE"); } } @@ -7391,11 +7397,11 @@ static int ipa3_pre_init(const struct ipa3_plat_drv_res *resource_p, } ipa3_debugfs_pre_init(); - +#ifdef IPA_WAKELOCKS /* Create a wakeup source. */ wakeup_source_init(&ipa3_ctx->w_lock, "IPA_WS"); spin_lock_init(&ipa3_ctx->wakelock_ref_cnt.spinlock); - +#endif /* Initialize Power Management framework */ if (ipa3_ctx->use_ipa_pm) { result = ipa_pm_init(&ipa3_res.pm_init); diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_dp.c b/drivers/platform/msm/ipa/ipa_v3/ipa_dp.c index 612160e8461a..d27a332b0ac3 100644 --- a/drivers/platform/msm/ipa/ipa_v3/ipa_dp.c +++ b/drivers/platform/msm/ipa/ipa_v3/ipa_dp.c @@ -804,14 +804,17 @@ static int ipa3_rx_switch_to_intr_mode(struct ipa3_sys_context *sys) atomic_set(&sys->curr_polling_state, 0); __ipa3_update_curr_poll_state(sys->ep->client, 0); - +#ifdef IPA_WAKELOCKS ipa3_dec_release_wakelock(); +#endif ret = gsi_config_channel_mode(sys->ep->gsi_chan_hdl, GSI_CHAN_MODE_CALLBACK); if ((ret != GSI_STATUS_SUCCESS) && !atomic_read(&sys->curr_polling_state)) { if (ret == -GSI_STATUS_PENDING_IRQ) { + #ifdef IPA_WAKELOCKS ipa3_inc_acquire_wakelock(); + #endif atomic_set(&sys->curr_polling_state, 1); __ipa3_update_curr_poll_state(sys->ep->client, 1); } else { @@ -4359,8 +4362,9 @@ void __ipa_gsi_irq_rx_scedule_poll(struct ipa3_sys_context *sys) atomic_set(&sys->curr_polling_state, 1); __ipa3_update_curr_poll_state(sys->ep->client, 1); - +#ifdef IPA_WAKELOCKS ipa3_inc_acquire_wakelock(); +#endif /* * pm deactivate is done in wq context @@ -4449,7 +4453,9 @@ static void ipa_dma_gsi_irq_rx_notify_cb(struct gsi_chan_xfer_notify *notify) /* put the gsi channel into polling mode */ gsi_config_channel_mode(sys->ep->gsi_chan_hdl, GSI_CHAN_MODE_POLL); + #ifdef IPA_WAKELOCKS ipa3_inc_acquire_wakelock(); + #endif atomic_set(&sys->curr_polling_state, 1); queue_work(sys->wq, &sys->work); } diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_i.h b/drivers/platform/msm/ipa/ipa_v3/ipa_i.h index bff5a7ffc3fe..61375f123989 100644 --- a/drivers/platform/msm/ipa/ipa_v3/ipa_i.h +++ b/drivers/platform/msm/ipa/ipa_v3/ipa_i.h @@ -1424,10 +1424,12 @@ struct ipa3_active_clients { int bus_vote_idx; }; +#ifdef IPA_WAKELOCKS struct ipa3_wakelock_ref_cnt { spinlock_t spinlock; int cnt; }; +#endif struct ipa3_tag_completion { struct completion comp; @@ -1974,8 +1976,10 @@ struct ipa3_context { bool gsi_ch20_wa; bool s1_bypass_arr[IPA_SMMU_CB_MAX]; u32 wdi_map_cnt; +#ifdef IPA_WAKELOCKS struct wakeup_source w_lock; struct ipa3_wakelock_ref_cnt wakelock_ref_cnt; +#endif /* RMNET_IOCTL_INGRESS_FORMAT_AGG_DATA */ bool ipa_client_apps_wan_cons_agg_gro; /* M-release support to know client pipes */