Index | Thread | Search

From:
Jonathan Matthew <jonathan@d14n.org>
Subject:
Re: bse: mp-safe interrupts
To:
Vitaliy Makkoveev <mvs@openbsd.org>
Cc:
tech@openbsd.org
Date:
Thu, 19 Feb 2026 11:49:32 +1000

Download raw body.

Thread
On Sat, Feb 14, 2026 at 04:20:40PM +0300, Vitaliy Makkoveev wrote:
> On Sat, Feb 14, 2026 at 01:38:44PM +1000, Jonathan Matthew wrote:
> > On Fri, Feb 13, 2026 at 08:35:54PM +0300, Vitaliy Makkoveev wrote:
> > > Make the interrupt handler mp-asfe. Serialize the reception part of
> > > genet_intr() interrupt handler and genet_rxtick() timeout handler with
> > > `sc_mtx' mutex. The transmission part has nothing to do.
> > 
> > The timeout handler already has exclusive access to the receive ring
> > without adding a mutex here, so all you need to do is add IPL_MPSAFE.
> > 
> > The timeout is only armed when the interrupt handler has emptied the
> > ring and has not been able to refill it.  Once the ring is empty,
> > the interface can't receive any more packets until the timeout runs,
> > so the interrupt handler won't touch the receive ring.
> > We use this pattern in almost every mpsafe network driver.
> > 
> > 
> 
> Thanks. This means the mutex locking in the previous diff is just
> null-op and we can assume the following diff as identical.

ok jmatthew@

> 
> Index: sys/dev/acpi/if_bse_acpi.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/acpi/if_bse_acpi.c,v
> diff -u -p -r1.6 if_bse_acpi.c
> --- sys/dev/acpi/if_bse_acpi.c	6 Apr 2022 18:59:27 -0000	1.6
> +++ sys/dev/acpi/if_bse_acpi.c	14 Feb 2026 13:05:29 -0000
> @@ -90,7 +90,7 @@ bse_acpi_attach(struct device *parent, s
>  	}
>  
>  	sc->sc.sc_ih = acpi_intr_establish(aaa->aaa_irq[0],
> -	    aaa->aaa_irq_flags[0], IPL_NET, genet_intr,
> +	    aaa->aaa_irq_flags[0], IPL_NET | IPL_MPSAFE, genet_intr,
>  	    sc, sc->sc.sc_dev.dv_xname);
>  	if (sc->sc.sc_ih == NULL) {
>  		printf(": can't establish interrupt\n");
> Index: sys/dev/fdt/if_bse_fdt.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/fdt/if_bse_fdt.c,v
> diff -u -p -r1.2 if_bse_fdt.c
> --- sys/dev/fdt/if_bse_fdt.c	6 Apr 2022 18:59:28 -0000	1.2
> +++ sys/dev/fdt/if_bse_fdt.c	14 Feb 2026 13:05:29 -0000
> @@ -72,7 +72,7 @@ bse_fdt_attach(struct device *parent, st
>  		return;
>  	}
>  
> -	sc->sc_ih = fdt_intr_establish(faa->fa_node, IPL_NET,
> +	sc->sc_ih = fdt_intr_establish(faa->fa_node, IPL_NET | IPL_MPSAFE,
>  	    genet_intr, sc, sc->sc_dev.dv_xname);
>  	if (sc->sc_ih == NULL) {
>  		printf(": can't establish interrupt\n");