Page MenuHomeFreeBSD

bge: Convert driver to CTLFLAG_MPSAFE
Needs ReviewPublic

Authored by seuros on Jan 9 2026, 1:29 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Sep 14, 9:42 PM
Unknown Object (File)
Sun, Sep 6, 5:26 AM
Unknown Object (File)
Wed, Aug 26, 11:11 AM
Unknown Object (File)
Sun, Aug 23, 2:57 PM
Unknown Object (File)
Aug 8 2026, 6:26 PM
Unknown Object (File)
Aug 8 2026, 1:01 PM
Unknown Object (File)
Jul 31 2026, 1:16 AM
Unknown Object (File)
Jul 26 2026, 2:47 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

seuros requested review of this revision.Jan 9 2026, 1:29 PM

@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.