linux-stable/drivers/pci
Michael Kelley 4732ac1c23 PCI: hv: Fix ring buffer size calculation
[ Upstream commit b5ff74c1ef ]

For a physical PCI device that is passed through to a Hyper-V guest VM,
current code specifies the VMBus ring buffer size as 4 pages.  But this
is an inappropriate dependency, since the amount of ring buffer space
needed is unrelated to PAGE_SIZE. For example, on x86 the ring buffer
size ends up as 16 Kbytes, while on ARM64 with 64 Kbyte pages, the ring
size bloats to 256 Kbytes. The ring buffer for PCI pass-thru devices
is used for only a few messages during device setup and removal, so any
space above a few Kbytes is wasted.

Fix this by declaring the ring buffer size to be a fixed 16 Kbytes.
Furthermore, use the VMBUS_RING_SIZE() macro so that the ring buffer
header is properly accounted for, and so the size is rounded up to a
page boundary, using the page size for which the kernel is built. While
w/64 Kbyte pages this results in a 64 Kbyte ring buffer header plus a
64 Kbyte ring buffer, that's the smallest possible with that page size.
It's still 128 Kbytes better than the current code.

Link: https://lore.kernel.org/linux-pci/20240216202240.251818-1-mhklinux@outlook.com
Signed-off-by: Michael Kelley <mhklinux@outlook.com>
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Reviewed-by: Ilpo Jarvinen <ilpo.jarvinen@linux.intel.com>
Reviewed-by: Long Li <longli@microsoft.com>
Cc: <stable@vger.kernel.org> # 5.15.x
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-04-03 15:19:34 +02:00
..
controller PCI: hv: Fix ring buffer size calculation 2024-04-03 15:19:34 +02:00
endpoint NTB: fix possible name leak in ntb_register_device() 2024-03-26 18:20:49 -04:00
hotplug Revert "PCI: acpiphp: Reassign resources on bridge if necessary" 2023-12-20 17:00:20 +01:00
msi PCI/MSI: Prevent MSI hardware interrupt number truncation 2024-03-01 13:26:33 +01:00
pcie PCI/AER: Block runtime suspend when handling errors 2024-04-03 15:19:33 +02:00
switch PCI: switchtec: Fix an error handling path in switchtec_pci_probe() 2024-03-26 18:20:47 -04:00
access.c PCI: Add locking to RMW PCI Express Capability Register accessors 2023-09-13 09:42:46 +02:00
ats.c
bus.c PCI: s390: Fix use-after-free of PCI resources with per-function hotplug 2023-03-22 13:33:45 +01:00
doe.c PCI/DOE: Fix destroy_work_on_stack() race 2023-09-13 09:42:45 +02:00
ecam.c
host-bridge.c
iov.c PCI/IOV: Enlarge virtfn sysfs name buffer 2023-03-10 09:33:31 +01:00
irq.c PCI: Check for alloc failure in pci_request_irq() 2022-12-31 13:32:33 +01:00
Kconfig cxl for 6.0 2022-08-10 11:07:26 -07:00
Makefile PCI/DOE: Add DOE mailbox support functions 2022-07-19 15:38:04 -07:00
mmap.c PCI: Remove pci_mmap_page_range() wrapper 2022-07-29 12:08:44 -05:00
of.c IOMMU Updates for Linux v5.19 2022-05-31 09:56:54 -07:00
p2pdma.c PCI/P2PDMA: Use for_each_pci_dev() helper 2022-09-19 13:44:38 -05:00
pci-acpi.c PCI/sysfs: Protect driver's D3cold preference from user space 2023-11-28 17:07:08 +00:00
pci-bridge-emul.c PCI: pci-bridge-emul: Set position of PCI capabilities to real HW value 2022-08-25 12:07:56 +02:00
pci-bridge-emul.h PCI: pci-bridge-emul: Set position of PCI capabilities to real HW value 2022-08-25 12:07:56 +02:00
pci-driver.c PCI/PM: Drain runtime-idle callbacks before driver removal 2024-04-03 15:19:31 +02:00
pci-label.c
pci-mid.c
pci-pf-stub.c
pci-stub.c PCI: pci_stub: Set driver_managed_dma 2022-04-28 15:32:20 +02:00
pci-sysfs.c PCI/sysfs: Protect driver's D3cold preference from user space 2023-11-28 17:07:08 +00:00
pci.c Revert "PCI/ASPM: Remove pcie_aspm_pm_state_change()" 2024-01-10 17:10:20 +01:00
pci.h PCI: Make pci_dev_is_disconnected() helper public for other drivers 2024-03-26 18:20:39 -04:00
probe.c PCI: Do error check on own line to split long "if" conditions 2023-11-28 17:07:00 +00:00
proc.c PCI: Remove pci_mmap_page_range() wrapper 2022-07-29 12:08:44 -05:00
quirks.c PCI/DPC: Quirk PIO log size for Intel Raptor Lake Root Ports 2024-04-03 15:19:31 +02:00
remove.c
rom.c
search.c
setup-bus.c PCI: Distribute available resources for root buses, too 2023-03-11 13:55:38 +01:00
setup-irq.c
setup-res.c PCI: Sanitise firmware BAR assignments behind a PCI-PCI bridge 2022-09-21 17:52:47 -05:00
slot.c
syscall.c
vc.c
vgaarb.c PCI/VGA: Replace full MIT license text with SPDX identifier 2022-03-09 18:31:34 -06:00
vpd.c
xen-pcifront.c xen/pcifront: move xenstore config scanning into sub-function 2022-10-07 07:36:44 +02:00