clk: Dont return error when assigned-clocks is empty or missing
PATCH 1/1 clk: Dont return error when assigned-clocks is empty or missing
There is a chance that assigned-clock-rates is given and assigned-clocks could be empty. Dont return error in that case, because the probe of the corresponding driver will not be called at all if this fails. Better to continue to look for it and return 0.
---
drivers/clk/clk-uclass.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/clk/clk-uclass.c +7 -1
@@ -329,7 +329,13 @@ static int clk_set_default_rates(struct udevice *dev,dev_dbg (dev,"could not get assigned clock %d (err = %d)\n" , index, ret); -continue ; +/* Skip if it is empty */ +if (ret == -ENOENT ) { + ret =0 ; +continue ; + } + +return ret; }/* This is clk provider device trying to program itself
Signature · 1 line
2.17.1
Quoted 4 lines · Ashok Reddy Soma
There is a chance that assigned-clock-rates is given and assigned-clocks could be empty. Dont return error in that case, because the probe of the corresponding driver will not be called at all if this fails. Better to continue to look for it and return 0.
No, this is an error in the device tree. assigned-clock-rates depends on assigned-clocks, so you must provide the latter if the former is present.
--Sean
Quoted 25 lines
Signed-off-by Ashok Reddy Soma <[email protected]>---
drivers/clk/clk-uclass.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)drivers/clk/clk-uclass.c +7
-1@@ -329,7 +329,13 @@ static int clk_set_default_rates(struct udevice *dev,dev_dbg (dev,"could not get assigned clock %d (err = %d)\n" , index, ret); -continue ; +/* Skip if it is empty */ +if (ret == -ENOENT ) { + ret =0 ; +continue ; + } + +return ret; }/* This is clk provider device trying to program itself
Hi Sean,
Quoted 8 lines · Sean Anderson
Quoted 4 lines · Ashok Reddy Soma
There is a chance that assigned-clock-rates is given and assigned-clocks could be empty. Dont return error in that case, because the probe of the corresponding driver will not be called at all if this fails. Better to continue to look for it and return 0.
No, this is an error in the device tree. assigned-clock-rates depends on assigned-clocks, so you must provide the latter if the former is present.
We were also checking it and in the Linux kernel it is handle like this.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/clk/clk-conf.c#n95
It means you can have rate assigned but not assigned-clocks property.
And yes in working case both should be present to work properly.
Thanks,
Michal
Quoted 12 lines · Michal Simek
Hi Sean,
Quoted 8 lines · Sean Anderson
Quoted 4 lines · Ashok Reddy Soma
There is a chance that assigned-clock-rates is given and assigned-clocks could be empty. Dont return error in that case, because the probe of the corresponding driver will not be called at all if this fails. Better to continue to look for it and return 0.
No, this is an error in the device tree. assigned-clock-rates depends on assigned-clocks, so you must provide the latter if the former is present.
Quoted 6 lines
We were also checking it and in the Linux kernel it is handle like this.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/clk/clk-conf.c#n95It means you can have rate assigned but not assigned-clocks property.
And yes in working case both should be present to work properly.
What is the use-case for this? It will not pass schema checking [1] anyway.
--Sean
[1] https://github.com/devicetree-org/dt-schema/blob/main/dtschema/schemas/clock/clock.yaml
Quoted 18 lines · Sean Anderson
Quoted 17 lines · Michal Simek
Hi Sean,
Quoted 8 lines · Sean Anderson
Quoted 4 lines · Ashok Reddy Soma
There is a chance that assigned-clock-rates is given and assigned-clocks could be empty. Dont return error in that case, because the probe of the corresponding driver will not be called at all if this fails. Better to continue to look for it and return 0.
No, this is an error in the device tree. assigned-clock-rates depends on assigned-clocks, so you must provide the latter if the former is present.
We were also checking it and in the Linux kernel it is handle like this.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/clk/clk-conf.c#n95It means you can have rate assigned but not assigned-clocks property.
Quoted 7 lines
Quoted 1 line
And yes in working case both should be present to work properly.
What is the use-case for this? It will not pass schema checking [1] anyway.
--Sean
[1] https://github.com/devicetree-org/dt-schema/blob/main/dtschema/schemas/clock/clock.yaml
If you check your DT against schema. No doubt how correct behavior should be.
It is just aligning behavior with Linux kernel if user messes up DT.
Thanks,
Michal
Hi Sean,
Quoted 25 lines · Michal Simek
Quoted 22 lines · Sean Anderson
Quoted 12 lines · Michal Simek
Hi Sean,
Quoted 8 lines · Sean Anderson
Quoted 4 lines · Ashok Reddy Soma
There is a chance that assigned-clock-rates is given and assigned-clocks could be empty. Dont return error in that case, because the probe of the corresponding driver will not be called at all if this fails. Better to continue to look for it and return 0.
No, this is an error in the device tree. assigned-clock-rates depends on assigned-clocks, so you must provide the latter if the former is present.
Quoted 6 lines
We were also checking it and in the Linux kernel it is handle like this.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/clk/clk-conf.c#n95It means you can have rate assigned but not assigned-clocks property.
And yes in working case both should be present to work properly.
What is the use-case for this? It will not pass schema checking [1] anyway.
Quoted 7 lines
Quoted 3 lines
--Sean
[1] https://github.com/devicetree-org/dt-schema/blob/main/dtschema/schemas/clock/clock.yaml
If you check your DT against schema. No doubt how correct behavior should be.
It is just aligning behavior with Linux kernel if user messes up DT.
I see that you are listed as clock maintainer. Are you fine with this alignment patch or do you want to change something or reject it?
Thanks,
Michal
Hi Tom,
Quoted 20 lines · Ashok Reddy Soma
There is a chance that assigned-clock-rates is given and assigned-clocks could be empty. Dont return error in that case, because the probe of the corresponding driver will not be called at all if this fails. Better to continue to look for it and return 0.
Signed-off-by Ashok Reddy Soma <[email protected]>---
drivers/clk/clk-uclass.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)drivers/clk/clk-uclass.c +0
-1@@ -329,7 +329,13 @@ static int clk_set_default_rates(struct udevice *dev,dev_dbg (dev,"could not get assigned clock %d (err = %d)\n" , index, ret); -continue ;
drivers/clk/clk-uclass.c static int clk_set_default_rates(struct udevice *dev, · line 341
Quoted 10 lines
drivers/clk/clk-uclass.c +7
-0+/* Skip if it is empty */ +if (ret == -ENOENT ) { + ret =0 ; +continue ; + } + +return ret; }/* This is clk provider device trying to program itself
What's your take on this one? I didn't get reply from Sean.
Thanks,
Michal
Quoted 26 lines · Michal Simek
Hi Tom,
Quoted 23 lines · Ashok Reddy Soma
There is a chance that assigned-clock-rates is given and assigned-clocks could be empty. Dont return error in that case, because the probe of the corresponding driver will not be called at all if this fails. Better to continue to look for it and return 0.
Signed-off-by Ashok Reddy Soma <[email protected]>---
drivers/clk/clk-uclass.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)drivers/clk/clk-uclass.c +3
-1@@ -329,7 +329,13 @@ static int clk_set_default_rates(struct udevice *dev,dev_dbg (dev,"could not get assigned clock %d (err = %d)\n" , index, ret); -continue ; +/* Skip if it is empty */ +if (ret == -ENOENT ) { + ret =0 ;
Quoted 8 lines
drivers/clk/clk-uclass.c static int clk_set_default_rates(struct udevice *dev, · line 341
Quoted 6 lines
drivers/clk/clk-uclass.c +4
-0+continue ; + } + +return ret; }/* This is clk provider device trying to program itself What's your take on this one? I didn't get reply from Sean.
I guess, what's the validated upstream dts where this is the case?
Signature · 1 line
Tom
Quoted 36 lines · Tom Rini
Quoted 26 lines · Michal Simek
Hi Tom,
Quoted 23 lines · Ashok Reddy Soma
There is a chance that assigned-clock-rates is given and assigned-clocks could be empty. Dont return error in that case, because the probe of the corresponding driver will not be called at all if this fails. Better to continue to look for it and return 0.
Signed-off-by Ashok Reddy Soma <[email protected]>---
drivers/clk/clk-uclass.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)drivers/clk/clk-uclass.c +3
-1@@ -329,7 +329,13 @@ static int clk_set_default_rates(struct udevice *dev,dev_dbg (dev,"could not get assigned clock %d (err = %d)\n" , index, ret); -continue ; +/* Skip if it is empty */ +if (ret == -ENOENT ) { + ret =0 ;Quoted 8 lines
drivers/clk/clk-uclass.c static int clk_set_default_rates(struct udevice *dev, · line 340
Quoted 6 lines
drivers/clk/clk-uclass.c +4
-0+continue ; + } + +return ret; }/* This is clk provider device trying to program itself What's your take on this one? I didn't get reply from Sean.
Quoted 2 lines
I guess, what's the validated upstream dts where this is the case?
It was found by incorrect DT. It means I don't think there is any DT which contains this issue. But that being said we can extend current clock tests to cover this case.
Please look below.
Thanks,
Michal
arch/sandbox/dts/test.dts +10 -0
@@ -589,6 +589,16 @@ clock-names = "fixed", "i2c", "spi", "uart2", "uart1"; }; + clk-test2 { + compatible = "sandbox,clk-test"; + assigned-clock-rates = <321>; + }; + + clk-test3 { + compatible = "sandbox,clk-test"; + assigned-clocks = <&clk_sandbox 1>; + }; + ccf: clk-ccf { compatible = "sandbox,clk-ccf"; };
test/dm/clk.c +6 -0
@@ -36,6 +36,12 @@ static int dm_test_clk_base(struct unit_test_state *uts)ut_asserteq (clk_is_match (&clk_method1, &clk_method2), true);ut_asserteq (clk_method1.id, clk_method2.id); +ut_assertok (uclass_get_device_by_name (UCLASS_MISC ,"clk-test2" , &dev)); +ut_assertok (clk_set_defaults (dev,CLK_DEFAULTS_PRE )); + +ut_assertok (uclass_get_device_by_name (UCLASS_MISC ,"clk-test3" , &dev)); +ut_assertok (clk_set_defaults (dev,CLK_DEFAULTS_PRE )); +return 0 ; }
Quoted 39 lines · Michal Simek
Quoted 36 lines · Tom Rini
Quoted 34 lines · Michal Simek
Hi Tom,
Quoted 19 lines · Ashok Reddy Soma
There is a chance that assigned-clock-rates is given and assigned-clocks could be empty. Dont return error in that case, because the probe of the corresponding driver will not be called at all if this fails. Better to continue to look for it and return 0.
Signed-off-by Ashok Reddy Soma <[email protected]>---
drivers/clk/clk-uclass.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)drivers/clk/clk-uclass.c +0
-0@@ -329,7 +329,13 @@ static int clk_set_default_rates(struct udevice *dev,dev_dbg (dev,"could not get assigned clock %d (err = %d)\n" , index, ret);drivers/clk/clk-uclass.c static int clk_set_default_rates(struct udevice *dev, · line 340
Quoted 10 lines
drivers/clk/clk-uclass.c +7
-1-continue ; +/* Skip if it is empty */ +if (ret == -ENOENT ) { + ret =0 ; +continue ; + } + +return ret; }/* This is clk provider device trying to program itself What's your take on this one? I didn't get reply from Sean.
Quoted 7 lines
Quoted 2 lines
I guess, what's the validated upstream dts where this is the case?
It was found by incorrect DT. It means I don't think there is any DT which contains this issue.
But that being said we can extend current clock tests to cover this case. Please look below.
Well, if the DT is invalid (and yes, we can't easily run the validation suite in U-Boot today), I'd rather go with a debug we can optimize out so that the next person with an invalid DT can more quickly find their problem and we don't work-around it instead. Or am I missing something?
Signature · 1 line
Tom
Quoted 48 lines · Tom Rini
Quoted 39 lines · Michal Simek
Quoted 36 lines · Tom Rini
Quoted 34 lines · Michal Simek
Hi Tom,
Quoted 19 lines · Ashok Reddy Soma
There is a chance that assigned-clock-rates is given and assigned-clocks could be empty. Dont return error in that case, because the probe of the corresponding driver will not be called at all if this fails. Better to continue to look for it and return 0.
Signed-off-by Ashok Reddy Soma <[email protected]>---
drivers/clk/clk-uclass.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)drivers/clk/clk-uclass.c +0
-0@@ -329,7 +329,13 @@ static int clk_set_default_rates(struct udevice *dev,dev_dbg (dev,"could not get assigned clock %d (err = %d)\n" , index, ret);drivers/clk/clk-uclass.c static int clk_set_default_rates(struct udevice *dev, · line 340
Quoted 10 lines
drivers/clk/clk-uclass.c +7
-1-continue ; +/* Skip if it is empty */ +if (ret == -ENOENT ) { + ret =0 ; +continue ; + } + +return ret; }/* This is clk provider device trying to program itself What's your take on this one? I didn't get reply from Sean.
Quoted 7 lines
Quoted 2 lines
I guess, what's the validated upstream dts where this is the case?
It was found by incorrect DT. It means I don't think there is any DT which contains this issue.
But that being said we can extend current clock tests to cover this case. Please look below.
Quoted 4 lines
Well, if the DT is invalid (and yes, we can't easily run the validation suite in U-Boot today), I'd rather go with a debug we can optimize out so that the next person with an invalid DT can more quickly find their problem and we don't work-around it instead. Or am I missing something?
There is already dev_dbg print above. It means when user enable DEBUG it gets information about it.
The thing is that it just sync behavior with the linux kernel. You can look at
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/clk/clk-conf.c?h=v6.5#n90
There is also one more example like this.
clk-test4 {
compatible = "sandbox,clk-test";
assigned-clock-rates = <654>, <321>;
assigned-clocks = <&clk_sandbox 1>;
};But if you prefer to fail in all these cases I am also fine with it.
Thanks,
Michal
Tom Rini
Reviewed-byQuoted 63 lines · Michal Simek
Quoted 48 lines · Tom Rini
Quoted 39 lines · Michal Simek
Quoted 36 lines · Tom Rini
Quoted 34 lines · Michal Simek
Hi Tom,
Quoted 19 lines · Ashok Reddy Soma
There is a chance that assigned-clock-rates is given and assigned-clocks could be empty. Dont return error in that case, because the probe of the corresponding driver will not be called at all if this fails. Better to continue to look for it and return 0.
Signed-off-by Ashok Reddy Soma <[email protected]>---
drivers/clk/clk-uclass.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)drivers/clk/clk-uclass.c +0
-0@@ -329,7 +329,13 @@ static int clk_set_default_rates(struct udevice *dev,dev_dbg (dev,"could not get assigned clock %d (err = %d)\n" , index, ret);drivers/clk/clk-uclass.c static int clk_set_default_rates(struct udevice *dev, · line 340
Quoted 10 lines
drivers/clk/clk-uclass.c +7
-1-continue ; +/* Skip if it is empty */ +if (ret == -ENOENT ) { + ret =0 ; +continue ; + } + +return ret; }/* This is clk provider device trying to program itself What's your take on this one? I didn't get reply from Sean.
Quoted 7 lines
Quoted 2 lines
I guess, what's the validated upstream dts where this is the case?
It was found by incorrect DT. It means I don't think there is any DT which contains this issue.
But that being said we can extend current clock tests to cover this case. Please look below.Quoted 4 lines
Well, if the DT is invalid (and yes, we can't easily run the validation suite in U-Boot today), I'd rather go with a debug we can optimize out so that the next person with an invalid DT can more quickly find their problem and we don't work-around it instead. Or am I missing something?
There is already
dev_dbgprint above. It means when user enable DEBUG it gets information about it.The thing is that it just sync behavior with the linux kernel. You can look at
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/clk/clk-conf.c?h=v6.5#n90
Quoted 8 lines
There is also one more example like this.
clk-test4 { compatible = "sandbox,clk-test"; assigned-clock-rates = <654>, <321>; assigned-clocks = <&clk_sandbox 1>; };But if you prefer to fail in all these cases I am also fine with it.
Ah, OK. Yes, I guess matching the kernel here is a good idea then. And yes, updating the tests next.
Signature · 1 line
Tom