From patchwork Fri Feb 21 15:50:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alex Deucher X-Patchwork-Id: 3698231 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2F9DC9F1EE for ; Fri, 21 Feb 2014 15:50:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3F41B2018B for ; Fri, 21 Feb 2014 15:50:19 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 6864320179 for ; Fri, 21 Feb 2014 15:50:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 80809FA467; Fri, 21 Feb 2014 07:50:14 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qc0-f179.google.com (mail-qc0-f179.google.com [209.85.216.179]) by gabe.freedesktop.org (Postfix) with ESMTP id 1948CFA467 for ; Fri, 21 Feb 2014 07:50:12 -0800 (PST) Received: by mail-qc0-f179.google.com with SMTP id r5so1492419qcx.10 for ; Fri, 21 Feb 2014 07:50:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=oRVVFuI9nRd7KsDU4WRk6j3HMUtLOhnVcI4fDl5ExqM=; b=Aj5LLB1wX9GeR6GjPT7PErI4wiVp5o9xyWcu+p3HVYxQXjocBds5nIaXQ1KPWx4s3B BHBRoN+JQ/KqAxkfd6h+pJA5cvSbVJcopyMZ/tInJe0gDJqjzEfF/3vPOLiGlmrZi+JO Q6zqj/wxRo49mQQS451CvPKlqL9n4wrEOB1WrJydrL9S6t3hmwK1npsKzQBc6PF7LcON 7kNloxyTnVFQQxar3WkhH84fC8ZIl37LwQMjN78zblpVL0SJpgbAhJFCKGhcKh67gFea XJxvAGMxTbDvlavUIE3o6MwSAeoVLsC3mps/IrqOMFkWSXFG9NhCN7dANpZFDJjbdpgE 1Jvw== X-Received: by 10.224.103.66 with SMTP id j2mr10927754qao.13.1392997811499; Fri, 21 Feb 2014 07:50:11 -0800 (PST) Received: from localhost.localdomain (static-74-96-105-49.washdc.fios.verizon.net. [74.96.105.49]) by mx.google.com with ESMTPSA id k35sm7624349qgd.22.2014.02.21.07.50.11 for (version=TLSv1.2 cipher=AES128-GCM-SHA256 bits=128/128); Fri, 21 Feb 2014 07:50:11 -0800 (PST) From: Alex Deucher To: dri-devel@lists.freedesktop.org Subject: [PATCH] drm/radeon/pm: handle powered down GPUs properly in sysfs/debugfs Date: Fri, 21 Feb 2014 10:50:06 -0500 Message-Id: <1392997806-12588-1-git-send-email-alexander.deucher@amd.com> X-Mailer: git-send-email 1.8.3.1 Cc: Alex Deucher , stable@vger.kernel.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When we power down the dGPU on a PX system, bail if the user tried to adjust the power state or check the temperature. The GPU is powered down, so it doesn't make sense to actually do anything. We could power up the dGPU to complete the operation, but it would just be undone again as soon as it was completed as the card would be powered down again. Return 0 for temperature and return -EINVAL for other interfaces. bug: https://bugzilla.kernel.org/show_bug.cgi?id=70651 Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org Reviewed-by: Christian König --- drivers/gpu/drm/radeon/radeon_pm.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon_pm.c b/drivers/gpu/drm/radeon/radeon_pm.c index 8e8153e..6f20bb0 100644 --- a/drivers/gpu/drm/radeon/radeon_pm.c +++ b/drivers/gpu/drm/radeon/radeon_pm.c @@ -67,6 +67,11 @@ int radeon_pm_get_type_index(struct radeon_device *rdev, void radeon_pm_acpi_event_handler(struct radeon_device *rdev) { + struct drm_device *ddev = rdev->ddev; + + if (ddev->switch_power_state == DRM_SWITCH_POWER_OFF) + return; + if ((rdev->pm.pm_method == PM_METHOD_DPM) && rdev->pm.dpm_enabled) { mutex_lock(&rdev->pm.mutex); if (power_supply_is_system_supplied() > 0) @@ -361,6 +366,9 @@ static ssize_t radeon_set_pm_profile(struct device *dev, struct drm_device *ddev = dev_get_drvdata(dev); struct radeon_device *rdev = ddev->dev_private; + if (ddev->switch_power_state == DRM_SWITCH_POWER_OFF) + return -EINVAL; + mutex_lock(&rdev->pm.mutex); if (rdev->pm.pm_method == PM_METHOD_PROFILE) { if (strncmp("default", buf, strlen("default")) == 0) @@ -410,7 +418,8 @@ static ssize_t radeon_set_pm_method(struct device *dev, struct radeon_device *rdev = ddev->dev_private; /* we don't support the legacy modes with dpm */ - if (rdev->pm.pm_method == PM_METHOD_DPM) { + if ((rdev->pm.pm_method == PM_METHOD_DPM) || + (ddev->switch_power_state == DRM_SWITCH_POWER_OFF)) { count = -EINVAL; goto fail; } @@ -459,6 +468,11 @@ static ssize_t radeon_set_dpm_state(struct device *dev, struct drm_device *ddev = dev_get_drvdata(dev); struct radeon_device *rdev = ddev->dev_private; + if (ddev->switch_power_state == DRM_SWITCH_POWER_OFF) { + count = -EINVAL; + goto fail; + } + mutex_lock(&rdev->pm.mutex); if (strncmp("battery", buf, strlen("battery")) == 0) rdev->pm.dpm.user_state = POWER_STATE_TYPE_BATTERY; @@ -500,6 +514,9 @@ static ssize_t radeon_set_dpm_forced_performance_level(struct device *dev, enum radeon_dpm_forced_level level; int ret = 0; + if (ddev->switch_power_state == DRM_SWITCH_POWER_OFF) + return -EINVAL; + mutex_lock(&rdev->pm.mutex); if (strncmp("low", buf, strlen("low")) == 0) { level = RADEON_DPM_FORCED_LEVEL_LOW; @@ -538,9 +555,13 @@ static ssize_t radeon_hwmon_show_temp(struct device *dev, char *buf) { struct radeon_device *rdev = dev_get_drvdata(dev); + struct drm_device *ddev = rdev->ddev; int temp; - if (rdev->asic->pm.get_temperature) + /* return 0 if PX card is off */ + if (ddev->switch_power_state == DRM_SWITCH_POWER_OFF) + temp = 0; + else if (rdev->asic->pm.get_temperature) temp = radeon_get_temperature(rdev); else temp = 0; @@ -1579,7 +1600,9 @@ static int radeon_debugfs_pm_info(struct seq_file *m, void *data) struct drm_device *dev = node->minor->dev; struct radeon_device *rdev = dev->dev_private; - if (rdev->pm.dpm_enabled) { + if (dev->switch_power_state == DRM_SWITCH_POWER_OFF) { + seq_printf(m, "Chip powered off\n"); + } else if (rdev->pm.dpm_enabled) { mutex_lock(&rdev->pm.mutex); if (rdev->asic->dpm.debugfs_print_current_performance_level) radeon_dpm_debugfs_print_current_performance_level(rdev, m);