Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 360d9bb5 authored by Kalle Valo's avatar Kalle Valo
Browse files

Revert "ath9k: export HW random number generator"

This reverts commit 6301566e. Oleksij Rempel
noticed that the randomness doesn't look to be good enough and Stephan Mueller
commented:

"I would say that the discussed RNG does not seem fit for hooking it up with the
hwrandom framework."

http://lkml.kernel.org/g/3945775.m5HblJPgiO@tauon.atsec.com



So let's the revert the patch until we are sure that we can trust this random
generator.

Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
parent 92ff7a69
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -176,10 +176,3 @@ config ATH9K_HTC_DEBUGFS
	depends on ATH9K_HTC && DEBUG_FS
	---help---
	  Say Y, if you need access to ath9k_htc's statistics.

config ATH9K_HWRNG
	bool "Random number generator support"
	depends on ATH9K && (HW_RANDOM = y || HW_RANDOM = ATH9K)
	default y
	---help---
	  Provides a hardware random number generator to the kernel.
+0 −1
Original line number Diff line number Diff line
@@ -15,7 +15,6 @@ ath9k-$(CONFIG_ATH9K_DFS_DEBUGFS) += dfs_debug.o
ath9k-$(CONFIG_ATH9K_DFS_CERTIFIED) += dfs.o
ath9k-$(CONFIG_ATH9K_TX99) += tx99.o
ath9k-$(CONFIG_ATH9K_WOW) += wow.o
ath9k-$(CONFIG_ATH9K_HWRNG) += rng.o

ath9k-$(CONFIG_ATH9K_DEBUGFS) += debug.o

+0 −23
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@
#include <linux/leds.h>
#include <linux/completion.h>
#include <linux/time.h>
#include <linux/hw_random.h>

#include "common.h"
#include "debug.h"
@@ -1042,12 +1041,6 @@ struct ath_softc {
	u32 wow_intr_before_sleep;
	bool force_wow;
#endif

#ifdef CONFIG_ATH9K_HWRNG
	struct hwrng rng;
	bool rng_initialized;
	u32 rng_last;
#endif
};

/********/
@@ -1070,22 +1063,6 @@ static inline int ath9k_tx99_send(struct ath_softc *sc,
}
#endif /* CONFIG_ATH9K_TX99 */

/***************************/
/* Random Number Generator */
/***************************/
#ifdef CONFIG_ATH9K_HWRNG
void ath9k_rng_register(struct ath_softc *sc);
void ath9k_rng_unregister(struct ath_softc *sc);
#else
static inline void ath9k_rng_register(struct ath_softc *sc)
{
}

static inline void ath9k_rng_unregister(struct ath_softc *sc)
{
}
#endif

static inline void ath_read_cachesize(struct ath_common *common, int *csz)
{
	common->bus_ops->read_cachesize(common, csz);
+0 −4
Original line number Diff line number Diff line
@@ -739,8 +739,6 @@ static int ath9k_start(struct ieee80211_hw *hw)

	ath9k_ps_restore(sc);

	ath9k_rng_register(sc);

	return 0;
}

@@ -830,8 +828,6 @@ static void ath9k_stop(struct ieee80211_hw *hw)

	ath9k_deinit_channel_context(sc);

	ath9k_rng_unregister(sc);

	mutex_lock(&sc->mutex);

	ath_cancel_work(sc);
+0 −75
Original line number Diff line number Diff line
/*
 * Copyright (c) 2015 Qualcomm Atheros, Inc.
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#include "ath9k.h"
#include "hw.h"
#include "ar9003_phy.h"

static int ath9k_rng_data_read(struct hwrng *rng, u32 *data)
{
	u32 v1, v2;
	struct ath_softc *sc = (struct ath_softc *)rng->priv;
	struct ath_hw *ah = sc->sc_ah;

	ath9k_ps_wakeup(sc);

	REG_RMW_FIELD(ah, AR_PHY_TEST, AR_PHY_TEST_BBB_OBS_SEL, 5);
	REG_CLR_BIT(ah, AR_PHY_TEST, AR_PHY_TEST_RX_OBS_SEL_BIT5);
	REG_RMW_FIELD(ah, AR_PHY_TEST_CTL_STATUS, AR_PHY_TEST_CTL_RX_OBS_SEL, 0);

	v1 = REG_READ(ah, AR_PHY_TST_ADC);
	v2 = REG_READ(ah, AR_PHY_TST_ADC);

	ath9k_ps_restore(sc);

	/* wait for data ready */
	if (v1 && v2 && sc->rng_last != v1 && v1 != v2) {
		*data = (v1 & 0xffff) | (v2 << 16);
		sc->rng_last = v2;

		return sizeof(u32);
	}

	sc->rng_last = v2;

	return 0;
}

void ath9k_rng_register(struct ath_softc *sc)
{
	struct ath_hw *ah = sc->sc_ah;

	if (WARN_ON(sc->rng_initialized))
		return;

	if (!AR_SREV_9300_20_OR_LATER(ah))
		return;

	sc->rng.name = "ath9k";
	sc->rng.data_read = ath9k_rng_data_read;
	sc->rng.priv = (unsigned long)sc;

	if (!hwrng_register(&sc->rng))
		sc->rng_initialized = true;
}

void ath9k_rng_unregister(struct ath_softc *sc)
{
	if (sc->rng_initialized) {
		hwrng_unregister(&sc->rng);
		sc->rng_initialized = false;
	}
}