Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci/hdaudio Fix locking against myself problem:
details: https://anonhg.NetBSD.org/src/rev/fdadbb088d7b
branches: trunk
changeset: 336079:fdadbb088d7b
user: christos <christos%NetBSD.org@localhost>
date: Wed Feb 11 00:37:25 2015 +0000
description:
Fix locking against myself problem:
hdaudio_intr() ->
mutex_enter(&sc->sc_corb_mtx);
hdaudio_rirb_dequeue() ->
hdaudio_rirb_unsol() ->
hdafg_unsol() ->
hdafg_assoc_dump_dd() ->
hdaudio_command() ->
mutex_enter(&sc->sc_corb_mtx);
Should that be done differently?
diffstat:
sys/dev/pci/hdaudio/hdafg.c | 21 ++++++++++++---------
sys/dev/pci/hdaudio/hdaudio.c | 18 ++++++++++++++----
sys/dev/pci/hdaudio/hdaudiovar.h | 4 +++-
3 files changed, 29 insertions(+), 14 deletions(-)
diffs (144 lines):
diff -r db5447f5b99a -r fdadbb088d7b sys/dev/pci/hdaudio/hdafg.c
--- a/sys/dev/pci/hdaudio/hdafg.c Wed Feb 11 00:11:58 2015 +0000
+++ b/sys/dev/pci/hdaudio/hdafg.c Wed Feb 11 00:37:25 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hdafg.c,v 1.25 2014/09/23 13:29:30 nat Exp $ */
+/* $NetBSD: hdafg.c,v 1.26 2015/02/11 00:37:25 christos Exp $ */
/*
* Copyright (c) 2009 Precedence Technologies Ltd <support%precedence.co.uk@localhost>
@@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hdafg.c,v 1.25 2014/09/23 13:29:30 nat Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hdafg.c,v 1.26 2015/02/11 00:37:25 christos Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -836,21 +836,24 @@
}
static void
-hdafg_assoc_dump_dd(struct hdafg_softc *sc, struct hdaudio_assoc *as, int pin)
+hdafg_assoc_dump_dd(struct hdafg_softc *sc, struct hdaudio_assoc *as, int pin,
+ int lock)
{
struct hdafg_dd_info hdi;
struct hdaudio_widget *w;
uint8_t elddata[256];
unsigned int elddatalen = 0, i;
uint32_t res;
+ uint32_t (*cmd)(struct hdaudio_codec *, int, uint32_t, uint32_t) =
+ lock ? hdaudio_command : hdaudio_command_unlocked;
w = hdafg_widget_lookup(sc, as->as_pins[pin]);
if (w->w_pin.cap & COP_PINCAP_TRIGGER_REQD) {
- hdaudio_command(sc->sc_codec, as->as_pins[pin],
+ (*cmd)(sc->sc_codec, as->as_pins[pin],
CORB_SET_PIN_SENSE, 0);
}
- res = hdaudio_command(sc->sc_codec, as->as_pins[pin],
+ res = (*cmd)(sc->sc_codec, as->as_pins[pin],
CORB_GET_PIN_SENSE, 0);
#ifdef HDAFG_HDMI_DEBUG
@@ -864,13 +867,13 @@
if ((res &
(COP_GET_PIN_SENSE_PRESENSE_DETECT|COP_GET_PIN_SENSE_ELD_VALID)) ==
(COP_GET_PIN_SENSE_PRESENSE_DETECT|COP_GET_PIN_SENSE_ELD_VALID)) {
- res = hdaudio_command(sc->sc_codec, as->as_pins[pin],
+ res = (*cmd)(sc->sc_codec, as->as_pins[pin],
CORB_GET_HDMI_DIP_SIZE, COP_DIP_ELD_SIZE);
elddatalen = COP_DIP_BUFFER_SIZE(res);
if (elddatalen == 0)
elddatalen = sizeof(elddata); /* paranoid */
for (i = 0; i < elddatalen; i++) {
- res = hdaudio_command(sc->sc_codec, as->as_pins[pin],
+ res = (*cmd)(sc->sc_codec, as->as_pins[pin],
CORB_GET_HDMI_ELD_DATA, i);
if (!(res & COP_ELD_VALID)) {
hda_error(sc, "bad ELD size (%u/%u)\n",
@@ -1089,7 +1092,7 @@
for (j = 0; j < HDAUDIO_MAXPINS; j++) {
if (as[i].as_pins[j] == 0)
continue;
- hdafg_assoc_dump_dd(sc, &as[i], j);
+ hdafg_assoc_dump_dd(sc, &as[i], j, 1);
}
}
}
@@ -4268,7 +4271,7 @@
for (j = 0; j < HDAUDIO_MAXPINS; j++) {
if (as[i].as_pins[j] == 0)
continue;
- hdafg_assoc_dump_dd(sc, &as[i], j);
+ hdafg_assoc_dump_dd(sc, &as[i], j, 0);
}
}
break;
diff -r db5447f5b99a -r fdadbb088d7b sys/dev/pci/hdaudio/hdaudio.c
--- a/sys/dev/pci/hdaudio/hdaudio.c Wed Feb 11 00:11:58 2015 +0000
+++ b/sys/dev/pci/hdaudio/hdaudio.c Wed Feb 11 00:37:25 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hdaudio.c,v 1.24 2014/09/21 14:30:22 christos Exp $ */
+/* $NetBSD: hdaudio.c,v 1.25 2015/02/11 00:37:25 christos Exp $ */
/*
* Copyright (c) 2009 Precedence Technologies Ltd <support%precedence.co.uk@localhost>
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hdaudio.c,v 1.24 2014/09/21 14:30:22 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hdaudio.c,v 1.25 2015/02/11 00:37:25 christos Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -327,15 +327,25 @@
hdaudio_command(struct hdaudio_codec *co, int nid, uint32_t control,
uint32_t param)
{
+ uint32_t result;
+ struct hdaudio_softc *sc = co->co_host;
+ mutex_enter(&sc->sc_corb_mtx);
+ result = hdaudio_command_unlocked(co, nid, control, param);
+ mutex_exit(&sc->sc_corb_mtx);
+ return result;
+}
+
+uint32_t
+hdaudio_command_unlocked(struct hdaudio_codec *co, int nid, uint32_t control,
+ uint32_t param)
+{
struct hdaudio_softc *sc = co->co_host;
uint32_t result;
- mutex_enter(&sc->sc_corb_mtx);
hda_trace(sc, "cmd : request %08X %08X (%02X)\n",
control, param, nid);
hdaudio_corb_enqueue(sc, co->co_addr, nid, control, param);
result = hdaudio_rirb_dequeue(sc, false);
- mutex_exit(&sc->sc_corb_mtx);
return result;
}
diff -r db5447f5b99a -r fdadbb088d7b sys/dev/pci/hdaudio/hdaudiovar.h
--- a/sys/dev/pci/hdaudio/hdaudiovar.h Wed Feb 11 00:11:58 2015 +0000
+++ b/sys/dev/pci/hdaudio/hdaudiovar.h Wed Feb 11 00:37:25 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hdaudiovar.h,v 1.9 2011/02/13 17:49:12 jmcneill Exp $ */
+/* $NetBSD: hdaudiovar.h,v 1.10 2015/02/11 00:37:25 christos Exp $ */
/*
* Copyright (c) 2009 Precedence Technologies Ltd <support%precedence.co.uk@localhost>
@@ -176,6 +176,8 @@
void hdaudio_childdet(struct hdaudio_softc *, device_t);
uint32_t hdaudio_command(struct hdaudio_codec *, int, uint32_t, uint32_t);
+uint32_t hdaudio_command_unlocked(struct hdaudio_codec *, int, uint32_t,
+ uint32_t);
int hdaudio_intr(struct hdaudio_softc *);
int hdaudio_dma_alloc(struct hdaudio_softc *, struct hdaudio_dma *, int);
Home |
Main Index |
Thread Index |
Old Index