Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 19 Aug 2022 21:09:45 GMT
From:      Kristof Provost <kp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 7647626d3380 - main - e6000sw: fix incorrect locking
Message-ID:  <202208192109.27JL9joI056568@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by kp:

URL: https://cgit.FreeBSD.org/src/commit/?id=7647626d3380d17096b2690eb25f9d8fa18d0f83

commit 7647626d3380d17096b2690eb25f9d8fa18d0f83
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2022-08-10 13:57:05 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2022-08-19 21:09:11 +0000

    e6000sw: fix incorrect locking
    
    During attach we release the lock to call e6000sw_attach_miibus(), which
    calls mii_attach(). The mii_attach() function calls miibus_readreg() /
    miibus_writereg(). However, these are set to be
    e6000sw_readphy_locked().
    
    That is, the read/write phy functions do not acquire the lock, but
    expect to be called while locked.  Simply do not unlock and relock while
    calling mii_attach().
    
    Reviewed by:    Hubert Mazur <hum@semihalf.com>
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
    Differential Revision:  https://reviews.freebsd.org/D36117
---
 sys/dev/etherswitch/e6000sw/e6000sw.c | 9 ---------
 1 file changed, 9 deletions(-)

diff --git a/sys/dev/etherswitch/e6000sw/e6000sw.c b/sys/dev/etherswitch/e6000sw/e6000sw.c
index d096c31b349a..f3d46ff2f926 100644
--- a/sys/dev/etherswitch/e6000sw/e6000sw.c
+++ b/sys/dev/etherswitch/e6000sw/e6000sw.c
@@ -529,20 +529,11 @@ e6000sw_attach(device_t dev)
 		if (!e6000sw_is_phyport(sc, port))
 			continue;
 
-		/*
-		 * It's necessary to unlock mutex, because e6000sw_attach_miibus
-		 * calls functions, which try to lock mutex.That leads
-		 * to recursive lock on non recursive mutex.
-		 */
-		E6000SW_UNLOCK(sc);
-
 		err = e6000sw_attach_miibus(sc, port);
 		if (err != 0) {
 			device_printf(sc->dev, "failed to attach miibus\n");
 			goto out_fail;
 		}
-
-		E6000SW_LOCK(sc);
 	}
 
 	etherswitch_info.es_nports = sc->num_ports;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202208192109.27JL9joI056568>