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

From: Frederic Barrat <[email-masked]>
Date: Wed, 9 Mar 2016 10:27:20 +0100

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