From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1FE5718DB2A; Wed, 25 Feb 2026 01:32:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771983170; cv=none; b=eCucX1ETlMwGXjFHBYwHbp9R7RzLiQXQzfHH+ZKIBlDUj8xeorRfzsNUcrawg1EE6Cy4NQ3erNWwguOwlBB8M6aw7QcPDd2+EaXk+aSttUjqBZc7FM7pjlS7Z0wuGUcxMaIzTBEXYWTG/tytOEwxAAwWAPrZiTGVv03/y34Zhg0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771983170; c=relaxed/simple; bh=Qn5hclG+WB+ZkAxZLLjTDbsGQhiNqe0Y2UU+Bo2UnH4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FSxIdXXE8qJHwRzn80if+7NwqdmjJ7i6jBvE3NGcH17eszPMOdwwubAUpQBj5yAkAemg7T+hFYnG9IMQDluocjwgAdOTNx4lhJhENDOXqWV6W4nRwnKOXjK0rwWmYc6tgIYHVGKNeIHLIfPfXhJ+zBE0nWNO8X4VV7MVGMtQApY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=xQLySLLH; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="xQLySLLH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E320BC116D0; Wed, 25 Feb 2026 01:32:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1771983170; bh=Qn5hclG+WB+ZkAxZLLjTDbsGQhiNqe0Y2UU+Bo2UnH4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xQLySLLHt8E7gORhkHo2xA1h7EwkHRxCBBMKqhl8UPK2NNqhMuOSyp/reQZCF8nLj w+1qLkvLc5f7rslBqKAdYJhqzP+tKfO5l7jL8KHjutcSQZBZ879/v8Od2uPuBNtWHA sAKuEszSz9E+vgjsRN6OfL1ebw4RkQ4q6b4ef8ts= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Brian Norris , Brian Norris , Bjorn Helgaas , Sasha Levin Subject: [PATCH 6.19 322/781] PCI/PM: Avoid redundant delays on D3hot->D3cold Date: Tue, 24 Feb 2026 17:17:11 -0800 Message-ID: <20260225012407.600277934@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260225012359.695468795@linuxfoundation.org> References: <20260225012359.695468795@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Brian Norris [ Upstream commit 4d982084507d663df160546c4c48066a8887ed89 ] When transitioning to D3cold, __pci_set_power_state() first transitions to D3hot. If the device was already in D3hot, this adds excess work: (a) read/modify/write PMCSR; and (b) excess delay (pci_dev_d3_sleep()). For (b), we already performed the necessary delay on the previous D3hot entry; this was extra noticeable when evaluating runtime PM transition latency. Check whether we're already in the target state before continuing. Note that __pci_set_power_state() already does this same check for other state transitions, but D3cold is special because __pci_set_power_state() converts it to D3hot for the purposes of PMCSR. This seems to be an oversight in commit 0aacdc957401 ("PCI/PM: Clean up pci_set_low_power_state()"). Fixes: 0aacdc957401 ("PCI/PM: Clean up pci_set_low_power_state()") Signed-off-by: Brian Norris Signed-off-by: Brian Norris [bhelgaas: reverse test to match other "dev->current_state == state" cases] Signed-off-by: Bjorn Helgaas Link: https://patch.msgid.link/20251003154008.1.I7a21c240b30062c66471329567a96dceb6274358@changeid Signed-off-by: Sasha Levin --- drivers/pci/pci.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 13dbb405dc31f..86ccbd0efb495 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -1488,6 +1488,9 @@ static int pci_set_low_power_state(struct pci_dev *dev, pci_power_t state, bool || (state == PCI_D2 && !dev->d2_support)) return -EIO; + if (dev->current_state == state) + return 0; + pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr); if (PCI_POSSIBLE_ERROR(pmcsr)) { pci_err(dev, "Unable to change power state from %s to %s, device inaccessible\n", -- 2.51.0