Skip to content

Commit 3b7adb8

Browse files
committed
Merge feature/vpci/5.15 into v5.15.153
* commit '92c970cf37ef2b7d159905ca9df9e25f86618248': PCI: hv: Avoid the retarget interrupt hypercall in irq_unmask() on ARM64 PCI: hv: Only reuse existing IRTE allocation for Multi-MSI Drivers: hv: vmbus: Propagate VMbus coherence to each VMbus device PCI: hv: Add arm64 Hyper-V vPCI support PCI: hv: Make the code arch neutral by adding arch specific interfaces
2 parents 4652738 + 92c970c commit 3b7adb8

File tree

9 files changed

+504
-199
lines changed

9 files changed

+504
-199
lines changed

arch/arm64/include/asm/hyperv-tlfs.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,15 @@
6464
#define HV_REGISTER_STIMER0_CONFIG 0x000B0000
6565
#define HV_REGISTER_STIMER0_COUNT 0x000B0001
6666

67+
union hv_msi_entry {
68+
u64 as_uint64[2];
69+
struct {
70+
u64 address;
71+
u32 data;
72+
u32 reserved;
73+
} __packed;
74+
};
75+
6776
#include <asm-generic/hyperv-tlfs.h>
6877

6978
#endif

arch/x86/include/asm/hyperv-tlfs.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,39 @@ enum hv_interrupt_type {
585585
HV_X64_INTERRUPT_TYPE_MAXIMUM = 0x000A,
586586
};
587587

588+
union hv_msi_address_register {
589+
u32 as_uint32;
590+
struct {
591+
u32 reserved1:2;
592+
u32 destination_mode:1;
593+
u32 redirection_hint:1;
594+
u32 reserved2:8;
595+
u32 destination_id:8;
596+
u32 msi_base:12;
597+
};
598+
} __packed;
599+
600+
union hv_msi_data_register {
601+
u32 as_uint32;
602+
struct {
603+
u32 vector:8;
604+
u32 delivery_mode:3;
605+
u32 reserved1:3;
606+
u32 level_assert:1;
607+
u32 trigger_mode:1;
608+
u32 reserved2:16;
609+
};
610+
} __packed;
611+
612+
/* HvRetargetDeviceInterrupt hypercall */
613+
union hv_msi_entry {
614+
u64 as_uint64;
615+
struct {
616+
union hv_msi_address_register address;
617+
union hv_msi_data_register data;
618+
} __packed;
619+
};
620+
588621
#include <asm-generic/hyperv-tlfs.h>
589622

590623
#endif

drivers/hv/hv_common.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <linux/panic_notifier.h>
2121
#include <linux/ptrace.h>
2222
#include <linux/slab.h>
23+
#include <linux/dma-map-ops.h>
2324
#include <asm/hyperv-tlfs.h>
2425
#include <asm/mshyperv.h>
2526

@@ -216,6 +217,16 @@ bool hv_query_ext_cap(u64 cap_query)
216217
}
217218
EXPORT_SYMBOL_GPL(hv_query_ext_cap);
218219

220+
void hv_setup_dma_ops(struct device *dev, bool coherent)
221+
{
222+
/*
223+
* Hyper-V does not offer a vIOMMU in the guest
224+
* VM, so pass 0/NULL for the IOMMU settings
225+
*/
226+
arch_setup_dma_ops(dev, 0, 0, NULL, coherent);
227+
}
228+
EXPORT_SYMBOL_GPL(hv_setup_dma_ops);
229+
219230
bool hv_is_hibernation_supported(void)
220231
{
221232
return !hv_root_partition && acpi_sleep_state_supported(ACPI_STATE_S4);

drivers/hv/vmbus_drv.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,14 @@ static int vmbus_probe(struct device *child_device)
904904
struct hv_device *dev = device_to_hv_device(child_device);
905905
const struct hv_vmbus_device_id *dev_id;
906906

907+
/*
908+
* On ARM64, propagate the DMA coherence setting from the top level
909+
* VMbus ACPI device to the child VMbus device being added here.
910+
* On x86/x64 coherence is assumed and these calls have no effect.
911+
*/
912+
hv_setup_dma_ops(child_device,
913+
device_get_dma_attr(&hv_acpi_dev->dev) == DEV_DMA_COHERENT);
914+
907915
dev_id = hv_vmbus_get_id(drv, dev);
908916
if (drv->probe) {
909917
ret = drv->probe(dev, dev_id);
@@ -2438,6 +2446,21 @@ static int vmbus_acpi_add(struct acpi_device *device)
24382446

24392447
hv_acpi_dev = device;
24402448

2449+
/*
2450+
* Older versions of Hyper-V for ARM64 fail to include the _CCA
2451+
* method on the top level VMbus device in the DSDT. But devices
2452+
* are hardware coherent in all current Hyper-V use cases, so fix
2453+
* up the ACPI device to behave as if _CCA is present and indicates
2454+
* hardware coherence.
2455+
*/
2456+
ACPI_COMPANION_SET(&device->dev, device);
2457+
if (IS_ENABLED(CONFIG_ACPI_CCA_REQUIRED) &&
2458+
device_get_dma_attr(&device->dev) == DEV_DMA_NOT_SUPPORTED) {
2459+
pr_info("No ACPI _CCA found; assuming coherent device I/O\n");
2460+
device->flags.cca_seen = true;
2461+
device->flags.coherent_dma = true;
2462+
}
2463+
24412464
result = acpi_walk_resources(device->handle, METHOD_NAME__CRS,
24422465
vmbus_walk_resources, NULL);
24432466

drivers/pci/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ config PCI_LABEL
184184

185185
config PCI_HYPERV
186186
tristate "Hyper-V PCI Frontend"
187-
depends on X86_64 && HYPERV && PCI_MSI && PCI_MSI_IRQ_DOMAIN && SYSFS
187+
depends on ((X86 && X86_64) || ARM64) && HYPERV && PCI_MSI && PCI_MSI_IRQ_DOMAIN && SYSFS
188188
select PCI_HYPERV_INTERFACE
189189
help
190190
The PCI device frontend driver allows the kernel to import arbitrary

drivers/pci/controller/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ config PCIE_BRCMSTB
280280

281281
config PCI_HYPERV_INTERFACE
282282
tristate "Hyper-V PCI Interface"
283-
depends on X86 && HYPERV && PCI_MSI && PCI_MSI_IRQ_DOMAIN && X86_64
283+
depends on ((X86 && X86_64) || ARM64) && HYPERV && PCI_MSI && PCI_MSI_IRQ_DOMAIN
284284
help
285285
The Hyper-V PCI Interface is a helper driver allows other drivers to
286286
have a common interface with the Hyper-V PCI frontend driver.

0 commit comments

Comments
 (0)