[PATCH] hw/nvme: fix number of PIDs for FDP RUH update

Vincent Fu posted 1 patch 2 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20240503175004.1573-1-vincent.fu@samsung.com
Maintainers: Keith Busch <kbusch@kernel.org>, Klaus Jensen <its@irrelevant.dk>, Jesper Devantier <foss@defmacro.it>
hw/nvme/ctrl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] hw/nvme: fix number of PIDs for FDP RUH update
Posted by Vincent Fu 2 weeks ago
The number of PIDs is in the upper 16 bits of cdw10. So we need to
right-shift by 16 bits instead of only a single bit.

Signed-off-by: Vincent Fu <vincent.fu@samsung.com>
---
 hw/nvme/ctrl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
index 127c3d2383..e89f9f7808 100644
--- a/hw/nvme/ctrl.c
+++ b/hw/nvme/ctrl.c
@@ -4352,7 +4352,7 @@ static uint16_t nvme_io_mgmt_send_ruh_update(NvmeCtrl *n, NvmeRequest *req)
     NvmeNamespace *ns = req->ns;
     uint32_t cdw10 = le32_to_cpu(cmd->cdw10);
     uint16_t ret = NVME_SUCCESS;
-    uint32_t npid = (cdw10 >> 1) + 1;
+    uint32_t npid = (cdw10 >> 16) + 1;
     unsigned int i = 0;
     g_autofree uint16_t *pids = NULL;
     uint32_t maxnpid;
-- 
2.43.0
Re: [PATCH] hw/nvme: fix number of PIDs for FDP RUH update
Posted by Klaus Jensen 1 week, 4 days ago
On May  3 13:50, Vincent Fu wrote:
> The number of PIDs is in the upper 16 bits of cdw10. So we need to
> right-shift by 16 bits instead of only a single bit.
> 
> Signed-off-by: Vincent Fu <vincent.fu@samsung.com>
> ---
>  hw/nvme/ctrl.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
> index 127c3d2383..e89f9f7808 100644
> --- a/hw/nvme/ctrl.c
> +++ b/hw/nvme/ctrl.c
> @@ -4352,7 +4352,7 @@ static uint16_t nvme_io_mgmt_send_ruh_update(NvmeCtrl *n, NvmeRequest *req)
>      NvmeNamespace *ns = req->ns;
>      uint32_t cdw10 = le32_to_cpu(cmd->cdw10);
>      uint16_t ret = NVME_SUCCESS;
> -    uint32_t npid = (cdw10 >> 1) + 1;
> +    uint32_t npid = (cdw10 >> 16) + 1;
>      unsigned int i = 0;
>      g_autofree uint16_t *pids = NULL;
>      uint32_t maxnpid;
> -- 
> 2.43.0
> 

Hi Vincent,

Thanks, LGTM! Applied to nvme-next!

Reviewed-by: Klaus Jensen <k.jensen@samsung.com>

I'll also add,

Cc: qemu-stable@nongnu.org
Fixes: 73064edfb864 ("hw/nvme: flexible data placement emulation")