[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC 1/5] block/nvme: use some NVME_CAP_* macros
From: |
Auger Eric |
Subject: |
Re: [RFC 1/5] block/nvme: use some NVME_CAP_* macros |
Date: |
Thu, 15 Oct 2020 18:11:56 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 |
Hi Philippe,
On 10/15/20 3:36 PM, Philippe Mathieu-Daudé wrote:
> On 10/15/20 3:32 PM, Philippe Mathieu-Daudé wrote:
>> On 10/15/20 3:29 PM, Philippe Mathieu-Daudé wrote:
>>> On 10/15/20 1:52 PM, Eric Auger wrote:
>>>> let's use NVME_CAP_DSTRD, NVME_CAP_MPSMIN and NVME_CAP_TO macros
>>>>
>>>> Signed-off-by: Eric Auger <eric.auger@redhat.com>
>>>> ---
>>>> block/nvme.c | 6 +++---
>>>> 1 file changed, 3 insertions(+), 3 deletions(-)
>>>>
>>>> diff --git a/block/nvme.c b/block/nvme.c
>>>> index f4f27b6da7..e3d96f20d0 100644
>>>> --- a/block/nvme.c
>>>> +++ b/block/nvme.c
>>>> @@ -728,10 +728,10 @@ static int nvme_init(BlockDriverState *bs,
>>>> const char *device, int namespace,
>>>> goto out;
>>>> }
>>>> - s->page_size = MAX(4096, 1 << (12 + ((cap >> 48) & 0xF)));
>>>> - s->doorbell_scale = (4 << (((cap >> 32) & 0xF))) /
>>>> sizeof(uint32_t);
>>>> + s->page_size = MAX(4096, 1 << (12 + NVME_CAP_MPSMIN(cap)));
>>>
>>> Are you suggesting commit fad1eb68862 ("block/nvme: Use register
>>> definitions from 'block/nvme.h'") is buggy?
yes I think so. Sorry I messed up my rebase and failed to grab that patch.
>>
>> Buh I wonder how we missed that :/
>
> Since your patch doesn't apply anyway, I might fix as:
>
> s->page_size = 4096 << NVME_CAP_MPSMIN(cap);
1 << (12 + NVME_CAP_MPSMIN(cap)) matches the spec text so personally I
would keep that.
Thanks
Eric
>
>>
>>>
>>>> + s->doorbell_scale = (4 << ((NVME_CAP_DSTRD(cap)))) /
>>>> sizeof(uint32_t);
>>>> bs->bl.opt_mem_alignment = s->page_size;
>>>> - timeout_ms = MIN(500 * ((cap >> 24) & 0xFF), 30000);
>>>> + timeout_ms = MIN(500 * NVME_CAP_TO(cap), 30000);
>>>> /* Reset device to get a clean state. */
>>>> s->regs->ctrl.cc = cpu_to_le32(le32_to_cpu(s->regs->ctrl.cc) &
>>>> 0xFE);
>>>>
>>>
>>
>
>
[RFC 2/5] block/nvme: Change size and alignment of IDENTIFY response buffer, Eric Auger, 2020/10/15
[RFC 3/5] block/nvme: Change size and alignment of queue, Eric Auger, 2020/10/15
[RFC 4/5] block/nvme: Change size and alignment of prp_list_pages, Eric Auger, 2020/10/15
[RFC 5/5] block/nvme: Align iov's va and size on host page size, Eric Auger, 2020/10/15
Re: [RFC 0/5] NVMe passthrough: Support 64kB page host, Philippe Mathieu-Daudé, 2020/10/15