From: David Gibson <david@gibson.dropbear.id.au>
To: Vaibhav Jain <vaibhav@linux.ibm.com>
Cc: xiaoguangrong.eric@gmail.com, mst@redhat.com,
aneesh.kumar@linux.ibm.com, Greg Kurz <groug@kaod.org>,
kvm-ppc@vger.kernel.org, qemu-devel@nongnu.org,
shivaprasadbhat@gmail.com, qemu-ppc@nongnu.org,
bharata@linux.vnet.ibm.com, imammedo@redhat.com,
ehabkost@redhat.com
Subject: Re: [PATCH] ppc/spapr: Add support for implement support for H_SCM_HEALTH
Date: Wed, 31 Mar 2021 10:49:07 +1100 [thread overview]
Message-ID: <YGO488mqe2RMHBiu@yekko.fritz.box> (raw)
In-Reply-To: <87r1jwpo3p.fsf@vajain21.in.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 5403 bytes --]
On Tue, Mar 30, 2021 at 10:37:06PM +0530, Vaibhav Jain wrote:
>
> Thanks for looking into this patch Greg. My responses below inline.
>
>
> Greg Kurz <groug@kaod.org> writes:
>
> > Hi Vaibhav,
> >
> > Great to see you around :-)
>
> :-)
>
> >
> > On Mon, 29 Mar 2021 21:52:59 +0530
> > Vaibhav Jain <vaibhav@linux.ibm.com> wrote:
> >
> >> Add support for H_SCM_HEALTH hcall described at [1] for spapr
> >> nvdimms. This enables guest to detect the 'unarmed' status of a
> >> specific spapr nvdimm identified by its DRC and if its unarmed, mark
> >> the region backed by the nvdimm as read-only.
> >>
> >
> > Any chance that you can provide the documentation of this new hcall ?
> >
> H_SCM_HEALTH specifications is already documented in linux kernel
> documentation at
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/powerpc/papr_hcalls.rst
Putting a reference to that in the commit message would be a good idea.
> That documentation was added when kernel support for H_SCM_HEALTH hcall
> support was implemented in 5.9 kernel.
>
> >> The patch adds h_scm_health() to handle the H_SCM_HEALTH hcall which
> >> returns two 64-bit bitmaps (health bitmap, health bitmap mask) derived
> >> from 'struct nvdimm->unarmed' member.
> >>
> >> Linux kernel side changes to enable handling of 'unarmed' nvdimms for
> >> ppc64 are proposed at [2].
> >>
> >> References:
> >> [1] "Hypercall Op-codes (hcalls)"
> >> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/powerpc/papr_hcalls.rst
> >>
> >> [2] "powerpc/papr_scm: Mark nvdimm as unarmed if needed during probe"
> >> https://lore.kernel.org/linux-nvdimm/20210329113103.476760-1-vaibhav@linux.ibm.com/
> >>
> >> Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>
> >> ---
> >> hw/ppc/spapr_nvdimm.c | 30 ++++++++++++++++++++++++++++++
> >> include/hw/ppc/spapr.h | 4 ++--
> >> 2 files changed, 32 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/hw/ppc/spapr_nvdimm.c b/hw/ppc/spapr_nvdimm.c
> >> index b46c36917c..e38740036d 100644
> >> --- a/hw/ppc/spapr_nvdimm.c
> >> +++ b/hw/ppc/spapr_nvdimm.c
> >> @@ -31,6 +31,13 @@
> >> #include "qemu/range.h"
> >> #include "hw/ppc/spapr_numa.h"
> >>
> >> +/* DIMM health bitmap bitmap indicators */
> >> +/* SCM device is unable to persist memory contents */
> >> +#define PAPR_PMEM_UNARMED (1ULL << (63 - 0))
> >
> > This looks like PPC_BIT(0).
> >
> Yes, right. Will update the patch in v2 to use the PPC_BIT macro.
>
> >> +
> >> +/* Bits status indicators for health bitmap indicating unarmed dimm */
> >> +#define PAPR_PMEM_UNARMED_MASK (PAPR_PMEM_UNARMED)
> >> +
> >> bool spapr_nvdimm_validate(HotplugHandler *hotplug_dev, NVDIMMDevice *nvdimm,
> >> uint64_t size, Error **errp)
> >> {
> >> @@ -467,6 +474,28 @@ static target_ulong h_scm_unbind_all(PowerPCCPU *cpu, SpaprMachineState *spapr,
> >> return H_SUCCESS;
> >> }
> >>
> >> +static target_ulong h_scm_health(PowerPCCPU *cpu, SpaprMachineState *spapr,
> >> + target_ulong opcode, target_ulong *args)
> >> +{
> >> + uint32_t drc_index = args[0];
> >> + SpaprDrc *drc = spapr_drc_by_index(drc_index);
> >> + NVDIMMDevice *nvdimm;
> >> +
> >> + if (drc && spapr_drc_type(drc) != SPAPR_DR_CONNECTOR_TYPE_PMEM) {
> >> + return H_PARAMETER;
> >> + }
> >> +
> >> + nvdimm = NVDIMM(drc->dev);
> >
> > Yeah as already suggested by Shiva, drc->dev should be checked like
> > in h_scm_bind_mem().
> >
> Yes, will send a v2 with this case handled.
>
> >> +
> >> + /* Check if the nvdimm is unarmed and send its status via health bitmaps */
> >> + args[0] = nvdimm->unarmed ? PAPR_PMEM_UNARMED_MASK : 0;
> >> +
> >
> > Shouldn't ^^ use PAPR_PMEM_UNARMED then ?
> >
> >> + /* health bitmap mask same as the health bitmap */
> >> + args[1] = args[0];
> >> +
> >
> > If so, it seems that PAPR_PMEM_UNARMED_MASK isn't even needed.
>
> Definition of these defines are similar to what kernel implementation
> uses at
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/powerpc/platforms/pseries/papr_scm.c#n53
>
> Since unarmed condition can also arise due to an unhealthy nvdimm hence
> the kernel implementation uses a mask thats composed of two bits
> PPC_BIT(0) and PPC_BIT(6) being set. Though we arent using PPC_BIT(6)
> right now in qemu, it will change in future when better nvdimm health
> reporting will be done. Hence kept the PPC_BIT(0) define as well as the
> mask to mimic the kernel definitions.
>
> >
> > Having access to the excerpts from the PAPR addendum that describes
> > this hcall would _really_ help in reviewing.
> >
> The kernel documentation for H_SCM_HEALTH mentioned above captures most
> if not all parts of the PAPR addendum for this hcall. I believe it
> contains enough information to review the patch. If you still need more
> info than please let me know.
We've missed the qemu-6.0 cutoff, so this will be 6.1 material. I'll
await v2 for further review.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2021-03-31 0:06 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-29 16:22 [PATCH] ppc/spapr: Add support for implement support for H_SCM_HEALTH Vaibhav Jain
2021-03-30 6:38 ` Shivaprasad G Bhat
2021-03-30 8:38 ` Vaibhav Jain
2021-03-30 14:14 ` Greg Kurz
2021-03-30 17:07 ` Vaibhav Jain
2021-03-30 23:49 ` David Gibson [this message]
2021-03-31 3:49 ` Vaibhav Jain
2021-03-31 9:15 ` Greg Kurz
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=YGO488mqe2RMHBiu@yekko.fritz.box \
--to=david@gibson.dropbear.id.au \
--cc=aneesh.kumar@linux.ibm.com \
--cc=bharata@linux.vnet.ibm.com \
--cc=ehabkost@redhat.com \
--cc=groug@kaod.org \
--cc=imammedo@redhat.com \
--cc=kvm-ppc@vger.kernel.org \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=shivaprasadbhat@gmail.com \
--cc=vaibhav@linux.ibm.com \
--cc=xiaoguangrong.eric@gmail.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).