linux-mips.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] irqchip/irq-brcmstb-l2: Avoid saving mask on shutdown
@ 2024-04-16 19:43 Florian Fainelli
  2024-04-22 21:29 ` Thomas Gleixner
  0 siblings, 1 reply; 6+ messages in thread
From: Florian Fainelli @ 2024-04-16 19:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: opendmb, Florian Fainelli, Tim Ross,
	Broadcom internal kernel review list, Thomas Gleixner,
	open list:BROADCOM BMIPS MIPS ARCHITECTURE,
	moderated list:BROADCOM BCM7XXX ARM ARCHITECTURE

The interrupt controller shutdown path does not need to save the mask of
enabled interrupts because the next state the system is going to be in
is akin to a cold boot, or a kexec'd kernel.

Reported-by: Tim Ross <tim.ross@broadcom.com>
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
 drivers/irqchip/irq-brcmstb-l2.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/drivers/irqchip/irq-brcmstb-l2.c b/drivers/irqchip/irq-brcmstb-l2.c
index 2b0b3175cea0..c988886917f7 100644
--- a/drivers/irqchip/irq-brcmstb-l2.c
+++ b/drivers/irqchip/irq-brcmstb-l2.c
@@ -118,7 +118,7 @@ static void brcmstb_l2_intc_irq_handle(struct irq_desc *desc)
 	chained_irq_exit(chip, desc);
 }
 
-static void brcmstb_l2_intc_suspend(struct irq_data *d)
+static void __brcmstb_l2_intc_suspend(struct irq_data *d, bool save)
 {
 	struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
 	struct irq_chip_type *ct = irq_data_get_chip_type(d);
@@ -127,7 +127,8 @@ static void brcmstb_l2_intc_suspend(struct irq_data *d)
 
 	irq_gc_lock_irqsave(gc, flags);
 	/* Save the current mask */
-	b->saved_mask = irq_reg_readl(gc, ct->regs.mask);
+	if (save)
+		b->saved_mask = irq_reg_readl(gc, ct->regs.mask);
 
 	if (b->can_wake) {
 		/* Program the wakeup mask */
@@ -137,6 +138,16 @@ static void brcmstb_l2_intc_suspend(struct irq_data *d)
 	irq_gc_unlock_irqrestore(gc, flags);
 }
 
+static void brcmstb_l2_intc_shutdown(struct irq_data *d)
+{
+	__brcmstb_l2_intc_suspend(d, false);
+}
+
+static void brcmstb_l2_intc_suspend(struct irq_data *d)
+{
+	__brcmstb_l2_intc_suspend(d, true);
+}
+
 static void brcmstb_l2_intc_resume(struct irq_data *d)
 {
 	struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
@@ -252,7 +263,7 @@ static int __init brcmstb_l2_intc_of_init(struct device_node *np,
 
 	ct->chip.irq_suspend = brcmstb_l2_intc_suspend;
 	ct->chip.irq_resume = brcmstb_l2_intc_resume;
-	ct->chip.irq_pm_shutdown = brcmstb_l2_intc_suspend;
+	ct->chip.irq_pm_shutdown = brcmstb_l2_intc_shutdown;
 
 	if (data->can_wake) {
 		/* This IRQ chip can wake the system, set all child interrupts
-- 
2.34.1


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

* Re: [PATCH] irqchip/irq-brcmstb-l2: Avoid saving mask on shutdown
  2024-04-16 19:43 [PATCH] irqchip/irq-brcmstb-l2: Avoid saving mask on shutdown Florian Fainelli
@ 2024-04-22 21:29 ` Thomas Gleixner
  2024-04-22 22:26   ` Florian Fainelli
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Gleixner @ 2024-04-22 21:29 UTC (permalink / raw)
  To: Florian Fainelli, linux-kernel
  Cc: opendmb, Florian Fainelli, Tim Ross,
	Broadcom internal kernel review list,
	open list:BROADCOM BMIPS MIPS ARCHITECTURE,
	moderated list:BROADCOM BCM7XXX ARM ARCHITECTURE

On Tue, Apr 16 2024 at 12:43, Florian Fainelli wrote:
> The interrupt controller shutdown path does not need to save the mask of
> enabled interrupts because the next state the system is going to be in
> is akin to a cold boot, or a kexec'd kernel.

Sure, but

> Reported-by: Tim Ross <tim.ross@broadcom.com>
> Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
> ---
>  drivers/irqchip/irq-brcmstb-l2.c | 17 ++++++++++++++---
>  1 file changed, 14 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/irqchip/irq-brcmstb-l2.c b/drivers/irqchip/irq-brcmstb-l2.c
> index 2b0b3175cea0..c988886917f7 100644
> --- a/drivers/irqchip/irq-brcmstb-l2.c
> +++ b/drivers/irqchip/irq-brcmstb-l2.c
> @@ -118,7 +118,7 @@ static void brcmstb_l2_intc_irq_handle(struct irq_desc *desc)
>  	chained_irq_exit(chip, desc);
>  }
>  
> -static void brcmstb_l2_intc_suspend(struct irq_data *d)
> +static void __brcmstb_l2_intc_suspend(struct irq_data *d, bool save)
>  {
>  	struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
>  	struct irq_chip_type *ct = irq_data_get_chip_type(d);
> @@ -127,7 +127,8 @@ static void brcmstb_l2_intc_suspend(struct irq_data *d)
>  
>  	irq_gc_lock_irqsave(gc, flags);
>  	/* Save the current mask */
> -	b->saved_mask = irq_reg_readl(gc, ct->regs.mask);
> +	if (save)
> +		b->saved_mask = irq_reg_readl(gc, ct->regs.mask);

what's the conditional actually buying you except more complex code?

Thanks,

        tglx

        

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

* Re: [PATCH] irqchip/irq-brcmstb-l2: Avoid saving mask on shutdown
  2024-04-22 21:29 ` Thomas Gleixner
@ 2024-04-22 22:26   ` Florian Fainelli
  2024-04-22 23:45     ` Thomas Gleixner
  0 siblings, 1 reply; 6+ messages in thread
From: Florian Fainelli @ 2024-04-22 22:26 UTC (permalink / raw)
  To: Thomas Gleixner, Florian Fainelli, linux-kernel
  Cc: opendmb, Tim Ross, Broadcom internal kernel review list,
	open list:BROADCOM BMIPS MIPS ARCHITECTURE,
	moderated list:BROADCOM BCM7XXX ARM ARCHITECTURE

On 4/22/24 14:29, Thomas Gleixner wrote:
> On Tue, Apr 16 2024 at 12:43, Florian Fainelli wrote:
>> The interrupt controller shutdown path does not need to save the mask of
>> enabled interrupts because the next state the system is going to be in
>> is akin to a cold boot, or a kexec'd kernel.
> 
> Sure, but
> 
>> Reported-by: Tim Ross <tim.ross@broadcom.com>
>> Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
>> ---
>>   drivers/irqchip/irq-brcmstb-l2.c | 17 ++++++++++++++---
>>   1 file changed, 14 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/irqchip/irq-brcmstb-l2.c b/drivers/irqchip/irq-brcmstb-l2.c
>> index 2b0b3175cea0..c988886917f7 100644
>> --- a/drivers/irqchip/irq-brcmstb-l2.c
>> +++ b/drivers/irqchip/irq-brcmstb-l2.c
>> @@ -118,7 +118,7 @@ static void brcmstb_l2_intc_irq_handle(struct irq_desc *desc)
>>   	chained_irq_exit(chip, desc);
>>   }
>>   
>> -static void brcmstb_l2_intc_suspend(struct irq_data *d)
>> +static void __brcmstb_l2_intc_suspend(struct irq_data *d, bool save)
>>   {
>>   	struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
>>   	struct irq_chip_type *ct = irq_data_get_chip_type(d);
>> @@ -127,7 +127,8 @@ static void brcmstb_l2_intc_suspend(struct irq_data *d)
>>   
>>   	irq_gc_lock_irqsave(gc, flags);
>>   	/* Save the current mask */
>> -	b->saved_mask = irq_reg_readl(gc, ct->regs.mask);
>> +	if (save)
>> +		b->saved_mask = irq_reg_readl(gc, ct->regs.mask);
> 
> what's the conditional actually buying you except more complex code?

Not much this is an optimization that is simple to carry out. There can 
be dozens of such L2 interrupt controllers in a given system and the 
MMIO accesses start adding up eventually.
-- 
Florian


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

* Re: [PATCH] irqchip/irq-brcmstb-l2: Avoid saving mask on shutdown
  2024-04-22 22:26   ` Florian Fainelli
@ 2024-04-22 23:45     ` Thomas Gleixner
  2024-04-24 16:50       ` Florian Fainelli
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Gleixner @ 2024-04-22 23:45 UTC (permalink / raw)
  To: Florian Fainelli, Florian Fainelli, linux-kernel
  Cc: opendmb, Tim Ross, Broadcom internal kernel review list,
	open list:BROADCOM BMIPS MIPS ARCHITECTURE,
	moderated list:BROADCOM BCM7XXX ARM ARCHITECTURE

On Mon, Apr 22 2024 at 15:26, Florian Fainelli wrote:
> On 4/22/24 14:29, Thomas Gleixner wrote:
>>> +	if (save)
>>> +		b->saved_mask = irq_reg_readl(gc, ct->regs.mask);
>> 
>> what's the conditional actually buying you except more complex code?
>
> Not much this is an optimization that is simple to carry out. There can 
> be dozens of such L2 interrupt controllers in a given system and the 
> MMIO accesses start adding up eventually.

I'm impressed by saving ~12 microseconds per one dozen of interrupt
controllers on system shutdown :)


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

* Re: [PATCH] irqchip/irq-brcmstb-l2: Avoid saving mask on shutdown
  2024-04-22 23:45     ` Thomas Gleixner
@ 2024-04-24 16:50       ` Florian Fainelli
  2024-04-24 17:19         ` Thomas Gleixner
  0 siblings, 1 reply; 6+ messages in thread
From: Florian Fainelli @ 2024-04-24 16:50 UTC (permalink / raw)
  To: Thomas Gleixner, Florian Fainelli, linux-kernel
  Cc: opendmb, Tim Ross, Broadcom internal kernel review list,
	open list:BROADCOM BMIPS MIPS ARCHITECTURE,
	moderated list:BROADCOM BCM7XXX ARM ARCHITECTURE

On 4/22/24 16:45, Thomas Gleixner wrote:
> On Mon, Apr 22 2024 at 15:26, Florian Fainelli wrote:
>> On 4/22/24 14:29, Thomas Gleixner wrote:
>>>> +	if (save)
>>>> +		b->saved_mask = irq_reg_readl(gc, ct->regs.mask);
>>>
>>> what's the conditional actually buying you except more complex code?
>>
>> Not much this is an optimization that is simple to carry out. There can
>> be dozens of such L2 interrupt controllers in a given system and the
>> MMIO accesses start adding up eventually.
> 
> I'm impressed by saving ~12 microseconds per one dozen of interrupt
> controllers on system shutdown :)

I know, right? More seriously are you willing to take that patch, should 
I write a better justification?
-- 
Florian


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

* Re: [PATCH] irqchip/irq-brcmstb-l2: Avoid saving mask on shutdown
  2024-04-24 16:50       ` Florian Fainelli
@ 2024-04-24 17:19         ` Thomas Gleixner
  0 siblings, 0 replies; 6+ messages in thread
From: Thomas Gleixner @ 2024-04-24 17:19 UTC (permalink / raw)
  To: Florian Fainelli, Florian Fainelli, linux-kernel
  Cc: opendmb, Tim Ross, Broadcom internal kernel review list,
	open list:BROADCOM BMIPS MIPS ARCHITECTURE,
	moderated list:BROADCOM BCM7XXX ARM ARCHITECTURE

On Wed, Apr 24 2024 at 09:50, Florian Fainelli wrote:
> On 4/22/24 16:45, Thomas Gleixner wrote:
>> On Mon, Apr 22 2024 at 15:26, Florian Fainelli wrote:
>>> On 4/22/24 14:29, Thomas Gleixner wrote:
>>>>> +	if (save)
>>>>> +		b->saved_mask = irq_reg_readl(gc, ct->regs.mask);
>>>>
>>>> what's the conditional actually buying you except more complex code?
>>>
>>> Not much this is an optimization that is simple to carry out. There can
>>> be dozens of such L2 interrupt controllers in a given system and the
>>> MMIO accesses start adding up eventually.
>> 
>> I'm impressed by saving ~12 microseconds per one dozen of interrupt
>> controllers on system shutdown :)
>
> I know, right? More seriously are you willing to take that patch, should 
> I write a better justification?

I don't have real objections other than rolling my eyes, but a better
justification would be useful.

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

end of thread, other threads:[~2024-04-24 17:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-16 19:43 [PATCH] irqchip/irq-brcmstb-l2: Avoid saving mask on shutdown Florian Fainelli
2024-04-22 21:29 ` Thomas Gleixner
2024-04-22 22:26   ` Florian Fainelli
2024-04-22 23:45     ` Thomas Gleixner
2024-04-24 16:50       ` Florian Fainelli
2024-04-24 17:19         ` Thomas Gleixner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).