From: Alan Cox Subject: Re: Locking question for DRM Date: Fri, 23 Apr 2010 12:00:54 +0100 Message-ID: <20100423120054.0987f3e4@lxorguk.ukuu.org.uk> References: <20100423112222.67cfcbb2@lxorguk.ukuu.org.uk> <20100423113717.1188415d@lxorguk.ukuu.org.uk> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from www.etchedpixels.co.uk (earthlight.etchedpixels.co.uk [81.2.110.250]) by gabe.freedesktop.org (Postfix) with ESMTP id 5ABBF9E84C for ; Fri, 23 Apr 2010 03:55:51 -0700 (PDT) In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org To: Dave Airlie Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org > > I don't think that works. drm_open_helper doesn't appear to be under the > > BKL merely the struct mutex. > > It blocks the case you specified of two releases happening together. But not parallel open/release > > But setmaster can sleep so the BKL is dropped on contention of the > > struct_mutex, ditto dropmaster > > they should only sleep in the mutex lock nuless the driver callback is > allocating memory. but yeah its a bit of a mess. With the mutex alone the damage is done. Consider two setmasters and some other action which is making the mutex contend CPU1 CPU2 file->priv->minor->master == NULL ? file_priv->minor->master != file_priv->master mutex_lock (drop BKL) file->priv->minor->master === NULL master != file_priv->master mutex_lock [drop BKL] takes mutex minor->master = drm_master_get is_master = 1 master_set drop mutex return 0 takes mutex minor->master = drm_master_get is_master = 1 master_set drops mutex return 0 Alan