Received: by 2002:a05:7208:c250:b0:86:f851:443 with SMTP id w16csp941840rbd; Thu, 13 Jun 2024 01:55:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWjhO61LKlRxvkQPFxFhnkKcDsalRT6Ra3InaopufLeXg1TUbZ8wQWjPamz40P/xhW/h4AV4SGvixK3E98xZlUunKpOwAFsvLrlEwbChg== X-Google-Smtp-Source: AGHT+IFPInNKk/qT5feked/I9li4TUKT2QMrqocSI+QkihQLOk9Glf2tIaaBZeqQvdHCLx0VdTIr X-Received: by 2002:a50:8d42:0:b0:57c:71a4:3142 with SMTP id 4fb4d7f45d1cf-57ca976acdamr2891547a12.11.1718268931210; Thu, 13 Jun 2024 01:55:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718268931; cv=pass; d=google.com; s=arc-20160816; b=kfxUY13I0gQOEjAsd62MdKQHumPBo/iPXB8ON5sIpS9KS6Xq1gIdLf0n9zeiUKty33 YFnhAXv32AhTBXROcByaE6Y95khqY/vfqAa5SemlWOfgznwp+qZ34oy3PO0zr/kZkX62 htRRpwkkVY6BSO5r8yWpZBy6mgzoBmYU7QcQafLpYlPqREbucQowBFDX8jugx4GdMCfY nY4aED/ELoTkiSY4Qsy0/6IOExWAAfQPXwgxVOwZdxLBsemacd6r+Ewd5ccSQhZ32i3o uiUMy4B+ssRM4aTCyqBxI6JZ8QiEMPSvi+STKJVnDepI4MhDqilpNOEygfELelBeDbKh edVw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :from:references:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=Irx/gci0ZA3rOvQHA6GSCj2QdQ8Xc/neLqNKaC/68s0=; fh=mcQD7TBN1707e0tZW2ZtSAiTwZibGRo0r19DxJntYfw=; b=IudJDD/8KCg6c1UzJ2VHaiUlXeDskFg/odv1lnMfpQsf2aQqhwq4Cnrmz/fH2xmsoI KzXfQCujl96bmyZQ0vw9IzERvmw3UAN0RaBl7gGkI1VdoFW0RnjZzxU9U52MG6p5yy9f BT8mQekQBLwizQDB38d85BEmwow09EoXBNby6vDRyD8Oy2defUQAe//mfaHNOlVXFefv jUgbgE/iKTm/x5G2icPujmEzUE0Tnl2aJ5qR0aFpb5FLiK5R6Q6EOMB0BDCoP8PD49zD 60ZmyuoA5jp+ywGSaKnXkXBO2lEwNJ7Mnv6xlLbKTVE1WSS7y2/2qD5qnb/e75FduqEA qHLA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fmlbtIPO; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-212888-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-212888-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57cb742ccd0si492438a12.215.2024.06.13.01.55.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 01:55:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-212888-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fmlbtIPO; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-212888-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-212888-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id F18301F22213 for ; Thu, 13 Jun 2024 08:55:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4EA861419A9; Thu, 13 Jun 2024 08:52:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fmlbtIPO" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 66A1113C9A1; Thu, 13 Jun 2024 08:52:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718268767; cv=none; b=Q0MlWEJDKx9CFNh3wZdZTRi+t0QKOz7cRBX07YBvIxnmG225gTRU6hiZsT3ptO4BvrZTu56CBy3IdPgPxbhAd3dSGED2RQkRbBf1AVKJ3urvf9lbfN9PovSMud8ceyfcPkCP/RChAtutJgR9cU1mRhiqFlGZRxdDxRw8kQgasx8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718268767; c=relaxed/simple; bh=Irx/gci0ZA3rOvQHA6GSCj2QdQ8Xc/neLqNKaC/68s0=; h=Message-ID:Date:MIME-Version:Subject:To:References:From: In-Reply-To:Content-Type; b=bK2ghraySPjPnpQY6cgqxqw7ugFcY+FuNEMojl78QcQo+prwzf+/zhFZ1adm9ciWktnsOXeZL5wodYxNXEnDHzyUn/Y+m0PC/02rBMBWeiM7125KkpjaT8FpcHGzbWl3Mb5hrfJ1x4PvhUZiVlcl2LhGAsTsUn1CEcLu9Z6WTsY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fmlbtIPO; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9312CC2BBFC; Thu, 13 Jun 2024 08:52:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718268766; bh=Irx/gci0ZA3rOvQHA6GSCj2QdQ8Xc/neLqNKaC/68s0=; h=Date:Subject:To:References:From:In-Reply-To:From; b=fmlbtIPO+G1MlsJ7fVs6XPIRy/EDzweZhiVWTq4c/z5HtoDVyG3poQVD1KbFDgkcX kxnKHfHnMC5U5tTtF+/sxIv6hXBB2znmPqAskRGqLfGjFqEKtIVu3WJpQhpdurLdtQ X2qpe02hoiokT2ldHyzVo60/vwzLSiMVDbKcDI5Sawe+TuhSt4mAMbYTlJhvjoqfhf F8YxgIMmf23SUbFTbOWDvLvpBSpCStqWFoKLx3U1vuPp5fiVMSK36UMehhQR8iYsL5 m+vHwXWaFRCpgleQoB5OJwTkb2t8x7ENOUaU0Of2hASk+/Tjz7r9822LlIYUTAoC35 jFHQUF8BENOxQ== Message-ID: <69839983-5ec0-4207-a798-8cdac7444f20@kernel.org> Date: Thu, 13 Jun 2024 10:52:42 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] usb: dwc3: core: remove lock of otg mode during gadget suspend/resume to avoid deadlock To: Meng Li , Thinh.Nguyen@synopsys.com, gregkh@linuxfoundation.org, quic_uaggarwa@quicinc.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org References: <20240613072310.1927966-1-Meng.Li@windriver.com> From: Krzysztof Kozlowski Content-Language: en-US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I4Xjg+AX1hHFVKmvl3VBHIsBv0oDcsQWXqY+NaFahT0lRPjYtrTa1v3tem/ JoFzZ4B0p27K+qQCF2R96hVvuEyjzBmdq2esyE6zIqftdo4MOJho8uctOiWbwNNq2U9pPWmu 4vXVFBYIGmpyNPYzRm0QPwARAQABwsF8BBgBCgAmAhsMFiEEm9B+DgxR+NWWd7dUG5NDfTtB YpsFAmA872oFCRRflLYACgkQG5NDfTtBYpvScw/9GrqBrVLuJoJ52qBBKUBDo4E+5fU1bjt0 Gv0nh/hNJuecuRY6aemU6HOPNc2t8QHMSvwbSF+Vp9ZkOvrM36yUOufctoqON+wXrliEY0J4 ksR89ZILRRAold9Mh0YDqEJc1HmuxYLJ7lnbLYH1oui8bLbMBM8S2Uo9RKqV2GROLi44enVt vdrDvo+CxKj2K+d4cleCNiz5qbTxPUW/cgkwG0lJc4I4sso7l4XMDKn95c7JtNsuzqKvhEVS oic5by3fbUnuI0cemeizF4QdtX2uQxrP7RwHFBd+YUia7zCcz0//rv6FZmAxWZGy5arNl6Vm lQqNo7/Poh8WWfRS+xegBxc6hBXahpyUKphAKYkah+m+I0QToCfnGKnPqyYIMDEHCS/RfqA5 t8F+O56+oyLBAeWX7XcmyM6TGeVfb+OZVMJnZzK0s2VYAuI0Rl87FBFYgULdgqKV7R7WHzwD uZwJCLykjad45hsWcOGk3OcaAGQS6NDlfhM6O9aYNwGL6tGt/6BkRikNOs7VDEa4/HlbaSJo 7FgndGw1kWmkeL6oQh7wBvYll2buKod4qYntmNKEicoHGU+x91Gcan8mCoqhJkbqrL7+nXG2 5Q/GS5M9RFWS+nYyJh+c3OcfKqVcZQNANItt7+ULzdNJuhvTRRdC3g9hmCEuNSr+CLMdnRBY fv0= In-Reply-To: <20240613072310.1927966-1-Meng.Li@windriver.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 13/06/2024 09:23, Meng Li wrote: > When config CONFIG_USB_DWC3_DUAL_ROLE is selected, and trigger system > to enter suspend status with below command: > echo mem > /sys/power/state > There will be a deadlock issue occurring. Because dwc3_gadget_suspend() also > try to get the lock again when previous invoked dwc3_suspend_common() has > got the lock . This issue is introduced by commit c7ebd8149ee5 ("usb: dwc3: > gadget: Fix NULL pointer dereference in dwc3_gadget_suspend") that removes > the code of checking whether dwc->gadget_driver is NULL or not. It causes the > following code is executed and deadlock occurs when trying to get the spinlock. > To fix the deadlock issue, refer to commit 5265397f9442("usb: dwc3: Remove > DWC3 locking during gadget suspend/resume"), remove lock of otg mode during > gadget suspend/resume. That's a funny way of fixing deadlocks: remove the lock. Of course it could be correct way with some justification why locking is not needed. No such justification here, so following your logic, let's remove locking everywhere and then no deadlocks possible! Let me prepare patches for that... Best regards, Krzysztof