Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp899209ybx; Thu, 7 Nov 2019 04:22:03 -0800 (PST) X-Google-Smtp-Source: APXvYqwdqP6fxOp6JCaZXdzAeRb32qJPZkJwFuMb5BgeV+60dBU9ediP87jGfQ9xyyZ0GRI5Hgcq X-Received: by 2002:a17:906:1be9:: with SMTP id t9mr2723322ejg.10.1573129323789; Thu, 07 Nov 2019 04:22:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573129323; cv=none; d=google.com; s=arc-20160816; b=kT9qItBaMm7UcGePl/JWGdQRb9AG9HiRRNWjzp/gUX5xsC5ZgG3dBT+5Tm+XFjFzwL Wn9SFqHT9R10ij3vp7g1o3J3lzgneykZjh9ORgd7A8KgxEjkL+gdOtl02bBLxS9KSqtc cdG7+vtkmySKFCP7Q2vwNlzGJOEKt9U92D4Jdq/xfHjNa/u8y4xqjTwacoIM1lQVJTsk EAufnp7XwoJgyaGbu7Sk9edumk+yUS46uTpttM51DC4QMnV17XBqMBCb5mZxdugx8nm2 3TrYFPDDNdxVkPuH9xOmTG/PFaii4IGyYvaCGK5geMPbMAWgflzMQTVGp5QeYYpZ/vQU KM3w== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=oEGpvg2SmoSsWceh1Jv/ebOBWvNWldXLVMemOpEMECY=; b=vLhlXTiJOZYjkFT6wpduk0RRlgQSYzibC2lTalUoOty7sjJgsPgDjuVFw17Bt0CLnJ IvpZbjO4O/7mIfdbWBHpEYRxWr85NkO0sANWfuRmmOsynD2pq88J4RuNmxgDO7KLxTME LVoqTY8JIUBtTqu26nHB6NLJaf2KLzUX5k59tvPOSQawVdU4Sj7UFS+20Q7L6mS7oU3U Nj80VUJmlREwtvien9DzmICNCD3SmVFxDRANLr5Mluqxt7xqLFSgIVLwyYQp98A6ev9H VMVpm0qSGc010qgSzSFqWKgc1QWBjJS5GMt/wLNlpvKY8U9D9aYbZwzOte+4MbAL06HU 2ILQ== 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 f3si1361413eda.251.2019.11.07.04.21.39; Thu, 07 Nov 2019 04:22:03 -0800 (PST) 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 S2388524AbfKGMTB (ORCPT + 99 others); Thu, 7 Nov 2019 07:19:01 -0500 Received: from mga18.intel.com ([134.134.136.126]:18274 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388319AbfKGMSy (ORCPT ); Thu, 7 Nov 2019 07:18:54 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Nov 2019 04:18:53 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,278,1569308400"; d="scan'208";a="201023124" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga008.fm.intel.com with ESMTP; 07 Nov 2019 04:18:49 -0800 Received: by black.fi.intel.com (Postfix, from userid 1001) id 273A7FC; Thu, 7 Nov 2019 14:18:48 +0200 (EET) From: Mika Westerberg To: Bjorn Helgaas , "Rafael J. Wysocki" Cc: Len Brown , Lukas Wunner , Keith Busch , Alex Williamson , Alexandru Gagniuc , Kai-Heng Feng , Paul Menzel , Nicholas Johnson , Mika Westerberg , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 1/2] PCI: Introduce pcie_wait_for_link_delay() Date: Thu, 7 Nov 2019 15:18:46 +0300 Message-Id: <20191107121847.24781-2-mika.westerberg@linux.intel.com> X-Mailer: git-send-email 2.24.0.rc1 In-Reply-To: <20191107121847.24781-1-mika.westerberg@linux.intel.com> References: <20191107121847.24781-1-mika.westerberg@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is otherwise similar to pcie_wait_for_link() but allows passing custom activation delay in milliseconds. Signed-off-by: Mika Westerberg --- drivers/pci/pci.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index ecc775793c3c..7083adc07f5c 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -4588,14 +4588,17 @@ static int pci_pm_reset(struct pci_dev *dev, int probe) return pci_dev_wait(dev, "PM D3hot->D0", PCIE_RESET_READY_POLL_MS); } + /** - * pcie_wait_for_link - Wait until link is active or inactive + * pcie_wait_for_link_delay - Wait until link is active or inactive * @pdev: Bridge device * @active: waiting for active or inactive? + * @delay: Delay to wait after link has become active (in ms) * * Use this to wait till link becomes active or inactive. */ -bool pcie_wait_for_link(struct pci_dev *pdev, bool active) +static bool pcie_wait_for_link_delay(struct pci_dev *pdev, bool active, + int delay) { int timeout = 1000; bool ret; @@ -4632,13 +4635,25 @@ bool pcie_wait_for_link(struct pci_dev *pdev, bool active) timeout -= 10; } if (active && ret) - msleep(100); + msleep(delay); else if (ret != active) pci_info(pdev, "Data Link Layer Link Active not %s in 1000 msec\n", active ? "set" : "cleared"); return ret == active; } +/** + * pcie_wait_for_link - Wait until link is active or inactive + * @pdev: Bridge device + * @active: waiting for active or inactive? + * + * Use this to wait till link becomes active or inactive. + */ +bool pcie_wait_for_link(struct pci_dev *pdev, bool active) +{ + return pcie_wait_for_link_delay(pdev, active, 100); +} + void pci_reset_secondary_bus(struct pci_dev *dev) { u16 ctrl; -- 2.24.0.rc1