All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] vdpa: regist vhost-vdpa dev class
@ 2021-12-24  7:04 ` Yi Wang
  0 siblings, 0 replies; 6+ messages in thread
From: Yi Wang @ 2021-12-24  7:04 UTC (permalink / raw)
  To: mst
  Cc: sgarzare, jasowang, kvm, virtualization, netdev, linux-kernel,
	xue.zhihong, wang.yi59, wang.liang82, Zhang Min

From: Zhang Min <zhang.min9@zte.com.cn>

Some applications like kata-containers need to acquire MAJOR/MINOR/DEVNAME
for devInfo [1], so regist vhost-vdpa dev class to expose uevent.

1. https://github.com/kata-containers/kata-containers/blob/main/src/runtime/virtcontainers/device/config/config.go

Signed-off-by: Zhang Min <zhang.min9@zte.com.cn>
Signed-off-by: Yi Wang <wang.yi59@zte.com.cn>
---
v2: remove redundant vhost_vdpa_class reset and pr_warn, adjust location
    of *vhost_vdpa_class impl and class_destroy.

 drivers/vhost/vdpa.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
index e3c4f059b21a..55e966c508c8 100644
--- a/drivers/vhost/vdpa.c
+++ b/drivers/vhost/vdpa.c
@@ -53,6 +53,7 @@ struct vhost_vdpa {
 static DEFINE_IDA(vhost_vdpa_ida);
 
 static dev_t vhost_vdpa_major;
+static struct class *vhost_vdpa_class;
 
 static void handle_vq_kick(struct vhost_work *work)
 {
@@ -1140,6 +1141,7 @@ static int vhost_vdpa_probe(struct vdpa_device *vdpa)
 	v->dev.release = vhost_vdpa_release_dev;
 	v->dev.parent = &vdpa->dev;
 	v->dev.devt = MKDEV(MAJOR(vhost_vdpa_major), minor);
+	v->dev.class = vhost_vdpa_class;
 	v->vqs = kmalloc_array(v->nvqs, sizeof(struct vhost_virtqueue),
 			       GFP_KERNEL);
 	if (!v->vqs) {
@@ -1197,6 +1199,10 @@ static int __init vhost_vdpa_init(void)
 {
 	int r;
 
+	vhost_vdpa_class = class_create(THIS_MODULE, "vhost-vdpa");
+	if (IS_ERR(vhost_vdpa_class))
+		return PTR_ERR(vhost_vdpa_class);
+
 	r = alloc_chrdev_region(&vhost_vdpa_major, 0, VHOST_VDPA_DEV_MAX,
 				"vhost-vdpa");
 	if (r)
@@ -1211,6 +1217,7 @@ static int __init vhost_vdpa_init(void)
 err_vdpa_register_driver:
 	unregister_chrdev_region(vhost_vdpa_major, VHOST_VDPA_DEV_MAX);
 err_alloc_chrdev:
+	class_destroy(vhost_vdpa_class);
 	return r;
 }
 module_init(vhost_vdpa_init);
@@ -1219,6 +1226,7 @@ static void __exit vhost_vdpa_exit(void)
 {
 	vdpa_unregister_driver(&vhost_vdpa_driver);
 	unregister_chrdev_region(vhost_vdpa_major, VHOST_VDPA_DEV_MAX);
+	class_destroy(vhost_vdpa_class);
 }
 module_exit(vhost_vdpa_exit);
 
-- 
2.27.0

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

* [PATCH v2] vdpa: regist vhost-vdpa dev class
@ 2021-12-24  7:04 ` Yi Wang
  0 siblings, 0 replies; 6+ messages in thread
From: Yi Wang @ 2021-12-24  7:04 UTC (permalink / raw)
  To: mst
  Cc: wang.yi59, Zhang Min, wang.liang82, kvm, netdev, linux-kernel,
	virtualization, xue.zhihong

From: Zhang Min <zhang.min9@zte.com.cn>

Some applications like kata-containers need to acquire MAJOR/MINOR/DEVNAME
for devInfo [1], so regist vhost-vdpa dev class to expose uevent.

1. https://github.com/kata-containers/kata-containers/blob/main/src/runtime/virtcontainers/device/config/config.go

Signed-off-by: Zhang Min <zhang.min9@zte.com.cn>
Signed-off-by: Yi Wang <wang.yi59@zte.com.cn>
---
v2: remove redundant vhost_vdpa_class reset and pr_warn, adjust location
    of *vhost_vdpa_class impl and class_destroy.

 drivers/vhost/vdpa.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
index e3c4f059b21a..55e966c508c8 100644
--- a/drivers/vhost/vdpa.c
+++ b/drivers/vhost/vdpa.c
@@ -53,6 +53,7 @@ struct vhost_vdpa {
 static DEFINE_IDA(vhost_vdpa_ida);
 
 static dev_t vhost_vdpa_major;
+static struct class *vhost_vdpa_class;
 
 static void handle_vq_kick(struct vhost_work *work)
 {
@@ -1140,6 +1141,7 @@ static int vhost_vdpa_probe(struct vdpa_device *vdpa)
 	v->dev.release = vhost_vdpa_release_dev;
 	v->dev.parent = &vdpa->dev;
 	v->dev.devt = MKDEV(MAJOR(vhost_vdpa_major), minor);
+	v->dev.class = vhost_vdpa_class;
 	v->vqs = kmalloc_array(v->nvqs, sizeof(struct vhost_virtqueue),
 			       GFP_KERNEL);
 	if (!v->vqs) {
@@ -1197,6 +1199,10 @@ static int __init vhost_vdpa_init(void)
 {
 	int r;
 
+	vhost_vdpa_class = class_create(THIS_MODULE, "vhost-vdpa");
+	if (IS_ERR(vhost_vdpa_class))
+		return PTR_ERR(vhost_vdpa_class);
+
 	r = alloc_chrdev_region(&vhost_vdpa_major, 0, VHOST_VDPA_DEV_MAX,
 				"vhost-vdpa");
 	if (r)
@@ -1211,6 +1217,7 @@ static int __init vhost_vdpa_init(void)
 err_vdpa_register_driver:
 	unregister_chrdev_region(vhost_vdpa_major, VHOST_VDPA_DEV_MAX);
 err_alloc_chrdev:
+	class_destroy(vhost_vdpa_class);
 	return r;
 }
 module_init(vhost_vdpa_init);
@@ -1219,6 +1226,7 @@ static void __exit vhost_vdpa_exit(void)
 {
 	vdpa_unregister_driver(&vhost_vdpa_driver);
 	unregister_chrdev_region(vhost_vdpa_major, VHOST_VDPA_DEV_MAX);
+	class_destroy(vhost_vdpa_class);
 }
 module_exit(vhost_vdpa_exit);
 
-- 
2.27.0
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

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

* Re: [PATCH v2] vdpa: regist vhost-vdpa dev class
  2021-12-24  7:04 ` Yi Wang
@ 2022-01-04  3:44   ` Jason Wang
  -1 siblings, 0 replies; 6+ messages in thread
From: Jason Wang @ 2022-01-04  3:44 UTC (permalink / raw)
  To: Yi Wang
  Cc: mst, Stefano Garzarella, kvm, virtualization, netdev,
	linux-kernel, xue.zhihong, wang.liang82, Zhang Min

On Fri, Dec 24, 2021 at 3:13 PM Yi Wang <wang.yi59@zte.com.cn> wrote:
>
> From: Zhang Min <zhang.min9@zte.com.cn>
>
> Some applications like kata-containers need to acquire MAJOR/MINOR/DEVNAME
> for devInfo [1], so regist vhost-vdpa dev class to expose uevent.

Hi:

I think we need to be more verbose here e.g:

1) why can't we get major/minor with the current interface
2) what kind of the uevent is required and not supported currently

Thanks

>
> 1. https://github.com/kata-containers/kata-containers/blob/main/src/runtime/virtcontainers/device/config/config.go
>
> Signed-off-by: Zhang Min <zhang.min9@zte.com.cn>
> Signed-off-by: Yi Wang <wang.yi59@zte.com.cn>
> ---
> v2: remove redundant vhost_vdpa_class reset and pr_warn, adjust location
>     of *vhost_vdpa_class impl and class_destroy.
>
>  drivers/vhost/vdpa.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
> index e3c4f059b21a..55e966c508c8 100644
> --- a/drivers/vhost/vdpa.c
> +++ b/drivers/vhost/vdpa.c
> @@ -53,6 +53,7 @@ struct vhost_vdpa {
>  static DEFINE_IDA(vhost_vdpa_ida);
>
>  static dev_t vhost_vdpa_major;
> +static struct class *vhost_vdpa_class;
>
>  static void handle_vq_kick(struct vhost_work *work)
>  {
> @@ -1140,6 +1141,7 @@ static int vhost_vdpa_probe(struct vdpa_device *vdpa)
>         v->dev.release = vhost_vdpa_release_dev;
>         v->dev.parent = &vdpa->dev;
>         v->dev.devt = MKDEV(MAJOR(vhost_vdpa_major), minor);
> +       v->dev.class = vhost_vdpa_class;
>         v->vqs = kmalloc_array(v->nvqs, sizeof(struct vhost_virtqueue),
>                                GFP_KERNEL);
>         if (!v->vqs) {
> @@ -1197,6 +1199,10 @@ static int __init vhost_vdpa_init(void)
>  {
>         int r;
>
> +       vhost_vdpa_class = class_create(THIS_MODULE, "vhost-vdpa");
> +       if (IS_ERR(vhost_vdpa_class))
> +               return PTR_ERR(vhost_vdpa_class);
> +
>         r = alloc_chrdev_region(&vhost_vdpa_major, 0, VHOST_VDPA_DEV_MAX,
>                                 "vhost-vdpa");
>         if (r)
> @@ -1211,6 +1217,7 @@ static int __init vhost_vdpa_init(void)
>  err_vdpa_register_driver:
>         unregister_chrdev_region(vhost_vdpa_major, VHOST_VDPA_DEV_MAX);
>  err_alloc_chrdev:
> +       class_destroy(vhost_vdpa_class);
>         return r;
>  }
>  module_init(vhost_vdpa_init);
> @@ -1219,6 +1226,7 @@ static void __exit vhost_vdpa_exit(void)
>  {
>         vdpa_unregister_driver(&vhost_vdpa_driver);
>         unregister_chrdev_region(vhost_vdpa_major, VHOST_VDPA_DEV_MAX);
> +       class_destroy(vhost_vdpa_class);
>  }
>  module_exit(vhost_vdpa_exit);
>
> --
> 2.27.0
>


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

* Re: [PATCH v2] vdpa: regist vhost-vdpa dev class
@ 2022-01-04  3:44   ` Jason Wang
  0 siblings, 0 replies; 6+ messages in thread
From: Jason Wang @ 2022-01-04  3:44 UTC (permalink / raw)
  To: Yi Wang
  Cc: Zhang Min, wang.liang82, kvm, mst, netdev, linux-kernel,
	virtualization, xue.zhihong

On Fri, Dec 24, 2021 at 3:13 PM Yi Wang <wang.yi59@zte.com.cn> wrote:
>
> From: Zhang Min <zhang.min9@zte.com.cn>
>
> Some applications like kata-containers need to acquire MAJOR/MINOR/DEVNAME
> for devInfo [1], so regist vhost-vdpa dev class to expose uevent.

Hi:

I think we need to be more verbose here e.g:

1) why can't we get major/minor with the current interface
2) what kind of the uevent is required and not supported currently

Thanks

>
> 1. https://github.com/kata-containers/kata-containers/blob/main/src/runtime/virtcontainers/device/config/config.go
>
> Signed-off-by: Zhang Min <zhang.min9@zte.com.cn>
> Signed-off-by: Yi Wang <wang.yi59@zte.com.cn>
> ---
> v2: remove redundant vhost_vdpa_class reset and pr_warn, adjust location
>     of *vhost_vdpa_class impl and class_destroy.
>
>  drivers/vhost/vdpa.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
> index e3c4f059b21a..55e966c508c8 100644
> --- a/drivers/vhost/vdpa.c
> +++ b/drivers/vhost/vdpa.c
> @@ -53,6 +53,7 @@ struct vhost_vdpa {
>  static DEFINE_IDA(vhost_vdpa_ida);
>
>  static dev_t vhost_vdpa_major;
> +static struct class *vhost_vdpa_class;
>
>  static void handle_vq_kick(struct vhost_work *work)
>  {
> @@ -1140,6 +1141,7 @@ static int vhost_vdpa_probe(struct vdpa_device *vdpa)
>         v->dev.release = vhost_vdpa_release_dev;
>         v->dev.parent = &vdpa->dev;
>         v->dev.devt = MKDEV(MAJOR(vhost_vdpa_major), minor);
> +       v->dev.class = vhost_vdpa_class;
>         v->vqs = kmalloc_array(v->nvqs, sizeof(struct vhost_virtqueue),
>                                GFP_KERNEL);
>         if (!v->vqs) {
> @@ -1197,6 +1199,10 @@ static int __init vhost_vdpa_init(void)
>  {
>         int r;
>
> +       vhost_vdpa_class = class_create(THIS_MODULE, "vhost-vdpa");
> +       if (IS_ERR(vhost_vdpa_class))
> +               return PTR_ERR(vhost_vdpa_class);
> +
>         r = alloc_chrdev_region(&vhost_vdpa_major, 0, VHOST_VDPA_DEV_MAX,
>                                 "vhost-vdpa");
>         if (r)
> @@ -1211,6 +1217,7 @@ static int __init vhost_vdpa_init(void)
>  err_vdpa_register_driver:
>         unregister_chrdev_region(vhost_vdpa_major, VHOST_VDPA_DEV_MAX);
>  err_alloc_chrdev:
> +       class_destroy(vhost_vdpa_class);
>         return r;
>  }
>  module_init(vhost_vdpa_init);
> @@ -1219,6 +1226,7 @@ static void __exit vhost_vdpa_exit(void)
>  {
>         vdpa_unregister_driver(&vhost_vdpa_driver);
>         unregister_chrdev_region(vhost_vdpa_major, VHOST_VDPA_DEV_MAX);
> +       class_destroy(vhost_vdpa_class);
>  }
>  module_exit(vhost_vdpa_exit);
>
> --
> 2.27.0
>

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

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

* Re:[PATCH v2] vdpa: regist vhost-vdpa dev class
  2022-01-04  3:44   ` Jason Wang
@ 2022-01-11  7:09     ` wang.yi59
  -1 siblings, 0 replies; 6+ messages in thread
From: wang.yi59 @ 2022-01-11  7:09 UTC (permalink / raw)
  To: jasowang
  Cc: mst, sgarzare, kvm, virtualization, netdev, linux-kernel,
	xue.zhihong, wang.liang82, zhang.min9

Hi Jason,
> On Fri, Dec 24, 2021 at 3:13 PM Yi Wangwrote:
> >
> > From: Zhang Min
> >
> > Some applications like kata-containers need to acquire MAJOR/MINOR/DEVNAME
> > for devInfo [1], so regist vhost-vdpa dev class to expose uevent.
>
> Hi:
>
> I think we need to be more verbose here e.g:
>
> 1) why can't we get major/minor with the current interface

Although major/minor can be acquired in /sys/bus/vdpa/devices/vdpa0/vhost-vdpa/vhost-vdpa-0/dev,
applications like kata-containers prefer and actually have tried to obtain them
in /sys/class/vhost-vdpa/vhost-vdpa-0/uevent, such like [1].

> 2) what kind of the uevent is required and not supported currently

The items needed show in uevent are MAJOR MINOR DEVNAME that vhost_vdpa_probe
currently has registed, but dev_uevent_filter failed to pass and uevent show is
empty now, so we regist dev class to let dev_uevent_filter pass and show them.

1. https://github.com/kata-containers/kata-containers/blob/main/src/runtime/virtcontainers/device/config/config.go

>
> Thanks
>
> >
> > 1. https://github.com/kata-containers/kata-containers/blob/main/src/runtime/virtcontainers/device/config/config.go
> >
> > Signed-off-by: Zhang Min

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

* Re:[PATCH v2] vdpa: regist vhost-vdpa dev class
@ 2022-01-11  7:09     ` wang.yi59
  0 siblings, 0 replies; 6+ messages in thread
From: wang.yi59 @ 2022-01-11  7:09 UTC (permalink / raw)
  To: jasowang
  Cc: zhang.min9, wang.liang82, kvm, mst, netdev, linux-kernel,
	virtualization, xue.zhihong

Hi Jason,
> On Fri, Dec 24, 2021 at 3:13 PM Yi Wangwrote:
> >
> > From: Zhang Min
> >
> > Some applications like kata-containers need to acquire MAJOR/MINOR/DEVNAME
> > for devInfo [1], so regist vhost-vdpa dev class to expose uevent.
>
> Hi:
>
> I think we need to be more verbose here e.g:
>
> 1) why can't we get major/minor with the current interface

Although major/minor can be acquired in /sys/bus/vdpa/devices/vdpa0/vhost-vdpa/vhost-vdpa-0/dev,
applications like kata-containers prefer and actually have tried to obtain them
in /sys/class/vhost-vdpa/vhost-vdpa-0/uevent, such like [1].

> 2) what kind of the uevent is required and not supported currently

The items needed show in uevent are MAJOR MINOR DEVNAME that vhost_vdpa_probe
currently has registed, but dev_uevent_filter failed to pass and uevent show is
empty now, so we regist dev class to let dev_uevent_filter pass and show them.

1. https://github.com/kata-containers/kata-containers/blob/main/src/runtime/virtcontainers/device/config/config.go

>
> Thanks
>
> >
> > 1. https://github.com/kata-containers/kata-containers/blob/main/src/runtime/virtcontainers/device/config/config.go
> >
> > Signed-off-by: Zhang Min
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

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

end of thread, other threads:[~2022-01-11  7:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-24  7:04 [PATCH v2] vdpa: regist vhost-vdpa dev class Yi Wang
2021-12-24  7:04 ` Yi Wang
2022-01-04  3:44 ` Jason Wang
2022-01-04  3:44   ` Jason Wang
2022-01-11  7:09   ` wang.yi59
2022-01-11  7:09     ` wang.yi59

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.