linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] nvme: validate cntlid's only for nvme >= 1.1.0
@ 2020-06-30 12:29 Maximilian Heyne
  2020-06-30 13:33 ` Christoph Hellwig
  0 siblings, 1 reply; 5+ messages in thread
From: Maximilian Heyne @ 2020-06-30 12:29 UTC (permalink / raw)
  Cc: Amit Shah, Maximilian Heyne, stable, Keith Busch, Jens Axboe,
	Christoph Hellwig, Sagi Grimberg, linux-nvme, linux-kernel

Controller ID's (cntlid) for NVMe devices were introduced in version
1.1.0 of the specification. Controllers that follow the older 1.0.0 spec
don't set this field so it doesn't make sense to validate it. On the
contrary, when using SR-IOV this check breaks VFs as they are all part
of the same NVMe subsystem.

Signed-off-by: Maximilian Heyne <mheyne@amazon.de>
Cc: <stable@vger.kernel.org> # 5.4+
---
 drivers/nvme/host/core.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 28f4388c1337..c4a991acc949 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2773,7 +2773,8 @@ static int nvme_init_subsystem(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
 		put_device(&subsys->dev);
 		subsys = found;
 
-		if (!nvme_validate_cntlid(subsys, ctrl, id)) {
+		if (ctrl->vs >= NVME_VS(1, 1, 0) &&
+		    !nvme_validate_cntlid(subsys, ctrl, id)) {
 			ret = -EINVAL;
 			goto out_put_subsystem;
 		}
@@ -2883,7 +2884,7 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)
 			goto out_free;
 	}
 
-	if (!(ctrl->ops->flags & NVME_F_FABRICS))
+	if (!(ctrl->ops->flags & NVME_F_FABRICS) && ctrl->vs >= NVME_VS(1, 1, 0))
 		ctrl->cntlid = le16_to_cpu(id->cntlid);
 
 	if (!ctrl->identified) {
-- 
2.16.6




Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss
Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879




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

* Re: [PATCH] nvme: validate cntlid's only for nvme >= 1.1.0
  2020-06-30 12:29 [PATCH] nvme: validate cntlid's only for nvme >= 1.1.0 Maximilian Heyne
@ 2020-06-30 13:33 ` Christoph Hellwig
  2020-06-30 13:36   ` Christoph Hellwig
  0 siblings, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2020-06-30 13:33 UTC (permalink / raw)
  To: Maximilian Heyne
  Cc: Amit Shah, stable, Keith Busch, Jens Axboe, Christoph Hellwig,
	Sagi Grimberg, linux-nvme, linux-kernel

On Tue, Jun 30, 2020 at 12:29:23PM +0000, Maximilian Heyne wrote:
> Controller ID's (cntlid) for NVMe devices were introduced in version
> 1.1.0 of the specification. Controllers that follow the older 1.0.0 spec
> don't set this field so it doesn't make sense to validate it. On the
> contrary, when using SR-IOV this check breaks VFs as they are all part
> of the same NVMe subsystem.
> 
> Signed-off-by: Maximilian Heyne <mheyne@amazon.de>
> Cc: <stable@vger.kernel.org> # 5.4+

The first hunk looks ok, the second doesn't make sense as fabrics
was only added with NVMe 1.2.2.  I can fix it up when applying if you
are ok with that.

But you guys really shouldn't be doing SR-IOV with 1.0 controllers
independent of this..

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

* Re: [PATCH] nvme: validate cntlid's only for nvme >= 1.1.0
  2020-06-30 13:33 ` Christoph Hellwig
@ 2020-06-30 13:36   ` Christoph Hellwig
  2020-06-30 14:01     ` Maximilian Heyne
  0 siblings, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2020-06-30 13:36 UTC (permalink / raw)
  To: Maximilian Heyne
  Cc: Amit Shah, stable, Keith Busch, Jens Axboe, Christoph Hellwig,
	Sagi Grimberg, linux-nvme, linux-kernel

On Tue, Jun 30, 2020 at 03:33:58PM +0200, Christoph Hellwig wrote:
> On Tue, Jun 30, 2020 at 12:29:23PM +0000, Maximilian Heyne wrote:
> > Controller ID's (cntlid) for NVMe devices were introduced in version
> > 1.1.0 of the specification. Controllers that follow the older 1.0.0 spec
> > don't set this field so it doesn't make sense to validate it. On the
> > contrary, when using SR-IOV this check breaks VFs as they are all part
> > of the same NVMe subsystem.
> > 
> > Signed-off-by: Maximilian Heyne <mheyne@amazon.de>
> > Cc: <stable@vger.kernel.org> # 5.4+
> 
> The first hunk looks ok, the second doesn't make sense as fabrics
> was only added with NVMe 1.2.2.  I can fix it up when applying if you
> are ok with that.
> 
> But you guys really shouldn't be doing SR-IOV with 1.0 controllers
> independent of this..

And actually - 1.0 did not have the concept of a subsystem.  So having
a duplicate serial number for a 1.0 controller actually is a pretty
nasty bug.  Can you point me to this broken controller?  Do you think
the OEM could fix it up to report a proper version number and controller
ID?

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

* Re: [PATCH] nvme: validate cntlid's only for nvme >= 1.1.0
  2020-06-30 13:36   ` Christoph Hellwig
@ 2020-06-30 14:01     ` Maximilian Heyne
  2020-06-30 14:08       ` Keith Busch
  0 siblings, 1 reply; 5+ messages in thread
From: Maximilian Heyne @ 2020-06-30 14:01 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Amit Shah, stable, Keith Busch, Jens Axboe, Sagi Grimberg,
	linux-nvme, linux-kernel



On 6/30/20 3:36 PM, Christoph Hellwig wrote:
> On Tue, Jun 30, 2020 at 03:33:58PM +0200, Christoph Hellwig wrote:
>> On Tue, Jun 30, 2020 at 12:29:23PM +0000, Maximilian Heyne wrote:
>>> Controller ID's (cntlid) for NVMe devices were introduced in version
>>> 1.1.0 of the specification. Controllers that follow the older 1.0.0 spec
>>> don't set this field so it doesn't make sense to validate it. On the
>>> contrary, when using SR-IOV this check breaks VFs as they are all part
>>> of the same NVMe subsystem.
>>>
>>> Signed-off-by: Maximilian Heyne <mheyne@amazon.de>
>>> Cc: <stable@vger.kernel.org> # 5.4+
>>
>> The first hunk looks ok, the second doesn't make sense as fabrics
>> was only added with NVMe 1.2.2.  I can fix it up when applying if you
>> are ok with that.

I'd be totally ok with that.

>>
>> But you guys really shouldn't be doing SR-IOV with 1.0 controllers
>> independent of this..

So far it worked...

> 
> And actually - 1.0 did not have the concept of a subsystem.  So having
> a duplicate serial number for a 1.0 controller actually is a pretty
> nasty bug.  Can you point me to this broken controller?  Do you think
> the OEM could fix it up to report a proper version number and controller
> ID?
> 

I meant that the VF NVMe controllers will all land in the same subsystem from
the kernel's point of view, because, as you said, there was no idea of different
subsystems in the 1.0 spec.
It's an older in-house controller. Seems to set the same serial number for all
VF's. Should the firmware set unique serials for the VF's instead?

Thanks
Max



Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss
Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879



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

* Re: [PATCH] nvme: validate cntlid's only for nvme >= 1.1.0
  2020-06-30 14:01     ` Maximilian Heyne
@ 2020-06-30 14:08       ` Keith Busch
  0 siblings, 0 replies; 5+ messages in thread
From: Keith Busch @ 2020-06-30 14:08 UTC (permalink / raw)
  To: Maximilian Heyne
  Cc: Christoph Hellwig, Amit Shah, stable, Jens Axboe, Sagi Grimberg,
	linux-nvme, linux-kernel

On Tue, Jun 30, 2020 at 04:01:45PM +0200, Maximilian Heyne wrote:
> On 6/30/20 3:36 PM, Christoph Hellwig wrote:
> > And actually - 1.0 did not have the concept of a subsystem.  So having
> > a duplicate serial number for a 1.0 controller actually is a pretty
> > nasty bug.  Can you point me to this broken controller?  Do you think
> > the OEM could fix it up to report a proper version number and controller
> > ID?
> > 
> 
> I meant that the VF NVMe controllers will all land in the same subsystem from
> the kernel's point of view, because, as you said, there was no idea of different
> subsystems in the 1.0 spec.

Each controller should have landed in its own subsystem in this case
rather than the same subsystem.

> It's an older in-house controller. Seems to set the same serial number for all
> VF's. Should the firmware set unique serials for the VF's instead?

Yes, the driver shouldn't be finding duplicate serial numbers.

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

end of thread, other threads:[~2020-06-30 14:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-30 12:29 [PATCH] nvme: validate cntlid's only for nvme >= 1.1.0 Maximilian Heyne
2020-06-30 13:33 ` Christoph Hellwig
2020-06-30 13:36   ` Christoph Hellwig
2020-06-30 14:01     ` Maximilian Heyne
2020-06-30 14:08       ` Keith Busch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).