Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/usb rnd(9): Adjust IPL of locks used by rndsource ca...
details: https://anonhg.NetBSD.org/src/rev/dc32c5fdc0ce
branches: trunk
changeset: 364361:dc32c5fdc0ce
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sat Mar 19 11:37:05 2022 +0000
description:
rnd(9): Adjust IPL of locks used by rndsource callbacks.
These no longer ever run from hard interrupt context or with a spin
lock held, so there is no longer any need to have them at IPL_VM to
block hard interrupts. Instead, lower them to IPL_SOFTSERIAL.
diffstat:
sys/arch/arm/broadcom/bcm2835_rng.c | 10 +++++-----
sys/arch/arm/omap/am335x_trng.c | 6 +++---
sys/arch/arm/rockchip/rk_v1crypto.c | 6 +++---
sys/arch/arm/sunxi/sun8i_crypto.c | 8 ++++----
sys/arch/arm/ti/ti_rng.c | 6 +++---
sys/arch/mips/cavium/dev/octeon_rnm.c | 6 +++---
sys/arch/mips/ingenic/ingenic_rng.c | 10 +++++-----
sys/dev/ic/amdccp.c | 7 ++++---
sys/dev/ic/rng200.c | 8 ++++----
sys/dev/pci/amdpm.c | 7 +++----
sys/dev/pci/viornd.c | 8 ++++----
sys/dev/usb/ualea.c | 6 +++---
12 files changed, 44 insertions(+), 44 deletions(-)
diffs (truncated from 372 to 300 lines):
diff -r 58d32d91a9a8 -r dc32c5fdc0ce sys/arch/arm/broadcom/bcm2835_rng.c
--- a/sys/arch/arm/broadcom/bcm2835_rng.c Sat Mar 19 11:36:53 2022 +0000
+++ b/sys/arch/arm/broadcom/bcm2835_rng.c Sat Mar 19 11:37:05 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bcm2835_rng.c,v 1.15 2021/01/27 03:10:19 thorpej Exp $ */
+/* $NetBSD: bcm2835_rng.c,v 1.16 2022/03/19 11:37:05 riastradh Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_rng.c,v 1.15 2021/01/27 03:10:19 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_rng.c,v 1.16 2022/03/19 11:37:05 riastradh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -121,7 +121,7 @@
bus_space_write_4(sc->sc_iot, sc->sc_ioh, RNG_CTRL, ctrl);
/* set up an rndsource */
- mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_VM);
+ mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_SOFTSERIAL);
rndsource_setcb(&sc->sc_rndsource, &bcmrng_get, sc);
rnd_attach_source(&sc->sc_rndsource, device_xname(self), RND_TYPE_RNG,
RND_FLAG_COLLECT_VALUE|RND_FLAG_HASCB);
@@ -134,7 +134,7 @@
uint32_t status, cnt;
uint32_t buf[RNG_DATA_MAX]; /* 1k on the stack */
- mutex_spin_enter(&sc->sc_lock);
+ mutex_enter(&sc->sc_lock);
while (bytes_wanted) {
status = bus_space_read_4(sc->sc_iot, sc->sc_ioh, RNG_STATUS);
cnt = __SHIFTOUT(status, RNG_STATUS_CNT);
@@ -148,5 +148,5 @@
bytes_wanted -= MIN(bytes_wanted, (cnt * 4));
}
explicit_memset(buf, 0, sizeof(buf));
- mutex_spin_exit(&sc->sc_lock);
+ mutex_exit(&sc->sc_lock);
}
diff -r 58d32d91a9a8 -r dc32c5fdc0ce sys/arch/arm/omap/am335x_trng.c
--- a/sys/arch/arm/omap/am335x_trng.c Sat Mar 19 11:36:53 2022 +0000
+++ b/sys/arch/arm/omap/am335x_trng.c Sat Mar 19 11:37:05 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: am335x_trng.c,v 1.3 2020/04/30 03:40:52 riastradh Exp $ */
+/* $NetBSD: am335x_trng.c,v 1.4 2022/03/19 11:37:05 riastradh Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: am335x_trng.c,v 1.3 2020/04/30 03:40:52 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: am335x_trng.c,v 1.4 2022/03/19 11:37:05 riastradh Exp $");
#include "opt_omap.h"
@@ -99,7 +99,7 @@
return;
}
- mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_VM);
+ mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_SOFTSERIAL);
prcm_module_enable(&rng_module);
diff -r 58d32d91a9a8 -r dc32c5fdc0ce sys/arch/arm/rockchip/rk_v1crypto.c
--- a/sys/arch/arm/rockchip/rk_v1crypto.c Sat Mar 19 11:36:53 2022 +0000
+++ b/sys/arch/arm/rockchip/rk_v1crypto.c Sat Mar 19 11:37:05 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rk_v1crypto.c,v 1.7 2021/01/27 03:10:19 thorpej Exp $ */
+/* $NetBSD: rk_v1crypto.c,v 1.8 2022/03/19 11:37:05 riastradh Exp $ */
/*-
* Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: rk_v1crypto.c,v 1.7 2021/01/27 03:10:19 thorpej Exp $");
+__KERNEL_RCSID(1, "$NetBSD: rk_v1crypto.c,v 1.8 2022/03/19 11:37:05 riastradh Exp $");
#include <sys/types.h>
@@ -128,7 +128,7 @@
sc->sc_dev = self;
sc->sc_bst = faa->faa_bst;
- mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_VM);
+ mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_SOFTSERIAL);
/* Get and map device registers. */
if (fdtbus_get_reg(phandle, 0, &addr, &size) != 0) {
diff -r 58d32d91a9a8 -r dc32c5fdc0ce sys/arch/arm/sunxi/sun8i_crypto.c
--- a/sys/arch/arm/sunxi/sun8i_crypto.c Sat Mar 19 11:36:53 2022 +0000
+++ b/sys/arch/arm/sunxi/sun8i_crypto.c Sat Mar 19 11:37:05 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sun8i_crypto.c,v 1.29 2022/03/18 23:36:57 riastradh Exp $ */
+/* $NetBSD: sun8i_crypto.c,v 1.30 2022/03/19 11:37:05 riastradh Exp $ */
/*-
* Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -43,7 +43,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: sun8i_crypto.c,v 1.29 2022/03/18 23:36:57 riastradh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sun8i_crypto.c,v 1.30 2022/03/19 11:37:05 riastradh Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -390,10 +390,10 @@
sc->sc_dmat = faa->faa_dmat;
sc->sc_bst = faa->faa_bst;
sc->sc_taskpool = pool_cache_init(sizeof(struct sun8i_crypto_task),
- 0, 0, 0, "sun8icry", NULL, IPL_VM,
+ 0, 0, 0, "sun8icry", NULL, IPL_SOFTSERIAL,
&sun8i_crypto_task_ctor, &sun8i_crypto_task_dtor, sc);
sc->sc_cfg = of_compatible_lookup(phandle, compat_data)->data;
- mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NONE);
+ mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_SOFTSERIAL);
mutex_init(&sc->sc_intr_lock, MUTEX_DEFAULT, IPL_VM);
callout_init(&sc->sc_timeout, CALLOUT_MPSAFE);
callout_setfunc(&sc->sc_timeout, &sun8i_crypto_timeout, sc);
diff -r 58d32d91a9a8 -r dc32c5fdc0ce sys/arch/arm/ti/ti_rng.c
--- a/sys/arch/arm/ti/ti_rng.c Sat Mar 19 11:36:53 2022 +0000
+++ b/sys/arch/arm/ti/ti_rng.c Sat Mar 19 11:37:05 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ti_rng.c,v 1.5 2021/01/27 03:10:20 thorpej Exp $ */
+/* $NetBSD: ti_rng.c,v 1.6 2022/03/19 11:37:05 riastradh Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ti_rng.c,v 1.5 2021/01/27 03:10:20 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ti_rng.c,v 1.6 2022/03/19 11:37:05 riastradh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -101,7 +101,7 @@
return;
}
- mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_VM);
+ mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_SOFTSERIAL);
if ((RD4(sc, TRNG_CONTROL_REG) & TRNG_CONTROL_ENABLE) == 0) {
WR4(sc, TRNG_CONFIG_REG,
diff -r 58d32d91a9a8 -r dc32c5fdc0ce sys/arch/mips/cavium/dev/octeon_rnm.c
--- a/sys/arch/mips/cavium/dev/octeon_rnm.c Sat Mar 19 11:36:53 2022 +0000
+++ b/sys/arch/mips/cavium/dev/octeon_rnm.c Sat Mar 19 11:37:05 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: octeon_rnm.c,v 1.13 2021/12/28 13:22:43 riastradh Exp $ */
+/* $NetBSD: octeon_rnm.c,v 1.14 2022/03/19 11:37:05 riastradh Exp $ */
/*
* Copyright (c) 2007 Internet Initiative Japan, Inc.
@@ -99,7 +99,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: octeon_rnm.c,v 1.13 2021/12/28 13:22:43 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: octeon_rnm.c,v 1.14 2022/03/19 11:37:05 riastradh Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -185,7 +185,7 @@
}
/* Create a mutex to serialize access to the FIFO. */
- mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_VM);
+ mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_SOFTSERIAL);
/*
* Reset the core, enable the RNG engine without entropy, wait
diff -r 58d32d91a9a8 -r dc32c5fdc0ce sys/arch/mips/ingenic/ingenic_rng.c
--- a/sys/arch/mips/ingenic/ingenic_rng.c Sat Mar 19 11:36:53 2022 +0000
+++ b/sys/arch/mips/ingenic/ingenic_rng.c Sat Mar 19 11:37:05 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ingenic_rng.c,v 1.5 2020/04/30 03:40:53 riastradh Exp $ */
+/* $NetBSD: ingenic_rng.c,v 1.6 2022/03/19 11:37:05 riastradh Exp $ */
/*-
* Copyright (c) 2015 Michael McConville
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ingenic_rng.c,v 1.5 2020/04/30 03:40:53 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ingenic_rng.c,v 1.6 2022/03/19 11:37:05 riastradh Exp $");
/*
* adapted from Jared McNeill's amlogic_rng.c
@@ -94,7 +94,7 @@
return;
}
- mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_VM);
+ mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_SOFTSERIAL);
aprint_naive(": Ingenic random number generator\n");
aprint_normal(": Ingenic random number generator\n");
@@ -110,7 +110,7 @@
struct ingenic_rng_softc * const sc = priv;
uint32_t data;
- mutex_spin_enter(&sc->sc_lock);
+ mutex_enter(&sc->sc_lock);
while (bytes_wanted) {
data = bus_space_read_4(sc->sc_bst, sc->sc_bsh, 0);
delay(1);
@@ -119,5 +119,5 @@
bytes_wanted -= MIN(bytes_wanted, sizeof(data));
}
explicit_memset(&data, 0, sizeof(data));
- mutex_spin_exit(&sc->sc_lock);
+ mutex_exit(&sc->sc_lock);
}
diff -r 58d32d91a9a8 -r dc32c5fdc0ce sys/dev/ic/amdccp.c
--- a/sys/dev/ic/amdccp.c Sat Mar 19 11:36:53 2022 +0000
+++ b/sys/dev/ic/amdccp.c Sat Mar 19 11:37:05 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: amdccp.c,v 1.3 2021/08/23 23:55:43 mrg Exp $ */
+/* $NetBSD: amdccp.c,v 1.4 2022/03/19 11:37:06 riastradh Exp $ */
/*
* Copyright (c) 2018 Jonathan A. Kollasch
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: amdccp.c,v 1.3 2021/08/23 23:55:43 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amdccp.c,v 1.4 2022/03/19 11:37:06 riastradh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -44,7 +44,8 @@
void
amdccp_common_attach(struct amdccp_softc *sc)
{
- mutex_init(&sc->sc_rndlock, MUTEX_DEFAULT, IPL_VM);
+
+ mutex_init(&sc->sc_rndlock, MUTEX_DEFAULT, IPL_SOFTSERIAL);
rndsource_setcb(&sc->sc_rndsource, amdccp_rnd_callback, sc);
rnd_attach_source(&sc->sc_rndsource, device_xname(sc->sc_dev),
RND_TYPE_RNG, RND_FLAG_COLLECT_VALUE|RND_FLAG_HASCB);
diff -r 58d32d91a9a8 -r dc32c5fdc0ce sys/dev/ic/rng200.c
--- a/sys/dev/ic/rng200.c Sat Mar 19 11:36:53 2022 +0000
+++ b/sys/dev/ic/rng200.c Sat Mar 19 11:37:05 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rng200.c,v 1.2 2020/04/30 03:40:53 riastradh Exp $ */
+/* $NetBSD: rng200.c,v 1.3 2022/03/19 11:37:06 riastradh Exp $ */
/*
* Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -79,7 +79,7 @@
uint32_t w, data;
unsigned count;
- mutex_spin_enter(&sc->sc_lock);
+ mutex_enter(&sc->sc_lock);
while (bytes_wanted) {
w = READ4(sc, RNG200_STATUS);
@@ -98,14 +98,14 @@
bytes_wanted -= MIN(bytes_wanted, sizeof(data));
}
explicit_memset(&data, 0, sizeof(data));
- mutex_spin_exit(&sc->sc_lock);
+ mutex_exit(&sc->sc_lock);
}
void
rng200_attach(struct rng200_softc *sc)
{
- mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_VM);
+ mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_SOFTSERIAL);
rndsource_setcb(&sc->sc_rndsource, rng200_get, sc);
rnd_attach_source(&sc->sc_rndsource, sc->sc_name,
diff -r 58d32d91a9a8 -r dc32c5fdc0ce sys/dev/pci/amdpm.c
--- a/sys/dev/pci/amdpm.c Sat Mar 19 11:36:53 2022 +0000
+++ b/sys/dev/pci/amdpm.c Sat Mar 19 11:37:05 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: amdpm.c,v 1.42 2020/05/30 10:27:29 jdolecek Exp $ */
+/* $NetBSD: amdpm.c,v 1.43 2022/03/19 11:37:06 riastradh Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
Home |
Main Index |
Thread Index |
Old Index