Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753015AbcCIJ1e (ORCPT ); Wed, 9 Mar 2016 04:27:34 -0500 Received: from e06smtp17.uk.ibm.com ([195.75.94.113]:32903 "EHLO e06smtp17.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751599AbcCIJ10 (ORCPT ); Wed, 9 Mar 2016 04:27:26 -0500 X-IBM-Helo: d06dlp03.portsmouth.uk.ibm.com X-IBM-MailFrom: fbarrat@linux.vnet.ibm.com X-IBM-RcptTo: linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 1/2] cxl: Add mechanism for delivering AFU driver specific events To: Ian Munsie , Michael Ellerman , linux-kernel , Matt Ochs , Manoj Kumar References: <1457401715-26435-1-git-send-email-imunsie@au.ibm.com> Cc: linuxppc-dev , Michael Neuling From: Frederic Barrat Message-ID: <56DFEC78.9050704@linux.vnet.ibm.com> Date: Wed, 9 Mar 2016 10:27:20 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <1457401715-26435-1-git-send-email-imunsie@au.ibm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16030909-0005-0000-0000-00000AB738EF Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1187 Lines: 42 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