Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp827459ybp; Fri, 4 Oct 2019 05:41:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqyCnr0bDfrQP1guZx+vB3FrManem3095XT3LZ9cEM69adsrSt4h8K8fmE39myQghqeBbNXd X-Received: by 2002:a50:ed82:: with SMTP id h2mr15037437edr.206.1570192872568; Fri, 04 Oct 2019 05:41:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570192872; cv=none; d=google.com; s=arc-20160816; b=YKfgarahGcbzP9dNH5PjBFv6cE/dh8Kk/6JgvLlHJyH8AJFqLfoa39SQxUDWdJr3C7 OowclSoDc0ureIm6TDB4YfSzFm9vchSlbzwXavJLYLj7fInlJAA9SyMmH+XgFx2js4PL EmAdZ7pG7HDQETaOTOQP84azjs8bphe3Yn425MdUVJTdEQgdEabkpMxhlqPcYgHtSgbc 9qdZjzuroAYGylDYs8ktPKoy+uUegTPAJ5fmUO+PBh5Eu68r3ZvrQis/0Y45qKKI/etO E8bakcvj5TaZgMG/N39ispA4gr1qejXptxQYC6/WCZ6ltu97j7538IK3jnXa/ZWaJw3M CTHQ== 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=IE3xv/DITrvSSOYnJ8VrQmPdrRXZVy1EPvCVK4fcPKw=; b=k1dpGxO6mgJRDp0lfc/3EG/LrqYv5eNnMocXRZ5s4tEOlI1fde3MRyF0sCE9dprtQK xt74Tnsd/qQp4I7eNWSNFxeoZCO6Ljt9n3mqK4BlY3qCiYlpD2ULNgFPy3+ToQeWlNNc 8N+Ycw03/JYvp7q6hzfQkHKA0BLaS9ockCwAUYvliU8AtnIe4wDi7xTDq53YmEu25hx0 anuP/50SG55sKNuYker0nsPqMWs/tK9CoDJdRdC3WvZnl89DztZ2WA6tkab47Z6Bem9j l7kb4i6bDc4fMo2/GAjYHoAC72DPmgQc21/i8T4rpLjT+eKok1CLTx0MziVNrIlT4wMi D49g== 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 mh25si2921248ejb.81.2019.10.04.05.40.47; Fri, 04 Oct 2019 05:41:12 -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 S2387817AbfJDMjy (ORCPT + 99 others); Fri, 4 Oct 2019 08:39:54 -0400 Received: from mga14.intel.com ([192.55.52.115]:36112 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387440AbfJDMjx (ORCPT ); Fri, 4 Oct 2019 08:39:53 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Oct 2019 05:39:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,256,1566889200"; d="scan'208";a="343965861" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga004.jf.intel.com with ESMTP; 04 Oct 2019 05:39:48 -0700 Received: by black.fi.intel.com (Postfix, from userid 1001) id BD27E76; Fri, 4 Oct 2019 15:39:47 +0300 (EEST) From: Mika Westerberg To: Bjorn Helgaas , "Rafael J. Wysocki" Cc: Len Brown , Lukas Wunner , Keith Busch , Alex Williamson , Alexandru Gagniuc , Kai-Heng Feng , Matthias Andree , Paul Menzel , Nicholas Johnson , Mika Westerberg , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] PCI: Introduce pcie_wait_for_link_delay() Date: Fri, 4 Oct 2019 15:39:46 +0300 Message-Id: <20191004123947.11087-2-mika.westerberg@linux.intel.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191004123947.11087-1-mika.westerberg@linux.intel.com> References: <20191004123947.11087-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 e7982af9a5d8..bfd92e018925 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -4607,14 +4607,17 @@ static int pci_pm_reset(struct pci_dev *dev, int probe) return pci_dev_wait(dev, "PM D3->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; @@ -4651,13 +4654,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.23.0