]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - arch/powerpc/platforms/cell/spu_base.c
[PATCH] sem2mutex: misc static one-file mutexes
[net-next-2.6.git] / arch / powerpc / platforms / cell / spu_base.c
index 7fe3fa3da0e92a92d1e3b8232e693d00e3141e7c..a8fa1eeeb17443753177ff857369fbdd635df81a 100644 (file)
@@ -32,7 +32,7 @@
 
 #include <asm/io.h>
 #include <asm/prom.h>
-#include <asm/semaphore.h>
+#include <linux/mutex.h>
 #include <asm/spu.h>
 #include <asm/mmu_context.h>
 
@@ -342,7 +342,7 @@ spu_free_irqs(struct spu *spu)
 }
 
 static LIST_HEAD(spu_list);
-static DECLARE_MUTEX(spu_mutex);
+static DEFINE_MUTEX(spu_mutex);
 
 static void spu_init_channels(struct spu *spu)
 {
@@ -382,7 +382,7 @@ struct spu *spu_alloc(void)
 {
        struct spu *spu;
 
-       down(&spu_mutex);
+       mutex_lock(&spu_mutex);
        if (!list_empty(&spu_list)) {
                spu = list_entry(spu_list.next, struct spu, list);
                list_del_init(&spu->list);
@@ -391,7 +391,7 @@ struct spu *spu_alloc(void)
                pr_debug("No SPU left\n");
                spu = NULL;
        }
-       up(&spu_mutex);
+       mutex_unlock(&spu_mutex);
 
        if (spu)
                spu_init_channels(spu);
@@ -402,9 +402,9 @@ EXPORT_SYMBOL_GPL(spu_alloc);
 
 void spu_free(struct spu *spu)
 {
-       down(&spu_mutex);
+       mutex_lock(&spu_mutex);
        list_add_tail(&spu->list, &spu_list);
-       up(&spu_mutex);
+       mutex_unlock(&spu_mutex);
 }
 EXPORT_SYMBOL_GPL(spu_free);
 
@@ -507,6 +507,14 @@ int spu_irq_class_1_bottom(struct spu *spu)
        return ret;
 }
 
+void spu_irq_setaffinity(struct spu *spu, int cpu)
+{
+       u64 target = iic_get_target_id(cpu);
+       u64 route = target << 48 | target << 32 | target << 16;
+       spu_int_route_set(spu, route);
+}
+EXPORT_SYMBOL_GPL(spu_irq_setaffinity);
+
 static void __iomem * __init map_spe_prop(struct device_node *n,
                                                 const char *name)
 {
@@ -625,14 +633,14 @@ static int __init create_spu(struct device_node *spe)
        spu->wbox_callback = NULL;
        spu->stop_callback = NULL;
 
-       down(&spu_mutex);
+       mutex_lock(&spu_mutex);
        spu->number = number++;
        ret = spu_request_irqs(spu);
        if (ret)
                goto out_unmap;
 
        list_add(&spu->list, &spu_list);
-       up(&spu_mutex);
+       mutex_unlock(&spu_mutex);
 
        pr_debug(KERN_DEBUG "Using SPE %s %02x %p %p %p %p %d\n",
                spu->name, spu->isrc, spu->local_store,
@@ -640,7 +648,7 @@ static int __init create_spu(struct device_node *spe)
        goto out;
 
 out_unmap:
-       up(&spu_mutex);
+       mutex_unlock(&spu_mutex);
        spu_unmap(spu);
 out_free:
        kfree(spu);
@@ -660,10 +668,10 @@ static void destroy_spu(struct spu *spu)
 static void cleanup_spu_base(void)
 {
        struct spu *spu, *tmp;
-       down(&spu_mutex);
+       mutex_lock(&spu_mutex);
        list_for_each_entry_safe(spu, tmp, &spu_list, list)
                destroy_spu(spu);
-       up(&spu_mutex);
+       mutex_unlock(&spu_mutex);
 }
 module_exit(cleanup_spu_base);