diff options
author | Terje Bergstrom <tbergstrom@nvidia.com> | 2011-09-01 08:19:50 +0300 |
---|---|---|
committer | Rohan Somvanshi <rsomvanshi@nvidia.com> | 2011-09-05 10:25:09 -0700 |
commit | 532b8db1aa4faff01c3c770c8c25c63cdead0243 (patch) | |
tree | c776d6ab57ad435cec4938badd02cafe54858ed4 | |
parent | 0cea1bd3ed04d2fa3877be1b3ca2b14859d7af02 (diff) |
nvhost: Add locking to module clock code
nvhost_module_add_client(), nvhost_module_remove_client() and
nvhost_module_set_rate() need locking when accessing the client list.
Bug 870328
Change-Id: Idbf8298ec213dca2829f48e9aafd4173806ea00b
Reviewed-on: http://git-master/r/50259
Reviewed-by: Rohan Somvanshi <rsomvanshi@nvidia.com>
Tested-by: Rohan Somvanshi <rsomvanshi@nvidia.com>
-rw-r--r-- | drivers/video/tegra/host/nvhost_acm.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/drivers/video/tegra/host/nvhost_acm.c b/drivers/video/tegra/host/nvhost_acm.c index b7a06f380d27..29f05359c1c3 100644 --- a/drivers/video/tegra/host/nvhost_acm.c +++ b/drivers/video/tegra/host/nvhost_acm.c @@ -511,7 +511,9 @@ int nvhost_module_set_rate(struct nvhost_module *mod, void *priv, unsigned long rate, int index) { struct nvhost_module_client *m; + int err; + mutex_lock(&mod->lock); list_for_each_entry(m, &mod->client_list, node) { if (m->priv == priv) { rate = clk_round_rate(mod->clk[index].clk, rate); @@ -519,7 +521,9 @@ int nvhost_module_set_rate(struct nvhost_module *mod, void *priv, break; } } - return nvhost_module_update_rate(mod, index); + err = nvhost_module_update_rate(mod, index); + mutex_unlock(&mod->lock); + return err; } int nvhost_module_add_client(struct nvhost_module *mod, void *priv) @@ -529,9 +533,9 @@ int nvhost_module_add_client(struct nvhost_module *mod, void *priv) struct nvhost_module_client *client; client = kzalloc(sizeof(*client), GFP_KERNEL); - if (!client) { + if (!client) return -ENOMEM; - } + INIT_LIST_HEAD(&client->node); client->priv = priv; @@ -540,7 +544,9 @@ int nvhost_module_add_client(struct nvhost_module *mod, void *priv) mod->clk[i].default_rate); client->rate[i] = rate; } + mutex_lock(&mod->lock); list_add_tail(&client->node, &mod->client_list); + mutex_unlock(&mod->lock); return 0; } @@ -549,6 +555,7 @@ void nvhost_module_remove_client(struct nvhost_module *mod, void *priv) int i; struct nvhost_module_client *m; + mutex_lock(&mod->lock); list_for_each_entry(m, &mod->client_list, node) { if (priv == m->priv) { list_del(&m->node); @@ -559,6 +566,7 @@ void nvhost_module_remove_client(struct nvhost_module *mod, void *priv) kfree(m); for (i = 0; i < mod->num_clks; i++) nvhost_module_update_rate(mod, i); + mutex_unlock(&mod->lock); } #else int nvhost_module_get_rate(struct nvhost_module *mod, unsigned long *rate, |