From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 42C32345EB9; Sat, 12 Sep 2026 15:38:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789227494; cv=none; b=JHyxeZPNbNckneUNudVbB/6+6nROW0Vxxd80+vnlk/j42wKcl/12po1s1MLrLPeLZWwPnxpP5Z3Ad3/Lv5glTW3696TNxl0/8nZACIBraNaSMw3BgdQ3ufSw9+d7O5hRTlK5k5SDPYrdr56G/3AhpBMnzJLpUJYz0XVT3C8XEmQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789227494; c=relaxed/simple; bh=P9ZlnC3wRRthquFHF761uUrBwEeKqz+6GA+EWjiC+NE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=J4euYm4UxsiUhtn3Mt5ETCsazFaebR6gKWc8tDFx4nno+loFWe9uPipzdVPvOyjGu3A5loVEGW/bGN9asPx6tBTuaissslZUQ+VaReouHm8Thh/dzhu9Wksdo4isYr2ZCzXjslxkOPI1Xe4zvBPl7mq8QMd36LwJMxKIZSKB7uU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Gj2/6VcT; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Gj2/6VcT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EFB5E1F000FF; Sat, 12 Sep 2026 15:38:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789227493; bh=YWfcxoTNWTONwMXhDHN+WEXPhgX3Jros+NpHozI+phs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Gj2/6VcThgsFZceq+VNmcTxadAJaH8faNjGw9qGD8HQDzmrVc28fjceXrPjV/hfOB z5VUnpFKFd3yqRfZVUf+jOovGRf4a3sL7SB1x0j1aIwYBDi+UJeTQuWgqgZIdI/a9l Jf7OaD7/zl8p+yLssgY4X0Wq6Br3qT46zaZVZJe0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Bjorn Helgaas Subject: [PATCH 6.1 0190/1191] PCI/proc: Avoid spurious runtime PM wakeup on config space accesses Date: Sat, 12 Sep 2026 08:48:38 +0200 Message-ID: <20260912065552.482784999@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065548.086904252@linuxfoundation.org> References: <20260912065548.086904252@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Krzysztof Wilczyński commit 4ff664a81d729b37f2eb65de80a670abfb61c9a0 upstream. Currently, proc_bus_pci_read() and proc_bus_pci_write() do not return early for zero-length configuration space accesses at valid offsets. Such an access invokes pci_config_pm_runtime_get() and pci_config_pm_runtime_put() around transfer blocks that do nothing. This is a problem because pci_config_pm_runtime_get() synchronously resumes the upstream bridge through pm_runtime_get_sync(), and resumes the device itself through pm_runtime_resume() when it is in D3cold, only for the handler to return zero immediately afterwards. Such a spurious wakeup wastes power and adds needless resume latency. The sysfs core already returns early for in-range zero-length binary attribute accesses before pci_read_config() or pci_write_config() is invoked. In contrast, the VFS forwards zero-length requests to the procfs callbacks, where they continue into runtime PM handling. Return early from proc_bus_pci_read() and proc_bus_pci_write() when nbytes is zero, before any runtime PM involvement. The value returned to userspace at these offsets remains zero, so the change is not visible to userspace. Signed-off-by: Krzysztof Wilczyński [bhelgaas: order tags] Signed-off-by: Bjorn Helgaas Cc: stable@vger.kernel.org Link: https://patch.msgid.link/20260729075909.1219906-1-kwilczynski@kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/pci/proc.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/drivers/pci/proc.c +++ b/drivers/pci/proc.c @@ -45,6 +45,9 @@ static ssize_t proc_bus_pci_read(struct else size = 64; + if (!nbytes) + return 0; + if (pos >= size) return 0; if (nbytes >= size) @@ -121,6 +124,9 @@ static ssize_t proc_bus_pci_write(struct if (ret) return ret; + if (!nbytes) + return 0; + if (pos >= size) return 0; if (nbytes >= size)