Page MenuHomeFreeBSD

bus: Make BUS_TRANSLATE_RESOURCE behave more like other bus methods
ClosedPublic

Authored by markj on Nov 5 2021, 6:19 PM.
Tags
None
Referenced Files
Unknown Object (File)
Oct 4 2024, 11:07 PM
Unknown Object (File)
Oct 1 2024, 6:59 PM
Unknown Object (File)
Oct 1 2024, 4:26 AM
Unknown Object (File)
Sep 28 2024, 1:06 PM
Unknown Object (File)
Sep 28 2024, 1:05 AM
Unknown Object (File)
Sep 27 2024, 10:18 AM
Unknown Object (File)
Sep 25 2024, 12:28 PM
Unknown Object (File)
Sep 24 2024, 10:27 PM

Details

Summary
  • Return an errno value upon failure, instead of 1.
  • Provide a bus_translate_resource() wrapper.
  • Implement the generic version, which traverses the hierarchy until a bus driver with a non-trivial implementation is found, in subr_bus.c like other similar default implementations.
  • Make ofw_pcib_translate_resource() return an error if a matching PCI address range is not found.
  • Make generic_pcie_translate_resource_common() return an int instead of a bool. Fix up callers.

No functional change intended.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 42613
Build 39501: arc lint + arc unit

Event Timeline

markj requested review of this revision.Nov 5 2021, 6:19 PM
This revision is now accepted and ready to land.Nov 9 2021, 5:27 PM
sys/dev/ofw/ofw_pcib.c
489

I'd kill this.

516

and instead put *newstart = start; return (0); here. There's no locking issues to worry about for the single in single out pattern, nor are there likely to be.

523

and kill this else and just return ENOENT always.

sys/dev/pci/pci_host_generic.c
426

shouldn't this be != 0? If it was unsuccessful, we want to print the error message, no?

480

Do you need to undo the effects of rman_activate_resource() above here?

sys/dev/pci/pci_host_generic.c
426

The original looks wrong as well if translate_resource returned true for an error, so either it's wrong or the description in the review is wrong.

markj marked 5 inline comments as done.Nov 9 2021, 5:58 PM
markj added inline comments.
sys/dev/pci/pci_host_generic.c
426

This should be != 0, thanks. The confusing bit is that generic_pcie_translate_resource_common() returned a bool, "found", and generic_pcie_translate_resource() inverted the result. The code was right before.

480

Hmm, probably yes. In practice I don't think this error can happen.

markj marked an inline comment as done.

Handle Warner's notes:

  • Simplify ofw_pcib_translate_resource()
  • Fix an inverted test
  • Deactivate the resource in generic_pcie_activate_resource() if generic_pcie_translate_resource_common() fails
This revision now requires review to proceed.Nov 9 2021, 6:04 PM
markj marked an inline comment as done.Nov 9 2021, 6:05 PM

Thanks! Looks good to go now.

This revision is now accepted and ready to land.Nov 9 2021, 8:41 PM