soc/tegra: fuse: Add clock error check in tegra_fuse_readl
diff mbox series

Message ID 1566991129-13479-1-git-send-email-nkristam@nvidia.com
State Superseded
Headers show
Series
  • soc/tegra: fuse: Add clock error check in tegra_fuse_readl
Related show

Commit Message

Nagarjuna Kristam Aug. 28, 2019, 11:18 a.m. UTC
Tegra fuse clock handle is retrieved in tegra_fuse_probe().
tegra_fuse_readl() is exported symbol, which can be called from drivers
at any time. tegra_fuse_readl() enables fuse clock and reads corresponding
fuse register offset.

Calling tegra_fuse_readl() before tegra_fuse_probe(), will cause data
abort. Add DEFER_PROBE error check for fuse clock in tegra_fuse_readl(),
to avoid enabling of fuse clock, before clock is available.

Signed-off-by: Nagarjuna Kristam <nkristam@nvidia.com>
---
 drivers/soc/tegra/fuse/fuse-tegra.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jon Hunter Sept. 2, 2019, 10:45 a.m. UTC | #1
On 28/08/2019 12:18, Nagarjuna Kristam wrote:
> Tegra fuse clock handle is retrieved in tegra_fuse_probe().
> tegra_fuse_readl() is exported symbol, which can be called from drivers
> at any time. tegra_fuse_readl() enables fuse clock and reads corresponding
> fuse register offset.
> 
> Calling tegra_fuse_readl() before tegra_fuse_probe(), will cause data
> abort. Add DEFER_PROBE error check for fuse clock in tegra_fuse_readl(),
> to avoid enabling of fuse clock, before clock is available.
> 
> Signed-off-by: Nagarjuna Kristam <nkristam@nvidia.com>
> ---
>  drivers/soc/tegra/fuse/fuse-tegra.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/soc/tegra/fuse/fuse-tegra.c b/drivers/soc/tegra/fuse/fuse-tegra.c
> index 3eb44e6..21b39b7 100644
> --- a/drivers/soc/tegra/fuse/fuse-tegra.c
> +++ b/drivers/soc/tegra/fuse/fuse-tegra.c
> @@ -186,7 +186,7 @@ u32 __init tegra_fuse_read_early(unsigned int offset)
>  
>  int tegra_fuse_readl(unsigned long offset, u32 *value)
>  {
> -	if (!fuse->read)
> +	if (!fuse->read || (PTR_ERR(fuse->clk) == -EPROBE_DEFER))
>  		return -EPROBE_DEFER;

What about the case where fuse->clk is NULL or a different error value?

Jon
Nagarjuna Kristam Sept. 3, 2019, 4:59 a.m. UTC | #2
On 02-09-2019 16:15, Jon Hunter wrote:
> 
> On 28/08/2019 12:18, Nagarjuna Kristam wrote:
>> Tegra fuse clock handle is retrieved in tegra_fuse_probe().
>> tegra_fuse_readl() is exported symbol, which can be called from drivers
>> at any time. tegra_fuse_readl() enables fuse clock and reads corresponding
>> fuse register offset.
>>
>> Calling tegra_fuse_readl() before tegra_fuse_probe(), will cause data
>> abort. Add DEFER_PROBE error check for fuse clock in tegra_fuse_readl(),
>> to avoid enabling of fuse clock, before clock is available.
>>
>> Signed-off-by: Nagarjuna Kristam <nkristam@nvidia.com>
>> ---
>>  drivers/soc/tegra/fuse/fuse-tegra.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/soc/tegra/fuse/fuse-tegra.c b/drivers/soc/tegra/fuse/fuse-tegra.c
>> index 3eb44e6..21b39b7 100644
>> --- a/drivers/soc/tegra/fuse/fuse-tegra.c
>> +++ b/drivers/soc/tegra/fuse/fuse-tegra.c
>> @@ -186,7 +186,7 @@ u32 __init tegra_fuse_read_early(unsigned int offset)
>>  
>>  int tegra_fuse_readl(unsigned long offset, u32 *value)
>>  {
>> -	if (!fuse->read)
>> +	if (!fuse->read || (PTR_ERR(fuse->clk) == -EPROBE_DEFER))
>>  		return -EPROBE_DEFER;
> 
> What about the case where fuse->clk is NULL or a different error value?
> 
> Jon
> 
Yes, all error checks are needed, will use IS_ERR as a separate condition for clock.

Thanks,
Nagarjuna

Patch
diff mbox series

diff --git a/drivers/soc/tegra/fuse/fuse-tegra.c b/drivers/soc/tegra/fuse/fuse-tegra.c
index 3eb44e6..21b39b7 100644
--- a/drivers/soc/tegra/fuse/fuse-tegra.c
+++ b/drivers/soc/tegra/fuse/fuse-tegra.c
@@ -186,7 +186,7 @@  u32 __init tegra_fuse_read_early(unsigned int offset)
 
 int tegra_fuse_readl(unsigned long offset, u32 *value)
 {
-	if (!fuse->read)
+	if (!fuse->read || (PTR_ERR(fuse->clk) == -EPROBE_DEFER))
 		return -EPROBE_DEFER;
 
 	*value = fuse->read(fuse, offset);