arch/powerpc/platforms/cell/spufs/backing_ops.c
Source file repositories/reference/linux-study-clean/arch/powerpc/platforms/cell/spufs/backing_ops.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/platforms/cell/spufs/backing_ops.c- Extension
.c- Size
- 10492 bytes
- Lines
- 401
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/errno.hlinux/sched.hlinux/kernel.hlinux/mm.hlinux/vmalloc.hlinux/smp.hlinux/stddef.hlinux/unistd.hlinux/poll.hasm/io.hasm/spu.hasm/spu_csa.hasm/spu_info.hasm/mmu_context.hspufs.h
Detected Declarations
function Copyrightfunction spu_backing_mbox_readfunction spu_backing_mbox_stat_readfunction spu_backing_mbox_stat_pollfunction spu_backing_ibox_readfunction spu_backing_wbox_writefunction spu_backing_signal1_readfunction spu_backing_signal1_writefunction spu_backing_signal2_readfunction spu_backing_signal2_writefunction spu_backing_signal1_type_setfunction spu_backing_signal1_type_getfunction spu_backing_signal2_type_setfunction spu_backing_signal2_type_getfunction spu_backing_npc_readfunction spu_backing_npc_writefunction spu_backing_status_readfunction spu_backing_privcntl_writefunction spu_backing_runcntl_readfunction spu_backing_runcntl_writefunction spu_backing_runcntl_stopfunction spu_backing_master_startfunction spu_backing_master_stopfunction spu_backing_set_mfc_queryfunction spu_backing_read_mfc_tagstatusfunction spu_backing_get_mfc_free_elementsfunction spu_backing_send_mfc_commandfunction spu_backing_restart_dma
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/* backing_ops.c - query/set operations on saved SPU context.
*
* Copyright (C) IBM 2005
* Author: Mark Nutter <mnutter@us.ibm.com>
*
* These register operations allow SPUFS to operate on saved
* SPU contexts rather than hardware.
*/
#include <linux/errno.h>
#include <linux/sched.h>
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/vmalloc.h>
#include <linux/smp.h>
#include <linux/stddef.h>
#include <linux/unistd.h>
#include <linux/poll.h>
#include <asm/io.h>
#include <asm/spu.h>
#include <asm/spu_csa.h>
#include <asm/spu_info.h>
#include <asm/mmu_context.h>
#include "spufs.h"
/*
* Reads/writes to various problem and priv2 registers require
* state changes, i.e. generate SPU events, modify channel
* counts, etc.
*/
static void gen_spu_event(struct spu_context *ctx, u32 event)
{
u64 ch0_cnt;
u64 ch0_data;
u64 ch1_data;
ch0_cnt = ctx->csa.spu_chnlcnt_RW[0];
ch0_data = ctx->csa.spu_chnldata_RW[0];
ch1_data = ctx->csa.spu_chnldata_RW[1];
ctx->csa.spu_chnldata_RW[0] |= event;
if ((ch0_cnt == 0) && !(ch0_data & event) && (ch1_data & event)) {
ctx->csa.spu_chnlcnt_RW[0] = 1;
}
}
static int spu_backing_mbox_read(struct spu_context *ctx, u32 * data)
{
u32 mbox_stat;
int ret = 0;
spin_lock(&ctx->csa.register_lock);
mbox_stat = ctx->csa.prob.mb_stat_R;
if (mbox_stat & 0x0000ff) {
/* Read the first available word.
* Implementation note: the depth
* of pu_mb_R is currently 1.
*/
*data = ctx->csa.prob.pu_mb_R;
ctx->csa.prob.mb_stat_R &= ~(0x0000ff);
ctx->csa.spu_chnlcnt_RW[28] = 1;
gen_spu_event(ctx, MFC_PU_MAILBOX_AVAILABLE_EVENT);
ret = 4;
}
spin_unlock(&ctx->csa.register_lock);
return ret;
}
static u32 spu_backing_mbox_stat_read(struct spu_context *ctx)
{
return ctx->csa.prob.mb_stat_R;
}
static __poll_t spu_backing_mbox_stat_poll(struct spu_context *ctx,
__poll_t events)
{
__poll_t ret;
u32 stat;
ret = 0;
spin_lock_irq(&ctx->csa.register_lock);
stat = ctx->csa.prob.mb_stat_R;
/* if the requested event is there, return the poll
mask, otherwise enable the interrupt to get notified,
but first mark any pending interrupts as done so
we don't get woken up unnecessarily */
Annotation
- Immediate include surface: `linux/errno.h`, `linux/sched.h`, `linux/kernel.h`, `linux/mm.h`, `linux/vmalloc.h`, `linux/smp.h`, `linux/stddef.h`, `linux/unistd.h`.
- Detected declarations: `function Copyright`, `function spu_backing_mbox_read`, `function spu_backing_mbox_stat_read`, `function spu_backing_mbox_stat_poll`, `function spu_backing_ibox_read`, `function spu_backing_wbox_write`, `function spu_backing_signal1_read`, `function spu_backing_signal1_write`, `function spu_backing_signal2_read`, `function spu_backing_signal2_write`.
- Atlas domain: Architecture Layer / arch/powerpc.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.