Page MenuHomeFreeBSD

bge: Convert driver to CTLFLAG_MPSAFE
Needs ReviewPublic

Authored by guest-seuros on Jan 9 2026, 1:29 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Mar 12, 4:55 PM
Unknown Object (File)
Thu, Mar 12, 10:13 AM
Unknown Object (File)
Wed, Mar 11, 1:12 PM
Unknown Object (File)
Sat, Mar 7, 9:49 PM
Unknown Object (File)
Sun, Mar 1, 5:00 AM
Unknown Object (File)
Tue, Feb 24, 6:05 AM
Unknown Object (File)
Sun, Feb 22, 9:28 AM
Unknown Object (File)
Fri, Feb 20, 12:50 PM
This revision needs review, but there are no reviewers specified.

Details

Reviewers
None
Summary

Replace CTLFLAG_NEEDGIANT with CTLFLAG_MPSAFE for all sysctls.
The driver uses mutex bge_mtx for hardware access and does not
require Giant lock.

Sysctls converted:

  • Debug sysctls (debug_info, reg_read, ape_read, mem_read)
  • Statistics sysctls (read-only hardware stats)

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 69749
Build 66632: arc lint + arc unit

Event Timeline

@tuexen I see you're the most recent committer to touch bge, would you take a look?

zlei added inline comments.
sys/dev/bge/if_bge.c
6240

bge_sysctl_mem_read() invokes bge_readmem_ind(),

static uint32_t
bge_readmem_ind(struct bge_softc *sc, int off)
{
        device_t dev;
        uint32_t val;

        if (sc->bge_asicrev == BGE_ASICREV_BCM5906 &&
            off >= BGE_STATS_BLOCK && off < BGE_SEND_RING_1_TO_4)
                return (0);

        dev = sc->bge_dev;

        pci_write_config(dev, BGE_PCI_MEMWIN_BASEADDR, off, 4);
        val = pci_read_config(dev, BGE_PCI_MEMWIN_DATA, 4);
        pci_write_config(dev, BGE_PCI_MEMWIN_BASEADDR, 0, 4);
        return (val);
}

It appears bge_readmem_ind() is not immune to concurrent access.