All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] um: virtio_uml: allow probing from devicetree
@ 2021-12-21  9:04 ` Vincent Whitchurch
  0 siblings, 0 replies; 16+ messages in thread
From: Vincent Whitchurch @ 2021-12-21  9:04 UTC (permalink / raw)
  To: Jeff Dike, Richard Weinberger, Anton Ivanov
  Cc: kernel, johannes.berg, devicetree, Vincent Whitchurch, linux-um,
	linux-kernel

Allow the virtio_uml device to be probed from the devicetree so that
sub-devices can be specified using the standard virtio bindings, for
example:

  virtio@1 {
    compatible = "virtio,uml";
    socket-path = "i2c.sock";
    virtio-device-id = <0x22>;

    i2c-controller {
      compatible = "virtio,device22";
      #address-cells = <0x01>;
      #size-cells = <0x00>;

      light-sensor@01 {
        compatible = "ti,opt3001";
        reg = <0x01>;
      };
    };
  };

Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
---

Notes:
    Requires the UML devicetree support I posted a couple of weeks ago:
    https://lore.kernel.org/all/20211208151123.29313-1-vincent.whitchurch@axis.com/

 arch/um/drivers/virtio_uml.c | 50 +++++++++++++++++++++++++++++++++---
 1 file changed, 47 insertions(+), 3 deletions(-)

diff --git a/arch/um/drivers/virtio_uml.c b/arch/um/drivers/virtio_uml.c
index d51e445df797..3e4fa0f262d3 100644
--- a/arch/um/drivers/virtio_uml.c
+++ b/arch/um/drivers/virtio_uml.c
@@ -21,6 +21,7 @@
  * Based on Virtio MMIO driver by Pawel Moll, copyright 2011-2014, ARM Ltd.
  */
 #include <linux/module.h>
+#include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 #include <linux/virtio.h>
@@ -49,6 +50,7 @@ struct virtio_uml_platform_data {
 struct virtio_uml_device {
 	struct virtio_device vdev;
 	struct platform_device *pdev;
+	struct virtio_uml_platform_data *pdata;
 
 	spinlock_t sock_lock;
 	int sock, req_fd, irq;
@@ -149,7 +151,7 @@ static int vhost_user_recv(struct virtio_uml_device *vu_dev,
 	if (rc == -ECONNRESET && vu_dev->registered) {
 		struct virtio_uml_platform_data *pdata;
 
-		pdata = vu_dev->pdev->dev.platform_data;
+		pdata = vu_dev->pdata;
 
 		virtio_break_device(&vu_dev->vdev);
 		schedule_work(&pdata->conn_broken_wk);
@@ -1113,21 +1115,63 @@ void virtio_uml_set_no_vq_suspend(struct virtio_device *vdev,
 		 no_vq_suspend ? "dis" : "en");
 }
 
+static void vu_of_conn_broken(struct work_struct *wk)
+{
+	/*
+	 * We can't remove the device from the devicetree so the only thing we
+	 * can do is warn.
+	 */
+	WARN_ON(1);
+}
+
 /* Platform device */
 
+static struct virtio_uml_platform_data *
+virtio_uml_create_pdata(struct platform_device *pdev)
+{
+	struct device_node *np = pdev->dev.of_node;
+	struct virtio_uml_platform_data *pdata;
+	int ret;
+
+	if (!np)
+		return ERR_PTR(-EINVAL);
+
+	pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
+	if (!pdata)
+		return ERR_PTR(-ENOMEM);
+
+	INIT_WORK(&pdata->conn_broken_wk, vu_of_conn_broken);
+	pdata->pdev = pdev;
+
+	ret = of_property_read_string(np, "socket-path", &pdata->socket_path);
+	if (ret)
+		return ERR_PTR(ret);
+
+	ret = of_property_read_u32(np, "virtio-device-id",
+				   &pdata->virtio_device_id);
+	if (ret)
+		return ERR_PTR(ret);
+
+	return pdata;
+}
+
 static int virtio_uml_probe(struct platform_device *pdev)
 {
 	struct virtio_uml_platform_data *pdata = pdev->dev.platform_data;
 	struct virtio_uml_device *vu_dev;
 	int rc;
 
-	if (!pdata)
-		return -EINVAL;
+	if (!pdata) {
+		pdata = virtio_uml_create_pdata(pdev);
+		if (IS_ERR(pdata))
+			return PTR_ERR(pdata);
+	}
 
 	vu_dev = kzalloc(sizeof(*vu_dev), GFP_KERNEL);
 	if (!vu_dev)
 		return -ENOMEM;
 
+	vu_dev->pdata = pdata;
 	vu_dev->vdev.dev.parent = &pdev->dev;
 	vu_dev->vdev.dev.release = virtio_uml_release_dev;
 	vu_dev->vdev.config = &virtio_uml_config_ops;
-- 
2.33.1


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

* [PATCH] um: virtio_uml: allow probing from devicetree
@ 2021-12-21  9:04 ` Vincent Whitchurch
  0 siblings, 0 replies; 16+ messages in thread
From: Vincent Whitchurch @ 2021-12-21  9:04 UTC (permalink / raw)
  To: Jeff Dike, Richard Weinberger, Anton Ivanov
  Cc: kernel, johannes.berg, devicetree, Vincent Whitchurch, linux-um,
	linux-kernel

Allow the virtio_uml device to be probed from the devicetree so that
sub-devices can be specified using the standard virtio bindings, for
example:

  virtio@1 {
    compatible = "virtio,uml";
    socket-path = "i2c.sock";
    virtio-device-id = <0x22>;

    i2c-controller {
      compatible = "virtio,device22";
      #address-cells = <0x01>;
      #size-cells = <0x00>;

      light-sensor@01 {
        compatible = "ti,opt3001";
        reg = <0x01>;
      };
    };
  };

Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
---

Notes:
    Requires the UML devicetree support I posted a couple of weeks ago:
    https://lore.kernel.org/all/20211208151123.29313-1-vincent.whitchurch@axis.com/

 arch/um/drivers/virtio_uml.c | 50 +++++++++++++++++++++++++++++++++---
 1 file changed, 47 insertions(+), 3 deletions(-)

diff --git a/arch/um/drivers/virtio_uml.c b/arch/um/drivers/virtio_uml.c
index d51e445df797..3e4fa0f262d3 100644
--- a/arch/um/drivers/virtio_uml.c
+++ b/arch/um/drivers/virtio_uml.c
@@ -21,6 +21,7 @@
  * Based on Virtio MMIO driver by Pawel Moll, copyright 2011-2014, ARM Ltd.
  */
 #include <linux/module.h>
+#include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 #include <linux/virtio.h>
@@ -49,6 +50,7 @@ struct virtio_uml_platform_data {
 struct virtio_uml_device {
 	struct virtio_device vdev;
 	struct platform_device *pdev;
+	struct virtio_uml_platform_data *pdata;
 
 	spinlock_t sock_lock;
 	int sock, req_fd, irq;
@@ -149,7 +151,7 @@ static int vhost_user_recv(struct virtio_uml_device *vu_dev,
 	if (rc == -ECONNRESET && vu_dev->registered) {
 		struct virtio_uml_platform_data *pdata;
 
-		pdata = vu_dev->pdev->dev.platform_data;
+		pdata = vu_dev->pdata;
 
 		virtio_break_device(&vu_dev->vdev);
 		schedule_work(&pdata->conn_broken_wk);
@@ -1113,21 +1115,63 @@ void virtio_uml_set_no_vq_suspend(struct virtio_device *vdev,
 		 no_vq_suspend ? "dis" : "en");
 }
 
+static void vu_of_conn_broken(struct work_struct *wk)
+{
+	/*
+	 * We can't remove the device from the devicetree so the only thing we
+	 * can do is warn.
+	 */
+	WARN_ON(1);
+}
+
 /* Platform device */
 
+static struct virtio_uml_platform_data *
+virtio_uml_create_pdata(struct platform_device *pdev)
+{
+	struct device_node *np = pdev->dev.of_node;
+	struct virtio_uml_platform_data *pdata;
+	int ret;
+
+	if (!np)
+		return ERR_PTR(-EINVAL);
+
+	pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
+	if (!pdata)
+		return ERR_PTR(-ENOMEM);
+
+	INIT_WORK(&pdata->conn_broken_wk, vu_of_conn_broken);
+	pdata->pdev = pdev;
+
+	ret = of_property_read_string(np, "socket-path", &pdata->socket_path);
+	if (ret)
+		return ERR_PTR(ret);
+
+	ret = of_property_read_u32(np, "virtio-device-id",
+				   &pdata->virtio_device_id);
+	if (ret)
+		return ERR_PTR(ret);
+
+	return pdata;
+}
+
 static int virtio_uml_probe(struct platform_device *pdev)
 {
 	struct virtio_uml_platform_data *pdata = pdev->dev.platform_data;
 	struct virtio_uml_device *vu_dev;
 	int rc;
 
-	if (!pdata)
-		return -EINVAL;
+	if (!pdata) {
+		pdata = virtio_uml_create_pdata(pdev);
+		if (IS_ERR(pdata))
+			return PTR_ERR(pdata);
+	}
 
 	vu_dev = kzalloc(sizeof(*vu_dev), GFP_KERNEL);
 	if (!vu_dev)
 		return -ENOMEM;
 
+	vu_dev->pdata = pdata;
 	vu_dev->vdev.dev.parent = &pdev->dev;
 	vu_dev->vdev.dev.release = virtio_uml_release_dev;
 	vu_dev->vdev.config = &virtio_uml_config_ops;
-- 
2.33.1


_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um


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

* Re: [PATCH] um: virtio_uml: allow probing from devicetree
  2021-12-21  9:04 ` Vincent Whitchurch
@ 2021-12-21 20:48   ` Johannes Berg
  -1 siblings, 0 replies; 16+ messages in thread
From: Johannes Berg @ 2021-12-21 20:48 UTC (permalink / raw)
  To: Vincent Whitchurch, Jeff Dike, Richard Weinberger, Anton Ivanov,
	Rob Herring
  Cc: kernel, devicetree, linux-um, linux-kernel

On Tue, 2021-12-21 at 10:04 +0100, Vincent Whitchurch wrote:
> Allow the virtio_uml device to be probed from the devicetree so that
> sub-devices can be specified using the standard virtio bindings, for
> example:
> 
>   virtio@1 {
>     compatible = "virtio,uml";
>     socket-path = "i2c.sock";
>     virtio-device-id = <0x22>;
> 

Given this, maybe it should modify
Documentation/devicetree/bindings/virtio/virtio-device.yaml? Or actually
add a new Documentation/devicetree/bindings/virtio/uml.yaml I guess?

+Rob, because I'm not really into any of this.

Also, I'm not even sure we should/need to document the DT bits that are
basically only used for testing in the first place?

Code looks good to me.

johannes

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

* Re: [PATCH] um: virtio_uml: allow probing from devicetree
@ 2021-12-21 20:48   ` Johannes Berg
  0 siblings, 0 replies; 16+ messages in thread
From: Johannes Berg @ 2021-12-21 20:48 UTC (permalink / raw)
  To: Vincent Whitchurch, Jeff Dike, Richard Weinberger, Anton Ivanov,
	Rob Herring
  Cc: kernel, devicetree, linux-um, linux-kernel

On Tue, 2021-12-21 at 10:04 +0100, Vincent Whitchurch wrote:
> Allow the virtio_uml device to be probed from the devicetree so that
> sub-devices can be specified using the standard virtio bindings, for
> example:
> 
>   virtio@1 {
>     compatible = "virtio,uml";
>     socket-path = "i2c.sock";
>     virtio-device-id = <0x22>;
> 

Given this, maybe it should modify
Documentation/devicetree/bindings/virtio/virtio-device.yaml? Or actually
add a new Documentation/devicetree/bindings/virtio/uml.yaml I guess?

+Rob, because I'm not really into any of this.

Also, I'm not even sure we should/need to document the DT bits that are
basically only used for testing in the first place?

Code looks good to me.

johannes

_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um


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

* Re: [PATCH] um: virtio_uml: allow probing from devicetree
  2021-12-21 20:48   ` Johannes Berg
@ 2021-12-22 10:34     ` Vincent Whitchurch
  -1 siblings, 0 replies; 16+ messages in thread
From: Vincent Whitchurch @ 2021-12-22 10:34 UTC (permalink / raw)
  To: Johannes Berg
  Cc: Jeff Dike, Richard Weinberger, Anton Ivanov, Rob Herring, kernel,
	devicetree, linux-um, linux-kernel

On Tue, Dec 21, 2021 at 09:48:26PM +0100, Johannes Berg wrote:
> On Tue, 2021-12-21 at 10:04 +0100, Vincent Whitchurch wrote:
> > Allow the virtio_uml device to be probed from the devicetree so that
> > sub-devices can be specified using the standard virtio bindings, for
> > example:
> > 
> >   virtio@1 {
> >     compatible = "virtio,uml";
> >     socket-path = "i2c.sock";
> >     virtio-device-id = <0x22>;
> > 
> 
> Given this, maybe it should modify
> Documentation/devicetree/bindings/virtio/virtio-device.yaml? Or actually
> add a new Documentation/devicetree/bindings/virtio/uml.yaml I guess?
> 
> +Rob, because I'm not really into any of this.
> 
> Also, I'm not even sure we should/need to document the DT bits that are
> basically only used for testing in the first place?

I wasn't sure either, but Rob was OK with not documenting some other
bindings which are only used for testing[0], so I assumed that that
applied here too:

 [0] https://lore.kernel.org/all/5baa1ae6.1c69fb81.847f2.3ab1@mx.google.com/ 

Also, DT bindings are supposed to be generic and based on what the
hardware has, but here we have no hardware and something very Linux and
UML-specific.

> Code looks good to me.

Thanks!

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

* Re: [PATCH] um: virtio_uml: allow probing from devicetree
@ 2021-12-22 10:34     ` Vincent Whitchurch
  0 siblings, 0 replies; 16+ messages in thread
From: Vincent Whitchurch @ 2021-12-22 10:34 UTC (permalink / raw)
  To: Johannes Berg
  Cc: Jeff Dike, Richard Weinberger, Anton Ivanov, Rob Herring, kernel,
	devicetree, linux-um, linux-kernel

On Tue, Dec 21, 2021 at 09:48:26PM +0100, Johannes Berg wrote:
> On Tue, 2021-12-21 at 10:04 +0100, Vincent Whitchurch wrote:
> > Allow the virtio_uml device to be probed from the devicetree so that
> > sub-devices can be specified using the standard virtio bindings, for
> > example:
> > 
> >   virtio@1 {
> >     compatible = "virtio,uml";
> >     socket-path = "i2c.sock";
> >     virtio-device-id = <0x22>;
> > 
> 
> Given this, maybe it should modify
> Documentation/devicetree/bindings/virtio/virtio-device.yaml? Or actually
> add a new Documentation/devicetree/bindings/virtio/uml.yaml I guess?
> 
> +Rob, because I'm not really into any of this.
> 
> Also, I'm not even sure we should/need to document the DT bits that are
> basically only used for testing in the first place?

I wasn't sure either, but Rob was OK with not documenting some other
bindings which are only used for testing[0], so I assumed that that
applied here too:

 [0] https://lore.kernel.org/all/5baa1ae6.1c69fb81.847f2.3ab1@mx.google.com/ 

Also, DT bindings are supposed to be generic and based on what the
hardware has, but here we have no hardware and something very Linux and
UML-specific.

> Code looks good to me.

Thanks!

_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um


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

* Re: [PATCH] um: virtio_uml: allow probing from devicetree
  2021-12-22 10:34     ` Vincent Whitchurch
@ 2021-12-22 11:11       ` Anton Ivanov
  -1 siblings, 0 replies; 16+ messages in thread
From: Anton Ivanov @ 2021-12-22 11:11 UTC (permalink / raw)
  To: Vincent Whitchurch, Johannes Berg
  Cc: Jeff Dike, Richard Weinberger, Rob Herring, kernel, devicetree,
	linux-um, linux-kernel

On 22/12/2021 10:34, Vincent Whitchurch wrote:
> On Tue, Dec 21, 2021 at 09:48:26PM +0100, Johannes Berg wrote:
>> On Tue, 2021-12-21 at 10:04 +0100, Vincent Whitchurch wrote:
>>> Allow the virtio_uml device to be probed from the devicetree so that
>>> sub-devices can be specified using the standard virtio bindings, for
>>> example:
>>>
>>>    virtio@1 {
>>>      compatible = "virtio,uml";
>>>      socket-path = "i2c.sock";
>>>      virtio-device-id = <0x22>;
>>>
>>
>> Given this, maybe it should modify
>> Documentation/devicetree/bindings/virtio/virtio-device.yaml? Or actually
>> add a new Documentation/devicetree/bindings/virtio/uml.yaml I guess?
>>
>> +Rob, because I'm not really into any of this.
>>
>> Also, I'm not even sure we should/need to document the DT bits that are
>> basically only used for testing in the first place?
> 
> I wasn't sure either, but Rob was OK with not documenting some other
> bindings which are only used for testing[0], so I assumed that that
> applied here too:
> 
>   [0] https://lore.kernel.org/all/5baa1ae6.1c69fb81.847f2.3ab1@mx.google.com/
> 
> Also, DT bindings are supposed to be generic and based on what the
> hardware has, but here we have no hardware and something very Linux and
> UML-specific.

This will probably need to be added to the general UML documentation. I 
will take care of that once the patches are in the tree.

Brgds,

> 
>> Code looks good to me.
> 
> Thanks!
> 


-- 
Anton R. Ivanov
Cambridgegreys Limited. Registered in England. Company Number 10273661
https://www.cambridgegreys.com/

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

* Re: [PATCH] um: virtio_uml: allow probing from devicetree
@ 2021-12-22 11:11       ` Anton Ivanov
  0 siblings, 0 replies; 16+ messages in thread
From: Anton Ivanov @ 2021-12-22 11:11 UTC (permalink / raw)
  To: Vincent Whitchurch, Johannes Berg
  Cc: Jeff Dike, Richard Weinberger, Rob Herring, kernel, devicetree,
	linux-um, linux-kernel

On 22/12/2021 10:34, Vincent Whitchurch wrote:
> On Tue, Dec 21, 2021 at 09:48:26PM +0100, Johannes Berg wrote:
>> On Tue, 2021-12-21 at 10:04 +0100, Vincent Whitchurch wrote:
>>> Allow the virtio_uml device to be probed from the devicetree so that
>>> sub-devices can be specified using the standard virtio bindings, for
>>> example:
>>>
>>>    virtio@1 {
>>>      compatible = "virtio,uml";
>>>      socket-path = "i2c.sock";
>>>      virtio-device-id = <0x22>;
>>>
>>
>> Given this, maybe it should modify
>> Documentation/devicetree/bindings/virtio/virtio-device.yaml? Or actually
>> add a new Documentation/devicetree/bindings/virtio/uml.yaml I guess?
>>
>> +Rob, because I'm not really into any of this.
>>
>> Also, I'm not even sure we should/need to document the DT bits that are
>> basically only used for testing in the first place?
> 
> I wasn't sure either, but Rob was OK with not documenting some other
> bindings which are only used for testing[0], so I assumed that that
> applied here too:
> 
>   [0] https://lore.kernel.org/all/5baa1ae6.1c69fb81.847f2.3ab1@mx.google.com/
> 
> Also, DT bindings are supposed to be generic and based on what the
> hardware has, but here we have no hardware and something very Linux and
> UML-specific.

This will probably need to be added to the general UML documentation. I 
will take care of that once the patches are in the tree.

Brgds,

> 
>> Code looks good to me.
> 
> Thanks!
> 


-- 
Anton R. Ivanov
Cambridgegreys Limited. Registered in England. Company Number 10273661
https://www.cambridgegreys.com/

_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um


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

* Re: [PATCH] um: virtio_uml: allow probing from devicetree
  2021-12-22 11:11       ` Anton Ivanov
@ 2021-12-22 19:41         ` Richard Weinberger
  -1 siblings, 0 replies; 16+ messages in thread
From: Richard Weinberger @ 2021-12-22 19:41 UTC (permalink / raw)
  To: anton ivanov
  Cc: Vincent Whitchurch, Johannes Berg, Jeff Dike, Rob Herring,
	kernel, devicetree, linux-um, linux-kernel

----- Ursprüngliche Mail -----
> Von: "anton ivanov" <anton.ivanov@cambridgegreys.com> 
>> Also, DT bindings are supposed to be generic and based on what the
>> hardware has, but here we have no hardware and something very Linux and
>> UML-specific.
> 
> This will probably need to be added to the general UML documentation. I
> will take care of that once the patches are in the tree.

That would be great! Patch applied.

Thanks,
//richard

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

* Re: [PATCH] um: virtio_uml: allow probing from devicetree
@ 2021-12-22 19:41         ` Richard Weinberger
  0 siblings, 0 replies; 16+ messages in thread
From: Richard Weinberger @ 2021-12-22 19:41 UTC (permalink / raw)
  To: anton ivanov
  Cc: Vincent Whitchurch, Johannes Berg, Jeff Dike, Rob Herring,
	kernel, devicetree, linux-um, linux-kernel

----- Ursprüngliche Mail -----
> Von: "anton ivanov" <anton.ivanov@cambridgegreys.com> 
>> Also, DT bindings are supposed to be generic and based on what the
>> hardware has, but here we have no hardware and something very Linux and
>> UML-specific.
> 
> This will probably need to be added to the general UML documentation. I
> will take care of that once the patches are in the tree.

That would be great! Patch applied.

Thanks,
//richard

_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um

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

* [PATCH] um: Document dtb command line option
  2021-12-22 19:41         ` Richard Weinberger
@ 2022-01-04 10:44           ` anton.ivanov
  -1 siblings, 0 replies; 16+ messages in thread
From: anton.ivanov @ 2022-01-04 10:44 UTC (permalink / raw)
  To: linux-um
  Cc: linux-kernel, devicetree, kernel, robh+dt, jdike, johannes,
	vincent.whitchurch, richard, linux-doc, Anton Ivanov

From: Anton Ivanov <anton.ivanov@cambridgegreys.com>

Add documentation for the dtb command line option and the
ability to load/parse device trees.

Signed-off-by: Anton Ivanov <anton.ivanov@cambridgegreys.com>
---
 .../virt/uml/user_mode_linux_howto_v2.rst     | 20 +++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/Documentation/virt/uml/user_mode_linux_howto_v2.rst b/Documentation/virt/uml/user_mode_linux_howto_v2.rst
index 2cafd3c3c6cb..81986fe014d4 100644
--- a/Documentation/virt/uml/user_mode_linux_howto_v2.rst
+++ b/Documentation/virt/uml/user_mode_linux_howto_v2.rst
@@ -1189,6 +1189,26 @@ E.g. ``os_close_file()`` is just a wrapper around ``close()``
 which ensures that the userspace function close does not clash
 with similarly named function(s) in the kernel part.
 
+Using UML as a Test Platform
+============================
+
+UML is an excellent test platform for device driver development. As
+with most things UML, "some user assembly may be required". It is
+up to the user to build their emulation environment. UML at present
+provides only the kernel infrastructure.
+
+Part of this infrastructure is the ability to load and parse fdt
+device tree blobs as used in Arm or Open Firmware platforms. These
+are supplied as an optional extra argument to the kernel command
+line::
+
+    dtb=filename
+
+The device tree is loaded and parsed at boottime and is accessible by
+drivers which query it. At this moment in time this facility is
+intended solely for development purposes. UML's own devices do not
+query the device tree.
+
 Security Considerations
 -----------------------
 
-- 
2.30.2


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

* [PATCH] um: Document dtb command line option
@ 2022-01-04 10:44           ` anton.ivanov
  0 siblings, 0 replies; 16+ messages in thread
From: anton.ivanov @ 2022-01-04 10:44 UTC (permalink / raw)
  To: linux-um
  Cc: linux-kernel, devicetree, kernel, robh+dt, jdike, johannes,
	vincent.whitchurch, richard, linux-doc, Anton Ivanov

From: Anton Ivanov <anton.ivanov@cambridgegreys.com>

Add documentation for the dtb command line option and the
ability to load/parse device trees.

Signed-off-by: Anton Ivanov <anton.ivanov@cambridgegreys.com>
---
 .../virt/uml/user_mode_linux_howto_v2.rst     | 20 +++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/Documentation/virt/uml/user_mode_linux_howto_v2.rst b/Documentation/virt/uml/user_mode_linux_howto_v2.rst
index 2cafd3c3c6cb..81986fe014d4 100644
--- a/Documentation/virt/uml/user_mode_linux_howto_v2.rst
+++ b/Documentation/virt/uml/user_mode_linux_howto_v2.rst
@@ -1189,6 +1189,26 @@ E.g. ``os_close_file()`` is just a wrapper around ``close()``
 which ensures that the userspace function close does not clash
 with similarly named function(s) in the kernel part.
 
+Using UML as a Test Platform
+============================
+
+UML is an excellent test platform for device driver development. As
+with most things UML, "some user assembly may be required". It is
+up to the user to build their emulation environment. UML at present
+provides only the kernel infrastructure.
+
+Part of this infrastructure is the ability to load and parse fdt
+device tree blobs as used in Arm or Open Firmware platforms. These
+are supplied as an optional extra argument to the kernel command
+line::
+
+    dtb=filename
+
+The device tree is loaded and parsed at boottime and is accessible by
+drivers which query it. At this moment in time this facility is
+intended solely for development purposes. UML's own devices do not
+query the device tree.
+
 Security Considerations
 -----------------------
 
-- 
2.30.2


_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um


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

* Re: [PATCH] um: virtio_uml: allow probing from devicetree
  2021-12-22 10:34     ` Vincent Whitchurch
@ 2022-01-04 14:13       ` Anton Ivanov
  -1 siblings, 0 replies; 16+ messages in thread
From: Anton Ivanov @ 2022-01-04 14:13 UTC (permalink / raw)
  To: Vincent Whitchurch, Johannes Berg
  Cc: Jeff Dike, Richard Weinberger, Rob Herring, kernel, devicetree,
	linux-um, linux-kernel



On 22/12/2021 10:34, Vincent Whitchurch wrote:
> On Tue, Dec 21, 2021 at 09:48:26PM +0100, Johannes Berg wrote:
>> On Tue, 2021-12-21 at 10:04 +0100, Vincent Whitchurch wrote:
>>> Allow the virtio_uml device to be probed from the devicetree so that
>>> sub-devices can be specified using the standard virtio bindings, for
>>> example:
>>>
>>>    virtio@1 {
>>>      compatible = "virtio,uml";
>>>      socket-path = "i2c.sock";
>>>      virtio-device-id = <0x22>;
>>>
>>
>> Given this, maybe it should modify
>> Documentation/devicetree/bindings/virtio/virtio-device.yaml? Or actually
>> add a new Documentation/devicetree/bindings/virtio/uml.yaml I guess?
>>
>> +Rob, because I'm not really into any of this.
>>
>> Also, I'm not even sure we should/need to document the DT bits that are
>> basically only used for testing in the first place?

If we start adding the UML devices themselves to the DT, we might as well add all of them.

In the doc patch have described the DT support as mostly for development at this point.

It can be a good alternative to the endless command line (especially for complex devices like f.e. l2tpv3).


> 
> I wasn't sure either, but Rob was OK with not documenting some other
> bindings which are only used for testing[0], so I assumed that that
> applied here too:
> 
>   [0] https://lore.kernel.org/all/5baa1ae6.1c69fb81.847f2.3ab1@mx.google.com/
> 
> Also, DT bindings are supposed to be generic and based on what the
> hardware has, but here we have no hardware and something very Linux and
> UML-specific.
> 
>> Code looks good to me.
> 
> Thanks!
> 

Brgds,

-- 
Anton R. Ivanov
Cambridgegreys Limited. Registered in England. Company Number 10273661
https://www.cambridgegreys.com/

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

* Re: [PATCH] um: virtio_uml: allow probing from devicetree
@ 2022-01-04 14:13       ` Anton Ivanov
  0 siblings, 0 replies; 16+ messages in thread
From: Anton Ivanov @ 2022-01-04 14:13 UTC (permalink / raw)
  To: Vincent Whitchurch, Johannes Berg
  Cc: Jeff Dike, Richard Weinberger, Rob Herring, kernel, devicetree,
	linux-um, linux-kernel



On 22/12/2021 10:34, Vincent Whitchurch wrote:
> On Tue, Dec 21, 2021 at 09:48:26PM +0100, Johannes Berg wrote:
>> On Tue, 2021-12-21 at 10:04 +0100, Vincent Whitchurch wrote:
>>> Allow the virtio_uml device to be probed from the devicetree so that
>>> sub-devices can be specified using the standard virtio bindings, for
>>> example:
>>>
>>>    virtio@1 {
>>>      compatible = "virtio,uml";
>>>      socket-path = "i2c.sock";
>>>      virtio-device-id = <0x22>;
>>>
>>
>> Given this, maybe it should modify
>> Documentation/devicetree/bindings/virtio/virtio-device.yaml? Or actually
>> add a new Documentation/devicetree/bindings/virtio/uml.yaml I guess?
>>
>> +Rob, because I'm not really into any of this.
>>
>> Also, I'm not even sure we should/need to document the DT bits that are
>> basically only used for testing in the first place?

If we start adding the UML devices themselves to the DT, we might as well add all of them.

In the doc patch have described the DT support as mostly for development at this point.

It can be a good alternative to the endless command line (especially for complex devices like f.e. l2tpv3).


> 
> I wasn't sure either, but Rob was OK with not documenting some other
> bindings which are only used for testing[0], so I assumed that that
> applied here too:
> 
>   [0] https://lore.kernel.org/all/5baa1ae6.1c69fb81.847f2.3ab1@mx.google.com/
> 
> Also, DT bindings are supposed to be generic and based on what the
> hardware has, but here we have no hardware and something very Linux and
> UML-specific.
> 
>> Code looks good to me.
> 
> Thanks!
> 

Brgds,

-- 
Anton R. Ivanov
Cambridgegreys Limited. Registered in England. Company Number 10273661
https://www.cambridgegreys.com/

_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um


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

* Re: [PATCH] um: Document dtb command line option
  2022-01-04 10:44           ` anton.ivanov
@ 2022-01-13 15:09             ` Vincent Whitchurch
  -1 siblings, 0 replies; 16+ messages in thread
From: Vincent Whitchurch @ 2022-01-13 15:09 UTC (permalink / raw)
  To: anton.ivanov
  Cc: linux-um, linux-kernel, devicetree, kernel, robh+dt, jdike,
	johannes, richard, linux-doc

On Tue, Jan 04, 2022 at 11:44:57AM +0100, anton.ivanov@cambridgegreys.com wrote:
> From: Anton Ivanov <anton.ivanov@cambridgegreys.com>
> 
> Add documentation for the dtb command line option and the
> ability to load/parse device trees.
> 
> Signed-off-by: Anton Ivanov <anton.ivanov@cambridgegreys.com>

LGTM, thanks.

Reviewed-by: Vincent Whitchurch <vincent.whitchurch@axis.com>

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

* Re: [PATCH] um: Document dtb command line option
@ 2022-01-13 15:09             ` Vincent Whitchurch
  0 siblings, 0 replies; 16+ messages in thread
From: Vincent Whitchurch @ 2022-01-13 15:09 UTC (permalink / raw)
  To: anton.ivanov
  Cc: linux-um, linux-kernel, devicetree, kernel, robh+dt, jdike,
	johannes, richard, linux-doc

On Tue, Jan 04, 2022 at 11:44:57AM +0100, anton.ivanov@cambridgegreys.com wrote:
> From: Anton Ivanov <anton.ivanov@cambridgegreys.com>
> 
> Add documentation for the dtb command line option and the
> ability to load/parse device trees.
> 
> Signed-off-by: Anton Ivanov <anton.ivanov@cambridgegreys.com>

LGTM, thanks.

Reviewed-by: Vincent Whitchurch <vincent.whitchurch@axis.com>

_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um


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

end of thread, other threads:[~2022-01-13 15:09 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-21  9:04 [PATCH] um: virtio_uml: allow probing from devicetree Vincent Whitchurch
2021-12-21  9:04 ` Vincent Whitchurch
2021-12-21 20:48 ` Johannes Berg
2021-12-21 20:48   ` Johannes Berg
2021-12-22 10:34   ` Vincent Whitchurch
2021-12-22 10:34     ` Vincent Whitchurch
2021-12-22 11:11     ` Anton Ivanov
2021-12-22 11:11       ` Anton Ivanov
2021-12-22 19:41       ` Richard Weinberger
2021-12-22 19:41         ` Richard Weinberger
2022-01-04 10:44         ` [PATCH] um: Document dtb command line option anton.ivanov
2022-01-04 10:44           ` anton.ivanov
2022-01-13 15:09           ` Vincent Whitchurch
2022-01-13 15:09             ` Vincent Whitchurch
2022-01-04 14:13     ` [PATCH] um: virtio_uml: allow probing from devicetree Anton Ivanov
2022-01-04 14:13       ` Anton Ivanov

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.