Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci Fix wm_watchdog_txq() lock region.
details: https://anonhg.NetBSD.org/src/rev/386d20aa7417
branches: trunk
changeset: 358765:386d20aa7417
user: knakahara <knakahara%NetBSD.org@localhost>
date: Tue Jan 16 07:23:13 2018 +0000
description:
Fix wm_watchdog_txq() lock region.
Not only wm_txeof() but also wm_watchdog_txq() itself requires txq_lock
as it reads Tx descriptor management variables such as "txq_free".
There is almost no influence on performance.
diffstat:
sys/dev/pci/if_wm.c | 18 ++++++++++++++----
1 files changed, 14 insertions(+), 4 deletions(-)
diffs (53 lines):
diff -r fe079fccb98d -r 386d20aa7417 sys/dev/pci/if_wm.c
--- a/sys/dev/pci/if_wm.c Tue Jan 16 07:05:24 2018 +0000
+++ b/sys/dev/pci/if_wm.c Tue Jan 16 07:23:13 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_wm.c,v 1.554 2018/01/15 04:25:48 knakahara Exp $ */
+/* $NetBSD: if_wm.c,v 1.555 2018/01/16 07:23:13 knakahara Exp $ */
/*
* Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -83,7 +83,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.554 2018/01/15 04:25:48 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.555 2018/01/16 07:23:13 knakahara Exp $");
#ifdef _KERNEL_OPT
#include "opt_net_mpsafe.h"
@@ -671,6 +671,7 @@
static bool wm_resume(device_t, const pmf_qual_t *);
static void wm_watchdog(struct ifnet *);
static void wm_watchdog_txq(struct ifnet *, struct wm_txqueue *);
+static void wm_watchdog_txq_locked(struct ifnet *, struct wm_txqueue *);
static void wm_tick(void *);
static int wm_ifflags_cb(struct ethercom *);
static int wm_ioctl(struct ifnet *, u_long, void *);
@@ -2953,15 +2954,24 @@
static void
wm_watchdog_txq(struct ifnet *ifp, struct wm_txqueue *txq)
{
+
+ mutex_enter(txq->txq_lock);
+ wm_watchdog_txq_locked(ifp, txq);
+ mutex_exit(txq->txq_lock);
+}
+
+static void
+wm_watchdog_txq_locked(struct ifnet *ifp, struct wm_txqueue *txq)
+{
struct wm_softc *sc = ifp->if_softc;
+ KASSERT(mutex_owned(txq->txq_lock));
+
/*
* Since we're using delayed interrupts, sweep up
* before we report an error.
*/
- mutex_enter(txq->txq_lock);
wm_txeof(sc, txq);
- mutex_exit(txq->txq_lock);
if (txq->txq_free != WM_NTXDESC(txq)) {
#ifdef WM_DEBUG
Home |
Main Index |
Thread Index |
Old Index