mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] clocksource/timer-of: Add missing casts to percpu address space
@ 2024-08-19  6:13 Uros Bizjak
  2024-08-19  8:18 ` Daniel Lezcano
  0 siblings, 1 reply; 3+ messages in thread
From: Uros Bizjak @ 2024-08-19  6:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Uros Bizjak, Daniel Lezcano, Thomas Gleixner

Add missing casts to percpu address space to fix

timer-of.c:29:46: warning: incorrect type in argument 2 (different address spaces)
timer-of.c:29:46:    expected void [noderef] __percpu *
timer-of.c:29:46:    got struct clock_event_device *clkevt
timer-of.c:74:51: warning: incorrect type in argument 4 (different address spaces)
timer-of.c:74:51:    expected void [noderef] __percpu *percpu_dev_id
timer-of.c:74:51:    got struct clock_event_device *clkevt

sparse warnings.

Found by GCC's named address space checks.

There were no changes in the resulting object file.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
---
 drivers/clocksource/timer-of.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/clocksource/timer-of.c b/drivers/clocksource/timer-of.c
index c3f54d9912be..7e0375a804ff 100644
--- a/drivers/clocksource/timer-of.c
+++ b/drivers/clocksource/timer-of.c
@@ -26,7 +26,8 @@ static __init void timer_of_irq_exit(struct of_timer_irq *of_irq)
 	struct clock_event_device *clkevt = &to->clkevt;
 
 	if (of_irq->percpu)
-		free_percpu_irq(of_irq->irq, clkevt);
+		free_percpu_irq(of_irq->irq,
+				(void __percpu *)(unsigned long)clkevt);
 	else
 		free_irq(of_irq->irq, clkevt);
 }
@@ -70,8 +71,8 @@ static __init int timer_of_irq_init(struct device_node *np,
 	}
 
 	ret = of_irq->percpu ?
-		request_percpu_irq(of_irq->irq, of_irq->handler,
-				   np->full_name, clkevt) :
+		request_percpu_irq(of_irq->irq, of_irq->handler, np->full_name,
+				   (void __percpu *)(unsigned long)clkevt) :
 		request_irq(of_irq->irq, of_irq->handler,
 			    of_irq->flags ? of_irq->flags : IRQF_TIMER,
 			    np->full_name, clkevt);
-- 
2.46.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] clocksource/timer-of: Add missing casts to percpu address space
  2024-08-19  6:13 [PATCH] clocksource/timer-of: Add missing casts to percpu address space Uros Bizjak
@ 2024-08-19  8:18 ` Daniel Lezcano
  2024-08-19  8:31   ` Uros Bizjak
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Lezcano @ 2024-08-19  8:18 UTC (permalink / raw)
  To: Uros Bizjak, linux-kernel; +Cc: Thomas Gleixner

On 19/08/2024 08:13, Uros Bizjak wrote:
> Add missing casts to percpu address space to fix
> 
> timer-of.c:29:46: warning: incorrect type in argument 2 (different address spaces)
> timer-of.c:29:46:    expected void [noderef] __percpu *
> timer-of.c:29:46:    got struct clock_event_device *clkevt
> timer-of.c:74:51: warning: incorrect type in argument 4 (different address spaces)
> timer-of.c:74:51:    expected void [noderef] __percpu *percpu_dev_id
> timer-of.c:74:51:    got struct clock_event_device *clkevt
> 
> sparse warnings.
> 
> Found by GCC's named address space checks.
> 
> There were no changes in the resulting object file.

The warning may go away but the problem sparse is spotting is still there.

IMO sparse is totally right and the code related to the percpu is 
broken. It seems the .percpu flag is never used in the drivers and we 
should be able to just remove the percpu related code in timer-of.c

> Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
> Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> ---
>   drivers/clocksource/timer-of.c | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/clocksource/timer-of.c b/drivers/clocksource/timer-of.c
> index c3f54d9912be..7e0375a804ff 100644
> --- a/drivers/clocksource/timer-of.c
> +++ b/drivers/clocksource/timer-of.c
> @@ -26,7 +26,8 @@ static __init void timer_of_irq_exit(struct of_timer_irq *of_irq)
>   	struct clock_event_device *clkevt = &to->clkevt;
>   
>   	if (of_irq->percpu)
> -		free_percpu_irq(of_irq->irq, clkevt);
> +		free_percpu_irq(of_irq->irq,
> +				(void __percpu *)(unsigned long)clkevt);
>   	else
>   		free_irq(of_irq->irq, clkevt);
>   }
> @@ -70,8 +71,8 @@ static __init int timer_of_irq_init(struct device_node *np,
>   	}
>   
>   	ret = of_irq->percpu ?
> -		request_percpu_irq(of_irq->irq, of_irq->handler,
> -				   np->full_name, clkevt) :
> +		request_percpu_irq(of_irq->irq, of_irq->handler, np->full_name,
> +				   (void __percpu *)(unsigned long)clkevt) :
>   		request_irq(of_irq->irq, of_irq->handler,
>   			    of_irq->flags ? of_irq->flags : IRQF_TIMER,
>   			    np->full_name, clkevt);


-- 
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] clocksource/timer-of: Add missing casts to percpu address space
  2024-08-19  8:18 ` Daniel Lezcano
@ 2024-08-19  8:31   ` Uros Bizjak
  0 siblings, 0 replies; 3+ messages in thread
From: Uros Bizjak @ 2024-08-19  8:31 UTC (permalink / raw)
  To: Daniel Lezcano; +Cc: linux-kernel, Thomas Gleixner

On Mon, Aug 19, 2024 at 10:18 AM Daniel Lezcano
<daniel.lezcano@linaro.org> wrote:
>
> On 19/08/2024 08:13, Uros Bizjak wrote:
> > Add missing casts to percpu address space to fix
> >
> > timer-of.c:29:46: warning: incorrect type in argument 2 (different address spaces)
> > timer-of.c:29:46:    expected void [noderef] __percpu *
> > timer-of.c:29:46:    got struct clock_event_device *clkevt
> > timer-of.c:74:51: warning: incorrect type in argument 4 (different address spaces)
> > timer-of.c:74:51:    expected void [noderef] __percpu *percpu_dev_id
> > timer-of.c:74:51:    got struct clock_event_device *clkevt
> >
> > sparse warnings.
> >
> > Found by GCC's named address space checks.
> >
> > There were no changes in the resulting object file.
>
> The warning may go away but the problem sparse is spotting is still there.
>
> IMO sparse is totally right and the code related to the percpu is
> broken. It seems the .percpu flag is never used in the drivers and we
> should be able to just remove the percpu related code in timer-of.c

This issue also breaks allyesconfig build on x86 when strict percpu
address space checker is enabled. However, I have little idea what the
code is doing, so I try to keep the proposed changes as non intrusive
as possible. The referred code is questionable as it tries to reuse
the clkevent pointer once as percpu pointer and once as generic
pointer, which should be avoided.

The only other issue flagged in clocksource drivers directory is
reported in [1] where generic request_irq() function apparently tries
to handle the percpu pointer.

[1] https://lore.kernel.org/lkml/20240730132015.8920-1-ubizjak@gmail.com/

Thanks,
Uros.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-08-19  8:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-19  6:13 [PATCH] clocksource/timer-of: Add missing casts to percpu address space Uros Bizjak
2024-08-19  8:18 ` Daniel Lezcano
2024-08-19  8:31   ` Uros Bizjak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®