From owner-freebsd-scsi@FreeBSD.ORG Thu Feb 23 13:15:36 2012 Return-Path: Delivered-To: freebsd-scsi@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7AEC2106566B; Thu, 23 Feb 2012 13:15:36 +0000 (UTC) (envelope-from Kashyap.Desai@lsi.com) Received: from na3sys009aog105.obsmtp.com (na3sys009aog105.obsmtp.com [74.125.149.75]) by mx1.freebsd.org (Postfix) with ESMTP id 768248FC13; Thu, 23 Feb 2012 13:15:35 +0000 (UTC) Received: from paledge01.lsi.com ([192.19.193.42]) (using TLSv1) by na3sys009aob105.postini.com ([74.125.148.12]) with SMTP ID DSNKT0Y79jrMvJtxitf75DYklripRivWpX58@postini.com; Thu, 23 Feb 2012 05:15:36 PST Received: from PALCAS01.lsi.com (128.94.213.117) by PALEDGE01.lsi.com (192.19.193.42) with Microsoft SMTP Server (TLS) id 8.3.213.0; Thu, 23 Feb 2012 08:20:19 -0500 Received: from inbexch01.lsi.com (135.36.98.37) by PALCAS01.lsi.com (128.94.213.117) with Microsoft SMTP Server (TLS) id 8.3.213.0; Thu, 23 Feb 2012 08:15:33 -0500 Received: from inbmail01.lsi.com ([135.36.98.64]) by inbexch01.lsi.com ([135.36.98.37]) with mapi; Thu, 23 Feb 2012 18:45:30 +0530 From: "Desai, Kashyap" To: Ed Schouten Date: Thu, 23 Feb 2012 18:45:29 +0530 Thread-Topic: mpslsi0 : Trying sleep, but thread marked as sleeping prohibited Thread-Index: AczyD/02FbCI9SrkQyKSb+ipNDdQzAAHNqbg Message-ID: References: <20120223094611.GC32748@hoeg.nl> In-Reply-To: <20120223094611.GC32748@hoeg.nl> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Cc: freebsd-stable , "joerg@FreeBSD.org" , "Kenneth D. Merry" , "freebsd-scsi@freebsd.org" , "Justin T. Gibbs" , "McConnell, Stephen" Subject: RE: mpslsi0 : Trying sleep, but thread marked as sleeping prohibited X-BeenThere: freebsd-scsi@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SCSI subsystem List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Feb 2012 13:15:36 -0000 > -----Original Message----- > From: Ed Schouten [mailto:ed@80386.nl] > Sent: Thursday, February 23, 2012 3:16 PM > To: Desai, Kashyap > Cc: freebsd-scsi@freebsd.org; freebsd-stable; joerg@FreeBSD.org; Kenneth > D. Merry; McConnell, Stephen; Justin T. Gibbs > Subject: Re: mpslsi0 : Trying sleep, but thread marked as sleeping > prohibited >=20 > Hi Kashyap, >=20 > * Desai, Kashyap , 20120222 18:51: > > Adding Ed Schouten and Jorg Wunsch as I see there are author of > > msleep/mtx related APIs. >=20 > Am I? :-) I am new to FreeBSD and desperate to know the answer. :-). Thanks for your = help. >=20 > > 1. When any irq is register with FreeBSD OS, it sets " TDP_NOSLEEPING" > > pflag. It means though irq in freebsd is treated as thread, We cannot > > sleep in IRQ because of " "TDP_NOSLEEPING " set. > > 2. In mps driver we have below code snippet in ISR routine. > > > > > > mps_dprint(sc, MPS_TRACE, "%s\n", __func__); > > mps_lock(sc); > > mps_intr_locked(data); > > mps_unlock(sc); > > > > I wonder why there is no issue with above code ? Theoretical we cannot > > sleep in ISR. (as explained in #1) Any thoughts ? >=20 > The TDP_NOSLEEPING flag only disallows sleeping of an indeterminate > amount of time. Locking a mutex is allowed, as it can only cause the > thread to be blocked for a small amount of time, waiting for another > thread to unlock it. So does this assumption that another thread will release mutex fast enough = ? Same as msleep() this can be applicable here as well. I mean another thread= _can_ (if some bad drivers) take long time to release mutex. >=20 > > 3. I recently added few place msleep() instead of DELAY in ISR context > > and I see " Trying sleep, but thread marked as sleeping prohibited". >=20 > Which makes sense, as msleep() can be used to sleep for indefinitely. This part is clear. ! I agree with all experts view.=20 >=20 > -- > Ed Schouten > WWW: http://80386.nl/