public inbox for linux-nvme@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] nvme: enable generic interface (/dev/ngX) for unknown command sets
       [not found] <CGME20220325111952epcas5p4800055294fe473b923713d4b9c006026@epcas5p4.samsung.com>
@ 2022-03-25 11:14 ` Kanchan Joshi
  2022-03-25 16:20   ` Christoph Hellwig
  0 siblings, 1 reply; 3+ messages in thread
From: Kanchan Joshi @ 2022-03-25 11:14 UTC (permalink / raw)
  To: hch, kbusch; +Cc: linux-nvme, k.jensen, javier, j.granados

block and char interface do not show up for any command set other than
NVM and ZNS.
Allow namespace setup to take place, and char interface to come up for
unknown command sets. Hide the block-interface for such command sets.

Suggested-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kanchan Joshi <joshi.k@samsung.com>
---
This is prepared against linux-block/for-next.
On top of commit e529e21f317 ("Merge branch 'for-5.18/io_uring' into for-next")


 drivers/nvme/host/core.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 677fa4bf76d3..3e5d9a3f4167 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1875,7 +1875,7 @@ static void nvme_set_chunk_sectors(struct nvme_ns *ns, struct nvme_id_ns *id)
 static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_id_ns *id)
 {
 	unsigned lbaf = nvme_lbaf_index(id->flbas);
-	int ret;
+	int ret = 0;
 
 	blk_mq_freeze_queue(ns->disk->queue);
 	ns->lba_shift = id->lbaf[lbaf].ds;
@@ -1885,11 +1885,13 @@ static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_id_ns *id)
 	nvme_set_chunk_sectors(ns, id);
 	nvme_update_disk_info(ns->disk, ns, id);
 
-	if (ns->head->ids.csi == NVME_CSI_ZNS) {
+	if (ns->head->ids.csi == NVME_CSI_ZNS)
 		ret = nvme_update_zone_info(ns, lbaf);
-		if (ret)
-			goto out_unfreeze;
-	}
+	else if (ns->head->ids.csi != NVME_CSI_NVM)
+		/* suppress block-interface for unknown command-sets */
+		ret = -ENODEV;
+	if (ret)
+		goto out_unfreeze;
 
 	set_bit(NVME_NS_READY, &ns->flags);
 	blk_mq_unfreeze_queue(ns->disk->queue);
@@ -4098,6 +4100,14 @@ static void nvme_validate_or_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid)
 	default:
 		dev_warn(ctrl->device, "unknown csi %u for nsid %u\n",
 			ids.csi, nsid);
+		if (!nvme_multi_css(ctrl)) {
+			dev_warn(ctrl->device,
+				"command set not reported for nsid: %d\n",
+				nsid);
+			break;
+		}
+		/* required to enable char-interface for unknown command sets*/
+		nvme_alloc_ns(ctrl, nsid, &ids);
 		break;
 	}
 }
-- 
2.25.1



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

* Re: [PATCH] nvme: enable generic interface (/dev/ngX) for unknown command sets
  2022-03-25 11:14 ` [PATCH] nvme: enable generic interface (/dev/ngX) for unknown command sets Kanchan Joshi
@ 2022-03-25 16:20   ` Christoph Hellwig
  2022-03-28 15:12     ` Kanchan Joshi
  0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2022-03-25 16:20 UTC (permalink / raw)
  To: Kanchan Joshi; +Cc: hch, kbusch, linux-nvme, k.jensen, javier, j.granados

On Fri, Mar 25, 2022 at 04:44:44PM +0530, Kanchan Joshi wrote:
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index 677fa4bf76d3..3e5d9a3f4167 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -1875,7 +1875,7 @@ static void nvme_set_chunk_sectors(struct nvme_ns *ns, struct nvme_id_ns *id)
>  static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_id_ns *id)
>  {
>  	unsigned lbaf = nvme_lbaf_index(id->flbas);
> -	int ret;
> +	int ret = 0;
>  
>  	blk_mq_freeze_queue(ns->disk->queue);
>  	ns->lba_shift = id->lbaf[lbaf].ds;

nvme_update_ns_info can't really work for arbitrary command sets as
the concept of LBA sizes and format doesn't apply there.  So we'll
need a different stubbed out version that doesn't deal with the
block interface at all.

> @@ -4098,6 +4100,14 @@ static void nvme_validate_or_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid)
>  	default:
>  		dev_warn(ctrl->device, "unknown csi %u for nsid %u\n",
>  			ids.csi, nsid);
> +		if (!nvme_multi_css(ctrl)) {
> +			dev_warn(ctrl->device,
> +				"command set not reported for nsid: %d\n",
> +				nsid);
> +			break;
> +		}

Given that the NVM command set has a CSI of 0 getting random garbage
here sounds unlikely.  That being said if we want to support passthrough
for unknown command sets the warning above should probably go
away above as well.

> +		/* required to enable char-interface for unknown command sets*/
> +		nvme_alloc_ns(ctrl, nsid, &ids);

And this can't really work as nvme_alloc_ns looks at the Identify
Namespace structure for the NVM command set which can't really
work for arbitrary command sets.  We'll need a nvme_alloc_ns_generic
instead that looks at the Command Set Independent Identify Namespace
structure for a few things like namespace sharing capability and
does just the basic work to get the passthrough interface up.



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

* Re: [PATCH] nvme: enable generic interface (/dev/ngX) for unknown command sets
  2022-03-25 16:20   ` Christoph Hellwig
@ 2022-03-28 15:12     ` Kanchan Joshi
  0 siblings, 0 replies; 3+ messages in thread
From: Kanchan Joshi @ 2022-03-28 15:12 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Kanchan Joshi, Keith Busch, linux-nvme, k.jensen,
	Javier González, j.granados

On Fri, Mar 25, 2022 at 9:55 PM Christoph Hellwig <hch@lst.de> wrote:
Thanks for the feedback; will change accordingly.


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

end of thread, other threads:[~2022-03-28 15:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CGME20220325111952epcas5p4800055294fe473b923713d4b9c006026@epcas5p4.samsung.com>
2022-03-25 11:14 ` [PATCH] nvme: enable generic interface (/dev/ngX) for unknown command sets Kanchan Joshi
2022-03-25 16:20   ` Christoph Hellwig
2022-03-28 15:12     ` Kanchan Joshi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox