summaryrefslogtreecommitdiff
path: root/drivers/net/wireless/ath/ath9k/rng.c
diff options
context:
space:
mode:
authorMiaoqing Pan <miaoqing@codeaurora.org>2016-03-18 09:54:56 (GMT)
committerKalle Valo <kvalo@qca.qualcomm.com>2016-04-04 14:07:28 (GMT)
commita2cb3d5f043e4cc646c396a3e188a171b38c15a0 (patch)
tree241f363eca151d521e9667a97a03404da736d8a8 /drivers/net/wireless/ath/ath9k/rng.c
parent69218a48005d0c93b8e9ec483f42ead481a43034 (diff)
downloadlinux-a2cb3d5f043e4cc646c396a3e188a171b38c15a0.tar.xz
ath9k: fix rng high cpu load
If no valid ADC randomness output, ath9k rng will continuously reading ADC, which will cause high CPU load. So increase the delay to wait for ADC ready. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=114261 Signed-off-by: Miaoqing Pan <miaoqing@codeaurora.org> Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
Diffstat (limited to 'drivers/net/wireless/ath/ath9k/rng.c')
-rw-r--r--drivers/net/wireless/ath/ath9k/rng.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/drivers/net/wireless/ath/ath9k/rng.c b/drivers/net/wireless/ath/ath9k/rng.c
index c9cb2aa..d38e50f 100644
--- a/drivers/net/wireless/ath/ath9k/rng.c
+++ b/drivers/net/wireless/ath/ath9k/rng.c
@@ -55,11 +55,26 @@ static int ath9k_rng_data_read(struct ath_softc *sc, u32 *buf, u32 buf_size)
return j << 2;
}
+static u32 ath9k_rng_delay_get(u32 fail_stats)
+{
+ u32 delay;
+
+ if (fail_stats < 100)
+ delay = 10;
+ else if (fail_stats < 105)
+ delay = 1000;
+ else
+ delay = 10000;
+
+ return delay;
+}
+
static int ath9k_rng_kthread(void *data)
{
int bytes_read;
struct ath_softc *sc = data;
u32 *rng_buf;
+ u32 delay, fail_stats = 0;
rng_buf = kmalloc_array(ATH9K_RNG_BUF_SIZE, sizeof(u32), GFP_KERNEL);
if (!rng_buf)
@@ -69,10 +84,13 @@ static int ath9k_rng_kthread(void *data)
bytes_read = ath9k_rng_data_read(sc, rng_buf,
ATH9K_RNG_BUF_SIZE);
if (unlikely(!bytes_read)) {
- msleep_interruptible(10);
+ delay = ath9k_rng_delay_get(++fail_stats);
+ msleep_interruptible(delay);
continue;
}
+ fail_stats = 0;
+
/* sleep until entropy bits under write_wakeup_threshold */
add_hwgenerator_randomness((void *)rng_buf, bytes_read,
ATH9K_RNG_ENTROPY(bytes_read));