Linux-NVME Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v4] nvme/pci: Split 8-byte reads
@ 2019-10-07 18:22 Ard Biesheuvel
  2019-10-07 18:28 ` Keith Busch
  2019-10-07 18:47 ` Christoph Hellwig
  0 siblings, 2 replies; 3+ messages in thread
From: Ard Biesheuvel @ 2019-10-07 18:22 UTC (permalink / raw)
  To: linux-nvme; +Cc: sagi, Ard Biesheuvel, ilias.apalodimas, axboe, kbusch, hch

The nvme pci driver had split 8-byte register reads using lo_hi_readq()
due to nvme controllers that do not support that sized access. This
behavior was inadvertently changed to readq(), which may break those
controllers. Restore the previous behavior.

Fixes: 7fd8930f26be4 ("nvme: add a common helper to read Identify Controller data")
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
v4: update comment and commit text according to Keith's guidance
v3: add comment explaining why we need the split read
v2: drop WARN_ON(), add reference to commit that [re-]introduced the issue
---
 drivers/nvme/host/pci.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index bb88681f4dc3..3fe0c5185646 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -2672,7 +2672,12 @@ static int nvme_pci_reg_write32(struct nvme_ctrl *ctrl, u32 off, u32 val)
 
 static int nvme_pci_reg_read64(struct nvme_ctrl *ctrl, u32 off, u64 *val)
 {
-	*val = readq(to_nvme_dev(ctrl)->bar + off);
+	/*
+	 * Split the 8-byte read into two 4-byte reads since all controllers
+	 * support 4 byte register reads, but some do not support the larger
+	 * access size.
+	 */
+	 *val = lo_hi_readq(to_nvme_dev(ctrl)->bar + off);
 	return 0;
 }
 
-- 
2.20.1


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v4] nvme/pci: Split 8-byte reads
  2019-10-07 18:22 [PATCH v4] nvme/pci: Split 8-byte reads Ard Biesheuvel
@ 2019-10-07 18:28 ` Keith Busch
  2019-10-07 18:47 ` Christoph Hellwig
  1 sibling, 0 replies; 3+ messages in thread
From: Keith Busch @ 2019-10-07 18:28 UTC (permalink / raw)
  To: Ard Biesheuvel; +Cc: axboe, ilias.apalodimas, sagi, linux-nvme, hch

On Mon, Oct 07, 2019 at 08:22:44PM +0200, Ard Biesheuvel wrote:
> The nvme pci driver had split 8-byte register reads using lo_hi_readq()
> due to nvme controllers that do not support that sized access. This
> behavior was inadvertently changed to readq(), which may break those
> controllers. Restore the previous behavior.
> 
> Fixes: 7fd8930f26be4 ("nvme: add a common helper to read Identify Controller data")
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

Looks good to me.

Reviewed-by: Keith Busch <kbusch@kernel.org>

> ---
>  drivers/nvme/host/pci.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
> index bb88681f4dc3..3fe0c5185646 100644
> --- a/drivers/nvme/host/pci.c
> +++ b/drivers/nvme/host/pci.c
> @@ -2672,7 +2672,12 @@ static int nvme_pci_reg_write32(struct nvme_ctrl *ctrl, u32 off, u32 val)
>  
>  static int nvme_pci_reg_read64(struct nvme_ctrl *ctrl, u32 off, u64 *val)
>  {
> -	*val = readq(to_nvme_dev(ctrl)->bar + off);
> +	/*
> +	 * Split the 8-byte read into two 4-byte reads since all controllers
> +	 * support 4 byte register reads, but some do not support the larger
> +	 * access size.
> +	 */
> +	 *val = lo_hi_readq(to_nvme_dev(ctrl)->bar + off);
>  	return 0;
>  }
>  
> -- 
> 2.20.1
> 

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v4] nvme/pci: Split 8-byte reads
  2019-10-07 18:22 [PATCH v4] nvme/pci: Split 8-byte reads Ard Biesheuvel
  2019-10-07 18:28 ` Keith Busch
@ 2019-10-07 18:47 ` Christoph Hellwig
  1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2019-10-07 18:47 UTC (permalink / raw)
  To: Ard Biesheuvel; +Cc: sagi, ilias.apalodimas, linux-nvme, axboe, kbusch, hch

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-07 18:22 [PATCH v4] nvme/pci: Split 8-byte reads Ard Biesheuvel
2019-10-07 18:28 ` Keith Busch
2019-10-07 18:47 ` Christoph Hellwig

Linux-NVME Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-nvme/0 linux-nvme/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-nvme linux-nvme/ https://lore.kernel.org/linux-nvme \
		linux-nvme@lists.infradead.org linux-nvme@archiver.kernel.org
	public-inbox-index linux-nvme

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-nvme


AGPL code for this site: git clone https://public-inbox.org/ public-inbox