Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/dtv don't kmem_alloc with IPL_VM mutex locked, spott...
details: https://anonhg.NetBSD.org/src/rev/1b48012dd13d
branches: trunk
changeset: 767143:1b48012dd13d
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Sat Jul 09 17:55:20 2011 +0000
description:
don't kmem_alloc with IPL_VM mutex locked, spotted by rmind
diffstat:
sys/dev/dtv/dtv_buffer.c | 20 ++++----------------
sys/dev/dtv/dtv_device.c | 10 ++++++++--
sys/dev/dtv/dtv_ioctl.c | 19 +++++--------------
sys/dev/dtv/dtvvar.h | 7 ++++---
4 files changed, 21 insertions(+), 35 deletions(-)
diffs (180 lines):
diff -r ecbd1b811748 -r 1b48012dd13d sys/dev/dtv/dtv_buffer.c
--- a/sys/dev/dtv/dtv_buffer.c Sat Jul 09 17:32:29 2011 +0000
+++ b/sys/dev/dtv/dtv_buffer.c Sat Jul 09 17:55:20 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dtv_buffer.c,v 1.1 2011/07/09 14:46:56 jmcneill Exp $ */
+/* $NetBSD: dtv_buffer.c,v 1.2 2011/07/09 17:55:20 jmcneill Exp $ */
/*-
* Copyright (c) 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dtv_buffer.c,v 1.1 2011/07/09 14:46:56 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dtv_buffer.c,v 1.2 2011/07/09 17:55:20 jmcneill Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -120,7 +120,7 @@
kmem_free(db, sizeof(*db));
}
-static int
+int
dtv_buffer_realloc(struct dtv_softc *sc, size_t bufsize)
{
struct dtv_stream *ds = &sc->sc_stream;
@@ -196,23 +196,14 @@
}
int
-dtv_buffer_setup(struct dtv_softc *sc, size_t bufsize)
+dtv_buffer_setup(struct dtv_softc *sc)
{
struct dtv_stream *ds = &sc->sc_stream;
unsigned int i;
- int error;
mutex_enter(&ds->ds_lock);
-
- error = dtv_buffer_realloc(sc, PAGE_ALIGN(bufsize));
- if (error) {
- mutex_exit(&ds->ds_lock);
- return error;
- }
-
for (i = 0; i < ds->ds_nbufs; i++)
dtv_stream_enqueue(ds, ds->ds_buf[i]);
-
mutex_exit(&ds->ds_lock);
return 0;
@@ -224,13 +215,10 @@
struct dtv_stream *ds = &sc->sc_stream;
mutex_enter(&ds->ds_lock);
-
while (SIMPLEQ_FIRST(&ds->ds_ingress))
SIMPLEQ_REMOVE_HEAD(&ds->ds_ingress, db_entries);
while (SIMPLEQ_FIRST(&ds->ds_egress))
SIMPLEQ_REMOVE_HEAD(&ds->ds_egress, db_entries);
- dtv_buffer_realloc(sc, 0);
-
mutex_exit(&ds->ds_lock);
return 0;
diff -r ecbd1b811748 -r 1b48012dd13d sys/dev/dtv/dtv_device.c
--- a/sys/dev/dtv/dtv_device.c Sat Jul 09 17:32:29 2011 +0000
+++ b/sys/dev/dtv/dtv_device.c Sat Jul 09 17:55:20 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dtv_device.c,v 1.1 2011/07/09 14:46:56 jmcneill Exp $ */
+/* $NetBSD: dtv_device.c,v 1.2 2011/07/09 17:55:20 jmcneill Exp $ */
/*-
* Copyright (c) 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dtv_device.c,v 1.1 2011/07/09 14:46:56 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dtv_device.c,v 1.2 2011/07/09 17:55:20 jmcneill Exp $");
#include <sys/types.h>
#include <sys/conf.h>
@@ -102,6 +102,11 @@
cv_init(&ds->ds_sample_cv, "dtv");
selinit(&ds->ds_sel);
dtv_scatter_buf_init(&ds->ds_data);
+ if (dtv_buffer_realloc(sc, DTV_DEFAULT_BUFSIZE) != 0) {
+ aprint_error(": no memory\n");
+ sc->sc_dying = true;
+ return;
+ }
dtv_device_get_devinfo(sc, &info);
@@ -133,6 +138,7 @@
cv_destroy(&ds->ds_sample_cv);
mutex_destroy(&ds->ds_lock);
seldestroy(&ds->ds_sel);
+ dtv_buffer_realloc(sc, 0);
dtv_scatter_buf_destroy(&ds->ds_data);
return 0;
diff -r ecbd1b811748 -r 1b48012dd13d sys/dev/dtv/dtv_ioctl.c
--- a/sys/dev/dtv/dtv_ioctl.c Sat Jul 09 17:32:29 2011 +0000
+++ b/sys/dev/dtv/dtv_ioctl.c Sat Jul 09 17:55:20 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dtv_ioctl.c,v 1.1 2011/07/09 14:46:56 jmcneill Exp $ */
+/* $NetBSD: dtv_ioctl.c,v 1.2 2011/07/09 17:55:20 jmcneill Exp $ */
/*-
* Copyright (c) 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dtv_ioctl.c,v 1.1 2011/07/09 14:46:56 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dtv_ioctl.c,v 1.2 2011/07/09 17:55:20 jmcneill Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -75,26 +75,17 @@
{
struct dmx_pes_filter_params *pesfilt;
uint16_t pid;
- size_t bufsize;
int error;
switch (cmd) {
case DMX_START:
- if (sc->sc_bufsize_chg) {
- if ((error = dtv_buffer_setup(sc, sc->sc_bufsize)) != 0)
- return error;
- sc->sc_bufsize_chg = false;
- }
+ error = dtv_buffer_setup(sc);
+ if (error)
+ return error;
return dtv_device_start_transfer(sc);
case DMX_STOP:
return dtv_device_stop_transfer(sc);
case DMX_SET_BUFFER_SIZE:
- bufsize = *(uintptr_t *)data;
- if (bufsize >= DTV_DEFAULT_BUFSIZE &&
- sc->sc_bufsize != bufsize) {
- sc->sc_bufsize = bufsize;
- sc->sc_bufsize_chg = true;
- }
return 0;
case DMX_SET_PES_FILTER:
pesfilt = data;
diff -r ecbd1b811748 -r 1b48012dd13d sys/dev/dtv/dtvvar.h
--- a/sys/dev/dtv/dtvvar.h Sat Jul 09 17:32:29 2011 +0000
+++ b/sys/dev/dtv/dtvvar.h Sat Jul 09 17:55:20 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dtvvar.h,v 1.1 2011/07/09 14:46:56 jmcneill Exp $ */
+/* $NetBSD: dtvvar.h,v 1.2 2011/07/09 17:55:20 jmcneill Exp $ */
/*-
* Copyright (c) 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -38,7 +38,7 @@
#include <dev/dtv/dtvif.h>
#include <dev/dtv/dtv_scatter.h>
-#define DTV_DEFAULT_BUFSIZE (64 * 4096)
+#define DTV_DEFAULT_BUFSIZE (128 * PAGE_SIZE)
#define TS_PKTLEN 188
#define TS_HAS_SYNC(_tspkt) ((_tspkt)[0] == 0x47)
@@ -107,7 +107,8 @@
int dtv_frontend_ioctl(struct dtv_softc *, u_long, void *, int);
int dtv_demux_ioctl(struct dtv_softc *, u_long, void *, int);
-int dtv_buffer_setup(struct dtv_softc *, size_t);
+int dtv_buffer_realloc(struct dtv_softc *, size_t);
+int dtv_buffer_setup(struct dtv_softc *);
int dtv_buffer_destroy(struct dtv_softc *);
int dtv_buffer_read(struct dtv_softc *, struct uio *, int);
int dtv_buffer_poll(struct dtv_softc *, int, lwp_t *);
Home |
Main Index |
Thread Index |
Old Index