Page MenuHomeFreeBSD

LinuxKPI: Add pcie_capability_clear_and_set_word() function
ClosedPublic

Authored by wulf on Nov 28 2023, 9:36 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, May 23, 8:37 PM
Unknown Object (File)
Thu, May 23, 8:37 PM
Unknown Object (File)
May 8 2024, 11:32 AM
Unknown Object (File)
May 8 2024, 11:31 AM
Unknown Object (File)
May 8 2024, 11:31 AM
Unknown Object (File)
May 8 2024, 11:31 AM
Unknown Object (File)
May 8 2024, 9:26 AM
Unknown Object (File)
Mar 17 2024, 10:52 AM

Details

Summary

It does a Read-Modify-Write operation using clear and set bitmasks on
PCI Express Capability Register at pos. As certain PCI Express
Capability Registers are accessed concurrently in RMW fashion, hence
require locking which is handled transparently to the caller.

Sponsored by: Serenity CyberSecurity, LLC
MFC after: 1 week
MFC TODO: Move pcie_cap_lock to bottom to preserve KBI compatibility

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

wulf requested review of this revision.Nov 28 2023, 9:36 PM
This revision is now accepted and ready to land.Nov 29 2023, 6:19 AM
bz requested changes to this revision.Dec 8 2023, 6:01 PM
bz added a reviewer: jhb.

How does that lock prevent us from any other changes at the same time by anything calling pcie_capability_write_word() in between?

This revision now requires changes to proceed.Dec 8 2023, 6:01 PM

Add locking in pcie_capability_set_word() and pcie_capability_clear_word()

In D42821#979762, @bz wrote:

How does that lock prevent us from any other changes at the same time by anything calling pcie_capability_write_word() in between?

It will not prevent. On Linux only pcie_capability_clear_and_set_word(), pcie_capability_clear_word() and pcie_capability_clear_and_set_word() are protected with this lock.

Even with the other locks it won't give us want we want. I assume it's likely okay to accept the race as otherwise we'd probably have to sort this out in the native PCI layer? @jhb?

sys/compat/linuxkpi/common/src/linux_pci.c
528

There's probably a destroy missing for this?

It's probably ok to just depend on this lock and not worry about other readers/writers to these config registers as they are rarely read or written.

sys/compat/linuxkpi/common/src/linux_pci.c
528

Yeah, you will need a destroy.

Lock destructors are added

This revision is now accepted and ready to land.Dec 17 2023, 5:06 PM