All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] drm/nouveau/led: don't access led subdev if it wasn't initialized
@ 2016-09-16  7:34 Martin Peres
       [not found] ` <20160916073444.8952-1-martin.peres-GANU6spQydw@public.gmane.org>
  0 siblings, 1 reply; 10+ messages in thread
From: Martin Peres @ 2016-09-16  7:34 UTC (permalink / raw)
  To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

From: Karol Herbst <karolherbst@gmail.com>

Fixes a kernel crash on suspend/resume.
---
 drm/nouveau/nouveau_led.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drm/nouveau/nouveau_led.c b/drm/nouveau/nouveau_led.c
index 9eed5a6..5e28b5f 100644
--- a/drm/nouveau/nouveau_led.c
+++ b/drm/nouveau/nouveau_led.c
@@ -107,7 +107,8 @@ nouveau_led_suspend(struct drm_device *dev)
 {
 	struct nouveau_drm *drm = nouveau_drm(dev);
 
-	led_classdev_suspend(&drm->led->led);
+	if (drm->led)
+		led_classdev_suspend(&drm->led->led);
 }
 
 void
@@ -115,8 +116,8 @@ nouveau_led_resume(struct drm_device *dev)
 {
 	struct nouveau_drm *drm = nouveau_drm(dev);
 
-	led_classdev_resume(&drm->led->led);
-
+	if (drm->led)
+		led_classdev_resume(&drm->led->led);
 }
 
 void
-- 
2.8.0

_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau

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

* [PATCH 2/3] drm/nouveau/led: guard against a division by 0
       [not found] ` <20160916073444.8952-1-martin.peres-GANU6spQydw@public.gmane.org>
@ 2016-09-16  7:34   ` Martin Peres
       [not found]     ` <20160916073444.8952-2-martin.peres-GANU6spQydw@public.gmane.org>
  2016-09-16  7:34   ` [PATCH 3/3] drm/nouveau/led: abort early if the device does not have GPIOs Martin Peres
  2016-09-17 21:04   ` [PATCH] drm/nouveau/led: make all the stub functions static inline Martin Peres
  2 siblings, 1 reply; 10+ messages in thread
From: Martin Peres @ 2016-09-16  7:34 UTC (permalink / raw)
  To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Signed-off-by: Martin Peres <martin.peres@free.fr>
---
 drm/nouveau/nouveau_led.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drm/nouveau/nouveau_led.c b/drm/nouveau/nouveau_led.c
index 5e28b5f..1f731da 100644
--- a/drm/nouveau/nouveau_led.c
+++ b/drm/nouveau/nouveau_led.c
@@ -44,7 +44,10 @@ nouveau_led_get_brightness(struct led_classdev *led)
 	div =  nvif_rd32(device, 0x61c880) & 0x00ffffff;
 	duty = nvif_rd32(device, 0x61c884) & 0x00ffffff;
 
-	return duty * LED_FULL / div;
+	if (div > 0)
+		return duty * LED_FULL / div;
+	else
+		return 0;
 }
 
 static void
-- 
2.8.0

_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau

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

* [PATCH 3/3] drm/nouveau/led: abort early if the device does not have GPIOs
       [not found] ` <20160916073444.8952-1-martin.peres-GANU6spQydw@public.gmane.org>
  2016-09-16  7:34   ` [PATCH 2/3] drm/nouveau/led: guard against a division by 0 Martin Peres
@ 2016-09-16  7:34   ` Martin Peres
       [not found]     ` <20160916073444.8952-3-martin.peres-GANU6spQydw@public.gmane.org>
  2016-09-17 21:04   ` [PATCH] drm/nouveau/led: make all the stub functions static inline Martin Peres
  2 siblings, 1 reply; 10+ messages in thread
From: Martin Peres @ 2016-09-16  7:34 UTC (permalink / raw)
  To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Signed-off-by: Martin Peres <martin.peres@free.fr>
---
 drm/nouveau/nouveau_led.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drm/nouveau/nouveau_led.c b/drm/nouveau/nouveau_led.c
index 1f731da..3e2f1b6 100644
--- a/drm/nouveau/nouveau_led.c
+++ b/drm/nouveau/nouveau_led.c
@@ -82,6 +82,9 @@ nouveau_led_init(struct drm_device *dev)
 	struct dcb_gpio_func logo_led;
 	int ret;
 
+	if (!gpio)
+		return 0;
+
 	/* check that there is a GPIO controlling the logo LED */
 	if (nvkm_gpio_find(gpio, 0, DCB_GPIO_LOGO_LED_PWM, 0xff, &logo_led))
 		return 0;
-- 
2.8.0

_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau

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

* Re: [PATCH 2/3] drm/nouveau/led: guard against a division by 0
       [not found]     ` <20160916073444.8952-2-martin.peres-GANU6spQydw@public.gmane.org>
@ 2016-09-16  7:42       ` Alexandre Courbot
  2016-09-16  7:42       ` Karol Herbst
  1 sibling, 0 replies; 10+ messages in thread
From: Alexandre Courbot @ 2016-09-16  7:42 UTC (permalink / raw)
  To: Martin Peres; +Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

On Fri, Sep 16, 2016 at 4:34 PM, Martin Peres <martin.peres@free.fr> wrote:
> Signed-off-by: Martin Peres <martin.peres@free.fr>

Tested-by: Alexandre Courbot <acourbot@nvidia.com>

Fixes the crash I was seeing on GM206, thanks!
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau

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

* Re: [PATCH 2/3] drm/nouveau/led: guard against a division by 0
       [not found]     ` <20160916073444.8952-2-martin.peres-GANU6spQydw@public.gmane.org>
  2016-09-16  7:42       ` Alexandre Courbot
@ 2016-09-16  7:42       ` Karol Herbst
       [not found]         ` <CAEXux-bN4EsMMW1Y9qaNwfE3pjFO=a9qaKEoBC3-Xijvh57zRA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  1 sibling, 1 reply; 10+ messages in thread
From: Karol Herbst @ 2016-09-16  7:42 UTC (permalink / raw)
  To: Martin Peres; +Cc: ML nouveau

Reviewed-by: Karol Herbst <karolherbst@gmail.com>

2016-09-16 9:34 GMT+02:00 Martin Peres <martin.peres@free.fr>:
> Signed-off-by: Martin Peres <martin.peres@free.fr>
> ---
>  drm/nouveau/nouveau_led.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drm/nouveau/nouveau_led.c b/drm/nouveau/nouveau_led.c
> index 5e28b5f..1f731da 100644
> --- a/drm/nouveau/nouveau_led.c
> +++ b/drm/nouveau/nouveau_led.c
> @@ -44,7 +44,10 @@ nouveau_led_get_brightness(struct led_classdev *led)
>         div =  nvif_rd32(device, 0x61c880) & 0x00ffffff;
>         duty = nvif_rd32(device, 0x61c884) & 0x00ffffff;
>
> -       return duty * LED_FULL / div;
> +       if (div > 0)
> +               return duty * LED_FULL / div;
> +       else
> +               return 0;

minor nitpick: you can drop the else, I don't mind though. Maybe it
would be clearer to do it the other way around though.

Or to do:

if (unlikely(div <= 0)) return 0;
return duty * LED_FULL / div;

>  }
>
>  static void
> --
> 2.8.0
>
> _______________________________________________
> Nouveau mailing list
> Nouveau@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/nouveau
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau

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

* Re: [PATCH 3/3] drm/nouveau/led: abort early if the device does not have GPIOs
       [not found]     ` <20160916073444.8952-3-martin.peres-GANU6spQydw@public.gmane.org>
@ 2016-09-16  7:42       ` Alexandre Courbot
  2016-09-16  7:43       ` Karol Herbst
  1 sibling, 0 replies; 10+ messages in thread
From: Alexandre Courbot @ 2016-09-16  7:42 UTC (permalink / raw)
  To: Martin Peres; +Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

On Fri, Sep 16, 2016 at 4:34 PM, Martin Peres <martin.peres@free.fr> wrote:
> Signed-off-by: Martin Peres <martin.peres@free.fr>

Tested-by: Alexandre Courbot <acourbot@nvidia.com>

Fixes the crash I was seeing on Tegra, thanks!
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau

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

* Re: [PATCH 3/3] drm/nouveau/led: abort early if the device does not have GPIOs
       [not found]     ` <20160916073444.8952-3-martin.peres-GANU6spQydw@public.gmane.org>
  2016-09-16  7:42       ` Alexandre Courbot
@ 2016-09-16  7:43       ` Karol Herbst
  1 sibling, 0 replies; 10+ messages in thread
From: Karol Herbst @ 2016-09-16  7:43 UTC (permalink / raw)
  To: Martin Peres; +Cc: ML nouveau

Reviewed-by: Karol Herbst <karolherbst@gmail.com>

2016-09-16 9:34 GMT+02:00 Martin Peres <martin.peres@free.fr>:
> Signed-off-by: Martin Peres <martin.peres@free.fr>
> ---
>  drm/nouveau/nouveau_led.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/drm/nouveau/nouveau_led.c b/drm/nouveau/nouveau_led.c
> index 1f731da..3e2f1b6 100644
> --- a/drm/nouveau/nouveau_led.c
> +++ b/drm/nouveau/nouveau_led.c
> @@ -82,6 +82,9 @@ nouveau_led_init(struct drm_device *dev)
>         struct dcb_gpio_func logo_led;
>         int ret;
>
> +       if (!gpio)
> +               return 0;
> +
>         /* check that there is a GPIO controlling the logo LED */
>         if (nvkm_gpio_find(gpio, 0, DCB_GPIO_LOGO_LED_PWM, 0xff, &logo_led))
>                 return 0;
> --
> 2.8.0
>
> _______________________________________________
> Nouveau mailing list
> Nouveau@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/nouveau
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau

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

* Re: [PATCH 2/3] drm/nouveau/led: guard against a division by 0
       [not found]         ` <CAEXux-bN4EsMMW1Y9qaNwfE3pjFO=a9qaKEoBC3-Xijvh57zRA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2016-09-16  9:14           ` Martin Peres
       [not found]             ` <776cc8a8-a36e-7b4f-9240-f63773fea33f-GANU6spQydw@public.gmane.org>
  0 siblings, 1 reply; 10+ messages in thread
From: Martin Peres @ 2016-09-16  9:14 UTC (permalink / raw)
  To: Karol Herbst; +Cc: ML nouveau

On 16/09/16 10:42, Karol Herbst wrote:
> Reviewed-by: Karol Herbst <karolherbst@gmail.com>
>
> 2016-09-16 9:34 GMT+02:00 Martin Peres <martin.peres@free.fr>:
>> Signed-off-by: Martin Peres <martin.peres@free.fr>
>> ---
>>   drm/nouveau/nouveau_led.c | 5 ++++-
>>   1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/drm/nouveau/nouveau_led.c b/drm/nouveau/nouveau_led.c
>> index 5e28b5f..1f731da 100644
>> --- a/drm/nouveau/nouveau_led.c
>> +++ b/drm/nouveau/nouveau_led.c
>> @@ -44,7 +44,10 @@ nouveau_led_get_brightness(struct led_classdev *led)
>>          div =  nvif_rd32(device, 0x61c880) & 0x00ffffff;
>>          duty = nvif_rd32(device, 0x61c884) & 0x00ffffff;
>>
>> -       return duty * LED_FULL / div;
>> +       if (div > 0)
>> +               return duty * LED_FULL / div;
>> +       else
>> +               return 0;
> minor nitpick: you can drop the else, I don't mind though. Maybe it
> would be clearer to do it the other way around though.
>
> Or to do:
>
> if (unlikely(div <= 0)) return 0;
> return duty * LED_FULL / div;

The unlikely is a good idea, not a fan of single lines if conditions 
though :s
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau

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

* Re: [PATCH 2/3] drm/nouveau/led: guard against a division by 0
       [not found]             ` <776cc8a8-a36e-7b4f-9240-f63773fea33f-GANU6spQydw@public.gmane.org>
@ 2016-09-16 11:02               ` Karol Herbst
  0 siblings, 0 replies; 10+ messages in thread
From: Karol Herbst @ 2016-09-16 11:02 UTC (permalink / raw)
  To: Martin Peres; +Cc: ML nouveau

2016-09-16 11:14 GMT+02:00 Martin Peres <martin.peres@free.fr>:
> On 16/09/16 10:42, Karol Herbst wrote:
>>
>> Reviewed-by: Karol Herbst <karolherbst@gmail.com>
>>
>> 2016-09-16 9:34 GMT+02:00 Martin Peres <martin.peres@free.fr>:
>>>
>>> Signed-off-by: Martin Peres <martin.peres@free.fr>
>>> ---
>>>   drm/nouveau/nouveau_led.c | 5 ++++-
>>>   1 file changed, 4 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drm/nouveau/nouveau_led.c b/drm/nouveau/nouveau_led.c
>>> index 5e28b5f..1f731da 100644
>>> --- a/drm/nouveau/nouveau_led.c
>>> +++ b/drm/nouveau/nouveau_led.c
>>> @@ -44,7 +44,10 @@ nouveau_led_get_brightness(struct led_classdev *led)
>>>          div =  nvif_rd32(device, 0x61c880) & 0x00ffffff;
>>>          duty = nvif_rd32(device, 0x61c884) & 0x00ffffff;
>>>
>>> -       return duty * LED_FULL / div;
>>> +       if (div > 0)
>>> +               return duty * LED_FULL / div;
>>> +       else
>>> +               return 0;
>>
>> minor nitpick: you can drop the else, I don't mind though. Maybe it
>> would be clearer to do it the other way around though.
>>
>> Or to do:
>>
>> if (unlikely(div <= 0)) return 0;
>> return duty * LED_FULL / div;
>
>
> The unlikely is a good idea, not a fan of single lines if conditions though
> :s

the single line was me being lazy.

if (unlikely(div <= 0))
        return 0;
return duty * LED_FULL / div;

:p
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau

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

* [PATCH] drm/nouveau/led: make all the stub functions static inline
       [not found] ` <20160916073444.8952-1-martin.peres-GANU6spQydw@public.gmane.org>
  2016-09-16  7:34   ` [PATCH 2/3] drm/nouveau/led: guard against a division by 0 Martin Peres
  2016-09-16  7:34   ` [PATCH 3/3] drm/nouveau/led: abort early if the device does not have GPIOs Martin Peres
@ 2016-09-17 21:04   ` Martin Peres
  2 siblings, 0 replies; 10+ messages in thread
From: Martin Peres @ 2016-09-17 21:04 UTC (permalink / raw)
  To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Suggested-by: Ilia Mirkin <imirkin@alum.mit.edu>
Signed-off-by: Martin Peres <martin.peres@free.fr>
---
 drm/nouveau/nouveau_led.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drm/nouveau/nouveau_led.h b/drm/nouveau/nouveau_led.h
index 750a0d9..187ecdb 100644
--- a/drm/nouveau/nouveau_led.h
+++ b/drm/nouveau/nouveau_led.h
@@ -49,9 +49,9 @@ void nouveau_led_resume(struct drm_device *dev);
 void nouveau_led_fini(struct drm_device *dev);
 #else
 static inline int  nouveau_led_init(struct drm_device *dev) { return 0; };
-void nouveau_led_suspend(struct drm_device *dev) { return; };
-void nouveau_led_resume(struct drm_device *dev) { return; };
-void nouveau_led_fini(struct drm_device *dev) { return; };
+static inline void nouveau_led_suspend(struct drm_device *dev) { };
+static inline void nouveau_led_resume(struct drm_device *dev) { };
+static inline void nouveau_led_fini(struct drm_device *dev) { };
 #endif
 
 #endif
-- 
2.8.0

_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau

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

end of thread, other threads:[~2016-09-17 21:04 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-16  7:34 [PATCH 1/3] drm/nouveau/led: don't access led subdev if it wasn't initialized Martin Peres
     [not found] ` <20160916073444.8952-1-martin.peres-GANU6spQydw@public.gmane.org>
2016-09-16  7:34   ` [PATCH 2/3] drm/nouveau/led: guard against a division by 0 Martin Peres
     [not found]     ` <20160916073444.8952-2-martin.peres-GANU6spQydw@public.gmane.org>
2016-09-16  7:42       ` Alexandre Courbot
2016-09-16  7:42       ` Karol Herbst
     [not found]         ` <CAEXux-bN4EsMMW1Y9qaNwfE3pjFO=a9qaKEoBC3-Xijvh57zRA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-09-16  9:14           ` Martin Peres
     [not found]             ` <776cc8a8-a36e-7b4f-9240-f63773fea33f-GANU6spQydw@public.gmane.org>
2016-09-16 11:02               ` Karol Herbst
2016-09-16  7:34   ` [PATCH 3/3] drm/nouveau/led: abort early if the device does not have GPIOs Martin Peres
     [not found]     ` <20160916073444.8952-3-martin.peres-GANU6spQydw@public.gmane.org>
2016-09-16  7:42       ` Alexandre Courbot
2016-09-16  7:43       ` Karol Herbst
2016-09-17 21:04   ` [PATCH] drm/nouveau/led: make all the stub functions static inline Martin Peres

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.