From owner-freebsd-drivers@FreeBSD.ORG Thu Dec 11 19:58:41 2014 Return-Path: Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 32F20D82 for ; Thu, 11 Dec 2014 19:58:41 +0000 (UTC) Received: from mail-pd0-x231.google.com (mail-pd0-x231.google.com [IPv6:2607:f8b0:400e:c02::231]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id F1A0B998 for ; Thu, 11 Dec 2014 19:58:40 +0000 (UTC) Received: by mail-pd0-f177.google.com with SMTP id ft15so5529879pdb.8 for ; Thu, 11 Dec 2014 11:58:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=lj0WQFcvgt3yICYFfLw5VDQLVW9VBkSfmcASVdUUEBM=; b=Cam15oGAJ+qAcLkvgaUdkZ/zna7aglFh0tSbG8vy0jG+q3im/VCsA7z7dJyq4AbRHo zUx9CBm26wiTialDr1OCT15W5Z36KvI/mcGwsZvBgXYTR4M7pTNDrOWOLfDZJYQrHbBh eBa3KfAZ+26xpUK5zLvp/Ljc5NDpXX0wXK3QhK5vE2gOIHSkskUfDAcw5Pm4F7PO32VE ZePtDVRnC/xAmSNMyUr+wWyoagxGgV8ikBpHlzeBcjE9phi1vItZBXqKZrgn0kETiqn9 3fYfieyFwFb8Vb5XJoHj5UfND3Niob81cPH8fWm1S5r9KsdMenzImg18KZmPsm0hb1uY DXLQ== X-Received: by 10.68.204.8 with SMTP id ku8mr19975230pbc.103.1418327920486; Thu, 11 Dec 2014 11:58:40 -0800 (PST) Received: from ox ([24.6.44.228]) by mx.google.com with ESMTPSA id bu4sm2062457pdb.80.2014.12.11.11.58.38 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 11 Dec 2014 11:58:39 -0800 (PST) Date: Thu, 11 Dec 2014 11:58:21 -0800 From: Navdeep Parhar To: Martin Galvan Subject: Re: Locking a MTX_DEF inside an interrupt thread Message-ID: <20141211195821.GA3827@ox> Mail-Followup-To: Martin Galvan , freebsd-drivers@freebsd.org References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Cc: freebsd-drivers@freebsd.org X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Dec 2014 19:58:41 -0000 MTX_DEF mutexes can block but never sleep, and it is perfectly safe to acquire them in an ithread. On Thu, Dec 11, 2014 at 03:38:06AM -0300, Martin Galvan wrote: > Hi everyone! I was reading the man page on bus_setup_intr() and > noticed it warned against sleeping inside an ithread routine. However, > I saw a few drivers that start their ithread routines by locking a > MTX_DEF mutex, which I understand will make a thread sleep if the > mutex is already being held by another thread. Based on that, I'd like > to ask you guys a few questions: > > 1) Why can't we sleep inside an ithread? Isn't being able to > context-switch (and thus avoiding using spinlocks) the whole point of > using a separate thread for an interrupt handler? > 2) What would be the 'correct' way to write an ithread routine which > uses shared resources (such as a softc)? > 3) Should we fix the drivers that use MTX_DEF mutexes inside their ithreads? > > Thanks a lot! > _______________________________________________ > freebsd-drivers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-drivers > To unsubscribe, send any mail to "freebsd-drivers-unsubscribe@freebsd.org"