* [PATCH 2/4] drm/radeon/pm: don't walk the crtc list before it has been initialized (v2)
2014-04-15 16:44 [PATCH 1/4] drm/radeon: properly unregister hwmon interface (v2) Alex Deucher
@ 2014-04-15 16:44 ` Alex Deucher
2014-04-15 16:44 ` [PATCH 3/4] drm/radeon: fix ATPX detection on non-VGA GPUs Alex Deucher
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Alex Deucher @ 2014-04-15 16:44 UTC (permalink / raw)
To: dri-devel, deathsimple; +Cc: Alex Deucher, stable
Avoids a crash in certain cases when thermal irqs are generated
before the display structures have been initialized.
v2: fix the vblank and vrefresh helpers as well
bug:
https://bugzilla.kernel.org/show_bug.cgi?id=73931
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
---
drivers/gpu/drm/radeon/r600_dpm.c | 35 +++++++++++++++++++----------------
drivers/gpu/drm/radeon/radeon_pm.c | 28 ++++++++++++++++------------
2 files changed, 35 insertions(+), 28 deletions(-)
diff --git a/drivers/gpu/drm/radeon/r600_dpm.c b/drivers/gpu/drm/radeon/r600_dpm.c
index cbf7e32..9c61b74 100644
--- a/drivers/gpu/drm/radeon/r600_dpm.c
+++ b/drivers/gpu/drm/radeon/r600_dpm.c
@@ -158,16 +158,18 @@ u32 r600_dpm_get_vblank_time(struct radeon_device *rdev)
u32 line_time_us, vblank_lines;
u32 vblank_time_us = 0xffffffff; /* if the displays are off, vblank time is max */
- list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
- radeon_crtc = to_radeon_crtc(crtc);
- if (crtc->enabled && radeon_crtc->enabled && radeon_crtc->hw_mode.clock) {
- line_time_us = (radeon_crtc->hw_mode.crtc_htotal * 1000) /
- radeon_crtc->hw_mode.clock;
- vblank_lines = radeon_crtc->hw_mode.crtc_vblank_end -
- radeon_crtc->hw_mode.crtc_vdisplay +
- (radeon_crtc->v_border * 2);
- vblank_time_us = vblank_lines * line_time_us;
- break;
+ if (rdev->num_crtc && rdev->mode_info.mode_config_initialized) {
+ list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
+ radeon_crtc = to_radeon_crtc(crtc);
+ if (crtc->enabled && radeon_crtc->enabled && radeon_crtc->hw_mode.clock) {
+ line_time_us = (radeon_crtc->hw_mode.crtc_htotal * 1000) /
+ radeon_crtc->hw_mode.clock;
+ vblank_lines = radeon_crtc->hw_mode.crtc_vblank_end -
+ radeon_crtc->hw_mode.crtc_vdisplay +
+ (radeon_crtc->v_border * 2);
+ vblank_time_us = vblank_lines * line_time_us;
+ break;
+ }
}
}
@@ -181,14 +183,15 @@ u32 r600_dpm_get_vrefresh(struct radeon_device *rdev)
struct radeon_crtc *radeon_crtc;
u32 vrefresh = 0;
- list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
- radeon_crtc = to_radeon_crtc(crtc);
- if (crtc->enabled && radeon_crtc->enabled && radeon_crtc->hw_mode.clock) {
- vrefresh = radeon_crtc->hw_mode.vrefresh;
- break;
+ if (rdev->num_crtc && rdev->mode_info.mode_config_initialized) {
+ list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
+ radeon_crtc = to_radeon_crtc(crtc);
+ if (crtc->enabled && radeon_crtc->enabled && radeon_crtc->hw_mode.clock) {
+ vrefresh = radeon_crtc->hw_mode.vrefresh;
+ break;
+ }
}
}
-
return vrefresh;
}
diff --git a/drivers/gpu/drm/radeon/radeon_pm.c b/drivers/gpu/drm/radeon/radeon_pm.c
index e0a664d..4fc1ec9 100644
--- a/drivers/gpu/drm/radeon/radeon_pm.c
+++ b/drivers/gpu/drm/radeon/radeon_pm.c
@@ -1406,12 +1406,14 @@ static void radeon_pm_compute_clocks_old(struct radeon_device *rdev)
rdev->pm.active_crtcs = 0;
rdev->pm.active_crtc_count = 0;
- list_for_each_entry(crtc,
- &ddev->mode_config.crtc_list, head) {
- radeon_crtc = to_radeon_crtc(crtc);
- if (radeon_crtc->enabled) {
- rdev->pm.active_crtcs |= (1 << radeon_crtc->crtc_id);
- rdev->pm.active_crtc_count++;
+ if (rdev->num_crtc && rdev->mode_info.mode_config_initialized) {
+ list_for_each_entry(crtc,
+ &ddev->mode_config.crtc_list, head) {
+ radeon_crtc = to_radeon_crtc(crtc);
+ if (radeon_crtc->enabled) {
+ rdev->pm.active_crtcs |= (1 << radeon_crtc->crtc_id);
+ rdev->pm.active_crtc_count++;
+ }
}
}
@@ -1478,12 +1480,14 @@ static void radeon_pm_compute_clocks_dpm(struct radeon_device *rdev)
/* update active crtc counts */
rdev->pm.dpm.new_active_crtcs = 0;
rdev->pm.dpm.new_active_crtc_count = 0;
- list_for_each_entry(crtc,
- &ddev->mode_config.crtc_list, head) {
- radeon_crtc = to_radeon_crtc(crtc);
- if (crtc->enabled) {
- rdev->pm.dpm.new_active_crtcs |= (1 << radeon_crtc->crtc_id);
- rdev->pm.dpm.new_active_crtc_count++;
+ if (rdev->num_crtc && rdev->mode_info.mode_config_initialized) {
+ list_for_each_entry(crtc,
+ &ddev->mode_config.crtc_list, head) {
+ radeon_crtc = to_radeon_crtc(crtc);
+ if (crtc->enabled) {
+ rdev->pm.dpm.new_active_crtcs |= (1 << radeon_crtc->crtc_id);
+ rdev->pm.dpm.new_active_crtc_count++;
+ }
}
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH 3/4] drm/radeon: fix ATPX detection on non-VGA GPUs
2014-04-15 16:44 [PATCH 1/4] drm/radeon: properly unregister hwmon interface (v2) Alex Deucher
2014-04-15 16:44 ` [PATCH 2/4] drm/radeon/pm: don't walk the crtc list before it has been initialized (v2) Alex Deucher
@ 2014-04-15 16:44 ` Alex Deucher
2014-04-15 16:44 ` [PATCH 4/4] drm/radeon: don't allow runpm=1 on systems with out ATPX Alex Deucher
2014-04-22 14:51 ` [PATCH 1/4] drm/radeon: properly unregister hwmon interface (v2) Christian König
3 siblings, 0 replies; 5+ messages in thread
From: Alex Deucher @ 2014-04-15 16:44 UTC (permalink / raw)
To: dri-devel, deathsimple; +Cc: Alex Deucher, stable
Some newer PX laptops have the pci device class
set to DISPLAY_OTHER rather than DISPLAY_VGA. This
properly detects ATPX on those laptops.
Based on a patch from: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
Cc: airlied@gmail.com
---
drivers/gpu/drm/radeon/radeon_atpx_handler.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/gpu/drm/radeon/radeon_atpx_handler.c b/drivers/gpu/drm/radeon/radeon_atpx_handler.c
index dedea72..a9fb0d0 100644
--- a/drivers/gpu/drm/radeon/radeon_atpx_handler.c
+++ b/drivers/gpu/drm/radeon/radeon_atpx_handler.c
@@ -528,6 +528,13 @@ static bool radeon_atpx_detect(void)
has_atpx |= (radeon_atpx_pci_probe_handle(pdev) == true);
}
+ /* some newer PX laptops mark the dGPU as a non-VGA display device */
+ while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_OTHER << 8, pdev)) != NULL) {
+ vga_count++;
+
+ has_atpx |= (radeon_atpx_pci_probe_handle(pdev) == true);
+ }
+
if (has_atpx && vga_count == 2) {
acpi_get_name(radeon_atpx_priv.atpx.handle, ACPI_FULL_PATHNAME, &buffer);
printk(KERN_INFO "VGA switcheroo: detected switching method %s handle\n",
--
1.8.3.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH 4/4] drm/radeon: don't allow runpm=1 on systems with out ATPX
2014-04-15 16:44 [PATCH 1/4] drm/radeon: properly unregister hwmon interface (v2) Alex Deucher
2014-04-15 16:44 ` [PATCH 2/4] drm/radeon/pm: don't walk the crtc list before it has been initialized (v2) Alex Deucher
2014-04-15 16:44 ` [PATCH 3/4] drm/radeon: fix ATPX detection on non-VGA GPUs Alex Deucher
@ 2014-04-15 16:44 ` Alex Deucher
2014-04-22 14:51 ` [PATCH 1/4] drm/radeon: properly unregister hwmon interface (v2) Christian König
3 siblings, 0 replies; 5+ messages in thread
From: Alex Deucher @ 2014-04-15 16:44 UTC (permalink / raw)
To: dri-devel, deathsimple; +Cc: Alex Deucher, stable
vgaswitcheroo and the ATPX ACPI methods are required to
power down the dGPU.
bug:
https://bugzilla.kernel.org/show_bug.cgi?id=73901
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
---
drivers/gpu/drm/radeon/radeon_kms.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c
index 9337820..f4a9c5d 100644
--- a/drivers/gpu/drm/radeon/radeon_kms.c
+++ b/drivers/gpu/drm/radeon/radeon_kms.c
@@ -107,11 +107,9 @@ int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags)
flags |= RADEON_IS_PCI;
}
- if (radeon_runtime_pm == 1)
- flags |= RADEON_IS_PX;
- else if ((radeon_runtime_pm == -1) &&
- radeon_has_atpx() &&
- ((flags & RADEON_IS_IGP) == 0))
+ if ((radeon_runtime_pm != 0) &&
+ radeon_has_atpx() &&
+ ((flags & RADEON_IS_IGP) == 0))
flags |= RADEON_IS_PX;
/* radeon_device_init should report only fatal error
--
1.8.3.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/4] drm/radeon: properly unregister hwmon interface (v2)
2014-04-15 16:44 [PATCH 1/4] drm/radeon: properly unregister hwmon interface (v2) Alex Deucher
` (2 preceding siblings ...)
2014-04-15 16:44 ` [PATCH 4/4] drm/radeon: don't allow runpm=1 on systems with out ATPX Alex Deucher
@ 2014-04-22 14:51 ` Christian König
3 siblings, 0 replies; 5+ messages in thread
From: Christian König @ 2014-04-22 14:51 UTC (permalink / raw)
To: Alex Deucher, dri-devel; +Cc: Alex Deucher, stable
Am 15.04.2014 18:44, schrieb Alex Deucher:
> Need to properly unregister the hwmon device on driver
> unload.
>
> v2: minor clean up
>
> bug:
> https://bugzilla.kernel.org/show_bug.cgi?id=73931
>
> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
> Cc: stable@vger.kernel.org
Added to my 3.15 queue.
Sorry for the delay, those patches somehow got lost in my inbox.
Christian.
> ---
> drivers/gpu/drm/radeon/radeon_pm.c | 21 +++++++++++++++------
> 1 file changed, 15 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_pm.c b/drivers/gpu/drm/radeon/radeon_pm.c
> index ee738a5..e0a664d 100644
> --- a/drivers/gpu/drm/radeon/radeon_pm.c
> +++ b/drivers/gpu/drm/radeon/radeon_pm.c
> @@ -603,7 +603,6 @@ static const struct attribute_group *hwmon_groups[] = {
> static int radeon_hwmon_init(struct radeon_device *rdev)
> {
> int err = 0;
> - struct device *hwmon_dev;
>
> switch (rdev->pm.int_thermal_type) {
> case THERMAL_TYPE_RV6XX:
> @@ -616,11 +615,11 @@ static int radeon_hwmon_init(struct radeon_device *rdev)
> case THERMAL_TYPE_KV:
> if (rdev->asic->pm.get_temperature == NULL)
> return err;
> - hwmon_dev = hwmon_device_register_with_groups(rdev->dev,
> - "radeon", rdev,
> - hwmon_groups);
> - if (IS_ERR(hwmon_dev)) {
> - err = PTR_ERR(hwmon_dev);
> + rdev->pm.int_hwmon_dev = hwmon_device_register_with_groups(rdev->dev,
> + "radeon", rdev,
> + hwmon_groups);
> + if (IS_ERR(rdev->pm.int_hwmon_dev)) {
> + err = PTR_ERR(rdev->pm.int_hwmon_dev);
> dev_err(rdev->dev,
> "Unable to register hwmon device: %d\n", err);
> }
> @@ -632,6 +631,12 @@ static int radeon_hwmon_init(struct radeon_device *rdev)
> return err;
> }
>
> +static void radeon_hwmon_fini(struct radeon_device *rdev)
> +{
> + if (rdev->pm.int_hwmon_dev)
> + hwmon_device_unregister(rdev->pm.int_hwmon_dev);
> +}
> +
> static void radeon_dpm_thermal_work_handler(struct work_struct *work)
> {
> struct radeon_device *rdev =
> @@ -1353,6 +1358,8 @@ static void radeon_pm_fini_old(struct radeon_device *rdev)
> device_remove_file(rdev->dev, &dev_attr_power_method);
> }
>
> + radeon_hwmon_fini(rdev);
> +
> if (rdev->pm.power_state)
> kfree(rdev->pm.power_state);
> }
> @@ -1372,6 +1379,8 @@ static void radeon_pm_fini_dpm(struct radeon_device *rdev)
> }
> radeon_dpm_fini(rdev);
>
> + radeon_hwmon_fini(rdev);
> +
> if (rdev->pm.power_state)
> kfree(rdev->pm.power_state);
> }
^ permalink raw reply [flat|nested] 5+ messages in thread