From 837f8a853f54361405ade7924a740785dc711542 Mon Sep 17 00:00:00 2001 From: mav Date: Thu, 31 Aug 2017 10:59:39 +0000 Subject: [PATCH] Make ntb_set_ctx() always generate fake link event. It allows application driver get initial link state without racing with hardware interrupts, thanks to the context rmlock held here. MFC after: 1 week Sponsored by: iXsystems, Inc. --- sys/dev/ntb/ntb.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sys/dev/ntb/ntb.c b/sys/dev/ntb/ntb.c index 7515dfcaa49a..fd6e1028891a 100644 --- a/sys/dev/ntb/ntb.c +++ b/sys/dev/ntb/ntb.c @@ -264,6 +264,13 @@ ntb_set_ctx(device_t ntb, void *ctx, const struct ntb_ctx_ops *ctx_ops) } nc->ctx = ctx; nc->ctx_ops = ctx_ops; + + /* + * If applicaiton driver asks for link events, generate fake one now + * to let it update link state without races while we hold the lock. + */ + if (ctx_ops->link_event != NULL) + ctx_ops->link_event(ctx); rm_wunlock(&nc->ctx_lock); return (0);