From: Jerry Hoemann <jerry.hoemann@hpe.com>
To: Dan Williams <dan.j.williams@intel.com>
Cc: "linux-nvdimm@lists.01.org" <linux-nvdimm@lists.01.org>
Subject: Re: [PATCH v8 05/10] nvdimm: Add IOCTL pass thru functions
Date: Mon, 11 Apr 2016 17:43:41 -0600 [thread overview]
Message-ID: <20160411234341.GC119165@tevye.fc.hp.com> (raw)
In-Reply-To: <CAPcyv4jZf0udsY3aPCGxqLFi6Dvrn14oV0C8UBMX6VhOzEuk2w@mail.gmail.com>
On Mon, Apr 11, 2016 at 12:15:14PM -0700, Dan Williams wrote:
> On Mon, Mar 21, 2016 at 12:37 PM, Jerry Hoemann <jerry.hoemann@hpe.com> wrote:
> > Add ioctl command ND_CMD_CALL_DSM to acpi_nfit_ctl and __nd_ioctl which
> > allow kernel to call a nvdimm's _DSM as a passthru without using the
> > marshaling code of the nd_cmd_desc.
> >
> > Signed-off-by: Jerry Hoemann <jerry.hoemann@hpe.com>
> > ---
> > drivers/acpi/nfit.c | 141 ++++++++++++++++++++++++++++++++++++++++++++-------
> > drivers/nvdimm/bus.c | 43 +++++++++++++++-
> > 2 files changed, 166 insertions(+), 18 deletions(-)
> >
> > diff --git a/drivers/acpi/nfit.c b/drivers/acpi/nfit.c
> > index d0f35e6..9511ab4 100644
> > --- a/drivers/acpi/nfit.c
> > +++ b/drivers/acpi/nfit.c
> > @@ -56,6 +56,21 @@ struct nfit_table_prev {
> > struct list_head flushes;
> > };
> >
> > +struct cmd_family_tbl {
> > + enum nfit_uuids key_uuid; /* Internal handle */
> > + int key_type; /* Exported handle */
> > + int rev; /* _DSM rev */
> > + u64 mask; /* 0 bit excludes underlying func.*/
> > +};
> > +
> > +struct cmd_family_tbl nfit_cmd_family_tbl[] = {
> > + { NFIT_DEV_BUS, ND_TYPE_BUS, 1, ~0UL},
>
> Per the comment on patch2 lets kill this for now.
>
> > + { NFIT_DEV_DIMM, ND_TYPE_DIMM_INTEL1, 1, ~0UL},
> > + { NFIT_DEV_DIMM_N_HPE1, ND_TYPE_DIMM_N_HPE1, 1, ~0UL},
> > + { NFIT_DEV_DIMM_N_HPE2, ND_TYPE_DIMM_N_HPE2, 1, ~0UL},
>
> Why does the mask default to all supported? I assume this should be
> the known-valid mask for each type, i.e. 0x3fe for
> ND_TYPE_DIMM_INTEL1.
innocent until proven guilty.
This mask is bit and'd with mask returned by firmware, so mask
returned by firmware limits callers to those function firmware
supports.
My having this extra mask, it allows kernel a way to prevent user space
application from calling a certain function totally. e.g. if we
found that a function is dangerous or something that couldn't be
coordinated with the kernel's use of the function.
By not restricting it to currently defined functions, it allow testing
firmware that might be implemented a new function w/o having to give
firmware team a special kernel.
> >
> > +
> > +/*
> > + * determine if the _DSM specified by UUID is supported and return
> > + * mask of supported functions in nd_cmd_mask.
> > + */
> > +
> > +static int acpi_nfit_sup_func(acpi_handle handle, const u8 *uuid,
> > + int rev, unsigned long *nd_cmd_mask)
> > +{
> > + int i;
> > + u64 mask = 0;
> > + union acpi_object *obj;
> > +
> > + obj = acpi_evaluate_dsm(handle, uuid, rev, 0, NULL);
> > + if (!obj)
> > + return 0;
> > + /* For compatibility, old BIOSes may return an integer */
> > + if (obj->type == ACPI_TYPE_INTEGER)
> > + mask = obj->integer.value;
> > + else if (obj->type == ACPI_TYPE_BUFFER)
> > + for (i = 0; i < obj->buffer.length && i < 8; i++)
> > + mask |= (((u8)obj->buffer.pointer[i]) << (i * 8));
> > + ACPI_FREE(obj);
> > +
> > + *nd_cmd_mask = mask;
> > +
> > + return !!mask;
> > +}
> > +
> > +
> > +static inline void
> > +to_nfit_uuid_msk(acpi_handle handle, struct cmd_family_tbl *tbl,
> > + u8 const **cmd_uuid, unsigned long *cmd_mask)
> > +{
> > + unsigned long mask = 0;
> > + int i;
> > +
> > + for (i = 0; tbl[i].key_uuid >= 0 ; i++) {
> > + const u8 *uuid = to_nfit_uuid(tbl[i].key_uuid);
> > + int rev = tbl[i].rev;
> > +
> > + if (acpi_nfit_sup_func(handle, uuid, rev, &mask)) {
> > + *cmd_mask = mask & tbl[i].mask;
> > + *cmd_uuid = uuid;
> > + break;
> > + }
> > + }
> > +}
> > +
> > static int acpi_nfit_add_dimm(struct acpi_nfit_desc *acpi_desc,
> > struct nfit_mem *nfit_mem, u32 device_handle)
> > {
> > struct acpi_device *adev, *adev_dimm;
> > struct device *dev = acpi_desc->dev;
> > - const u8 *uuid = to_nfit_uuid(NFIT_DEV_DIMM);
> > - int i;
> >
> > nfit_mem->dsm_mask = acpi_desc->dimm_dsm_force_en;
> > adev = to_acpi_dev(acpi_desc);
> > @@ -939,9 +1045,8 @@ static int acpi_nfit_add_dimm(struct acpi_nfit_desc *acpi_desc,
> > return force_enable_dimms ? 0 : -ENODEV;
> > }
> >
> > - for (i = ND_CMD_SMART; i <= ND_CMD_VENDOR; i++)
> > - if (acpi_check_dsm(adev_dimm->handle, uuid, 1, 1ULL << i))
> > - set_bit(i, &nfit_mem->dsm_mask);
> > + to_nfit_uuid_msk(adev_dimm->handle, nfit_cmd_family_tbl,
> > + &nfit_mem->dsm_uuid, &nfit_mem->dsm_mask);
>
> Why is this replacing acpi_check_dsm() with an open-coded implementation?
Not sure of the question.
Is it why acpi_nfit_sup_func? or why to_nfit_uuid_msk?
if why to_nfit_uuid_msk? We need to determine both mask and uuid
(previously uuid was assumed.)
if why acpi_nfit_sup_func? A few reasons.
Want to allow user space to get mask. This is a "safe" way to know
that calls are being made to/returned from firmware.
Didn't want to hard code upper limit on function (at least not less
than having function 0 .. 63 which the acpi layer is doing.)
Finally didn't want to call acpi_check_dsm 64 times per nvdimm. :)
But, we can go back to iterating over 0..63, both work.
Question, if non-root nodes are changed from DSM to LSM, won't
we need to add a function for that?
--
-----------------------------------------------------------------------------
Jerry Hoemann Software Engineer Hewlett Packard Enterprise
-----------------------------------------------------------------------------
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
next prev parent reply other threads:[~2016-04-11 23:43 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-21 19:37 [PATCH v8 00/10] nvdimm: Add an IOCTL pass thru for DSM calls Jerry Hoemann
2016-03-21 19:37 ` [PATCH v8 01/10] ACPI / util: Fix acpi_evaluate_dsm() argument type Jerry Hoemann
2016-03-21 19:37 ` [PATCH v8 02/10] nvdimm: Add wrapper for IOCTL pass thru Jerry Hoemann
2016-04-11 18:21 ` Dan Williams
2016-04-11 23:16 ` Jerry Hoemann
2016-04-11 23:23 ` Dan Williams
2016-04-12 0:19 ` Jerry Hoemann
2016-04-12 0:27 ` Dan Williams
2016-03-21 19:37 ` [PATCH v8 03/10] nvdimm: Increase max envelope size for IOCTL Jerry Hoemann
2016-03-21 19:37 ` [PATCH v8 04/10] nvdimm: Add UUIDs Jerry Hoemann
2016-04-11 18:25 ` Dan Williams
2016-03-21 19:37 ` [PATCH v8 05/10] nvdimm: Add IOCTL pass thru functions Jerry Hoemann
2016-04-11 19:15 ` Dan Williams
2016-04-11 23:43 ` Jerry Hoemann [this message]
2016-04-12 0:18 ` Dan Williams
2016-03-21 19:37 ` [PATCH v8 06/10] libnvdimm: nvdimm_bus_descriptor field name change Jerry Hoemann
2016-03-21 19:37 ` [PATCH v8 07/10] tools/testing/nvdimm: 'call_dsm' support Jerry Hoemann
2016-03-21 19:37 ` [PATCH v8 08/10] nvdimm: command ioctl support Jerry Hoemann
2016-03-21 19:37 ` [PATCH v8 09/10] nvdimm: sysfs shows which dsm support full command ioctl Jerry Hoemann
2016-04-11 21:43 ` Dan Williams
2016-04-11 23:58 ` Jerry Hoemann
2016-04-12 0:30 ` Dan Williams
2016-04-12 21:41 ` Jerry Hoemann
2016-04-12 22:05 ` Dan Williams
2016-04-14 22:58 ` Jerry Hoemann
2016-04-15 2:49 ` Dan Williams
2016-03-21 20:55 ` [PATCH v8 10/10] nvdimm: Add ioctl to return command mask Jerry Hoemann
2016-03-29 20:39 ` [PATCH v8 00/10] nvdimm: Add an IOCTL pass thru for DSM calls Jerry Hoemann
2016-04-11 22:19 ` Dan Williams
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=20160411234341.GC119165@tevye.fc.hp.com \
--to=jerry.hoemann@hpe.com \
--cc=dan.j.williams@intel.com \
--cc=linux-nvdimm@lists.01.org \
/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