diff mbox

radeon kms: fix uninitialised hotplug work usage in r100_irq_process()

Message ID 20130829092935.GB2235@swordfish (mailing list archive)
State New, archived
Headers show

Commit Message

Sergey Senozhatsky Aug. 29, 2013, 9:29 a.m. UTC
Commit a01c34f72e7cd2624570818f579b5ab464f93de2 (radeon kms: do not
flush uninitialized hotplug work) moved work initialisation phase to
the last step of radeon_irq_kms_init(). Meelis Roos reported that this
causes problems on his machine because drm_irq_install() uses hotplug
work on r100.

hotplug work flushed in radeon_irq_kms_fini(), with two possible cases:
-- radeon_irq_kms_fini() call after successful radeon_irq_kms_init()
-- radeon_irq_kms_fini() call after unsuccessful (or not called at all)
   radeon_irq_kms_init()

The latter one causes flush work on uninitialised hotplug work. Move
work initialisation before drm_irq_install(), but keep existing agreement
to flush hotplug work in radeon_irq_kms_fini() only for `irq.installed'
(successful radeon_irq_kms_init()) case.

WARNING: CPU: 0 PID: 243 at kernel/workqueue.c:1378 __queue_work+0x132/0x16d()
Call Trace:
[<c12319b3>] ? dump_stack+0xa/0x13
[<c1022600>] ? warn_slowpath_common+0x75/0x8a
[<c1031010>] ? __queue_work+0x132/0x16d
[<c1031010>] ? __queue_work+0x132/0x16d
[<c102269e>] ? warn_slowpath_null+0x1b/0x1f
[<c1031010>] ? __queue_work+0x132/0x16d
[<c103107b>] ? queue_work_on+0x30/0x40
[<f8aed3f3>] ? r100_irq_process+0x16d/0x1e6 [radeon]
[<f8ae77cf>] ? radeon_driver_irq_preinstall_kms+0xc2/0xc5 [radeon]
[<f8974d77>] ? drm_irq_install+0xb2/0x1ac [drm]
[<f897604d>] ? drm_vblank_init+0x196/0x1d2 [drm]
[<f8ae78d3>] ? radeon_irq_kms_init+0x33/0xc6 [radeon]
[<f8aef35a>] ? r100_startup+0x1a3/0x1d6 [radeon]
[<f8ad77c8>] ? radeon_ttm_init+0x26e/0x287 [radeon]
[<f8aef752>] ? r100_init+0x2b3/0x309 [radeon]
[<c118082e>] ? vga_client_register+0x39/0x40
[<f8ac535f>] ? radeon_device_init+0x54b/0x61b [radeon]
[<f8ac40fd>] ? cail_mc_write+0x13/0x13 [radeon]
[<f8ac6864>] ? radeon_driver_load_kms+0x82/0xda [radeon]
[<f8978bbd>] ? drm_get_pci_dev+0x136/0x22d [drm]
[<f8ac409b>] ? radeon_pci_probe+0x6c/0x86 [radeon]
[<c112acf6>] ? pci_device_probe+0x4c/0x83
[<c11846c7>] ? driver_probe_device+0x80/0x184
[<c112a848>] ? pci_match_id+0x18/0x36
[<c1184837>] ? __driver_attach+0x44/0x5f
[<c11833f4>] ? bus_for_each_dev+0x50/0x5a
[<c118433e>] ? driver_attach+0x14/0x16
[<c11847f3>] ? __device_attach+0x28/0x28
[<c1184045>] ? bus_add_driver+0xd6/0x1bf
[<c1184c22>] ? driver_register+0x78/0xcf
[<f8ba8000>] ? 0xf8ba7fff
[<c10003bf>] ? do_one_initcall+0x8b/0x121
[<c101e668>] ? change_page_attr_clear+0x2e/0x33
[<f8ba8000>] ? 0xf8ba7fff
[<c101e689>] ? set_memory_ro+0x1c/0x20
[<c104de94>] ? set_page_attributes+0x11/0x12
[<c104f6e1>] ? load_module+0x12fa/0x17e8
[<c107483b>] ? map_vm_area+0x22/0x31
[<c104fc36>] ? SyS_init_module+0x67/0x7d
[<c1234245>] ? sysenter_do_call+0x12/0x26

Reported-by: Meelis Roos <mroos@linux.ee>
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>

---

 drivers/gpu/drm/radeon/radeon_irq_kms.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

Meelis Roos Aug. 29, 2013, 10:55 a.m. UTC | #1
> Reported-by: Meelis Roos <mroos@linux.ee>
> Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>

It works, thank you for quick response!

Tested-by: Meelis Roos <mroos@linux.ee>

>  drivers/gpu/drm/radeon/radeon_irq_kms.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/radeon/radeon_irq_kms.c b/drivers/gpu/drm/radeon/radeon_irq_kms.c
> index 081886b..cc9e848 100644
> --- a/drivers/gpu/drm/radeon/radeon_irq_kms.c
> +++ b/drivers/gpu/drm/radeon/radeon_irq_kms.c
> @@ -275,17 +275,19 @@ int radeon_irq_kms_init(struct radeon_device *rdev)
>  			dev_info(rdev->dev, "radeon: using MSI.\n");
>  		}
>  	}
> +
> +	INIT_WORK(&rdev->hotplug_work, radeon_hotplug_work_func);
> +	INIT_WORK(&rdev->audio_work, r600_audio_update_hdmi);
> +	INIT_WORK(&rdev->reset_work, radeon_irq_reset_work_func);
> +
>  	rdev->irq.installed = true;
>  	r = drm_irq_install(rdev->ddev);
>  	if (r) {
>  		rdev->irq.installed = false;
> +		flush_work(&rdev->hotplug_work);
>  		return r;
>  	}
>  
> -	INIT_WORK(&rdev->hotplug_work, radeon_hotplug_work_func);
> -	INIT_WORK(&rdev->audio_work, r600_audio_update_hdmi);
> -	INIT_WORK(&rdev->reset_work, radeon_irq_reset_work_func);
> -
>  	DRM_INFO("radeon: irq initialized.\n");
>  	return 0;
>  }
>
Alex Deucher Aug. 29, 2013, 6:27 p.m. UTC | #2
On Thu, Aug 29, 2013 at 6:55 AM, Meelis Roos <mroos@linux.ee> wrote:
>> Reported-by: Meelis Roos <mroos@linux.ee>
>> Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
>
> It works, thank you for quick response!
>
> Tested-by: Meelis Roos <mroos@linux.ee>

Thanks.  I've added it to my patch queue.

Alex

>
>>  drivers/gpu/drm/radeon/radeon_irq_kms.c | 10 ++++++----
>>  1 file changed, 6 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/radeon/radeon_irq_kms.c b/drivers/gpu/drm/radeon/radeon_irq_kms.c
>> index 081886b..cc9e848 100644
>> --- a/drivers/gpu/drm/radeon/radeon_irq_kms.c
>> +++ b/drivers/gpu/drm/radeon/radeon_irq_kms.c
>> @@ -275,17 +275,19 @@ int radeon_irq_kms_init(struct radeon_device *rdev)
>>                       dev_info(rdev->dev, "radeon: using MSI.\n");
>>               }
>>       }
>> +
>> +     INIT_WORK(&rdev->hotplug_work, radeon_hotplug_work_func);
>> +     INIT_WORK(&rdev->audio_work, r600_audio_update_hdmi);
>> +     INIT_WORK(&rdev->reset_work, radeon_irq_reset_work_func);
>> +
>>       rdev->irq.installed = true;
>>       r = drm_irq_install(rdev->ddev);
>>       if (r) {
>>               rdev->irq.installed = false;
>> +             flush_work(&rdev->hotplug_work);
>>               return r;
>>       }
>>
>> -     INIT_WORK(&rdev->hotplug_work, radeon_hotplug_work_func);
>> -     INIT_WORK(&rdev->audio_work, r600_audio_update_hdmi);
>> -     INIT_WORK(&rdev->reset_work, radeon_irq_reset_work_func);
>> -
>>       DRM_INFO("radeon: irq initialized.\n");
>>       return 0;
>>  }
>>
>
> --
> Meelis Roos (mroos@linux.ee)
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
Alex Deucher Aug. 29, 2013, 8:06 p.m. UTC | #3
On Thu, Aug 29, 2013 at 4:07 PM, Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
> On Thu, Aug 29, 2013 at 02:27:52PM -0400, Alex Deucher wrote:
>> On Thu, Aug 29, 2013 at 6:55 AM, Meelis Roos <mroos@linux.ee> wrote:
>> >> Reported-by: Meelis Roos <mroos@linux.ee>
>> >> Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
>> >
>> > It works, thank you for quick response!
>> >
>> > Tested-by: Meelis Roos <mroos@linux.ee>
>>
>> Thanks.  I've added it to my patch queue.
>
> Can you add a cc: stable mark if it also is going to affect the stable
> kernels as well?
>

Yes, already done.

Alex

> thanks,
>
> greg k-h
Greg Kroah-Hartman Aug. 29, 2013, 8:07 p.m. UTC | #4
On Thu, Aug 29, 2013 at 02:27:52PM -0400, Alex Deucher wrote:
> On Thu, Aug 29, 2013 at 6:55 AM, Meelis Roos <mroos@linux.ee> wrote:
> >> Reported-by: Meelis Roos <mroos@linux.ee>
> >> Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
> >
> > It works, thank you for quick response!
> >
> > Tested-by: Meelis Roos <mroos@linux.ee>
> 
> Thanks.  I've added it to my patch queue.

Can you add a cc: stable mark if it also is going to affect the stable
kernels as well?

thanks,

greg k-h
Sergey Senozhatsky Aug. 29, 2013, 8:28 p.m. UTC | #5
On (08/29/13 16:06), Alex Deucher wrote:
> On Thu, Aug 29, 2013 at 4:07 PM, Greg Kroah-Hartman
> <gregkh@linuxfoundation.org> wrote:
> > On Thu, Aug 29, 2013 at 02:27:52PM -0400, Alex Deucher wrote:
> >> On Thu, Aug 29, 2013 at 6:55 AM, Meelis Roos <mroos@linux.ee> wrote:
> >> >> Reported-by: Meelis Roos <mroos@linux.ee>
> >> >> Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
> >> >
> >> > It works, thank you for quick response!
> >> >
> >> > Tested-by: Meelis Roos <mroos@linux.ee>
> >>
> >> Thanks.  I've added it to my patch queue.
> >
> > Can you add a cc: stable mark if it also is going to affect the stable
> > kernels as well?
> >
> 
> Yes, already done.
>

Thank you Meelis for testing.



As far as I remember, original patch did not apply to
some stable kernels. I'll keep an eye on it and will
backport.

Thanks,
	-ss

> Alex
> 
> > thanks,
> >
> > greg k-h
>
diff mbox

Patch

diff --git a/drivers/gpu/drm/radeon/radeon_irq_kms.c b/drivers/gpu/drm/radeon/radeon_irq_kms.c
index 081886b..cc9e848 100644
--- a/drivers/gpu/drm/radeon/radeon_irq_kms.c
+++ b/drivers/gpu/drm/radeon/radeon_irq_kms.c
@@ -275,17 +275,19 @@  int radeon_irq_kms_init(struct radeon_device *rdev)
 			dev_info(rdev->dev, "radeon: using MSI.\n");
 		}
 	}
+
+	INIT_WORK(&rdev->hotplug_work, radeon_hotplug_work_func);
+	INIT_WORK(&rdev->audio_work, r600_audio_update_hdmi);
+	INIT_WORK(&rdev->reset_work, radeon_irq_reset_work_func);
+
 	rdev->irq.installed = true;
 	r = drm_irq_install(rdev->ddev);
 	if (r) {
 		rdev->irq.installed = false;
+		flush_work(&rdev->hotplug_work);
 		return r;
 	}
 
-	INIT_WORK(&rdev->hotplug_work, radeon_hotplug_work_func);
-	INIT_WORK(&rdev->audio_work, r600_audio_update_hdmi);
-	INIT_WORK(&rdev->reset_work, radeon_irq_reset_work_func);
-
 	DRM_INFO("radeon: irq initialized.\n");
 	return 0;
 }