From patchwork Sat Feb 24 00:46:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Feng Kan X-Patchwork-Id: 10240071 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B47EE60390 for ; Sat, 24 Feb 2018 00:47:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A595229A75 for ; Sat, 24 Feb 2018 00:47:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9A1A129A7D; Sat, 24 Feb 2018 00:47:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B72629AA2 for ; Sat, 24 Feb 2018 00:47:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751943AbeBXArC (ORCPT ); Fri, 23 Feb 2018 19:47:02 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:43412 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751873AbeBXArB (ORCPT ); Fri, 23 Feb 2018 19:47:01 -0500 Received: by mail-pg0-f67.google.com with SMTP id f6so3976493pgs.10 for ; Fri, 23 Feb 2018 16:47:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=apm.com; s=apm; h=from:to:cc:subject:date:message-id; bh=ub/MkWy76lgZ8Ki4+XuvLmyZ6oSXujZU6Gtb8AY+MQw=; b=gAVlaOLvKI2C4J2ai312/uyEDYVBogF4qV0qykLmhbuHmJCri3HwzhrCYB2NOiltmj g3sk/P6HzhbLny+gTrgvMYJFj53z2YbRKCTXmj3EtMB2QauIF8dtLgJPRSV+p5gJJiPG rzuEB74PRXv2P6sUu2LAuaj2C5/a+t1mMGEag= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ub/MkWy76lgZ8Ki4+XuvLmyZ6oSXujZU6Gtb8AY+MQw=; b=TqxoUtVcfcekqiPP3LkbAaZq6+w1TMb9e/h5RlQWbKilgH2zB0EUojRSVXMXjKTNJ1 a7S1UaDRTJC48tmm98fD0l0NytNYOk/cWqhn1dGNodjzjdisYiskE8sibsjXLJetlLAy O9bANs1pntz3p/xg7AxW7fz5T3FZAXIuEetl+PndAgLad09OU+Iepb2AfOQVo8VcjfZZ suKXx+cqx39QccR01CchaIZ8hb05TMz7heId1uyoSxzXOGDmR9OBf03MeWWRMnAB8Vzh 26hZ9/z4r6hfemru+t5pdOkv3jE02Tc/eY8ghiaOA9NG7Pc/LbQE7r5XMC6ObCtJPnSo nBrg== X-Gm-Message-State: APf1xPAmB3UdnWJoW1UIDhfYDafJmjGC5BhoCBQ+0FCGM28J89OhbB3T rZpG33I3csSNgxba+YvFgGulOA== X-Google-Smtp-Source: AH8x224+n7Vnz7Dt5wtVk2he+flqOL+RyVS93doo2F0PF37n7eRW8wAxrUNNZz8wtg/VYATUp61f5g== X-Received: by 10.98.62.196 with SMTP id y65mr3412256pfj.24.1519433220840; Fri, 23 Feb 2018 16:47:00 -0800 (PST) Received: from goldengate.amcc.com ([206.80.4.98]) by smtp.gmail.com with ESMTPSA id x86sm7140066pfa.164.2018.02.23.16.46.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 23 Feb 2018 16:46:59 -0800 (PST) From: Feng Kan To: rjw@rjwysocki.net, linux-pm@vger.kernel.org, lorenzo.pieralisi@arm.com, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, bhelgaas@google.com Cc: Feng Kan Subject: [PATCH] PCIe bridge deferred probe breaks suspend resume Date: Fri, 23 Feb 2018 16:46:49 -0800 Message-Id: <1519433209-14581-1-git-send-email-fkan@apm.com> X-Mailer: git-send-email 2.7.4 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This is not a patch, but rather a question regarding the deferred probe's effect on PCIe PM ordering. This happens on our system which defer the probing of root bridge due to the IOMMU not being ready. Because of the deferred action, the bridge is moved to the end of the dpm_list which results in incorrect suspend and resume sequence. In the cases I have seen, the bridge is always reordered because of startup sequence. They are always place after the endpoint. If that is the case the following code should be able to prevent such cases. However, is there some cases here that would violate such situation? --- drivers/base/dd.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/base/dd.c b/drivers/base/dd.c index de6fd09..5b96d5c 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -116,15 +116,17 @@ static void deferred_probe_work_func(struct work_struct *work) */ mutex_unlock(&deferred_probe_mutex); - /* - * Force the device to the end of the dpm_list since - * the PM code assumes that the order we add things to - * the list is a good order for suspend but deferred - * probe makes that very unsafe. - */ - device_pm_lock(); - device_pm_move_last(dev); - device_pm_unlock(); + if (!dev_is_pci(dev)) { + /* + * Force the device to the end of the dpm_list since + * the PM code assumes that the order we add things to + * the list is a good order for suspend but deferred + * probe makes that very unsafe. + */ + device_pm_lock(); + device_pm_move_last(dev); + device_pm_unlock(); + } dev_dbg(dev, "Retrying from deferred list\n"); if (initcall_debug && !initcalls_done)