All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/nouveau: enable interrupts on cards with 32 intr lines
@ 2017-04-02  5:03 Adam Borowski
       [not found] ` <20170402050328.9511-1-kilobyte-b9QjgO8OEXPVItvQsEIGlw@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Adam Borowski @ 2017-04-02  5:03 UTC (permalink / raw)
  To: Ben Skeggs, David Airlie,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: Adam Borowski

The code attempts to enable them, but hits an undefined behaviour by
shifting by the entire register's width:

    int lines = 32;
    u32 mask = (1 << lines) - 1;    // 00000000 on x86
    u32 mask = (1 << lines) - 1;    // ffffffff on arm (32)
    u32 mask = (1 << lines) - 1;    // 00000000 on arm64
    u32 mask = (1ULL << lines) - 1; // ffffffff everywhere

Signed-off-by: Adam Borowski <kilobyte@angband.pl>
---
To be honest, I can't tell the difference other than UBSAN stopping its
complaints, but the current code is obviously wrong.

 drivers/gpu/drm/nouveau/nvkm/subdev/gpio/base.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/gpio/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/gpio/base.c
index 77c649723ad7..4a57defc99b3 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/gpio/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/gpio/base.c
@@ -164,7 +164,7 @@ static int
 nvkm_gpio_fini(struct nvkm_subdev *subdev, bool suspend)
 {
 	struct nvkm_gpio *gpio = nvkm_gpio(subdev);
-	u32 mask = (1 << gpio->func->lines) - 1;
+	u32 mask = (1ULL << gpio->func->lines) - 1;
 
 	gpio->func->intr_mask(gpio, NVKM_GPIO_TOGGLED, mask, 0);
 	gpio->func->intr_stat(gpio, &mask, &mask);
-- 
2.11.0

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

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

* Re: [PATCH] drm/nouveau: enable interrupts on cards with 32 intr lines
       [not found] ` <20170402050328.9511-1-kilobyte-b9QjgO8OEXPVItvQsEIGlw@public.gmane.org>
@ 2017-04-06  4:52   ` Ben Skeggs
  0 siblings, 0 replies; 2+ messages in thread
From: Ben Skeggs @ 2017-04-06  4:52 UTC (permalink / raw)
  To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

On 04/02/2017 03:03 PM, Adam Borowski wrote:
> The code attempts to enable them, but hits an undefined behaviour by
> shifting by the entire register's width:
Good catch!

I've merged the patch, clarifying the commit title though to make it 
clear that it's *gpio* interrupts, and not interrupts in general.

Thanks,
Ben.

>
>     int lines = 32;
>     u32 mask = (1 << lines) - 1;    // 00000000 on x86
>     u32 mask = (1 << lines) - 1;    // ffffffff on arm (32)
>     u32 mask = (1 << lines) - 1;    // 00000000 on arm64
>     u32 mask = (1ULL << lines) - 1; // ffffffff everywhere
>
> Signed-off-by: Adam Borowski <kilobyte@angband.pl>
> ---
> To be honest, I can't tell the difference other than UBSAN stopping its
> complaints, but the current code is obviously wrong.
>
>  drivers/gpu/drm/nouveau/nvkm/subdev/gpio/base.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/gpio/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/gpio/base.c
> index 77c649723ad7..4a57defc99b3 100644
> --- a/drivers/gpu/drm/nouveau/nvkm/subdev/gpio/base.c
> +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/gpio/base.c
> @@ -164,7 +164,7 @@ static int
>  nvkm_gpio_fini(struct nvkm_subdev *subdev, bool suspend)
>  {
>  	struct nvkm_gpio *gpio = nvkm_gpio(subdev);
> -	u32 mask = (1 << gpio->func->lines) - 1;
> +	u32 mask = (1ULL << gpio->func->lines) - 1;
>
>  	gpio->func->intr_mask(gpio, NVKM_GPIO_TOGGLED, mask, 0);
>  	gpio->func->intr_stat(gpio, &mask, &mask);
>
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau

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

end of thread, other threads:[~2017-04-06  4:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-02  5:03 [PATCH] drm/nouveau: enable interrupts on cards with 32 intr lines Adam Borowski
     [not found] ` <20170402050328.9511-1-kilobyte-b9QjgO8OEXPVItvQsEIGlw@public.gmane.org>
2017-04-06  4:52   ` Ben Skeggs

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.