Commit 1cf106d9 authored by Boqun Feng's avatar Boqun Feng Committed by Lorenzo Pieralisi

PCI: hv: Introduce hv_msi_entry

Add a new structure (hv_msi_entry), which is also defined in the TLFS,
to describe the msi entry for HVCALL_RETARGET_INTERRUPT. The structure
is needed because its layout may be different from architecture to
architecture.

Also add a new generic interface hv_set_msi_entry_from_desc() to allow
different archs to set the msi entry from msi_desc.

No functional change, only preparation for the future support of virtual
PCI on non-x86 architectures.
Signed-off-by: default avatarBoqun Feng (Microsoft) <boqun.feng@gmail.com>
Signed-off-by: default avatarLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: default avatarDexuan Cui <decui@microsoft.com>
parent 61bfd920
...@@ -913,11 +913,18 @@ struct hv_partition_assist_pg { ...@@ -913,11 +913,18 @@ struct hv_partition_assist_pg {
u32 tlb_lock_count; u32 tlb_lock_count;
}; };
union hv_msi_entry {
u64 as_uint64;
struct {
u32 address;
u32 data;
} __packed;
};
struct hv_interrupt_entry { struct hv_interrupt_entry {
u32 source; /* 1 for MSI(-X) */ u32 source; /* 1 for MSI(-X) */
u32 reserved1; u32 reserved1;
u32 address; union hv_msi_entry msi_entry;
u32 data;
} __packed; } __packed;
/* /*
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/nmi.h> #include <linux/nmi.h>
#include <linux/msi.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/hyperv-tlfs.h> #include <asm/hyperv-tlfs.h>
#include <asm/nospec-branch.h> #include <asm/nospec-branch.h>
...@@ -240,6 +241,13 @@ bool hv_vcpu_is_preempted(int vcpu); ...@@ -240,6 +241,13 @@ bool hv_vcpu_is_preempted(int vcpu);
static inline void hv_apic_init(void) {} static inline void hv_apic_init(void) {}
#endif #endif
static inline void hv_set_msi_entry_from_desc(union hv_msi_entry *msi_entry,
struct msi_desc *msi_desc)
{
msi_entry->address = msi_desc->msg.address_lo;
msi_entry->data = msi_desc->msg.data;
}
#else /* CONFIG_HYPERV */ #else /* CONFIG_HYPERV */
static inline void hyperv_init(void) {} static inline void hyperv_init(void) {}
static inline void hyperv_setup_mmu_ops(void) {} static inline void hyperv_setup_mmu_ops(void) {}
......
...@@ -1213,8 +1213,7 @@ static void hv_irq_unmask(struct irq_data *data) ...@@ -1213,8 +1213,7 @@ static void hv_irq_unmask(struct irq_data *data)
memset(params, 0, sizeof(*params)); memset(params, 0, sizeof(*params));
params->partition_id = HV_PARTITION_ID_SELF; params->partition_id = HV_PARTITION_ID_SELF;
params->int_entry.source = 1; /* MSI(-X) */ params->int_entry.source = 1; /* MSI(-X) */
params->int_entry.address = msi_desc->msg.address_lo; hv_set_msi_entry_from_desc(&params->int_entry.msi_entry, msi_desc);
params->int_entry.data = msi_desc->msg.data;
params->device_id = (hbus->hdev->dev_instance.b[5] << 24) | params->device_id = (hbus->hdev->dev_instance.b[5] << 24) |
(hbus->hdev->dev_instance.b[4] << 16) | (hbus->hdev->dev_instance.b[4] << 16) |
(hbus->hdev->dev_instance.b[7] << 8) | (hbus->hdev->dev_instance.b[7] << 8) |
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment