From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com ([192.55.52.115]:13038 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750885AbcEZG3m (ORCPT ); Thu, 26 May 2016 02:29:42 -0400 From: Felipe Balbi To: Bin Liu , linux-usb@vger.kernel.org Cc: stable@vger.kernel.org Subject: Re: [PATCH v2] usb: gadget: fix spinlock dead lock in gadgetfs In-Reply-To: <20160525192458.GA12150@uda0271908> References: <1464203914-17339-1-git-send-email-b-liu@ti.com> <20160525192458.GA12150@uda0271908> Date: Thu, 26 May 2016 09:27:26 +0300 Message-ID: <87bn3tqqpd.fsf@linux.intel.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Sender: stable-owner@vger.kernel.org List-ID: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hi, Bin Liu writes: > On Wed, May 25, 2016 at 02:18:34PM -0500, Bin Liu wrote: >> [ 40.467381] =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D >> [ 40.473013] [ INFO: possible recursive locking detected ] >> [ 40.478651] 4.6.0-08691-g7f3db9a #37 Not tainted >> [ 40.483466] --------------------------------------------- >> [ 40.489098] usb/733 is trying to acquire lock: >> [ 40.493734] (&(&dev->lock)->rlock){-.....}, at: [] ep0_com= plete+0x18/0xdc [gadgetfs] >> [ 40.502882] >> [ 40.502882] but task is already holding lock: >> [ 40.508967] (&(&dev->lock)->rlock){-.....}, at: [] ep0_rea= d+0x20/0x5e0 [gadgetfs] >> [ 40.517811] >> [ 40.517811] other info that might help us debug this: >> [ 40.524623] Possible unsafe locking scenario: >> [ 40.524623] >> [ 40.530798] CPU0 >> [ 40.533346] ---- >> [ 40.535894] lock(&(&dev->lock)->rlock); >> [ 40.540088] lock(&(&dev->lock)->rlock); >> [ 40.544284] >> [ 40.544284] *** DEADLOCK *** >> [ 40.544284] >> [ 40.550461] May be due to missing lock nesting notation >> [ 40.550461] >> [ 40.557544] 2 locks held by usb/733: >> [ 40.561271] #0: (&f->f_pos_lock){+.+.+.}, at: [] __fdget_= pos+0x40/0x48 >> [ 40.569219] #1: (&(&dev->lock)->rlock){-.....}, at: [] ep= 0_read+0x20/0x5e0 [gadgetfs] >> [ 40.578523] >> [ 40.578523] stack backtrace: >> [ 40.583075] CPU: 0 PID: 733 Comm: usb Not tainted 4.6.0-08691-g7f3db9= a #37 >> [ 40.590246] Hardware name: Generic AM33XX (Flattened Device Tree) >> [ 40.596625] [] (unwind_backtrace) from [] (show_s= tack+0x10/0x14) >> [ 40.604718] [] (show_stack) from [] (dump_stack+0= xb0/0xe4) >> [ 40.612267] [] (dump_stack) from [] (__lock_acqui= re+0xf68/0x1994) >> [ 40.620440] [] (__lock_acquire) from [] (lock_acq= uire+0xd8/0x238) >> [ 40.628621] [] (lock_acquire) from [] (_raw_spin_= lock_irqsave+0x38/0x4c) >> [ 40.637440] [] (_raw_spin_lock_irqsave) from [] (= ep0_complete+0x18/0xdc [gadgetfs]) >> [ 40.647339] [] (ep0_complete [gadgetfs]) from [] = (musb_g_giveback+0x118/0x1b0 [musb_hdrc]) >> [ 40.657842] [] (musb_g_giveback [musb_hdrc]) from [] (musb_g_ep0_queue+0x16c/0x188 [musb_hdrc]) >> [ 40.668772] [] (musb_g_ep0_queue [musb_hdrc]) from [] (ep0_read+0x544/0x5e0 [gadgetfs]) >> [ 40.678963] [] (ep0_read [gadgetfs]) from [] (__v= fs_read+0x20/0x110) >> [ 40.687414] [] (__vfs_read) from [] (vfs_read+0x8= 8/0x114) >> [ 40.694864] [] (vfs_read) from [] (SyS_read+0x44/= 0x9c) >> [ 40.702051] [] (SyS_read) from [] (ret_fast_sysca= ll+0x0/0x1c) >>=20 >> Cc: # v3.16+ >> Signed-off-by: Bin Liu >> --- >> v2: >> - lock protects setup_req(), only unlock for usb_ep_queue() >> - use GFP_KERNEL in usb_ep_queue() >> - fix the same in two places in gadgetfs_setup() too > > Never mind. Sent the patch too soon. It gives the following problem. > > [ 179.810367] WARNING: CPU: 0 PID: 0 at kernel/locking/lockdep.c:2724 > _raw_spin_unlock_irq+0x24/0x2c > [ 179.819719] DEBUG_LOCKS_WARN_ON(current->hardirq_context) thanks for letting us know. I'm dropping this from my queue. Please resend final patch once you have it ;-) =2D-=20 balbi --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJXRpdOAAoJEIaOsuA1yqRE/D8P/R+ey/IfcPJdDjT5bfywokqO 75tJJ3/kg+nNYqc6bOGQoX6e73WnyQeqfADLsIIC/k5sms+UNME8SzVoJNQL4OpI WCI6Bm2rKhYx7XmnIG8F7jSW4MdQMudhpM1qHj9ng7x/RfqsaqMMl4gD4wmkhh/+ NIXWAuiIkc2ZfVtExQaNshOfHkYFp8ZmZRvIBYAYIQALi6kClmrlXJr0ajV2yOvy 4VUMEeookoIY7DD6NxprCeF06b4LsAoZT1tXD91xaXcqtn4iJ8NkIWwouMqeoJrb bZ/wUEDXKhX3sCXqRPnrU9rfOS1tjkev2QkZlQ9Xv2A8cZYUWtGM4y//KroWn0fP UnzDr2IWRefXp4hWePt7tIA6j3ZbtpAlAzRVrf0gGPQQWxsk5VEJM2Y0+vc7lGOB WEGW2YGY7+EQuIfnbcpFsltAMGIXRXD8Kq917oRneJ0h/dKpSrhj9eSgdvQeSbgU B+sMZF9LDsgQmz4bjxsFp42E9GkGYVtrqp4Lb6J6VK6LSfFfk3LxNIKToMiDGHEq yUvF+QbYAidkGSQi+XR911A+DQmgFF5dkgR6ThJ0DJ1Of2Cva/aDHCznnhYLr+3S yJEuvOdkbv6TrhIG0TsYvbRFwzE7D2uk4lXSUVbKKmGL2WDDJk2CRdakKVS+rGfp ghbad4kKDgIe/cZYNFBp =Y9pR -----END PGP SIGNATURE----- --=-=-=--