Re: dwqe ifconfig down panic

2024-03-28 Thread Mark Kettenis
> Date: Thu, 28 Mar 2024 23:06:13 +0100
> From: Stefan Sperling 
> 
> On Wed, Mar 27, 2024 at 02:08:27PM +0100, Stefan Sperling wrote:
> > On Tue, Mar 26, 2024 at 11:05:49PM +0100, Patrick Wildt wrote:
> > > On Fri, Mar 01, 2024 at 12:00:29AM +0100, Alexander Bluhm wrote:
> > > > Hi,
> > > > 
> > > > When doing flood ping transmit from a machine and simultaneously
> > > > ifconfig down/up in a loop, dwqe(4) interface driver crashes.
> >  
> > > * Don't run TX/RX proc in case the interface is down?
> > 
> > The RX path already has a corresponding check. But the Tx path does not.
> > 
> > If the problem is a race involving mbufs freed via dwqe_down() and
> > mbufs freed via dwqe_tx_proc() then this simple tweak might help.
> 
> With this patch bluhm's test machine has survived 30 minutes of
> flood ping + ifconfig down/up in a loop. Without the patch the
> machine crashes within a few seconds.
> 
> I understand that there could be an issue in intr_barrier() which
> gets papered over by this patch. However the patch does avoid the
> crash and it is trivial to revert when testing the effectiveness
> of any potential intr_barrier() fixes.
> 
> ok?

since we already do this in the rx path, I think this is fine.

ok kettenis@

> > diff /usr/src
> > commit - 029d0a842cd8a317375b31145383409491d345e7
> > path + /usr/src
> > blob - 97f874d2edf74a009a811455fbf37ca56f725eef
> > file + sys/dev/ic/dwqe.c
> > --- sys/dev/ic/dwqe.c
> > +++ sys/dev/ic/dwqe.c
> > @@ -593,6 +593,9 @@ dwqe_tx_proc(struct dwqe_softc *sc)
> > struct dwqe_buf *txb;
> > int idx, txfree;
> >  
> > +   if ((ifp->if_flags & IFF_RUNNING) == 0)
> > +   return;
> > +
> > bus_dmamap_sync(sc->sc_dmat, DWQE_DMA_MAP(sc->sc_txring), 0,
> > DWQE_DMA_LEN(sc->sc_txring),
> > BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
> > > 
> > 
> > 
> 
> 



Re: dwqe ifconfig down panic

2024-03-28 Thread Stefan Sperling
On Wed, Mar 27, 2024 at 02:08:27PM +0100, Stefan Sperling wrote:
> On Tue, Mar 26, 2024 at 11:05:49PM +0100, Patrick Wildt wrote:
> > On Fri, Mar 01, 2024 at 12:00:29AM +0100, Alexander Bluhm wrote:
> > > Hi,
> > > 
> > > When doing flood ping transmit from a machine and simultaneously
> > > ifconfig down/up in a loop, dwqe(4) interface driver crashes.
>  
> > * Don't run TX/RX proc in case the interface is down?
> 
> The RX path already has a corresponding check. But the Tx path does not.
> 
> If the problem is a race involving mbufs freed via dwqe_down() and
> mbufs freed via dwqe_tx_proc() then this simple tweak might help.

With this patch bluhm's test machine has survived 30 minutes of
flood ping + ifconfig down/up in a loop. Without the patch the
machine crashes within a few seconds.

I understand that there could be an issue in intr_barrier() which
gets papered over by this patch. However the patch does avoid the
crash and it is trivial to revert when testing the effectiveness
of any potential intr_barrier() fixes.

ok?

> diff /usr/src
> commit - 029d0a842cd8a317375b31145383409491d345e7
> path + /usr/src
> blob - 97f874d2edf74a009a811455fbf37ca56f725eef
> file + sys/dev/ic/dwqe.c
> --- sys/dev/ic/dwqe.c
> +++ sys/dev/ic/dwqe.c
> @@ -593,6 +593,9 @@ dwqe_tx_proc(struct dwqe_softc *sc)
>   struct dwqe_buf *txb;
>   int idx, txfree;
>  
> + if ((ifp->if_flags & IFF_RUNNING) == 0)
> + return;
> +
>   bus_dmamap_sync(sc->sc_dmat, DWQE_DMA_MAP(sc->sc_txring), 0,
>   DWQE_DMA_LEN(sc->sc_txring),
>   BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
> > 
> 
>