Page MenuHomeFreeBSD

pci: restore configuration state after resetting a detached child
Needs ReviewPublic

Authored by nick_spun.io on Mon, Sep 7, 9:29 PM.
Tags
Referenced Files
F174000417: D59499.diff
Tue, Sep 29, 9:29 PM
F173967122: D59499.diff
Tue, Sep 29, 4:57 PM
Unknown Object (File)
Mon, Sep 28, 2:18 PM
Unknown Object (File)
Fri, Sep 25, 6:00 PM
Unknown Object (File)
Fri, Sep 25, 8:46 AM
Unknown Object (File)
Thu, Sep 24, 4:39 PM
Unknown Object (File)
Thu, Sep 24, 6:13 AM
Unknown Object (File)
Thu, Sep 24, 3:51 AM
Subscribers

Details

Summary

pcie_flr() saves and restores nothing; pairing it with
pci_save_state() and pci_restore_state() is the caller's job. On the
DEVF_RESET_DETACH path of pci_reset_child(), device_detach() saves
through pci_child_detached() and nothing restores. The only restore,
BUS_RESET_POST(), runs when pcie_flr() reports that no reset was
performed.

An FLR returns configuration space to its defaults, so the reprobe
runs against a function whose BARs read zero.

Restore the saved state before reprobing.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 76655
Build 73538: arc lint + arc unit

Event Timeline

Hmmm, so in theory device_detach() might power off the child. I guess that's ok. I have some WIP that will "fix" this more properly by having device_probe_and_attach() invoke a pre-probe bus_if.m method that for PCI restores the saved state that would handle this transparently, but this is ok for now.

sys/dev/pci/pci.c
7330

Hmm, for DS_BUSY this just bogusly returns 0 without detaching the device. I think this needs to be >= DS_ATTACHED.