Commit 4a73049c authored by Federico Vaga's avatar Federico Vaga

trigger: data_done returns an integer

The data_done trigger operation returns an integer which mean if the
trigger must be automatically re-armed (1) or not (0). The rearm value
it is returned by zio_trigger_data_done to notify if the trigger was
rearmed or not.
Signed-off-by: 's avatarFederico Vaga <federico.vaga@gmail.com>
Acked-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 216e8787
......@@ -162,33 +162,37 @@ EXPORT_SYMBOL(zio_arm_trigger);
* transfer is over and we need to complete the operation. The trigger
* is in "ARMED" state when this is called, and is not any more when
* the function returns. Please note that we keep the cset lock
* for the duration of the whole function, which must be atomic
* for the duration of the whole function, which must be atomic.
*
* The data_done trigger operation returns an integer [0, 1] which mean if the
* trigger must be re-armed or not. The rearm value it is returned to the caller
* to notify if the trigger was rearmed or not.
*/
void zio_trigger_data_done(struct zio_cset *cset)
int zio_trigger_data_done(struct zio_cset *cset)
{
int self_timed = cset->flags & ZIO_CSET_SELF_TIMED;
unsigned long flags;
int rearm;
spin_lock_irqsave(&cset->lock, flags);
if (cset->ti->t_op->data_done)
cset->ti->t_op->data_done(cset);
rearm = cset->ti->t_op->data_done(cset);
else
zio_generic_data_done(cset);
rearm = zio_generic_data_done(cset);
cset->ti->flags &= ~ZIO_TI_ARMED;
spin_unlock_irqrestore(&cset->lock, flags);
/*
* If it is self-timed, re-arm the trigger immediately.
* zio_arm_trigger() needs to lock, so it's correct we
* released the lock above. No race is expected, because
* self-timed devices need to run the transparent trigger. But
* if the cset is misconfigured and somebody arm the trigger
* in this small window, no harm is done anyways.
*/
if (self_timed)
if (rearm == 1)
zio_arm_trigger(cset->ti);
return rearm;
}
EXPORT_SYMBOL(zio_trigger_data_done);
......@@ -90,7 +90,7 @@ struct zio_trigger_operations {
void (*pull_block)(struct zio_ti *ti,
struct zio_channel *chan);
void (*data_done)(struct zio_cset *cset);
int (*data_done)(struct zio_cset *cset);
int (*config)(struct zio_ti *ti,
struct zio_control *ctrl);
......@@ -105,7 +105,7 @@ struct zio_trigger_operations {
void (*abort)(struct zio_ti *ti);
};
void zio_trigger_data_done(struct zio_cset *cset);
int zio_trigger_data_done(struct zio_cset *cset);
int zio_trigger_abort_disable(struct zio_cset *cset, int disable);
/*
......@@ -113,9 +113,13 @@ int zio_trigger_abort_disable(struct zio_cset *cset, int disable);
* If no trigger-specific function is specified, the core calls this one.
* This can also be called by cset->stop_io to return partial blocks.
* The function is called while holding the cset spin lock.
*
* The function returns 1 if the trigger must be rearmed automatically,
* otherwise, it returns 0.
*/
static inline void zio_generic_data_done(struct zio_cset *cset)
static inline int zio_generic_data_done(struct zio_cset *cset)
{
int self_timed = cset->flags & ZIO_CSET_SELF_TIMED;
struct zio_buffer_type *zbuf;
struct zio_channel *chan;
struct zio_block *block;
......@@ -155,11 +159,13 @@ static inline void zio_generic_data_done(struct zio_cset *cset)
chan->active_block = NULL;
}
if (likely((ti->flags & ZIO_DIR) == ZIO_DIR_INPUT))
return;
return (self_timed ? 1 : 0);
/* Only for output: prepare the next event if any is ready */
chan_for_each(chan, cset)
chan->active_block = zio_buffer_retr_block(chan->bi);
return (self_timed ? 1 : 0);
}
/**
......
Markdown is supported
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