Linux-NVDIMM Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Verma, Vishal L" <vishal.l.verma@intel.com>
To: "Williams, Dan J" <dan.j.williams@intel.com>
Cc: "linux-nvdimm@lists.01.org" <linux-nvdimm@lists.01.org>
Subject: Re: [PATCH v4] libnvdimm, btt: BTT updates for UEFI 2.7 format
Date: Wed, 28 Jun 2017 20:20:15 +0000	[thread overview]
Message-ID: <1498681119.6401.41.camel@intel.com> (raw)
In-Reply-To: <CAPcyv4hxNLNQ6d0P2tEOwU+LQ4gbc_WEYEOuZZ+zZYQJE3kw7Q@mail.gmail.com>

On Wed, 2017-06-28 at 13:14 -0700, Dan Williams wrote:
> On Wed, Jun 28, 2017 at 1:07 PM, Vishal Verma <vishal.l.verma@intel.co
> m> wrote:
> > The UEFI 2.7 specification defines an updated BTT metadata format,
> > bumping the revision to 2.0. Add support for the new format, while
> > retaining compatibility for the old 1.1 format.
> > 
> > Cc: Toshi Kani <toshi.kani@hpe.com>
> > Cc: Linda Knippers <linda.knippers@hpe.com>
> > Cc: Dan Williams <dan.j.williams@intel.com>
> > Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
> 
> [..]
> > diff --git a/drivers/nvdimm/namespace_devs.c
> > b/drivers/nvdimm/namespace_devs.c
> > index f05d9b0..09e7e76 100644
> > --- a/drivers/nvdimm/namespace_devs.c
> > +++ b/drivers/nvdimm/namespace_devs.c
> > @@ -1411,6 +1411,58 @@ static ssize_t dpa_extents_show(struct device
> > *dev,
> >  }
> >  static DEVICE_ATTR_RO(dpa_extents);
> > 
> > +static int btt_claim_class(struct device *dev)
> > +{
> > +       struct nd_region *nd_region = to_nd_region(dev->parent);
> > +       int i, loop_bitmask = 0;
> > +
> > +       for (i = 0; i < nd_region->ndr_mappings; i++) {
> > +               struct nd_mapping *nd_mapping = &nd_region-
> > >mapping[i];
> > +               struct nvdimm_drvdata *ndd = to_ndd(nd_mapping);
> > +               struct nd_namespace_index *nsindex;
> > +
> > +               nsindex = to_namespace_index(ndd, ndd->ns_current);
> > +               if (nsindex == NULL)
> > +                       loop_bitmask |= 1;
> > +               else {
> > +                       /* check whether existing labels are v1.1 or
> > v1.2 */
> > +                       if (__le16_to_cpu(nsindex->major) == 1
> > +                                       && __le16_to_cpu(nsindex-
> > >minor) == 1)
> > +                               loop_bitmask |= 2;
> > +                       else
> > +                               loop_bitmask |= 4;
> > +               }
> > +       }
> > +       /*
> > +        * If nsindex is null loop_bitmask's bit 0 will be set, and
> > if an index
> > +        * block is found, a v1.1 label for any mapping will set bit
> > 1, and a
> > +        * v1.2 label will set bit 2.
> > +        *
> > +        * At the end of the loop, only one of the three bits must
> > be set.
> > +        * If multiple bits were set, it means the different
> > mappings disagree
> > +        * about their labels, and this must be cleaned up first.
> > +        *
> > +        * If all the label index blocks are found to agree, nsindex
> > of NULL
> > +        * implies labels haven't been initialized yet, and when
> > they will,
> > +        * they will be of the 1.2 format, so we can assume BTT2.0
> > +        *
> > +        * If 1.1 labels are found, we enforce BTT1.1, and if 1.2
> > labels are
> > +        * found, we enforce BTT2.0
> > +        *
> > +        * If the loop was never entered, default to BTT1.1 (legacy
> > namespaces)
> > +        */
> > +       switch (loop_bitmask) {
> > +       case 0:
> > +       case 2:
> > +               return NVDIMM_CCLASS_BTT;
> > +       case 1:
> > +       case 4:
> > +               return NVDIMM_CCLASS_BTT2;
> > +       default:
> > +               return -ENXIO;
> > +       }
> 
> Clever, looks good to me. I'll get this queued.

Err Hold on, I just noticed I forgot to properly propagate the ENXIO in
__holder_class_store.

v5 incoming.
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

      reply	other threads:[~2017-06-28 20:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-28 20:07 [PATCH v4] libnvdimm, btt: BTT updates for UEFI 2.7 format Vishal Verma
2017-06-28 20:14 ` Dan Williams
2017-06-28 20:20   ` Verma, Vishal L [this message]

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=1498681119.6401.41.camel@intel.com \
    --to=vishal.l.verma@intel.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