Introduce iwm_nic_assert_locked() to verify that the driver has correctly
requested MAC access before accessing certain registers, as required
by the hardware.
Use it to assert that hardware is still in an accessible state before
reading or writing such a register. For now, panic if that check fails.
The long term goal is to make this a non-fatal error and handle it properly
in all code paths that end up reading or writing such a register.
Fix a missing NIC lock on 8000 hardware, found by this new assertion.
Also, grab the NIC lock early during hardware init and keep it until init
is done. The previous code relinquished and reacquired the NIC lock several
times during the init sequence. It seems this is what was causing some random
errors when the interface was brought up, such as "could not enable Tx queue",
"could not add aux station", and "could not add phy context".
For some reason, bsd.rd kernels were suffering particularly hard from such
problems, to the point where some machines could not be upgraded over iwm(4).
This change does not eliminate such problems entirely but is a step forward.
Prodded by deraadt@
This change has already been in snaps for a while.