Skip to contentSkip to conversation

PCI: hv: Hyper-V vPCI for arm64

PATCH Applied Sunil Muthuswamy 3 participants 6 messages Jan 5, 2022 – Jan 6, 2022

Subsystems (7)
lore
Share & tools
lore
#0 lore raw

v8 cover PCI: hv: Hyper-V vPCI for arm64

From: Sunil Muthuswamy <[email protected]>

Current Hyper-V vPCI code only compiles and works for x86. There are some hardcoded assumptions about the architectural IRQ chip and other arch defines.

Add support for Hyper-V vPCI for arm64 by first breaking the current hard coded dependency using a set of new interfaces and implementing those for x86 first. That is in the first patch. The second patch adds support for Hyper-V vPCI for arm64 by implementing the above mentioned interfaces. That is done by introducing a Hyper-V vPCI specific MSI IRQ domain & chip for allocating SPI vectors.

changes in v1 -> v2:
- Moved the irqchip implementation to drivers/pci as suggested by Marc Zyngier
- Addressed Multi-MSI handling issues identified by Marc Zyngier
- Addressed lock/synchronization primitive as suggested by Marc Zyngier
- Addressed other code feedback from Marc Zyngier

changes in v2 -> v3:
- Addressed comments from Bjorn Helgaas about patch formatting and verbiage
- Using 'git send-email' to ensure that the patch series is correctly threaded. Feedback by Bjorn Helgaas
- Fixed Hyper-V vPCI build break for module build, reported by Boqun Feng

changes in v3 -> v4:
- Removed the separate file for IRQ chip that was there in previous iterations and moved the IRQ chip implementation to pci-hyperv.c. Feedback by Michael Kelley and Marc Zyngier.
- Addressed various comments from Marc Zyngier about structuring and layout.
- Addressed comment from Marc Zyngier about IRQ affinity and other miscellaneous comments.

changes in v4 -> v5:
- Fixed an issue with picking the right cpu for irq affinity, identified by Marc Zyngier.

changes in v5 -> v6:
- Minor comment updates suggested by Michael Kelley.

changes in v6 -> v7:
- Addressed feedback from Marc Zyngier about IRQ cleanup in the error path and explicitly setting the IRQ trigger type.
- Address feedback from Bjorn Helgaas about subject line format.

changes in v7 -> v8:
- Addressed feedback from Michael Kelley about the cpu mask to use for the initial interrupt affinity and IRQ cleanup in the error path.

Sunil Muthuswamy (2):
PCI: hv: Make the code arch neutral by adding arch specific interfaces
PCI: hv: Add arm64 Hyper-V vPCI support

 arch/arm64/include/asm/hyperv-tlfs.h |   9 +
 arch/x86/include/asm/hyperv-tlfs.h   |  33 +++
 arch/x86/include/asm/mshyperv.h      |   7 -
 drivers/pci/Kconfig                  |   2 +-
 drivers/pci/controller/Kconfig       |   2 +-
 drivers/pci/controller/pci-hyperv.c  | 312 ++++++++++++++++++++++++---
 include/asm-generic/hyperv-tlfs.h    |  33 ---
 7 files changed, 331 insertions(+), 67 deletions(-)

base-commit: fa55b7dcdc43c1aa1ba12bca9d2dd4318c2a0dbf

Signature · 1 line
2.25.1
#1 lore raw

PATCH v8 1/2 PCI: hv: Make the code arch neutral by adding arch specific interfaces

From: Sunil Muthuswamy <[email protected]>

Encapsulate arch dependencies in Hyper-V vPCI through a set of arch-dependent interfaces. Adding these arch specific interfaces will allow for an implementation for other architectures, such as arm64.

There are no functional changes expected from this patch.

---
In v2, v3, v4, v5, v6, v7 & v8:
Changes are described in the cover letter. No changes from v4 -> v5, v6 -> v7 or v7 -> v8.

 arch/x86/include/asm/hyperv-tlfs.h  | 33 ++++++++++++
 arch/x86/include/asm/mshyperv.h     |  7 ---
 drivers/pci/controller/pci-hyperv.c | 79 ++++++++++++++++++++---------
 include/asm-generic/hyperv-tlfs.h   | 33 ------------
 4 files changed, 87 insertions(+), 65 deletions(-)
arch/x86/include/asm/hyperv-tlfs.h +33 -0
index 381e88122a5f..0a9407dc0859 100644
@@ -602,6 +602,39 @@ enum hv_interrupt_type {
 	HV_X64_INTERRUPT_TYPE_MAXIMUM           = 0x000A,
 };
 
+union hv_msi_address_register {
+	u32 as_uint32;
+	struct {
+		u32 reserved1:2;
+		u32 destination_mode:1;
+		u32 redirection_hint:1;
+		u32 reserved2:8;
+		u32 destination_id:8;
+		u32 msi_base:12;
+	};
+} __packed;
+
+union hv_msi_data_register {
+	u32 as_uint32;
+	struct {
+		u32 vector:8;
+		u32 delivery_mode:3;
+		u32 reserved1:3;
+		u32 level_assert:1;
+		u32 trigger_mode:1;
+		u32 reserved2:16;
+	};
+} __packed;
+
+/* HvRetargetDeviceInterrupt hypercall */
+union hv_msi_entry {
+	u64 as_uint64;
+	struct {
+		union hv_msi_address_register address;
+		union hv_msi_data_register data;
+	} __packed;
+};
+
 #include <asm-generic/hyperv-tlfs.h>
 
 #endif
arch/x86/include/asm/mshyperv.h +0 -7
index da3972fe5a7a..a1c3dceff8eb 100644
@@ -169,13 +169,6 @@ bool hv_vcpu_is_preempted(int vcpu);
 static inline void hv_apic_init(void) {}
 #endif
 
-static inline void hv_set_msi_entry_from_desc(union hv_msi_entry *msi_entry,
-					      struct msi_desc *msi_desc)
-{
-	msi_entry->address.as_uint32 = msi_desc->msg.address_lo;
-	msi_entry->data.as_uint32 = msi_desc->msg.data;
-}
-
 struct irq_domain *hv_create_pci_msi_domain(void);
 
 int hv_map_ioapic_interrupt(int ioapic_id, bool level, int vcpu, int vector,
drivers/pci/controller/pci-hyperv.c +54 -25

181 lines not on this page · raw message

include/asm-generic/hyperv-tlfs.h +0 -33
index 8ed6733d5146..8f97c2927bee 100644
@@ -540,39 +540,6 @@ enum hv_interrupt_source {
 	HV_INTERRUPT_SOURCE_IOAPIC,
 };
 
-union hv_msi_address_register {
-	u32 as_uint32;
-	struct {
-		u32 reserved1:2;
-		u32 destination_mode:1;
-		u32 redirection_hint:1;
-		u32 reserved2:8;
-		u32 destination_id:8;
-		u32 msi_base:12;
-	};
-} __packed;
-
-union hv_msi_data_register {
-	u32 as_uint32;
-	struct {
-		u32 vector:8;
-		u32 delivery_mode:3;
-		u32 reserved1:3;
-		u32 level_assert:1;
-		u32 trigger_mode:1;
-		u32 reserved2:16;
-	};
-} __packed;
-
-/* HvRetargetDeviceInterrupt hypercall */
-union hv_msi_entry {
-	u64 as_uint64;
-	struct {
-		union hv_msi_address_register address;
-		union hv_msi_data_register data;
-	} __packed;
-};
-
 union hv_ioapic_rte {
 	u64 as_uint64;
 
Signature · 1 line
2.25.1
Reviewed-by on v8 1/2
#2 lore raw

RE: [PATCH v8 1/2] PCI: hv: Make the code arch neutral by adding arch specific interfaces

From: Sunil Muthuswamy <[email protected]> Sent: Wednesday, January 5, 2022 11:33 AM

Quoted 15 lines

Encapsulate arch dependencies in Hyper-V vPCI through a set of arch-dependent interfaces. Adding these arch specific interfaces will allow for an implementation for other architectures, such as arm64.

There are no functional changes expected from this patch.

---
In v2, v3, v4, v5, v6, v7 & v8:
Changes are described in the cover letter. No changes from v4 -> v5, v6 -> v7 or v7 -> v8.

Quoted 6 lines
 arch/x86/include/asm/hyperv-tlfs.h  | 33 ++++++++++++
 arch/x86/include/asm/mshyperv.h     |  7 ---
 drivers/pci/controller/pci-hyperv.c | 79 ++++++++++++++++++++---------
 include/asm-generic/hyperv-tlfs.h   | 33 ------------
 4 files changed, 87 insertions(+), 65 deletions(-)
#3 lore raw

PATCH v8 2/2 PCI: hv: Add arm64 Hyper-V vPCI support

In reply to Sunil Muthuswamy

From: Sunil Muthuswamy <[email protected]>

Add arm64 Hyper-V vPCI support by implementing the arch specific interfaces. Introduce an IRQ domain and chip specific to Hyper-v vPCI that is based on SPIs. The IRQ domain parents itself to the arch GIC IRQ domain for basic vector management.

---
In v2, v3, v4, v5, v6, v7 & v8:
Changes are described in the cover letter.

 arch/arm64/include/asm/hyperv-tlfs.h |   9 +
 drivers/pci/Kconfig                  |   2 +-
 drivers/pci/controller/Kconfig       |   2 +-
 drivers/pci/controller/pci-hyperv.c  | 235 ++++++++++++++++++++++++++-
 4 files changed, 245 insertions(+), 3 deletions(-)
arch/arm64/include/asm/hyperv-tlfs.h +9 -0
index 4d964a7f02ee..bc6c7ac934a1 100644
@@ -64,6 +64,15 @@
 #define HV_REGISTER_STIMER0_CONFIG	0x000B0000
 #define HV_REGISTER_STIMER0_COUNT	0x000B0001
 
+union hv_msi_entry {
+	u64 as_uint64[2];
+	struct {
+		u64 address;
+		u32 data;
+		u32 reserved;
+	} __packed;
+};
+
 #include <asm-generic/hyperv-tlfs.h>
 
 #endif
drivers/pci/Kconfig +1 -1
index 43e615aa12ff..d98fafdd0f99 100644
@@ -184,7 +184,7 @@ config PCI_LABEL
 
 config PCI_HYPERV
 	tristate "Hyper-V PCI Frontend"
-	depends on X86_64 && HYPERV && PCI_MSI && PCI_MSI_IRQ_DOMAIN && SYSFS
+	depends on ((X86 && X86_64) || ARM64) && HYPERV && PCI_MSI && PCI_MSI_IRQ_DOMAIN && SYSFS
 	select PCI_HYPERV_INTERFACE
 	help
 	  The PCI device frontend driver allows the kernel to import arbitrary
drivers/pci/controller/Kconfig +1 -1
index 93b141110537..2536abcc045a 100644
@@ -281,7 +281,7 @@ config PCIE_BRCMSTB
 
 config PCI_HYPERV_INTERFACE
 	tristate "Hyper-V PCI Interface"
-	depends on X86 && HYPERV && PCI_MSI && PCI_MSI_IRQ_DOMAIN && X86_64
+	depends on ((X86 && X86_64) || ARM64) && HYPERV && PCI_MSI && PCI_MSI_IRQ_DOMAIN
 	help
 	  The Hyper-V PCI Interface is a helper driver allows other drivers to
 	  have a common interface with the Hyper-V PCI frontend driver.
drivers/pci/controller/pci-hyperv.c +234 -1

266 lines not on this page · raw message

Signature · 1 line
2.25.1
Reviewed-by on v8 2/2
#4 lore raw

RE: [PATCH v8 2/2] PCI: hv: Add arm64 Hyper-V vPCI support

From: Sunil Muthuswamy <[email protected]> Sent: Wednesday, January 5, 2022 11:33 AM

Quoted 12 lines

Add arm64 Hyper-V vPCI support by implementing the arch specific interfaces. Introduce an IRQ domain and chip specific to Hyper-v vPCI that is based on SPIs. The IRQ domain parents itself to the arch GIC IRQ domain for basic vector management.

---
In v2, v3, v4, v5, v6, v7 & v8:
Changes are described in the cover letter.

Quoted 6 lines
 arch/arm64/include/asm/hyperv-tlfs.h |   9 +
 drivers/pci/Kconfig                  |   2 +-
 drivers/pci/controller/Kconfig       |   2 +-
 drivers/pci/controller/pci-hyperv.c  | 235 ++++++++++++++++++++++++++-
 4 files changed, 245 insertions(+), 3 deletions(-)
#5 lore raw
In reply to Sunil Muthuswamy
Quoted 6 lines · Sunil Muthuswamy

From: Sunil Muthuswamy <[email protected]>

Current Hyper-V vPCI code only compiles and works for x86. There are some hardcoded assumptions about the architectural IRQ chip and other arch defines.

Quoted 8 lines

Add support for Hyper-V vPCI for arm64 by first breaking the current hard coded dependency using a set of new interfaces and implementing those for x86 first. That is in the first patch. The second patch adds support for Hyper-V vPCI for arm64 by implementing the above mentioned interfaces. That is done by introducing a Hyper-V vPCI specific MSI IRQ domain & chip for allocating SPI vectors.

[...]

Applied to pci/hv, thanks!

[1/2] PCI: hv: Make the code arch neutral by adding arch specific interfaces

      https://git.kernel.org/lpieralisi/pci/c/6c63f4da30
[2/2] PCI: hv: Add arm64 Hyper-V vPCI support
      https://git.kernel.org/lpieralisi/pci/c/c10bdb758c

Thanks,
Lorenzo