Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933278AbcCIQoC (ORCPT ); Wed, 9 Mar 2016 11:44:02 -0500 Received: from e31.co.us.ibm.com ([32.97.110.149]:54293 "EHLO e31.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753712AbcCIQny convert rfc822-to-8bit (ORCPT ); Wed, 9 Mar 2016 11:43:54 -0500 X-IBM-Helo: d03dlp02.boulder.ibm.com X-IBM-MailFrom: mrochs@us.ibm.com X-IBM-RcptTo: linux-kernel@vger.kernel.org Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2104\)) Subject: Re: [PATCH v3 1/2] cxl: Add mechanism for delivering AFU driver specific events From: Matt Ochs In-Reply-To: <87a8m7iunv.fsf@vajain21.in.ibm.com> Date: Wed, 9 Mar 2016 10:41:04 -0600 Cc: Ian Munsie , Michael Ellerman , linux-kernel , Manoj Kumar , linuxppc-dev , Michael Neuling Content-Transfer-Encoding: 8BIT Message-Id: <87CD53E9-4F45-476F-9DA3-A3CEF974D357@us.ibm.com> References: <1457401715-26435-1-git-send-email-imunsie@au.ibm.com> <87a8m7iunv.fsf@vajain21.in.ibm.com> To: Vaibhav Jain X-Mailer: Apple Mail (2.2104) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16030916-8236-0000-0000-000016FE97B2 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2549 Lines: 55 > On Mar 9, 2016, at 8:37 AM, Vaibhav Jain wrote: >> +/* >> + * AFU driver ops allows an AFU driver to create their own events to pass to >> + * userspace through the file descriptor as a simpler alternative to overriding >> + * the read() and poll() calls that works with the generic cxl events. These >> + * events are given priority over the generic cxl events, so they will be >> + * delivered first if multiple types of events are pending. >> + * >> + * event_pending() will be called by the cxl driver to check if an event is >> + * pending (e.g. in select/poll/read calls). >> + * >> + * deliver_event() will be called to fill out a cxl_event structure with the >> + * driver specific event. The header will already have the type and >> + * process_element fields filled in, and header.size will be set to >> + * sizeof(struct cxl_event_header). The AFU driver can extend that size up to >> + * max_size (if an afu driver requires more space, they should submit a patch >> + * increasing the size in the struct cxl_event_afu_driver_reserved definition). >> + * >> + * Both of these calls are made with a spin lock held, so they must not sleep. >> + */ >> +struct cxl_afu_driver_ops { >> + bool (*event_pending) (struct cxl_context *ctx); >> + void (*deliver_event) (struct cxl_context *ctx, >> + struct cxl_event *event, size_t max_size); >> +}; >> + > > I would propose these two apis. > > /* > * fetches an event from the driver event queue. NULL means that queue > * is empty. Can sleep if needed. The memory for cxl_event is allocated > * by module being called. Hence it can be potentially be larger then > * sizeof(struct cxl_event). Multiple calls to this should return same > * pointer untill ack_event is called. > */ > struct cxl_event * fetch_event(struct cxl_context * ctx); > > /* > * Returns and acknowledge the struct cxl_event * back to the driver > * which can then free it or maybe put it back in a kmem_cache. This > * should be called once we have completely returned the current > * struct cxl_event from the readcall > */ > void ack_event(struct cxl_context * ctx, struct cxl_event *); > > I think above apis would give us more flexbility in the future when > drivers would want to send larger events without breaking the abi. >From a cxlflash perspective, I think we'd be fine with this model as long as the driver events are still prioritized. I do like the removal of the no-sleep requirement and this would allow us to simply hand off an already populated event reference.