2022-01-26 19:43:18

by Lizhi Hou

[permalink] [raw]
Subject: [PATCH V1 Create empty OF root 0/1] XRT Alveo driver infrastructure overview

Hello,

Xilinx Alveo PCIe accelerator cards use flattened device tree to describe
HW subsystems or endpoints. Each device tree node represents a hardware
endpoint and each endpoint is an hardware unit which requires a driver.
The product detail:
https://www.xilinx.com/products/boards-and-kits/alveo.html

The feedback from the previous patches was to create a base tree if there
is not one and apply the unflattened device nodes by existing Linux
platform device and OF infrastructure. Please refer to previous discussion
with device tree and fpga maintainers.
https://lore.kernel.org/lkml/CAL_JsqJfyRymB=VxLuQqLpep+Q1Eie48dobv9sC5OizDz0d2DQ@mail.gmail.com/
https://lore.kernel.org/lkml/[email protected]/

This patch adds OF_EMPTY_ROOT config. When it is selected and there is not
a device tree, create an empty device tree root node.

Lizhi Hou (1):
of: create empty of root

drivers/of/Kconfig | 3 +++
drivers/of/Makefile | 1 +
drivers/of/of_empty_root.c | 51 ++++++++++++++++++++++++++++++++++++++
3 files changed, 55 insertions(+)
create mode 100644 drivers/of/of_empty_root.c

--
2.27.0


2022-01-26 19:51:29

by Lizhi Hou

[permalink] [raw]
Subject: [PATCH V1 Create empty OF root 1/1] of: create empty of root

Add OF_EMPTY_ROOT config. When it is selected and there is not a device
tree, create an empty device tree root node.

Signed-off-by: Sonal Santan <[email protected]>
Signed-off-by: Max Zhen <[email protected]>
Signed-off-by: Lizhi Hou <[email protected]>
---
drivers/of/Kconfig | 3 +++
drivers/of/Makefile | 1 +
drivers/of/of_empty_root.c | 51 ++++++++++++++++++++++++++++++++++++++
3 files changed, 55 insertions(+)
create mode 100644 drivers/of/of_empty_root.c

diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig
index 80b5fd44ab1c..42afb126f91a 100644
--- a/drivers/of/Kconfig
+++ b/drivers/of/Kconfig
@@ -94,4 +94,7 @@ config OF_DMA_DEFAULT_COHERENT
# arches should select this if DMA is coherent by default for OF devices
bool

+config OF_EMPTY_ROOT
+ bool
+
endif # OF
diff --git a/drivers/of/Makefile b/drivers/of/Makefile
index e0360a44306e..c65364f32935 100644
--- a/drivers/of/Makefile
+++ b/drivers/of/Makefile
@@ -12,6 +12,7 @@ obj-$(CONFIG_OF_RESERVED_MEM) += of_reserved_mem.o
obj-$(CONFIG_OF_RESOLVE) += resolver.o
obj-$(CONFIG_OF_OVERLAY) += overlay.o
obj-$(CONFIG_OF_NUMA) += of_numa.o
+obj-$(CONFIG_OF_EMPTY_ROOT) += of_empty_root.o

ifdef CONFIG_KEXEC_FILE
ifdef CONFIG_OF_FLATTREE
diff --git a/drivers/of/of_empty_root.c b/drivers/of/of_empty_root.c
new file mode 100644
index 000000000000..5c429c7a27bd
--- /dev/null
+++ b/drivers/of/of_empty_root.c
@@ -0,0 +1,51 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2022 Xilinx, Inc.
+ */
+
+#include <linux/of.h>
+#include <linux/slab.h>
+
+#include "of_private.h"
+
+static int __init of_root_init(void)
+{
+ struct property *prop = NULL;
+ struct device_node *node;
+ __be32 *val = NULL;
+
+ if (of_root)
+ return 0;
+
+ pr_info("Create empty OF root node\n");
+ node = kzalloc(sizeof(*node), GFP_KERNEL);
+ if (!node)
+ return -ENOMEM;
+ of_node_init(node);
+ node->full_name = "/";
+
+ prop = kcalloc(2, sizeof(*prop), GFP_KERNEL);
+ if (!prop)
+ return -ENOMEM;
+
+ val = kzalloc(sizeof(*val), GFP_KERNEL);
+ if (!val)
+ return -ENOMEM;
+ *val = cpu_to_be32(sizeof(void *) / sizeof(u32));
+
+ prop->name = "#address-cells";
+ prop->value = val;
+ prop->length = sizeof(u32);
+ of_add_property(node, prop);
+ prop++;
+ prop->name = "#size-cells";
+ prop->value = val;
+ prop->length = sizeof(u32);
+ of_add_property(node, prop);
+ of_root = node;
+ for_each_of_allnodes(node)
+ __of_attach_node_sysfs(node);
+
+ return 0;
+}
+pure_initcall(of_root_init);
--
2.27.0

2022-02-02 00:05:48

by Lizhi Hou

[permalink] [raw]
Subject: Re: [PATCH V1 Create empty OF root 0/1] XRT Alveo driver infrastructure overview

Hi Rob,


We are still waiting for your feedback and guidance on this. Could you
take a look?


Thanks,

Lizhi

On 1/25/22 9:48 PM, Lizhi Hou wrote:
> Hello,
>
> Xilinx Alveo PCIe accelerator cards use flattened device tree to describe
> HW subsystems or endpoints. Each device tree node represents a hardware
> endpoint and each endpoint is an hardware unit which requires a driver.
> The product detail:
> https://www.xilinx.com/products/boards-and-kits/alveo.html
>
> The feedback from the previous patches was to create a base tree if there
> is not one and apply the unflattened device nodes by existing Linux
> platform device and OF infrastructure. Please refer to previous discussion
> with device tree and fpga maintainers.
> https://lore.kernel.org/lkml/CAL_JsqJfyRymB=VxLuQqLpep+Q1Eie48dobv9sC5OizDz0d2DQ@mail.gmail.com/
> https://lore.kernel.org/lkml/[email protected]/
>
> This patch adds OF_EMPTY_ROOT config. When it is selected and there is not
> a device tree, create an empty device tree root node.
>
> Lizhi Hou (1):
> of: create empty of root
>
> drivers/of/Kconfig | 3 +++
> drivers/of/Makefile | 1 +
> drivers/of/of_empty_root.c | 51 ++++++++++++++++++++++++++++++++++++++
> 3 files changed, 55 insertions(+)
> create mode 100644 drivers/of/of_empty_root.c
>

2022-02-09 07:15:38

by Sonal Santan

[permalink] [raw]
Subject: RE: [PATCH V1 Create empty OF root 0/1] XRT Alveo driver infrastructure overview

Hi all,

Gentle ping. Are we okay with this series?

Will appreciate feedback as our next set of patches for Alveo is based on this feature.

Thanks,
-Sonal

> -----Original Message-----
> From: Lizhi Hou <[email protected]>
> Sent: Monday, January 31, 2022 4:50 PM
> To: Lizhi Hou <[email protected]>; [email protected];
> [email protected]
> Cc: [email protected]; [email protected]; Max Zhen
> <[email protected]>; Sonal Santan <[email protected]>; Yu Liu
> <[email protected]>; Michal Simek <[email protected]>; Stefano Stabellini
> <[email protected]>; [email protected]; [email protected];
> [email protected]
> Subject: Re: [PATCH V1 Create empty OF root 0/1] XRT Alveo driver
> infrastructure overview
>
> Hi Rob,
>
>
> We are still waiting for your feedback and guidance on this. Could you take a
> look?
>
>
> Thanks,
>
> Lizhi
>
> On 1/25/22 9:48 PM, Lizhi Hou wrote:
> > Hello,
> >
> > Xilinx Alveo PCIe accelerator cards use flattened device tree to describe
> > HW subsystems or endpoints. Each device tree node represents a hardware
> > endpoint and each endpoint is an hardware unit which requires a driver.
> > The product detail:
> > https://www.xilinx.com/products/boards-and-kits/alveo.html
> >
> > The feedback from the previous patches was to create a base tree if there
> > is not one and apply the unflattened device nodes by existing Linux
> > platform device and OF infrastructure. Please refer to previous discussion
> > with device tree and fpga maintainers.
> >
> https://lore.kernel.org/lkml/CAL_JsqJfyRymB=VxLuQqLpep+Q1Eie48dobv9sC5Oi
> [email protected]/
> > https://lore.kernel.org/lkml/20220105225013.1567871-1-
> [email protected]/
> >
> > This patch adds OF_EMPTY_ROOT config. When it is selected and there is not
> > a device tree, create an empty device tree root node.
> >
> > Lizhi Hou (1):
> > of: create empty of root
> >
> > drivers/of/Kconfig | 3 +++
> > drivers/of/Makefile | 1 +
> > drivers/of/of_empty_root.c | 51
> ++++++++++++++++++++++++++++++++++++++
> > 3 files changed, 55 insertions(+)
> > create mode 100644 drivers/of/of_empty_root.c
> >

2022-02-11 20:51:33

by Xu Yilun

[permalink] [raw]
Subject: Re: [PATCH V1 Create empty OF root 1/1] of: create empty of root

On Tue, Jan 25, 2022 at 09:48:07PM -0800, Lizhi Hou wrote:
> Add OF_EMPTY_ROOT config. When it is selected and there is not a device
> tree, create an empty device tree root node.

Maybe add some description about why a empty device tree root node is
needed. Note that the Patch #0 will not be present in the repo when the
series will be merged, so add your description here please.

>
> Signed-off-by: Sonal Santan <[email protected]>
> Signed-off-by: Max Zhen <[email protected]>
> Signed-off-by: Lizhi Hou <[email protected]>
> ---
> drivers/of/Kconfig | 3 +++
> drivers/of/Makefile | 1 +
> drivers/of/of_empty_root.c | 51 ++++++++++++++++++++++++++++++++++++++
> 3 files changed, 55 insertions(+)
> create mode 100644 drivers/of/of_empty_root.c
>
> diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig
> index 80b5fd44ab1c..42afb126f91a 100644
> --- a/drivers/of/Kconfig
> +++ b/drivers/of/Kconfig
> @@ -94,4 +94,7 @@ config OF_DMA_DEFAULT_COHERENT
> # arches should select this if DMA is coherent by default for OF devices
> bool
>
> +config OF_EMPTY_ROOT
> + bool

Also some descriptions for better understanding?

Thanks,
Yilun

> +
> endif # OF
> diff --git a/drivers/of/Makefile b/drivers/of/Makefile
> index e0360a44306e..c65364f32935 100644
> --- a/drivers/of/Makefile
> +++ b/drivers/of/Makefile
> @@ -12,6 +12,7 @@ obj-$(CONFIG_OF_RESERVED_MEM) += of_reserved_mem.o
> obj-$(CONFIG_OF_RESOLVE) += resolver.o
> obj-$(CONFIG_OF_OVERLAY) += overlay.o
> obj-$(CONFIG_OF_NUMA) += of_numa.o
> +obj-$(CONFIG_OF_EMPTY_ROOT) += of_empty_root.o
>
> ifdef CONFIG_KEXEC_FILE
> ifdef CONFIG_OF_FLATTREE
> diff --git a/drivers/of/of_empty_root.c b/drivers/of/of_empty_root.c
> new file mode 100644
> index 000000000000..5c429c7a27bd
> --- /dev/null
> +++ b/drivers/of/of_empty_root.c
> @@ -0,0 +1,51 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (C) 2022 Xilinx, Inc.
> + */
> +
> +#include <linux/of.h>
> +#include <linux/slab.h>
> +
> +#include "of_private.h"
> +
> +static int __init of_root_init(void)
> +{
> + struct property *prop = NULL;
> + struct device_node *node;
> + __be32 *val = NULL;
> +
> + if (of_root)
> + return 0;
> +
> + pr_info("Create empty OF root node\n");
> + node = kzalloc(sizeof(*node), GFP_KERNEL);
> + if (!node)
> + return -ENOMEM;
> + of_node_init(node);
> + node->full_name = "/";
> +
> + prop = kcalloc(2, sizeof(*prop), GFP_KERNEL);
> + if (!prop)
> + return -ENOMEM;
> +
> + val = kzalloc(sizeof(*val), GFP_KERNEL);
> + if (!val)
> + return -ENOMEM;
> + *val = cpu_to_be32(sizeof(void *) / sizeof(u32));
> +
> + prop->name = "#address-cells";
> + prop->value = val;
> + prop->length = sizeof(u32);
> + of_add_property(node, prop);
> + prop++;
> + prop->name = "#size-cells";
> + prop->value = val;
> + prop->length = sizeof(u32);
> + of_add_property(node, prop);
> + of_root = node;
> + for_each_of_allnodes(node)
> + __of_attach_node_sysfs(node);
> +
> + return 0;
> +}
> +pure_initcall(of_root_init);
> --
> 2.27.0

2022-02-14 18:52:13

by Lizhi Hou

[permalink] [raw]
Subject: Re: [PATCH V1 Create empty OF root 1/1] of: create empty of root

Hi Yilun,

Thanks a lot for your feedback. I will revise the comments and send
another patch.

In the meanwhile, based on our previous discussion,

https://lore.kernel.org/lkml/20220111070000.GC979169@yilunxu-OptiPlex-7050/

I will propose another patch to add an of_pci interface which can be
called by pci driver probe routine to create device node for it.


Thanks,

Lizhi

On 2/11/22 7:38 AM, Xu Yilun wrote:
> On Tue, Jan 25, 2022 at 09:48:07PM -0800, Lizhi Hou wrote:
>> Add OF_EMPTY_ROOT config. When it is selected and there is not a device
>> tree, create an empty device tree root node.
> Maybe add some description about why a empty device tree root node is
> needed. Note that the Patch #0 will not be present in the repo when the
> series will be merged, so add your description here please.
>
>> Signed-off-by: Sonal Santan <[email protected]>
>> Signed-off-by: Max Zhen <[email protected]>
>> Signed-off-by: Lizhi Hou <[email protected]>
>> ---
>> drivers/of/Kconfig | 3 +++
>> drivers/of/Makefile | 1 +
>> drivers/of/of_empty_root.c | 51 ++++++++++++++++++++++++++++++++++++++
>> 3 files changed, 55 insertions(+)
>> create mode 100644 drivers/of/of_empty_root.c
>>
>> diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig
>> index 80b5fd44ab1c..42afb126f91a 100644
>> --- a/drivers/of/Kconfig
>> +++ b/drivers/of/Kconfig
>> @@ -94,4 +94,7 @@ config OF_DMA_DEFAULT_COHERENT
>> # arches should select this if DMA is coherent by default for OF devices
>> bool
>>
>> +config OF_EMPTY_ROOT
>> + bool
> Also some descriptions for better understanding?
>
> Thanks,
> Yilun
>
>> +
>> endif # OF
>> diff --git a/drivers/of/Makefile b/drivers/of/Makefile
>> index e0360a44306e..c65364f32935 100644
>> --- a/drivers/of/Makefile
>> +++ b/drivers/of/Makefile
>> @@ -12,6 +12,7 @@ obj-$(CONFIG_OF_RESERVED_MEM) += of_reserved_mem.o
>> obj-$(CONFIG_OF_RESOLVE) += resolver.o
>> obj-$(CONFIG_OF_OVERLAY) += overlay.o
>> obj-$(CONFIG_OF_NUMA) += of_numa.o
>> +obj-$(CONFIG_OF_EMPTY_ROOT) += of_empty_root.o
>>
>> ifdef CONFIG_KEXEC_FILE
>> ifdef CONFIG_OF_FLATTREE
>> diff --git a/drivers/of/of_empty_root.c b/drivers/of/of_empty_root.c
>> new file mode 100644
>> index 000000000000..5c429c7a27bd
>> --- /dev/null
>> +++ b/drivers/of/of_empty_root.c
>> @@ -0,0 +1,51 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +/*
>> + * Copyright (C) 2022 Xilinx, Inc.
>> + */
>> +
>> +#include <linux/of.h>
>> +#include <linux/slab.h>
>> +
>> +#include "of_private.h"
>> +
>> +static int __init of_root_init(void)
>> +{
>> + struct property *prop = NULL;
>> + struct device_node *node;
>> + __be32 *val = NULL;
>> +
>> + if (of_root)
>> + return 0;
>> +
>> + pr_info("Create empty OF root node\n");
>> + node = kzalloc(sizeof(*node), GFP_KERNEL);
>> + if (!node)
>> + return -ENOMEM;
>> + of_node_init(node);
>> + node->full_name = "/";
>> +
>> + prop = kcalloc(2, sizeof(*prop), GFP_KERNEL);
>> + if (!prop)
>> + return -ENOMEM;
>> +
>> + val = kzalloc(sizeof(*val), GFP_KERNEL);
>> + if (!val)
>> + return -ENOMEM;
>> + *val = cpu_to_be32(sizeof(void *) / sizeof(u32));
>> +
>> + prop->name = "#address-cells";
>> + prop->value = val;
>> + prop->length = sizeof(u32);
>> + of_add_property(node, prop);
>> + prop++;
>> + prop->name = "#size-cells";
>> + prop->value = val;
>> + prop->length = sizeof(u32);
>> + of_add_property(node, prop);
>> + of_root = node;
>> + for_each_of_allnodes(node)
>> + __of_attach_node_sysfs(node);
>> +
>> + return 0;
>> +}
>> +pure_initcall(of_root_init);
>> --
>> 2.27.0
>