]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blobdiff - arch/powerpc/platforms/cell/spu_base.c
[PATCH] spufs: fix for CONFIG_NUMA
[mirror_ubuntu-zesty-kernel.git] / arch / powerpc / platforms / cell / spu_base.c
index 269dda4fd0b4ff23cb2657087cf6bd34adc09739..b788e165c557254fd3c3fde11ba594c6cf153d43 100644 (file)
@@ -306,19 +306,19 @@ spu_request_irqs(struct spu *spu)
 
        snprintf(spu->irq_c0, sizeof (spu->irq_c0), "spe%02d.0", spu->number);
        ret = request_irq(irq_base + spu->isrc,
-                spu_irq_class_0, 0, spu->irq_c0, spu);
+                spu_irq_class_0, SA_INTERRUPT, spu->irq_c0, spu);
        if (ret)
                goto out;
 
        snprintf(spu->irq_c1, sizeof (spu->irq_c1), "spe%02d.1", spu->number);
        ret = request_irq(irq_base + IIC_CLASS_STRIDE + spu->isrc,
-                spu_irq_class_1, 0, spu->irq_c1, spu);
+                spu_irq_class_1, SA_INTERRUPT, spu->irq_c1, spu);
        if (ret)
                goto out1;
 
        snprintf(spu->irq_c2, sizeof (spu->irq_c2), "spe%02d.2", spu->number);
        ret = request_irq(irq_base + 2*IIC_CLASS_STRIDE + spu->isrc,
-                spu_irq_class_2, 0, spu->irq_c2, spu);
+                spu_irq_class_2, SA_INTERRUPT, spu->irq_c2, spu);
        if (ret)
                goto out2;
        goto out;
@@ -487,10 +487,14 @@ int spu_irq_class_1_bottom(struct spu *spu)
        ea = spu->dar;
        dsisr = spu->dsisr;
        if (dsisr & (MFC_DSISR_PTE_NOT_FOUND | MFC_DSISR_ACCESS_DENIED)) {
+               u64 flags;
+
                access = (_PAGE_PRESENT | _PAGE_USER);
                access |= (dsisr & MFC_DSISR_ACCESS_PUT) ? _PAGE_RW : 0UL;
+               local_irq_save(flags);
                if (hash_page(ea, access, 0x300) != 0)
                        error |= CLASS1_ENABLE_STORAGE_FAULT_INTR;
+               local_irq_restore(flags);
        }
        if (error & CLASS1_ENABLE_STORAGE_FAULT_INTR) {
                if ((ret = spu_handle_mm_fault(spu)) != 0)
@@ -516,6 +520,56 @@ void spu_irq_setaffinity(struct spu *spu, int cpu)
 }
 EXPORT_SYMBOL_GPL(spu_irq_setaffinity);
 
+static int __init find_spu_node_id(struct device_node *spe)
+{
+       unsigned int *id;
+       struct device_node *cpu;
+       cpu = spe->parent->parent;
+       id = (unsigned int *)get_property(cpu, "node-id", NULL);
+       return id ? *id : 0;
+}
+
+static int __init cell_spuprop_present(struct device_node *spe,
+                                       const char *prop)
+{
+       static DEFINE_MUTEX(add_spumem_mutex);
+
+       struct address_prop {
+               unsigned long address;
+               unsigned int len;
+       } __attribute__((packed)) *p;
+       int proplen;
+
+       unsigned long start_pfn, nr_pages;
+       int node_id;
+       struct pglist_data *pgdata;
+       struct zone *zone;
+       int ret;
+
+       p = (void*)get_property(spe, prop, &proplen);
+       WARN_ON(proplen != sizeof (*p));
+
+       start_pfn = p->address >> PAGE_SHIFT;
+       nr_pages = ((unsigned long)p->len + PAGE_SIZE - 1) >> PAGE_SHIFT;
+
+       /*
+        * XXX need to get the correct NUMA node in here. This may
+        * be different from the spe::node_id property, e.g. when
+        * the host firmware is not NUMA aware.
+        */
+       node_id = 0;
+
+       pgdata = NODE_DATA(node_id);
+       zone = pgdata->node_zones;
+
+       /* XXX rethink locking here */
+       mutex_lock(&add_spumem_mutex);
+       ret = __add_pages(zone, start_pfn, nr_pages);
+       mutex_unlock(&add_spumem_mutex);
+
+       return ret;
+}
+
 static void __iomem * __init map_spe_prop(struct device_node *n,
                                                 const char *name)
 {
@@ -526,6 +580,8 @@ static void __iomem * __init map_spe_prop(struct device_node *n,
 
        void *p;
        int proplen;
+       void* ret = NULL;
+       int err = 0;
 
        p = get_property(n, name, &proplen);
        if (proplen != sizeof (struct address_prop))
@@ -533,7 +589,14 @@ static void __iomem * __init map_spe_prop(struct device_node *n,
 
        prop = p;
 
-       return ioremap(prop->address, prop->len);
+       err = cell_spuprop_present(n, name);
+       if (err && (err != -EEXIST))
+               goto out;
+
+       ret = ioremap(prop->address, prop->len);
+
+ out:
+       return ret;
 }
 
 static void spu_unmap(struct spu *spu)
@@ -593,17 +656,6 @@ out:
        return ret;
 }
 
-static int __init find_spu_node_id(struct device_node *spe)
-{
-       unsigned int *id;
-       struct device_node *cpu;
-
-       cpu = spe->parent->parent;
-       id = (unsigned int *)get_property(cpu, "node-id", NULL);
-
-       return id ? *id : 0;
-}
-
 static int __init create_spu(struct device_node *spe)
 {
        struct spu *spu;