From 19ae638fb64b6277682cd8f107183bb1fea3d57b Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Wed, 24 May 2023 17:36:55 -0400 Subject: [PATCH] pci/ecam: Fix reading config registers using ACPI method. Also adjust end-address computation: we read up to 4 bytes past the offset. Change-Id: I76343aba38cddb614394bd0dca1b36094b8dd85e Reviewed-on: https://review.haiku-os.org/c/haiku/+/6469 Reviewed-by: waddlesplash Reviewed-by: X512 Tested-by: Commit checker robot Reviewed-by: Adrien Destugues --- src/add-ons/kernel/busses/pci/ecam/ECAMPCIController.cpp | 5 +---- src/add-ons/kernel/busses/pci/ecam/ECAMPCIControllerACPI.cpp | 3 ++- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/add-ons/kernel/busses/pci/ecam/ECAMPCIController.cpp b/src/add-ons/kernel/busses/pci/ecam/ECAMPCIController.cpp index b283cddc61..686e8e8c0f 100644 --- a/src/add-ons/kernel/busses/pci/ecam/ECAMPCIController.cpp +++ b/src/add-ons/kernel/busses/pci/ecam/ECAMPCIController.cpp @@ -166,10 +166,7 @@ ECAMPCIController::ConfigAddress(uint8 bus, uint8 device, uint8 function, uint16 .device = device, .bus = bus }; - PciAddressEcam addressEnd = address; - addressEnd.offset = /*~(uint32)0*/ 4095; - - if (addressEnd.val >= fRegsLen) + if ((address.val + 4) > fRegsLen) return 0; return (addr_t)fRegs + address.val; diff --git a/src/add-ons/kernel/busses/pci/ecam/ECAMPCIControllerACPI.cpp b/src/add-ons/kernel/busses/pci/ecam/ECAMPCIControllerACPI.cpp index a9bb59a817..c3aa3f2e3d 100644 --- a/src/add-ons/kernel/busses/pci/ecam/ECAMPCIControllerACPI.cpp +++ b/src/add-ons/kernel/busses/pci/ecam/ECAMPCIControllerACPI.cpp @@ -57,8 +57,9 @@ ECAMPCIControllerACPI::ReadResourceInfo() uint8 startBusNumber = alloc->start_bus_number; uint8 endBusNumber = alloc->end_bus_number; + fRegsLen = (endBusNumber - startBusNumber + 1) << 20; fRegsArea.SetTo(map_physical_memory("PCI Config MMIO", - alloc->address, (endBusNumber - startBusNumber + 1) << 20, B_ANY_KERNEL_ADDRESS, + alloc->address, fRegsLen, B_ANY_KERNEL_ADDRESS, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA, (void **)&fRegs)); CHECK_RET(fRegsArea.Get());