Re: [linux-yocto] [PATCH v5.2] nvme-pci: Set the prp2 correctly when using more than 4k page

2019-10-18 Thread Bruce Ashfield
In message: [PATCH v5.2] nvme-pci: Set the prp2 correctly when using more than 
4k page
on 19/10/2019 Kevin Hao wrote:

> commit a4f40484e7f1dff56bb9f286cc59ffa36e0259eb from
> git://git.infradead.org/nvme.git
> 
> In the current code, the nvme is using a fixed 4k PRP entry size,
> but if the kernel use a page size which is more than 4k, we should
> consider the situation that the bv_offset may be larger than the
> dev->ctrl.page_size. Otherwise we may miss setting the prp2 and then
> cause the command can't be executed correctly.
> 
> Fixes: dff824b2aadb ("nvme-pci: optimize mapping of small single segment 
> requests")
> Cc: sta...@vger.kernel.org
> Reviewed-by: Christoph Hellwig 
> Signed-off-by: Kevin Hao 
> Signed-off-by: Keith Busch 
> ---
> Hi Bruce,
> 
> This patch has already been merged into nvme-5.4 and I also CCed 
> sta...@vger.kernel.org,
> so in theory it could propagate to linux-yocto via the stable update.
> But this issue cause a critical malfunction for the nvme interface and
> block our validation for it. So I would like to pick this patch ASAP.
> We should merge this into v5.2/standard/base branch.

No problem. I was just looking at the queue, and since this was already
reviewed upstream and safe .. I jumped it to the front and have merged
and pushed it to the repo.

Bruce

> 
>  drivers/nvme/host/pci.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
> index 4b181969c432..869f462e6b6e 100644
> --- a/drivers/nvme/host/pci.c
> +++ b/drivers/nvme/host/pci.c
> @@ -773,7 +773,8 @@ static blk_status_t nvme_setup_prp_simple(struct nvme_dev 
> *dev,
>   struct bio_vec *bv)
>  {
>   struct nvme_iod *iod = blk_mq_rq_to_pdu(req);
> - unsigned int first_prp_len = dev->ctrl.page_size - bv->bv_offset;
> + unsigned int offset = bv->bv_offset & (dev->ctrl.page_size - 1);
> + unsigned int first_prp_len = dev->ctrl.page_size - offset;
>  
>   iod->first_dma = dma_map_bvec(dev->dev, bv, rq_dma_dir(req), 0);
>   if (dma_mapping_error(dev->dev, iod->first_dma))
> -- 
> 2.14.4
> 
-- 
___
linux-yocto mailing list
linux-yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/linux-yocto


[linux-yocto] [PATCH v5.2] nvme-pci: Set the prp2 correctly when using more than 4k page

2019-10-18 Thread Kevin Hao
commit a4f40484e7f1dff56bb9f286cc59ffa36e0259eb from
git://git.infradead.org/nvme.git

In the current code, the nvme is using a fixed 4k PRP entry size,
but if the kernel use a page size which is more than 4k, we should
consider the situation that the bv_offset may be larger than the
dev->ctrl.page_size. Otherwise we may miss setting the prp2 and then
cause the command can't be executed correctly.

Fixes: dff824b2aadb ("nvme-pci: optimize mapping of small single segment 
requests")
Cc: sta...@vger.kernel.org
Reviewed-by: Christoph Hellwig 
Signed-off-by: Kevin Hao 
Signed-off-by: Keith Busch 
---
Hi Bruce,

This patch has already been merged into nvme-5.4 and I also CCed 
sta...@vger.kernel.org,
so in theory it could propagate to linux-yocto via the stable update.
But this issue cause a critical malfunction for the nvme interface and
block our validation for it. So I would like to pick this patch ASAP.
We should merge this into v5.2/standard/base branch.

 drivers/nvme/host/pci.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 4b181969c432..869f462e6b6e 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -773,7 +773,8 @@ static blk_status_t nvme_setup_prp_simple(struct nvme_dev 
*dev,
struct bio_vec *bv)
 {
struct nvme_iod *iod = blk_mq_rq_to_pdu(req);
-   unsigned int first_prp_len = dev->ctrl.page_size - bv->bv_offset;
+   unsigned int offset = bv->bv_offset & (dev->ctrl.page_size - 1);
+   unsigned int first_prp_len = dev->ctrl.page_size - offset;
 
iod->first_dma = dma_map_bvec(dev->dev, bv, rq_dma_dir(req), 0);
if (dma_mapping_error(dev->dev, iod->first_dma))
-- 
2.14.4

-- 
___
linux-yocto mailing list
linux-yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/linux-yocto