Ejemplo n.º 1
0
static int psh_byt_resume(struct device *dev)
{
	struct psh_ia_priv *ia_data =
			(struct psh_ia_priv *)dev_get_drvdata(dev);

    struct psh_ext_if* lp_psh_if_info = 
        (struct psh_ext_if*)ia_data->platform_priv;
    
    //	struct spi_device *client =
	//	container_of(dev, struct spi_device, dev);

#ifdef ENABLE_POWER_CTRL_PIN
	psh_byt_toggle_ctl_pin(dev, 1);

    //	read_psh_data(ia_data);


#endif 
    //	enable_irq(client->irq);
	//disable_irq_wake(client->irq);
    psh_ia_comm_resume(dev);

    //MUST RESUME POLLER AFTER psh_ia_comm_resume()!!
    poller_resume(dev, &lp_psh_if_info->poller_worker);

	return 0;
}
Ejemplo n.º 2
0
static int psh_byt_suspend(struct device *dev)
{
	int ret;

	struct psh_ia_priv *ia_data =
			(struct psh_ia_priv *)dev_get_drvdata(dev);

    struct psh_ext_if* lp_psh_if_info = 
        (struct psh_ext_if*)ia_data->platform_priv;
    
    //MUST PAUSE POLLER BEFORE psh_ia_comm_resume()!!
    poller_pause(dev, &lp_psh_if_info->poller_worker);

	ret = psh_ia_comm_suspend(dev);
	if (ret)
    {
        poller_resume(dev, &lp_psh_if_info->poller_worker);
        return ret;
    }
	

    //	disable_irq(client->irq);

#ifdef ENABLE_POWER_CTRL_PIN
	psh_byt_toggle_ctl_pin(dev, 0);
#endif 

	//enable_irq_wake(client->irq);
 
	return 0;
}
Ejemplo n.º 3
0
static int psh_byt_runtime_resume(struct device *dev)
{
#ifdef ENABLE_POWER_CTRL_PIN

	struct psh_ia_priv *ia_data =
			(struct psh_ia_priv *)dev_get_drvdata(dev);

    struct psh_ext_if* lp_psh_if_info = 
        (struct psh_ext_if*)ia_data->platform_priv;
    
    psh_byt_toggle_ctl_pin(dev, 1);
    poller_resume(dev, &lp_psh_if_info->poller_worker);

#endif 

	dev_dbg(dev, "PSH_BYT: %s\n", __func__);

	return 0;
}
Ejemplo n.º 4
0
static void
ev_stat_cb(UNUSED EV_P_ ev_stat *w, UNUSED int revents)
{
    mrkthr_ctx_t *ctx;
    ev_item_t *ev;

    ctx = w->data;

    if (ctx == NULL) {
        CTRACE("no thread for stat path %s using default [discard]...", w->path);
        ev_stat_stop(the_loop, w);

    } else {
        ev = ctx->pdata.ev;

        assert(ev != NULL);
        assert(&ev->ev.stat == w);

        ctx->pdata.ev = NULL;

        if (ctx->co.f == NULL) {
            CTRACE("co for stat path %s is NULL, discarding ...", w->path);
            clear_event_stat(ev);

        } else {
            /*
             * XXX
             */

            clear_event_stat(ev);

            if (poller_resume(ctx) != 0) {
#ifdef TRACE_VERBOSE
                CTRACE("Could not resume co %d "
                      "for stat path %s, discarding ...",
                      ctx->co.id, w->path);
#endif
            }
        }
    }
}
Ejemplo n.º 5
0
/**
 * Event loop
 */
static void
ev_io_cb(UNUSED EV_P_ ev_io *w, UNUSED int revents)
{
    mrkthr_ctx_t *ctx;
    ev_item_t *ev;

    ctx = w->data;

    if (ctx == NULL) {
        CTRACE("no thread for FD %d filter %s "
               "using default [discard]...", w->fd,
               EV_STR(w->events));
        ev_io_stop(the_loop, w);

    } else {
        ev = ctx->pdata.ev;

        assert(ev != NULL);
        assert(&ev->ev.io == w);

        ctx->pdata.ev = NULL;

        if (ctx->co.f == NULL) {
            CTRACE("co for FD %d is NULL, discarding ...", w->fd);
            clear_event_io(ev);

        } else {
            if (w->events == EV_READ) {
                if ((ctx->co.state &
                        (CO_STATE_READ | CO_STATE_OTHER_POLLER)) == 0) {
                    CTRACE(FRED("Delivering a read event "
                                "that was not scheduled for!"));
                }
            } else if (w->events == EV_WRITE) {
                if ((ctx->co.state &
                        (CO_STATE_WRITE | CO_STATE_OTHER_POLLER)) == 0) {
                    CTRACE(FRED("Delivering a read event "
                                "that was not scheduled for!"));
                }
            } else if (w->events & (EV_READ|EV_WRITE)) {
                if (ctx->co.state != CO_STATE_OTHER_POLLER) {
                    CTRACE(FRED("Delivering other poller events (%d) "
                                "that were not scheduled for!"),
                                w->events);
                }
            } else {
                CTRACE("filter %s is not supporting", EV_STR(w->events));
            }

            clear_event_io(ev);

            if (poller_resume(ctx) != 0) {
#ifdef TRACE_VERBOSE
                CTRACE("Could not resume co %d "
                       "for FD %d, discarding ...",
                       ctx->co.id, w->fd);
#endif
            }
        }
    }
}
Ejemplo n.º 6
0
/**
 * Give a single slice to those threads that have their sleep time
 * expired.
 */
void
poller_sift_sleepq(void)
{
    STQUEUE(_mrkthr_ctx, runq);
    mnbtrie_node_t *trn;
    mrkthr_ctx_t *ctx;
    uint64_t now;

    /* run expired threads */

    STQUEUE_INIT(&runq);

    now = mrkthr_get_now_ticks();

    for (trn = BTRIE_MIN(&the_sleepq);
         trn != NULL;
         trn = BTRIE_MIN(&the_sleepq)) {

        ctx = (mrkthr_ctx_t *)(trn->value);
        assert(ctx != NULL);

        if (ctx->expire_ticks < now) {
            //if (ctx->expire_ticks > MRKTHR_SLEEP_RESUME_NOW) {
            //    TRACEC(FBYELLOW("remove (poller)"));
            //    mrkthr_dump(ctx);
            //}

            STQUEUE_ENQUEUE(&runq, runq_link, ctx);
            //sleepq_remove(ctx);
            trn->value = NULL;
            btrie_remove_node(&the_sleepq, trn);
            trn = NULL;
#ifdef TRACE_VERBOSE
            CTRACE(FBGREEN("Put in runq:"));
            mrkthr_dump(ctx);
#endif
        } else {
            break;
        }
    }

    while ((ctx = STQUEUE_HEAD(&runq)) != NULL) {
        mrkthr_ctx_t *bctx;
        mrkthr_waitq_t sleepq_bucket_tmp;

        STQUEUE_DEQUEUE(&runq, runq_link);
        STQUEUE_ENTRY_FINI(runq_link, ctx);
#ifdef TRACE_VERBOSE
        CTRACE(FBGREEN("Resuming expired bucket owner >>>"));
        mrkthr_dump(ctx);
        CTRACE(FBGREEN("<<<"));
#endif
        ctx->expire_ticks = MRKTHR_SLEEP_UNDEFINED;

        if (!(ctx->co.state & CO_STATES_RESUMABLE_EXTERNALLY)) {
            /*
             * We cannot resume events here that can only be
             * resumed from within other places of mrkthr_loop().
             *
             * All other events not included here are
             * CO_STATE_READ, CO_STATE_WRITE, CO_STATE_OTHER_POLLER. This
             * should never occur.
             */
#ifdef TRACE_VERBOSE
            CTRACE("ctx=%p", ctx);
            CTRACE(FYELLOW("Have to deliver a %s event "
                       "to co.id=%ld that was not scheduled for!"),
                       CO_STATE_STR(ctx->co.state),
                       (long)ctx->co.id);
            mrkthr_dump(ctx);
#endif
        }

        sleepq_bucket_tmp = ctx->sleepq_bucket;
        DTQUEUE_FINI(&ctx->sleepq_bucket);

        if (poller_resume(ctx) != 0) {
#ifdef TRACE_VERBOSE
            CTRACE("Could not resume co %ld, discarding ...",
                   (long)ctx->co.id);
#endif
        }

        while ((bctx = DTQUEUE_HEAD(&sleepq_bucket_tmp)) != NULL) {
            DTQUEUE_DEQUEUE(&sleepq_bucket_tmp, sleepq_link);
            DTQUEUE_ENTRY_FINI(sleepq_link, bctx);
#ifdef TRACE_VERBOSE
            CTRACE(FBGREEN("Resuming expired thread (from bucket) >>>"));
            mrkthr_dump(bctx);
            CTRACE(FBGREEN("<<<"));
#endif
            bctx->expire_ticks = MRKTHR_SLEEP_UNDEFINED;

            if (!(bctx->co.state & CO_STATES_RESUMABLE_EXTERNALLY)) {
                /*
                 * We cannot resume events here that can only be
                 * resumed from within other places of mrkthr_loop().
                 *
                 * All other events not included here are
                 * CO_STATE_READ, CO_STATE_WRITE, CO_STATE_OTHER_POLLER. This
                 * should never occur.
                 */
#ifdef TRACE_VERBOSE
                CTRACE(FYELLOW("Have to deliver a %s event "
                           "to co.id=%ld that was not scheduled for!"),
                           CO_STATE_STR(bctx->co.state),
                           (long)bctx->co.id);
                mrkthr_dump(bctx);
#endif
            }

            if (poller_resume(bctx) != 0) {
#ifdef TRACE_VERBOSE
                CTRACE("Could not resume co %ld, discarding ...",
                       (long)bctx->co.id);
#endif
            }
        }
    }
}