From nobody Thu Apr 2 22:27:32 2026 Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E8652387590 for ; Thu, 26 Feb 2026 06:43:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772088223; cv=none; b=iq5nJgG8jrtssjW/EogZZ5jCPICVcGybEjggquiSPJhruXbARjf2grXlIiBzUgke9jei+kXFvat5F2Ze4d0KyzvnOp6dqX4bBWDP2mA3otjDDVu7lypd+Htd0ZA5tgeHv1UBbopZ5W2DNmtOZLkpqLuNFy6LudsvFGpWOMF4QnY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772088223; c=relaxed/simple; bh=FufQji+7Ewrr7vcq8PkZtbwA3C6p0/81Ayvn998N2Fc=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=JN6HzXUi5WF2fGL//HfUGf9yVM00XqpzcFwQvSgZQGjrqbIZNrIgMw7ZhY0+fcxZfmRJyDgTLfNe/ao9VV0Y10PO9wBceegn4wgpQ1Rd8tiqI7/WGtqlewypHS2lbyRfNdUQYPkTJ2SJkfuugyV3PdRlHwOfr3KwqBtLqs+Ocus= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.216.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-f48.google.com with SMTP id 98e67ed59e1d1-358e16d7da4so267364a91.3 for ; Wed, 25 Feb 2026 22:43:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772088221; x=1772693021; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=b+gS9rzm17IOsOjXDE1pbAIlvnilZzxzhAM4Cjn+O+I=; b=mMuIy6bUvxX5Ln/J8drRFX5QRocwziWyGM+SUiJGzcdVRNiIE54o6yqGG2ACgI7n00 +jBDd9ZngiCLBhGWCQBIaANGx1wg0YgEhy7VkiXkQXLMabHzt3Z0eU0K/KiteFu4ANBB BRbHhqap26ONq0I1v3RN1pcn14MsTT2UjtT+2d5yyqZOSrx1AlHfZ8O90KlYjudsMMRT 8zEPJJAeEH/TQF9ReOJlPtqiXldkUkeW1ZgYo3KIEZgS5PGU2zFE2W04dctesD0YQYU2 RklO0UCKHq1OEpZoeqZ5B0pQKqOwgdW3W70aC9Lvh9mUu+pToPnvg7to4WmKEOkrM48Y bnAA== X-Forwarded-Encrypted: i=1; AJvYcCWChXp/WKFWWA5TikO3G1T7WMms92PN58MPw7LdonS/9v/6nr9MchIISK8SnlLfpfCEFy0r5wjiQXWOLbs=@vger.kernel.org X-Gm-Message-State: AOJu0Yyi5IJOCMRfDUBn9geVnvq/kgWETBDZcjyzqWjVveS22ZZPJcWP ZBbkFln6CkipW4H1E0CyB6/O7iixCfhO4fmmDZ/JckXw7JNL6PfSqctqiXWjAA== X-Gm-Gg: ATEYQzyvgTYcUMq8u4HArBgz/k1pc22OPPwpSexlUxG+iONAqDZGFk7npzyh3zwbxqh qwwHGRifGiOSbOiIiZU5dlw8JNqIkdCAw0Zv3zNyNT1rdKeStwViFQZiEWewJHSBikp7i4IkD2Q qw2tyyZhko66pq0F7hNAwVeGUyftjgGm40amFiTkRePf4C9o9jDF1zE7nplVdn2KsCGA7CoUtwQ p7CaCzyVKVxj6K5QLl3ymgxf+9F35RpDN4lKz6Nxo3jT1YeEZOVC/IyWECB2I/GHgtdmnjm7cE5 q0cm39ymaArDjTltAcgXSAGiv0bT0kmHMvYYgFFc7r2Wjyax76/w1gWGBrmrwmOMhyKMkw31B36 o9ku7Dz/FMSLQigl/htx5H96P+VwfW/oxnHL1NceAeDDPr13qVbgah+C+AlLuD9WptK/t1XCPnO F8DGJdb5KBFxIg2nAyIwGdI2ma7rPrQHV8sHfABijuVJxgvD7eYw== X-Received: by 2002:a17:90b:1dc8:b0:354:a608:30a2 with SMTP id 98e67ed59e1d1-358aea0818bmr15837823a91.35.1772088221270; Wed, 25 Feb 2026 22:43:41 -0800 (PST) Received: from localhost.localdomain ([116.128.244.169]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3593dcad6ddsm1040973a91.1.2026.02.25.22.43.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Feb 2026 22:43:40 -0800 (PST) From: Hongyu Xie To: bhelgaas@google.com Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, ilpo.jarvinen@linux.intel.com, Hongyu Xie Subject: [PATCH v2] PCI: replace msleep to save waiting time Date: Thu, 26 Feb 2026 14:43:33 +0800 Message-Id: <20260226064333.538857-1-xiehongyu1@kylinos.cn> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" On a arm64 platform, there is a 10~11ms gap during PCI bus scan(last two line below, between 0000:01:00.0 and 0000:02:00.0): [ 0.078871] pci_bus 0000:00: root bus resource [mem 0x58000000-0x7ffffff= f window] [ 0.078873] pci_bus 0000:00: root bus resource [mem 0x1000000000-0x1ffff= fffff window] [ 0.078875] pci_bus 0000:00: root bus resource [io 0x0000-0xffff window] [ 0.078877] pci_bus 0000:00: root bus resource [bus 00-ff] [ 0.078888] pci 0000:00:00.0: [1db7:dc01] type 01 class 0x060400 [ 0.078895] pci 0000:00:00.0: reg 0x38: [mem 0xfff00000-0xffffffff pref] [ 0.078914] pci 0000:00:00.0: supports D1 [ 0.078916] pci 0000:00:00.0: PME# supported from D0 D1 D3hot [ 0.078979] pci 0000:00:01.0: [1db7:dc01] type 01 class 0x060400 [ 0.078984] pci 0000:00:01.0: reg 0x10: [mem 0x1000000000-0x10000fffff 6= 4bit pref] [ 0.079001] pci 0000:00:01.0: supports D1 D2 [ 0.079003] pci 0000:00:01.0: PME# supported from D0 D1 D2 D3hot D3cold [ 0.079073] pci 0000:01:00.0: [1e49:1101] type 00 class 0x010802 [ 0.079086] pci 0000:01:00.0: reg 0x10: [mem 0x58100000-0x58103fff 64bit] [ 0.079201] pci 0000:01:00.0: 31.504 Gb/s available PCIe bandwidth, limi= ted by 8.0 GT/s PCIe x4 link at 0000:00:00.0 (capable ojjf 63.012 Gb/s with= 16.0 GT/s PCIe x4 link) [ 0.091501] pci 0000:02:00.0: [10ec:b852] type 00 class 0x028000 In pcie_wait_for_link_status(), using msleep(1) to wait for link status change. But msleep(1) can sleep for nearly 5ms. ftrace shows: 0) | pcie_wait_for_link_status() { 0) 0.500 us | pcie_capability_read_word(); 0) 0.580 us | pcie_capability_read_word(); 0) * 10292.26 us | } after changing to usleep_range(). ftrace shows: 0) | pcie_wait_for_link_status() { 0) 0.320 us | pcie_capability_read_word(); 0) 0.480 us | pcie_capability_read_word(); 0) # 2483.980 us | } After changing to usleep_range(), the time gap is gone: ... [ 0.076763] PCI host bridge to bus 0000:00 [ 0.076766] pci_bus 0000:00: root bus resource [mem 0x58000000-0x7ffffff= f window] [ 0.076768] pci_bus 0000:00: root bus resource [mem 0x1000000000-0x1ffff= fffff window] [ 0.076770] pci_bus 0000:00: root bus resource [io 0x0000-0xffff window] [ 0.076772] pci_bus 0000:00: root bus resource [bus 00-ff] [ 0.076783] pci 0000:00:00.0: [1db7:dc01] type 01 class 0x060400 [ 0.076791] pci 0000:00:00.0: reg 0x38: [mem 0xfff00000-0xffffffff pref] [ 0.076811] pci 0000:00:00.0: supports D1 [ 0.076813] pci 0000:00:00.0: PME# supported from D0 D1 D3hot [ 0.076874] pci 0000:00:01.0: [1db7:dc01] type 01 class 0x060400 [ 0.076880] pci 0000:00:01.0: reg 0x10: [mem 0x1000000000-0x10000fffff 6= 4bit pref] [ 0.076897] pci 0000:00:01.0: supports D1 D2 [ 0.076898] pci 0000:00:01.0: PME# supported from D0 D1 D2 D3hot D3cold [ 0.076969] pci 0000:01:00.0: [1e49:1101] type 00 class 0x010802 [ 0.076982] pci 0000:01:00.0: reg 0x10: [mem 0x58100000-0x58103fff 64bit] [ 0.077098] pci 0000:01:00.0: 31.504 Gb/s available PCIe bandwidth, limi= ted by 8.0 GT/s PCIe x4 link at 0000:00:00.0 (capable of 63.012 Gb/s with 1= 6.0 GT/s PCIe x4 link) [ 0.078281] pci 0000:02:00.0: [10ec:b852] type 00 class 0x028000 To speed up booting, replace msleep() by using fsleep() (more generic then usleep_range()). Signed-off-by: Hongyu Xie --- v2->v1: 1, add booting log 2, change usleep_range to fsleep drivers/pci/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index f3244630bfd0..15fd15f24df3 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -4519,7 +4519,7 @@ static int pcie_wait_for_link_status(struct pci_dev *= pdev, pcie_capability_read_word(pdev, PCI_EXP_LNKSTA, &lnksta); if ((lnksta & lnksta_mask) =3D=3D lnksta_match) return 0; - msleep(1); + fsleep(1000); } while (time_before(jiffies, end_jiffies)); =20 return -ETIMEDOUT; --=20 2.25.1