[SeaBIOS] Re: [UNVERIFIED SENDER] [PATCH 1/3] nvme: Record maximum allowed request size

Sironi, Filippo posted 1 patch 3 weeks ago
Failed in applying to current master (apply log)
src/hw/nvme-int.h |  8 +++++++-
src/hw/nvme.c     | 13 +++++++++++--
2 files changed, 18 insertions(+), 3 deletions(-)

[SeaBIOS] Re: [UNVERIFIED SENDER] [PATCH 1/3] nvme: Record maximum allowed request size

Posted by Sironi, Filippo 3 weeks ago
________________________________________
From: Alexander Graf <graf@amazon.com>
Sent: Tuesday, September 29, 2020 20:36
To: seabios@seabios.org
Subject: [UNVERIFIED SENDER] [SeaBIOS] [PATCH 1/3] nvme: Record maximum allowed request size

NVMe has a limit on how many sectors it can handle at most within a single
request. Remember that number, so that in a follow-up patch, we can verify
that we don't exceed it.

Signed-off-by: Alexander Graf <graf@amazon.com>
---
 src/hw/nvme-int.h |  8 +++++++-
 src/hw/nvme.c     | 13 +++++++++++--
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/src/hw/nvme-int.h b/src/hw/nvme-int.h
index 9f95dd8..674008a 100644
--- a/src/hw/nvme-int.h
+++ b/src/hw/nvme-int.h
@@ -117,6 +117,7 @@ struct nvme_namespace {

     u32 block_size;
     u32 metadata_size;
+    u32 max_req_size;

     /* Page aligned buffer of size NVME_PAGE_SIZE. */
     char *dma_buffer;
@@ -131,7 +132,12 @@ struct nvme_identify_ctrl {
     char mn[40];
     char fr[8];

-    char _boring[516 - 72];
+    u8 rab;
+    u8 ieee[3];
+    u8 cmic;
+    u8 mdts;
+
+    char _boring[516 - 78];

     u32 nn;                     /* number of namespaces */
 };
diff --git a/src/hw/nvme.c b/src/hw/nvme.c
index 6a01204..2cde6a7 100644
--- a/src/hw/nvme.c
+++ b/src/hw/nvme.c
@@ -238,7 +238,8 @@ nvme_admin_identify_ns(struct nvme_ctrl *ctrl, u32 ns_id)
 }

 static void
-nvme_probe_ns(struct nvme_ctrl *ctrl, struct nvme_namespace *ns, u32 ns_id)
+nvme_probe_ns(struct nvme_ctrl *ctrl, struct nvme_namespace *ns, u32 ns_id,
+              u8 mdts)
 {
     ns->ctrl  = ctrl;
     ns->ns_id = ns_id;
@@ -281,6 +282,14 @@ nvme_probe_ns(struct nvme_ctrl *ctrl, struct nvme_namespace *ns, u32 ns_id)
     ns->drive.blksize   = ns->block_size;
     ns->drive.sectors   = ns->lba_count;

+    if (mdts) {
+        ns->max_req_size = 1U << mdts;
+        dprintf(3, "NVME NS %u max request size: %d sectors\n",
+                ns->max_req_size);

The use of dprintf is incorrect, you're only providing one variable to print instead of two. You're missing the number of sectors.

+    } else {
+        ns->max_req_size = -1U;
+    }
+
     ns->dma_buffer = zalloc_page_aligned(&ZoneHigh, NVME_PAGE_SIZE);

     char *desc = znprintf(MAXDESCSIZE, "NVMe NS %u: %llu MiB (%llu %u-byte "
@@ -567,7 +576,7 @@ nvme_controller_enable(struct nvme_ctrl *ctrl)
     /* Populate namespace IDs */
     int ns_idx;
     for (ns_idx = 0; ns_idx < ctrl->ns_count; ns_idx++) {
-        nvme_probe_ns(ctrl, &ctrl->ns[ns_idx], ns_idx + 1);
+        nvme_probe_ns(ctrl, &ctrl->ns[ns_idx], ns_idx + 1, identify->mdts);
     }

     dprintf(3, "NVMe initialization complete!\n");
--
2.16.4




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


_______________________________________________
SeaBIOS mailing list -- seabios@seabios.org
To unsubscribe send an email to seabios-leave@seabios.org



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


_______________________________________________
SeaBIOS mailing list -- seabios@seabios.org
To unsubscribe send an email to seabios-leave@seabios.org

[SeaBIOS] Re: [PATCH 1/3] nvme: Record maximum allowed request size

Posted by Alexander Graf 3 weeks ago

On 30.09.20 12:22, Sironi, Filippo wrote:
> ________________________________________
> From: Alexander Graf <graf@amazon.com>
> Sent: Tuesday, September 29, 2020 20:36
> To: seabios@seabios.org
> Subject: [UNVERIFIED SENDER] [SeaBIOS] [PATCH 1/3] nvme: Record maximum allowed request size
> 
> NVMe has a limit on how many sectors it can handle at most within a single
> request. Remember that number, so that in a follow-up patch, we can verify
> that we don't exceed it.
> 
> Signed-off-by: Alexander Graf <graf@amazon.com>
> ---
>   src/hw/nvme-int.h |  8 +++++++-
>   src/hw/nvme.c     | 13 +++++++++++--
>   2 files changed, 18 insertions(+), 3 deletions(-)
> 
> diff --git a/src/hw/nvme-int.h b/src/hw/nvme-int.h
> index 9f95dd8..674008a 100644
> --- a/src/hw/nvme-int.h
> +++ b/src/hw/nvme-int.h
> @@ -117,6 +117,7 @@ struct nvme_namespace {
> 
>       u32 block_size;
>       u32 metadata_size;
> +    u32 max_req_size;
> 
>       /* Page aligned buffer of size NVME_PAGE_SIZE. */
>       char *dma_buffer;
> @@ -131,7 +132,12 @@ struct nvme_identify_ctrl {
>       char mn[40];
>       char fr[8];
> 
> -    char _boring[516 - 72];
> +    u8 rab;
> +    u8 ieee[3];
> +    u8 cmic;
> +    u8 mdts;
> +
> +    char _boring[516 - 78];
> 
>       u32 nn;                     /* number of namespaces */
>   };
> diff --git a/src/hw/nvme.c b/src/hw/nvme.c
> index 6a01204..2cde6a7 100644
> --- a/src/hw/nvme.c
> +++ b/src/hw/nvme.c
> @@ -238,7 +238,8 @@ nvme_admin_identify_ns(struct nvme_ctrl *ctrl, u32 ns_id)
>   }
> 
>   static void
> -nvme_probe_ns(struct nvme_ctrl *ctrl, struct nvme_namespace *ns, u32 ns_id)
> +nvme_probe_ns(struct nvme_ctrl *ctrl, struct nvme_namespace *ns, u32 ns_id,
> +              u8 mdts)
>   {
>       ns->ctrl  = ctrl;
>       ns->ns_id = ns_id;
> @@ -281,6 +282,14 @@ nvme_probe_ns(struct nvme_ctrl *ctrl, struct nvme_namespace *ns, u32 ns_id)
>       ns->drive.blksize   = ns->block_size;
>       ns->drive.sectors   = ns->lba_count;
> 
> +    if (mdts) {
> +        ns->max_req_size = 1U << mdts;
> +        dprintf(3, "NVME NS %u max request size: %d sectors\n",
> +                ns->max_req_size);
> 
> The use of dprintf is incorrect, you're only providing one variable to print instead of two. You're missing the number of sectors.

Yikes, I fixed that one locally before I hit git format-patch. I 
promise! My machine probably just went back in time and pulled this 
broken state out of the abyss :).

Kidding aside, I'll submit the right one for v2. Thanks for noticing!


Alex



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


_______________________________________________
SeaBIOS mailing list -- seabios@seabios.org
To unsubscribe send an email to seabios-leave@seabios.org