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 299EC4EB862; Tue, 13 Oct 2026 12:35:53 +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=1791894954; cv=none; b=VZOJJbO5dSFkWdj9OsGZNQ/KYDJIUdM7eAXVUZMqAyB7my4q4QwWaVdYB437bil3dMkzjkZT9XD9WqNUBSdBVe5xzoBHQiF1C5mG8nQsXY1x3CF02JPwaqgODlf3asGgqg30LK3AK3QzsUJoBl7QzYGwZ7CWnwFeJkK2F20bSsI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791894954; c=relaxed/simple; bh=udcU4aBWs8gLZt42+tRSl3uUnkv2Ha+TgisnreVpmVg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JelN72YgdrZOXSV4yvsObj3FMF9/BKUQJckb/SXoiE8aFU9zJmIx/MOu+M1a5CXpDE6zBFPLPfB/lPZ6zhIWpukMW4MIF41XJFYvl9cTmMbalq4GdykPPBVvRSAy+N07OalzCQvrht1v29py+Um282wwElU05BWu8cfxsW5HLos= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=BAqKcCoK; 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="BAqKcCoK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7FE871F000FF; Tue, 13 Oct 2026 12:35:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1791894953; bh=T7iCEUWGTP3DwlzEVLjGv6O7wCUGqKE6d2HCCJrELaU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=BAqKcCoKkMQnA97Xuds/Ox01iJmzy5S+TXr4dT38Y6APngWA0W/pokQBykcvjGdbE gGAWodbchIMlNRvzB4ltR68Y31W/6TCM039wjoWoF9uG3QMbW0VgjPPxz9TXeXtnY/ oYHHxR3zMDjAA5GgFatc3W7Bktd4NAPlv5qEHRJg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Nikola Prica , Bjorn Helgaas , Gerd Bayer , =?UTF-8?q?Christian=20K=C3=B6nig?= , Sasha Levin Subject: [PATCH 6.12 112/497] PCI: Accept AtomicOps already enabled by the hypervisor Date: Tue, 13 Oct 2026 13:34:39 +0200 Message-ID: <20261013112910.548997665@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261013112907.864180619@linuxfoundation.org> References: <20261013112907.864180619@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.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Nikola Prica [ Upstream commit 40cce45b921f7930886bcba43069edc579725457 ] pci_enable_atomic_ops_to_root() currently fails when no Root Port is visible. That is common in passthrough guests (ESXi, Hyper-V): the Endpoint is assigned to the VM, but the Root Port above it is not visible in the guest topology. In those setups the hypervisor may already have enabled AtomicOp Requester Enable on the device. If PCI_EXP_DEVCTL2_ATOMIC_REQ is set, treat AtomicOps as already enabled and return success instead of failing the Root Port walk. After 1ae8c4ce1570 ("PCI: Enable AtomicOps only if Root Port supports them"), pci_enable_atomic_ops_to_root() always returns failure if the Root Port is not visible, so drivers don't use atomics when they could. On systems where the Root Port is not visible but *does* support AtomicOps, this is a regression: prior to 1ae8c4ce1570, it enabled AtomicOps in the endpoint and returned success. Fixes: 1ae8c4ce1570 ("PCI: Enable AtomicOps only if Root Port supports them") Signed-off-by: Nikola Prica [bhelgaas: commit log, code comment] Signed-off-by: Bjorn Helgaas Tested-by: Gerd Bayer Reviewed-by: Christian König Reviewed-by: Gerd Bayer Link: https://patch.msgid.link/20260921111903.978687-1-nikprica@amd.com Signed-off-by: Sasha Levin --- drivers/pci/pci.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 4364ed7cdc27b..0d33b30ec2f67 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -3764,8 +3764,21 @@ int pci_enable_atomic_ops_to_root(struct pci_dev *dev, u32 cap_mask) } root = pcie_find_root_port(dev); - if (!root) + if (!root) { + + /* + * A hypervisor may expose a topology with the root port + * not visible to the guest. If the hypervisor has already + * set AtomicOp Requester Enable in the endpoint, we assume + * it has verified support in the root port, so it is safe + * for the driver to use AtomicOps. + */ + pcie_capability_read_dword(dev, PCI_EXP_DEVCTL2, &ctl2); + if (ctl2 & PCI_EXP_DEVCTL2_ATOMIC_REQ) + return 0; + return -EINVAL; + } pcie_capability_read_dword(root, PCI_EXP_DEVCAP2, &cap); if ((cap & cap_mask) != cap_mask) -- 2.53.0