Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp221355imu; Wed, 7 Nov 2018 16:04:15 -0800 (PST) X-Google-Smtp-Source: AJdET5ffJzggkDVFV/u5KnVlmCuN20iRhiDEaKFkan6klwrZI8PTubT00l0wiL9F1BvnCskMe4Hw X-Received: by 2002:a62:e30a:: with SMTP id g10-v6mr2365204pfh.151.1541635455892; Wed, 07 Nov 2018 16:04:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541635455; cv=none; d=google.com; s=arc-20160816; b=WLZJAQBDDaiXh8P6aKPZmrFU1iGy+SPubStrCpNB9mNdfKo8kh/7o2oMlSI+3aIGge plKuQu8ptc3tZCH2HTdZAU5/FH9zRHYkK3DrYk7pN+knT4qDAzpOrdvOKobhooiTcX16 gte8GvbkgclJlF91Y9mv+DZq0aNrEwi5dZoL6/TIWpylVFEnvw+kvrpaeok5QUdeonZM l+y6AU0z2ozWVnVJeb+XPhTU7sHozp7wKBPZ15i2Nk8HEDWK0gIVPw1OU5dCuGr5PQjs cUgo8dXdH2MV4erU4IFY9yq/ITHS5p279rjnVE9WlanX1xcBPLmmbjUop3Lb9qDWnRsS JueQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=CUOaIeLrvUsqbuz/h9LTQt6CsoTtwVaGzCar9ve/Q+M=; b=oSMx1H3WMv7RlObKLgv1hcRl7LoPnryqQTmXl5XAdrRiOoaV5JT8jEkAEl3/0FQKVt AT8eR+YWE4u1kpDL6SEEbJLh6Ki8x483LwpGwivxO5DUNN6xbhMYDdA4L/WEUe/idXe2 sNVZq144golsspacfYVn4hPJoZtGjY4zX5P/KTviW1BsdpqdwdHqmgEE2Pw1XaxqWb90 WyUsDw6UCWekt3o9YKVjIG1lo9uVgfUHgjItw5iG1f/DXJ9GDtOIOMoT2yw9pBVy0R/G MVKbaF9SzGjFrH/pwz40AcFqNQBx1j/78nqWMq8Fs8jihettWkMxSmGZRFSsfJMVHiGj 0LWA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d16-v6si2008392pgd.555.2018.11.07.16.03.57; Wed, 07 Nov 2018 16:04:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727995AbeKHJgW (ORCPT + 99 others); Thu, 8 Nov 2018 04:36:22 -0500 Received: from dcvr.yhbt.net ([64.71.152.64]:38132 "EHLO dcvr.yhbt.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727695AbeKHJgW (ORCPT ); Thu, 8 Nov 2018 04:36:22 -0500 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id CE3261F453; Thu, 8 Nov 2018 00:03:35 +0000 (UTC) Date: Thu, 8 Nov 2018 00:03:35 +0000 From: Eric Wong To: Benjamin Herrenschmidt Cc: David Airlie , Bartlomiej Zolnierkiewicz , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, Alex Deucher , Christian =?utf-8?B?S8O2bmln?= , "David (ChunMing) Zhou" Subject: Re: radeon vs radeonfb Mobility quirks (Thinkpad X32) Message-ID: <20181108000335.a7usqftcmxvu7ywk@untitled> References: <20181104042328.jzavn47y2wloprbs@untitled> <365d8b24f1c6a28c32998924a95b6a2a74655526.camel@kernel.crashing.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <365d8b24f1c6a28c32998924a95b6a2a74655526.camel@kernel.crashing.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Benjamin Herrenschmidt wrote: > There's a whole pile of power management stuff for ancient laptops that > never quite made it from radeonfb to the radeon DRM driver... sadly it > also prevents sleep on old PowerBooks but I haven't had many complaints > so... Thanks for the confirmation that stuff is missing from the DRM driver. > The code for D2 and D3 on those old things is reasonably self > contained, it shouldn't be that hard to move it over I suppose. I started working on the following (dirty) patch for my X32, but hasn't made a difference with just PCI_D2: diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c index 59c8a6647ff2..acc587b18ad2 100644 --- a/drivers/gpu/drm/radeon/radeon_device.c +++ b/drivers/gpu/drm/radeon/radeon_device.c @@ -1548,6 +1548,23 @@ void radeon_device_fini(struct radeon_device *rdev) radeon_doorbell_fini(rdev); } +/* XXX copy of radeonfb_whack_power_state */ +static void radeon_whack_power_state(struct pci_dev *pdev, pci_power_t state) +{ + u16 pwr_cmd; + + for (;;) { + pci_read_config_word(pdev, pdev->pm_cap + PCI_PM_CTRL, + &pwr_cmd); + if (pwr_cmd & state) + break; + pwr_cmd = (pwr_cmd & ~PCI_PM_CTRL_STATE_MASK) | state; + pci_write_config_word(pdev, pdev->pm_cap + PCI_PM_CTRL, + pwr_cmd); + msleep(500); + } + pdev->current_state = state; +} /* * Suspend & resume. @@ -1596,6 +1613,7 @@ int radeon_suspend_kms(struct drm_device *dev, bool suspend, if (radeon_crtc->cursor_bo) { struct radeon_bo *robj = gem_to_radeon_bo(radeon_crtc->cursor_bo); + r = radeon_bo_reserve(robj, false); if (r == 0) { radeon_bo_unpin(robj); @@ -1647,7 +1665,13 @@ int radeon_suspend_kms(struct drm_device *dev, bool suspend, } else if (suspend) { /* Shut down the device */ pci_disable_device(dev->pdev); - pci_set_power_state(dev->pdev, PCI_D3hot); + + if ("X32") { + radeon_whack_power_state(dev->pdev, PCI_D2); + __pci_complete_power_transition(dev->pdev, PCI_D2); + } else { + pci_set_power_state(dev->pdev, PCI_D3hot); + } } if (fbcon) { I suppose some of the mobility stuff from drivers/video/fbdev/aty/radeon_pm.c is necessary, but I haven't figured it out for the DRM driver. Not sure when/if I'll have time to figure it out, or if I'll stick to the radeonfb driver for now. /* Prepare mobility chips for suspend. */ if (rinfo->is_mobility) { /* Program V2CLK */ radeon_pm_program_v2clk(rinfo); /* Disable IO PADs */ radeon_pm_disable_iopad(rinfo); /* Set low current */ radeon_pm_low_current(rinfo); /* Prepare chip for power management */ radeon_pm_setup_for_suspend(rinfo);