diff --git a/include/linux/zio-trigger.h b/include/linux/zio-trigger.h index 1ba07af4de9a12a2c92b26b7ae0dfbea0bea6a12..d1b8bebd8daeff4a458eeb72afca64ac407b681e 100644 --- a/include/linux/zio-trigger.h +++ b/include/linux/zio-trigger.h @@ -51,9 +51,7 @@ struct zio_ti { /* first 4bit are reserved for zio object universal flags */ enum zti_flag_mask { - ZTI_STATUS = 0x10, - ZTI_STATUS_OFF = 0x00, /* trigger is idle */ - ZTI_STATUS_ON = 0x10, /* trigger fire and transfer occurs */ + ZTI_BUSY = 0x10, /* trigger fire and transfer occurs */ }; #define to_zio_ti(_kobj) container_of(_kobj, struct zio_ti, head.kobj) diff --git a/zio-sys.c b/zio-sys.c index 398f06395a90fd6b3d55e4e0f6fafac4ce38039a..a8494bee775b079500bf30949716730dccb57d9e 100644 --- a/zio-sys.c +++ b/zio-sys.c @@ -155,7 +155,9 @@ void zio_generic_data_done(struct zio_cset *cset) zbuf->b_op->free_block(bi, block); } out: - ti->flags &= (~ZTI_STATUS); + spin_lock(&cset->lock); + ti->flags &= (~ZTI_BUSY); /* Reset busy, now is idle */ + spin_unlock(&cset->lock); } EXPORT_SYMBOL(zio_generic_data_done); @@ -225,13 +227,14 @@ void zio_fire_trigger(struct zio_ti *ti) /* If the trigger runs too early, ti->cset is still NULL */ if (!ti->cset) return; - /* chek if trigger is disabled */ - if (unlikely((ti->flags & ZIO_STATUS) == ZIO_DISABLED)) - return; - /* check if previouvs fire is still running*/ - if ((ti->flags & ZTI_STATUS) == ZTI_STATUS_ON) + + /* check if trigger is disabled or previous fire is still running */ + if (unlikely((ti->flags & ZIO_STATUS) == ZIO_DISABLED || + (ti->flags & ZTI_BUSY))) return; - ti->flags |= ZTI_STATUS_ON; + spin_lock(&ti->cset->lock); + ti->flags |= ZTI_BUSY; + spin_unlock(&ti->cset->lock); /* Copy the stamp (we are software driven anyways) */ ti->current_ctrl->tstamp.secs = ti->tstamp.tv_sec; ti->current_ctrl->tstamp.ticks = ti->tstamp.tv_nsec; @@ -742,7 +745,7 @@ static void __zobj_enable(struct kobject *kobj, unsigned int enable, ti = to_zio_ti(kobj); /* if trigger is running, abort it*/ - if ((*flags & ZTI_STATUS) == ZTI_STATUS_ON) + if (*flags & ZTI_BUSY) if(ti->t_op->abort) ti->t_op->abort(ti->cset); /* trigger instance callback */ @@ -1360,7 +1363,7 @@ static int cset_register(struct zio_cset *cset) err = PTR_ERR(cset->chan); goto out_remove_sys; } - + spin_lock_init(&cset->lock); /* * The cset must have a buffer type. If none is associated * to the cset, ZIO selects the preferred or default one.