]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Use single global lock in the ENA driver
authorMarcin Wojtas <mw@FreeBSD.org>
Tue, 26 May 2020 15:39:41 +0000 (15:39 +0000)
committerMarcin Wojtas <mw@FreeBSD.org>
Tue, 26 May 2020 15:39:41 +0000 (15:39 +0000)
commit6959869eaea77fbdc99e46523daeb896662d9cca
tree9dc2417a89b929f58058719aa1d2091e16635e70
parent7926bc4492a9a5c1e12595355d5c11121eb51f4b
Use single global lock in the ENA driver

Currently, the driver had 2 global locks - one was sx lock used for
up/down synchronization and the second one was mutex, which was used
for link configuration and timer service callout.

It is better to have single lock for that. We cannot use mutex, as it
can sleep and cause witness errors in up/down configuration, so sx lock
seems to be the only choice.

Callout cannot use sx lock, but the timer service is MP safe, so we just
need to avoid race between ena_down() and ena_detach(). It can be
avoided by acquiring sx lock.

Simple macros were added that are encapsulating implementation of the
lock and makes the code cleaner.

Submitted by:  Michal Krawczyk <mk@semihalf.com>
Obtained from: Semihalf
Sponsored by:  Amazon, Inc.
sys/dev/ena/ena.c
sys/dev/ena/ena.h
sys/dev/ena/ena_netmap.c