Skip to contentSkip to conversation

ndctl: add an api for getting the ars_status overflow flag

PATCH Superseded Vishal Verma 2 participants 5 messages Jun 6, 2018 libnvdimm: non-volatile memory device

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Vishal Verma

author maintainer
#0 lore raw

PATCH v2 1/1 ndctl: add an api for getting the ars_status overflow flag

The ARS status command defines a 'flags' field that wasn't being exposed via an API yet. Since there is only one flag defined in ACPI 6.2, add a helper for retrieving it (overflow flag).

---
 ndctl/lib/ars.c        | 11 +++++++++++
 ndctl/lib/libndctl.sym |  1 +
 ndctl/libndctl.h       |  4 ++++
 3 files changed, 16 insertions(+)

v2: instead of exposing the binary representation of flags, provide a helper for each flag. ACPI currently defines a single 'overflow' flag. (Dan)

ndctl/lib/ars.c +11 -0
index e04b51e..b765c88 100644
@@ -269,6 +269,17 @@ NDCTL_EXPORT unsigned long long ndctl_cmd_ars_get_record_len(
 	return ars_stat->ars_status->records[rec_index].length;
 }
 
+NDCTL_EXPORT int ndctl_cmd_ars_stat_get_flag_overflow(
+		struct ndctl_cmd *ars_stat)
+{
+	struct ndctl_ctx *ctx = ndctl_bus_get_ctx(cmd_to_bus(ars_stat));
+
+	if (!validate_ars_stat(ctx, ars_stat))
+		return -EINVAL;
+
+	return (ars_stat->ars_status->flags & ND_ARS_STAT_FLAG_OVERFLOW);
+}
+
 NDCTL_EXPORT struct ndctl_cmd *ndctl_bus_cmd_new_clear_error(
 		unsigned long long address, unsigned long long len,
 		struct ndctl_cmd *ars_cap)
ndctl/lib/libndctl.sym +1 -0
index c1228e5..e939993 100644
@@ -365,4 +365,5 @@ global:
 	ndctl_cmd_ars_cap_get_clear_unit;
 	ndctl_namespace_inject_error2;
 	ndctl_namespace_uninject_error2;
+	ndctl_cmd_ars_stat_get_flag_overflow;
 } LIBNDCTL_15;
ndctl/libndctl.h +4 -0
index be997ac..3d141a6 100644
@@ -187,6 +187,9 @@ int ndctl_dimm_is_enabled(struct ndctl_dimm *dimm);
 int ndctl_dimm_disable(struct ndctl_dimm *dimm);
 int ndctl_dimm_enable(struct ndctl_dimm *dimm);
 
+/* ars_status flags */
+#define ND_ARS_STAT_FLAG_OVERFLOW (1 << 0)
+
 struct ndctl_cmd;
 struct ndctl_cmd *ndctl_bus_cmd_new_ars_cap(struct ndctl_bus *bus,
 		unsigned long long address, unsigned long long len);
@@ -210,6 +213,7 @@ struct ndctl_cmd *ndctl_bus_cmd_new_clear_error(unsigned long long address,
 unsigned long long ndctl_cmd_clear_error_get_cleared(
 		struct ndctl_cmd *clear_err);
 unsigned int ndctl_cmd_ars_cap_get_clear_unit(struct ndctl_cmd *ars_cap);
+int ndctl_cmd_ars_stat_get_flag_overflow(struct ndctl_cmd *ars_stat);
 
 /*
  * Note: ndctl_cmd_smart_get_temperature is an alias for
Signature · 6 lines
2.17.0

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#1 lore raw
Quoted 25 lines · Vishal Verma

The ARS status command defines a 'flags' field that wasn't being exposed via an API yet. Since there is only one flag defined in ACPI 6.2, add a helper for retrieving it (overflow flag).

---
 ndctl/lib/ars.c        | 11 +++++++++++
 ndctl/lib/libndctl.sym |  1 +
 ndctl/libndctl.h       |  4 ++++
 3 files changed, 16 insertions(+)

v2: instead of exposing the binary representation of flags, provide a helper for each flag. ACPI currently defines a single 'overflow' flag. (Dan)

ndctl/lib/ars.c +0 -0
index e04b51e..b765c88 100644
@@ -269,6 +269,17 @@ NDCTL_EXPORT unsigned long long ndctl_cmd_ars_get_record_len(
        return ars_stat->ars_status->records[rec_index].length;
 }
 

ndctl/lib/ars.c NDCTL_EXPORT unsigned long long ndctl_cmd_ars_get_record_len( · line 281

Quoted 10 lines
ndctl/lib/ars.c +10 -0
+NDCTL_EXPORT int ndctl_cmd_ars_stat_get_flag_overflow(
+               struct ndctl_cmd *ars_stat)
+{
+       struct ndctl_ctx *ctx = ndctl_bus_get_ctx(cmd_to_bus(ars_stat));
+
+       if (!validate_ars_stat(ctx, ars_stat))
+               return -EINVAL;
+
+       return (ars_stat->ars_status->flags & ND_ARS_STAT_FLAG_OVERFLOW);
+}

How about return bool since it's a flag?
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

author maintainer
#2 lore raw
Quoted 29 lines · Dan Williams
Quoted 27 lines · Vishal Verma

The ARS status command defines a 'flags' field that wasn't being exposed
via an API yet. Since there is only one flag defined in ACPI 6.2, add a helper for retrieving it (overflow flag).

---
 ndctl/lib/ars.c        | 11 +++++++++++
 ndctl/lib/libndctl.sym |  1 +
 ndctl/libndctl.h       |  4 ++++
 3 files changed, 16 insertions(+)

v2: instead of exposing the binary representation of flags, provide a helper for each flag. ACPI currently defines a single 'overflow' flag. (Dan)

ndctl/lib/ars.c +0 -0
index e04b51e..b765c88 100644
@@ -269,6 +269,17 @@ NDCTL_EXPORT unsigned long long

ndctl_cmd_ars_get_record_len(

        return ars_stat->ars_status->records[rec_index].length;

}

Quoted 14 lines
Quoted 10 lines
ndctl/lib/ars.c +4 -0
+NDCTL_EXPORT int ndctl_cmd_ars_stat_get_flag_overflow(
+               struct ndctl_cmd *ars_stat)
+{
+       struct ndctl_ctx *ctx =

ndctl_bus_get_ctx(cmd_to_bus(ars_stat));

ndctl/lib/ars.c +5 -0
+
+       if (!validate_ars_stat(ctx, ars_stat))
+               return -EINVAL;
+
+       return (ars_stat->ars_status->flags &
Quoted 2 lines

ND_ARS_STAT_FLAG_OVERFLOW);
+}

How about return bool since it's a flag?

I considered it, but int allows us to return an error for an invalid status command. If we use a bool, should we just return 'false' for a bad command?
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#3 lore raw
Quoted 45 lines · Vishal L
Quoted 29 lines · Dan Williams
Quoted 27 lines · Vishal Verma

The ARS status command defines a 'flags' field that wasn't being exposed
via an API yet. Since there is only one flag defined in ACPI 6.2, add a helper for retrieving it (overflow flag).

---
 ndctl/lib/ars.c        | 11 +++++++++++
 ndctl/lib/libndctl.sym |  1 +
 ndctl/libndctl.h       |  4 ++++
 3 files changed, 16 insertions(+)

v2: instead of exposing the binary representation of flags, provide a helper for each flag. ACPI currently defines a single 'overflow' flag. (Dan)

ndctl/lib/ars.c +0 -0
index e04b51e..b765c88 100644
@@ -269,6 +269,17 @@ NDCTL_EXPORT unsigned long long

ndctl_cmd_ars_get_record_len(

        return ars_stat->ars_status->records[rec_index].length;

}

Quoted 14 lines
Quoted 10 lines
ndctl/lib/ars.c +4 -0
+NDCTL_EXPORT int ndctl_cmd_ars_stat_get_flag_overflow(
+               struct ndctl_cmd *ars_stat)
+{
+       struct ndctl_ctx *ctx =

ndctl_bus_get_ctx(cmd_to_bus(ars_stat));

ndctl/lib/ars.c +5 -0
+
+       if (!validate_ars_stat(ctx, ars_stat))
+               return -EINVAL;
+
+       return (ars_stat->ars_status->flags &
Quoted 2 lines

ND_ARS_STAT_FLAG_OVERFLOW);
+}

How about return bool since it's a flag?

Quoted 2 lines

I considered it, but int allows us to return an error for an invalid status command. If we use a bool, should we just return 'false' for a bad command?

Oh, sorry, missed that. In that case let's do:

   return !!(ars_stat->ars_status->flags & ND_ARS_STAT_FLAG_OVERFLOW);

So it's defined to be 0, 1, or -error.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

author maintainer
#4 lore raw
Quoted 56 lines · Dan Williams
Quoted 49 lines · Vishal L
Quoted 33 lines · Dan Williams
Quoted 30 lines · Vishal Verma

The ARS status command defines a 'flags' field that wasn't being exposed
via an API yet. Since there is only one flag defined in ACPI 6.2, add a
helper for retrieving it (overflow flag).

---
 ndctl/lib/ars.c        | 11 +++++++++++
 ndctl/lib/libndctl.sym |  1 +
 ndctl/libndctl.h       |  4 ++++
 3 files changed, 16 insertions(+)

v2: instead of exposing the binary representation of flags, provide a
helper for each flag. ACPI currently defines a single 'overflow' flag.
(Dan)

ndctl/lib/ars.c +0 -0
index e04b51e..b765c88 100644
@@ -269,6 +269,17 @@ NDCTL_EXPORT unsigned long long

ndctl_cmd_ars_get_record_len(

        return ars_stat->ars_status->records[rec_index].length;

}

Quoted 14 lines
Quoted 10 lines
ndctl/lib/ars.c +4 -0
+NDCTL_EXPORT int ndctl_cmd_ars_stat_get_flag_overflow(
+               struct ndctl_cmd *ars_stat)
+{
+       struct ndctl_ctx *ctx =

ndctl_bus_get_ctx(cmd_to_bus(ars_stat));

ndctl/lib/ars.c +5 -0
+
+       if (!validate_ars_stat(ctx, ars_stat))
+               return -EINVAL;
+
+       return (ars_stat->ars_status->flags &
Quoted 2 lines

ND_ARS_STAT_FLAG_OVERFLOW);
+}

How about return bool since it's a flag?

Quoted 4 lines

I considered it, but int allows us to return an error for an invalid status
command. If we use a bool, should we just return 'false' for a bad command?

Quoted 5 lines

Oh, sorry, missed that. In that case let's do:

   return !!(ars_stat->ars_status->flags & ND_ARS_STAT_FLAG_OVERFLOW);

So it's defined to be 0, 1, or -error.

Ok, yep that is better, I'll fix and send a new version.
_______________________________________________
Linux-nvdimm mailing list [email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm