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