aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/pci
Commit message (Collapse)AuthorAgeFilesLines
* vga_pci: Use bus_generic_* directly instead of wrappersJohn Baldwin2024-11-301-16/+2
| | | | | | Differential Revision: https://reviews.freebsd.org/D47375 (cherry picked from commit c7d29adcb3ce6544eb30c6b5489999d8f001cb71)
* ignore_pci: Add a proper stub attach routineJohn Baldwin2024-11-301-1/+8
| | | | | | | | | This isn't a bus driver, so an empty attach routine is more appropriate. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D47220 (cherry picked from commit f2e50ce0a37a40363b7ec6a165aa0b0a2e81ffc4)
* fixup_pci: Remove unused attach DEVMETHODJohn Baldwin2024-11-301-1/+0
| | | | | | | | | | | | | The probe routine always fails, so the attach routine is unused. However, this weird driver is really a quirk system for PCI and should be turned into PCI quirks instead. The Natoma quirk is also broken as it should be doing a runtime check either on mp_ncpus (or more likely to see if it is using APIC) instead of #ifdef. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D47219 (cherry picked from commit 1cddce89ce30570d554120af864d23c554cd5d18)
* pci_iov: Add a device_printf if out of bus numbersVal Packett2024-10-021-0/+1
| | | | | | | Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D20591 (cherry picked from commit 6a4f0c063718781c5e3eddbeff0da7b89d290d1e)
* pci: Fix pci_host_generic_acpi with gccAndrew Turner2024-07-151-3/+2
| | | | | | | | | | | | | | | In pci_host_generic_acpi.c we loop over pci_acpi_quirks to check if we need to handle any quirks. GCC doesn't like the terminatin as it sets a fixed width string to 0. As this the array is only ever used in this file change to use nitems to find when to stop the loop. Reviewed by: brooks, imp, jhb, emaste Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D45265 (cherry picked from commit f55e866488ba2d8bb5b79659ee84bec1fe7808fb)
* iovctl: allow vlan restrictions to be passed to the driverKristof Provost2024-07-011-0/+61
| | | | | | | | | | | Allow iovctl to create VFs that are restricted to specific VLAN IDs. Reviewed by: kib, np MFC after: 2 weeks Sponsored by: Orange Business Services Differential Revision: https://reviews.freebsd.org/D45402 (cherry picked from commit c57c26179033f64c2011a2d2a904ee3fa62e826a)
* pcireg.h: Add AMD IOMMU Base Cap definitionsKonstantin Belousov2024-04-171-0/+52
| | | | (cherry picked from commit 33adb388c78ee48efbdc9b497fe2224397fdee84)
* pcireg.h: add include guardKonstantin Belousov2024-04-171-0/+5
| | | | (cherry picked from commit 1cd9868f04c3e91929974dca3444a79047f4e602)
* pcib: Make various bus methods private to pci_pci.cJohn Baldwin2024-04-082-15/+13
| | | | | | | | | | These functions are not used by pcib subclasses so do not need to be exposed in pcib_private.h. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D43688 (cherry picked from commit 03719c651430d46cd8aa95aead02a7f0c43dcb04)
* pci_cfgreg: Add a PCI domain argument to the low-level register APIJohn Baldwin2024-01-182-10/+11
| | | | | | | | | | | | | | | | | | | | | | | | | This commit changes the API of pci_cfgreg(read|write) to add a domain argument (referred to as a segment in ACPI parlance) (note that this is not the same as a NUMA domain, but something PCI-specific). This does not yet enable access to domains other than 0, but updates the API to support domains. Places that use hard-coded bus/slot/function addresses have been updated to hardcode a domain of 0. A few places that have the PCI domain (segment) available such as the acpi_pcib_acpi.c Host-PCI bridge driver pass the PCI domain. The hpt27xx(4) and hptnr(4) drivers fail to attach to a device not on domain 0 since they provide APIs to their binary blobs that only permit bus/slot/function addressing. The x86 non-ACPI PCI bus drivers all hardcode a domain of 0 as they do not support multiple domains. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D42827 (cherry picked from commit 1587a9db92c03c738bb3f0fc5874b43c961e7c99)
* sys: Remove $FreeBSD$: one-line sh patternWarner Losh2023-08-234-4/+0
| | | | | | | Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/ Similar commit in current: (cherry picked from commit 031beb4e239b)
* sys: Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-2318-36/+0
| | | | | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/ Similar commit in current: (cherry picked from commit 685dc743dc3b)
* sys: Remove $FreeBSD$: two-line .h patternWarner Losh2023-08-2311-22/+0
| | | | | | | Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/ Similar commit in current: (cherry picked from commit 95ee2897e98f)
* pci: return 0 for pci_remap_intr_method MSI-X non-error caseEd Maste2023-08-211-1/+4
| | | | | | | | | | | | | | | | When remapping a MSI-X vector, we would always return ENOENT, even if successful. This didn't really matter, as the sole caller of BUS_REMAP_INTR also didn't check for errors. Return 0 if there's no error, so that we can start handling (or at least warning about) actual failures. Reviewed by: jhb MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D41449 (cherry picked from commit 43e545e8e016d22346a4fe278ea2570328b20cc1)
* spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh2023-07-2512-12/+12
| | | | | | | | | | | The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch up to that fact and revert to their recommended match of BSD-2-Clause. Discussed with: pfg MFC After: 3 days Sponsored by: Netflix (cherry picked from commit 4d846d260e2b9a3d4d0a701462568268cbfe7a5b)
* pcib: Allocate the memory BAR with the MSI-X table.John Baldwin2023-06-282-5/+19
| | | | | | | | | | | | This is required for pci_alloc_msix() to work and to thus use MSI-X interrupts for PCI-e hotplug. Reported by: cperciva Reviewed by: cperciva MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D40581 (cherry picked from commit e6b838363fb473b5e35a8ae6a1da5e15f5b52960)
* Add the fixed memory type to the pci ecam driverAndrew Turner2023-05-151-3/+20
| | | | | | | | | | | | Add ACPI_RESOURCE_TYPE_FIXED_MEMORY32 to the PCI ECAM driver. This is used on the Microsoft Dev Kit 2023 and reportedly the Lenovo x13s. Reviewed by: Robert Clausecker <fuz@fuz.su> (Earlier version) Tested by: Robert Clausecker <fuz@fuz.su> (Earlier version) Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D38031 (cherry picked from commit 896f556205c8d87ef842dc844752daa7d2385336)
* pci: add tunable hw.pci.enable_mps_tuneCorvin Köhne2023-04-051-1/+7
| | | | | | | | | | | | | | | | If the tunable is set to 0, the tuning of the MPS (maximum payload size) is disabled and the default MPS values set by the BIOS are used. In this case the system may use a lower speed or operate in a less optimized state, but it can resolve issues with stability and compatibility. With specific devices the tuning of the mps, can lead to a complete freeze of the system. Reviewed by: manu MFC after: 1 week Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D38397 (cherry picked from commit 48d70503bcae816eea6109c30ba79261eb47c9d0)
* pcireg.h: Add values for ACS PCIe Extended capability.Navdeep Parhar2023-02-021-0/+25
| | | | | | | | | | | These values come from section 7.7.11 ("ACS Extended Capability") of the PCI Express Base Specification Revision 6.0, dated 16 Dec 2021. Sponsored by: Chelsio Communications Reviewed by: kib@ Differential Revision: https://reviews.freebsd.org/D37270 (cherry picked from commit b2700160cc4f5ff7d64926ea55a214b5ac970cf5)
* pci: Disable Electromechanical Interlock.Alexander Motin2022-10-181-1/+7
| | | | | | | | | | | | | | | Add sysctl/tunable to control Electromechanical Interlock support. Disable it by default since Linux does not do it either and it seems the number of systems having it broken is higher than having working. This fixes NVMe backplane operation on ASUS RS500A-E11-RS12U server with AMD EPYC 7402 CPU, where attempts to control reported interlock for some reason end up in PCIe link loss, while interlock status does not change (it is not really there). MFC after: 2 weeks (cherry picked from commit a58536b91ae3931d222c3e4f1a949ff4a4927fb2)
* pci_host_generic: stop address translation in bus_alloc_resourceKyle Evans2022-10-171-11/+0
| | | | | | | | | | | | | | | | | | | | Translating the provided range prior to rman_reserve_resource(9) is decidedly wrong; the caller may be trying to do a wildcard allocation, for which the implementation is expected to DTRT and clamp the range to what's actually feasible. We don't use the resulting translation here anyways, so just remove it entirely -- the rman in the default implementation is derived from sc->ranges, so the translation should trivially succeed every time as long as the reservation succeeded. If something has gone awry in a derived driver, we'll detect it when we translate prior to activation, so there's likely no diagnostic value in retaining the translation after reservation either. Reviewed by: andrew Noticed by: jhb (cherry picked from commit bd93b5f79ab489fb0ed6ab25d6be48242eb8c028)
* Mark cfg as __unused to avoid ifdef soupWarner Losh2022-10-021-2/+2
| | | | | | Sponsored by: Netflix (cherry picked from commit 09b966ee7c6389db635f793377cc50cb2fcb4962)
* pci(4): Fix a typo in asource code commentGordon Bergling2022-09-061-1/+1
| | | | | | - s/overriden/overridden/ (cherry picked from commit 6b497700885b21106235a1ee7bfd31194e4ca42b)
* pci: Add helper routines to iterate over a device's BARs.John Baldwin2022-08-252-0/+17
| | | | | | | | | Reviewed by: imp, markj, emaste MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D36237 (cherry picked from commit 16bedf532c022f2380b0bb2970a3a3ebc7ca0f36)
* Clean up in the pci host generic driverAndrew Turner2022-07-192-9/+43
| | | | | | | | | | | Add clean up on failure and a detach function to the pci host generic driver. Reviewed by: jhb (earlier version) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D35291 (cherry picked from commit d843dd0e1addd2aa69a78be99e251147aafcfd80)
* pci(4): Fix a common typo in source code commentsGordon Bergling2022-07-081-4/+4
| | | | | | - s/transistions/transitions/ (cherry picked from commit 00c00c3824cb32abf732a8eb177eaba9385dab8b)
* Create wrapper for Giant taken for newbusWarner Losh2022-06-212-4/+7
| | | | | | | | | | | | | Create a wrapper for newbus to take giant and for busses to take it too. bus_topo_lock() should be called before interacting with newbus routines and unlocked with bus_topo_unlock(). If you need the topology lock for some reason, bus_topo_mtx() will provide that. Sponsored by: Netflix Reviewed by: mav Differential Revision: https://reviews.freebsd.org/D31831 (cherry picked from commit c6df6f5322f7004c71216391e1c0b374d853704a)
* pci: Fix a -Wunused-but-set-variable warningMark Johnston2022-03-071-2/+0
| | | | (cherry picked from commit 4db93fb278fce5f1034a9868413a641d9554214e)
* pci_host_generic: update Synopsys device description for ACPIMarcin Wojtas2022-03-071-0/+2
| | | | | | | | | | The recent addition of Synopsys ECAM quirk set the device description only for the DT variant. Do the same in ACPI case. Reported by: jrtc27 (cherry picked from commit e8a872536042970b4dbf14dc75755a352fb14488)
* pci_host_generic: Add Synopsys Designware PCIe controller quirkPawel Anikiel2022-03-074-0/+46
| | | | | | | | | | | | | | | Due to the quirky nature of the Synopsys Designware PCIe IP, the type 0 configuration is broadcast and whatever device is plugged into slot, will appear at each 32 device positions of bus0. Mitigate the issue by filtering out duplicated devices on this bus for both DT and ACPI cases. Reviewed by: mw Sponsored by: Semihalf MFC: after 3 weeks Differential revision: https://reviews.freebsd.org/D31887 (cherry picked from commit 2de4c7f6d08798fb6269582907155703d1ab5ef4)
* dev/pci: fix potential panic due to bogus VPD dataStefan Eßer2022-03-042-10/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A panic has been observed on a system with a Intel X520 dual LAN device. The panic is caused by a KASSERT() noticing that the amount of VPD data copied out to the pciconf command does not match the amount of data read from the device. The cause of the size mismatch was VPD data that started with 0x82, the VPD tag that indicates that a VPD ident follows, but with a length of more than 255 characters, which happens to be the maximum ident size supported by the API between kernel and the pciconf program. The data provided did not resemble an actual VPD identifier, and it can be assumed that the initial tag value 0x82 happens to be there by accident. An ident size of 255 far exceeds the sensible length of that data element, which is in the order of at most 30 to 40 bytes. This patch adds several consitstency checks to the VPD parser, the most critical being that ident lengths of more than 255 bytes are rejected. Other checks reject VPD with more than one ident tag or with an empty (zero length) ident string. This patch prevents the panic that occured when "pciconf -lV" was executed on the affected system. During the anaylsis of the issue and the VPD code it has been found that the VPD parser uses a state machine that accepts tags in any order and combination. This is a bad match for the actual VPD data, which has a very simple structure that can be parsed with a non-recursive direct descent parser (which always knows exactly which token to expect next). A review fpr a much simpler VPD parser that performs many more consistency checks and rejects invalid VPD has been proposed in review https://reviews.freebsd.org/D34268. (cherry picked from commit f01c863337f7b097d03069daee359b6b5ecd0279)
* pci_dw_mv: Don't enable unhandled interrupts.Michal Meloun2022-01-201-2/+2
| | | | | | | | Mainly link errors interrupts should only be activated on fully linked port, otherwise noise on lanes can cause livelock. But we don't have error counters yet, so leave these interrupts disabled. (cherry picked from commit ce5a4083de2d79bc44d209c9e355a09ede47346c)
* pci: Don't try to read cfg registers of non-existing devicesKornel Duleba2021-12-151-5/+10
| | | | | | | | | | | | | | | | | | | | | Instead of returning 0xffs some controllers, such as Layerscape generate an external exception when someone attempts to read any register of config space of a non-existing device other than PCIR_VENDOR. This causes a kernel panic. Fix it by bailing during device enumeration if a device vendor register returns invalid value. (0xffff) Use this opportunity to replace some hardcoded values with a macro. I believe that this change won't have any unintended side-effects since it is safe to assume that vendor == 0xffff -> hdr_type == 0xffff. Sponsored by: Alstom Obtained from: Semihalf Reviewed by: jhb MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D33059 (cherry picked from commit 68cbe189fdd3c572476f8af9219a5d335f05b51a)
* pci: Implement pci_bar_enabled() for SR-IOV VFsMark Johnston2021-11-153-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | In a VF's configuration space, "memory space enable" is hard-wired to 0, so the existing implementation always returns false. We need to read the SR-IOV control register from the PF device to get the value of the MSE bit. Fix pci_bar_enabled() to read this register instead for VFs. I don't see any way to access the PF's config space without a backpointer in the pci device ivars, so I added one. This fixes a regression where bhyve(8) fails to map the MSI-X table after commit 7fa233534736 ("bhyve: Map the MSI-X table unconditionally for passthrough") when a VF is passed through, since with that commit we use PCIOCBARMMAP to map the table and that ioctl always fails for VFs without this change. As a bonus, pciconf(8) now correctly reports the enablement of BARs for VFs. Reported and tested by: Raúl Muñoz <raul.munoz@custos.es> Reviewed by: rstone, jhb Sponsored by: The FreeBSD Foundation (cherry picked from commit 1f960e646b7280795766fdaa183e3b9bd4cea345)
* LinuxKPI: Support lazy BAR allocationJessica Clarke2021-10-242-1/+5
| | | | | | | | | | | | | | | Linux KPIs like pci_resource_start/len assume that BARs have been allocated, but FreeBSD lazily allocates BARs if it cannot allocate the firmware-allocated BARs. Thus using the Linux KPIs must force allocation of the BARs rather than returning 0 for the start and length, which can crash drm-kmod drivers that assume the BARs are valid. This is needed for the AMDGPU driver to be able to attach on SiFive's HiFive Unmatched. Reviewed by: hselasky, jhb, mav MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D32447 (cherry picked from commit 82098c8bb5b303c7c8b48e7537fadfe74b375bd3)
* pci_pci: Support growing bus ranges in bus_adjust_resource for NEW_PCIBJessica Clarke2021-10-101-1/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is the same underlying problem as 262459806433, just for bus ranges rather than windows. SiFive's HiFive Unmatched has the following topology: Root Port <---> Bridge <---> Bridge <-+-> Bridge <---> (Unused) (pcib0) (pcib1) (pcib2) | (pcib3) +-> Bridge <---> xHCI | (pcib4) +-> Bridge <---> M.2 E-key | (pcib5) +-> Bridge <---> M.2 M-key | (pcib6) +-> Bridge <---> x16 slot (pcib7) If a device is plugged into the x16 slot that itself has a bridge, such as many graphics cards, we currently fail to allocate a bus number for its child bus (and so pcib_attach_child skips adding a child bus for further enumeration) as, when the new child bridge attaches, it attempts to allocate a bus number from its parent (pcib7) which in turn attempts to grow its own bus range by calling bus_adjust_resource on its own parent (pcib2) whose bus rman cannot accommodate the request and needs to itself be extended by calling its own parent (pcib1). Note that pcib3-7 do not face the same issue when they attach since pcib1 ends up managing bus numbers 1-255 from the beginning and so never needs to grow its own range. Reviewed by: jhb, mav MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D32011 (cherry picked from commit 31776afdc79d5fb1ea211cc2a69c17c62b3dc8ff)
* pcib(4): Switch from callout to timeout_task.Alexander Motin2021-10-042-41/+45
| | | | | | | | | This allows to avoid blocking on Giant in callout context, moving to already existing dedicated taskqueue_pci_hp thread. MFC after: 1 month (cherry picked from commit fa3b03d378546b74582613431bab537d3488d81f)
* pci_dw: Drop unconditional explicit DEBUG defineJessica Clarke2021-09-071-1/+0
| | | | | | | | | | | | | | | | | This has been present since the first revision of the file. The debugf macros have always been unused so it doesn't actually do anything useful, and besides, debugging should not be unconditionally turned on for a production driver. Moreover, this breaks the riscv LINT kernel build as sys/conf/NOTES includes options DEBUG, resulting in a macro redefinition error. This does not show up in the arm64 LINT kernel build since that has an explicit nooptions DEBUG, which is dubious and should be revisited. Rather than copy such a hack to riscv's NOTES, fix this specific instance of DEBUG breaking. Fixes: 896e217a0eae ("fu740_pci_dw: Add SiFive FU740 PCIe controller driver") MFC after: 1 week (cherry picked from commit 22997b755013bdde60119fdc781769192ab7e1e0)
* pci_dw: Detect number of outbound regions automaticallyJessica Clarke2021-09-072-10/+78
| | | | | | | | | | | | | | Currently we use the num-viewports property to decide how many outbound regions there are we can use, defaulting to 2. However, Linux has stopped using that and so it no longer appears in new device trees, such as for the SiFive FU740. Instead, it's possible to just probe the hardware directly. Reviewed by: mmel MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D31030 (cherry picked from commit 4707bb0430e6ca3935ef8196e30830b3cdaf3514)
* pci_dw: Support modern "unroll" iATU modeJessica Clarke2021-09-072-3/+114
| | | | | | | | | | | | This supersedes the old legacy mode where a viewport register was used to mux multiple regions behind a single set of registers, and is used on the SiFive FU740. Reviewed by: mmel MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D31029 (cherry picked from commit f240dfff229d1f1ff502f59901ef2b9364ca55d9)
* pci_dw: Support multiple memory windowsJessica Clarke2021-09-072-49/+63
| | | | | | | | | | | | | | | | | | | | | Currently we assume there is only one memory and one prefetch memory window, and ignore the latter. However, the SiFive FU740 has two normal memory windows. As part of this, the viewports are rearranged. Previously the viewports were memory, config then optionally I/O. Both to simplify the config index calculation and to ensure it can always be mapped even if we have too many memory windows for the number of viewports, config is moved to being the first viewport. This generalisation now also naturally supports mapping prefetch memory windows. Reviewed by: mmel MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D31028 (cherry picked from commit f8c1701f23b5b99365ffab2a067e4676b905ab57)
* pci_dw: Trim ATU windows bigger than 4GBWojciech Macek2021-09-071-0/+12
| | | | | | | | | | | | | | The size of the ATU MEM/IO windows is implicitly casted to uint32_t. Because of that some window sizes were silently demoted to 0 and ignored. Check the size if its too large, trim it to 4GB and print a warning message. Submitted by: Kornel Duleba <mindal@semihalf.com> Reviewed by: mw Obtained from: Semihalf Sponsored by: Marvell Differential revision: https://reviews.freebsd.org/D29625 (cherry picked from commit 243000b19f8b4ab104b584b2d16bc6aa9131c9b5)
* pci_dw: fix outbound I/O window configurationMarcin Wojtas2021-09-071-1/+1
| | | | | | | | | | | | Use viewport "2" instead of "0" and change window type from MEM to IO. Without these changes the MEM ATU window can be overwritten with the IO one. Submitted by: Kornel Duleba <mindal@semihalf.com> Obtained from: Semihalf Sponsored by: Marvell Differential revision: https://reviews.freebsd.org/D29516 (cherry picked from commit 57dbb3c25936f0d61fef152eb224ca86a73af0e9)
* pcib(4): Write window registers after resource adjustmentAlexander Motin2021-09-011-1/+11
| | | | | | | | | | | | | | | | | | When adjusting resources we should write updated window base/limit into the registers. Without this newly added address range won't be routed through the bridge properly. Use MIN()/MAX() against current window base/limit to not shrink it on the other side if the window is shared by several resources. Align passed resource start/end to the set window granularity to keep it properly aligned. Currently this is mostly called by other bridges having the same window alignment, but it may be change one day. Reviewed by: jrtc27, jhb MFC after: 1 week Sponsored by: iXsystems, Inc. Differential Revision: https://reviews.freebsd.org/D31693
* pci_pci: Support growing windows in bus_adjust_resource for NEW_PCIBJessica Clarke2021-09-011-15/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If we allocate a new window for a bridge rather than reusing an existing one set up by firmware to cover all the devices then the new window only includes the range needed for the first device to allocate the resource. If a request comes in to adjust this resource in order to extend a downstream window for another device then this will fail as the rman doesn't have any space, so we must first grow the bridge's own window. This is needed to support successfully attaching more than one PCI device on SiFive's HiFive Unmatched, which has the following topology: Root Port <---> Bridge <---> Bridge <-+-> Bridge <---> (Unused) (pcib0) (pcib1) (pcib2) | (pcib3) +-> Bridge <---> xHCI | (pcib4) +-> Bridge <---> M.2 E-key | (pcib5) +-> Bridge <---> M.2 M-key | (pcib6) +-> Bridge <---> x16 slot (pcib7) Without this, the xHCI endpoint successfully attaches but NVMe M.2 M-key endpoint fails to attach as, when its adjacent bridge (pcib6) attempts to allocate a window from its parent (pcib2) on the other side of the switch, its parent attempts to grow its own window by calling bus_adjust_resource on its own parent (pcib1) which fails to call the root port device (pcib0) to request more memory to grow its own window. Had the root port been directly connected to the switch without the bridge in the middle then the existing code would have worked, but the extra hop broke it. Reviewed by: jhb MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D31035
* pci: Add an ioctl to perform I/O to BARsMark Johnston2021-08-291-0/+100
| | | | | | | | | | | This is useful for bhyve, which otherwise has to use /dev/io to handle accesses to I/O port BARs when PCI passthrough is in use. Reviewed by: imp, kib Discussed with: jhb Sponsored by: The FreeBSD Foundation (cherry picked from commit 7e14be0b0717105f4b3b8c62df82a1e883d8ebb6)
* /dev/pci: clarify meaning of writeable file descriptorKonstantin Belousov2021-08-031-1/+6
| | | | (cherry picked from commit 85ae35ef37c07c32d4e923435b637cbf0df3e8a3)
* pci: enhance printf for leaked MSI[-X] vectorsBjoern A. Zeeb2021-07-181-1/+6
| | | | | | | | | | | | When debugging leaked MSI/MSI-X vectors through LinuxKPI I found the informational printf unhelpful. Rather than just stating we leaked also tell how many MSI or MSI-X vectors we leak. Sponsored by: The FreeBSD Foundation Reviewed by: jhb Differential Revision: https://reviews.freebsd.org/D29394 (cherry picked from commit a9f0367b04b385e7bed47914662badf5ab18bc88)
* PCI hot-plug: use dedicated taskqueue for device attach / detachAndriy Gapon2021-05-211-2/+4
| | | | | | | | | | | | | | | | | | | | Attaching and detaching devices can be heavy-weight and detaching can sleep waiting for events. For that reason using the system-wide single-threaded taskqueue_thread is not really appropriate. There is even a possibility for a deadlock if taskqueue_thread is used for detaching. In fact, there is an easy to reproduce deadlock involving nvme, pass and a sudden removal of an NVMe device. A pass peripheral would not release a reference on an nvme sim until pass_shutdown_kqueue() is executed via taskqueue_thread. But the taskqueue's thread is blocked in nvme_detach() -> ... -> cam_sim_free() because of the outstanding reference. Sponsored by: CyberSecure Reviewed by: mav, imp (cherry picked from commit 12588ce02dd835b332952d9fece5881d943554a9)
* Set PCIe device's Max_Payload_Size to match PCIe root's.Alexander Motin2021-05-051-0/+40
| | | | | | | | | | | | | Usually on boot the MPS is already configured by BIOS. But we've found that on hot-plug it is not true at least for our Supermicro X11 boards. As result, mismatch between root's configuration of 256 bytes and device's default of 128 bytes cause problems for some devices, while others seem to work fine. MFC after: 1 month Sponsored by: iXsystems, Inc. (cherry picked from commit 5a898b2b78ce04d608bbaaa0813424b11f921ae7)