Skip to content
Snippets Groups Projects
Commit 77b8fb02 authored by Alessandro Rubini's avatar Alessandro Rubini Committed by Federico Vaga
Browse files

generic_data_done: mark lost blocks in the alarm field


This also reorganizes generic_data_done to exploit symmetry between
input and output csets. Actually, we didn't update seq_num or the
timestamp for output, but now we have the current control in sysfs,
so we'd better update it every time.

Signed-off-by: default avatarAlessandro Rubini <rubini@gnudd.com>
Acked-by: default avatarFederico Vaga <federico.vaga@gmail.com>
parent 54e402f2
Branches
Tags
No related merge requests found
......@@ -84,13 +84,10 @@ static int __zio_arm_input_trigger(struct zio_ti *ti)
/* Allocate the buffer for the incoming sample, in active channels */
chan_for_each(chan, cset) {
ctrl = chan->current_ctrl;
ctrl->seq_num++;
ctrl->nsamples = ti->nsamples;
datalen = ctrl->ssize * ti->nsamples;
block = zbuf->b_op->alloc_block(chan->bi, datalen,
GFP_ATOMIC);
/* on error it returns NULL so we are all happy */
block = zbuf->b_op->alloc_block(chan->bi, datalen, GFP_ATOMIC);
/* If alloc error, it is reported at data_done time */
chan->active_block = block;
}
i = cset->raw_io(cset);
......
......@@ -117,46 +117,50 @@ int zio_trigger_abort_disable(struct zio_cset *cset, int disable);
static inline void zio_generic_data_done(struct zio_cset *cset)
{
struct zio_buffer_type *zbuf;
struct zio_device *zdev;
struct zio_channel *chan;
struct zio_block *block;
struct zio_control *ctrl;
struct zio_ti *ti;
struct zio_bi *bi;
pr_debug("%s:%d\n", __func__, __LINE__);
ti = cset->ti;
zdev = cset->zdev;
zbuf = cset->zbuf;
if (unlikely((ti->flags & ZIO_DIR) == ZIO_DIR_OUTPUT)) {
chan_for_each(chan, cset) {
bi = chan->bi;
block = chan->active_block;
if (block)
zbuf->b_op->free_block(chan->bi, block);
/* We may have a new block ready, or not */
chan->active_block = zbuf->b_op->retr_block(chan->bi);
}
return;
}
/* DIR_INPUT */
/* Input and output are very similar by now */
chan_for_each(chan, cset) {
bi = chan->bi;
block = chan->active_block;
if (!block)
ctrl = chan->current_ctrl;
/* Update the current control: sequence and timestamp */
ctrl->seq_num++;
ctrl->tstamp.secs = ti->tstamp.tv_sec;
ctrl->tstamp.ticks = ti->tstamp.tv_nsec;
ctrl->tstamp.bins = ti->tstamp_extra;
if (!block) {
ctrl->zio_alarms |= ZIO_ALARM_LOST_BLOCK;
continue;
/* Copy the stamp: it is cset-wide so it lives in the trigger */
chan->current_ctrl->tstamp.secs = ti->tstamp.tv_sec;
chan->current_ctrl->tstamp.ticks = ti->tstamp.tv_nsec;
chan->current_ctrl->tstamp.bins = ti->tstamp_extra;
memcpy(zio_get_ctrl(block), chan->current_ctrl,
zio_control_size(chan));
if (zbuf->b_op->store_block(bi, block)) /* may fail, no prob */
zbuf->b_op->free_block(bi, block);
}
if (unlikely((ti->flags & ZIO_DIR) == ZIO_DIR_OUTPUT)) {
zbuf->b_op->free_block(chan->bi, block);
} else { /* DIR_INPUT */
memcpy(zio_get_ctrl(block), ctrl,
zio_control_size(chan));
if (zbuf->b_op->store_block(bi, block))
zbuf->b_op->free_block(bi, block);
}
chan->active_block = NULL;
}
if (likely((ti->flags & ZIO_DIR) == ZIO_DIR_INPUT))
return;
/* Only for output: prepare the next event if any is ready */
chan_for_each(chan, cset)
chan->active_block = zbuf->b_op->retr_block(chan->bi);
}
#endif /* __ZIO_TRIGGER_H__ */
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment