Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp524958imm; Wed, 20 Jun 2018 02:14:34 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLAznrjxzkjo2f27O7XaARDFfJgdlRfhMOA1DA755G0R6Hn5OxDS9umKEhZE6nNzFmQAPCr X-Received: by 2002:a17:902:543:: with SMTP id 61-v6mr22841059plf.47.1529486074388; Wed, 20 Jun 2018 02:14:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529486074; cv=none; d=google.com; s=arc-20160816; b=mv22HxYiJeBozv0u0xEWazQqdGLVhFH1PI9IO/wRihokDZ0XkBCTPBIQL2WW4lIhKo r67OPL35i6RZeA5omw69zm+FOporO9j43cYut53rh8i7g4by1529fP3AJty23/2UBclW AKxXMb5MGQtF7VKVFEhl2fZpna8f+TTnmNQa6nDCu84ijOxH08xaGWffk75K+xY/tEsL GxVtzgni7xu3dED7qZUfieeMiQQRGW9B12sOSHfk6nt/lpMKZ/4shmBTdvrW4G0NQv1P 6w0Hj1GbhKunReHhm+0g50xOC6GMn8A1+f6eld2+WgGIm4ove4yUVcFjLx+tikGZeQlq BF/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=K5KPQABF2eaqI3klfL3qsAMyh4oi5ltOiQxEL5/tpFc=; b=c3rcNcDQFF3cAEZGefjW30uc61Z7X8ckkDApJS6/xHNk7NFne82vPD4x28qP3bBXfy krP2tjPNcMDKf+uEqUdGvyQlGcv9FyrLBvpt2NrIFg6pvY4Ph28SaW3635dfslZdWqyN 3uAvkxDv6XzYbchMCq0+7pNPPWlR7+okaXQ37Xy0SlHn3v4hnxe6Mu8tu7PaZbqy9pZ1 MvIbz06v1/0BN12FGdhs2vAMbGmDVgpSJYVmR56bgW1C6Jb3silchHKazFyMJub+DOKT A7L/yS0JVTTo/v4NN6s0o72TQI6GVnw1DdPYoAOzZz17INRMDaDKHHhGEggqw4V0GMmX pHCQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o10-v6si1625627pgp.153.2018.06.20.02.14.20; Wed, 20 Jun 2018 02:14:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754765AbeFTJM1 (ORCPT + 99 others); Wed, 20 Jun 2018 05:12:27 -0400 Received: from mga09.intel.com ([134.134.136.24]:1546 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754295AbeFTJMW (ORCPT ); Wed, 20 Jun 2018 05:12:22 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Jun 2018 02:12:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,246,1526367600"; d="scan'208";a="50437870" Received: from mattu-haswell.fi.intel.com (HELO [10.237.72.164]) ([10.237.72.164]) by orsmga007.jf.intel.com with ESMTP; 20 Jun 2018 02:12:20 -0700 Subject: Re: [BUG] usb: xhci: Two possible sleep-in-atomic-context bugs To: Peter Chen , Jia-Ju Bai , "mathias.nyman@intel.com" , "gregkh@linuxfoundation.org" Cc: "linux-usb@vger.kernel.org" , Linux Kernel Mailing List References: From: Mathias Nyman Message-ID: <8410b5bf-097c-2b53-84ff-221fb4ab03fa@linux.intel.com> Date: Wed, 20 Jun 2018 12:15:00 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 20.06.2018 06:28, Peter Chen wrote: > >> >> The driver may sleep with holding a spinlock. >> The function call paths (from bottom to top) in Linux-4.16.7 are: >> >> [FUNC] schedule >> drivers/base/power/runtime.c, 741: schedule in rpm_resume >> drivers/base/power/runtime.c, 1322: rpm_resume in pm_runtime_forbid >> drivers/usb/host/xhci-hub.c, 647: pm_runtime_forbid in xhci_enter_test_mode >> drivers/usb/host/xhci-hub.c, 632: _raw_spin_lock_irqsave in xhci_enter_test_mode >> >> [FUNC] schedule >> drivers/base/power/runtime.c, 570: schedule in rpm_suspend >> drivers/base/power/runtime.c, 434: rpm_suspend in rpm_idle >> drivers/base/power/runtime.c, 1343: rpm_idle in pm_runtime_allow >> drivers/usb/host/xhci-hub.c, 670: pm_runtime_allow in xhci_exit_test_mode >> drivers/usb/host/xhci-hub.c, 1387: xhci_exit_test_mode in xhci_hub_control >> drivers/usb/host/xhci-hub.c, 1038: _raw_spin_lock_irqsave in xhci_hub_control >> >> These bugs are found by my static analysis tool (DSAC-2) and checked by my code >> review. >> > > I don't think runtime PM API is needed at xhci_hub_control since the controller should > be always active, Mathias, do you agree I delete pm_runtime_forbid and pm_runtime_allow > to fix this issue? > The USB2 test mode is a bit special, it will disable all connected devices, and halt the host. Port should stay in test mode until feature is cleared or host reset. There is a risk runtime suspend will try to suspend the host as no devices seem preset. But I think pm_runtime_get_noresume() and pm_runtime_put_noidle() could be used instad, those should be safe. -Mathias