1. 25 6月, 2021 1 次提交
    • V
      powerpc/papr_scm: Make 'perf_stats' invisible if perf-stats unavailable · ed78f56e
      Vaibhav Jain 提交于
      In case performance stats for an nvdimm are not available, reading the
      'perf_stats' sysfs file returns an -ENOENT error. A better approach is
      to make the 'perf_stats' file entirely invisible to indicate that
      performance stats for an nvdimm are unavailable.
      
      So this patch updates 'papr_nd_attribute_group' to add a 'is_visible'
      callback implemented as newly introduced 'papr_nd_attribute_visible()'
      that returns an appropriate mode in case performance stats aren't
      supported in a given nvdimm.
      
      Also the initialization of 'papr_scm_priv.stat_buffer_len' is moved
      from papr_scm_nvdimm_init() to papr_scm_probe() so that it value is
      available when 'papr_nd_attribute_visible()' is called during nvdimm
      initialization.
      
      Even though 'perf_stats' attribute is available since v5.9, there are
      no known user-space tools/scripts that are dependent on presence of its
      sysfs file. Hence I dont expect any user-space breakage with this
      patch.
      
      Fixes: 2d02bf83 ("powerpc/papr_scm: Fetch nvdimm performance stats from PHYP")
      Signed-off-by: NVaibhav Jain <vaibhav@linux.ibm.com>
      Reviewed-by: NDan Williams <dan.j.williams@intel.com>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20210513092349.285021-1-vaibhav@linux.ibm.com
      ed78f56e
  2. 24 6月, 2021 1 次提交
  3. 17 5月, 2021 1 次提交
    • V
      powerpc/papr_scm: Reduce error severity if nvdimm stats inaccessible · f3f6d184
      Vaibhav Jain 提交于
      Currently drc_pmem_qeury_stats() generates a dev_err in case
      "Enable Performance Information Collection" feature is disabled from
      HMC or performance stats are not available for an nvdimm. The error is
      of the form below:
      
      papr_scm ibm,persistent-memory:ibm,pmemory@44104001: Failed to query
      	 performance stats, Err:-10
      
      This error message confuses users as it implies a possible problem
      with the nvdimm even though its due to a disabled/unavailable
      feature. We fix this by explicitly handling the H_AUTHORITY and
      H_UNSUPPORTED errors from the H_SCM_PERFORMANCE_STATS hcall.
      
      In case of H_AUTHORITY error an info message is logged instead of an
      error, saying that "Permission denied while accessing performance
      stats" and an EPERM error is returned back.
      
      In case of H_UNSUPPORTED error we return a EOPNOTSUPP error back from
      drc_pmem_query_stats() indicating that performance stats-query
      operation is not supported on this nvdimm.
      
      Fixes: 2d02bf83 ("powerpc/papr_scm: Fetch nvdimm performance stats from PHYP")
      Signed-off-by: NVaibhav Jain <vaibhav@linux.ibm.com>
      Reviewed-by: NIra Weiny <ira.weiny@intel.com>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20210508043642.114076-1-vaibhav@linux.ibm.com
      f3f6d184
  4. 27 4月, 2021 1 次提交
  5. 16 4月, 2021 1 次提交
  6. 14 4月, 2021 1 次提交
  7. 08 10月, 2020 1 次提交
  8. 06 10月, 2020 1 次提交
  9. 16 9月, 2020 1 次提交
    • V
      powerpc/papr_scm: Fix warning triggered by perf_stats_show() · ca78ef2f
      Vaibhav Jain 提交于
      A warning is reported by the kernel in case perf_stats_show() returns
      an error code. The warning is of the form below:
      
       papr_scm ibm,persistent-memory:ibm,pmemory@44100001:
       	  Failed to query performance stats, Err:-10
       dev_attr_show: perf_stats_show+0x0/0x1c0 [papr_scm] returned bad count
       fill_read_buffer: dev_attr_show+0x0/0xb0 returned bad count
      
      On investigation it looks like that the compiler is silently
      truncating the return value of drc_pmem_query_stats() from 'long' to
      'int', since the variable used to store the return code 'rc' is an
      'int'. This truncated value is then returned back as a 'ssize_t' back
      from perf_stats_show() to 'dev_attr_show()' which thinks of it as a
      large unsigned number and triggers this warning..
      
      To fix this we update the type of variable 'rc' from 'int' to
      'ssize_t' that prevents the compiler from truncating the return value
      of drc_pmem_query_stats() and returning correct signed value back from
      perf_stats_show().
      
      Fixes: 2d02bf83 ("powerpc/papr_scm: Fetch nvdimm performance stats from PHYP")
      Signed-off-by: NVaibhav Jain <vaibhav@linux.ibm.com>
      Reviewed-by: NIra Weiny <ira.weiny@intel.com>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20200912081451.66225-1-vaibhav@linux.ibm.com
      ca78ef2f
  10. 09 9月, 2020 1 次提交
  11. 31 7月, 2020 2 次提交
    • V
      powerpc/papr_scm: Add support for fetching nvdimm 'fuel-gauge' metric · af0870c4
      Vaibhav Jain 提交于
      We add support for reporting 'fuel-gauge' NVDIMM metric via
      PAPR_PDSM_HEALTH pdsm payload. 'fuel-gauge' metric indicates the usage
      life remaining of a papr-scm compatible NVDIMM. PHYP exposes this
      metric via the H_SCM_PERFORMANCE_STATS.
      
      The metric value is returned from the pdsm by extending the return
      payload 'struct nd_papr_pdsm_health' without breaking the ABI. A new
      field 'dimm_fuel_gauge' to hold the metric value is introduced at the
      end of the payload struct and its presence is indicated by by
      extension flag PDSM_DIMM_HEALTH_RUN_GAUGE_VALID.
      
      The patch introduces a new function papr_pdsm_fuel_gauge() that is
      called from papr_pdsm_health(). If fetching NVDIMM performance stats
      is supported then 'papr_pdsm_fuel_gauge()' allocated an output buffer
      large enough to hold the performance stat and passes it to
      drc_pmem_query_stats() that issues the HCALL to PHYP. The return value
      of the stat is then populated in the 'struct
      nd_papr_pdsm_health.dimm_fuel_gauge' field with extension flag
      'PDSM_DIMM_HEALTH_RUN_GAUGE_VALID' set in 'struct
      nd_papr_pdsm_health.extension_flags'
      Signed-off-by: NVaibhav Jain <vaibhav@linux.ibm.com>
      Reviewed-by: NAneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20200731064153.182203-3-vaibhav@linux.ibm.com
      af0870c4
    • V
      powerpc/papr_scm: Fetch nvdimm performance stats from PHYP · 2d02bf83
      Vaibhav Jain 提交于
      Update papr_scm.c to query dimm performance statistics from PHYP via
      H_SCM_PERFORMANCE_STATS hcall and export them to user-space as PAPR
      specific NVDIMM attribute 'perf_stats' in sysfs. The patch also
      provide a sysfs ABI documentation for the stats being reported and
      their meanings.
      
      During NVDIMM probe time in papr_scm_nvdimm_init() a special variant
      of H_SCM_PERFORMANCE_STATS hcall is issued to check if collection of
      performance statistics is supported or not. If successful then a PHYP
      returns a maximum possible buffer length needed to read all
      performance stats. This returned value is stored in a per-nvdimm
      attribute 'stat_buffer_len'.
      
      The layout of request buffer for reading NVDIMM performance stats from
      PHYP is defined in 'struct papr_scm_perf_stats' and 'struct
      papr_scm_perf_stat'. These structs are used in newly introduced
      drc_pmem_query_stats() that issues the H_SCM_PERFORMANCE_STATS hcall.
      
      The sysfs access function perf_stats_show() uses value
      'stat_buffer_len' to allocate a buffer large enough to hold all
      possible NVDIMM performance stats and passes it to
      drc_pmem_query_stats() to populate. Finally statistics reported in the
      buffer are formatted into the sysfs access function output buffer.
      Signed-off-by: NVaibhav Jain <vaibhav@linux.ibm.com>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20200731064153.182203-2-vaibhav@linux.ibm.com
      2d02bf83
  12. 26 7月, 2020 1 次提交
  13. 20 7月, 2020 1 次提交
  14. 16 7月, 2020 1 次提交
  15. 16 6月, 2020 4 次提交
    • V
      powerpc/papr_scm: Implement support for PAPR_PDSM_HEALTH · d35f18b5
      Vaibhav Jain 提交于
      This patch implements support for PDSM request 'PAPR_PDSM_HEALTH'
      that returns a newly introduced 'struct nd_papr_pdsm_health' instance
      containing dimm health information back to user space in response to
      ND_CMD_CALL. This functionality is implemented in newly introduced
      papr_pdsm_health() that queries the nvdimm health information and
      then copies this information to the package payload whose layout is
      defined by 'struct nd_papr_pdsm_health'.
      Signed-off-by: NVaibhav Jain <vaibhav@linux.ibm.com>
      Cc: "Aneesh Kumar K . V" <aneesh.kumar@linux.ibm.com>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Ira Weiny <ira.weiny@intel.com>
      Link: https://lore.kernel.org/r/20200615124407.32596-7-vaibhav@linux.ibm.comSigned-off-by: NDan Williams <dan.j.williams@intel.com>
      d35f18b5
    • V
      ndctl/papr_scm,uapi: Add support for PAPR nvdimm specific methods · f517f792
      Vaibhav Jain 提交于
      Introduce support for PAPR NVDIMM Specific Methods (PDSM) in papr_scm
      module and add the command family NVDIMM_FAMILY_PAPR to the white list
      of NVDIMM command sets. Also advertise support for ND_CMD_CALL for the
      nvdimm command mask and implement necessary scaffolding in the module
      to handle ND_CMD_CALL ioctl and PDSM requests that we receive.
      
      The layout of the PDSM request as we expect from libnvdimm/libndctl is
      described in newly introduced uapi header 'papr_pdsm.h' which
      defines a 'struct nd_pkg_pdsm' and a maximal union named
      'nd_pdsm_payload'. These new structs together with 'struct nd_cmd_pkg'
      for a pdsm envelop thats sent by libndctl to libnvdimm and serviced by
      papr_scm in 'papr_scm_service_pdsm()'. The PDSM request is
      communicated by member 'struct nd_cmd_pkg.nd_command' together with
      other information on the pdsm payload (size-in, size-out).
      
      The patch also introduces 'struct pdsm_cmd_desc' instances of which
      are stored in an array __pdsm_cmd_descriptors[] indexed with PDSM cmd
      and corresponding access function pdsm_cmd_desc() is
      introduced. 'struct pdsm_cdm_desc' holds the service function for a
      given PDSM and corresponding payload in/out sizes.
      
      A new function papr_scm_service_pdsm() is introduced and is called from
      papr_scm_ndctl() in case of a PDSM request is received via ND_CMD_CALL
      command from libnvdimm. The function performs validation on the PDSM
      payload based on info present in corresponding PDSM descriptor and if
      valid calls the 'struct pdcm_cmd_desc.service' function to service the
      PDSM.
      Signed-off-by: NVaibhav Jain <vaibhav@linux.ibm.com>
      Cc: "Aneesh Kumar K . V" <aneesh.kumar@linux.ibm.com>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Ira Weiny <ira.weiny@intel.com>
      Link: https://lore.kernel.org/r/20200615124407.32596-6-vaibhav@linux.ibm.comSigned-off-by: NDan Williams <dan.j.williams@intel.com>
      f517f792
    • V
      powerpc/papr_scm: Improve error logging and handling papr_scm_ndctl() · b5f38f09
      Vaibhav Jain 提交于
      Since papr_scm_ndctl() can be called from outside papr_scm, its
      exposed to the possibility of receiving NULL as value of 'cmd_rc'
      argument. This patch updates papr_scm_ndctl() to protect against such
      possibility by assigning it pointer to a local variable in case cmd_rc
      == NULL.
      
      Finally the patch also updates the 'default' add a debug log unknown
      'cmd' values.
      Signed-off-by: NVaibhav Jain <vaibhav@linux.ibm.com>
      Reviewed-by: NIra Weiny <ira.weiny@intel.com>
      Cc: "Aneesh Kumar K . V" <aneesh.kumar@linux.ibm.com>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Ira Weiny <ira.weiny@intel.com>
      Link: https://lore.kernel.org/r/20200615124407.32596-5-vaibhav@linux.ibm.comSigned-off-by: NDan Williams <dan.j.williams@intel.com>
      b5f38f09
    • V
      powerpc/papr_scm: Fetch nvdimm health information from PHYP · b791abf3
      Vaibhav Jain 提交于
      Implement support for fetching nvdimm health information via
      H_SCM_HEALTH hcall as documented in Ref[1]. The hcall returns a pair
      of 64-bit bitmap, bitwise-and of which is then stored in
      'struct papr_scm_priv' and subsequently partially exposed to
      user-space via newly introduced dimm specific attribute
      'papr/flags'. Since the hcall is costly, the health information is
      cached and only re-queried, 60s after the previous successful hcall.
      
      The patch also adds a  documentation text describing flags reported by
      the the new sysfs attribute 'papr/flags' is also introduced at
      Documentation/ABI/testing/sysfs-bus-papr-pmem.
      
      [1] commit 58b278f5 ("powerpc: Provide initial documentation for
      PAPR hcalls")
      Signed-off-by: NVaibhav Jain <vaibhav@linux.ibm.com>
      Cc: "Aneesh Kumar K . V" <aneesh.kumar@linux.ibm.com>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Ira Weiny <ira.weiny@intel.com>
      Link: https://lore.kernel.org/r/20200615124407.32596-4-vaibhav@linux.ibm.comSigned-off-by: NDan Williams <dan.j.williams@intel.com>
      b791abf3
  16. 01 4月, 2020 1 次提交
  17. 18 3月, 2020 1 次提交
  18. 19 2月, 2020 1 次提交
  19. 18 2月, 2020 1 次提交
  20. 25 1月, 2020 2 次提交
  21. 06 1月, 2020 1 次提交
  22. 20 11月, 2019 5 次提交
  23. 18 11月, 2019 1 次提交
  24. 13 11月, 2019 1 次提交
  25. 10 10月, 2019 1 次提交
  26. 25 9月, 2019 2 次提交
  27. 30 7月, 2019 1 次提交
    • A
      powerpc/nvdimm: Pick nearby online node if the device node is not online · da1115fd
      Aneesh Kumar K.V 提交于
      Currently, nvdimm subsystem expects the device numa node for SCM device to be
      an online node. It also doesn't try to bring the device numa node online. Hence
      if we use a non-online numa node as device node we hit crashes like below. This
      is because we try to access uninitialized NODE_DATA in different code paths.
      
      cpu 0x0: Vector: 300 (Data Access) at [c0000000fac53170]
          pc: c0000000004bbc50: ___slab_alloc+0x120/0xca0
          lr: c0000000004bc834: __slab_alloc+0x64/0xc0
          sp: c0000000fac53400
         msr: 8000000002009033
         dar: 73e8
       dsisr: 80000
        current = 0xc0000000fabb6d80
        paca    = 0xc000000003870000   irqmask: 0x03   irq_happened: 0x01
          pid   = 7, comm = kworker/u16:0
      Linux version 5.2.0-06234-g76bd729b2644 (kvaneesh@ltc-boston123) (gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)) #135 SMP Thu Jul 11 05:36:30 CDT 2019
      enter ? for help
      [link register   ] c0000000004bc834 __slab_alloc+0x64/0xc0
      [c0000000fac53400] c0000000fac53480 (unreliable)
      [c0000000fac53500] c0000000004bc818 __slab_alloc+0x48/0xc0
      [c0000000fac53560] c0000000004c30a0 __kmalloc_node_track_caller+0x3c0/0x6b0
      [c0000000fac535d0] c000000000cfafe4 devm_kmalloc+0x74/0xc0
      [c0000000fac53600] c000000000d69434 nd_region_activate+0x144/0x560
      [c0000000fac536d0] c000000000d6b19c nd_region_probe+0x17c/0x370
      [c0000000fac537b0] c000000000d6349c nvdimm_bus_probe+0x10c/0x230
      [c0000000fac53840] c000000000cf3cc4 really_probe+0x254/0x4e0
      [c0000000fac538d0] c000000000cf429c driver_probe_device+0x16c/0x1e0
      [c0000000fac53950] c000000000cf0b44 bus_for_each_drv+0x94/0x130
      [c0000000fac539b0] c000000000cf392c __device_attach+0xdc/0x200
      [c0000000fac53a50] c000000000cf231c bus_probe_device+0x4c/0xf0
      [c0000000fac53a90] c000000000ced268 device_add+0x528/0x810
      [c0000000fac53b60] c000000000d62a58 nd_async_device_register+0x28/0xa0
      [c0000000fac53bd0] c0000000001ccb8c async_run_entry_fn+0xcc/0x1f0
      [c0000000fac53c50] c0000000001bcd9c process_one_work+0x46c/0x860
      [c0000000fac53d20] c0000000001bd4f4 worker_thread+0x364/0x5f0
      [c0000000fac53db0] c0000000001c7260 kthread+0x1b0/0x1c0
      [c0000000fac53e20] c00000000000b954 ret_from_kernel_thread+0x5c/0x68
      
      The patch tries to fix this by picking the nearest online node as the SCM node.
      This does have a problem of us losing the information that SCM node is
      equidistant from two other online nodes. If applications need to understand these
      fine-grained details we should express then like x86 does via
      /sys/devices/system/node/nodeX/accessY/initiators/
      
      With the patch we get
      
       # numactl -H
      available: 2 nodes (0-1)
      node 0 cpus:
      node 0 size: 0 MB
      node 0 free: 0 MB
      node 1 cpus: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
      node 1 size: 130865 MB
      node 1 free: 129130 MB
      node distances:
      node   0   1
        0:  10  20
        1:  20  10
       # cat /sys/bus/nd/devices/region0/numa_node
      0
       # dmesg | grep papr_scm
      [   91.332305] papr_scm ibm,persistent-memory:ibm,pmemory@44104001: Region registered with target node 2 and online node 0
      Signed-off-by: NAneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20190729095128.23707-1-aneesh.kumar@linux.ibm.com
      da1115fd
  28. 22 7月, 2019 2 次提交
  29. 04 7月, 2019 1 次提交
    • A
      powerpc/pseries/scm: Use a specific endian format for storing uuid from the device tree · 259a948c
      Aneesh Kumar K.V 提交于
      We used uuid_parse to convert uuid string from device tree to two u64
      components. We want to make sure we look at the uuid read from device
      tree in an endian-neutral fashion. For now, I am picking little-endian
      to be format so that we don't end up doing an additional conversion.
      
      The reason to store in a specific endian format is to enable reading
      the namespace created with a little-endian kernel config on a
      big-endian kernel. We do store the device tree uuid string as a 64-bit
      little-endian cookie in the label area. When booting the kernel we
      also compare this cookie against what is read from the device tree.
      For this, to work we have to store and compare these values in a CPU
      endian config independent fashion.
      Signed-off-by: NAneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      259a948c