[Cbe-oss-dev] [PATCH] cell: move SPU affinity init code to a separate file

Geoff Levand geoffrey.levand at am.sony.com
Wed Jul 25 06:21:12 EST 2007


André Detsch wrote:
> Geoff Levand wrote:
>> Andre Detsch wrote:
>>> +static int init_spu_affinity(void)
>>> +{
>>> +	if (of_has_vicinity()) {
>>> +		init_aff_fw_vicinity();
>>> +	} else {
>>> +		long root = of_get_flat_dt_root();
>>> +		if (of_flat_dt_is_compatible(root, "IBM,CPBW-1.0"))
>>> +			init_aff_QS20_harcoded();
>>> +	}
>>> +
>>> +	return 0;
>>> +}
> 
>> There is nothing here to prevent this code from executing
>> on the PS3.  module_init() will unconditionaly run
>> init_spu_affinity() for all platforms.  PS3 has no OF, and
>> when this code runs it will most likely fault.  Even if it
>> does run, it won't be doing the correct thing.
> 
> Adding something like
> 
> if (!machine_is(cell))
> 	return -ENODEV;
> 
> at the beginning of init_spu_affinity(void) would be enough?

It's not really a good solution.  Also, your use of module_init()
and link order to get this code executed is less than desirable.
These are the reasons we made the whole spu_management abstraction,
to avoid having these kind of fragile things sprinkled all over
the kernel sources.  

Without really knowing the intent of this functionality, I would
say the proper way is to create a new method in struct spu_management_ops,
maybe say init_affinity, and call it at the appropriate point in
init_spu_base().  The PS3 implementation of the method would be empty.

-Geoff






More information about the cbe-oss-dev mailing list