ARM: da8xx: fix section mismatch in new drivers
Subsystems (2)
cover ARM: da8xx: fix section mismatch in new drivers
Sekhar noticed there's a section mismatch in the da8xx-mstpri and da8xx-ddrctl drivers. This is caused by calling of_flat_dt_get_machine_name() which has an __init annotation.
This series addresses this issue by introducing a new function that allows to retrieve the compatible property of the root node and using it instead of of_flat_dt_get_machine_name() in the new drivers.
Bartosz Golaszewski (3):
of: base: add support to get machine compatible string
bus: da8xx-mstpri: drop the call to of_flat_dt_get_machine_name()
memory: da8xx-ddrctl: drop the call to of_flat_dt_get_machine_name()
drivers/bus/da8xx-mstpri.c | 2 +- drivers/memory/da8xx-ddrctl.c | 2 +- drivers/of/base.c | 22 ++++++++++++++++++++++ include/linux/of.h | 6 ++++++ 4 files changed, 30 insertions(+), 2 deletions(-)
Signature · 6 lines
2.9.3 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 1/3 of: base: add support to get machine compatible string
Add a function allowing to retrieve the compatible string of the root node of the device tree.
--- drivers/of/base.c | 22 ++++++++++++++++++++++ include/linux/of.h | 6 ++++++ 2 files changed, 28 insertions(+)
drivers/of/base.c +22 -0
@@ -546,6 +546,28 @@ int of_machine_is_compatible(const char *compat)EXPORT_SYMBOL (of_machine_is_compatible);/** +* of_machine_get_compatible - Get the compatible property of the root node +* +* Returns a NULL-terminated string containing the compatible if it could +* be found, NULL otherwise. +*/ +const char *of_machine_get_compatible (void ) +{ +struct device_node *root; +const char *compatible; +int ret =-1 ; + + root =of_find_node_by_path ("/" ); +if (root) { + ret =of_property_read_string (root,"compatible" , &compatible); +of_node_put (root); + } + +return ret ?NULL : compatible; +} +EXPORT_SYMBOL (of_machine_get_compatible); + +/** * __of_device_is_available - check if a device is available for use * * @device: Node to check for availability, with locks already held
include/linux/of.h +6 -0
@@ -367,6 +367,7 @@ extern int of_alias_get_id(struct device_node *np, const char *stem);extern int of_alias_get_highest_id (const char *stem);extern int of_machine_is_compatible (const char *compat); +extern const char *of_machine_get_compatible (void );extern int of_add_property (struct device_node *np,struct property *prop);extern int of_remove_property (struct device_node *np,struct property *prop);
@@ -788,6 +789,11 @@ static inline int of_machine_is_compatible(const char *compat)return 0 ; } +static inline const char *of_machine_get_compatible (void ) +{ +return NULL ; +} +static inline bool of_console_check (const struct device_node *dn,const char *name,int index) {return false;
Signature · 1 line
2.9.3
PATCH 2/3 bus: da8xx-mstpri: drop the call to of_flat_dt_get_machine_name()
In reply to Bartosz GolaszewskiIn order to avoid a section mismatch use of_machine_get_compatible() instead of of_flat_dt_get_machine_name() when printing the error message.
--- drivers/bus/da8xx-mstpri.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/bus/da8xx-mstpri.c +1 -1
@@ -227,7 +227,7 @@ static int da8xx_mstpri_probe(struct platform_device *pdev) prio_list =da8xx_mstpri_get_board_prio ();if (!prio_list) {dev_err (dev,"no master priotities defined for board '%s'\n" , -of_flat_dt_get_machine_name ()); +of_machine_get_compatible ());return -EINVAL ; }
Signature · 1 line
2.9.3
PATCH 3/3 memory: da8xx-ddrctl: drop the call to of_flat_dt_get_machine_name()
In reply to Bartosz GolaszewskiIn order to avoid a section mismatch use of_machine_get_compatible() instead of of_flat_dt_get_machine_name() when printing the error message.
--- drivers/memory/da8xx-ddrctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/memory/da8xx-ddrctl.c +1 -1
@@ -118,7 +118,7 @@ static int da8xx_ddrctl_probe(struct platform_device *pdev) setting =da8xx_ddrctl_get_board_settings ();if (!setting) {dev_err (dev,"no settings for board '%s'\n" , -of_flat_dt_get_machine_name ()); +of_machine_get_compatible ());return -EINVAL ; }
Signature · 1 line
2.9.3
Re: [PATCH 1/3] of: base: add support to get machine compatible string
In reply to Bartosz GolaszewskiQuoted 3 lines · Bartosz Golaszewski
Add a function allowing to retrieve the compatible string of the root node of the device tree.
Rob has queued [1] and it's in -next today. You can reuse that if you are planning to target this for v4.11 or just use open coding in your driver for v4.10 and target this move for v4.11 to avoid cross tree dependencies as I already mentioned in your previous thread.
Signature · 8 lines
Regards, Sudeep [1] http://www.mail-archive.com/[email protected]/msg1274549.html -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/3] of: base: add support to get machine compatible string
2016-11-22 11:53 GMT+01:00 Sudeep Holla <[email protected]>:
Quoted 13 lines · Bartosz Golaszewski
Quoted 4 lines
Add a function allowing to retrieve the compatible string of the root node of the device tree.
Rob has queued [1] and it's in -next today. You can reuse that if you are planning to target this for v4.11 or just use open coding in your driver for v4.10 and target this move for v4.11 to avoid cross tree dependencies as I already mentioned in your previous thread.
Quoted 5 lines
--
Regards,
Sudeep[1] http://www.mail-archive.com/[email protected]/msg1274549.html
Rob's patch checks the model first - I'm not sure this is the behavior we want here as Sekhar suggested we print the machine compatible.
Thanks,
Bartosz Golaszewski
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/3] of: base: add support to get machine compatible string
2016-11-22 11:57 GMT+01:00 Bartosz Golaszewski <[email protected]>:
Quoted 14 lines
2016-11-22 11:53 GMT+01:00 Sudeep Holla <[email protected]>:
Quoted 13 lines · Bartosz Golaszewski
Quoted 4 lines
Add a function allowing to retrieve the compatible string of the root node of the device tree.
Rob has queued [1] and it's in -next today. You can reuse that if you are planning to target this for v4.11 or just use open coding in your driver for v4.10 and target this move for v4.11 to avoid cross tree dependencies as I already mentioned in your previous thread.
Quoted 9 lines
Quoted 5 lines
--
Regards,
Sudeep[1] http://www.mail-archive.com/linux-kernel at vger.kernel.org/msg1274549.html
Rob's patch checks the model first - I'm not sure this is the behavior we want here as Sekhar suggested we print the machine compatible.
I meant your patch of course.
Thanks,
Bartosz
Re: [PATCH 1/3] of: base: add support to get machine compatible string
In reply to Bartosz GolaszewskiQuoted 9 lines · Bartosz Golaszewski
2016-11-22 11:53 GMT+01:00 Sudeep Holla <[email protected]>:
Quoted 8 lines · Bartosz Golaszewski
Quoted 4 lines
Add a function allowing to retrieve the compatible string of the root node of the device tree.
Quoted 7 lines
Quoted 4 lines
Rob has queued [1] and it's in -next today. You can reuse that if you are planning to target this for v4.11 or just use open coding in your driver for v4.10 and target this move for v4.11 to avoid cross tree dependencies as I already mentioned in your previous thread.
Rob's patch checks the model first - I'm not sure this is the behavior we want here as Sekhar suggested we print the machine compatible.
IIUC, you are replacing of_flat_dt_get_machine_name and of_machine_get_model_name does exactly same. So I don't see any point in adding this new function and it's just used for logging purpose. Also Sekhar just gave example by using just compatible adding that function in the driver itself.
As Arnd suggested me[1], you should for v4.10 fix it in the driver itself to avoid the cross tree dependencies at this point similar to [2]
--
Regards,
Sudeep
[1] https://www.mail-archive.com/[email protected]/msg111428.html
[2] http://www.mail-archive.com/[email protected]/msg1274502.html
Re: [PATCH 1/3] of: base: add support to get machine compatible string
Quoted 20 lines · Sudeep Holla
Quoted 9 lines · Bartosz Golaszewski
2016-11-22 11:53 GMT+01:00 Sudeep Holla <[email protected]>:
Quoted 8 lines · Bartosz Golaszewski
Quoted 4 lines
Add a function allowing to retrieve the compatible string of the root node of the device tree.
Quoted 7 lines
Quoted 4 lines
Rob has queued [1] and it's in -next today. You can reuse that if you are planning to target this for v4.11 or just use open coding in your driver for v4.10 and target this move for v4.11 to avoid cross tree dependencies as I already mentioned in your previous thread.
Rob's patch checks the model first - I'm not sure this is the behavior we want here as Sekhar suggested we print the machine compatible.
Quoted 8 lines
IIUC, you are replacing
of_flat_dt_get_machine_nameandof_machine_get_model_namedoes exactly same. So I don't see any point in adding this new function and it's just used for logging purpose. Also Sekhar just gave example by using just compatible adding that function in the driver itself.As Arnd suggested me[1], you should for v4.10 fix it in the driver itself to avoid the cross tree dependencies at this point similar to [2]
+1. Bartosz, can you please fix it in the driver for v4.10. If there is an API available, we can move to it for v4.11
Thanks,
Sekhar
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/3] of: base: add support to get machine compatible string
In reply to Sudeep HollaHi Sudeep,
Quoted 11 lines · Sudeep Holla
Quoted 3 lines · Bartosz Golaszewski
Add a function allowing to retrieve the compatible string of the root node of the device tree.
Rob has queued [1] and it's in -next today. You can reuse that if you are planning to target this for v4.11 or just use open coding in your driver for v4.10 and target this move for v4.11 to avoid cross tree dependencies as I already mentioned in your previous thread.
I dont have your original patch in my mailbox, but I wonder if returning a pointer to property string for a node whose reference has already been released is safe to do? Probably not an issue for the root node, but still feels counter-intuitive.
This is the code for reference:
+int of_machine_get_model_name(const char **model) +{
+ int error;
+
+ if (!of_node_get(of_root))
+ return -EINVAL;
+
+ error = of_property_read_string(of_root, "model", model);
+ if (error)
+ error = of_property_read_string_index(of_root, "compatible",
+ 0, model);
+ of_node_put(of_root);
+
+ return error;
+} +EXPORT_SYMBOL(of_machine_get_model_name);
Thanks,
Sekhar
Re: [PATCH 1/3] of: base: add support to get machine compatible string
Hi Sekhar,
Quoted 15 lines · Sekhar Nori
Hi Sudeep,
Quoted 11 lines · Sudeep Holla
Quoted 3 lines · Bartosz Golaszewski
Add a function allowing to retrieve the compatible string of the root node of the device tree.
Rob has queued [1] and it's in -next today. You can reuse that if you are planning to target this for v4.11 or just use open coding in your driver for v4.10 and target this move for v4.11 to avoid cross tree dependencies as I already mentioned in your previous thread.
Quoted 5 lines
I dont have your original patch in my mailbox, but I wonder if returning a pointer to property string for a node whose reference has already been released is safe to do? Probably not an issue for the root node, but still feels counter-intuitive.
I am not sure if I understand the issue here. Are you referring a case where of_root is freed ?
Also I have seen drivers today just using this pointer directly, but it's better to copy the string(I just saw this done in one case)
Quoted 22 lines
This is the code for reference:
(quoted diff) +16
-0+int of_machine_get_model_name(const char **model) +{ + int error; + + if (!of_node_get(of_root)) + return -EINVAL; + + error = of_property_read_string(of_root, "model", model); + if (error) + error = of_property_read_string_index(of_root, "compatible", + 0, model); + of_node_put(of_root); + + return error; +} +EXPORT_SYMBOL(of_machine_get_model_name);Thanks,
Sekhar
Signature · 2 lines
Regards, Sudeep
Re: [PATCH 1/3] of: base: add support to get machine compatible string
Quoted 18 lines · Sudeep Holla
Hi Sekhar,
Quoted 15 lines · Sekhar Nori
Hi Sudeep,
Quoted 11 lines · Sudeep Holla
Quoted 3 lines · Bartosz Golaszewski
Add a function allowing to retrieve the compatible string of the root node of the device tree.
Rob has queued [1] and it's in -next today. You can reuse that if you are planning to target this for v4.11 or just use open coding in your driver for v4.10 and target this move for v4.11 to avoid cross tree dependencies as I already mentioned in your previous thread.
Quoted 8 lines
Quoted 5 lines
I dont have your original patch in my mailbox, but I wonder if returning a pointer to property string for a node whose reference has already been released is safe to do? Probably not an issue for the root node, but still feels counter-intuitive.
I am not sure if I understand the issue here. Are you referring a case where
of_rootis freed ?
Yes, right, thats what I was hinting at. Since you are giving up the reference to the device node before the function returns, the user can be left with a dangling reference.
Quoted 2 lines
Also I have seen drivers today just using this pointer directly, but it's better to copy the string(I just saw this done in one case)
Hmm, the reference is given up before the API returns, so I doubt copying it later is any additional benefit.
I suspect this is a theoretical issue though since root device node is probably never freed.
Thanks,
Sekhar
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/3] of: base: add support to get machine compatible string
Quoted 25 lines · Sekhar Nori
Quoted 24 lines · Sudeep Holla
Hi Sekhar,
Quoted 20 lines · Sekhar Nori
Hi Sudeep,
Quoted 11 lines · Sudeep Holla
Quoted 3 lines · Bartosz Golaszewski
Add a function allowing to retrieve the compatible string of the root node of the device tree.
Rob has queued [1] and it's in -next today. You can reuse that if you are planning to target this for v4.11 or just use open coding in your driver for v4.10 and target this move for v4.11 to avoid cross tree dependencies as I already mentioned in your previous thread.
I dont have your original patch in my mailbox, but I wonder if returning a pointer to property string for a node whose reference has already been released is safe to do? Probably not an issue for the root node, but still feels counter-intuitive.
Quoted 7 lines
Quoted 2 lines
I am not sure if I understand the issue here. Are you referring a case where
of_rootis freed ?Yes, right, thats what I was hinting at. Since you are giving up the reference to the device node before the function returns, the user can be left with a dangling reference.
Yes I agree.
Quoted 6 lines
Quoted 2 lines
Also I have seen drivers today just using this pointer directly, but it's better to copy the string(I just saw this done in one case)
Hmm, the reference is given up before the API returns, so I doubt copying it later is any additional benefit.
True.
Quoted 3 lines
I suspect this is a theoretical issue though since root device node is probably never freed.
Indeed, not sure if it's worth adding additional code to release the nod at all call sites.
Signature · 2 lines
Regards, Sudeep
Re: [PATCH 1/3] of: base: add support to get machine compatible string
Quoted 31 lines · Sudeep Holla
Quoted 28 lines · Sekhar Nori
Quoted 26 lines · Sudeep Holla
Hi Sekhar,
Quoted 15 lines · Sekhar Nori
Hi Sudeep,
Quoted 11 lines · Sudeep Holla
Quoted 3 lines · Bartosz Golaszewski
Add a function allowing to retrieve the compatible string of the root node of the device tree.
Rob has queued [1] and it's in -next today. You can reuse that if you are planning to target this for v4.11 or just use open coding in your driver for v4.10 and target this move for v4.11 to avoid cross tree dependencies as I already mentioned in your previous thread.
Quoted 5 lines
I dont have your original patch in my mailbox, but I wonder if returning a pointer to property string for a node whose reference has already been released is safe to do? Probably not an issue for the root node, but still feels counter-intuitive.
I am not sure if I understand the issue here. Are you referring a case where
of_rootis freed ?
Quoted 6 lines
Quoted 4 lines
Yes, right, thats what I was hinting at. Since you are giving up the reference to the device node before the function returns, the user can be left with a dangling reference.
Yes I agree.
So, the if(!of_node_get()) is just an expensive NULL pointer check. I think it is better to be explicit about it by not using of_node_get/put() at all. How about:
+int of_machine_get_model_name(const char **model) +{
+ int error;
+
+ if (!of_root)
+ return -EINVAL;
+
+ error = of_property_read_string(of_root, "model", model);
+ if (error)
+ error = of_property_read_string_index(of_root, "compatible",
+ 0, model);
+ return error;
+} +EXPORT_SYMBOL(of_machine_get_model_name);
I know the patch is already in -next so I guess it depends on how strongly Rob feels about this.
Thanks,
Sekhar
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/3] of: base: add support to get machine compatible string
Quoted 37 lines · Sekhar Nori
Quoted 36 lines · Sudeep Holla
Quoted 32 lines · Sekhar Nori
Quoted 18 lines · Sudeep Holla
Hi Sekhar,
Quoted 15 lines · Sekhar Nori
Hi Sudeep,
Quoted 11 lines · Sudeep Holla
Quoted 3 lines · Bartosz Golaszewski
Add a function allowing to retrieve the compatible string of the root node of the device tree.
Rob has queued [1] and it's in -next today. You can reuse that if you are planning to target this for v4.11 or just use open coding in your driver for v4.10 and target this move for v4.11 to avoid cross tree dependencies as I already mentioned in your previous thread.
Quoted 8 lines
Quoted 5 lines
I dont have your original patch in my mailbox, but I wonder if returning a pointer to property string for a node whose reference has already been released is safe to do? Probably not an issue for the root node, but still feels counter-intuitive.
I am not sure if I understand the issue here. Are you referring a case where
of_rootis freed ?Yes, right, thats what I was hinting at. Since you are giving up the reference to the device node before the function returns, the user can be left with a dangling reference.
Quoted 6 lines
Quoted 1 line
Yes I agree.
So, the if(!of_node_get()) is just an expensive NULL pointer check. I think it is better to be explicit about it by not using of_node_get/put() at all. How about:
Are we planning to use this in any time sensitive paths? Anyways I am fine removing them.
Quoted 15 lines
(quoted diff) +14
-0+int of_machine_get_model_name(const char **model) +{ + int error; + + if (!of_root) + return -EINVAL; + + error = of_property_read_string(of_root, "model", model); + if (error) + error = of_property_read_string_index(of_root, "compatible", + 0, model); + return error; +} +EXPORT_SYMBOL(of_machine_get_model_name);
Quoted 2 lines
I know the patch is already in -next so I guess it depends on how strongly Rob feels about this.
Frank expressed his concerns and it may be reverted.
Signature · 2 lines
Regards, Sudeep
Re: [PATCH 1/3] of: base: add support to get machine compatible string
Quoted 9 lines · Sudeep Holla
Quoted 6 lines
So, the if(!of_node_get()) is just an expensive NULL pointer check. I think
it is better to be explicit about it by not using of_node_get/put() at all.
How about:Are we planning to use this in any time sensitive paths? Anyways I am fine removing them.
Not worried about the time taken as much as it serving as a bad example and getting carried over to other places where the impact might actually be real.
Quoted 17 lines
Quoted 17 lines
(quoted diff) +10
-0+int of_machine_get_model_name(const char **model) +{ + int error; + + if (!of_root) + return -EINVAL; + + error = of_property_read_string(of_root, "model", model); + if (error) + error = of_property_read_string_index(of_root,"compatible",
(quoted diff) +4
-0+ 0, model); + return error; +} +EXPORT_SYMBOL(of_machine_get_model_name);
Quoted 5 lines
Quoted 3 lines
I know the patch is already in -next so I guess it depends on how strongly
Rob feels about this.Frank expressed his concerns and it may be reverted.
Didn't notice that. I will check that thread. Thanks!
Regards,
Sekhar
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/3] of: base: add support to get machine compatible string
Quoted 8 lines · Sekhar Nori
Quoted 7 lines · Sudeep Holla
Quoted 6 lines
So, the if(!of_node_get()) is just an expensive NULL pointer check. I think
it is better to be explicit about it by not using of_node_get/put() at all.
How about:
Quoted 7 lines
Quoted 2 lines
Are we planning to use this in any time sensitive paths? Anyways I am fine removing them.
Not worried about the time taken as much as it serving as a bad example and getting carried over to other places where the impact might actually be real.
Ah OK, sure.
Signature · 6 lines
Regards, Sudeep -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html