tree:   https://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu.git hyper-v
head:   bb564d53ed035865e85f16acf217dee93705e518
commit: 004240dcc222119271ce9559af4250ab00053621 [2/3] iommu/hyper-v: Add 
Hyper-V stub IOMMU driver
config: x86_64-randconfig-s3-02270001 (attached as .config)
compiler: gcc-8 (Debian 8.2.0-20) 8.2.0
reproduce:
        git checkout 004240dcc222119271ce9559af4250ab00053621
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

>> drivers//iommu/hyperv-iommu.c:62:14: error: 'apic_ack_irq' undeclared here 
>> (not in a function); did you mean 'apic_ack_edge'?
     .irq_ack  = apic_ack_irq,
                 ^~~~~~~~~~~~
                 apic_ack_edge
   drivers//iommu/hyperv-iommu.c: In function 'hyperv_prepare_irq_remapping':
>> drivers//iommu/hyperv-iommu.c:144:7: error: implicit declaration of function 
>> 'x2apic_supported'; did you mean 'device_dma_supported'? 
>> [-Werror=implicit-function-declaration]
         !x2apic_supported())
          ^~~~~~~~~~~~~~~~
          device_dma_supported
>> drivers//iommu/hyperv-iommu.c:169:7: error: implicit declaration of function 
>> 'cpu_physical_id'; did you mean 'cpu_possible'? 
>> [-Werror=implicit-function-declaration]
      if (cpu_physical_id(i) < 256)
          ^~~~~~~~~~~~~~~
          cpu_possible
   cc1: some warnings being treated as errors

vim +62 drivers//iommu/hyperv-iommu.c

    59  
    60  static struct irq_chip hyperv_ir_chip = {
    61          .name                   = "HYPERV-IR",
  > 62          .irq_ack                = apic_ack_irq,
    63          .irq_set_affinity       = hyperv_ir_set_affinity,
    64  };
    65  
    66  static int hyperv_irq_remapping_alloc(struct irq_domain *domain,
    67                                       unsigned int virq, unsigned int 
nr_irqs,
    68                                       void *arg)
    69  {
    70          struct irq_alloc_info *info = arg;
    71          struct irq_data *irq_data;
    72          struct irq_desc *desc;
    73          int ret = 0;
    74  
    75          if (!info || info->type != X86_IRQ_ALLOC_TYPE_IOAPIC || nr_irqs 
> 1)
    76                  return -EINVAL;
    77  
    78          ret = irq_domain_alloc_irqs_parent(domain, virq, nr_irqs, arg);
    79          if (ret < 0)
    80                  return ret;
    81  
    82          irq_data = irq_domain_get_irq_data(domain, virq);
    83          if (!irq_data) {
    84                  irq_domain_free_irqs_common(domain, virq, nr_irqs);
    85                  return -EINVAL;
    86          }
    87  
    88          irq_data->chip = &hyperv_ir_chip;
    89  
    90          /*
    91           * If there is interrupt remapping function of IOMMU, setting 
irq
    92           * affinity only needs to change IRTE of IOMMU. But Hyper-V 
doesn't
    93           * support interrupt remapping function, setting irq affinity 
of IO-APIC
    94           * interrupts still needs to change IO-APIC registers. But 
ioapic_
    95           * configure_entry() will ignore value of cfg->vector and cfg->
    96           * dest_apicid when IO-APIC's parent irq domain is not the 
vector
    97           * domain.(See ioapic_configure_entry()) In order to setting 
vector
    98           * and dest_apicid to IO-APIC register, IO-APIC entry pointer 
is saved
    99           * in the chip_data and 
hyperv_irq_remapping_activate()/hyperv_ir_set_
   100           * affinity() set vector and dest_apicid directly into IO-APIC 
entry.
   101           */
   102          irq_data->chip_data = info->ioapic_entry;
   103  
   104          /*
   105           * Hypver-V IO APIC irq affinity should be in the scope of
   106           * ioapic_max_cpumask because no irq remapping support.
   107           */
   108          desc = irq_data_to_desc(irq_data);
   109          cpumask_copy(desc->irq_common_data.affinity, 
&ioapic_max_cpumask);
   110  
   111          return 0;
   112  }
   113  
   114  static void hyperv_irq_remapping_free(struct irq_domain *domain,
   115                                   unsigned int virq, unsigned int 
nr_irqs)
   116  {
   117          irq_domain_free_irqs_common(domain, virq, nr_irqs);
   118  }
   119  
   120  static int hyperv_irq_remapping_activate(struct irq_domain *domain,
   121                            struct irq_data *irq_data, bool reserve)
   122  {
   123          struct irq_cfg *cfg = irqd_cfg(irq_data);
   124          struct IO_APIC_route_entry *entry = irq_data->chip_data;
   125  
   126          entry->dest = cfg->dest_apicid;
   127          entry->vector = cfg->vector;
   128  
   129          return 0;
   130  }
   131  
   132  static struct irq_domain_ops hyperv_ir_domain_ops = {
   133          .alloc = hyperv_irq_remapping_alloc,
   134          .free = hyperv_irq_remapping_free,
   135          .activate = hyperv_irq_remapping_activate,
   136  };
   137  
   138  static int __init hyperv_prepare_irq_remapping(void)
   139  {
   140          struct fwnode_handle *fn;
   141          int i;
   142  
   143          if (!hypervisor_is_type(X86_HYPER_MS_HYPERV) ||
 > 144              !x2apic_supported())
   145                  return -ENODEV;
   146  
   147          fn = irq_domain_alloc_named_id_fwnode("HYPERV-IR", 0);
   148          if (!fn)
   149                  return -ENOMEM;
   150  
   151          ioapic_ir_domain =
   152                  irq_domain_create_hierarchy(arch_get_ir_parent_domain(),
   153                                  0, IOAPIC_REMAPPING_ENTRY, fn,
   154                                  &hyperv_ir_domain_ops, NULL);
   155  
   156          irq_domain_free_fwnode(fn);
   157  
   158          /*
   159           * Hyper-V doesn't provide irq remapping function for
   160           * IO-APIC and so IO-APIC only accepts 8-bit APIC ID.
   161           * Cpu's APIC ID is read from ACPI MADT table and APIC IDs
   162           * in the MADT table on Hyper-v are sorted monotonic 
increasingly.
   163           * APIC ID reflects cpu topology. There maybe some APIC ID
   164           * gaps when cpu number in a socket is not power of two. Prepare
   165           * max cpu affinity for IOAPIC irqs. Scan cpu 0-255 and set cpu
   166           * into ioapic_max_cpumask if its APIC ID is less than 256.
   167           */
   168          for (i = min_t(unsigned int, num_possible_cpus() - 1, 255); i 
>= 0; i--)
 > 169                  if (cpu_physical_id(i) < 256)
   170                          cpumask_set_cpu(i, &ioapic_max_cpumask);
   171  
   172          return 0;
   173  }
   174  

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

Attachment: .config.gz
Description: application/gzip

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

Reply via email to