Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern need to take IFNET_LOCK() around if_stop (on suspen...
details: https://anonhg.NetBSD.org/src/rev/b8f5f2bad440
branches: trunk
changeset: 932608:b8f5f2bad440
user: jdolecek <jdolecek%NetBSD.org@localhost>
date: Tue May 12 10:02:56 2020 +0000
description:
need to take IFNET_LOCK() around if_stop (on suspend) and if_init (on resume)
calls, those need to read and/or manipulate if_flags and hence need
the lock for IFEF_MPSAFE drivers; the drivers can't do IFNET_LOCK() themselves,
because the ioctl path call these hooks with the lock held
fixes KASSERT() in xennet(4) while investigating PR port-xen/55207
diffstat:
sys/kern/kern_pmf.c | 15 ++++++++++++---
1 files changed, 12 insertions(+), 3 deletions(-)
diffs (51 lines):
diff -r 73d297aec5bb -r b8f5f2bad440 sys/kern/kern_pmf.c
--- a/sys/kern/kern_pmf.c Tue May 12 09:54:02 2020 +0000
+++ b/sys/kern/kern_pmf.c Tue May 12 10:02:56 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_pmf.c,v 1.42 2020/04/20 21:39:05 ad Exp $ */
+/* $NetBSD: kern_pmf.c,v 1.43 2020/05/12 10:02:56 jdolecek Exp $ */
/*-
* Copyright (c) 2007 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_pmf.c,v 1.42 2020/04/20 21:39:05 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_pmf.c,v 1.43 2020/05/12 10:02:56 jdolecek Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -893,7 +893,9 @@
int s;
s = splnet();
+ IFNET_LOCK(ifp);
(*ifp->if_stop)(ifp, 0);
+ IFNET_UNLOCK(ifp);
splx(s);
return true;
@@ -904,14 +906,21 @@
{
struct ifnet *ifp = device_pmf_class_private(dev);
int s;
+ bool restart = false;
s = splnet();
+ IFNET_LOCK(ifp);
if (ifp->if_flags & IFF_UP) {
ifp->if_flags &= ~IFF_RUNNING;
if ((*ifp->if_init)(ifp) != 0)
aprint_normal_ifnet(ifp, "resume failed\n");
+ restart = true;
+ }
+ IFNET_UNLOCK(ifp);
+
+ if (restart)
if_start_lock(ifp);
- }
+
splx(s);
return true;
Home |
Main Index |
Thread Index |
Old Index