Re: [PATCH v3 1/2] cxl: Add mechanism for delivering AFU driver specific events

From: Frederic Barrat
Date: Wed Mar 09 2016 - 04:27:38 EST


Hi Ian,

Le 08/03/2016 02:48, Ian Munsie a Ãcrit :
diff --git a/drivers/misc/cxl/file.c b/drivers/misc/cxl/file.c

...

+static inline bool ctx_event_pending(struct cxl_context *ctx)
+{
+ if (ctx->pending_irq || ctx->pending_fault || ctx->pending_afu_err)
+ return true;
+
+ if (ctx->afu_driver_ops)
+ return ctx->afu_driver_ops->event_pending(ctx);
+
+ return false;
+}
+

...

+
+ if (ctx->afu_driver_ops && ctx->afu_driver_ops->event_pending(ctx)) {
+ pr_devel("afu_read delivering AFU driver specific event\n");
+ event.header.type = CXL_EVENT_AFU_DRIVER;
+ ctx->afu_driver_ops->deliver_event(ctx, &event, sizeof(event));
+ WARN_ON(event.header.size > sizeof(event));
+
+ } else if (ctx->pending_irq) {


So on afu_read(), we may call afu_driver_ops->event_pending() twice before calling afu_driver_ops->deliver_event(). Actually, in the (likely) scenario where there's only an afu_driver event pending, we *will* call afu_driver_ops->event_pending() twice. Wouldn't it make sense to cache it then?

It would also avoid entering
WARN(1, "afu_read must be buggy\n");
if the driver changes its mind between the 2 calls :-)

Fred