18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Move OProfile dependencies from spufs module to the kernel so it 48c2ecf20Sopenharmony_ci * can run on non-cell PPC. 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * Copyright (C) IBM 2005 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#undef DEBUG 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#include <linux/export.h> 128c2ecf20Sopenharmony_ci#include <linux/notifier.h> 138c2ecf20Sopenharmony_ci#include <asm/spu.h> 148c2ecf20Sopenharmony_ci#include "spufs/spufs.h" 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_cistatic BLOCKING_NOTIFIER_HEAD(spu_switch_notifier); 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_civoid spu_switch_notify(struct spu *spu, struct spu_context *ctx) 198c2ecf20Sopenharmony_ci{ 208c2ecf20Sopenharmony_ci blocking_notifier_call_chain(&spu_switch_notifier, 218c2ecf20Sopenharmony_ci ctx ? ctx->object_id : 0, spu); 228c2ecf20Sopenharmony_ci} 238c2ecf20Sopenharmony_ciEXPORT_SYMBOL_GPL(spu_switch_notify); 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ciint spu_switch_event_register(struct notifier_block *n) 268c2ecf20Sopenharmony_ci{ 278c2ecf20Sopenharmony_ci int ret; 288c2ecf20Sopenharmony_ci ret = blocking_notifier_chain_register(&spu_switch_notifier, n); 298c2ecf20Sopenharmony_ci if (!ret) 308c2ecf20Sopenharmony_ci notify_spus_active(); 318c2ecf20Sopenharmony_ci return ret; 328c2ecf20Sopenharmony_ci} 338c2ecf20Sopenharmony_ciEXPORT_SYMBOL_GPL(spu_switch_event_register); 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ciint spu_switch_event_unregister(struct notifier_block *n) 368c2ecf20Sopenharmony_ci{ 378c2ecf20Sopenharmony_ci return blocking_notifier_chain_unregister(&spu_switch_notifier, n); 388c2ecf20Sopenharmony_ci} 398c2ecf20Sopenharmony_ciEXPORT_SYMBOL_GPL(spu_switch_event_unregister); 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_civoid spu_set_profile_private_kref(struct spu_context *ctx, 428c2ecf20Sopenharmony_ci struct kref *prof_info_kref, 438c2ecf20Sopenharmony_ci void (* prof_info_release) (struct kref *kref)) 448c2ecf20Sopenharmony_ci{ 458c2ecf20Sopenharmony_ci ctx->prof_priv_kref = prof_info_kref; 468c2ecf20Sopenharmony_ci ctx->prof_priv_release = prof_info_release; 478c2ecf20Sopenharmony_ci} 488c2ecf20Sopenharmony_ciEXPORT_SYMBOL_GPL(spu_set_profile_private_kref); 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_civoid *spu_get_profile_private_kref(struct spu_context *ctx) 518c2ecf20Sopenharmony_ci{ 528c2ecf20Sopenharmony_ci return ctx->prof_priv_kref; 538c2ecf20Sopenharmony_ci} 548c2ecf20Sopenharmony_ciEXPORT_SYMBOL_GPL(spu_get_profile_private_kref); 558c2ecf20Sopenharmony_ci 56