arch/powerpc/platforms/powernv/vas-window.c
Source file repositories/reference/linux-study-clean/arch/powerpc/platforms/powernv/vas-window.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/platforms/powernv/vas-window.c- Extension
.c- Size
- 41516 bytes
- Lines
- 1472
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- Inferred role
- Architecture Layer: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/types.hlinux/mutex.hlinux/slab.hlinux/io.hlinux/log2.hlinux/rcupdate.hlinux/cred.hlinux/sched/mm.hlinux/mmu_context.hasm/switch_to.hasm/ppc-opcode.hasm/vas.hvas.hcopy-paste.hvas-trace.h
Detected Declarations
function vas_win_paste_addrfunction get_hvwc_mmio_barfunction get_uwc_mmio_barfunction unmap_regionfunction unmap_paste_regionfunction unmap_winctx_mmio_barsfunction Contextfunction reset_window_regsfunction init_vas_winctx_regsfunction init_rsvd_tx_buf_countfunction init_winctx_regsfunction vas_release_window_idfunction vas_assign_window_idfunction vas_window_freefunction put_rx_winfunction set_vinst_winfunction set_vinst_winfunction userfunction tablefunction init_winctx_for_rxwinfunction rx_win_args_validfunction vas_init_rx_win_attrfunction vas_init_tx_win_attrfunction init_winctx_for_txwinfunction tx_win_args_validfunction mmapfunction vas_copy_crbfunction vas_paste_crbfunction creditsfunction poll_window_busy_statefunction vas_win_closefunction vas_win_closefunction vas_return_creditfunction ignoredfunction vas_user_win_paste_addrfunction vas_user_win_closefunction vas_register_api_powernvfunction vas_unregister_api_powernvexport vas_init_rx_win_attrexport vas_rx_win_openexport vas_init_tx_win_attrexport vas_tx_win_openexport vas_copy_crbexport vas_paste_crbexport vas_win_closeexport vas_register_api_powernvexport vas_unregister_api_powernv
Annotated Snippet
if (IS_ERR(txwin->paste_kaddr)) {
rc = PTR_ERR(txwin->paste_kaddr);
goto free_window;
}
} else {
/*
* Interrupt handler or fault window setup failed. Means
* NX can not generate fault for page fault. So not
* opening for user space tx window.
*/
if (!vinst->virq) {
rc = -ENODEV;
goto free_window;
}
rc = get_vas_user_win_ref(&txwin->vas_win.task_ref);
if (rc)
goto free_window;
vas_user_win_add_mm_context(&txwin->vas_win.task_ref);
}
set_vinst_win(vinst, txwin);
return &txwin->vas_win;
free_window:
vas_window_free(txwin);
put_rxwin:
put_rx_win(rxwin);
return ERR_PTR(rc);
}
EXPORT_SYMBOL_GPL(vas_tx_win_open);
int vas_copy_crb(void *crb, int offset)
{
return vas_copy(crb, offset);
}
EXPORT_SYMBOL_GPL(vas_copy_crb);
#define RMA_LSMP_REPORT_ENABLE PPC_BIT(53)
int vas_paste_crb(struct vas_window *vwin, int offset, bool re)
{
struct pnv_vas_window *txwin;
int rc;
void *addr;
uint64_t val;
txwin = container_of(vwin, struct pnv_vas_window, vas_win);
trace_vas_paste_crb(current, txwin);
/*
* Only NX windows are supported for now and hardware assumes
* report-enable flag is set for NX windows. Ensure software
* complies too.
*/
WARN_ON_ONCE(txwin->nx_win && !re);
addr = txwin->paste_kaddr;
if (re) {
/*
* Set the REPORT_ENABLE bit (equivalent to writing
* to 1K offset of the paste address)
*/
val = SET_FIELD(RMA_LSMP_REPORT_ENABLE, 0ULL, 1);
addr += val;
}
/*
* Map the raw CR value from vas_paste() to an error code (there
* is just pass or fail for now though).
*/
rc = vas_paste(addr, offset);
if (rc == 2)
rc = 0;
else
rc = -EINVAL;
pr_debug("Txwin #%d: Msg count %llu\n", txwin->vas_win.winid,
read_hvwc_reg(txwin, VREG(LRFIFO_PUSH)));
return rc;
}
EXPORT_SYMBOL_GPL(vas_paste_crb);
/*
* If credit checking is enabled for this window, poll for the return
* of window credits (i.e for NX engines to process any outstanding CRBs).
* Since NX-842 waits for the CRBs to be processed before closing the
Annotation
- Immediate include surface: `linux/types.h`, `linux/mutex.h`, `linux/slab.h`, `linux/io.h`, `linux/log2.h`, `linux/rcupdate.h`, `linux/cred.h`, `linux/sched/mm.h`.
- Detected declarations: `function vas_win_paste_addr`, `function get_hvwc_mmio_bar`, `function get_uwc_mmio_bar`, `function unmap_region`, `function unmap_paste_region`, `function unmap_winctx_mmio_bars`, `function Context`, `function reset_window_regs`, `function init_vas_winctx_regs`, `function init_rsvd_tx_buf_count`.
- Atlas domain: Architecture Layer / arch/powerpc.
- Implementation status: integration implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.