On Wed, Jan 17, 2024 at 11:46:36AM +0100, Radek wrote:
> ddb{0}> show panic
> *cpu0: kernel diagnostic assertion "pkt->pkt_m != NULL" failed: file 
> "/usr/src/
> sys/dev/pci/if_em.c", line 2580

> OpenBSD 7.4 (GENERIC.MP) #0: Fri Jan 12 09:31:37 CET 2024
>     r...@krz74.krz:/usr/src/sys/arch/amd64/compile/GENERIC.MP

It looks like you are running 7.4 release with a self compiled
kernel.  This diff from -current should fix your problem.

Protect em(4) refill timeout with splnet.

>From time to time "pkt->pkt_m == NULL" or "m != NULL" assertions
were hit in the em driver.  Stack trace shows that em refill timeout
was interrupted by em interrupt.  Doing em_rxfill() and em_rxeof()
simultaneously cannot be correct.  Protect softclock in em_rxrefill()
with splnet().

OK mglocker@

Index: dev/pci/if_em.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/dev/pci/if_em.c,v
diff -u -p -r1.368 if_em.c
--- dev/pci/if_em.c     3 Dec 2023 00:19:25 -0000       1.368
+++ dev/pci/if_em.c     29 Dec 2023 14:44:34 -0000
@@ -285,6 +285,7 @@ int  em_allocate_transmit_structures(str
 int  em_allocate_desc_rings(struct em_softc *);
 int  em_rxfill(struct em_queue *);
 void em_rxrefill(void *);
+void em_rxrefill_locked(struct em_queue *);
 int  em_rxeof(struct em_queue *);
 void em_receive_checksum(struct em_softc *, struct em_rx_desc *,
                         struct mbuf *);
@@ -1022,7 +1023,7 @@ em_intr(void *arg)
        if (ifp->if_flags & IFF_RUNNING) {
                em_txeof(que);
                if (em_rxeof(que))
-                       em_rxrefill(que);
+                       em_rxrefill_locked(que);
        }
 
        /* Link status change */
@@ -2958,6 +2959,16 @@ void
 em_rxrefill(void *arg)
 {
        struct em_queue *que = arg;
+       int s;
+
+       s = splnet();
+       em_rxrefill_locked(que);
+       splx(s);
+}
+
+void
+em_rxrefill_locked(struct em_queue *que)
+{
        struct em_softc *sc = que->sc;
 
        if (em_rxfill(que))
@@ -3954,7 +3965,7 @@ em_queue_intr_msix(void *vque)
        if (ifp->if_flags & IFF_RUNNING) {
                em_txeof(que);
                if (em_rxeof(que))
-                       em_rxrefill(que);
+                       em_rxrefill_locked(que);
        }
 
        em_enable_queue_intr_msix(que);

Reply via email to