spu_notify.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Move OProfile dependencies from spufs module to the kernel so it
  3. * can run on non-cell PPC.
  4. *
  5. * Copyright (C) IBM 2005
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2, or (at your option)
  10. * any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. */
  21. #undef DEBUG
  22. #include <linux/module.h>
  23. #include <asm/spu.h>
  24. #include "spufs/spufs.h"
  25. static BLOCKING_NOTIFIER_HEAD(spu_switch_notifier);
  26. void spu_switch_notify(struct spu *spu, struct spu_context *ctx)
  27. {
  28. blocking_notifier_call_chain(&spu_switch_notifier,
  29. ctx ? ctx->object_id : 0, spu);
  30. }
  31. EXPORT_SYMBOL_GPL(spu_switch_notify);
  32. int spu_switch_event_register(struct notifier_block *n)
  33. {
  34. int ret;
  35. ret = blocking_notifier_chain_register(&spu_switch_notifier, n);
  36. if (!ret)
  37. notify_spus_active();
  38. return ret;
  39. }
  40. EXPORT_SYMBOL_GPL(spu_switch_event_register);
  41. int spu_switch_event_unregister(struct notifier_block *n)
  42. {
  43. return blocking_notifier_chain_unregister(&spu_switch_notifier, n);
  44. }
  45. EXPORT_SYMBOL_GPL(spu_switch_event_unregister);
  46. void spu_set_profile_private_kref(struct spu_context *ctx,
  47. struct kref *prof_info_kref,
  48. void (* prof_info_release) (struct kref *kref))
  49. {
  50. ctx->prof_priv_kref = prof_info_kref;
  51. ctx->prof_priv_release = prof_info_release;
  52. }
  53. EXPORT_SYMBOL_GPL(spu_set_profile_private_kref);
  54. void *spu_get_profile_private_kref(struct spu_context *ctx)
  55. {
  56. return ctx->prof_priv_kref;
  57. }
  58. EXPORT_SYMBOL_GPL(spu_get_profile_private_kref);