X-GM-THRID: 6202253257836855296 X-Received: by 10.112.209.73 with SMTP id mk9mr1059649lbc.14.1444289861675; Thu, 08 Oct 2015 00:37:41 -0700 (PDT) X-BeenThere: outreachy-kernel@googlegroups.com Received: by 10.25.152.83 with SMTP id a80ls135393lfe.96.gmail; Thu, 08 Oct 2015 00:37:41 -0700 (PDT) X-Received: by 10.112.26.212 with SMTP id n20mr1084852lbg.2.1444289861172; Thu, 08 Oct 2015 00:37:41 -0700 (PDT) Return-Path: Received: from mout.kundenserver.de (mout.kundenserver.de. [212.227.126.131]) by gmr-mx.google.com with ESMTPS id bj4si271387wib.1.2015.10.08.00.37.41 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Oct 2015 00:37:41 -0700 (PDT) Received-SPF: neutral (google.com: 212.227.126.131 is neither permitted nor denied by best guess record for domain of arnd@arndb.de) client-ip=212.227.126.131; Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 212.227.126.131 is neither permitted nor denied by best guess record for domain of arnd@arndb.de) smtp.mailfrom=arnd@arndb.de Received: from wuerfel.localnet ([149.172.15.242]) by mrelayeu.kundenserver.de (mreue004) with ESMTPSA (Nemesis) id 0MHtgv-1ZlS9J3EWj-003eGU; Thu, 08 Oct 2015 09:37:40 +0200 From: Arnd Bergmann To: Amitoj Kaur Chawla Cc: outreachy-kernel@googlegroups.com, Julia Lawall Subject: Re: [Outreachy kernel] [PATCH] staging: rtl8712: usleep_range is preferred over udelay Date: Thu, 08 Oct 2015 09:37:40 +0200 Message-ID: <5882355.uMFG4U3DtR@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) In-Reply-To: References: <20151005195012.GA21881@amitoj-Inspiron-3542> <6335208.lbv5QB1mEN@wuerfel> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:Y0bU2rO0Lh4HlT0mufugr3nK5WHH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d Bergmann wrote: > > It really depends on what the driver is trying to do. In this case, it > > waits for a device register to signal 'done', and it tries this five times > > for a maximum of 50 microseconds, which is a relatively short period. > > > > Changing the maximum to 1000 means that it can now sleep for up to > > 5 milliseconds instead, which is a noticeable time, especially if > > it gets called frequently. > > > > The questions to answer here are: > > > > * Is it safe to call a sleeping function from this point at all? > > Look for other sleeping functions (proves that it is allowed to > > sleep) and for spinlocks (if a lock is held, you may not sleep) > > in this function. > > > > There aren't any other sleeping functions in this function. However, > udelay() has been used one more time in a loop. udelay() is not a sleeping function, so that doesn't count here. Try to look further out if you can't find a sleeping function or a spinlock here, scanning the callers of this function and everything they call for common sleeping functions like kmalloc(..., GFP_KERNEL), mutex_lock() or msleep(). > > * How often do you expect the function to get called? Once per data > > packet means it's not ok to sleep long, once an hour would mean it's > > clearly ok. > > > > * Are there other calls in this function that take longer than a > > millisecond? > > How can I find out these 2 things? Only udelay() is the sleeping function. Try understanding what the functions actually do by looking at the call chain for the first one, it should be fairly easy in this case. For the second one, look for functions that get called from this one, if any of them contains a mdelay() or msleep(), or a loop around udelay(), try guessing how long that can take. Arnd