Linux PCI subsystem development
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: Nikola Prica <nikprica@amd.com>, bhelgaas@google.com
Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
	jerry.jiang@amd.com, haijun.chang@amd.com, andy.zhang@amd.com,
	Nikola Prica <nikola.prica@amd.com>
Subject: Re: [PATCH] PCI: Accept AtomicOps already enabled by the hypervisor
Date: Thu, 3 Sep 2026 14:09:08 +0200	[thread overview]
Message-ID: <ecf98a97-a5b6-4829-92e8-0d1f47c44d7f@amd.com> (raw)
In-Reply-To: <20260903121218.4955-1-nikprica@amd.com>

On 9/3/26 14:12, Nikola Prica wrote:
> From: Nikola Prica <nikola.prica@amd.com>
> 
> 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 guest topology has no Root
> Port above it.
> 
> 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.
> 
> Signed-off-by: Nikola Prica <nikola.prica@amd.com>
> ---
>  drivers/pci/pci.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index b2879a6be5f8..7c62c7f31757 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -3768,6 +3768,14 @@ int pci_enable_atomic_ops_to_root(struct pci_dev *dev, u32 cap_mask)
>  		return -EINVAL;
>  	}
>  
> +	/*
> +	 * Some hypervisors already set AtomicOp Requester Enable.  If it
> +	 * is already set, there is nothing more to do.
> +	 */
> +	pcie_capability_read_dword(dev, PCI_EXP_DEVCTL2, &ctl2);
> +	if (ctl2 & PCI_EXP_DEVCTL2_ATOMIC_REQ)
> +		return 0;
> +

I think for a bit more defensiveness we should only do this when we can't find a root port. E.g. under the if (!root) below.

Apart from that looks totally sane to me.

Regards,
Christian.

>  	root = pcie_find_root_port(dev);
>  	if (!root)
>  		return -EINVAL;
> 
> base-commit: 89a312991dc6e638a36adc43ccb91dbc25504c04


  reply	other threads:[~2026-09-03 12:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-03 12:12 [PATCH] PCI: Accept AtomicOps already enabled by the hypervisor Nikola Prica
2026-09-03 12:09 ` Christian König [this message]
2026-09-03 12:12 ` sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ecf98a97-a5b6-4829-92e8-0d1f47c44d7f@amd.com \
    --to=christian.koenig@amd.com \
    --cc=andy.zhang@amd.com \
    --cc=bhelgaas@google.com \
    --cc=haijun.chang@amd.com \
    --cc=jerry.jiang@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=nikola.prica@amd.com \
    --cc=nikprica@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox