spu_notify.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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/export.h>
  23. #include <linux/notifier.h>
  24. #include <asm/spu.h>
  25. #include "spufs/spufs.h"
  26. static BLOCKING_NOTIFIER_HEAD(spu_switch_notifier);
  27. void spu_switch_notify(struct spu *spu, struct spu_context *ctx)
  28. {
  29. blocking_notifier_call_chain(&spu_switch_notifier,
  30. ctx ? ctx->object_id : 0, spu);
  31. }
  32. EXPORT_SYMBOL_GPL(spu_switch_notify);
  33. int spu_switch_event_register(struct notifier_block *n)
  34. {
  35. int ret;
  36. ret = blocking_notifier_chain_register(&spu_switch_notifier, n);
  37. if (!ret)
  38. notify_spus_active();
  39. return ret;
  40. }
  41. EXPORT_SYMBOL_GPL(spu_switch_event_register);
  42. int spu_switch_event_unregister(struct notifier_block *n)
  43. {
  44. return blocking_notifier_chain_unregister(&spu_switch_notifier, n);
  45. }
  46. EXPORT_SYMBOL_GPL(spu_switch_event_unregister);
  47. void spu_set_profile_private_kref(struct spu_context *ctx,
  48. struct kref *prof_info_kref,
  49. void (* prof_info_release) (struct kref *kref))
  50. {
  51. ctx->prof_priv_kref = prof_info_kref;
  52. ctx->prof_priv_release = prof_info_release;
  53. }
  54. EXPORT_SYMBOL_GPL(spu_set_profile_private_kref);
  55. void *spu_get_profile_private_kref(struct spu_context *ctx)
  56. {
  57. return ctx->prof_priv_kref;
  58. }
  59. EXPORT_SYMBOL_GPL(spu_get_profile_private_kref);