Skip to contentSkip to conversation

nvdimm/of_pmem: Provide a unique name for bus provider

PATCH In review Aneesh Kumar K.V 3 participants 11 messages Aug 7, 2019 – Aug 30, 2019 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvdimm/of_pmem: Provide a unique name for bus provider

ndctl utility requires the ndbus to have unique names. If not while enumerating the bus in userspace it drops bus with similar names. This results in us not listing devices beneath the bus.

---
 drivers/nvdimm/of_pmem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvdimm/of_pmem.c +1 -1
index a0c8dcfa0bf9..97187d6c0bdb 100644
@@ -42,7 +42,7 @@ static int of_pmem_region_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	priv->bus_desc.attr_groups = bus_attr_groups;
-	priv->bus_desc.provider_name = "of_pmem";
+	priv->bus_desc.provider_name = kstrdup(pdev->name, GFP_KERNEL);
 	priv->bus_desc.module = THIS_MODULE;
 	priv->bus_desc.of_node = np;
 
Signature · 6 lines
2.21.0

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#1 lore raw
Quoted 4 lines · Aneesh Kumar K.V

ndctl utility requires the ndbus to have unique names. If not while enumerating the bus in userspace it drops bus with similar names. This results in us not listing devices beneath the bus.

It does?

Quoted 11 lines
---
 drivers/nvdimm/of_pmem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvdimm/of_pmem.c +0 -0
index a0c8dcfa0bf9..97187d6c0bdb 100644

drivers/nvdimm/of_pmem.c static int of_pmem_region_probe(struct platform_device *pdev) · line 45

Quoted 5 lines
drivers/nvdimm/of_pmem.c +1 -1
@@ -42,7 +42,7 @@ static int of_pmem_region_probe(struct platform_device *pdev)
                return -ENOMEM;
 
        priv->bus_desc.attr_groups = bus_attr_groups;
-       priv->bus_desc.provider_name = "of_pmem";
+       priv->bus_desc.provider_name = kstrdup(pdev->name, GFP_KERNEL);

This looks ok to me to address support for older ndctl binaries, but I'd like to also fix the ndctl bug that makes non-unique provider names fail.

#2 lore raw
Quoted 22 lines · Dan Williams
Quoted 4 lines · Aneesh Kumar K.V

ndctl utility requires the ndbus to have unique names. If not while enumerating the bus in userspace it drops bus with similar names. This results in us not listing devices beneath the bus.

It does?

Quoted 13 lines
---
  drivers/nvdimm/of_pmem.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvdimm/of_pmem.c +0 -0
index a0c8dcfa0bf9..97187d6c0bdb 100644
@@ -42,7 +42,7 @@ static int of_pmem_region_probe(struct platform_device *pdev)
                 return -ENOMEM;
 
Quoted 8 lines

drivers/nvdimm/of_pmem.c static int of_pmem_region_probe(struct platform_device *pdev) · line 45

Quoted 3 lines
drivers/nvdimm/of_pmem.c +1 -1
         priv->bus_desc.attr_groups = bus_attr_groups;
-       priv->bus_desc.provider_name = "of_pmem";
+       priv->bus_desc.provider_name = kstrdup(pdev->name, GFP_KERNEL);

This looks ok to me to address support for older ndctl binaries, but I'd like to also fix the ndctl bug that makes non-unique provider names fail.

0462269ab121d323a016874ebdd42217f2911ee7 (ndctl: provide a method to invalidate the bus list)

This hunk does the filtering.

@@ -928,6 +929,14 @@ static int add_bus(void *parent, int id, const char *ctl_base)
goto err_read;
bus->buf_len = strlen(bus->bus_path) + 50;

+ ndctl_bus_foreach(ctx, bus_dup)
+ if (strcmp(ndctl_bus_get_provider(bus_dup),
+ ndctl_bus_get_provider(bus)) == 0) {
+ free_bus(bus, NULL);
+ free(path);
+ return 1;
+ }
+
list_add(&ctx->busses, &bus->list);

rc = 0;

#3 lore raw
Quoted 41 lines · Aneesh Kumar K.V
Quoted 22 lines · Dan Williams
Quoted 4 lines · Aneesh Kumar K.V

ndctl utility requires the ndbus to have unique names. If not while enumerating the bus in userspace it drops bus with similar names. This results in us not listing devices beneath the bus.

It does?

Quoted 13 lines
---
  drivers/nvdimm/of_pmem.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvdimm/of_pmem.c +0 -0
index a0c8dcfa0bf9..97187d6c0bdb 100644
@@ -42,7 +42,7 @@ static int of_pmem_region_probe(struct platform_device *pdev)
                 return -ENOMEM;
 
Quoted 8 lines

drivers/nvdimm/of_pmem.c static int of_pmem_region_probe(struct platform_device *pdev) · line 45

Quoted 3 lines
drivers/nvdimm/of_pmem.c +1 -1
         priv->bus_desc.attr_groups = bus_attr_groups;
-       priv->bus_desc.provider_name = "of_pmem";
+       priv->bus_desc.provider_name = kstrdup(pdev->name, GFP_KERNEL);

This looks ok to me to address support for older ndctl binaries, but I'd like to also fix the ndctl bug that makes non-unique provider names fail.

0462269ab121d323a016874ebdd42217f2911ee7 (ndctl: provide a method to invalidate the bus list)

This hunk does the filtering.

(quoted diff) +0 -0
@@ -928,6 +929,14 @@ static int add_bus(void *parent, int id, const char
 *ctl_base)
                goto err_read;

Review static int add_bus(void *parent, int id, const char · line 940

Quoted 10 lines
(quoted diff) +8 -0
        bus->buf_len = strlen(bus->bus_path) + 50;
 
+       ndctl_bus_foreach(ctx, bus_dup)
+               if (strcmp(ndctl_bus_get_provider(bus_dup),
+                                       ndctl_bus_get_provider(bus)) == 0) {
+                       free_bus(bus, NULL);
+                       free(path);
+                       return 1;
+               }
+

Yup, that's broken, does this incremental fix work?

ndctl/lib/libndctl.c +0 -0
index 4d9cc7e29c6b..6596f94edef8 100644
@@ -889,7 +889,9 @@ static void *add_bus(void *parent, int id, const

char *ctl_base)

ndctl_bus_foreach(ctx, bus_dup)
if (strcmp(ndctl_bus_get_provider(bus_dup),
- ndctl_bus_get_provider(bus)) == 0) {
+ ndctl_bus_get_provider(bus)) == 0
+ && strcmp(ndctl_bus_get_devname(bus_dup),

+                                       ndctl_bus_get_devname(bus)) == 0) {
                        free_bus(bus, NULL);
                        free(path);
                        return bus_dup;
Tested-by on v1 1/1
#6 lore raw
In reply to Aneesh Kumar K.V
Quoted 25 lines · Aneesh Kumar K.V

ndctl utility requires the ndbus to have unique names. If not while enumerating the bus in userspace it drops bus with similar names. This results in us not listing devices beneath the bus.

---
 drivers/nvdimm/of_pmem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvdimm/of_pmem.c +1 -1
index a0c8dcfa0bf9..97187d6c0bdb 100644
@@ -42,7 +42,7 @@ static int of_pmem_region_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	priv->bus_desc.attr_groups = bus_attr_groups;
-	priv->bus_desc.provider_name = "of_pmem";
+	priv->bus_desc.provider_name = kstrdup(pdev->name, GFP_KERNEL);
 	priv->bus_desc.module = THIS_MODULE;
 	priv->bus_desc.of_node = np;
 
Signature · 1 line
2.21.0
Signature · 2 lines
Vaibhav Jain <[email protected]>
Linux Technology Center, IBM India Pvt. Ltd.
#4 lore raw
In reply to Dan Williams
Quoted 71 lines · Dan Williams
Quoted 41 lines · Aneesh Kumar K.V
Quoted 22 lines · Dan Williams
Quoted 4 lines · Aneesh Kumar K.V

ndctl utility requires the ndbus to have unique names. If not while enumerating the bus in userspace it drops bus with similar names. This results in us not listing devices beneath the bus.

It does?

Quoted 13 lines
---
   drivers/nvdimm/of_pmem.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvdimm/of_pmem.c +0 -0
index a0c8dcfa0bf9..97187d6c0bdb 100644
@@ -42,7 +42,7 @@ static int of_pmem_region_probe(struct platform_device *pdev)
                  return -ENOMEM;
 
Quoted 8 lines

drivers/nvdimm/of_pmem.c static int of_pmem_region_probe(struct platform_device *pdev) · line 45

Quoted 3 lines
drivers/nvdimm/of_pmem.c +1 -1
          priv->bus_desc.attr_groups = bus_attr_groups;
-       priv->bus_desc.provider_name = "of_pmem";
+       priv->bus_desc.provider_name = kstrdup(pdev->name, GFP_KERNEL);

This looks ok to me to address support for older ndctl binaries, but I'd like to also fix the ndctl bug that makes non-unique provider names fail.

0462269ab121d323a016874ebdd42217f2911ee7 (ndctl: provide a method to invalidate the bus list)

This hunk does the filtering.

(quoted diff) +0 -0
@@ -928,6 +929,14 @@ static int add_bus(void *parent, int id, const char
 *ctl_base)
                 goto err_read;

Review static int add_bus(void *parent, int id, const char · line 940

Quoted 10 lines
(quoted diff) +8 -0
         bus->buf_len = strlen(bus->bus_path) + 50;
 
+       ndctl_bus_foreach(ctx, bus_dup)
+               if (strcmp(ndctl_bus_get_provider(bus_dup),
+                                       ndctl_bus_get_provider(bus)) == 0) {
+                       free_bus(bus, NULL);
+                       free(path);
+                       return 1;
+               }
+

Yup, that's broken, does this incremental fix work?

ndctl/lib/libndctl.c +3 -1
index 4d9cc7e29c6b..6596f94edef8 100644
@@ -889,7 +889,9 @@ static void *add_bus(void *parent, int id, const
 char *ctl_base)
 
         ndctl_bus_foreach(ctx, bus_dup)
                 if (strcmp(ndctl_bus_get_provider(bus_dup),
-                                       ndctl_bus_get_provider(bus)) == 0) {
+                                       ndctl_bus_get_provider(bus)) == 0
+                               && strcmp(ndctl_bus_get_devname(bus_dup),
+                                       ndctl_bus_get_devname(bus)) == 0) {
                         free_bus(bus, NULL);
                         free(path);
Quoted 2 lines
                         return bus_dup;

That worked.

-aneesh

#5 lore raw
Quoted 65 lines · Aneesh Kumar K.V
Quoted 63 lines · Dan Williams
Quoted 41 lines · Aneesh Kumar K.V
Quoted 22 lines · Dan Williams
Quoted 4 lines · Aneesh Kumar K.V

ndctl utility requires the ndbus to have unique names. If not while enumerating the bus in userspace it drops bus with similar names. This results in us not listing devices beneath the bus.

It does?

Quoted 13 lines
---
   drivers/nvdimm/of_pmem.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvdimm/of_pmem.c +0 -0
index a0c8dcfa0bf9..97187d6c0bdb 100644
@@ -42,7 +42,7 @@ static int of_pmem_region_probe(struct platform_device *pdev)
                  return -ENOMEM;
 
Quoted 8 lines

drivers/nvdimm/of_pmem.c static int of_pmem_region_probe(struct platform_device *pdev) · line 45

Quoted 3 lines
drivers/nvdimm/of_pmem.c +1 -1
          priv->bus_desc.attr_groups = bus_attr_groups;
-       priv->bus_desc.provider_name = "of_pmem";
+       priv->bus_desc.provider_name = kstrdup(pdev->name, GFP_KERNEL);

This looks ok to me to address support for older ndctl binaries, but I'd like to also fix the ndctl bug that makes non-unique provider names fail.

0462269ab121d323a016874ebdd42217f2911ee7 (ndctl: provide a method to invalidate the bus list)

This hunk does the filtering.

(quoted diff) +0 -0
@@ -928,6 +929,14 @@ static int add_bus(void *parent, int id, const char
 *ctl_base)
                 goto err_read;

Review static int add_bus(void *parent, int id, const char · line 940

Quoted 10 lines
(quoted diff) +8 -0
         bus->buf_len = strlen(bus->bus_path) + 50;
 
+       ndctl_bus_foreach(ctx, bus_dup)
+               if (strcmp(ndctl_bus_get_provider(bus_dup),
+                                       ndctl_bus_get_provider(bus)) == 0) {
+                       free_bus(bus, NULL);
+                       free(path);
+                       return 1;
+               }
+

Yup, that's broken, does this incremental fix work?

ndctl/lib/libndctl.c +0 -0
index 4d9cc7e29c6b..6596f94edef8 100644
@@ -889,7 +889,9 @@ static void *add_bus(void *parent, int id, const
 char *ctl_base)
 
Quoted 12 lines
Quoted 10 lines
ndctl/lib/libndctl.c +3 -1
         ndctl_bus_foreach(ctx, bus_dup)
                 if (strcmp(ndctl_bus_get_provider(bus_dup),
-                                       ndctl_bus_get_provider(bus)) == 0) {
+                                       ndctl_bus_get_provider(bus)) == 0
+                               && strcmp(ndctl_bus_get_devname(bus_dup),
+                                       ndctl_bus_get_devname(bus)) == 0) {
                         free_bus(bus, NULL);
                         free(path);
                         return bus_dup;

That worked.

Great. I'll make a formal patch, and I'll amend the changelog of the proposed kernel change to say "older ndctl binaries mistakenly require"

Quoted 2 lines

-aneesh

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#8 lore raw
In reply to a message not in the archive
Quoted 15 lines · [email protected] writes:

Hello:

This patch was applied to nvdimm/nvdimm.git (refs/heads/libnvdimm-for-next).

Quoted 8 lines · On Wed, 7 Aug 2019 09:30:29 +0530 you wrote:

ndctl utility requires the ndbus to have unique names. If not while enumerating the bus in userspace it drops bus with similar names. This results in us not listing devices beneath the bus.

---
 drivers/nvdimm/of_pmem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 5 lines

Here is a summary with links:
- nvdimm/of_pmem: Provide a unique name for bus provider

    https://git.kernel.org/nvdimm/nvdimm/c/49bddc73d15c25a68e4294d76fc74519fda984cd

You are awesome, thank you!

We decided to fix this in ndctl tool? If we go with ndctl fix, we can drop the kernel change. Parallely I am planning to do a fix for papr_scm driver that will update the provider name as "papr_scm". That way we can find out the backend driver using

:~> ndctl list -B
[

  {
    "provider":"papr_scm",
    "dev":"ndbus1"
  },
  {
    "provider":"of_pmem",
    "dev":"ndbus0"

}
]

-aneesh

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#9 lore raw
Quoted 18 lines · Aneesh Kumar K.V
Quoted 15 lines · [email protected] writes:

Hello:

This patch was applied to nvdimm/nvdimm.git (refs/heads/libnvdimm-for-next).

Quoted 8 lines · On Wed, 7 Aug 2019 09:30:29 +0530 you wrote:

ndctl utility requires the ndbus to have unique names. If not while enumerating the bus in userspace it drops bus with similar names. This results in us not listing devices beneath the bus.

---
 drivers/nvdimm/of_pmem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 8 lines
Quoted 5 lines

Here is a summary with links:
- nvdimm/of_pmem: Provide a unique name for bus provider

    https://git.kernel.org/nvdimm/nvdimm/c/49bddc73d15c25a68e4294d76fc74519fda984cd

You are awesome, thank you!

We decided to fix this in ndctl tool? If we go with ndctl fix, we can drop the kernel change.

Oh, I was planning to do both any concerns if I keep the kernel change, otherwise I'll need to rebase the branch.

Quoted 13 lines

Parallely I am planning to do a fix
for papr_scm driver that will update the provider name as "papr_scm". That way we can find out the backend driver using

:~> ndctl list -B
[

  {
    "provider":"papr_scm",
    "dev":"ndbus1"
  },
  {
    "provider":"of_pmem",
    "dev":"ndbus0"
Quoted 6 lines

}
]

-aneesh

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#10 lore raw
Quoted 24 lines · Dan Williams
Quoted 22 lines · Aneesh Kumar K.V
Quoted 19 lines · [email protected] writes:

Hello:

This patch was applied to nvdimm/nvdimm.git (refs/heads/libnvdimm-for-next).

Quoted 8 lines · On Wed, 7 Aug 2019 09:30:29 +0530 you wrote:

ndctl utility requires the ndbus to have unique names. If not while enumerating the bus in userspace it drops bus with similar names. This results in us not listing devices beneath the bus.

---
  drivers/nvdimm/of_pmem.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

Here is a summary with links:
- nvdimm/of_pmem: Provide a unique name for bus provider

     https://git.kernel.org/nvdimm/nvdimm/c/49bddc73d15c25a68e4294d76fc74519fda984cd
Quoted 8 lines
Quoted 4 lines
Quoted 1 line

You are awesome, thank you!

We decided to fix this in ndctl tool? If we go with ndctl fix, we can drop the kernel change.

Oh, I was planning to do both any concerns if I keep the kernel change, otherwise I'll need to rebase the branch.

I guess rebasing is not going to be nice. So we can keep the patch and if we are really need to move the provider name to indicate backend driver, I will fixup both of_pmem and papr_scm together.

Thanks.
-aneesh
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#11 lore raw
Quoted 31 lines · Aneesh Kumar K.V
Quoted 29 lines · Dan Williams
Quoted 26 lines · Aneesh Kumar K.V
Quoted 15 lines · [email protected] writes:

Hello:

This patch was applied to nvdimm/nvdimm.git (refs/heads/libnvdimm-for-next).

Quoted 8 lines · On Wed, 7 Aug 2019 09:30:29 +0530 you wrote:

ndctl utility requires the ndbus to have unique names. If not while enumerating the bus in userspace it drops bus with similar names. This results in us not listing devices beneath the bus.

---
  drivers/nvdimm/of_pmem.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 5 lines

Here is a summary with links:
- nvdimm/of_pmem: Provide a unique name for bus provider

     https://git.kernel.org/nvdimm/nvdimm/c/49bddc73d15c25a68e4294d76fc74519fda984cd

You are awesome, thank you!

We decided to fix this in ndctl tool? If we go with ndctl fix, we can drop the kernel change.

Quoted 7 lines
Quoted 3 lines

Oh, I was planning to do both any concerns if I keep the kernel change, otherwise I'll need to rebase the branch.

I guess rebasing is not going to be nice. So we can keep the patch and if we are really need to move the provider name to indicate backend driver, I will fixup both of_pmem and papr_scm together.

Another reason to make the kernel change is to improve compatibility with older ndctl releases.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm