> On 14 Aug 2022, at 23:35, Jeremie Courreges-Anglas <[email protected]> wrote:
>
> On Sun, Aug 14 2022, Vitaliy Makkoveev <[email protected]> wrote:
>> I propose to avoid netlock relocking for SIOCGIFSFFPAGE too.
>
> sigh, that seems to be needed indeed.
>
>> Also, since the relock should be avoided for many commands, I prefer
>> to have something like below:
>>
>> switch(cmd){
>> case SIOCGIFMEDIA:
>> case ...:
>> relock = 1;
>> break;
>> }
>>
>> if (relock)
>> NET_UNLOCK();
>
> Fine with me. "netlock_held" made more sense to me as the variable
> name, I hope you won't mind. ;)
>
No problem, ok by me.
> Works fine on GENERIC.MP.
>
>
> Index: dev/fdt/if_cad.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/fdt/if_cad.c,v
> retrieving revision 1.11
> diff -u -p -r1.11 if_cad.c
> --- dev/fdt/if_cad.c 8 Mar 2022 16:13:08 -0000 1.11
> +++ dev/fdt/if_cad.c 14 Aug 2022 20:20:00 -0000
> @@ -550,12 +550,22 @@ cad_ioctl(struct ifnet *ifp, u_long cmd,
> {
> struct cad_softc *sc = ifp->if_softc;
> struct ifreq *ifr = (struct ifreq *)data;
> - int error = 0;
> + int error = 0, netlock_held = 1;
> int s;
>
> - NET_UNLOCK();
> + switch (cmd) {
> + case SIOCGIFMEDIA:
> + case SIOCSIFMEDIA:
> + case SIOCGIFSFFPAGE:
> + netlock_held = 0;
> + break;
> + }
> +
> + if (netlock_held)
> + NET_UNLOCK();
> rw_enter_write(&sc->sc_cfg_lock);
> - NET_LOCK();
> + if (netlock_held)
> + NET_LOCK();
> s = splnet();
>
> switch (cmd) {
>
>
> --
> jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE