[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 03/19] block/nvme: Introduce device/iommu 'page_size_min'
From: |
Stefan Hajnoczi |
Subject: |
Re: [PATCH v2 03/19] block/nvme: Introduce device/iommu 'page_size_min' variables |
Date: |
Tue, 27 Oct 2020 09:32:21 +0000 |
On Mon, Oct 26, 2020 at 11:54:48AM +0100, Philippe Mathieu-Daudé wrote:
> Introduce device/iommu 'page_size_min' variables to make
> the code clearer.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> block/nvme.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/block/nvme.c b/block/nvme.c
> index aa290996679..5abd7257cac 100644
> --- a/block/nvme.c
> +++ b/block/nvme.c
> @@ -690,6 +690,8 @@ static int nvme_init(BlockDriverState *bs, const char
> *device, int namespace,
> uint64_t deadline, now;
> Error *local_err = NULL;
> volatile NvmeBar *regs = NULL;
> + size_t device_page_size_min;
> + size_t iommu_page_size_min = 4096;
>
> qemu_co_mutex_init(&s->dma_map_lock);
> qemu_co_queue_init(&s->dma_flush_queue);
> @@ -724,7 +726,8 @@ static int nvme_init(BlockDriverState *bs, const char
> *device, int namespace,
> goto out;
> }
>
> - s->page_size = MAX(4096, 1u << (12 + NVME_CAP_MPSMIN(cap)));
> + device_page_size_min = 1u << (12 + NVME_CAP_MPSMIN(cap));
> + s->page_size = MAX(iommu_page_size_min, device_page_size_min);
It's not clear to me that the 4096 value is related to the IOMMU page
size here. The MAX(4096) expression seems like a sanity-check to me. An
MPS value of 0 is a 4KB page size, so it's never possible to express a
smaller page size. I guess MAX() was used in case a device incorrectly
reports MPSMIN.
I think introducing the concept of IOMMU page size is premature and
maybe not the intention of the existing code, but the concept will be
needed soon, so this patch is okay:
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
signature.asc
Description: PGP signature
- [PATCH v2 00/19] util/vfio-helpers: Allow using multiple MSIX IRQs, Philippe Mathieu-Daudé, 2020/10/26
- [PATCH v2 01/19] block/nvme: Correct minimum device page size, Philippe Mathieu-Daudé, 2020/10/26
- [PATCH v2 02/19] block/nvme: Set request_alignment at initialization, Philippe Mathieu-Daudé, 2020/10/26
- [PATCH v2 03/19] block/nvme: Introduce device/iommu 'page_size_min' variables, Philippe Mathieu-Daudé, 2020/10/26
- [PATCH v2 04/19] block/nvme: Trace controller capabilities, Philippe Mathieu-Daudé, 2020/10/26
- [PATCH v2 05/19] util/vfio-helpers: Improve reporting unsupported IOMMU type, Philippe Mathieu-Daudé, 2020/10/26
- [PATCH v2 07/19] util/vfio-helpers: Trace PCI BAR region info, Philippe Mathieu-Daudé, 2020/10/26
- [PATCH v2 06/19] util/vfio-helpers: Trace PCI I/O config accesses, Philippe Mathieu-Daudé, 2020/10/26
- [PATCH v2 08/19] util/vfio-helpers: Trace where BARs are mapped, Philippe Mathieu-Daudé, 2020/10/26
- [PATCH v2 09/19] util/vfio-helpers: Improve DMA trace events, Philippe Mathieu-Daudé, 2020/10/26