Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2269497pxb; Sun, 24 Jan 2021 01:04:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJwoHPQbZi3JrXhoRvViBEXP327Yyr0hVLfwMZ77N1njSxlm5jjM/S9WGiXwWf6C5CqeKebY X-Received: by 2002:a50:852a:: with SMTP id 39mr2459192edr.114.1611479051818; Sun, 24 Jan 2021 01:04:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611479051; cv=none; d=google.com; s=arc-20160816; b=DRHB99MyemPExCVBDZK/qfQ7HB6r8gxzvYBwcv/fN8ZgXAGYWOSTngKaQm/O7+bdIJ RyRSMTyPKLRCYslnPNI4In+fGKdzWdwylvC06wdOuuTgZ4XtmFPfHHSaJylddRT0Qisw 0hRDO1lAOdKUQDjLWBDDkMQx9qFA/Xo3jYcu8u3/iitBBcJS1Mev+In0Iwb5O0+6/MqT JL9JJ3/Eb0K6o1aZQFAaWpFJLVmNVQJJn6orFZ3U4Fpy/u+xZa/7w2z7zrm+4yqzBMDa t2/MngREgxXPlXvxexztHPD5U/NYiZ3P85copjoeHpBxyc1QxN0H3h/HzI3JG03JX5vR yUFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:cc:to:subject:from:date; bh=MYG1+2fc0eIn4Sepn33mDp5AqW8APYTB5ZBMOhmbJcU=; b=t3LBynI5XMhpdBwoRmeC9efTxnGbWowfraaK14wkhHbDHi6MzgMPFcH9CQ1toyZCRQ 1+8eMTZDX1+CYKIOV9A7fkqeSq6sGC2DvRFYXmQXlrHcjQ71Vk8dqCuFMy9HlVPcsn4O J4jxabgxvOZivZyK0HpG99lOeSFTwUSyWao64UomJ7o4CWDCSB66eWCgzi2PzGo8wgXw Ymqb+N8YIuo6tuPPd+Q2003/Eu2P8Phy8s3TUR8TTP7GRom+9OoblGLu2G5ObC8v7ROv 53oR68GcOvzt3KVUh9RItXy5NI+mN39DG4BvQGMkV23vi1WeFtEuhjiUGthKih9eiGLZ P54Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i13si5780620edl.347.2021.01.24.01.03.48; Sun, 24 Jan 2021 01:04:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726714AbhAXJBN convert rfc822-to-8bit (ORCPT + 99 others); Sun, 24 Jan 2021 04:01:13 -0500 Received: from aposti.net ([89.234.176.197]:43768 "EHLO aposti.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726623AbhAXJBH (ORCPT ); Sun, 24 Jan 2021 04:01:07 -0500 Date: Sun, 24 Jan 2021 08:38:13 +0000 From: Paul Cercueil Subject: Re: [RE-RESEND PATCH 1/4] usb: musb: Fix runtime PM race =?UTF-8?Q?in=0D=0A?= musb_queue_resume_work To: Sergei Shtylyov Cc: Bin Liu , Greg Kroah-Hartman , Tony Lindgren , od@zcrc.me, linux-mips@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Message-Id: In-Reply-To: <72e48343-f87e-5fed-809c-41995197019e@gmail.com> References: <20210123142502.16980-1-paul@crapouillou.net> <72e48343-f87e-5fed-809c-41995197019e@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Sergei, Le sam. 23 janv. 2021 ? 19:41, Sergei Shtylyov a ?crit : > On 1/23/21 5:24 PM, Paul Cercueil wrote: > >> musb_queue_resume_work() would call the provided callback if the >> runtime >> PM status was 'active'. Otherwise, it would enqueue the request if >> the >> hardware was still suspended (musb->is_runtime_suspended is true). >> >> This causes a race with the runtime PM handlers, as it is possible >> to be >> in the case where the runtime PM status is not yet 'active', but the >> hardware has been awaken (PM resume function has been called). > > Awakened. :-) Oops. Hopefully Bin or Greg can fix it when merging (if I don't need to v2, that is to say - feedback welcome). Cheers, -Paul >> When hitting the race, the resume work was not enqueued, which >> probably >> triggered other bugs further down the stack. For instance, a telnet >> connection on Ingenic SoCs would result in a 50/50 chance of a >> segmentation fault somewhere in the musb code. >> >> Rework the code so that either we call the callback directly if >> (musb->is_runtime_suspended == 0), or enqueue the query otherwise. >> >> Fixes: ea2f35c01d5e ("usb: musb: Fix sleeping function called from >> invalid context for hdrc glue") >> Cc: stable@vger.kernel.org # v4.9+ >> Signed-off-by: Paul Cercueil >> Reviewed-by: Tony Lindgren >> Tested-by: Tony Lindgren > [...] > > > MBR, Sergei