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: 10240069 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 18DDA60390 for ; Sat, 24 Feb 2018 00:47:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0353F29A75 for ; Sat, 24 Feb 2018 00:47:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EC38429AA4; Sat, 24 Feb 2018 00:47:03 +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=ham 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 7A0AA29A75 for ; Sat, 24 Feb 2018 00:47:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751917AbeBXArC (ORCPT ); Fri, 23 Feb 2018 19:47:02 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:35426 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751674AbeBXArB (ORCPT ); Fri, 23 Feb 2018 19:47:01 -0500 Received: by mail-pg0-f67.google.com with SMTP id l131so3983859pga.2 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=YZA0+4PRlZMcCL4KkgcCDqH9g9G7kQFEwqE4qi74HMAIw4gVOahRL0ie27gfcj2fiB JLe/RBavC8ajG1cUDqmGmIPl+r/qo/67oQIO+2AOK7BQn00niBqJTjbhTs2TXRbb/1cE iJwW3iAPWflzad3xmGcd+NSiqTODbhtuSN5qdOfdYxVQ+lzyZ7NMI6oVZYwKUJJRgd6O NldGs74s3gwwBM7M9oRoNMbAJGk1DrTa9xf1S5dlDtG8wAsZLKZDJst41SZ89jHMY/34 IZuemonWKV2gEf6xp5iAVt5C8N+T5VjHAEpHeqkMKG8yG2mVRgcXElTuE4aa001o/FDd Mzdw== X-Gm-Message-State: APf1xPB/Mja7dzVzmw+w8bh6tVtC2+302LRKqSXlNgZH+OQfTF8CYolZ ynkMMB/UCYvTinyY2bqLbUwGIA== 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-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@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)