Commit 7c1ae8be authored by Alessandro Rubini's avatar Alessandro Rubini

chardev: fix race conditions for concurrent rd/wr

This is a long-standing bug, when more than one process access
concurrently the char devices. This adds proper locking and solved the
problem.

Also, a new policy for writing control is in place: if you write
control, any partial block (unless empty) is pushed to the pipeline.
This matches the idea that after write(2) accepts data, it cannot be lost.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
Acked-by: 's avatarFederico Vaga <federico.vaga@gmail.com>
parent 60fc63ca
This diff is collapsed.
......@@ -241,6 +241,7 @@ struct zio_channel {
struct zio_control *current_ctrl; /* the active one */
struct zio_block *user_block; /* being transferred w/ user */
struct mutex user_lock;
struct zio_block *active_block; /* being managed by hardware */
};
......
......@@ -875,6 +875,7 @@ static int cset_register(struct zio_cset *cset, struct zio_cset *cset_t)
cset->chan[i].index = i;
cset->chan[i].cset = cset;
cset->chan[i].ti = cset->ti;
mutex_init(&cset->chan[i].user_lock);
cset->chan[i].flags |= cset->flags & ZIO_DIR;
chan_tmp = NULL;
if (cset->chan_template)
......
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