Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1503742ybz; Wed, 22 Apr 2020 23:26:54 -0700 (PDT) X-Google-Smtp-Source: APiQypIqm2Wy+iEq1CryCBrx6nWauR1BAztmBZ8JRqISezAtgcgqueOhngYlF9OITt/xC0dkUG/V X-Received: by 2002:a50:f61c:: with SMTP id c28mr1393723edn.365.1587623214702; Wed, 22 Apr 2020 23:26:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587623214; cv=none; d=google.com; s=arc-20160816; b=I98hQWppHnfRh2cLIZv7wu603jEyZU0QDeRxSDdaripAPb293/GG6HX7KOemjs+UsF dbfUI4ixEji/FyUBuACbu5ZuYnMI600p/iMYDtCj6jTjlwMTdlQv1gIlb+10BiM9M58l CQxwQmjhyNJIVm/bauWIzGiTrmb3mxNm8uMWULSx8BqJ/kJ3/JVKtUonPpyI6LRBYAAJ jDDeUwzyycuIn2JG7bEoEjjZVsN0tPlSSgzIetXD68Mlikz/qhAMHbQFx1FD4Nf+7/Qq 47K/MtoOBhkl3BKJ3RvFOXgaw7ZlI6Ws8it0CGnG60SWuMTqDt7jrKt7vOpEnpnZx0iN HX4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=aQQRz+NmFEm03kuNeuGRJjZbWTjR2o0fJKWyF2u/Tsc=; b=z8+4tgtGmF/yuiKXb50H/CakWOKu9LuD4X3eYFgTE0K+dWADpGzqkT6G+xUX2LBT/a G8l5ew6mokM8l8eADbUFHhdUeYegurDgJ2Om8ASKR4OxgwukvLvvvW5Ws4X1dK6GYUt0 l4CDoMhpMd7XtZYbTFuFmGbE5yhb651sb42iXRP/9YvJgW1s9dTxuM5aWFNdarWe4R5v L/yOVATZpHCMp1MEBRQrLjjU9vdWcrU1ydxw980Lu+hNPZoZY1GzHNVT6uLsdv/ZhzbE 8jLhT33cv7pdu2YtUbUfvm5QJqhgfTqEL/DNrUMBhZn6XChqz/B0uRfzfaZL0Hcs6IlO M3MQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v29si632021eda.533.2020.04.22.23.26.31; Wed, 22 Apr 2020 23:26:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726730AbgDWGYH (ORCPT + 99 others); Thu, 23 Apr 2020 02:24:07 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:54211 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725562AbgDWGYH (ORCPT ); Thu, 23 Apr 2020 02:24:07 -0400 Received: from 61-220-137-37.hinet-ip.hinet.net ([61.220.137.37] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jRVHG-0000u2-Ic; Thu, 23 Apr 2020 06:24:03 +0000 From: Kai-Heng Feng To: bskeggs@redhat.com Cc: Kai-Heng Feng , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org (open list:DRM DRIVER FOR NVIDIA GEFORCE/QUADRO GPUS), nouveau@lists.freedesktop.org (open list:DRM DRIVER FOR NVIDIA GEFORCE/QUADRO GPUS), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 1/1] drm/nouveau: Use generic helper to check _PR3 presence Date: Thu, 23 Apr 2020 14:23:58 +0800 Message-Id: <20200423062358.1810-1-kai.heng.feng@canonical.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Replace nouveau_pr3_present() in favor of a more generic one, pci_pr3_present(). Also the presence of upstream bridge _PR3 doesn't need to go hand in hand with device's _DSM, so check _PR3 before _DSM. Signed-off-by: Kai-Heng Feng --- drivers/gpu/drm/nouveau/nouveau_acpi.c | 44 ++++++-------------------- 1 file changed, 10 insertions(+), 34 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_acpi.c b/drivers/gpu/drm/nouveau/nouveau_acpi.c index fe3a10255c36..b84dff1b0f28 100644 --- a/drivers/gpu/drm/nouveau/nouveau_acpi.c +++ b/drivers/gpu/drm/nouveau/nouveau_acpi.c @@ -212,37 +212,6 @@ static const struct vga_switcheroo_handler nouveau_dsm_handler = { .get_client_id = nouveau_dsm_get_client_id, }; -/* - * Firmware supporting Windows 8 or later do not use _DSM to put the device into - * D3cold, they instead rely on disabling power resources on the parent. - */ -static bool nouveau_pr3_present(struct pci_dev *pdev) -{ - struct pci_dev *parent_pdev = pci_upstream_bridge(pdev); - struct acpi_device *parent_adev; - - if (!parent_pdev) - return false; - - if (!parent_pdev->bridge_d3) { - /* - * Parent PCI bridge is currently not power managed. - * Since userspace can change these afterwards to be on - * the safe side we stick with _DSM and prevent usage of - * _PR3 from the bridge. - */ - pci_d3cold_disable(pdev); - return false; - } - - parent_adev = ACPI_COMPANION(&parent_pdev->dev); - if (!parent_adev) - return false; - - return parent_adev->power.flags.power_resources && - acpi_has_method(parent_adev->handle, "_PR3"); -} - static void nouveau_dsm_pci_probe(struct pci_dev *pdev, acpi_handle *dhandle_out, bool *has_mux, bool *has_opt, bool *has_opt_flags, bool *has_pr3) @@ -250,6 +219,16 @@ static void nouveau_dsm_pci_probe(struct pci_dev *pdev, acpi_handle *dhandle_out acpi_handle dhandle; bool supports_mux; int optimus_funcs; + struct pci_dev *parent_pdev; + + *has_pr3 = false; + parent_pdev = pci_upstream_bridge(pdev); + if (parent_pdev) { + if (parent_pdev->bridge_d3) + *has_pr3 = pci_pr3_present(parent_pdev); + else + pci_d3cold_disable(pdev); + } dhandle = ACPI_HANDLE(&pdev->dev); if (!dhandle) @@ -270,7 +249,6 @@ static void nouveau_dsm_pci_probe(struct pci_dev *pdev, acpi_handle *dhandle_out *has_mux = supports_mux; *has_opt = !!optimus_funcs; *has_opt_flags = optimus_funcs & (1 << NOUVEAU_DSM_OPTIMUS_FLAGS); - *has_pr3 = false; if (optimus_funcs) { uint32_t result; @@ -280,8 +258,6 @@ static void nouveau_dsm_pci_probe(struct pci_dev *pdev, acpi_handle *dhandle_out (result & OPTIMUS_ENABLED) ? "enabled" : "disabled", (result & OPTIMUS_DYNAMIC_PWR_CAP) ? "dynamic power, " : "", (result & OPTIMUS_HDA_CODEC_MASK) ? "hda bios codec supported" : ""); - - *has_pr3 = nouveau_pr3_present(pdev); } } -- 2.17.1