[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Minios-devel] [UNIKRAFT PATCH v3 07/10] plat/xen: Introduce Xenbus watch
Reviewed-by: Yuri Volchkov <yuri.volchkov@xxxxxxxxx> I will add one minor modification here (see inline) Costin Lupu <costin.lupu@xxxxxxxxx> writes: > Introduce the abstraction for Xenbus watches. > > Signed-off-by: Costin Lupu <costin.lupu@xxxxxxxxx> > --- > plat/xen/include/xenbus/client.h | 21 +++++++++++++++++++++ > plat/xen/include/xenbus/xenbus.h | 16 ++++++++++++++++ > plat/xen/xenbus/client.c | 40 > ++++++++++++++++++++++++++++++++++++++++ > plat/xen/xenbus/exportsyms.uk | 2 ++ > 4 files changed, 79 insertions(+) > > diff --git a/plat/xen/include/xenbus/client.h > b/plat/xen/include/xenbus/client.h > index 964592d..f3540b7 100644 > --- a/plat/xen/include/xenbus/client.h > +++ b/plat/xen/include/xenbus/client.h > @@ -65,4 +65,25 @@ const char *xenbus_devtype_to_str(enum xenbus_dev_type > devtype); > */ > enum xenbus_dev_type xenbus_str_to_devtype(const char *devtypestr); > > + > +/* > + * Watches > + */ > + > +/* > + * Waits for a watch event. Called by a client driver. > + * > + * @param watch Xenbus watch > + * @return 0 on success, a negative errno value on error. > + */ > +int xenbus_watch_wait_event(struct xenbus_watch *watch); > + > +/* > + * Notifies a client driver waiting for watch events. > + * > + * @param watch Xenbus watch > + * @return 0 on success, a negative errno value on error. > + */ > +int xenbus_watch_notify_event(struct xenbus_watch *watch); > + > #endif /* __XENBUS_CLIENT_H__ */ > diff --git a/plat/xen/include/xenbus/xenbus.h > b/plat/xen/include/xenbus/xenbus.h > index 970b96a..230dcd4 100644 > --- a/plat/xen/include/xenbus/xenbus.h > +++ b/plat/xen/include/xenbus/xenbus.h > @@ -88,6 +88,22 @@ void _xenbus_register_driver(struct xenbus_driver *drv); > typedef unsigned long xenbus_transaction_t; > #define XBT_NIL ((xenbus_transaction_t) 0) > > +/* > + * Xenbus watch > + */ > + > +struct xenbus_watch { > + /**< in use internally */ > + UK_TAILQ_ENTRY(struct xenbus_watch) watch_list; > + /**< Lock */ > + spinlock_t lock; > + /**< Number of pending events */ > + int pending_events; > + /**< Watch waiting queue */ > + struct uk_waitq wq; > +}; > +UK_TAILQ_HEAD(xenbus_watch_list, struct xenbus_watch); > + > > /* > * Xenbus device > diff --git a/plat/xen/xenbus/client.c b/plat/xen/xenbus/client.c > index 3ddae5e..3dbca0f 100644 > --- a/plat/xen/xenbus/client.c > +++ b/plat/xen/xenbus/client.c > @@ -90,3 +90,43 @@ enum xenbus_dev_type xenbus_str_to_devtype(const char > *devtypestr) > > return xenbus_dev_none; > } > + > +/* > + * Watches > + */ > + > +int xenbus_watch_wait_event(struct xenbus_watch *watch) > +{ > + if (watch == NULL) > + return -EINVAL; > + > + while (1) { > + ukarch_spin_lock(&watch->lock); > + > + if (watch->pending_events > 0) > + break; > + > + ukarch_spin_unlock(&watch->lock); > + > + uk_waitq_wait_event(&watch->wq, > + (watch->pending_events > 0)); > + } > + > + watch->pending_events--; > + ukarch_spin_unlock(&watch->lock); > + > + return 0; > +} > + > +int xenbus_watch_notify_event(struct xenbus_watch *watch) > +{ > + if (watch == NULL) > + return -EINVAL; > + > + ukarch_spin_lock(&watch->lock); > + watch->pending_events++; > + uk_waitq_wake_up(&watch->wq); > + ukarch_spin_unlock(&watch->lock); > + > + return 0; > +} > diff --git a/plat/xen/xenbus/exportsyms.uk b/plat/xen/xenbus/exportsyms.uk > index e58bcf8..2352a82 100644 > --- a/plat/xen/xenbus/exportsyms.uk > +++ b/plat/xen/xenbus/exportsyms.uk > @@ -24,4 +24,6 @@ xs_get_self_id > xenbus_state_to_str > xenbus_devtype_to_str > xenbus_str_to_devtype > +xenbus_watch_wait_event > +xenbus_watch_notify_event As discussed offline, notify_event is not needed to be exported. At least for now. I will remove it from exportsyms.uk before pushing > > -- > 2.11.0 > -- Yuri Volchkov Software Specialist NEC Europe Ltd Kurfürsten-Anlage 36 D-69115 Heidelberg _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |