aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/hyperv/pcib
Commit message (Collapse)AuthorAgeFilesLines
* Hyper-V: vPCI: fix cpu id mis-mapping in vmbus_pcib_map_msi()Wei Hu2024-03-111-1/+9
| | | | | | | | | | | | | | | | | | | The msi address contains apic id. The code in vmbus_pcib_map_msi() treats it as cpu id, which could cause mis-configuration of msix IRQs, leading to missing interrupts for SRIOV devices. This happens when apic id is not the same as cpu id on certain large VM sizes with multiple numa domains in Azure. Fix this issue by correctly mapping apic ids to cpu ids. On vPCI version before 1.4, it only supports up to 64 vcpus for msi/msix interrupt. This change also adds a check and returns error if the vcpu_id is greater than 63. (cherry picked from commit 999174ba03642fa63c9654752993a62db461afc9) Reported by: NetApp Tested by: whu Sponsored by: Microsoft
* sys: Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-231-2/+0
| | | | | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/ Similar commit in current: (cherry picked from commit 685dc743dc3b)
* Create wrapper for Giant taken for newbusWarner Losh2022-06-211-2/+2
| | | | | | | | | | | | | 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)
* Hyper-V: vPCI: Prepopulate device barsWei Hu2021-11-301-0/+43
| | | | | | | | | | | | | | | | | | In recent Hyper-V releases on Windows Server 2022, vPCI code does not initialize the last 4 bit of device bar registers. This behavior change could result weird problems cuasing PCI code failure when configuring bars. Just write all 1's to those bars whose probed values are not the same as current read ones. This seems to make Hyper-V vPCI and pci_write_bar() to cooperate correctly on these releases. Reported by: khng@freebsd.org Tested by: khng@freebsd.org MFC after: 2 weeks Sponsored by: Microsoft (cherry picked from commit 75412a521f60d4b0393c730ffb284e7c6ff9d2de)
* Hyper-V: pcib: Check revoke status during device attachWei Hu2020-10-151-12/+66
| | | | | | | | | | | | | | | It is possible that the vmbus pcib channel is revoked during attach path. The attach path could be waiting for response from host and this response will never arrive since the channel has already been revoked from host point of view. Check this situation during wait complete and return failed if this happens. Reported by: Netapp MFC after: 2 weeks Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D26486 Notes: svn path=/head/; revision=366720
* Fix build of hyperv with base gcc on i386Dimitry Andric2018-08-041-6/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Base gcc fails to compile `sys/dev/hyperv/pcib/vmbus_pcib.c` for i386, with the following -Werror warnings: cc1: warnings being treated as errors /usr/src/sys/dev/hyperv/pcib/vmbus_pcib.c: In function 'new_pcichild_device': /usr/src/sys/dev/hyperv/pcib/vmbus_pcib.c:567: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] /usr/src/sys/dev/hyperv/pcib/vmbus_pcib.c: In function 'vmbus_pcib_on_channel_callback': /usr/src/sys/dev/hyperv/pcib/vmbus_pcib.c:940: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] /usr/src/sys/dev/hyperv/pcib/vmbus_pcib.c: In function 'hv_pci_protocol_negotiation': /usr/src/sys/dev/hyperv/pcib/vmbus_pcib.c:1012: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] /usr/src/sys/dev/hyperv/pcib/vmbus_pcib.c: In function 'hv_pci_enter_d0': /usr/src/sys/dev/hyperv/pcib/vmbus_pcib.c:1073: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] /usr/src/sys/dev/hyperv/pcib/vmbus_pcib.c: In function 'hv_send_resources_allocated': /usr/src/sys/dev/hyperv/pcib/vmbus_pcib.c:1125: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] /usr/src/sys/dev/hyperv/pcib/vmbus_pcib.c: In function 'vmbus_pcib_map_msi': /usr/src/sys/dev/hyperv/pcib/vmbus_pcib.c:1730: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] This is because on i386, several casts from `uint64_t` to a pointer reduce the value from 64 bit to 32 bit. For gcc, this can be fixed by an intermediate cast to uintptr_t. Note that I am assuming the incoming values will always fit into 32 bit! Differential Revision: https://reviews.freebsd.org/D15753 MFC after: 3 days Notes: svn path=/head/; revision=337322
* hyperv: Update copyright for the files changed in 2017Sepherosa Ziehau2017-08-141-1/+1
| | | | | | | | | MFC after: 3 days Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D11982 Notes: svn path=/head/; revision=322488
* hyperv/pcib: use the device serial number as PCI domainDexuan Cui2017-06-081-0/+2
| | | | | | | | | | | | | | | Currently the PCI domain is initialized with the instance GUID in vmbus_pcib_attach(). It turns out the GUID can change across VM reboot, while some users want a persistent value for PCI domain. The solution is that we can change to use the device serial number, which starts with 1 and is unique within a VM. Obtained from: Haiyang Zhang MFC after: 1 day Sponsored by: Microsoft Notes: svn path=/head/; revision=319690
* Convert PCIe Hot Plug to using pci_request_featureWarner Losh2017-02-251-0/+1
| | | | | | | | | | | | Convert PCIe hot plug support over to asking the firmware, if any, for permission to use the HotPlug hardware. Implement pci_request_feature for ACPI. All other host pci connections to allowing all valid feature requests. Sponsored by: Netflix Notes: svn path=/head/; revision=314250
* hyperv/vmbus,pcib: unbreak build in case NEW_PCIB is undefinedDexuan Cui2016-11-251-0/+4
| | | | | | | | | | | | | vmbus_pcib requires NEW_PCIB, but in case that's not defined, we at least shouldn't break build. Reviewed by: sephe Approved by: sephe (mentor) MFC after: 3 days Sponsored by: Microsoft Notes: svn path=/head/; revision=309127
* hyperv/pcib: change the file name: pcib.c -> vmbus_pcib.cDexuan Cui2016-11-181-0/+0
| | | | | | | | | | | | This makes the file name and the variable naming in the file consistent. Reviewed by: sephe Approved by: sephe (mentor) MFC after: 1 week Sponsored by: Microsoft Notes: svn path=/head/; revision=308795
* hyperv/vmbus,pcib: Add MODULE_DEPEND on pciDexuan Cui2016-11-181-0/+1
| | | | | | | | | | | | | We'd better add this dependency explicitly, though usually the pci driver is built into the kernel by default. Reviewed by: sephe Approved by: sephe (mentor) MFC after: 1 week Sponsored by: Microsoft Notes: svn path=/head/; revision=308794
* hyperv/pcib: enable PCIe pass-through (a.k.a. Discrete Device Assignment)Dexuan Cui2016-11-161-0/+1790
The feature enables us to pass through physical PCIe devices to FreeBSD VM running on Hyper-V (Windows Server 2016) to get near-native performance with low CPU utilization. The patch implements a PCI bridge driver to support the feature: 1) The pcib driver talks to the host to discover device(s) and presents the device(s) to FreeBSD's pci driver via PCI configuration space (note: to access the configuration space, we don't use the standard I/O port 0xCF8/CFC method; instead, we use an MMIO-based method supplied by Hyper-V, which is very similar to the 0xCF8/CFC method). 2) The pcib driver allocates resources for the device(s) and initialize the related BARs, when the device driver's attach method is invoked; 3) The pcib driver talks to the host to create MSI/MSI-X interrupt remapping between the guest and the host; 4) The pcib driver supports device hot add/remove. Reviewed by: sephe Approved by: sephe (mentor) MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8332 Notes: svn path=/head/; revision=308725