msm: ipa: update ipa driver APIs for recent wakeup_source and dma

This change will ensure the APIs are updated correctly to the
latest for wakeup_source and dma functions.

Change-Id: Iaaffe6f876dab3824f7a8b72f9d71be686033a6b
Acked-by: Priyadarshini Rajagopal <prajagop@qti.qualcomm.com>
Signed-off-by: Bojun Pan <bojunp@codeaurora.org>
Signed-off-by: Ghanim Fodi <gfodi@codeaurora.org>
This commit is contained in:
Ghanim Fodi 2019-10-16 16:11:15 +03:00 • committed by Bojun Pan
commit db3d3302c1
6 changed files with 48 additions and 32 deletions

View file

@ -10,7 +10,10 @@
# include "gsi.h"
# include "gsi_reg.h"
#if defined(CONFIG_IPA_EMULATION)
# include "gsi_emulation_stubs.h"
#endif
# define gsi_emu_readl(c) (readl_relaxed(c))
# define gsi_emu_writel(v, c) ({ __iowmb(); writel_relaxed((v), (c)); })

View file

@ -40,7 +40,7 @@ struct ipa_rm_it_private {
bool reschedule_work;
bool work_in_progress;
unsigned long jiffies;
struct wakeup_source w_lock;
struct wakeup_source *w_lock;
char w_lock_name[MAX_WS_NAME];
};
@ -83,7 +83,7 @@ static void ipa_rm_inactivity_timer_func(struct work_struct *work)
} else {
IPA_RM_DBG_LOW("calling release_resource on resource %d\n",
me->resource_name);
__pm_relax(&ipa_rm_it_handles[me->resource_name].w_lock);
__pm_relax(ipa_rm_it_handles[me->resource_name].w_lock);
ipa_rm_release_resource(me->resource_name);
ipa_rm_it_handles[me->resource_name].work_in_progress = false;
}
@ -107,7 +107,6 @@ static void ipa_rm_inactivity_timer_func(struct work_struct *work)
int ipa_rm_inactivity_timer_init(enum ipa_rm_resource_name resource_name,
unsigned long msecs)
{
struct wakeup_source *pwlock;
char *name;
IPA_RM_DBG_LOW("resource %d\n", resource_name);
@ -129,10 +128,16 @@ int ipa_rm_inactivity_timer_init(enum ipa_rm_resource_name resource_name,
ipa_rm_it_handles[resource_name].resource_requested = false;
ipa_rm_it_handles[resource_name].reschedule_work = false;
ipa_rm_it_handles[resource_name].work_in_progress = false;
pwlock = &(ipa_rm_it_handles[resource_name].w_lock);
name = ipa_rm_it_handles[resource_name].w_lock_name;
snprintf(name, MAX_WS_NAME, "IPA_RM%d\n", resource_name);
wakeup_source_init(pwlock, name);
ipa_rm_it_handles[resource_name].w_lock =
wakeup_source_register(NULL, name);
if (!ipa_rm_it_handles[resource_name].w_lock) {
IPA_RM_ERR("IPA wakeup source register failed %s\n",
name);
return -ENOMEM;
}
INIT_DELAYED_WORK(&ipa_rm_it_handles[resource_name].work,
ipa_rm_inactivity_timer_func);
ipa_rm_it_handles[resource_name].initied = true;
@ -151,8 +156,6 @@ EXPORT_SYMBOL(ipa_rm_inactivity_timer_init);
*/
int ipa_rm_inactivity_timer_destroy(enum ipa_rm_resource_name resource_name)
{
struct wakeup_source *pwlock;
IPA_RM_DBG_LOW("resource %d\n", resource_name);
if (resource_name < 0 ||
@ -168,10 +171,7 @@ int ipa_rm_inactivity_timer_destroy(enum ipa_rm_resource_name resource_name)
}
cancel_delayed_work_sync(&ipa_rm_it_handles[resource_name].work);
pwlock = &(ipa_rm_it_handles[resource_name].w_lock);
/* wakeup_source_trash(pwlock); */
wakeup_source_remove(pwlock);
__pm_relax(pwlock);
wakeup_source_unregister(ipa_rm_it_handles[resource_name].w_lock);
memset(&ipa_rm_it_handles[resource_name], 0,
sizeof(struct ipa_rm_it_private));
@ -266,7 +266,7 @@ int ipa_rm_inactivity_timer_release_resource(
}
ipa_rm_it_handles[resource_name].work_in_progress = true;
ipa_rm_it_handles[resource_name].reschedule_work = false;
__pm_stay_awake(&ipa_rm_it_handles[resource_name].w_lock);
__pm_stay_awake(ipa_rm_it_handles[resource_name].w_lock);
IPA_RM_DBG_LOW("setting delayed work\n");
queue_delayed_work(system_unbound_wq,
&ipa_rm_it_handles[resource_name].work,

View file

@ -5118,7 +5118,7 @@ void ipa3_inc_acquire_wakelock(void)
spin_lock_irqsave(&ipa3_ctx->wakelock_ref_cnt.spinlock, flags);
ipa3_ctx->wakelock_ref_cnt.cnt++;
if (ipa3_ctx->wakelock_ref_cnt.cnt == 1)
__pm_stay_awake(&ipa3_ctx->w_lock);
__pm_stay_awake(ipa3_ctx->w_lock);
IPADBG_LOW("active wakelock ref cnt = %d\n",
ipa3_ctx->wakelock_ref_cnt.cnt);
spin_unlock_irqrestore(&ipa3_ctx->wakelock_ref_cnt.spinlock, flags);
@ -5141,7 +5141,7 @@ void ipa3_dec_release_wakelock(void)
IPADBG_LOW("active wakelock ref cnt = %d\n",
ipa3_ctx->wakelock_ref_cnt.cnt);
if (ipa3_ctx->wakelock_ref_cnt.cnt == 0)
__pm_relax(&ipa3_ctx->w_lock);
__pm_relax(ipa3_ctx->w_lock);
spin_unlock_irqrestore(&ipa3_ctx->wakelock_ref_cnt.spinlock, flags);
}
@ -6811,8 +6811,14 @@ static int ipa3_pre_init(const struct ipa3_plat_drv_res *resource_p,
goto fail_device_create;
}
/* Create a wakeup source. */
wakeup_source_init(&ipa3_ctx->w_lock, "IPA_WS");
/* Register a wakeup source. */
ipa3_ctx->w_lock =
wakeup_source_register(&ipa_pdev->dev, "IPA_WS");
if (!ipa3_ctx->w_lock) {
IPAERR("IPA wakeup source register failed\n");
result = -ENOMEM;
goto fail_w_source_register;
}
spin_lock_init(&ipa3_ctx->wakelock_ref_cnt.spinlock);
/* Initialize Power Management framework */
@ -6897,8 +6903,11 @@ fail_gsi_pre_fw_load_init:
ipa3_dma_shutdown();
fail_ipa_dma_setup:
ipa_pm_destroy();
fail_ipa_pm_init:
fail_w_source_register:
device_destroy(ipa3_ctx->cdev.class, ipa3_ctx->cdev.dev_num);
fail_ipa_pm_init:
wakeup_source_unregister(ipa3_ctx->w_lock);
ipa3_ctx->w_lock = NULL;
fail_device_create:
unregister_chrdev_region(ipa3_ctx->cdev.dev_num, 1);
fail_alloc_chrdev_region:

View file

@ -1889,7 +1889,7 @@ struct ipa3_context {
bool gsi_ch20_wa;
bool s1_bypass_arr[IPA_SMMU_CB_MAX];
u32 wdi_map_cnt;
struct wakeup_source w_lock;
struct wakeup_source *w_lock;
struct ipa3_wakelock_ref_cnt wakelock_ref_cnt;
/* RMNET_IOCTL_INGRESS_FORMAT_AGG_DATA */
bool ipa_client_apps_wan_cons_agg_gro;

View file

@ -9,10 +9,12 @@
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/uaccess.h>
#include <linux/dma-noncoherent.h>
#include "ipa_i.h"
#include "ipahal/ipahal.h"
#include "ipahal/ipahal_nat.h"
/*
* The following for adding code (ie. for EMULATION) not found on x86.
*/
@ -114,7 +116,7 @@ static int ipa3_nat_ipv6ct_mmap(struct file *filp, struct vm_area_struct *vma)
}
/* check if smmu enable & dma_coherent mode */
if (!cb->valid ||
!is_device_dma_coherent(cb->dev)) {
!dev_is_dma_coherent(cb->dev)) {
vma->vm_page_prot =
pgprot_noncached(vma->vm_page_prot);
IPADBG("App smmu enable in DMA mode\n");

View file

@ -149,7 +149,7 @@ struct ipa_pm_client {
struct work_struct activate_work;
struct delayed_work deactivate_work;
struct completion complete;
struct wakeup_source wlock;
struct wakeup_source *wlock;
};
/*
@ -399,7 +399,7 @@ static void activate_work_func(struct work_struct *work)
if (!client->skip_clk_vote) {
IPA_ACTIVE_CLIENTS_INC_SPECIAL(client->name);
if (client->group == IPA_PM_GROUP_APPS)
__pm_stay_awake(&client->wlock);
__pm_stay_awake(client->wlock);
}
spin_lock_irqsave(&client->state_lock, flags);
@ -421,7 +421,7 @@ static void activate_work_func(struct work_struct *work)
if (!client->skip_clk_vote) {
IPA_ACTIVE_CLIENTS_DEC_SPECIAL(client->name);
if (client->group == IPA_PM_GROUP_APPS)
__pm_relax(&client->wlock);
__pm_relax(client->wlock);
}
IPA_PM_DBG_STATE(client->hdl, client->name, client->state);
@ -480,7 +480,7 @@ static void delayed_deferred_deactivate_work_func(struct work_struct *work)
if (!client->skip_clk_vote) {
IPA_ACTIVE_CLIENTS_DEC_SPECIAL(client->name);
if (client->group == IPA_PM_GROUP_APPS)
__pm_relax(&client->wlock);
__pm_relax(client->wlock);
}
deactivate_client(client->hdl);
@ -704,7 +704,6 @@ int ipa_pm_destroy(void)
int ipa_pm_register(struct ipa_pm_register_params *params, u32 *hdl)
{
struct ipa_pm_client *client;
struct wakeup_source *wlock;
int elem;
if (ipa_pm_ctx == NULL) {
@ -755,8 +754,13 @@ int ipa_pm_register(struct ipa_pm_register_params *params, u32 *hdl)
client->group = params->group;
client->hdl = *hdl;
client->skip_clk_vote = params->skip_clk_vote;
wlock = &client->wlock;
wakeup_source_init(wlock, client->name);
client->wlock = wakeup_source_register(NULL, client->name);
if (!client->wlock) {
ipa_pm_deregister(*hdl);
IPA_PM_ERR("IPA wakeup source register failed %s\n",
client->name);
return -ENOMEM;
}
init_completion(&client->complete);
@ -822,9 +826,7 @@ int ipa_pm_deregister(u32 hdl)
if (ipa_pm_ctx->clients_by_pipe[i] == ipa_pm_ctx->clients[hdl])
ipa_pm_ctx->clients_by_pipe[i] = NULL;
}
/* wakeup_source_trash(&client->wlock); */
wakeup_source_remove(&client->wlock);
__pm_relax(&client->wlock);
wakeup_source_unregister(client->wlock);
kfree(client);
ipa_pm_ctx->clients[hdl] = NULL;
@ -943,7 +945,7 @@ static int ipa_pm_activate_helper(struct ipa_pm_client *client, bool sync)
if (result == 0) {
client->state = IPA_PM_ACTIVATED;
if (client->group == IPA_PM_GROUP_APPS)
__pm_stay_awake(&client->wlock);
__pm_stay_awake(client->wlock);
spin_unlock_irqrestore(&client->state_lock, flags);
activate_client(client->hdl);
if (sync)
@ -1121,7 +1123,7 @@ int ipa_pm_deactivate_all_deferred(void)
if (!client->skip_clk_vote) {
IPA_ACTIVE_CLIENTS_DEC_SPECIAL(client->name);
if (client->group == IPA_PM_GROUP_APPS)
__pm_relax(&client->wlock);
__pm_relax(client->wlock);
}
deactivate_client(client->hdl);
} else /* if activated or deactivated, we do nothing */
@ -1176,7 +1178,7 @@ int ipa_pm_deactivate_sync(u32 hdl)
if (!client->skip_clk_vote) {
IPA_ACTIVE_CLIENTS_DEC_SPECIAL(client->name);
if (client->group == IPA_PM_GROUP_APPS)
__pm_relax(&client->wlock);
__pm_relax(client->wlock);
}
spin_lock_irqsave(&client->state_lock, flags);