aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJork Loeser <jloeser@microsoft.com>2017-05-24 16:41:26 -0400
committerBjorn Helgaas <bhelgaas@google.com>2017-07-02 19:43:09 -0400
commit02c3764c776c7f1ff036ce3ff0c0bb4b1094fa0b (patch)
tree19b78eaf587f21b23c75d9f1a18beb228b7778e8
parentbe66b673659116930f2da2f41ec79c9d1279cd8f (diff)
PCI: hv: Temporary own CPU-number-to-vCPU-number infra
To ease parallel effort to centralize CPU-number-to-vCPU-number conversion, temporarily stand up own version, file-local hv_tmp_cpu_nr_to_vp_nr(). Once the changes have merged, this work-around can be removed, and the calls replaced with hv_cpu_number_to_vp_number(). Signed-off-by: Jork Loeser <jloeser@microsoft.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: K. Y. Srinivasan <kys@microsoft.com> Acked-by: K. Y. Srinivasan <kys@microsoft.com>
-rw-r--r--drivers/pci/host/pci-hyperv.c52
1 files changed, 50 insertions, 2 deletions
diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c
index 6e4b02678b7a..cf70fbc8e929 100644
--- a/drivers/pci/host/pci-hyperv.c
+++ b/drivers/pci/host/pci-hyperv.c
@@ -479,6 +479,52 @@ static void put_pcichild(struct hv_pci_dev *hv_pcidev,
479static void get_hvpcibus(struct hv_pcibus_device *hv_pcibus); 479static void get_hvpcibus(struct hv_pcibus_device *hv_pcibus);
480static void put_hvpcibus(struct hv_pcibus_device *hv_pcibus); 480static void put_hvpcibus(struct hv_pcibus_device *hv_pcibus);
481 481
482
483/*
484 * Temporary CPU to vCPU mapping to address transitioning
485 * vmbus_cpu_number_to_vp_number() being migrated to
486 * hv_cpu_number_to_vp_number() in a separate patch. Once that patch
487 * has been picked up in the main line, remove this code here and use
488 * the official code.
489 */
490static struct hv_tmpcpumap
491{
492 bool initialized;
493 u32 vp_index[NR_CPUS];
494} hv_tmpcpumap;
495
496static void hv_tmpcpumap_init_cpu(void *_unused)
497{
498 int cpu = smp_processor_id();
499 u64 vp_index;
500
501 hv_get_vp_index(vp_index);
502
503 hv_tmpcpumap.vp_index[cpu] = vp_index;
504}
505
506static void hv_tmpcpumap_init(void)
507{
508 if (hv_tmpcpumap.initialized)
509 return;
510
511 memset(hv_tmpcpumap.vp_index, -1, sizeof(hv_tmpcpumap.vp_index));
512 on_each_cpu(hv_tmpcpumap_init_cpu, NULL, true);
513 hv_tmpcpumap.initialized = true;
514}
515
516/**
517 * hv_tmp_cpu_nr_to_vp_nr() - Convert Linux CPU nr to Hyper-V vCPU nr
518 *
519 * Remove once vmbus_cpu_number_to_vp_number() has been converted to
520 * hv_cpu_number_to_vp_number() and replace callers appropriately.
521 */
522static u32 hv_tmp_cpu_nr_to_vp_nr(int cpu)
523{
524 return hv_tmpcpumap.vp_index[cpu];
525}
526
527
482/** 528/**
483 * devfn_to_wslot() - Convert from Linux PCI slot to Windows 529 * devfn_to_wslot() - Convert from Linux PCI slot to Windows
484 * @devfn: The Linux representation of PCI slot 530 * @devfn: The Linux representation of PCI slot
@@ -813,7 +859,7 @@ static void hv_irq_unmask(struct irq_data *data)
813 params->vector = cfg->vector; 859 params->vector = cfg->vector;
814 860
815 for_each_cpu_and(cpu, dest, cpu_online_mask) 861 for_each_cpu_and(cpu, dest, cpu_online_mask)
816 params->vp_mask |= (1ULL << vmbus_cpu_number_to_vp_number(cpu)); 862 params->vp_mask |= (1ULL << hv_tmp_cpu_nr_to_vp_nr(cpu));
817 863
818 hv_do_hypercall(HVCALL_RETARGET_INTERRUPT, params, NULL); 864 hv_do_hypercall(HVCALL_RETARGET_INTERRUPT, params, NULL);
819 865
@@ -908,7 +954,7 @@ static void hv_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
908 } else { 954 } else {
909 for_each_cpu_and(cpu, affinity, cpu_online_mask) { 955 for_each_cpu_and(cpu, affinity, cpu_online_mask) {
910 int_pkt->int_desc.cpu_mask |= 956 int_pkt->int_desc.cpu_mask |=
911 (1ULL << vmbus_cpu_number_to_vp_number(cpu)); 957 (1ULL << hv_tmp_cpu_nr_to_vp_nr(cpu));
912 } 958 }
913 } 959 }
914 960
@@ -2218,6 +2264,8 @@ static int hv_pci_probe(struct hv_device *hdev,
2218 return -ENOMEM; 2264 return -ENOMEM;
2219 hbus->state = hv_pcibus_init; 2265 hbus->state = hv_pcibus_init;
2220 2266
2267 hv_tmpcpumap_init();
2268
2221 /* 2269 /*
2222 * The PCI bus "domain" is what is called "segment" in ACPI and 2270 * The PCI bus "domain" is what is called "segment" in ACPI and
2223 * other specs. Pull it from the instance ID, to get something 2271 * other specs. Pull it from the instance ID, to get something