cell: abstract spu management routines
Subsystems (2)
PATCH 2/14 cell: abstract spu management routines
Subject: powerpc: abstract spu management routines
From: Geoff Levand <[email protected]>
This adds a platform specific spu management abstraction and the coresponding routines to support the IBM Cell Blade. It also removes the hypervisor only resources that were included in struct spu.
Three new platform specific routines are introduced, spu_enumerate_spus(), spu_create_spu() and spu_destroy_spu(). The underlining design uses a new type, struct spu_management_ops, to hold function pointers that the platform setup code is expected to initialize to instances appropriate to that platform.
For the IBM Cell Blade support, I put the hypervisor only resources that were in struct spu into a platform specific data structure struct spu_pdata.
--- arch/powerpc/platforms/cell/cbe_thermal.c | 5 arch/powerpc/platforms/cell/setup.c | 3 arch/powerpc/platforms/cell/spu_base.c | 334 +--------------------- arch/powerpc/platforms/cell/spu_priv1_mmio.c | 399 +++++++++++++++++++++++++-- arch/powerpc/platforms/cell/spu_priv1_mmio.h | 26 + include/asm-powerpc/spu.h | 5 include/asm-powerpc/spu_priv1.h | 40 ++ 7 files changed, 465 insertions(+), 347 deletions(-)
arch/powerpc/platforms/cell/cbe_thermal.c +3 -2
@@ -29,6 +29,7 @@#include <asm/prom.h> #include "cbe_regs.h" +#include "spu_priv1_mmio.h" static struct cbe_pmd_regs __iomem *get_pmd_regs (struct sys_device *sysdev) {
@@ -36,7 +37,7 @@ spu = container_of(sysdev, struct spu, sysdev); -return cbe_get_pmd_regs (spu->devnode); +return cbe_get_pmd_regs (spu_devnode (spu)); }/* returns the value for a given spu in a given register */
@@ -49,7 +50,7 @@/* getting the id from the reg attribute will not work on future device-tree layouts * in future we should store the id to the spu struct and use it here */ spu = container_of(sysdev, struct spu, sysdev); - id = (unsigned int *)get_property (spu->devnode,"reg" ,NULL ); + id = (unsigned int *)get_property (spu_devnode (spu),"reg" ,NULL ); value.val =in_be64 (®->val);return value.spe[*id];
arch/powerpc/platforms/cell/setup.c +2 -1
@@ -145,7 +145,8 @@static void __init cell_setup_arch (void ) {#ifdef CONFIG_SPU_BASE - spu_priv1_ops = &spu_priv1_mmio_ops; + spu_priv1_ops = &spu_priv1_mmio_ops; + spu_management_ops = &spu_management_of_ops;#endif cbe_regs_init ();
arch/powerpc/platforms/cell/spu_base.c +22 -312
407 lines not on this page · raw message
arch/powerpc/platforms/cell/spu_priv1_mmio.c +376 -23
496 lines not on this page · raw message
arch/powerpc/platforms/cell/spu_priv1_mmio.h new file +26 -0
@@ -0,0 +1,26 @@ +/* +* spu hypervisor abstraction for direct hardware access. +* +* Copyright (C) 2006 Sony Computer Entertainment Inc. +* Copyright 2006 Sony Corp. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; version 2 of the License. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef SPU_PRIV1_MMIO_H +#define SPU_PRIV1_MMIO_H + +struct device_node *spu_devnode (struct spu *spu); + +#endif /* SPU_PRIV1_MMIO_H */
include/asm-powerpc/spu.h +1 -4
@@ -111,13 +111,11 @@u8 *local_store;unsigned long problem_phys;struct spu_problem __iomem *problem; -struct spu_priv1 __iomem *priv1;struct spu_priv2 __iomem *priv2;struct list_head list;struct list_head sched_list;struct list_head full_list;int number; -int nid;unsigned int irqs[3 ];u32 node;u64 flags;
@@ -144,8 +142,7 @@char irq_c1[8 ];char irq_c2[8 ]; -struct device_node *devnode; - +void * pdata;/* platform private data */ struct sys_device sysdev; };
include/asm-powerpc/spu_priv1.h +35 -5
@@ -21,12 +21,13 @@#define _SPU_PRIV1_H #if defined(__KERNEL__) +#include <linux/types.h> + struct spu; /* access to priv1 registers */ -struct spu_priv1_ops -{ +struct spu_priv1_ops { void (*int_mask_and) (struct spu *spu, int class, u64 mask); void (*int_mask_or) (struct spu *spu, int class, u64 mask); void (*int_mask_set) (struct spu *spu, int class, u64 mask);
@@ -171,12 +172,41 @@return spu_priv1_ops->resource_allocation_enable_get (spu); } -/* The declarations folowing are put here for convenience -* and only intended to be used by the platform setup code -* for initializing spu_priv1_ops. +/* spu management abstraction */ + +struct spu_management_ops { +int (*enumerate_spus)(int (*fn)(void *data)); +int (*create_spu)(struct spu *spu,void *data); +int (*destroy_spu)(struct spu *spu); +}; + +extern const struct spu_management_ops * spu_management_ops; + +static inline int +spu_enumerate_spus (int (*fn)(void *data)) +{ +return spu_management_ops->enumerate_spus (fn); +} + +static inline int +spu_create_spu (struct spu *spu,void *data) +{ +return spu_management_ops->create_spu (spu, data); +} + +static inline int +spu_destroy_spu (struct spu *spu) +{ +return spu_management_ops->destroy_spu (spu); +} + +/* +* The declarations folowing are put here for convenience +* and only intended to be used by the platform setup code. */ extern const struct spu_priv1_ops spu_priv1_mmio_ops; +extern const struct spu_management_ops spu_management_of_ops;#endif /* __KERNEL__ */ #endif
T24gV2VkbmVzZGF5IDIyIE5vdmVtYmVyIDIwMDYgMDU6MTksIEdlb2ZmIExldmFuZCB3cm90ZToK PiArc3RhdGljIGludCBfX2luaXQgc3B1X21hcF9kZXZpY2Uoc3RydWN0IHNwdSAqc3B1LCBzdHJ1 Y3QgZGV2aWNlX25vZGUgKm5vZGUpCj4gK3sKPiAroKCgoKCgoGludCByZXQgPSAtRU5PREVWOwo+ ICugoKCgoKCgc3B1LT5uYW1lID0gZ2V0X3Byb3BlcnR5KG5vZGUsICJuYW1lIiwgTlVMTCk7Cj4g K6CgoKCgoKBpZiAoIXNwdS0+bmFtZSkKPiAroKCgoKCgoKCgoKCgoKCgZ290byBvdXQ7Cj4gKwo+ ICugoKCgoKCgcmV0ID0gc3B1X21hcF9yZXNvdXJjZShub2RlLCAwLCAodm9pZCBfX2lvbWVtKiop JnNwdS0+bG9jYWxfc3RvcmUsCj4gK6CgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCg oKCgoCZz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IEknbGwgc2VuZCBhIGZpeGVkIHZlcnNpb24uCgpUaGUgc2FtZSBodW5rIGFsc28gY3Jl YXRlcyBhIG1lcmdlIGNvbmZsaWN0IGJldHdlZW4gdGhlIG1hc3RlciBhbmQKZm9yLTIuNi4yMCBi cmFuY2hlcyBvZiBwb3dlcnBjLmdpdC4KCglBcm5kIDw+PAo=
PATCH 1/1 cell: abstract spu management routines
In reply to Geoff LevandSubject: powerpc: abstract spu management routines
From: Geoff Levand <[email protected]>
This adds a platform specific spu management abstraction and the coresponding routines to support the IBM Cell Blade. It also removes the hypervisor only resources that were included in struct spu.
Three new platform specific routines are introduced, spu_enumerate_spus(), spu_create_spu() and spu_destroy_spu(). The underlining design uses a new type, struct spu_management_ops, to hold function pointers that the platform setup code is expected to initialize to instances appropriate to that platform.
For the IBM Cell Blade support, I put the hypervisor only resources that were in struct spu into a platform specific data structure struct spu_pdata.
--- arch/powerpc/platforms/cell/cbe_thermal.c | 5 arch/powerpc/platforms/cell/setup.c | 3 arch/powerpc/platforms/cell/spu_base.c | 334 +--------------------- arch/powerpc/platforms/cell/spu_priv1_mmio.c | 399 +++++++++++++++++++++++++-- arch/powerpc/platforms/cell/spu_priv1_mmio.h | 26 + include/asm-powerpc/spu.h | 5 include/asm-powerpc/spu_priv1.h | 40 ++ 7 files changed, 465 insertions(+), 347 deletions(-)
arch/powerpc/platforms/cell/cbe_thermal.c +3 -2
@@ -29,6 +29,7 @@#include <asm/prom.h> #include "cbe_regs.h" +#include "spu_priv1_mmio.h" static struct cbe_pmd_regs __iomem *get_pmd_regs (struct sys_device *sysdev) {
@@ -36,7 +37,7 @@ static struct cbe_pmd_regs __iomem *get_ spu = container_of(sysdev, struct spu, sysdev); -return cbe_get_pmd_regs (spu->devnode); +return cbe_get_pmd_regs (spu_devnode (spu)); }/* returns the value for a given spu in a given register */
@@ -49,7 +50,7 @@ static u8 spu_read_register_value(struct/* getting the id from the reg attribute will not work on future device-tree layouts * in future we should store the id to the spu struct and use it here */ spu = container_of(sysdev, struct spu, sysdev); - id = (unsigned int *)get_property (spu->devnode,"reg" ,NULL ); + id = (unsigned int *)get_property (spu_devnode (spu),"reg" ,NULL ); value.val =in_be64 (®->val);return value.spe[*id];
arch/powerpc/platforms/cell/setup.c +2 -1
@@ -145,7 +145,8 @@ static void __init cell_init_irq(void)static void __init cell_setup_arch (void ) {#ifdef CONFIG_SPU_BASE - spu_priv1_ops = &spu_priv1_mmio_ops; + spu_priv1_ops = &spu_priv1_mmio_ops; + spu_management_ops = &spu_management_of_ops;#endif cbe_regs_init ();
arch/powerpc/platforms/cell/spu_base.c +22 -287
382 lines not on this page · raw message
arch/powerpc/platforms/cell/spu_priv1_mmio.c +401 -23
521 lines not on this page · raw message
arch/powerpc/platforms/cell/spu_priv1_mmio.h new file +26 -0
@@ -0,0 +1,26 @@ +/* +* spu hypervisor abstraction for direct hardware access. +* +* Copyright (C) 2006 Sony Computer Entertainment Inc. +* Copyright 2006 Sony Corp. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; version 2 of the License. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef SPU_PRIV1_MMIO_H +#define SPU_PRIV1_MMIO_H + +struct device_node *spu_devnode (struct spu *spu); + +#endif /* SPU_PRIV1_MMIO_H */
include/asm-powerpc/spu.h +1 -4
@@ -111,13 +111,11 @@ struct spu {u8 *local_store;unsigned long problem_phys;struct spu_problem __iomem *problem; -struct spu_priv1 __iomem *priv1;struct spu_priv2 __iomem *priv2;struct list_head list;struct list_head sched_list;struct list_head full_list;int number; -int nid;unsigned int irqs[3 ];u32 node;u64 flags;
@@ -144,8 +142,7 @@ struct spu {char irq_c1[8 ];char irq_c2[8 ]; -struct device_node *devnode; - +void * pdata;/* platform private data */ struct sys_device sysdev; };
include/asm-powerpc/spu_priv1.h +35 -5
@@ -21,12 +21,13 @@#define _SPU_PRIV1_H #if defined(__KERNEL__) +#include <linux/types.h> + struct spu; /* access to priv1 registers */ -struct spu_priv1_ops -{ +struct spu_priv1_ops { void (*int_mask_and) (struct spu *spu, int class, u64 mask); void (*int_mask_or) (struct spu *spu, int class, u64 mask); void (*int_mask_set) (struct spu *spu, int class, u64 mask);
@@ -171,12 +172,41 @@ spu_resource_allocation_enable_get (strureturn spu_priv1_ops->resource_allocation_enable_get (spu); } -/* The declarations folowing are put here for convenience -* and only intended to be used by the platform setup code -* for initializing spu_priv1_ops. +/* spu management abstraction */ + +struct spu_management_ops { +int (*enumerate_spus)(int (*fn)(void *data)); +int (*create_spu)(struct spu *spu,void *data); +int (*destroy_spu)(struct spu *spu); +}; + +extern const struct spu_management_ops * spu_management_ops; + +static inline int +spu_enumerate_spus (int (*fn)(void *data)) +{ +return spu_management_ops->enumerate_spus (fn); +} + +static inline int +spu_create_spu (struct spu *spu,void *data) +{ +return spu_management_ops->create_spu (spu, data); +} + +static inline int +spu_destroy_spu (struct spu *spu) +{ +return spu_management_ops->destroy_spu (spu); +} + +/* +* The declarations folowing are put here for convenience +* and only intended to be used by the platform setup code. */ extern const struct spu_priv1_ops spu_priv1_mmio_ops; +extern const struct spu_management_ops spu_management_of_ops;#endif /* __KERNEL__ */ #endif