public inbox for linux-nvme@lists.infradead.org
 help / color / mirror / Atom feed
From: Damien Le Moal <dlemoal@kernel.org>
To: Niklas Cassel <cassel@kernel.org>, Christoph Hellwig <hch@lst.de>,
	Sagi Grimberg <sagi@grimberg.me>,
	Chaitanya Kulkarni <kch@nvidia.com>
Cc: linux-nvme@lists.infradead.org
Subject: Re: [PATCH] nvmet: pci-epf: Always configure BAR0 as 64-bit
Date: Fri, 14 Mar 2025 19:34:06 +0900	[thread overview]
Message-ID: <bf6d9883-da33-4e52-9a67-aa0ee660caf2@kernel.org> (raw)
In-Reply-To: <20250314095858.1604764-2-cassel@kernel.org>

On 3/14/25 18:58, Niklas Cassel wrote:
> NVMe PCIe Transport Specification 1.1, section 2.1.10, claims that the
> BAR0 type is Implementation Specific.
> 
> However, in NVMe 1.1, the type is required to be 64-bit.
> 
> Thus, to make our PCI EPF work on as many host systems as possible,
> always configure the BAR0 type to be 64-bit.
> 
> In the rare case that the underlying PCI EPC does not support configuring
> BAR0 as 64-bit, the call to pci_epc_set_bar() will fail, and we will
> return a failure back to the user.
> 
> This should not be a problem, as most PCI EPCs support configuring a BAR
> as 64-bit (and those EPCs with .only_64bit set to true in epc_features
> only support configuring the BAR as 64-bit).
> 
> Signed-off-by: Niklas Cassel <cassel@kernel.org>
> ---
> Hello Damien,
> 
> please test on your platforms as well.

Will test. But I think this needs a Fixes tag:

Fixes: 0faa0fe6f90e ("nvmet: New NVMe PCI endpoint function target driver")

> 
> I think this is the way to go, as most real NVMe drives in the wild have
> BAR0 as a 64-bit BAR.
> 
>  drivers/nvme/target/pci-epf.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/nvme/target/pci-epf.c b/drivers/nvme/target/pci-epf.c
> index 0136df45ca275..a24f6549c0d15 100644
> --- a/drivers/nvme/target/pci-epf.c
> +++ b/drivers/nvme/target/pci-epf.c
> @@ -2096,8 +2096,15 @@ static int nvmet_pci_epf_configure_bar(struct nvmet_pci_epf *nvme_epf)
>  		return -ENODEV;
>  	}
>  
> -	if (epc_features->bar[BAR_0].only_64bit)
> -		epf->bar[BAR_0].flags |= PCI_BASE_ADDRESS_MEM_TYPE_64;
> +	/*
> +	 * While NVMe PCIe Transport Specification 1.1, section 2.1.10, claims
> +	 * that the BAR0 type is Implementation Specific, in NVMe 1.1, the type
> +	 * is required to be 64-bit. Thus, for interoperability, always set the
> +	 * type to 64-bit. In the rare case that the PCI EPC does not support
> +	 * configuring BAR0 as 64-bit, the call to pci_epc_set_bar() will fail,
> +	 * and we will return failure back to the user.
> +	 */
> +	epf->bar[BAR_0].flags |= PCI_BASE_ADDRESS_MEM_TYPE_64;
>  
>  	/*
>  	 * Calculate the size of the register bar: NVMe registers first with


-- 
Damien Le Moal
Western Digital Research


  reply	other threads:[~2025-03-14 10:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-14  9:58 [PATCH] nvmet: pci-epf: Always configure BAR0 as 64-bit Niklas Cassel
2025-03-14 10:34 ` Damien Le Moal [this message]
2025-03-14 11:06 ` Damien Le Moal

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=bf6d9883-da33-4e52-9a67-aa0ee660caf2@kernel.org \
    --to=dlemoal@kernel.org \
    --cc=cassel@kernel.org \
    --cc=hch@lst.de \
    --cc=kch@nvidia.com \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    /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