1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Move OProfile dependencies from spufs module to the kernel so it
4 * can run on non-cell PPC.
5 *
6 * Copyright (C) IBM 2005
7 */
8
9 #undef DEBUG
10
11 #include <linux/export.h>
12 #include <linux/notifier.h>
13 #include <asm/spu.h>
14 #include "spufs/spufs.h"
15
16 static BLOCKING_NOTIFIER_HEAD(spu_switch_notifier);
17
spu_switch_notify(struct spu * spu,struct spu_context * ctx)18 void spu_switch_notify(struct spu *spu, struct spu_context *ctx)
19 {
20 blocking_notifier_call_chain(&spu_switch_notifier,
21 ctx ? ctx->object_id : 0, spu);
22 }
23 EXPORT_SYMBOL_GPL(spu_switch_notify);
24
spu_switch_event_register(struct notifier_block * n)25 int spu_switch_event_register(struct notifier_block *n)
26 {
27 int ret;
28 ret = blocking_notifier_chain_register(&spu_switch_notifier, n);
29 if (!ret)
30 notify_spus_active();
31 return ret;
32 }
33 EXPORT_SYMBOL_GPL(spu_switch_event_register);
34
spu_switch_event_unregister(struct notifier_block * n)35 int spu_switch_event_unregister(struct notifier_block *n)
36 {
37 return blocking_notifier_chain_unregister(&spu_switch_notifier, n);
38 }
39 EXPORT_SYMBOL_GPL(spu_switch_event_unregister);
40
spu_set_profile_private_kref(struct spu_context * ctx,struct kref * prof_info_kref,void (* prof_info_release)(struct kref * kref))41 void spu_set_profile_private_kref(struct spu_context *ctx,
42 struct kref *prof_info_kref,
43 void (* prof_info_release) (struct kref *kref))
44 {
45 ctx->prof_priv_kref = prof_info_kref;
46 ctx->prof_priv_release = prof_info_release;
47 }
48 EXPORT_SYMBOL_GPL(spu_set_profile_private_kref);
49
spu_get_profile_private_kref(struct spu_context * ctx)50 void *spu_get_profile_private_kref(struct spu_context *ctx)
51 {
52 return ctx->prof_priv_kref;
53 }
54 EXPORT_SYMBOL_GPL(spu_get_profile_private_kref);
55
56