From 8df7aab6867cde8668799a260497cbb6c0a42b1e Mon Sep 17 00:00:00 2001 From: Dinesh K Garg Date: Fri, 25 Jul 2014 19:18:06 -0700 Subject: [PATCH] msm_rng: Enable/ Disable Bus bandwidth for every RNG read call This patch adds calls to enable and disable bus bandwidth for every RNG Read call. Change-Id: Ia1ac31ffa79a8be2761c243eee9bf87f25422c24 Signed-off-by: Dinesh K Garg --- drivers/char/hw_random/msm_rng.c | 35 ++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/drivers/char/hw_random/msm_rng.c b/drivers/char/hw_random/msm_rng.c index f54ccdab20cd..88d77419f1d1 100644 --- a/drivers/char/hw_random/msm_rng.c +++ b/drivers/char/hw_random/msm_rng.c @@ -120,6 +120,12 @@ int msm_rng_direct_read(struct msm_rng_device *msm_rng_dev, void *data) pdev = msm_rng_dev->pdev; base = msm_rng_dev->base; + if (msm_rng_dev->qrng_perf_client) { + ret = msm_bus_scale_client_update_request( + msm_rng_dev->qrng_perf_client, 1); + if (ret) + pr_err("bus_scale_client_update_req failed!\n"); + } /* enable PRNG clock */ ret = clk_prepare_enable(msm_rng_dev->prng_clk); if (ret) { @@ -146,6 +152,13 @@ int msm_rng_direct_read(struct msm_rng_device *msm_rng_dev, void *data) /* vote to turn off clock */ clk_disable_unprepare(msm_rng_dev->prng_clk); + if (msm_rng_dev->qrng_perf_client) { + ret = msm_bus_scale_client_update_request( + msm_rng_dev->qrng_perf_client, 0); + if (ret) + pr_err("bus_scale_client_update_req failed!\n"); + } + val = 0L; return currsize; @@ -185,6 +198,13 @@ static int msm_rng_drbg_read(struct hwrng *rng, } else ret1 = 1; + if (msm_rng_dev->qrng_perf_client) { + ret = msm_bus_scale_client_update_request( + msm_rng_dev->qrng_perf_client, 1); + if (ret) + pr_err("bus_scale_client_update_req failed!\n"); + } + /* read random data from h/w */ /* enable PRNG clock */ ret = clk_prepare_enable(msm_rng_dev->prng_clk); @@ -216,6 +236,13 @@ static int msm_rng_drbg_read(struct hwrng *rng, /* vote to turn off clock */ clk_disable_unprepare(msm_rng_dev->prng_clk); + if (msm_rng_dev->qrng_perf_client) { + ret = msm_bus_scale_client_update_request( + msm_rng_dev->qrng_perf_client, 0); + if (ret) + pr_err("bus_scale_client_update_req failed!\n"); + } + up(&msm_rng_dev->drbg_sem); return currsize; @@ -370,6 +397,14 @@ static int __devinit msm_rng_enable_hw(struct msm_rng_device *msm_rng_dev) mb(); } clk_disable_unprepare(msm_rng_dev->prng_clk); + + if (msm_rng_dev->qrng_perf_client) { + ret = msm_bus_scale_client_update_request( + msm_rng_dev->qrng_perf_client, 0); + if (ret) + pr_err("bus_scale_client_update_req failed!\n"); + } + return 0; }