Exemplo n.º 1
0
int do_nmi(cmd_tbl_t * cmdtp, int flag, int argc, char *const argv[])
{
	cvmx_coremask_t coremask = CVMX_COREMASK_EMPTY;
	uint64_t cores;
	int node;

	if (argc > 1) {
		if (cvmx_coremask_str2bmp(&coremask, argv[1])) {
			puts("Error: could not parse coremask string\n");
			return -1;
		}
	} else {
		cvmx_coremask_set_self(&coremask);
	}

	if (octeon_has_feature(OCTEON_FEATURE_MULTINODE)) {
		for (node = CVMX_MAX_NODES - 1; node >= 0; node--) {
			cores = cvmx_coremask_get64_node(&coremask, node);
			cvmx_write_csr_node(node, CVMX_CIU3_NMI, cores);

		}
	} else {
		cores = cvmx_coremask_get64(&coremask);
		if (octeon_has_feature(OCTEON_FEATURE_CIU3))
			cvmx_write_csr(CVMX_CIU3_NMI, cores);
		else
			cvmx_write_csr(CVMX_CIU_NMI, cores);
	}
	return 0;
}
/**
 * Wait (stall) until all cores in the given coremask has reached this point
 * in the program execution before proceeding.
 *
 * @param  coremask  the group of cores performing the barrier sync
 *
 */
void cvmx_coremask_barrier_sync(const cvmx_coremask_t *pcm)
{
	int i;
	unsigned int target;
#ifndef CVMX_BUILD_FOR_LINUX_KERNEL
	assert(pcm != NULL && !((long)pcm & 3));
#endif
	cvmx_spinlock_lock(&state.lock);

	for (i = 0; i < CVMX_COREMASK_MAX_SYNCS; i++) {

		if (cvmx_coremask_is_empty(&state.s[i].coremask)) {
			/* end of existing coremask list, create new entry, fall-thru */
			cvmx_coremask_copy(&state.s[i].coremask, pcm);
		}

		if (cvmx_coremask_cmp(&state.s[i].coremask, pcm) == 0) {

			target = state.s[i].exit + 1;	/* wrap-around at 32b */

			cvmx_coremask_set_self(&state.s[i].checkin);

			if (cvmx_coremask_cmp(&state.s[i].checkin, pcm) == 0) {
				cvmx_coremask_clear_all(&state.s[i].checkin);
				state.s[i].exit = target;	/* signal exit condition */
			}
			cvmx_spinlock_unlock(&state.lock);

			while (state.s[i].exit != target) ;

			return;
		}
	}

	/* error condition - coremask array overflowed */
	cvmx_spinlock_unlock(&state.lock);
#ifndef CVMX_BUILD_FOR_LINUX_KERNEL
	assert(0);
#endif
}