From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Klaus Jensen <its@irrelevant.dk>, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Fam Zheng <fam@euphon.net>,
Thomas Huth <thuth@redhat.com>,
qemu-block@nongnu.org, Peter Maydell <peter.maydell@linaro.org>,
Laurent Vivier <lvivier@redhat.com>,
Klaus Jensen <k.jensen@samsung.com>,
Gollu Appalanaidu <anaidu.gollu@samsung.com>,
Max Reitz <mreitz@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
Keith Busch <kbusch@kernel.org>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH v2 2/5] hw/nvme: use symbolic names for registers
Date: Wed, 14 Jul 2021 00:21:07 +0200 [thread overview]
Message-ID: <4864a63f-f829-91ae-3f48-428af05d2152@redhat.com> (raw)
In-Reply-To: <306b8373-079f-5000-e70c-041ab18c320f@redhat.com>
On 7/14/21 12:12 AM, Philippe Mathieu-Daudé wrote:
> On 7/13/21 9:24 PM, Klaus Jensen wrote:
>> From: Klaus Jensen <k.jensen@samsung.com>
>>
>> Add the NvmeBarRegs enum and use these instead of explicit register
>> offsets.
>>
>> Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
>> ---
>> include/block/nvme.h | 27 +++++++++++++++++++++++++++
>> hw/nvme/ctrl.c | 44 ++++++++++++++++++++++----------------------
>> 2 files changed, 49 insertions(+), 22 deletions(-)
>>
>> diff --git a/include/block/nvme.h b/include/block/nvme.h
>> index 84053b68b987..082d4bddbf9f 100644
>> --- a/include/block/nvme.h
>> +++ b/include/block/nvme.h
>> @@ -31,6 +31,33 @@ typedef struct QEMU_PACKED NvmeBar {
>> uint8_t css[484];
>> } NvmeBar;
>>
>> +enum NvmeBarRegs {
>> + NVME_REG_CAP = 0x0,
>> + NVME_REG_VS = 0x8,
>> + NVME_REG_INTMS = 0xc,
>> + NVME_REG_INTMC = 0x10,
>> + NVME_REG_CC = 0x14,
>> + NVME_REG_CSTS = 0x1c,
>> + NVME_REG_NSSR = 0x20,
>> + NVME_REG_AQA = 0x24,
>> + NVME_REG_ASQ = 0x28,
>> + NVME_REG_ACQ = 0x30,
>> + NVME_REG_CMBLOC = 0x38,
>> + NVME_REG_CMBSZ = 0x3c,
>> + NVME_REG_BPINFO = 0x40,
>> + NVME_REG_BPRSEL = 0x44,
>> + NVME_REG_BPMBL = 0x48,
>> + NVME_REG_CMBMSC = 0x50,
>> + NVME_REG_CMBSTS = 0x58,
>> + NVME_REG_PMRCAP = 0xe00,
>> + NVME_REG_PMRCTL = 0xe04,
>> + NVME_REG_PMRSTS = 0xe08,
>> + NVME_REG_PMREBS = 0xe0c,
>> + NVME_REG_PMRSWTP = 0xe10,
>> + NVME_REG_PMRMSCL = 0xe14,
>> + NVME_REG_PMRMSCU = 0xe18,
>> +};
>> +
>> enum NvmeCapShift {
>> CAP_MQES_SHIFT = 0,
>> CAP_CQR_SHIFT = 16,
>> diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
>> index 28299c6f3764..8c305315f41c 100644
>> --- a/hw/nvme/ctrl.c
>> +++ b/hw/nvme/ctrl.c
>> @@ -5740,7 +5740,7 @@ static void nvme_write_bar(NvmeCtrl *n, hwaddr offset, uint64_t data,
>> }
>>
>> switch (offset) {
>> - case 0xc: /* INTMS */
>> + case NVME_REG_INTMS:
>
> What about using offsetof(NvmeBar, intms) instead?
BTW I'm not suggesting this is better, I just wonder how we can avoid
to duplicate the definitions. Alternative is declaring:
enum NvmeBarRegs {
NVME_REG_CAP = offsetof(NvmeBar, cap),
NVME_REG_VS = offsetof(NvmeBar, vs),
...
Or keeping your patch.
next prev parent reply other threads:[~2021-07-13 22:33 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-13 19:24 [PATCH v2 0/5] hw/nvme: fix mmio read Klaus Jensen
2021-07-13 19:24 ` [PATCH v2 1/5] hw/nvme: split pmrmsc register into upper and lower Klaus Jensen
2021-07-13 19:24 ` [PATCH v2 2/5] hw/nvme: use symbolic names for registers Klaus Jensen
2021-07-13 22:12 ` Philippe Mathieu-Daudé
2021-07-13 22:21 ` Philippe Mathieu-Daudé [this message]
2021-07-14 5:32 ` Klaus Jensen
2021-07-13 19:24 ` [PATCH v2 3/5] hw/nvme: fix out-of-bounds reads Klaus Jensen
2021-07-13 19:24 ` [PATCH v2 4/5] hw/nvme: fix mmio read Klaus Jensen
2021-07-13 22:18 ` Philippe Mathieu-Daudé
2021-07-14 5:32 ` Klaus Jensen
2021-07-13 19:24 ` [PATCH v2 5/5] tests/qtest/nvme-test: add mmio read test Klaus Jensen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4864a63f-f829-91ae-3f48-428af05d2152@redhat.com \
--to=philmd@redhat.com \
--cc=anaidu.gollu@samsung.com \
--cc=fam@euphon.net \
--cc=its@irrelevant.dk \
--cc=k.jensen@samsung.com \
--cc=kbusch@kernel.org \
--cc=kwolf@redhat.com \
--cc=lvivier@redhat.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).