[PATCH v2 3/3] nvme: prevent ioq creation for discovery controllers

Kamaljit Singh posted 3 patches 3 months, 1 week ago
There is a newer version of this series
[PATCH v2 3/3] nvme: prevent ioq creation for discovery controllers
Posted by Kamaljit Singh 3 months, 1 week ago
Prevent ioq creation for discovery-controllers as the spec prohibits
them, similarly to the administrative controllers.

Reference: NVMe Base rev 2.2, sec 3.1.3.4, fig 28.

Signed-off-by: Kamaljit Singh <kamaljit.singh1@wdc.com>
---
 drivers/nvme/host/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index c310634e75f3..3ad3b1da8b34 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -3155,12 +3155,12 @@ static inline bool nvme_admin_ctrl(struct nvme_ctrl *ctrl)
 }
 
 /*
- * An admin controller has one admin queue, but no I/O queues.
+ * An admin or discovery controller has one admin queue, but no I/O queues.
  * Override queue_count so it only creates an admin queue.
  */
 void nvme_override_prohibited_io_queues(struct nvme_ctrl *ctrl)
 {
-	if (nvme_admin_ctrl(ctrl))
+	if (nvme_admin_ctrl(ctrl) || nvme_discovery_ctrl(ctrl))
 		ctrl->queue_count = 1;
 }
 EXPORT_SYMBOL_GPL(nvme_override_prohibited_io_queues);
-- 
2.43.0
Re: [PATCH v2 3/3] nvme: prevent ioq creation for discovery controllers
Posted by Hannes Reinecke 3 months ago
On 7/2/25 02:58, Kamaljit Singh wrote:
> Prevent ioq creation for discovery-controllers as the spec prohibits
> them, similarly to the administrative controllers.
> 
> Reference: NVMe Base rev 2.2, sec 3.1.3.4, fig 28.
> 
While this might be true, we already deal with discovery controllers
just fine, and never had issues with I/O queues being created.
Presumably because discovery controllers never exposed I/O queues
in the first place.

Which also means that admin controllers should work already if they
would not expose I/O queues.

We _might_ reduce the number of queues to '1' in nvme_set_queue_count(),
but then we should issue a warning here as this would be a configuration
error on the target side.

'Prohibited' cuts both ways; the host shouldn't ask for it and the
controller shouldn't advertise it...

Or that's at least my reading. Might be worthwhile clarifying this
at FMDS.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                  Kernel Storage Architect
hare@suse.de                                +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Re: [PATCH v2 3/3] nvme: prevent ioq creation for discovery controllers
Posted by Damien Le Moal 3 months, 1 week ago
On 7/2/25 09:58, Kamaljit Singh wrote:
> Prevent ioq creation for discovery-controllers as the spec prohibits
> them, similarly to the administrative controllers.
> 
> Reference: NVMe Base rev 2.2, sec 3.1.3.4, fig 28.
> 
> Signed-off-by: Kamaljit Singh <kamaljit.singh1@wdc.com>
> ---
>  drivers/nvme/host/core.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index c310634e75f3..3ad3b1da8b34 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -3155,12 +3155,12 @@ static inline bool nvme_admin_ctrl(struct nvme_ctrl *ctrl)
>  }
>  
>  /*
> - * An admin controller has one admin queue, but no I/O queues.
> + * An admin or discovery controller has one admin queue, but no I/O queues.
>   * Override queue_count so it only creates an admin queue.
>   */
>  void nvme_override_prohibited_io_queues(struct nvme_ctrl *ctrl)
>  {
> -	if (nvme_admin_ctrl(ctrl))
> +	if (nvme_admin_ctrl(ctrl) || nvme_discovery_ctrl(ctrl))
>  		ctrl->queue_count = 1;
>  }
>  EXPORT_SYMBOL_GPL(nvme_override_prohibited_io_queues);

Repeating comment on patch 1. Can't we do this in nvme_init_subsystem() or may
be better, in nvme_set_queue_count() or nvme_init_ctrl_finish() ?


-- 
Damien Le Moal
Western Digital Research