genirq: Fix export of irq_to_desc() for powerpc KVM
[linux-2.6-microblaze.git] / kernel / irq / irqdesc.c
index e810eb9..cc1a094 100644 (file)
@@ -147,12 +147,12 @@ static ssize_t per_cpu_count_show(struct kobject *kobj,
                                  struct kobj_attribute *attr, char *buf)
 {
        struct irq_desc *desc = container_of(kobj, struct irq_desc, kobj);
-       int cpu, irq = desc->irq_data.irq;
        ssize_t ret = 0;
        char *p = "";
+       int cpu;
 
        for_each_possible_cpu(cpu) {
-               unsigned int c = kstat_irqs_cpu(irq, cpu);
+               unsigned int c = irq_desc_kstat_cpu(desc, cpu);
 
                ret += scnprintf(buf + ret, PAGE_SIZE - ret, "%s%u", p, c);
                p = ",";
@@ -352,7 +352,9 @@ struct irq_desc *irq_to_desc(unsigned int irq)
 {
        return radix_tree_lookup(&irq_desc_tree, irq);
 }
-EXPORT_SYMBOL(irq_to_desc);
+#ifdef CONFIG_KVM_BOOK3S_64_HV_MODULE
+EXPORT_SYMBOL_GPL(irq_to_desc);
+#endif
 
 static void delete_irq_desc(unsigned int irq)
 {
@@ -924,15 +926,7 @@ static bool irq_is_nmi(struct irq_desc *desc)
        return desc->istate & IRQS_NMI;
 }
 
-/**
- * kstat_irqs - Get the statistics for an interrupt
- * @irq:       The interrupt number
- *
- * Returns the sum of interrupt counts on all cpus since boot for
- * @irq. The caller must ensure that the interrupt is not removed
- * concurrently.
- */
-unsigned int kstat_irqs(unsigned int irq)
+static unsigned int kstat_irqs(unsigned int irq)
 {
        struct irq_desc *desc = irq_to_desc(irq);
        unsigned int sum = 0;
@@ -943,21 +937,22 @@ unsigned int kstat_irqs(unsigned int irq)
        if (!irq_settings_is_per_cpu_devid(desc) &&
            !irq_settings_is_per_cpu(desc) &&
            !irq_is_nmi(desc))
-           return desc->tot_count;
+               return data_race(desc->tot_count);
 
        for_each_possible_cpu(cpu)
-               sum += *per_cpu_ptr(desc->kstat_irqs, cpu);
+               sum += data_race(*per_cpu_ptr(desc->kstat_irqs, cpu));
        return sum;
 }
 
 /**
- * kstat_irqs_usr - Get the statistics for an interrupt
+ * kstat_irqs_usr - Get the statistics for an interrupt from thread context
  * @irq:       The interrupt number
  *
  * Returns the sum of interrupt counts on all cpus since boot for @irq.
- * Contrary to kstat_irqs() this can be called from any context.
- * It uses rcu since a concurrent removal of an interrupt descriptor is
- * observing an rcu grace period before delayed_free_desc()/irq_kobj_release().
+ *
+ * It uses rcu to protect the access since a concurrent removal of an
+ * interrupt descriptor is observing an rcu grace period before
+ * delayed_free_desc()/irq_kobj_release().
  */
 unsigned int kstat_irqs_usr(unsigned int irq)
 {
@@ -968,3 +963,17 @@ unsigned int kstat_irqs_usr(unsigned int irq)
        rcu_read_unlock();
        return sum;
 }
+
+#ifdef CONFIG_LOCKDEP
+void __irq_set_lockdep_class(unsigned int irq, struct lock_class_key *lock_class,
+                            struct lock_class_key *request_class)
+{
+       struct irq_desc *desc = irq_to_desc(irq);
+
+       if (desc) {
+               lockdep_set_class(&desc->lock, lock_class);
+               lockdep_set_class(&desc->request_mutex, request_class);
+       }
+}
+EXPORT_SYMBOL_GPL(__irq_set_lockdep_class);
+#endif