All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dax: add a 'modalias' attribute to DAX 'bus' devices
@ 2019-02-22 23:58 Vishal Verma
  2019-02-23  0:24 ` Dan Williams
  0 siblings, 1 reply; 4+ messages in thread
From: Vishal Verma @ 2019-02-22 23:58 UTC (permalink / raw)
  To: linux-nvdimm; +Cc: Dave Hansen

Add a 'modalias' attribute to devices under the DAX bus so that userspace
is able to dynamically load modules as needed. The modalias already
exists, it was only the sysfs attribute that was missing.

Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
 drivers/dax/bus.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c
index 28c3324271ac..2109cfe80219 100644
--- a/drivers/dax/bus.c
+++ b/drivers/dax/bus.c
@@ -295,6 +295,17 @@ static ssize_t target_node_show(struct device *dev,
 }
 static DEVICE_ATTR_RO(target_node);
 
+static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
+		char *buf)
+{
+	/*
+	 * We only ever expect to handle device-dax instances, i.e. the
+	 * @type argument to MODULE_ALIAS_DAX_DEVICE() is always zero
+	 */
+	return sprintf(buf, DAX_DEVICE_MODALIAS_FMT "\n", 0);
+}
+static DEVICE_ATTR_RO(modalias);
+
 static umode_t dev_dax_visible(struct kobject *kobj, struct attribute *a, int n)
 {
 	struct device *dev = container_of(kobj, struct device, kobj);
@@ -306,6 +317,7 @@ static umode_t dev_dax_visible(struct kobject *kobj, struct attribute *a, int n)
 }
 
 static struct attribute *dev_dax_attributes[] = {
+	&dev_attr_modalias.attr,
 	&dev_attr_size.attr,
 	&dev_attr_target_node.attr,
 	NULL,
-- 
2.20.1

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] dax: add a 'modalias' attribute to DAX 'bus' devices
  2019-02-22 23:58 [PATCH] dax: add a 'modalias' attribute to DAX 'bus' devices Vishal Verma
@ 2019-02-23  0:24 ` Dan Williams
  2019-02-24  1:29   ` Vishal Verma
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Williams @ 2019-02-23  0:24 UTC (permalink / raw)
  To: Vishal Verma; +Cc: Dave Hansen, linux-nvdimm

Looks ok, but I think the changelog could be more accurate.

On Fri, Feb 22, 2019 at 3:59 PM Vishal Verma <vishal.l.verma@intel.com> wrote:
>
> Add a 'modalias' attribute to devices under the DAX bus so that userspace
> is able to dynamically load modules as needed.

The modalias is already published in the uevent which is how udev
identifies the module. This patch would allow "modalias to module
lookups" *outside* of the typical uevent used for dynamically loading
modules.

Care to fix up the changelog with that detail and why userspace needs
to do these lookups in addition to the typical uevent lookups?

> The modalias already
> exists, it was only the sysfs attribute that was missing.
>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Cc: Dave Hansen <dave.hansen@linux.intel.com>
> Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
> ---
>  drivers/dax/bus.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c
> index 28c3324271ac..2109cfe80219 100644
> --- a/drivers/dax/bus.c
> +++ b/drivers/dax/bus.c
> @@ -295,6 +295,17 @@ static ssize_t target_node_show(struct device *dev,
>  }
>  static DEVICE_ATTR_RO(target_node);
>
> +static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
> +               char *buf)
> +{
> +       /*
> +        * We only ever expect to handle device-dax instances, i.e. the
> +        * @type argument to MODULE_ALIAS_DAX_DEVICE() is always zero
> +        */
> +       return sprintf(buf, DAX_DEVICE_MODALIAS_FMT "\n", 0);
> +}
> +static DEVICE_ATTR_RO(modalias);
> +
>  static umode_t dev_dax_visible(struct kobject *kobj, struct attribute *a, int n)
>  {
>         struct device *dev = container_of(kobj, struct device, kobj);
> @@ -306,6 +317,7 @@ static umode_t dev_dax_visible(struct kobject *kobj, struct attribute *a, int n)
>  }
>
>  static struct attribute *dev_dax_attributes[] = {
> +       &dev_attr_modalias.attr,
>         &dev_attr_size.attr,
>         &dev_attr_target_node.attr,
>         NULL,
> --
> 2.20.1
>
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] dax: add a 'modalias' attribute to DAX 'bus' devices
  2019-02-23  0:24 ` Dan Williams
@ 2019-02-24  1:29   ` Vishal Verma
  2019-02-24 18:24     ` Dan Williams
  0 siblings, 1 reply; 4+ messages in thread
From: Vishal Verma @ 2019-02-24  1:29 UTC (permalink / raw)
  To: Dan Williams, Vishal Verma; +Cc: Dave Hansen, linux-nvdimm

On Fri, 2019-02-22 at 16:24 -0800, Dan Williams wrote:
> Looks ok, but I think the changelog could be more accurate.
> 
> On Fri, Feb 22, 2019 at 3:59 PM Vishal Verma <vishal.l.verma@intel.com> wrote:
> > Add a 'modalias' attribute to devices under the DAX bus so that userspace
> > is able to dynamically load modules as needed.
> 
> The modalias is already published in the uevent which is how udev
> identifies the module. This patch would allow "modalias to module
> lookups" *outside* of the typical uevent used for dynamically loading
> modules.
> 
> Care to fix up the changelog with that detail and why userspace needs
> to do these lookups in addition to the typical uevent lookups?
> 

Yes, thanks for the feedback, I think this reads better:

8<----

>From 1e399f52f21c22e4c4bd5d48b26f539e12342beb Mon Sep 17 00:00:00 2001
From: Vishal Verma <vishal.l.verma@intel.com>
Date: Fri, 22 Feb 2019 16:58:54 -0700
Subject: [PATCH v2] dax: add a 'modalias' attribute to DAX 'bus' devices

Add a 'modalias' attribute to devices under the DAX bus so that userspace
is able to dynamically load modules as needed.

Normally, udev can get the modalias from 'uevent', and that is correctly
set up by the DAX bus. However other tooling such as 'libndctl' for
interacting with drivers/nvdimm/, and 'libdaxctl' for drivers/dax/ can
also use the modalias to dynamically load modules via libkmod lookups.

The 'nd' bus set up by the libnvdimm subsystem exports a modalias
attribute. Imitate this to export the same for the 'dax' bus.

Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
 drivers/dax/bus.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c
index 28c3324271ac..2109cfe80219 100644
--- a/drivers/dax/bus.c
+++ b/drivers/dax/bus.c
@@ -295,6 +295,17 @@ static ssize_t target_node_show(struct device *dev,
 }
 static DEVICE_ATTR_RO(target_node);
 
+static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
+		char *buf)
+{
+	/*
+	 * We only ever expect to handle device-dax instances, i.e. the
+	 * @type argument to MODULE_ALIAS_DAX_DEVICE() is always zero
+	 */
+	return sprintf(buf, DAX_DEVICE_MODALIAS_FMT "\n", 0);
+}
+static DEVICE_ATTR_RO(modalias);
+
 static umode_t dev_dax_visible(struct kobject *kobj, struct attribute *a, int
n)
 {
 	struct device *dev = container_of(kobj, struct device, kobj);
@@ -306,6 +317,7 @@ static umode_t dev_dax_visible(struct kobject *kobj, struct
attribute *a, int n)
 }
 
 static struct attribute *dev_dax_attributes[] = {
+	&dev_attr_modalias.attr,
 	&dev_attr_size.attr,
 	&dev_attr_target_node.attr,
 	NULL,
-- 
2.20.1



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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] dax: add a 'modalias' attribute to DAX 'bus' devices
  2019-02-24  1:29   ` Vishal Verma
@ 2019-02-24 18:24     ` Dan Williams
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Williams @ 2019-02-24 18:24 UTC (permalink / raw)
  To: Vishal Verma; +Cc: Dave Hansen, linux-nvdimm

On Sat, Feb 23, 2019 at 5:29 PM Vishal Verma <vishal@kernel.org> wrote:
>
> On Fri, 2019-02-22 at 16:24 -0800, Dan Williams wrote:
> > Looks ok, but I think the changelog could be more accurate.
> >
> > On Fri, Feb 22, 2019 at 3:59 PM Vishal Verma <vishal.l.verma@intel.com> wrote:
> > > Add a 'modalias' attribute to devices under the DAX bus so that userspace
> > > is able to dynamically load modules as needed.
> >
> > The modalias is already published in the uevent which is how udev
> > identifies the module. This patch would allow "modalias to module
> > lookups" *outside* of the typical uevent used for dynamically loading
> > modules.
> >
> > Care to fix up the changelog with that detail and why userspace needs
> > to do these lookups in addition to the typical uevent lookups?
> >
>
> Yes, thanks for the feedback, I think this reads better:
>
> 8<----
>
> From 1e399f52f21c22e4c4bd5d48b26f539e12342beb Mon Sep 17 00:00:00 2001
> From: Vishal Verma <vishal.l.verma@intel.com>
> Date: Fri, 22 Feb 2019 16:58:54 -0700
> Subject: [PATCH v2] dax: add a 'modalias' attribute to DAX 'bus' devices
>
> Add a 'modalias' attribute to devices under the DAX bus so that userspace
> is able to dynamically load modules as needed.
>
> Normally, udev can get the modalias from 'uevent', and that is correctly
> set up by the DAX bus. However other tooling such as 'libndctl' for
> interacting with drivers/nvdimm/, and 'libdaxctl' for drivers/dax/ can
> also use the modalias to dynamically load modules via libkmod lookups.
>
> The 'nd' bus set up by the libnvdimm subsystem exports a modalias
> attribute. Imitate this to export the same for the 'dax' bus.
>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Cc: Dave Hansen <dave.hansen@linux.intel.com>
> Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>

Looks good,

Reviewed-by: Dan Williams <dan.j.williams@intel.com>
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-02-24 18:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-22 23:58 [PATCH] dax: add a 'modalias' attribute to DAX 'bus' devices Vishal Verma
2019-02-23  0:24 ` Dan Williams
2019-02-24  1:29   ` Vishal Verma
2019-02-24 18:24     ` Dan Williams

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.