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.

Dependency Surface

Detected Declarations

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

Implementation Notes