linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] irqchip/gic-v3: do not access GICR_WAKER if its secured register.
@ 2018-06-12 14:55 Srinivas Kandagatla
  2018-06-12 15:24 ` Sudeep Holla
  2018-06-12 16:34 ` Marc Zyngier
  0 siblings, 2 replies; 7+ messages in thread
From: Srinivas Kandagatla @ 2018-06-12 14:55 UTC (permalink / raw)
  To: tglx, jason, marc.zyngier
  Cc: linux-kernel, linux-arm-msm, rnayak, bjorn.andersson, sboyd,
	Srinivas Kandagatla

GICR_WAKER can be a secured register, check this before accessing it
as its done in power management code.

Without this patch Qualcomm DB820c board crashes.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 drivers/irqchip/irq-gic-v3.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c
index 5a67ec084588..38136d6e9ca5 100644
--- a/drivers/irqchip/irq-gic-v3.c
+++ b/drivers/irqchip/irq-gic-v3.c
@@ -656,6 +656,12 @@ static int gic_dist_supports_lpis(void)
 	return !!(readl_relaxed(gic_data.dist_base + GICD_TYPER) & GICD_TYPER_LPIS) && !gicv3_nolpi;
 }
 
+/* Check whether it's single security state view */
+static bool gic_dist_security_disabled(void)
+{
+	return readl_relaxed(gic_data.dist_base + GICD_CTLR) & GICD_CTLR_DS;
+}
+
 static void gic_cpu_init(void)
 {
 	void __iomem *rbase;
@@ -664,7 +670,8 @@ static void gic_cpu_init(void)
 	if (gic_populate_rdist())
 		return;
 
-	gic_enable_redist(true);
+	if (gic_dist_security_disabled())
+		gic_enable_redist(true);
 
 	rbase = gic_data_rdist_sgi_base();
 
@@ -819,11 +826,6 @@ static int gic_set_affinity(struct irq_data *d, const struct cpumask *mask_val,
 #endif
 
 #ifdef CONFIG_CPU_PM
-/* Check whether it's single security state view */
-static bool gic_dist_security_disabled(void)
-{
-	return readl_relaxed(gic_data.dist_base + GICD_CTLR) & GICD_CTLR_DS;
-}
 
 static int gic_cpu_pm_notifier(struct notifier_block *self,
 			       unsigned long cmd, void *v)
-- 
2.16.2


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

* Re: [PATCH] irqchip/gic-v3: do not access GICR_WAKER if its secured register.
  2018-06-12 14:55 [PATCH] irqchip/gic-v3: do not access GICR_WAKER if its secured register Srinivas Kandagatla
@ 2018-06-12 15:24 ` Sudeep Holla
  2018-06-12 15:51   ` Srinivas Kandagatla
  2018-06-12 16:34 ` Marc Zyngier
  1 sibling, 1 reply; 7+ messages in thread
From: Sudeep Holla @ 2018-06-12 15:24 UTC (permalink / raw)
  To: Srinivas Kandagatla
  Cc: Thomas Gleixner, Jason Cooper, Marc Zyngier, open list,
	linux-arm-msm, Nayak, Rajendra, bjorn.andersson, sboyd,
	Sudeep Holla

On Tue, Jun 12, 2018 at 3:55 PM, Srinivas Kandagatla
<srinivas.kandagatla@linaro.org> wrote:
> GICR_WAKER can be a secured register, check this before accessing it
> as its done in power management code.
>
> Without this patch Qualcomm DB820c board crashes.
>

Are you sure this is the one causing the crash ?

As per GIC specification:
"When GICD_CTLR.DS==1, this register is always accessible.
 When GICD_CTLR.DS==0, this is a Secure register. This register is RAZ/WI
 to Non-secure accesses."


--
Regards,
Sudeep

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

* Re: [PATCH] irqchip/gic-v3: do not access GICR_WAKER if its secured register.
  2018-06-12 15:24 ` Sudeep Holla
@ 2018-06-12 15:51   ` Srinivas Kandagatla
  0 siblings, 0 replies; 7+ messages in thread
From: Srinivas Kandagatla @ 2018-06-12 15:51 UTC (permalink / raw)
  To: Sudeep Holla
  Cc: Thomas Gleixner, Jason Cooper, Marc Zyngier, open list,
	linux-arm-msm, Nayak, Rajendra, bjorn.andersson, sboyd



On 12/06/18 16:24, Sudeep Holla wrote:
> On Tue, Jun 12, 2018 at 3:55 PM, Srinivas Kandagatla
> <srinivas.kandagatla@linaro.org> wrote:
>> GICR_WAKER can be a secured register, check this before accessing it
>> as its done in power management code.
>>
>> Without this patch Qualcomm DB820c board crashes.
>>
> 
> Are you sure this is the one causing the crash ?
> 
Yep, am 100% sure its the write in gic_enable_redist(). Very first zero 
write to GICR_WAKER is the one which is crashing my system.

If I add return before writing then I can boot my system fine.

Not sure why writes are not ignored?

Also why does other parts of the code have checks while accessing this 
register?

thanks,
srini

> As per GIC specification:
> "When GICD_CTLR.DS==1, this register is always accessible.
>   When GICD_CTLR.DS==0, this is a Secure register. This register is RAZ/WI
>   to Non-secure accesses."
> 
> 
> --
> Regards,
> Sudeep
> 

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

* Re: [PATCH] irqchip/gic-v3: do not access GICR_WAKER if its secured register.
  2018-06-12 14:55 [PATCH] irqchip/gic-v3: do not access GICR_WAKER if its secured register Srinivas Kandagatla
  2018-06-12 15:24 ` Sudeep Holla
@ 2018-06-12 16:34 ` Marc Zyngier
  2018-06-13  8:21   ` Srinivas Kandagatla
  1 sibling, 1 reply; 7+ messages in thread
From: Marc Zyngier @ 2018-06-12 16:34 UTC (permalink / raw)
  To: Srinivas Kandagatla
  Cc: tglx, jason, linux-kernel, linux-arm-msm, rnayak, bjorn.andersson, sboyd

On Tue, 12 Jun 2018 15:55:16 +0100,
Srinivas Kandagatla <srinivas.kandagatla@linaro.org> wrote:
> 
> GICR_WAKER can be a secured register, check this before accessing it
> as its done in power management code.

NAK.

From the GICv3 spec:

* When GICD_CTLR.DS==1, this register is always accessible.
* When GICD_CTLR.DS==0, this is a Secure register. This register is
  RAZ/WI to Non-secure accesses.

> Without this patch Qualcomm DB820c board crashes.

I suggest you find out how the GIC has been integrated on this
platform. If you take a fault on accessing this register, this very
much looks like an integration bug, and it should be quirked as such.

Thanks,

	M.
	
> 
> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> ---
>  drivers/irqchip/irq-gic-v3.c | 14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c
> index 5a67ec084588..38136d6e9ca5 100644
> --- a/drivers/irqchip/irq-gic-v3.c
> +++ b/drivers/irqchip/irq-gic-v3.c
> @@ -656,6 +656,12 @@ static int gic_dist_supports_lpis(void)
>  	return !!(readl_relaxed(gic_data.dist_base + GICD_TYPER) & GICD_TYPER_LPIS) && !gicv3_nolpi;
>  }
>  
> +/* Check whether it's single security state view */
> +static bool gic_dist_security_disabled(void)
> +{
> +	return readl_relaxed(gic_data.dist_base + GICD_CTLR) & GICD_CTLR_DS;
> +}
> +
>  static void gic_cpu_init(void)
>  {
>  	void __iomem *rbase;
> @@ -664,7 +670,8 @@ static void gic_cpu_init(void)
>  	if (gic_populate_rdist())
>  		return;
>  
> -	gic_enable_redist(true);
> +	if (gic_dist_security_disabled())
> +		gic_enable_redist(true);
>  
>  	rbase = gic_data_rdist_sgi_base();
>  
> @@ -819,11 +826,6 @@ static int gic_set_affinity(struct irq_data *d, const struct cpumask *mask_val,
>  #endif
>  
>  #ifdef CONFIG_CPU_PM
> -/* Check whether it's single security state view */
> -static bool gic_dist_security_disabled(void)
> -{
> -	return readl_relaxed(gic_data.dist_base + GICD_CTLR) & GICD_CTLR_DS;
> -}
>  
>  static int gic_cpu_pm_notifier(struct notifier_block *self,
>  			       unsigned long cmd, void *v)
> -- 
> 2.16.2
> 

-- 
Jazz is not dead, it just smell funny.

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

* Re: [PATCH] irqchip/gic-v3: do not access GICR_WAKER if its secured register.
  2018-06-12 16:34 ` Marc Zyngier
@ 2018-06-13  8:21   ` Srinivas Kandagatla
  2018-06-13  8:45     ` Sudeep Holla
  0 siblings, 1 reply; 7+ messages in thread
From: Srinivas Kandagatla @ 2018-06-13  8:21 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: tglx, jason, linux-kernel, linux-arm-msm, rnayak, bjorn.andersson, sboyd



On 12/06/18 17:34, Marc Zyngier wrote:
> I suggest you find out how the GIC has been integrated on this
> platform. If you take a fault on accessing this register, this very
> much looks like an integration bug, and it should be quirked as such.
Thanks for the suggestion, This is a bug in the firmware which is 
restricting access to this register. We have been working around this 
bug for more than 2 years due to this. Now this platform support is in 
mainline and We/I have no hope that this will be fixed in near future 
atleast for this platform.

I will try to come up with a Quirk specific for this SoC.

thanks,
srini

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

* Re: [PATCH] irqchip/gic-v3: do not access GICR_WAKER if its secured register.
  2018-06-13  8:21   ` Srinivas Kandagatla
@ 2018-06-13  8:45     ` Sudeep Holla
  2018-06-13 10:53       ` Srinivas Kandagatla
  0 siblings, 1 reply; 7+ messages in thread
From: Sudeep Holla @ 2018-06-13  8:45 UTC (permalink / raw)
  To: Srinivas Kandagatla
  Cc: Marc Zyngier, Thomas Gleixner, Jason Cooper, open list,
	linux-arm-msm, Nayak, Rajendra, bjorn.andersson, sboyd,
	Sudeep Holla

On Wed, Jun 13, 2018 at 9:21 AM, Srinivas Kandagatla
<srinivas.kandagatla@linaro.org> wrote:
>
>
> On 12/06/18 17:34, Marc Zyngier wrote:
>>
>> I suggest you find out how the GIC has been integrated on this
>> platform. If you take a fault on accessing this register, this very
>> much looks like an integration bug, and it should be quirked as such.
>
> Thanks for the suggestion, This is a bug in the firmware which is
> restricting access to this register. We have been working around this bug
> for more than 2 years due to this. Now this platform support is in mainline
> and We/I have no hope that this will be fixed in near future atleast for
> this platform.
>

From what you are saying, you were aware of the firmware bug for 2 years as
you had work-around from then. I wish the firmware had come up with the fix
in those lost 2 years. I understand if it was discovered now, but that doesn't
seem to be the case here.

Firmware fixes are now becoming inevitable, so the attitude that firmware can't
be fixed has to slowing change. I am not saying I am against the quirk, but in
general I have seen the firmware support of QCOM parts are really bad. I waited
for almost 2 years for PSCI firmware on previous dragonboard where developer
are trying to upstream some feature.

--
Regards,
Sudeep

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

* Re: [PATCH] irqchip/gic-v3: do not access GICR_WAKER if its secured register.
  2018-06-13  8:45     ` Sudeep Holla
@ 2018-06-13 10:53       ` Srinivas Kandagatla
  0 siblings, 0 replies; 7+ messages in thread
From: Srinivas Kandagatla @ 2018-06-13 10:53 UTC (permalink / raw)
  To: Sudeep Holla
  Cc: Marc Zyngier, Thomas Gleixner, Jason Cooper, open list,
	linux-arm-msm, Nayak, Rajendra, bjorn.andersson, sboyd



On 13/06/18 09:45, Sudeep Holla wrote:
> On Wed, Jun 13, 2018 at 9:21 AM, Srinivas Kandagatla
> <srinivas.kandagatla@linaro.org> wrote:
>>
>>
>> On 12/06/18 17:34, Marc Zyngier wrote:
>>>
>>> I suggest you find out how the GIC has been integrated on this
>>> platform. If you take a fault on accessing this register, this very
>>> much looks like an integration bug, and it should be quirked as such.
>>
>> Thanks for the suggestion, This is a bug in the firmware which is
>> restricting access to this register. We have been working around this bug
>> for more than 2 years due to this. Now this platform support is in mainline
>> and We/I have no hope that this will be fixed in near future atleast for
>> this platform.
>>
> 
>  From what you are saying, you were aware of the firmware bug for 2 years as
> you had work-around from then. I wish the firmware had come up with the fix
> in those lost 2 years. I understand if it was discovered now, but that doesn't
> seem to be the case here.
> 
> Firmware fixes are now becoming inevitable, so the attitude that firmware can't
> be fixed has to slowing change. I am not saying I am against the quirk, but in
> general I have seen the firmware support of QCOM parts are really bad. I waited
> for almost 2 years for PSCI firmware on previous dragonboard where developer
> are trying to upstream some feature.
I agree with you!

We did wait for more than 2 years for firmware to be fixed. But it never 
happened and very little hopes to get it fixed.

I did try the quirk based on GICD_IIDR and I could boot linus master on 
DB820c!

I will send it out as RFC soon.

thanks,
srini
> 
> --
> Regards,
> Sudeep
> 

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

end of thread, other threads:[~2018-06-13 10:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-12 14:55 [PATCH] irqchip/gic-v3: do not access GICR_WAKER if its secured register Srinivas Kandagatla
2018-06-12 15:24 ` Sudeep Holla
2018-06-12 15:51   ` Srinivas Kandagatla
2018-06-12 16:34 ` Marc Zyngier
2018-06-13  8:21   ` Srinivas Kandagatla
2018-06-13  8:45     ` Sudeep Holla
2018-06-13 10:53       ` Srinivas Kandagatla

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).