From: Klaus Jensen <its@irrelevant.dk>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: "Fam Zheng" <fam@euphon.net>, "Kevin Wolf" <kwolf@redhat.com>,
"Thomas Huth" <thuth@redhat.com>,
Qemu-block <qemu-block@nongnu.org>,
"Laurent Vivier" <lvivier@redhat.com>,
"Klaus Jensen" <k.jensen@samsung.com>,
"Gollu Appalanaidu" <anaidu.gollu@samsung.com>,
"QEMU Developers" <qemu-devel@nongnu.org>,
"Max Reitz" <mreitz@redhat.com>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"Keith Busch" <kbusch@kernel.org>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>
Subject: Re: [PATCH v3 1/5] hw/nvme: split pmrmsc register into upper and lower
Date: Mon, 19 Jul 2021 11:32:40 +0200 [thread overview]
Message-ID: <YPVGuGsGjFRWExzs@apples.localdomain> (raw)
In-Reply-To: <CAFEAcA8cynksH16VXGGUp5wCi_J1wsATa0CDoc9E-uRfDuzNzQ@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2503 bytes --]
On Jul 19 10:13, Peter Maydell wrote:
> On Wed, 14 Jul 2021 at 07:01, Klaus Jensen <its@irrelevant.dk> wrote:
> >
> > From: Klaus Jensen <k.jensen@samsung.com>
> >
> > The specification uses a set of 32 bit PMRMSCL and PMRMSCU registers to
> > make up the 64 bit logical PMRMSC register.
> >
> > Make it so.
> >
> > Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
> > ---
> > include/block/nvme.h | 31 ++++++++++++++++---------------
> > hw/nvme/ctrl.c | 9 +++++----
> > 2 files changed, 21 insertions(+), 19 deletions(-)
>
> > diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
> > index 2f0524e12a36..28299c6f3764 100644
> > --- a/hw/nvme/ctrl.c
> > +++ b/hw/nvme/ctrl.c
> > @@ -5916,11 +5916,12 @@ static void nvme_write_bar(NvmeCtrl *n, hwaddr offset, uint64_t data,
> > return;
> > }
> >
> > - n->bar.pmrmsc = (n->bar.pmrmsc & ~0xffffffff) | (data & 0xffffffff);
> > + n->bar.pmrmscl = data & 0xffffffff;
> > n->pmr.cmse = false;
> >
> > - if (NVME_PMRMSC_CMSE(n->bar.pmrmsc)) {
> > - hwaddr cba = NVME_PMRMSC_CBA(n->bar.pmrmsc) << PMRMSC_CBA_SHIFT;
> > + if (NVME_PMRMSCL_CMSE(n->bar.pmrmscl)) {
> > + hwaddr cba = n->bar.pmrmscu |
> > + (NVME_PMRMSCL_CBA(n->bar.pmrmscl) << PMRMSCL_CBA_SHIFT);
>
> Don't we need to shift n->bar.pmrmscu left by 32 before we OR it in
> with the pmrmscl part?
>
We do indeed - thanks for catching this!
> > if (cba + int128_get64(n->pmr.dev->mr.size) < cba) {
> > NVME_PMRSTS_SET_CBAI(n->bar.pmrsts, 1);
> > return;
> > @@ -5936,7 +5937,7 @@ static void nvme_write_bar(NvmeCtrl *n, hwaddr offset, uint64_t data,
> > return;
> > }
> >
> > - n->bar.pmrmsc = (n->bar.pmrmsc & 0xffffffff) | (data << 32);
> > + n->bar.pmrmscu = data & 0xffffffff;
> > return;
>
> Not an issue with this patch, but why don't we need to do the
> "update cba" stuff for a write to the U register that we do for
> a write to the L register? Does the spec mandate that guests
> do the writes in the order H then L and only the L change makes
> it take effect?
>
Yeah, bit 1 in PMRMSCL is the "Controller Memory Space Enable" bit
(CMSE) and we only enable the address space when that bit is set. So the
driver will typically write the high register first (if needed) and then
write the lower register with or without CMSE set.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2021-07-19 9:36 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-14 6:01 [PATCH v3 0/5] hw/nvme: fix mmio read Klaus Jensen
2021-07-14 6:01 ` [PATCH v3 1/5] hw/nvme: split pmrmsc register into upper and lower Klaus Jensen
[not found] ` <CGME20210714113905epcas5p3d582216af16ab401f806757cad6bcc8d@epcas5p3.samsung.com>
2021-07-14 11:35 ` Gollu Appalanaidu
2021-07-19 9:13 ` Peter Maydell
2021-07-19 9:32 ` Klaus Jensen [this message]
2021-07-14 6:01 ` [PATCH v3 2/5] hw/nvme: use symbolic names for registers Klaus Jensen
2021-07-14 9:08 ` Philippe Mathieu-Daudé
[not found] ` <CGME20210714114548epcas5p41a562395f6b695aabcfa4a531f2285d3@epcas5p4.samsung.com>
2021-07-14 11:42 ` Gollu Appalanaidu
2021-07-14 6:01 ` [PATCH v3 3/5] hw/nvme: fix out-of-bounds reads Klaus Jensen
2021-07-19 8:50 ` Stefan Hajnoczi
2021-07-19 9:15 ` Peter Maydell
2021-07-14 6:01 ` [PATCH v3 4/5] hw/nvme: fix mmio read Klaus Jensen
2021-07-19 9:52 ` Peter Maydell
2021-07-14 6:01 ` [PATCH v3 5/5] tests/qtest/nvme-test: add mmio read test Klaus Jensen
[not found] ` <CGME20210714120156epcas5p212ae986c7e2ed4d30191ce8915304d2c@epcas5p2.samsung.com>
2021-07-14 11:58 ` Gollu Appalanaidu
2021-07-19 6:43 ` [PATCH v3 0/5] hw/nvme: fix mmio read Klaus Jensen
2021-07-19 8:52 ` Stefan Hajnoczi
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=YPVGuGsGjFRWExzs@apples.localdomain \
--to=its@irrelevant.dk \
--cc=anaidu.gollu@samsung.com \
--cc=fam@euphon.net \
--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=philmd@redhat.com \
--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).