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)
Mon, Apr 22, 9:50 AM
Unknown Object (File)
Feb 23 2024, 7:40 PM
Unknown Object (File)
Feb 7 2024, 4:22 PM
Unknown Object (File)
Feb 1 2024, 11:46 AM
Unknown Object (File)
Dec 22 2023, 11:08 PM
Unknown Object (File)
Nov 14 2023, 4:25 AM
Unknown Object (File)
Nov 10 2023, 8:36 PM
Unknown Object (File)
Nov 1 2023, 12:35 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
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

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.

514

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.

521

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