From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753344AbbC3Qrc (ORCPT ); Mon, 30 Mar 2015 12:47:32 -0400 Received: from p3plex2out01.prod.phx3.secureserver.net ([184.168.131.12]:37061 "EHLO p3plex2out01.prod.phx3.secureserver.netIMP" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753202AbbC3Qr2 convert rfc822-to-8bit (ORCPT ); Mon, 30 Mar 2015 12:47:28 -0400 From: Hartley Sweeten To: Ian Abbott , "driverdev-devel@linuxdriverproject.org" CC: Greg Kroah-Hartman , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH 7/7] staging: comedi: comedi_fops: extend spin-lock scope in comedi_event() Thread-Topic: [PATCH 7/7] staging: comedi: comedi_fops: extend spin-lock scope in comedi_event() Thread-Index: AQHQaKCS1cgJDjHGRU2Tzm64CmOpop01QGWw Date: Mon, 30 Mar 2015 16:47:27 +0000 Message-ID: References: <1427469186-11222-1-git-send-email-abbotti@mev.co.uk> <1427469186-11222-8-git-send-email-abbotti@mev.co.uk> In-Reply-To: <1427469186-11222-8-git-send-email-abbotti@mev.co.uk> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [184.183.19.121] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Friday, March 27, 2015 8:13 AM, Ian Abbott wrote: > `comedi_event()` is called from low-level drivers to handle comedi > asynchronous command event flags. As a safety check, it checks the > subdevice's "run" flags to make sure an asynchronous command is running. > It can also change the run flags to mark the command as no longer > running (possibly also marking it as terminated with an error). > Checking the runflags and modifying them involves two uses of the > subdevice's spin-lock. It seems better to do it with a single use of > the spin-lock. This also avoids possible interactions with > `do_become_nonbusy()`. > > Acquire the subdevice's spin-lock at the start of `comedi_event()` and > release it near the end, before a possible call to `kill_fasync()` (but > after it's parameter values have been determined). > > Add and make use of few new inline helper functions: > > * `__comedi_clear_subdevice_runflags()` -- clears some run flags without > using the spin-lock > * `__comedi_set_subdevice_runflags()` -- sets some run flags without > using the spin-lock > * `__comedi_get_subdevice_runflags()` -- a spin-lockless version of > `comedi_get_subdevice_runflags() > * `__comedi_is_subdevice_running()` -- a spin-lockless version of > * `comedi_is_subdevice_running()` > > Signed-off-by: Ian Abbott Ian, For completeness, the comedi_alloc_spriv() helper should probably use __comedi_set_subdevice_runflags() to set the COMEDI_SRF_FREE_SPRIV bit. Regards, Hartley From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Hartley Sweeten Subject: RE: [PATCH 7/7] staging: comedi: comedi_fops: extend spin-lock scope in comedi_event() Date: Mon, 30 Mar 2015 16:47:27 +0000 Message-ID: References: <1427469186-11222-1-git-send-email-abbotti@mev.co.uk> <1427469186-11222-8-git-send-email-abbotti@mev.co.uk> In-Reply-To: <1427469186-11222-8-git-send-email-abbotti@mev.co.uk> Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 List-ID: To: Ian Abbott , "driverdev-devel@linuxdriverproject.org" Cc: Greg Kroah-Hartman , "linux-kernel@vger.kernel.org" On Friday, March 27, 2015 8:13 AM, Ian Abbott wrote: > `comedi_event()` is called from low-level drivers to handle comedi > asynchronous command event flags. As a safety check, it checks the > subdevice's "run" flags to make sure an asynchronous command is running. > It can also change the run flags to mark the command as no longer > running (possibly also marking it as terminated with an error). > Checking the runflags and modifying them involves two uses of the > subdevice's spin-lock. It seems better to do it with a single use of > the spin-lock. This also avoids possible interactions with > `do_become_nonbusy()`. > > Acquire the subdevice's spin-lock at the start of `comedi_event()` and > release it near the end, before a possible call to `kill_fasync()` (but > after it's parameter values have been determined). > > Add and make use of few new inline helper functions: > > * `__comedi_clear_subdevice_runflags()` -- clears some run flags without > using the spin-lock > * `__comedi_set_subdevice_runflags()` -- sets some run flags without > using the spin-lock > * `__comedi_get_subdevice_runflags()` -- a spin-lockless version of > `comedi_get_subdevice_runflags() > * `__comedi_is_subdevice_running()` -- a spin-lockless version of > * `comedi_is_subdevice_running()` > > Signed-off-by: Ian Abbott Ian, For completeness, the comedi_alloc_spriv() helper should probably use __comedi_set_subdevice_runflags() to set the COMEDI_SRF_FREE_SPRIV bit. Regards, Hartley