예제 #1
0
파일: io.c 프로젝트: dot-Sean/linux_kernels
/*
 * hub_set_piomode()
 *
 * 	Put the hub into either "PIO conveyor belt" mode or "fire-and-forget"
 * 	mode.  To do this, we have to make absolutely sure that no PIOs
 *	are in progress so we turn off access to all widgets for the duration
 *	of the function.
 *
 * XXX - This code should really check what kind of widget we're talking
 * to.  Bridges can only handle three requests, but XG will do more.
 * How many can crossbow handle to widget 0?  We're assuming 1.
 *
 * XXX - There is a bug in the crossbow that link reset PIOs do not
 * return write responses.  The easiest solution to this problem is to
 * leave widget 0 (xbow) in fire-and-forget mode at all times.  This
 * only affects pio's to xbow registers, which should be rare.
 */
void
hub_set_piomode(nasid_t nasid, int conveyor)
{
    hubreg_t ii_iowa;
    int direct_connect;
    hubii_wcr_t ii_wcr;
    int prbnum;
    int s, cons_lock = 0;

    ASSERT(NASID_TO_COMPACT_NODEID(nasid) != INVALID_CNODEID);
    if (nasid == get_console_nasid()) {
        PUTBUF_LOCK(s);
        cons_lock = 1;
    }

    ii_iowa = REMOTE_HUB_L(nasid, IIO_OUTWIDGET_ACCESS);
    REMOTE_HUB_S(nasid, IIO_OUTWIDGET_ACCESS, 0);

    ii_wcr.wcr_reg_value = REMOTE_HUB_L(nasid, IIO_WCR);
    direct_connect = ii_wcr.iwcr_dir_con;

    if (direct_connect) {
        /*
         * Assume a bridge here.
         */
        hub_setup_prb(nasid, 0, 3, conveyor);
    } else {
        /*
         * Assume a crossbow here.
         */
        hub_setup_prb(nasid, 0, 1, conveyor);
    }

    for (prbnum = HUB_WIDGET_ID_MIN; prbnum <= HUB_WIDGET_ID_MAX; prbnum++) {
        /*
         * XXX - Here's where we should take the widget type into
         * when account assigning credits.
         */
        /* Always set the PRBs in fire-and-forget mode */
        hub_setup_prb(nasid, prbnum, 3, conveyor);
    }

#ifdef IRIX
    /*
     * In direct connect mode, disable access to all widgets but 0.
     * Later, the prom will do this for us.
     */
    if (direct_connect)
        ii_iowa = 1;
#endif

    REMOTE_HUB_S(nasid, IIO_OUTWIDGET_ACCESS, ii_iowa);

    if (cons_lock)
        PUTBUF_UNLOCK(s);
}
예제 #2
0
/* ARGSUSED */
static void
assign_widgets_to_volunteers(devfs_handle_t xswitch, devfs_handle_t hubv)
{
	xswitch_info_t xswitch_info;
	xswitch_vol_t xvolinfo = NULL;
	xwidgetnum_t widgetnum;
	int num_volunteer;
	nasid_t nasid;
	hubinfo_t hubinfo;
	extern int iobrick_type_get_nasid(nasid_t);


	hubinfo_get(hubv, &hubinfo);
	nasid = hubinfo->h_nasid;
	
	xswitch_info = xswitch_info_get(xswitch);
	ASSERT(xswitch_info != NULL);

	(void)hwgraph_info_get_LBL(xswitch, 
				INFO_LBL_XSWITCH_VOL, 
				(arbitrary_info_t *)&xvolinfo);
	if (xvolinfo == NULL) {
	    return;
	}

	num_volunteer = xvolinfo->xswitch_volunteer_count;
	ASSERT(num_volunteer > 0);

	/* Assign master hub for xswitch itself.  */
	if (HUB_WIDGET_ID_MIN > 0) {
		hubv = xvolinfo->xswitch_volunteer[0];
		xswitch_info_master_assignment_set(xswitch_info, (xwidgetnum_t)0, hubv);
	}

	/*
	 * TBD: Use administrative information to alter assignment of
	 * widgets to hubs.
	 */
	for (widgetnum=HUB_WIDGET_ID_MIN; widgetnum <= HUB_WIDGET_ID_MAX; widgetnum++) {
		int i;

		/*
		 * Ignore disabled/empty ports.
		 */
		if (!xbow_port_io_enabled(nasid, widgetnum)) 
		    continue;

		/*
		 * If this is the master IO board, assign it to the same 
		 * hub that owned it in the prom.
		 */
		if (is_master_nasid_widget(nasid, widgetnum)) {
			for (i=0; i<num_volunteer; i++) {
				hubv = xvolinfo->xswitch_volunteer[i];
				hubinfo_get(hubv, &hubinfo);
				nasid = hubinfo->h_nasid;
				if (nasid == get_console_nasid())
					goto do_assignment;
			}
		}

		/*
		 * Assuming that we're dual-hosted and that PCI cards 
		 * are naturally placed left-to-right, alternate PCI 
		 * buses across both Cbricks.   For Pbricks, and Ibricks,
                 * io_brick_map_widget() returns the PCI bus number
                 * associated with the given brick type and widget number.
                 * For Xbricks, it returns the XIO slot number.
		 */

		i = 0;
		if (num_volunteer > 1) {
                        int	       bt;

                       	bt = iobrick_type_get_nasid(nasid);
                        if (bt >= 0) {
				/*
				 * PXBRICK has two busses per widget so this
				 * algorithm wouldn't work (all busses would
				 * be assigned to one volunteer). Change the
				 * bricktype to PBRICK whose mapping is setup
				 * suchthat 2 of the PICs will be assigned to
				 * one volunteer and the other one will be
				 * assigned to the other volunteer.
				 */
				if (bt == MODULE_PXBRICK) 
					bt = MODULE_PBRICK;

			        i = io_brick_map_widget(bt, widgetnum) & 1;
                        }
                }

		hubv = xvolinfo->xswitch_volunteer[i];

do_assignment:
		/*
		 * At this point, we want to make hubv the master of widgetnum.
		 */
		xswitch_info_master_assignment_set(xswitch_info, widgetnum, hubv);
	}

	xswitch_volunteer_delete(xswitch);
}
예제 #3
0
/* ARGSUSED */
static void
assign_widgets_to_volunteers(devfs_handle_t xswitch, devfs_handle_t hubv)
{
	int curr_volunteer, num_volunteer;
	xwidgetnum_t widgetnum;
	xswitch_info_t xswitch_info;
	xswitch_vol_t xvolinfo = NULL;
	nasid_t nasid;
	hubinfo_t hubinfo;

	hubinfo_get(hubv, &hubinfo);
	nasid = hubinfo->h_nasid;
	
	xswitch_info = xswitch_info_get(xswitch);
	ASSERT(xswitch_info != NULL);

	(void)hwgraph_info_get_LBL(xswitch, 
				INFO_LBL_XSWITCH_VOL, 
				(arbitrary_info_t *)&xvolinfo);
	if (xvolinfo == NULL) {
#ifdef LATER
	    if (!is_headless_node_vertex(hubv)) {
#if defined(SUPPORT_PRINTING_V_FORMAT)
		printk(KERN_WARNING  "assign_widgets_to_volunteers:vertex %v has "
			" no info label",
			xswitch);
#else
		printk(KERN_WARNING  "assign_widgets_to_volunteers:vertex 0x%x has "
			" no info label",
			xswitch);
#endif
	    }
#endif	/* LATER */
	    return;
	}

	num_volunteer = xvolinfo->xswitch_volunteer_count;
	ASSERT(num_volunteer > 0);
	curr_volunteer = 0;

	/* Assign master hub for xswitch itself.  */
	if (HUB_WIDGET_ID_MIN > 0) {
		hubv = xvolinfo->xswitch_volunteer[0];
		xswitch_info_master_assignment_set(xswitch_info, (xwidgetnum_t)0, hubv);
	}

	/*
	 * TBD: Use administrative information to alter assignment of
	 * widgets to hubs.
	 */
	for (widgetnum=HUB_WIDGET_ID_MIN; widgetnum <= HUB_WIDGET_ID_MAX; widgetnum++) {

		/*
		 * Ignore disabled/empty ports.
		 */
		if (!xbow_port_io_enabled(nasid, widgetnum)) 
		    continue;

		/*
		 * If this is the master IO board, assign it to the same 
		 * hub that owned it in the prom.
		 */
		if (is_master_nasid_widget(nasid, widgetnum)) {
			int i;

			for (i=0; i<num_volunteer; i++) {
				hubv = xvolinfo->xswitch_volunteer[i];
				hubinfo_get(hubv, &hubinfo);
				nasid = hubinfo->h_nasid;
				if (nasid == get_console_nasid())
					goto do_assignment;
			}
#ifdef LATER
			PRINT_PANIC("Nasid == %d, console nasid == %d",
				nasid, get_console_nasid());
#endif
		}


		/*
		 * Do a round-robin assignment among the volunteer nodes.
		 */
		hubv = xvolinfo->xswitch_volunteer[curr_volunteer];
		curr_volunteer = (curr_volunteer + 1) % num_volunteer;
		/* fall through */

do_assignment:
		/*
		 * At this point, we want to make hubv the master of widgetnum.
		 */
		xswitch_info_master_assignment_set(xswitch_info, widgetnum, hubv);
	}

	xswitch_volunteer_delete(xswitch);
}