linux-stable/drivers/pci
Michael Kelley 51ea6d58a4 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:32:18 +02:00
..
controller PCI: hv: Fix ring buffer size calculation 2024-04-03 15:32:18 +02:00
endpoint NTB: fix possible name leak in ntb_register_device() 2024-03-26 18:17:06 -04:00
hotplug Revert "PCI: acpiphp: Reassign resources on bridge if necessary" 2023-12-15 14:55:10 -06:00
msi PCI/MSI: Prevent MSI hardware interrupt number truncation 2024-02-19 16:11:01 +01:00
pcie PCI/AER: Block runtime suspend when handling errors 2024-04-03 15:32:17 +02:00
switch PCI: switchtec: Fix an error handling path in switchtec_pci_probe() 2024-03-26 18:17:04 -04:00
Kconfig PCI: Replace unnecessary UTF-8 in Kconfig 2023-10-06 14:30:48 -05:00
Makefile PCI: Create device tree node for bridge 2023-08-22 14:56:09 -05:00
access.c PCI: Move pci_clear_and_set_dword() helper to PCI header 2023-12-13 13:35:41 +00:00
ats.c PCI/ATS: Use FIELD_GET() 2023-10-24 16:55:45 -05:00
bus.c PCI/ASPM: Fix deadlock when enabling ASPM 2024-01-31 09:03:51 -06:00
doe.c
ecam.c
host-bridge.c
iov.c PCI: Use resource names in PCI log messages 2023-12-15 17:28:42 -06:00
irq.c
mmap.c
of.c PCI: of: Destroy changeset when adding PCI device node fails 2023-09-29 17:33:51 -05:00
of_property.c PCI: of_property: Handle interrupt parsing failures 2023-09-29 17:33:46 -05:00
p2pdma.c PCI/P2PDMA: Fix a sleeping issue in a RCU read section 2024-03-26 18:17:04 -04:00
pci-acpi.c Merge branch 'pci/pm' 2023-10-28 13:30:59 -05:00
pci-bridge-emul.c
pci-bridge-emul.h
pci-driver.c PCI/PM: Drain runtime-idle callbacks before driver removal 2024-04-03 15:32:13 +02:00
pci-label.c
pci-mid.c
pci-pf-stub.c
pci-stub.c
pci-sysfs.c Driver core changes for 6.7-rc1 2023-11-03 15:15:47 -10:00
pci.c pci-v6.8-fixes-3 2024-02-17 08:06:20 -08:00
pci.h PCI: Make pci_dev_is_disconnected() helper public for other drivers 2024-03-26 18:16:52 -04:00
probe.c PCI: Log bridge info when first enumerating bridge 2023-12-15 17:28:43 -06:00
proc.c
quirks.c PCI/DPC: Quirk PIO log size for Intel Raptor Lake Root Ports 2024-04-03 15:32:13 +02:00
remove.c PCI: Create device tree node for bridge 2023-08-22 14:56:09 -05:00
rom.c
search.c PCI: Add pci_get_base_class() helper 2023-09-28 16:49:44 -05:00
setup-bus.c PCI: Use resource names in PCI log messages 2023-12-15 17:28:42 -06:00
setup-irq.c
setup-res.c PCI: Use resource names in PCI log messages 2023-12-15 17:28:42 -06:00
slot.c
syscall.c PCI: Use consistent put_user() pointer types 2023-08-25 08:15:13 -05:00
vc.c PCI/VC: Use FIELD_GET() 2023-10-24 16:55:45 -05:00
vgaarb.c pci-v6.7-changes 2023-11-02 14:05:18 -10:00
vpd.c PCI/VPD: Add runtime power management to sysfs interface 2023-08-11 14:19:16 -05:00
xen-pcifront.c