Beispiel #1
0
int ticker_thread(void *data)
{
    struct timer_list ticker;

    // detach

    lock_kernel();
    exit_mm(current);
    exit_files(current);
    exit_fs(current);

    // setsid equivalent, used at start of kernel thread, no error checks needed, or at least none made :).
    current->leader = 1;
    current->session = current->pgrp = current->pid;
    current->tty = NULL;
    current->tty_old_pgrp = 0;

    // Name this thread
    sprintf(current->comm, "usbd-bi");

    // setup signal handler
    current->exit_signal = SIGCHLD;
    spin_lock(&current->sigmask_lock);
    flush_signals(current);
    spin_unlock(&current->sigmask_lock);

    // XXX Run at a high priority, ahead of sync and friends
//    current->nice = -20;
    current->policy = SCHED_OTHER;

    unlock_kernel();

    // setup timer
    init_timer(&ticker);
    ticker.data = 0;
    ticker.function = ticker_tick;

    // let startup continue
    up(&ticker_sem_start);

    // process loop
    for (ticker_timer_set = ticker_terminating = 0; !ticker_terminating;) {

        char buf[100];
        char *cp;

        if (!ticker_timer_set) {
            mod_timer(&ticker, jiffies + HZ*RETRYTIME);
        }

        // wait for someone to tell us to do something
        down(&ticker_sem_work);

        if (udc_interrupts != udc_interrupts_last) {
            dbg_tick(1,"--------------");
        }

        // do some work
        memset(buf, 0, sizeof(buf));
        cp = buf;

        if (dbgflg_usbdbi_tick) {
            unsigned long flags;
            local_irq_save(flags);
            dbg_tick(1,"[%d]", udc_interrupts);
            udc_regs();
            local_irq_restore(flags);
        }
    }

    // remove timer
    del_timer(&ticker);

    // let the process stopping us know we are done and return
    up(&ticker_sem_start);
    return 0;
}
Beispiel #2
0
int ticker_thread (void *data)
{
	struct timer_list ticker;

	// detach

	lock_kernel ();
	exit_mm (current);
	exit_files (current);
	exit_fs (current);

	// setsid equivalent, used at start of kernel thread, no error checks needed, or at least none made :). 
	current->leader = 1;
	current->session = current->pgrp = current->pid;
	current->tty = NULL;
	current->tty_old_pgrp = 0;

	// Name this thread 
	sprintf (current->comm, "usbd-bi");

	// setup signal handler
	current->exit_signal = SIGCHLD;
	spin_lock (&current->sigmask_lock);
	flush_signals (current);
	spin_unlock (&current->sigmask_lock);

	// XXX Run at a high priority, ahead of sync and friends
	// current->nice = -20;
	current->policy = SCHED_OTHER;

	unlock_kernel ();

	// setup timer
	init_timer (&ticker);
	ticker.data = 0;
	ticker.function = ticker_tick;

	// let startup continue
	up (&ticker_sem_start);

	// process loop
	for (ticker_timer_set = ticker_terminating = 0; !ticker_terminating;) {

		char buf[100];
		char *cp;

		if (!ticker_timer_set) {
			mod_timer (&ticker, jiffies + HZ * RETRYTIME);
		}
		// wait for someone to tell us to do something
		down (&ticker_sem_work);

		if (udc_interrupts != udc_interrupts_last) {
			dbg_tick (3, "--------------");
		}
		// do some work
		memset (buf, 0, sizeof (buf));
		cp = buf;

		if (dbgflg_usbdbi_tick) {
			unsigned long flags;
			local_irq_save (flags);
			dbg_tick (2, "[%d]", udc_interrupts);
			udc_regs ();
			local_irq_restore (flags);
		}

#if 0
		// XXX
#if defined(CONFIG_SA1110_CALYPSO) && defined(CONFIG_PM) && defined(CONFIG_USBD_TRAFFIC_KEEPAWAKE)
		/* Check for rx/tx activity, and reset the sleep timer if present */
		if (device->usbd_rxtx_timestamp != device->usbd_last_rxtx_timestamp) {
			extern void resetSleepTimer (void);
			dbg_tick (7, "resetting sleep timer");
			resetSleepTimer ();
			device->usbd_last_rxtx_timestamp = device->usbd_rxtx_timestamp;
		}
#endif
#endif
#if 0
		/* Check for TX endpoint stall.  If the endpoint has
		   stalled, we have probably run into the DMA/TCP window
		   problem, and the only thing we can do is disconnect
		   from the bus, then reconnect (and re-enumerate...). */
		if (reconnect > 0 && 0 >= --reconnect) {
			dbg_init (0, "TX stall disconnect finished");
			udc_connect ();
		} else if (0 != USBD_STALL_TIMEOUT_SECONDS) {
			// Stall watchdog unleashed
			unsigned long now, tx_waiting;
			now = jiffies;
			tx_waiting = (now - tx_queue_head_timestamp (now)) / HZ;
			if (tx_waiting > USBD_STALL_TIMEOUT_SECONDS) {
				/* The URB at the head of the queue has waited too long */
				reconnect = USBD_STALL_DISCONNECT_DURATION;
				dbg_init (0, "TX stalled, disconnecting for %d seconds", reconnect);
				udc_disconnect ();
			}
		}
#endif
	}

	// remove timer
	del_timer (&ticker);

	// let the process stopping us know we are done and return
	up (&ticker_sem_start);
	return 0;
}