1. 17 Oct, 2018 7 commits
    • Dan Williams's avatar
      acpi, nfit: Further restrict userspace ARS start requests · 59486121
      Dan Williams authored
      In addition to not allowing ARS start while the background thread is
      actively running, prevent ARS start while any scrub request is pending.
      
      This aligns the window for ARS start submission with the status of ARS
      reported via sysfs. Previously userspace could sneak its own ARS start
      requests in while sysfs reported -EBUSY.
      Reviewed-by: default avatarDave Jiang <dave.jiang@intel.com>
      Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
      59486121
    • Dan Williams's avatar
      acpi, nfit: Fix Address Range Scrub completion tracking · d3abaf43
      Dan Williams authored
      The Address Range Scrub implementation tried to skip running scrubs
      against ranges that were already scrubbed by the BIOS. Unfortunately
      that support also resulted in early scrub completions as evidenced by
      this debug output from nfit_test:
      
          nd_region region9: ARS: range 1 short complete
          nd_region region3: ARS: range 1 short complete
          nd_region region4: ARS: range 2 ARS start (0)
          nd_region region4: ARS: range 2 short complete
      
      ...i.e. completions without any indications that the scrub was started.
      
      This state of affairs was hard to see in the code due to the
      proliferation of state bits and mistakenly trying to track done state
      per-range when the completion is a global property of the bus.
      
      So, kill the four ARS state bits (ARS_REQ, ARS_REQ_REDO, ARS_DONE, and
      ARS_SHORT), and replace them with just 2 request flags ARS_REQ_SHORT and
      ARS_REQ_LONG. The implementation will still complete and reap the
      results of BIOS initiated ARS, but it will not attempt to use that
      information to affect the completion status of scrubbing the ranges from
      a Linux perspective.
      
      Instead, try to synchronously run a short ARS per range at init time and
      schedule a long scrub in the background. If ARS is busy with an ARS
      request, schedule both a short and a long scrub for when ARS returns to
      idle. This logic also satisfies the intent of what ARS_REQ_REDO was
      trying to achieve. The new rule is that the REQ flag stays set until the
      next successful ars_start() for that range.
      
      With the new policy that the REQ flags are not cleared until the next
      start, the implementation no longer loses requests as can be seen from
      the following log:
      
          nd_region region3: ARS: range 1 ARS start short (0)
          nd_region region9: ARS: range 1 ARS start short (0)
          nd_region region3: ARS: range 1 complete
          nd_region region4: ARS: range 2 ARS start short (0)
          nd_region region9: ARS: range 1 complete
          nd_region region9: ARS: range 1 ARS start long (0)
          nd_region region4: ARS: range 2 complete
          nd_region region3: ARS: range 1 ARS start long (0)
          nd_region region9: ARS: range 1 complete
          nd_region region3: ARS: range 1 complete
          nd_region region4: ARS: range 2 ARS start long (0)
          nd_region region4: ARS: range 2 complete
      
      ...note that the nfit_test emulated driver provides 2 buses, that is why
      some of the range indices are duplicated. Notice that each range
      now successfully completes a short and long scrub.
      
      Cc: <stable@vger.kernel.org>
      Fixes: 14c73f99 ("nfit, address-range-scrub: introduce nfit_spa->ars_state")
      Fixes: cc3d3458 ("acpi/nfit: queue issuing of ars when an uc error...")
      Reported-by: default avatarJacek Zloch <jacek.zloch@intel.com>
      Reported-by: default avatarKrzysztof Rusocki <krzysztof.rusocki@intel.com>
      Reviewed-by: default avatarDave Jiang <dave.jiang@intel.com>
      Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
      d3abaf43
    • David Howells's avatar
      UAPI: ndctl: Remove use of PAGE_SIZE · f366d322
      David Howells authored
      The macro PAGE_SIZE isn't valid outside of the kernel, so it should not
      appear in UAPI headers.
      
      Furthermore, the actual machine page size could theoretically change from
      an application's point of view if it's running in a container that gets
      migrated to another machine (say 4K/ppc64 to 64K/ppc64).
      
      Fixes: f2ba5a5b ("libnvdimm, namespace: make min namespace size 4K")
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
      f366d322
    • David Howells's avatar
      UAPI: ndctl: Fix g++-unsupported initialisation in headers · 9607871f
      David Howells authored
      The following code in the linux/ndctl header file:
      
      	static inline const char *nvdimm_bus_cmd_name(unsigned cmd)
      	{
      		static const char * const names[] = {
      			[ND_CMD_ARS_CAP] = "ars_cap",
      			[ND_CMD_ARS_START] = "ars_start",
      			[ND_CMD_ARS_STATUS] = "ars_status",
      			[ND_CMD_CLEAR_ERROR] = "clear_error",
      			[ND_CMD_CALL] = "cmd_call",
      		};
      
      		if (cmd < ARRAY_SIZE(names) && names[cmd])
      			return names[cmd];
      		return "unknown";
      	}
      
      is broken in a number of ways:
      
       (1) ARRAY_SIZE() is not generally defined.
      
       (2) g++ does not support "non-trivial" array initialisers fully yet.
      
       (3) Every file that calls this function will acquire a copy of names[].
      
      The same goes for nvdimm_cmd_name().
      
      Fix all three by converting to a switch statement where each case returns a
      string.  That way if cmd is a constant, the compiler can trivially reduce it
      and, if not, the compiler can use a shared lookup table if it thinks that is
      more efficient.
      
      A better way would be to remove these functions and their arrays from the
      header entirely.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
      9607871f
    • Dan Williams's avatar
      tools/testing/nvdimm: Populate dirty shutdown data · f1101766
      Dan Williams authored
      Allow the unit tests to verify the retrieval of the dirty shutdown
      count via smart commands, and allow the driver-load-time retrieval of
      the smart health payload to be simulated by nfit_test.
      Reviewed-by: default avatarKeith Busch <keith.busch@intel.com>
      Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
      f1101766
    • Dan Williams's avatar
      acpi, nfit: Collect shutdown status · 0ead1118
      Dan Williams authored
      Some NVDIMMs, in addition to providing an indication of whether the
      previous shutdown was clean, also provide a running count of lifetime
      dirty-shutdown events for the device. In anticipation of this
      functionality appearing on more devices arrange for the nfit driver to
      retrieve / cache this data at DIMM discovery time, and export it via
      sysfs.
      Reviewed-by: default avatarKeith Busch <keith.busch@intel.com>
      Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
      0ead1118
    • Dan Williams's avatar
      acpi, nfit: Introduce nfit_mem flags · 6f07f86c
      Dan Williams authored
      In preparation for adding a flag to indicate whether a DIMM publishes a
      dirty-shutdown count, convert the existing flags to a bit field.
      Reviewed-by: default avatarKeith Busch <keith.busch@intel.com>
      Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
      6f07f86c
  2. 12 Oct, 2018 6 commits
  3. 11 Oct, 2018 1 commit
    • Dan Williams's avatar
      libnvdimm, dimm: Maximize label transfer size · d11cf4a7
      Dan Williams authored
      Use kvzalloc() to bypass the arbitrary PAGE_SIZE limit of label transfer
      operations. Given the expense of calling into firmware, maximize the
      amount of label data we transfer per call to be up to the total label
      space if allowed by the firmware.
      
      Instead of limiting based on PAGE_SIZE we can instead simply limit the
      maximum size based on either the config_size int he case of the get
      operation, or the length of the write based on the set operation.
      
      On a system with 24 NVDIMM modules each with a config_size of 128K and a
      maximum transfer size of 64K - 4, this patch reduces the init time for the
      label data from around 24 seconds down to between 4-5 seconds.
      Reviewed-by: default avatarToshi Kani <toshi.kani@hpe.com>
      Signed-off-by: default avatarAlexander Duyck <alexander.h.duyck@linux.intel.com>
      Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
      d11cf4a7
  4. 09 Oct, 2018 1 commit
  5. 02 Oct, 2018 1 commit
  6. 28 Sep, 2018 2 commits
    • Dan Williams's avatar
      libnvdimm, region: Fail badblocks listing for inactive regions · 5d394eee
      Dan Williams authored
      While experimenting with region driver loading the following backtrace
      was triggered:
      
       INFO: trying to register non-static key.
       the code is fine but needs lockdep annotation.
       turning off the locking correctness validator.
       [..]
       Call Trace:
        dump_stack+0x85/0xcb
        register_lock_class+0x571/0x580
        ? __lock_acquire+0x2ba/0x1310
        ? kernfs_seq_start+0x2a/0x80
        __lock_acquire+0xd4/0x1310
        ? dev_attr_show+0x1c/0x50
        ? __lock_acquire+0x2ba/0x1310
        ? kernfs_seq_start+0x2a/0x80
        ? lock_acquire+0x9e/0x1a0
        lock_acquire+0x9e/0x1a0
        ? dev_attr_show+0x1c/0x50
        badblocks_show+0x70/0x190
        ? dev_attr_show+0x1c/0x50
        dev_attr_show+0x1c/0x50
      
      This results from a missing successful call to devm_init_badblocks()
      from nd_region_probe(). Block attempts to show badblocks while the
      region is not enabled.
      
      Fixes: 6a6bef90 ("libnvdimm: add mechanism to publish badblocks...")
      Cc: <stable@vger.kernel.org>
      Reviewed-by: default avatarJohannes Thumshirn <jthumshirn@suse.de>
      Reviewed-by: default avatarDave Jiang <dave.jiang@intel.com>
      Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
      5d394eee
    • Vishal Verma's avatar
      libnvdimm, pfn: during init, clear errors in the metadata area · 48af2f7e
      Vishal Verma authored
      If there are badblocks present in the 'struct page' area for pfn
      namespaces, until now, the only way to clear them has been to force the
      namespace into raw mode, clear the errors, and re-enable the fsdax mode.
      This is clunky, given that it should be easy enough for the pfn driver
      to do the same.
      
      Add a new helper that uses the most recently available badblocks list to
      check whether there are any badblocks that lie in the volatile struct
      page area. If so, before initializing the struct pages, send down
      targeted writes via nvdimm_write_bytes to write zeroes to the affected
      blocks, and thus clear errors.
      
      Cc: Dan Williams <dan.j.williams@intel.com>
      Signed-off-by: default avatarVishal Verma <vishal.l.verma@intel.com>
      Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
      48af2f7e
  7. 26 Sep, 2018 3 commits
  8. 16 Sep, 2018 2 commits
  9. 15 Sep, 2018 8 commits
  10. 14 Sep, 2018 9 commits