Skip to contentSkip to conversation

dm: device: Do not probe parents which are probed already

RFC PATCH New Michal Simek 2 participants 5 messages Jan 18, 2019 – Feb 5, 2019

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 dm: device: Do not probe parents which are probed already

From the first look there is no reason to probe parent nodes if they are active already.

---

I have created this just for showing status of parent device. Maybe there is any strong reason to do this but I just wanted to check this because it looks like just wasting of time.

Just revert this condition when you want to see outputs. if (dev->parent && !(dev->parent->flags & DM_FLAG_ACTIVATED)) {

Without this line

99 amba @ 7df04d20
100 amba @ 7df04d20
99 * root_driver @ 7df04960, seq 0, (req -1) 100 * root_driver @ 7df04960, seq 0, (req -1) 99 * root_driver @ 7df04960, seq 0, (req -1) 100 * root_driver @ 7df04960, seq 0, (req -1) 99 * root_driver @ 7df04960, seq 0, (req -1) 100 * root_driver @ 7df04960, seq 0, (req -1) 99 * root_driver @ 7df04960, seq 0, (req -1) 100 * root_driver @ 7df04960, seq 0, (req -1) 99 * root_driver @ 7df04960, seq 0, (req -1) 100 * root_driver @ 7df04960, seq 0, (req -1) 99 * root_driver @ 7df04960, seq 0, (req -1) 100 * root_driver @ 7df04960, seq 0, (req -1) 99 * root_driver @ 7df04960, seq 0, (req -1) 100 * root_driver @ 7df04960, seq 0, (req -1)
MMC: 99 * amba @ 7df04d20, seq 0, (req -1)
100 * amba @ 7df04d20, seq 0, (req -1)

ZynqMP> i2c dev 0
Setting bus to 0
99 * amba @ 7df04d20, seq 0, (req -1)
100 * amba @ 7df04d20, seq 0, (req -1)

with this line added

99 amba @ 7df04d20
100 amba @ 7df04d20
99 * root_driver @ 7df04960, seq 0, (req -1)
99 * root_driver @ 7df04960, seq 0, (req -1)
99 * root_driver @ 7df04960, seq 0, (req -1)
99 * root_driver @ 7df04960, seq 0, (req -1)
99 * root_driver @ 7df04960, seq 0, (req -1)
99 * root_driver @ 7df04960, seq 0, (req -1)
99 * root_driver @ 7df04960, seq 0, (req -1)
MMC: 99 * amba @ 7df04d20, seq 0, (req -1)

ZynqMP> i2c dev 0
Setting bus to 0
99 * amba @ 7df04d20, seq 0, (req -1)

---
 drivers/core/device.c | 7 ++++++-
 drivers/core/dump.c   | 2 +-
 2 files changed, 7 insertions(+), 2 deletions(-)
drivers/core/device.c +6 -1
index 0d15e5062b66..114888a8f7cf 100644
@@ -341,8 +341,13 @@ int device_probe(struct udevice *dev)
 		}
 	}
 
+	if (dev->parent)
+		dm_display_line(dev->parent, 99);
+
 	/* Ensure all parents are probed */
-	if (dev->parent) {
+	if (dev->parent && !(dev->parent->flags & DM_FLAG_ACTIVATED)) {
+		dm_display_line(dev->parent, 100);
+
 		size = dev->parent->driver->per_child_auto_alloc_size;
 		if (!size) {
 			size = dev->parent->uclass->uc_drv->
drivers/core/dump.c +1 -1
index 8fbfd93fb5e4..95ba7dcb9193 100644
@@ -62,7 +62,7 @@ void dm_dump_all(void)
  *
  * @dev:	Device to display
  */
-static void dm_display_line(struct udevice *dev, int index)
+void dm_display_line(struct udevice *dev, int index)
 {
 	printf("%i %c %s @ %08lx", index,
 	       dev->flags & DM_FLAG_ACTIVATED ? '*' : ' ',
Signature · 1 line
1.9.1
#1 lore raw

RFC PATCH 1/1 dm: device: Do not probe parents which are probed already

Hi Michal,

Quoted 68 lines · Michal Simek

From the first look there is no reason to probe parent nodes if they are active already.

---

I have created this just for showing status of parent device. Maybe there is any strong reason to do this but I just wanted to check this because it looks like just wasting of time.

Just revert this condition when you want to see outputs. if (dev->parent && !(dev->parent->flags & DM_FLAG_ACTIVATED)) {

Without this line

99 amba @ 7df04d20
100 amba @ 7df04d20
99 * root_driver @ 7df04960, seq 0, (req -1) 100 * root_driver @ 7df04960, seq 0, (req -1) 99 * root_driver @ 7df04960, seq 0, (req -1) 100 * root_driver @ 7df04960, seq 0, (req -1) 99 * root_driver @ 7df04960, seq 0, (req -1) 100 * root_driver @ 7df04960, seq 0, (req -1) 99 * root_driver @ 7df04960, seq 0, (req -1) 100 * root_driver @ 7df04960, seq 0, (req -1) 99 * root_driver @ 7df04960, seq 0, (req -1) 100 * root_driver @ 7df04960, seq 0, (req -1) 99 * root_driver @ 7df04960, seq 0, (req -1) 100 * root_driver @ 7df04960, seq 0, (req -1) 99 * root_driver @ 7df04960, seq 0, (req -1) 100 * root_driver @ 7df04960, seq 0, (req -1)
MMC: 99 * amba @ 7df04d20, seq 0, (req -1)
100 * amba @ 7df04d20, seq 0, (req -1)

ZynqMP> i2c dev 0
Setting bus to 0
99 * amba @ 7df04d20, seq 0, (req -1)
100 * amba @ 7df04d20, seq 0, (req -1)

with this line added

99 amba @ 7df04d20
100 amba @ 7df04d20
99 * root_driver @ 7df04960, seq 0, (req -1)
99 * root_driver @ 7df04960, seq 0, (req -1)
99 * root_driver @ 7df04960, seq 0, (req -1)
99 * root_driver @ 7df04960, seq 0, (req -1)
99 * root_driver @ 7df04960, seq 0, (req -1)
99 * root_driver @ 7df04960, seq 0, (req -1)
99 * root_driver @ 7df04960, seq 0, (req -1)
MMC: 99 * amba @ 7df04d20, seq 0, (req -1)

ZynqMP> i2c dev 0
Setting bus to 0
99 * amba @ 7df04d20, seq 0, (req -1)

---
 drivers/core/device.c | 7 ++++++-
 drivers/core/dump.c   | 2 +-
 2 files changed, 7 insertions(+), 2 deletions(-)
drivers/core/device.c +0 -0
index 0d15e5062b66..114888a8f7cf 100644
@@ -341,8 +341,13 @@ int device_probe(struct udevice *dev)
                }

drivers/core/device.c int device_probe(struct udevice *dev) · line 350

Quoted 10 lines
drivers/core/device.c +6 -1
        }
 
+       if (dev->parent)
+               dm_display_line(dev->parent, 99);
+
        /* Ensure all parents are probed */
-       if (dev->parent) {
+       if (dev->parent && !(dev->parent->flags & DM_FLAG_ACTIVATED)) {
+               dm_display_line(dev->parent, 100);
+

Yes this looks like a good change in principle.

But we still need to execute the code below even if the parent is probed, so that we allocate the child's parent data:

drivers/core/device.c int device_probe(struct udevice *dev) · line 353

Quoted 3 lines
drivers/core/device.c +0 -0
                size = dev->parent->driver->per_child_auto_alloc_size;
                if (!size) {
                        size = dev->parent->uclass->uc_drv->

...

So can you please rework this to allow for that?

Overall I think your change saves a function call. As you can see the flag is checked right at the top of device_probe().

Quoted 14 lines
drivers/core/dump.c +1 -2
index 8fbfd93fb5e4..95ba7dcb9193 100644
@@ -62,7 +62,7 @@ void dm_dump_all(void)
  *
  * @dev:       Device to display
  */
-static void dm_display_line(struct udevice *dev, int index)
+void dm_display_line(struct udevice *dev, int index)
 {
        printf("%i %c %s @ %08lx", index,
               dev->flags & DM_FLAG_ACTIVATED ? '*' : ' ',
--
Quoted 2 lines

1.9.1

Regards,
Simon

#2 lore raw

RFC PATCH 1/1 dm: device: Do not probe parents which are probed already

Quoted 84 lines · Simon Glass

Hi Michal,

Quoted 68 lines · Michal Simek

From the first look there is no reason to probe parent nodes if they are active already.

---

I have created this just for showing status of parent device. Maybe there is any strong reason to do this but I just wanted to check this because it looks like just wasting of time.

Just revert this condition when you want to see outputs. if (dev->parent && !(dev->parent->flags & DM_FLAG_ACTIVATED)) {

Without this line

99 amba @ 7df04d20
100 amba @ 7df04d20
99 * root_driver @ 7df04960, seq 0, (req -1) 100 * root_driver @ 7df04960, seq 0, (req -1) 99 * root_driver @ 7df04960, seq 0, (req -1) 100 * root_driver @ 7df04960, seq 0, (req -1) 99 * root_driver @ 7df04960, seq 0, (req -1) 100 * root_driver @ 7df04960, seq 0, (req -1) 99 * root_driver @ 7df04960, seq 0, (req -1) 100 * root_driver @ 7df04960, seq 0, (req -1) 99 * root_driver @ 7df04960, seq 0, (req -1) 100 * root_driver @ 7df04960, seq 0, (req -1) 99 * root_driver @ 7df04960, seq 0, (req -1) 100 * root_driver @ 7df04960, seq 0, (req -1) 99 * root_driver @ 7df04960, seq 0, (req -1) 100 * root_driver @ 7df04960, seq 0, (req -1)
MMC: 99 * amba @ 7df04d20, seq 0, (req -1)
100 * amba @ 7df04d20, seq 0, (req -1)

ZynqMP> i2c dev 0
Setting bus to 0
99 * amba @ 7df04d20, seq 0, (req -1)
100 * amba @ 7df04d20, seq 0, (req -1)

with this line added

99 amba @ 7df04d20
100 amba @ 7df04d20
99 * root_driver @ 7df04960, seq 0, (req -1)
99 * root_driver @ 7df04960, seq 0, (req -1)
99 * root_driver @ 7df04960, seq 0, (req -1)
99 * root_driver @ 7df04960, seq 0, (req -1)
99 * root_driver @ 7df04960, seq 0, (req -1)
99 * root_driver @ 7df04960, seq 0, (req -1)
99 * root_driver @ 7df04960, seq 0, (req -1)
MMC: 99 * amba @ 7df04d20, seq 0, (req -1)

ZynqMP> i2c dev 0
Setting bus to 0
99 * amba @ 7df04d20, seq 0, (req -1)

---
 drivers/core/device.c | 7 ++++++-
 drivers/core/dump.c   | 2 +-
 2 files changed, 7 insertions(+), 2 deletions(-)
drivers/core/device.c +0 -0
index 0d15e5062b66..114888a8f7cf 100644
@@ -341,8 +341,13 @@ int device_probe(struct udevice *dev)
                }

drivers/core/device.c int device_probe(struct udevice *dev) · line 350

Quoted 10 lines
drivers/core/device.c +6 -1
        }
 
+       if (dev->parent)
+               dm_display_line(dev->parent, 99);
+
        /* Ensure all parents are probed */
-       if (dev->parent) {
+       if (dev->parent && !(dev->parent->flags & DM_FLAG_ACTIVATED)) {
+               dm_display_line(dev->parent, 100);
+

Yes this looks like a good change in principle.

Quoted 2 lines

But we still need to execute the code below even if the parent is probed, so that we allocate the child's parent data:

ok.

Quoted 10 lines

drivers/core/device.c int device_probe(struct udevice *dev) · line 353

Quoted 3 lines
drivers/core/device.c +0 -0
                size = dev->parent->driver->per_child_auto_alloc_size;
                if (!size) {
                        size = dev->parent->uclass->uc_drv->

...

So can you please rework this to allow for that?

Overall I think your change saves a function call. As you can see the flag is checked right at the top of device_probe().

I am not quite sure how that rework should look like.

If just this.
if (!(dev->parent->flags & DM_FLAG_ACTIVATED))

	ret = device_probe(dev->parent);
	if (ret)
		goto fail;

Then improvement will be very minimal.

Thanks,
Michal

#3 lore raw

RFC PATCH 1/1 dm: device: Do not probe parents which are probed already

Hi Michal,

Quoted 5 lines · Michal Simek
Quoted 3 lines · Simon Glass

Hi Michal,

On Fri, 18 Jan 2019 at 02:41, Michal Simek <[email protected]>

Quoted 2 lines · wrote:
Quoted 2 lines
Quoted 2 lines

From the first look there is no reason to probe parent nodes if they

are

Quoted 98 lines
Quoted 79 lines
Quoted 66 lines

active already.

---

I have created this just for showing status of parent device. Maybe there is any strong reason to do this but I just wanted to check this because it looks like just wasting of time.

Just revert this condition when you want to see outputs. if (dev->parent && !(dev->parent->flags & DM_FLAG_ACTIVATED)) {

Without this line

99 amba @ 7df04d20
100 amba @ 7df04d20
99 * root_driver @ 7df04960, seq 0, (req -1) 100 * root_driver @ 7df04960, seq 0, (req -1) 99 * root_driver @ 7df04960, seq 0, (req -1) 100 * root_driver @ 7df04960, seq 0, (req -1) 99 * root_driver @ 7df04960, seq 0, (req -1) 100 * root_driver @ 7df04960, seq 0, (req -1) 99 * root_driver @ 7df04960, seq 0, (req -1) 100 * root_driver @ 7df04960, seq 0, (req -1) 99 * root_driver @ 7df04960, seq 0, (req -1) 100 * root_driver @ 7df04960, seq 0, (req -1) 99 * root_driver @ 7df04960, seq 0, (req -1) 100 * root_driver @ 7df04960, seq 0, (req -1) 99 * root_driver @ 7df04960, seq 0, (req -1) 100 * root_driver @ 7df04960, seq 0, (req -1)
MMC: 99 * amba @ 7df04d20, seq 0, (req -1)
100 * amba @ 7df04d20, seq 0, (req -1)

ZynqMP> i2c dev 0
Setting bus to 0
99 * amba @ 7df04d20, seq 0, (req -1)
100 * amba @ 7df04d20, seq 0, (req -1)

with this line added

99 amba @ 7df04d20
100 amba @ 7df04d20
99 * root_driver @ 7df04960, seq 0, (req -1)
99 * root_driver @ 7df04960, seq 0, (req -1)
99 * root_driver @ 7df04960, seq 0, (req -1)
99 * root_driver @ 7df04960, seq 0, (req -1)
99 * root_driver @ 7df04960, seq 0, (req -1)
99 * root_driver @ 7df04960, seq 0, (req -1)
99 * root_driver @ 7df04960, seq 0, (req -1)
MMC: 99 * amba @ 7df04d20, seq 0, (req -1)

ZynqMP> i2c dev 0
Setting bus to 0
99 * amba @ 7df04d20, seq 0, (req -1)

---
 drivers/core/device.c | 7 ++++++-
 drivers/core/dump.c   | 2 +-
 2 files changed, 7 insertions(+), 2 deletions(-)
drivers/core/device.c +0 -0
index 0d15e5062b66..114888a8f7cf 100644
@@ -341,8 +341,13 @@ int device_probe(struct udevice *dev)
                }

drivers/core/device.c int device_probe(struct udevice *dev) · line 350

Quoted 10 lines
drivers/core/device.c +6 -1
        }
 
+       if (dev->parent)
+               dm_display_line(dev->parent, 99);
+
        /* Ensure all parents are probed */
-       if (dev->parent) {
+       if (dev->parent && !(dev->parent->flags & DM_FLAG_ACTIVATED)) {
+               dm_display_line(dev->parent, 100);
+

Yes this looks like a good change in principle.

Quoted 2 lines

But we still need to execute the code below even if the parent is probed, so that we allocate the child's parent data:

ok.

Quoted 10 lines

drivers/core/device.c int device_probe(struct udevice *dev) · line 353

Quoted 3 lines
drivers/core/device.c +0 -0
                size = dev->parent->driver->per_child_auto_alloc_size;
                if (!size) {
                        size = dev->parent->uclass->uc_drv->

...

So can you please rework this to allow for that?

Overall I think your change saves a function call. As you can see the flag is checked right at the top of device_probe().

I am not quite sure how that rework should look like.

Quoted 8 lines

If just this.
if (!(dev->parent->flags & DM_FLAG_ACTIVATED))

        ret = device_probe(dev->parent);
        if (ret)
                goto fail;

Then improvement will be very minimal.

Yes indeed, it is just saving a function call.

Regards,
Simon

#4 lore raw

RFC PATCH 1/1 dm: device: Do not probe parents which are probed already

Quoted 117 lines · Simon Glass

Hi Michal,

Quoted 5 lines · Michal Simek
Quoted 3 lines · Simon Glass

Hi Michal,

On Fri, 18 Jan 2019 at 02:41, Michal Simek <[email protected]>

Quoted 2 lines · wrote:
Quoted 2 lines
Quoted 2 lines

From the first look there is no reason to probe parent nodes if they

are

Quoted 105 lines
Quoted 79 lines
Quoted 66 lines

active already.

---

I have created this just for showing status of parent device. Maybe there is any strong reason to do this but I just wanted to check this because it looks like just wasting of time.

Just revert this condition when you want to see outputs. if (dev->parent && !(dev->parent->flags & DM_FLAG_ACTIVATED)) {

Without this line

99 amba @ 7df04d20
100 amba @ 7df04d20
99 * root_driver @ 7df04960, seq 0, (req -1) 100 * root_driver @ 7df04960, seq 0, (req -1) 99 * root_driver @ 7df04960, seq 0, (req -1) 100 * root_driver @ 7df04960, seq 0, (req -1) 99 * root_driver @ 7df04960, seq 0, (req -1) 100 * root_driver @ 7df04960, seq 0, (req -1) 99 * root_driver @ 7df04960, seq 0, (req -1) 100 * root_driver @ 7df04960, seq 0, (req -1) 99 * root_driver @ 7df04960, seq 0, (req -1) 100 * root_driver @ 7df04960, seq 0, (req -1) 99 * root_driver @ 7df04960, seq 0, (req -1) 100 * root_driver @ 7df04960, seq 0, (req -1) 99 * root_driver @ 7df04960, seq 0, (req -1) 100 * root_driver @ 7df04960, seq 0, (req -1)
MMC: 99 * amba @ 7df04d20, seq 0, (req -1)
100 * amba @ 7df04d20, seq 0, (req -1)

ZynqMP> i2c dev 0
Setting bus to 0
99 * amba @ 7df04d20, seq 0, (req -1)
100 * amba @ 7df04d20, seq 0, (req -1)

with this line added

99 amba @ 7df04d20
100 amba @ 7df04d20
99 * root_driver @ 7df04960, seq 0, (req -1)
99 * root_driver @ 7df04960, seq 0, (req -1)
99 * root_driver @ 7df04960, seq 0, (req -1)
99 * root_driver @ 7df04960, seq 0, (req -1)
99 * root_driver @ 7df04960, seq 0, (req -1)
99 * root_driver @ 7df04960, seq 0, (req -1)
99 * root_driver @ 7df04960, seq 0, (req -1)
MMC: 99 * amba @ 7df04d20, seq 0, (req -1)

ZynqMP> i2c dev 0
Setting bus to 0
99 * amba @ 7df04d20, seq 0, (req -1)

---
 drivers/core/device.c | 7 ++++++-
 drivers/core/dump.c   | 2 +-
 2 files changed, 7 insertions(+), 2 deletions(-)
drivers/core/device.c +0 -0
index 0d15e5062b66..114888a8f7cf 100644
@@ -341,8 +341,13 @@ int device_probe(struct udevice *dev)
                }

drivers/core/device.c int device_probe(struct udevice *dev) · line 350

Quoted 10 lines
drivers/core/device.c +6 -1
        }
 
+       if (dev->parent)
+               dm_display_line(dev->parent, 99);
+
        /* Ensure all parents are probed */
-       if (dev->parent) {
+       if (dev->parent && !(dev->parent->flags & DM_FLAG_ACTIVATED)) {
+               dm_display_line(dev->parent, 100);
+

Yes this looks like a good change in principle.

Quoted 2 lines

But we still need to execute the code below even if the parent is probed, so that we allocate the child's parent data:

ok.

Quoted 10 lines

drivers/core/device.c int device_probe(struct udevice *dev) · line 353

Quoted 3 lines
drivers/core/device.c +0 -0
                size = dev->parent->driver->per_child_auto_alloc_size;
                if (!size) {
                        size = dev->parent->uclass->uc_drv->

...

So can you please rework this to allow for that?

Overall I think your change saves a function call. As you can see the flag is checked right at the top of device_probe().

I am not quite sure how that rework should look like.

If just this.
if (!(dev->parent->flags & DM_FLAG_ACTIVATED))

        ret = device_probe(dev->parent);
        if (ret)
                goto fail;
Quoted 3 lines
Quoted 1 line

Then improvement will be very minimal.

Yes indeed, it is just saving a function call.

thanks for confirmation. It means let's close this RFC that this is no needed and it is an issue.

Thanks,
Michal