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.au...@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); >>>> >>> >> > >