drm/nouveau/led: don't access led subdev if it wasn't initialized
PATCH 1/3 drm/nouveau/led: don't access led subdev if it wasn't initialized
From: Karol Herbst <[email protected]>
Fixes a kernel crash on suspend/resume.
--- drm/nouveau/nouveau_led.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drm/nouveau/nouveau_led.c +4 -3
@@ -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
Signature · 6 lines
2.8.0 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 2/3 drm/nouveau/led: guard against a division by 0
--- drm/nouveau/nouveau_led.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drm/nouveau/nouveau_led.c +4 -1
@@ -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
Signature · 6 lines
2.8.0 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
A message that is not in the archive (sent off-list or not yet received): [email protected]
Alexandre Courbot
Tested-byRe: [PATCH 2/3] drm/nouveau/led: guard against a division by 0
Quoted 1 line · Martin Peres
Signed-off-by Martin Peres <[email protected]>
Fixes the crash I was seeing on GM206, thanks!
_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
Karol Herbst
Reviewed-byRe: [PATCH 2/3] drm/nouveau/led: guard against a division by 0
In reply to a message not in the archive2016-09-16 9:34 GMT+02:00 Martin Peres <[email protected]>:
Quoted 10 lines
Signed-off-by Martin Peres <[email protected]>--- drm/nouveau/nouveau_led.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drm/nouveau/nouveau_led.c +0
-0
drm/nouveau/nouveau_led.c nouveau_led_get_brightness(struct led_classdev *led) · line 50
Quoted 8 lines
drm/nouveau/nouveau_led.c +4
-1@@ -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;
Quoted 10 lines
drm/nouveau/nouveau_led.c +0
-1} static void --2.8.0
_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
A message that is not in the archive (sent off-list or not yet received): CAEXux-bN4EsMMW1Y9qaNwfE3pjFO=a9qaKEoBC3-Xijvh57zRA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [PATCH 2/3] drm/nouveau/led: guard against a division by 0
Quoted 24 lines · Karol Herbst
Reviewed-by Karol Herbst <[email protected]>2016-09-16 9:34 GMT+02:00 Martin Peres <[email protected]>:
Quoted 10 lines
Signed-off-by Martin Peres <[email protected]>--- drm/nouveau/nouveau_led.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drm/nouveau/nouveau_led.c +0
-0drm/nouveau/nouveau_led.c nouveau_led_get_brightness(struct led_classdev *led) · line 50
Quoted 8 lines
drm/nouveau/nouveau_led.c +4
-1@@ -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.
Quoted 4 lines
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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
A message that is not in the archive (sent off-list or not yet received): 776cc8a8-a36e-7b4f-9240-f63773fea33f-GANU6spQydw@public.gmane.org
Re: [PATCH 2/3] drm/nouveau/led: guard against a division by 0
2016-09-16 11:14 GMT+02:00 Martin Peres <[email protected]>:
Quoted 28 lines · Karol Herbst
Quoted 27 lines
Reviewed-by Karol Herbst <[email protected]>2016-09-16 9:34 GMT+02:00 Martin Peres <[email protected]>:
Quoted 11 lines
Signed-off-by Martin Peres <[email protected]>--- drm/nouveau/nouveau_led.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drm/nouveau/nouveau_led.c +0
-0drm/nouveau/nouveau_led.c nouveau_led_get_brightness(struct led_classdev *led) · line 50
Quoted 8 lines
drm/nouveau/nouveau_led.c +4
-1@@ -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.
Quoted 8 lines
Quoted 4 lines
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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
PATCH 3/3 drm/nouveau/led: abort early if the device does not have GPIOs
In reply to a message not in the archive--- drm/nouveau/nouveau_led.c | 3 +++ 1 file changed, 3 insertions(+)
drm/nouveau/nouveau_led.c +3 -0
@@ -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 ;
Signature · 6 lines
2.8.0 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
A message that is not in the archive (sent off-list or not yet received): [email protected]
Alexandre Courbot
Tested-byRe: [PATCH 3/3] drm/nouveau/led: abort early if the device does not have GPIOs
Quoted 1 line · Martin Peres
Signed-off-by Martin Peres <[email protected]>
Fixes the crash I was seeing on Tegra, thanks!
_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
Karol Herbst
Reviewed-byRe: [PATCH 3/3] drm/nouveau/led: abort early if the device does not have GPIOs
In reply to a message not in the archive2016-09-16 9:34 GMT+02:00 Martin Peres <[email protected]>:
Quoted 22 lines
Signed-off-by Martin Peres <[email protected]>--- drm/nouveau/nouveau_led.c | 3 +++ 1 file changed, 3 insertions(+)drm/nouveau/nouveau_led.c +3
-1@@ -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
Quoted 4 lines
_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
PATCH 1/1 drm/nouveau/led: make all the stub functions static inline
In reply to a message not in the archive--- drm/nouveau/nouveau_led.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drm/nouveau/nouveau_led.h +3 -3
@@ -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
Signature · 6 lines
2.8.0 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau