From patchwork Thu May 29 11:16:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Badal Nilawar X-Patchwork-Id: 893132 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1D2DD28E580; Thu, 29 May 2025 11:14:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748517291; cv=none; b=B161wv/l19l8K5w665XyOrjym9VRH3uKybllmFzesua/jUsYmCnhZXQPtmPIaChir8bRAnFRpSdqbDBVB2R8WneR7z+NWt5SblSX8DOXi8I9MCBNWL/C8xlfmtYoWF6QKToIwbdahVqQltmEhbW3ZGsVeVZQ7bw2xTLIhCdMTn4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748517291; c=relaxed/simple; bh=63xE3b4gppfJTAf4t0apxS/FsrmUAxahH2v1ExrCUfM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sfq3KyTnbU5VUyNRd9omd/B222DEhaJg/PLTUWAHVNZU0FSMhYz4zgUJv6Zut32/4MCCZ73+NpIRuV3ue+HpKHKMuapWrH/KduENyOKUR7SpXCpNQ/6ua1nx/ZtW2T0NXBwsibmqWUZLhri18d36ZgzpvE/pWaRIVk1pSHPDD80= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=YGdeVD7F; arc=none smtp.client-ip=192.198.163.8 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="YGdeVD7F" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1748517289; x=1780053289; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=63xE3b4gppfJTAf4t0apxS/FsrmUAxahH2v1ExrCUfM=; b=YGdeVD7F98/cz7kqocaCBwlYwxr24DbSXVSxzNZsFENokdMAPgImsiZp FJhMbU13WgHeBwtY8yVl0AnaPaPJnw/r3O+sTD5R7r4UuBkE6g1M4xPmj OA5U/d71Vkdk0cEADj70u/sKFUT9mHafJTYMK+WIODfYUpByrpDyUixgh qcSmV8jCcGpF8TQ3ZLSHukYS6OKG9lBC82j1xJ30H+IG1pj9dfJfx7BX9 SjQnvMOLp/x9grkYM8r10badeBMbENd+tvTzUGPH/M5RLm7wrellbe7/J Ow/IdYSqxOJ8Y/2CT7K9xx5iqj1PwGe3R3cQOOE/D3rqKnqPNa8MVEUHV g==; X-CSE-ConnectionGUID: f1+oz5qOSVmmv+39HR1jww== X-CSE-MsgGUID: HNMJ6UYCT4Gtr3W1l4GpeA== X-IronPort-AV: E=McAfee;i="6700,10204,11447"; a="68123095" X-IronPort-AV: E=Sophos;i="6.15,192,1739865600"; d="scan'208";a="68123095" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 May 2025 04:14:49 -0700 X-CSE-ConnectionGUID: K2ss1kdaQKyIqXaJ3DrRQQ== X-CSE-MsgGUID: Hh5gyQ2xSnGuQS4VGS/f9A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,192,1739865600"; d="scan'208";a="143510380" Received: from unknown (HELO bnilawar-desk2.iind.intel.com) ([10.190.239.41]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 May 2025 04:14:45 -0700 From: Badal Nilawar To: intel-xe@lists.freedesktop.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org Cc: anshuman.gupta@intel.com, rafael@kernel.org, lenb@kernel.org, bhelgaas@google.com, ilpo.jarvinen@linux.intel.com, lucas.demarchi@intel.com, rodrigo.vivi@intel.com, varun.gupta@intel.com, ville.syrjala@linux.intel.com, uma.shankar@intel.com Subject: [PATCH v4 01/11] PCI/ACPI: Add D3cold Aux Power Limit_DSM method Date: Thu, 29 May 2025 16:46:44 +0530 Message-Id: <20250529111654.3140766-2-badal.nilawar@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250529111654.3140766-1-badal.nilawar@intel.com> References: <20250529111654.3140766-1-badal.nilawar@intel.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Anshuman Gupta Implement _DSM method 0Ah according to PCI firmware specifications, section 4.6.10 Rev 3.3., to request auxilary power needed for the device when in D3Cold. Note that this implementation assumes only a single device below the Downstream Port will request for Aux Power Limit under a given Root Port because it does not track and aggregate requests from all child devices below the Downstream Port as required by Section 4.6.10 Rev 3.3. One possible mitigation would be only allowing only first PCIe Non-Bridge Endpoint Function 0 driver to call_DSM method 0Ah. Signed-off-by: Varun Gupta Signed-off-by: Badal Nilawar Signed-off-by: Anshuman Gupta --- V2(Bjorn/Rafael): - Call acpi_dsm_check() to find method 0Ah supported - Return retry interval to caller V3(Kuppuswamy) - Add NULL check for retry interval --- drivers/pci/pci-acpi.c | 87 ++++++++++++++++++++++++++++++++++++++++ include/linux/pci-acpi.h | 8 ++++ 2 files changed, 95 insertions(+) diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c index af370628e583..87f30910a5f1 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c @@ -1421,6 +1421,93 @@ static void pci_acpi_optimize_delay(struct pci_dev *pdev, ACPI_FREE(obj); } +/** + * pci_acpi_request_d3cold_aux_power - Request aux power while device is in D3Cold + * @dev: PCI device instance + * @requested_power: Requested auxiliary power in milliwatts + * @retry_interval: Retry interval returned by platform to retry auxiliary + * power request + * + * This function sends a request to the host BIOS via root port ACPI _DSM Function 0Ah + * for the auxiliary power needed by the PCI device when it is in D3Cold. + * It checks and evaluates the _DSM (Device Specific Method) to request the auxiliary + * power and handles the response accordingly. + * + * This function shall be only called by 1st non-bridge Endpoint driver + * on Function 0. For a Multi-Function Device, the driver for Function 0 is + * required to report an aggregate power requirement covering all + * functions contained within the device. + * + * Return: Returns 0 on success and errno on failure. + */ +int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power, + u32 *retry_interval) +{ + union acpi_object in_obj = { + .integer.type = ACPI_TYPE_INTEGER, + .integer.value = requested_power, + }; + + union acpi_object *out_obj; + acpi_handle handle; + int result, ret = -EINVAL; + + if (!dev || !retry_interval) + return -EINVAL; + + handle = ACPI_HANDLE(&dev->dev); + if (!handle) + return -EINVAL; + + if (!acpi_check_dsm(handle, &pci_acpi_dsm_guid, 4, 1 << DSM_PCI_D3COLD_AUX_POWER_LIMIT)) { + pci_dbg(dev, "ACPI _DSM 0%Xh not supported\n", DSM_PCI_D3COLD_AUX_POWER_LIMIT); + return -ENODEV; + } + + out_obj = acpi_evaluate_dsm_typed(handle, &pci_acpi_dsm_guid, 4, + DSM_PCI_D3COLD_AUX_POWER_LIMIT, + &in_obj, ACPI_TYPE_INTEGER); + if (!out_obj) + return -EINVAL; + + result = out_obj->integer.value; + if (retry_interval) + *retry_interval = 0; + + switch (result) { + case 0x0: + pci_dbg(dev, "D3cold Aux Power %u mW request denied\n", + requested_power); + break; + case 0x1: + pci_info(dev, "D3cold Aux Power request granted: %u mW\n", + requested_power); + ret = 0; + break; + case 0x2: + pci_info(dev, "D3cold Aux Power: Main power won't be removed\n"); + ret = -EBUSY; + break; + default: + if (result >= 0x11 && result <= 0x1F) { + if (retry_interval) { + *retry_interval = result & 0xF; + pci_warn(dev, "D3cold Aux Power request needs retry interval: %u seconds\n", + *retry_interval); + ret = -EAGAIN; + } + } else { + pci_err(dev, "D3cold Aux Power: Reserved or unsupported response: 0x%x\n", + result); + } + break; + } + + ACPI_FREE(out_obj); + return ret; +} +EXPORT_SYMBOL_GPL(pci_acpi_request_d3cold_aux_power); + static void pci_acpi_set_external_facing(struct pci_dev *dev) { u8 val; diff --git a/include/linux/pci-acpi.h b/include/linux/pci-acpi.h index 078225b514d4..6079306ad754 100644 --- a/include/linux/pci-acpi.h +++ b/include/linux/pci-acpi.h @@ -121,6 +121,7 @@ extern const guid_t pci_acpi_dsm_guid; #define DSM_PCI_DEVICE_NAME 0x07 #define DSM_PCI_POWER_ON_RESET_DELAY 0x08 #define DSM_PCI_DEVICE_READINESS_DURATIONS 0x09 +#define DSM_PCI_D3COLD_AUX_POWER_LIMIT 0x0A #ifdef CONFIG_PCIE_EDR void pci_acpi_add_edr_notifier(struct pci_dev *pdev); @@ -132,10 +133,17 @@ static inline void pci_acpi_remove_edr_notifier(struct pci_dev *pdev) { } int pci_acpi_set_companion_lookup_hook(struct acpi_device *(*func)(struct pci_dev *)); void pci_acpi_clear_companion_lookup_hook(void); +int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power, + u32 *retry_interval); #else /* CONFIG_ACPI */ static inline void acpi_pci_add_bus(struct pci_bus *bus) { } static inline void acpi_pci_remove_bus(struct pci_bus *bus) { } +static inline int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power, + u32 *retry_interval) +{ + return -EOPNOTSUPP; +} #endif /* CONFIG_ACPI */ #endif /* _PCI_ACPI_H_ */ From patchwork Thu May 29 11:16:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Badal Nilawar X-Patchwork-Id: 893131 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7073628E573; Thu, 29 May 2025 11:14:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748517298; cv=none; b=JGripuSm6+uhnK3Nb00R1gE7BHIo5bAEJi0zTTY97nYr4WlGMLuykuJtIHP74m0PjRkGj04Xm3EoLRuuvEOrv7o/U16B94n7fsCV37hEUUZuowvYeWkVUn0kUfnnpTgizramF5O8I5wUwdIivdE+51sY/w13tzZcu1/fXz4GHHk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748517298; c=relaxed/simple; bh=ekowM/ryMYQEdbGCtks8zg81DPHnG/+YlLbeuHfh8WA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Hm41SaE0SxO7jJg1wmxGK2cLxup/y+EjqotO8HJ5ifc8S+17zw2BWMAm4mwtOqojAONsU/Ueu/dct0y2RPbBiHwAskmbBqhrFe/evf3K8owiGD4rH7T8RfD8NrAqUmnvnxBWhrdSdR+uM/1BRU7TG4jG7rwVdvtj244Ib1qBq5I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=kJ6oiy5O; arc=none smtp.client-ip=192.198.163.8 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="kJ6oiy5O" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1748517296; x=1780053296; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ekowM/ryMYQEdbGCtks8zg81DPHnG/+YlLbeuHfh8WA=; b=kJ6oiy5OzdHQQpskCczEyhBjMIm41VVJFjo5q96nEbotFgcgP74c5dv0 3K4nGIxBdHVO8iizsRUhTF0KaaCpQlRDRGFSjKc0YtyvUOI/pPF5Kca9c 94mfHkEMc7ctlALRKo4aE2hp2t9RwjOkZSvQeqFOnp7v8B24ohmEs0NIa 6OdVFGB2Nevi5SsfbhjDVgOP3NtXZwzVh7t3/pV8Fy8tnbFsa+92Td+3J PlEHNp8SF8PDFntJTml4+sZqegwkqGPXjaUNq0/LLrddREltv/942qfJI 3Ke+jW3FnAxuJo5OaSLrgJ5JVSpXXrY73t8t2IbSwVBlsuZ/xX8Jtdj97 Q==; X-CSE-ConnectionGUID: vHdet8MxQ4CWYYdcSCCP3g== X-CSE-MsgGUID: hioMDZP6Rai/t51KtB+LXQ== X-IronPort-AV: E=McAfee;i="6700,10204,11447"; a="68123118" X-IronPort-AV: E=Sophos;i="6.15,192,1739865600"; d="scan'208";a="68123118" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 May 2025 04:14:56 -0700 X-CSE-ConnectionGUID: Z/vn46dATBmKXVHPxzLfzw== X-CSE-MsgGUID: uxUc5E8dRkW9Pn7cCVhVag== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,192,1739865600"; d="scan'208";a="143510405" Received: from unknown (HELO bnilawar-desk2.iind.intel.com) ([10.190.239.41]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 May 2025 04:14:53 -0700 From: Badal Nilawar To: intel-xe@lists.freedesktop.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org Cc: anshuman.gupta@intel.com, rafael@kernel.org, lenb@kernel.org, bhelgaas@google.com, ilpo.jarvinen@linux.intel.com, lucas.demarchi@intel.com, rodrigo.vivi@intel.com, varun.gupta@intel.com, ville.syrjala@linux.intel.com, uma.shankar@intel.com Subject: [PATCH v4 03/11] PCI/ACPI: Add PERST# Assertion Delay _DSM method Date: Thu, 29 May 2025 16:46:46 +0530 Message-Id: <20250529111654.3140766-4-badal.nilawar@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250529111654.3140766-1-badal.nilawar@intel.com> References: <20250529111654.3140766-1-badal.nilawar@intel.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Anshuman Gupta Implement _DSM Method 0Bh as per PCI firmware specs section 4.6.11 Rev 3.3. Signed-off-by: Anshuman Gupta Signed-off-by: Badal Nilawar --- drivers/pci/pci-acpi.c | 57 ++++++++++++++++++++++++++++++++++++++++ include/linux/pci-acpi.h | 8 +++++- 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c index d33efba4ca94..88044491feaa 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c @@ -1531,6 +1531,63 @@ int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power, } EXPORT_SYMBOL_GPL(pci_acpi_request_d3cold_aux_power); +/** + * pci_acpi_add_perst_assertion_delay - Request PERST# delay via ACPI DSM + * @dev: PCI device instance + * @delay_us: Requested delay_us + * + * This function sends a request to the host BIOS via ACPI _DSM to grant the + * required PERST# delay for the specified PCI device. It evaluates the _DSM + * to request the PERST# delay and handles the response accordingly. + * + * Return: returns 0 on success and errno on failure. + */ +int pci_acpi_add_perst_assertion_delay(struct pci_dev *dev, u32 delay_us) +{ + union acpi_object in_obj = { + .integer.type = ACPI_TYPE_INTEGER, + .integer.value = delay_us, + }; + + union acpi_object *out_obj; + acpi_handle handle; + int result, ret = -EINVAL; + + if (!dev) + return -EINVAL; + + handle = ACPI_HANDLE(&dev->dev); + if (!handle) + return -EINVAL; + + if (!acpi_check_dsm(handle, &pci_acpi_dsm_guid, 4, 1 << DSM_PCI_PERST_ASSERTION_DELAY)) { + pci_dbg(dev, "ACPI _DSM 0%Xh not supported\n", DSM_PCI_PERST_ASSERTION_DELAY); + return -ENODEV; + } + + out_obj = acpi_evaluate_dsm_typed(handle, &pci_acpi_dsm_guid, 4, + DSM_PCI_PERST_ASSERTION_DELAY, + &in_obj, ACPI_TYPE_INTEGER); + if (!out_obj) + return -EINVAL; + + result = out_obj->integer.value; + + if (result == delay_us) { + pci_info(dev, "PERST# Assertion Delay set to %u microseconds\n", delay_us); + ret = 0; + } else if (result == 0) { + pci_warn(dev, "PERST# Assertion Delay request failed, no previous valid request\n"); + } else { + pci_warn(dev, "PERST# Assertion Delay request failed, Previous valid delay: %u microseconds\n", + result); + } + + ACPI_FREE(out_obj); + return ret; +} +EXPORT_SYMBOL_GPL(pci_acpi_add_perst_assertion_delay); + static void pci_acpi_set_external_facing(struct pci_dev *dev) { u8 val; diff --git a/include/linux/pci-acpi.h b/include/linux/pci-acpi.h index 6079306ad754..e53d4893cf56 100644 --- a/include/linux/pci-acpi.h +++ b/include/linux/pci-acpi.h @@ -122,6 +122,7 @@ extern const guid_t pci_acpi_dsm_guid; #define DSM_PCI_POWER_ON_RESET_DELAY 0x08 #define DSM_PCI_DEVICE_READINESS_DURATIONS 0x09 #define DSM_PCI_D3COLD_AUX_POWER_LIMIT 0x0A +#define DSM_PCI_PERST_ASSERTION_DELAY 0x0B #ifdef CONFIG_PCIE_EDR void pci_acpi_add_edr_notifier(struct pci_dev *pdev); @@ -135,7 +136,7 @@ int pci_acpi_set_companion_lookup_hook(struct acpi_device *(*func)(struct pci_de void pci_acpi_clear_companion_lookup_hook(void); int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power, u32 *retry_interval); - +int pci_acpi_add_perst_assertion_delay(struct pci_dev *dev, u32 delay_us); #else /* CONFIG_ACPI */ static inline void acpi_pci_add_bus(struct pci_bus *bus) { } static inline void acpi_pci_remove_bus(struct pci_bus *bus) { } @@ -144,6 +145,11 @@ static inline int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 req { return -EOPNOTSUPP; } + +static inline int pci_acpi_add_perst_assertion_delay(struct pci_dev *dev, u32 delay_us) +{ + return -EOPNOTSUPP; +} #endif /* CONFIG_ACPI */ #endif /* _PCI_ACPI_H_ */ From patchwork Thu May 29 11:16:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Badal Nilawar X-Patchwork-Id: 893130 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E306D28E607; Thu, 29 May 2025 11:15:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748517305; cv=none; b=H6CMTjMLJBKD+5os6DQtIyBmU9PG1hgC+E7PNkPK6x7YTNr0YrcHRjmNGexTkyvphxKaF0cUexqhJGoK7NK35Ogy/EZi+9x4GAjhkfXXZdX733d/OKb1/dQ6Mqh34YZ/Z07TmKUd2tYcHrr1tFURMTVq3zeI4VaTmxp2cRnBCiE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748517305; c=relaxed/simple; bh=lxHKZKVOenroNxh0FcZyRwd8gvSEvY446e/mnHo3N/0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gyjRoNir0SlwKyqqiWAa1iRWH0tQPm33X1SQ5vcfM+QCsZK9yZEXPtDkrirF5TCdogLS5AOgllwDa7ZANPD5W8pAZOZ4k59wmfVEpnljY9B7rNkLHeKlfcLkoHYJI3gvKJsvNqnvZHdbwVuEIHkbnEZMgxuFahkcZvCJzbQEeP4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=W02c2k0L; arc=none smtp.client-ip=192.198.163.8 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="W02c2k0L" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1748517304; x=1780053304; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lxHKZKVOenroNxh0FcZyRwd8gvSEvY446e/mnHo3N/0=; b=W02c2k0LL7VCZlbacrNMX4r99KUOUPnc6VNue2uZrolV5Ft4c3hM5P81 KFKmPt93RLaC+vVwWKgjGhyrOP2iO2CcB4MlpTwdP4Vn7BAyGpraRK70h DaQFlaMCyiYfoSDSJWktezG9r5jr9gtyshjX57oKkiTJOEhdozJNYGFo/ DB20CgSQIDRolc3PzGBBHe44aV5D1vhg0Ih68YPKcn7PDMoSp5yvbwuIZ yFo6MJzyiDCO4eYc80pPjN4zaxYdxVBOTufiYBBeZNGP2GyyoElsTQ1YB lzY8ciZMCJifoWbyYAePFK025f9S99mTQbLB2sTD9U3LGj7Sk596tIX35 w==; X-CSE-ConnectionGUID: vRJMbFJfQ0euMJ7JE+UvuA== X-CSE-MsgGUID: MP/NVeHnRt+sO8vFFilfDw== X-IronPort-AV: E=McAfee;i="6700,10204,11447"; a="68123140" X-IronPort-AV: E=Sophos;i="6.15,192,1739865600"; d="scan'208";a="68123140" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 May 2025 04:15:03 -0700 X-CSE-ConnectionGUID: YRErPp/vSEmm1GnbEp/dmw== X-CSE-MsgGUID: DUd5Nw4wTnyGuamw08ljgA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,192,1739865600"; d="scan'208";a="143510464" Received: from unknown (HELO bnilawar-desk2.iind.intel.com) ([10.190.239.41]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 May 2025 04:15:00 -0700 From: Badal Nilawar To: intel-xe@lists.freedesktop.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org Cc: anshuman.gupta@intel.com, rafael@kernel.org, lenb@kernel.org, bhelgaas@google.com, ilpo.jarvinen@linux.intel.com, lucas.demarchi@intel.com, rodrigo.vivi@intel.com, varun.gupta@intel.com, ville.syrjala@linux.intel.com, uma.shankar@intel.com Subject: [PATCH v4 05/11] drm/xe/vrsr: Detect VRSR Capability Date: Thu, 29 May 2025 16:46:48 +0530 Message-Id: <20250529111654.3140766-6-badal.nilawar@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250529111654.3140766-1-badal.nilawar@intel.com> References: <20250529111654.3140766-1-badal.nilawar@intel.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Anshuman Gupta Detect VRAM Self Refresh(vrsr) Capability. Reviewed-by: Rodrigo Vivi Signed-off-by: Anshuman Gupta --- drivers/gpu/drm/xe/regs/xe_regs.h | 3 +++ drivers/gpu/drm/xe/xe_device_types.h | 4 ++++ drivers/gpu/drm/xe/xe_pm.c | 26 ++++++++++++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/drivers/gpu/drm/xe/regs/xe_regs.h b/drivers/gpu/drm/xe/regs/xe_regs.h index 3abb17d2ca33..4db486fb310a 100644 --- a/drivers/gpu/drm/xe/regs/xe_regs.h +++ b/drivers/gpu/drm/xe/regs/xe_regs.h @@ -53,6 +53,9 @@ #define MTL_MPE_FREQUENCY XE_REG(0x13802c) #define MTL_RPE_MASK REG_GENMASK(8, 0) +#define VRAM_SR_CAPABILITY XE_REG(0x138144) +#define VRAM_SR_SUPPORTED REG_BIT(0) + #define VF_CAP_REG XE_REG(0x1901f8, XE_REG_OPTION_VF) #define VF_CAP REG_BIT(0) diff --git a/drivers/gpu/drm/xe/xe_device_types.h b/drivers/gpu/drm/xe/xe_device_types.h index e2749ed2a61f..3a15b3a252fd 100644 --- a/drivers/gpu/drm/xe/xe_device_types.h +++ b/drivers/gpu/drm/xe/xe_device_types.h @@ -512,6 +512,9 @@ struct xe_device { /** @d3cold.allowed: Indicates if d3cold is a valid device state */ bool allowed; + /** @d3cold.vrsr_capable: Indicates if d3cold VRAM Self Refresh is supported */ + bool vrsr_capable; + /** * @d3cold.vram_threshold: * @@ -522,6 +525,7 @@ struct xe_device { * Default threshold value is 300mb. */ u32 vram_threshold; + /** @d3cold.lock: protect vram_threshold */ struct mutex lock; } d3cold; diff --git a/drivers/gpu/drm/xe/xe_pm.c b/drivers/gpu/drm/xe/xe_pm.c index 693866def183..c9395e62d21d 100644 --- a/drivers/gpu/drm/xe/xe_pm.c +++ b/drivers/gpu/drm/xe/xe_pm.c @@ -13,13 +13,16 @@ #include #include "display/xe_display.h" +#include "regs/xe_regs.h" #include "xe_bo.h" #include "xe_bo_evict.h" #include "xe_device.h" +#include "xe_force_wake.h" #include "xe_ggtt.h" #include "xe_gt.h" #include "xe_guc.h" #include "xe_irq.h" +#include "xe_mmio.h" #include "xe_pcode.h" #include "xe_pxp.h" #include "xe_trace.h" @@ -235,6 +238,28 @@ static bool xe_pm_pci_d3cold_capable(struct xe_device *xe) return true; } +static bool xe_pm_vrsr_capable(struct xe_device *xe) +{ + struct xe_mmio *mmio = xe_root_tile_mmio(xe); + unsigned int fw_ref; + struct xe_gt *gt; + u32 val; + + gt = xe_root_mmio_gt(xe); + + if (!xe->info.probe_display) + return false; + + fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL); + if (!fw_ref) + return false; + + val = xe_mmio_read32(mmio, VRAM_SR_CAPABILITY); + xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL); + + return val & VRAM_SR_SUPPORTED; +} + static void xe_pm_runtime_init(struct xe_device *xe) { struct device *dev = xe->drm.dev; @@ -349,6 +374,7 @@ int xe_pm_init(struct xe_device *xe) err = xe_pm_set_vram_threshold(xe, vram_threshold); if (err) goto err_unregister; + xe->d3cold.vrsr_capable = xe_pm_vrsr_capable(xe); } xe_pm_runtime_init(xe); From patchwork Thu May 29 11:16:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Badal Nilawar X-Patchwork-Id: 893129 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 24A5A21882B; Thu, 29 May 2025 11:15:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748517312; cv=none; b=VeAU5SGtq1+Gx6YAIeda1DEOHbgy/aJ/XlVp8hIyLNAq0ddklWDpydAE2F+QDsb8VofOCw2v3LoZn5SvuZvy1tA63HeNI7eciUd0dvFMrYjUwf7XcdQu6ICnWzdDcmBFbzfBfarUPEj7OzCK+49AkdkE3XhdLwXkc4FVQ6FUiKM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748517312; c=relaxed/simple; bh=gzhdE5y3lhUr2rWxOg/vRRvTqpZk42Yf+2TMKejj6qg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LglKRo+Wbf2jPb2McxtKiJqS1zL1MUelL16cKHN5cWIei1gyRdPChTSzIri2XveZ0AnUgUJd5Do7Bw16NyfMzXK/RAmHEC4IxE6PS5R1dlYvtronbt4BgpXlez2ebf+0Hx6wA5W56dpT9GK6KogsrKGc0tyb0XWeYrcpuZbTdnE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Eo+oFKu/; arc=none smtp.client-ip=192.198.163.8 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Eo+oFKu/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1748517311; x=1780053311; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gzhdE5y3lhUr2rWxOg/vRRvTqpZk42Yf+2TMKejj6qg=; b=Eo+oFKu/Wu9qW9VfLQFJ3rUS/Wt8YELrSCEURI4bmjMZ7cWjmfXbRYq7 CEGOEjxoRo9tQdb75SwBrXsRKZJkjZEXOm98TN1rOGkG3+9jPk+dO5WNv dGOrYPAUN/DsfrMhWGOgNhgvgOT53LPM7HhFfi5ZPPuz7cH6YogevCaQj feTWkFtjJE4hZwJpuFpWDhQ+67+rNB3PkLMPEuOJjUBhvWKB5ZW22jUM1 LHg+aRarhaRVngFDnOgivoSHRqaGbFGR9tmvUh14Zl4pc+EY9E3tGijcp 0ts2s0gxitb2b2LiXndDFQ9UMj9qkkJxrFJ+zOL69i6KlBtgESinaKEmh Q==; X-CSE-ConnectionGUID: OAPb7NHaSQaHkazifsR/7g== X-CSE-MsgGUID: 7LBc4wVMShS4MfgAgNLD2g== X-IronPort-AV: E=McAfee;i="6700,10204,11447"; a="68123162" X-IronPort-AV: E=Sophos;i="6.15,192,1739865600"; d="scan'208";a="68123162" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 May 2025 04:15:11 -0700 X-CSE-ConnectionGUID: xgmMoqQLSIueKhbol7T1Qg== X-CSE-MsgGUID: BMLFaOhGRVCICKv0tDuV0g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,192,1739865600"; d="scan'208";a="143510526" Received: from unknown (HELO bnilawar-desk2.iind.intel.com) ([10.190.239.41]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 May 2025 04:15:07 -0700 From: Badal Nilawar To: intel-xe@lists.freedesktop.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org Cc: anshuman.gupta@intel.com, rafael@kernel.org, lenb@kernel.org, bhelgaas@google.com, ilpo.jarvinen@linux.intel.com, lucas.demarchi@intel.com, rodrigo.vivi@intel.com, varun.gupta@intel.com, ville.syrjala@linux.intel.com, uma.shankar@intel.com Subject: [PATCH v4 07/11] drm/xe/vrsr: Enable VRSR on default VGA boot device Date: Thu, 29 May 2025 16:46:50 +0530 Message-Id: <20250529111654.3140766-8-badal.nilawar@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250529111654.3140766-1-badal.nilawar@intel.com> References: <20250529111654.3140766-1-badal.nilawar@intel.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The VRSR feature is to enhance the display screen refresh experience when the device exits from the D3Cold state. Therefore, apply the VRSR feature to the default VGA boot device and when a display is connected. Signed-off-by: Badal Nilawar Signed-off-by: Anshuman Gupta --- drivers/gpu/drm/xe/display/xe_display.c | 22 ++++++++++++++++++++++ drivers/gpu/drm/xe/display/xe_display.h | 2 ++ drivers/gpu/drm/xe/xe_pm.c | 5 +++++ 3 files changed, 29 insertions(+) diff --git a/drivers/gpu/drm/xe/display/xe_display.c b/drivers/gpu/drm/xe/display/xe_display.c index 20c3bcd953b7..b3da88b12b35 100644 --- a/drivers/gpu/drm/xe/display/xe_display.c +++ b/drivers/gpu/drm/xe/display/xe_display.c @@ -88,6 +88,28 @@ static void display_destroy(struct drm_device *dev, void *dummy) destroy_workqueue(xe->display.hotplug.dp_wq); } +bool xe_display_connected(struct xe_device *xe) +{ + struct drm_connector *list_connector; + struct drm_connector_list_iter iter; + bool ret = false; + + mutex_lock(&xe->drm.mode_config.mutex); + drm_connector_list_iter_begin(&xe->drm, &iter); + + drm_for_each_connector_iter(list_connector, &iter) { + if (list_connector->status == connector_status_connected) { + ret = true; + break; + } + } + + drm_connector_list_iter_end(&iter); + mutex_unlock(&xe->drm.mode_config.mutex); + + return ret; +} + /** * xe_display_create - create display struct * @xe: XE device instance diff --git a/drivers/gpu/drm/xe/display/xe_display.h b/drivers/gpu/drm/xe/display/xe_display.h index 46e14f8dee28..c79441bccb43 100644 --- a/drivers/gpu/drm/xe/display/xe_display.h +++ b/drivers/gpu/drm/xe/display/xe_display.h @@ -39,6 +39,7 @@ void xe_display_pm_resume(struct xe_device *xe); void xe_display_pm_runtime_suspend(struct xe_device *xe); void xe_display_pm_runtime_suspend_late(struct xe_device *xe); void xe_display_pm_runtime_resume(struct xe_device *xe); +bool xe_display_connected(struct xe_device *xe); #else @@ -71,5 +72,6 @@ static inline void xe_display_pm_runtime_suspend(struct xe_device *xe) {} static inline void xe_display_pm_runtime_suspend_late(struct xe_device *xe) {} static inline void xe_display_pm_runtime_resume(struct xe_device *xe) {} +static inline bool xe_display_connected(struct xe_device *xe) { return false; } #endif /* CONFIG_DRM_XE_DISPLAY */ #endif /* _XE_DISPLAY_H_ */ diff --git a/drivers/gpu/drm/xe/xe_pm.c b/drivers/gpu/drm/xe/xe_pm.c index 278f2eeeaab6..c84b9b3f7371 100644 --- a/drivers/gpu/drm/xe/xe_pm.c +++ b/drivers/gpu/drm/xe/xe_pm.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -310,6 +311,7 @@ static int pci_acpi_aux_power_setup(struct xe_device *xe) static void xe_pm_vrsr_init(struct xe_device *xe) { + struct pci_dev *pdev = to_pci_dev(xe->drm.dev); int ret; /* Check if platform support D3Cold VRSR */ @@ -319,6 +321,9 @@ static void xe_pm_vrsr_init(struct xe_device *xe) if (!xe_pm_vrsr_capable(xe)) return; + if (pdev != vga_default_device() || !xe_display_connected(xe)) + return; + /* * If the VRSR initialization fails, the device will proceed with the regular * D3Cold flow From patchwork Thu May 29 11:16:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Badal Nilawar X-Patchwork-Id: 893128 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D0BAB28E60F; Thu, 29 May 2025 11:15:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748517321; cv=none; b=sIUZVMVPpRD51HDvpeEaxzns3avKH0tbhpXvDOxcsYAYsluVqjWzimcDxdm5vPXbIuzGW+KlLxzQIb0zgJZPYXyoHUG6jyvuXCTB2oR8Z7YbH9eQOYWxsKPRJJmpFH5uf3VkZDKqX4XnNJLL0X/u70GiJe+2fALd4IF4Ly2ARCE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748517321; c=relaxed/simple; bh=zZkQPrOWz9t9zy6CLUbpHFxEOKK2DfWWIF4T94QYUl4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gppcHQSEdhby/x/u8xN4d2MLSDZ9g8vHLM29dz5yNAVpDhQcohNYPwboCvoDEzwjqr15ix05r8cc0FrFJVbR1PPk6FHL9vH5iGJXU2m0/Mh6+hObezkN3mLW2yKQsKe8zXr4MKXpEC1O1wFIzXRFPCdKuMWHdMW8ChQ8YVR1OOc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=ZQE/yuio; arc=none smtp.client-ip=192.198.163.8 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ZQE/yuio" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1748517319; x=1780053319; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zZkQPrOWz9t9zy6CLUbpHFxEOKK2DfWWIF4T94QYUl4=; b=ZQE/yuioHolJ5bGUXVZxUiRPMM6SZeWv8VuKmxH5zyK4vLidOU6rsSpy /LrSmqtT5204AzsAoMtn0BDpo+sUAuhDfBgW5z5V57m8TEIeUp1NpaeyC tDqW9Lp4oWuhUtrHmPkLH0f3+4fx2mBIVnDgKpwjm5SptE0y9ektBUAja w8NBj7pKM5jnaPYOJhSoTapXasxe8xEZ9LAkKDPvpkWcUQLb5jZpZ9Cl0 cYYsjxPUCj5b7GE2UekuamqH1Sd8BckLYF7a6VEReTbttmFrnbV8nkXGV j8JL1mERkOXZqRgsgJE8p/0QhVkt1X2KSXIjxMuLBlD2sFWffr7jqMQqT Q==; X-CSE-ConnectionGUID: ERkYYzCbT4uP7RvvrBWyiQ== X-CSE-MsgGUID: ZsW4iTtwRnuKIXfgL7PgWQ== X-IronPort-AV: E=McAfee;i="6700,10204,11447"; a="68123179" X-IronPort-AV: E=Sophos;i="6.15,192,1739865600"; d="scan'208";a="68123179" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 May 2025 04:15:18 -0700 X-CSE-ConnectionGUID: ov2D+RJ8SvCI1Qxi8lqq1w== X-CSE-MsgGUID: GxBqnopSR/qIQyMSyZz4/Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,192,1739865600"; d="scan'208";a="143510560" Received: from unknown (HELO bnilawar-desk2.iind.intel.com) ([10.190.239.41]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 May 2025 04:15:15 -0700 From: Badal Nilawar To: intel-xe@lists.freedesktop.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org Cc: anshuman.gupta@intel.com, rafael@kernel.org, lenb@kernel.org, bhelgaas@google.com, ilpo.jarvinen@linux.intel.com, lucas.demarchi@intel.com, rodrigo.vivi@intel.com, varun.gupta@intel.com, ville.syrjala@linux.intel.com, uma.shankar@intel.com Subject: [PATCH v4 09/11] drm/xe/pm: D3Cold target state Date: Thu, 29 May 2025 16:46:52 +0530 Message-Id: <20250529111654.3140766-10-badal.nilawar@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250529111654.3140766-1-badal.nilawar@intel.com> References: <20250529111654.3140766-1-badal.nilawar@intel.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Anshuman Gupta Trade-off D3Cold target state based upon current vram usage. If vram usage is greater than vram_d3cold_threshold and GPU is VRSR capable target D3Cold state is D3Cold-VRSR otherwise target state is D3Cold-Off. Signed-off-by: Anshuman Gupta --- drivers/gpu/drm/xe/xe_pm.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/gpu/drm/xe/xe_pm.c b/drivers/gpu/drm/xe/xe_pm.c index b86e95493cb5..1e061bfc3e52 100644 --- a/drivers/gpu/drm/xe/xe_pm.c +++ b/drivers/gpu/drm/xe/xe_pm.c @@ -113,6 +113,14 @@ static void xe_rpm_lockmap_release(const struct xe_device *xe) &xe_pm_runtime_d3cold_map); } +static void xe_pm_suspend_prepare(struct xe_device *xe) +{ + if (pm_suspend_target_state == PM_SUSPEND_TO_IDLE) + xe_pm_d3cold_target_state_toggle(xe); + else + xe->d3cold.target_state = XE_D3COLD_OFF; +} + /** * xe_pm_suspend - Helper for System suspend, i.e. S0->S3 / S0->S2idle * @xe: xe device instance @@ -128,6 +136,8 @@ int xe_pm_suspend(struct xe_device *xe) drm_dbg(&xe->drm, "Suspending device\n"); trace_xe_pm_suspend(xe, __builtin_return_address(0)); + xe_pm_suspend_prepare(xe); + err = xe_pxp_pm_suspend(xe->pxp); if (err) goto err; @@ -948,10 +958,14 @@ void xe_pm_d3cold_target_state_toggle(struct xe_device *xe) if (total_vram_used_mb < xe->d3cold.vram_threshold) xe->d3cold.target_state = XE_D3COLD_OFF; + else if (xe->d3cold.vrsr_capable) + xe->d3cold.target_state = XE_D3COLD_VRSR; else xe->d3cold.target_state = XE_D3HOT; mutex_unlock(&xe->d3cold.lock); + + drm_dbg(&xe->drm, "Xe D3cold target state %d\n", xe->d3cold.target_state); } /** From patchwork Thu May 29 11:16:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Badal Nilawar X-Patchwork-Id: 893127 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 56C3C347B4; Thu, 29 May 2025 11:15:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748517327; cv=none; b=tkvPftsgb0SCGuDMS02DcSGQEKOm9rMY2oXR+5mXZ6S330YM2G25jS1GzQdTgcspZfsx/ZG1oxcLE11ijUScvMM52c2o59f+67mE4h9BGMBfUlNjgLzNzuwi7Xivxj1DWxdLCy7WZdxQAhjS0brLhpi02QZFibwoxyFOu4vB/3s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748517327; c=relaxed/simple; bh=j0RX+hYzyhMgc0XGcBiN0az+uJ5tRmncGyuo6+y7pf0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ptdt1Qb6NY0Hs6M6wU/nHd2t4Kmq9IkZ03jBDZD6nXOcvjk67jWLnu/Ms102/sg7LsPeZlz3KVg/r9/0iTzy47kV3I7epFZFvi70+LuX4tmLnHcGkeq+nh8krS5kCXRwakJouhpCbY5U7SHUz2DDM0CaVpvbzb6z+dRmhCaq5t0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=ezoAk3sX; arc=none smtp.client-ip=192.198.163.8 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ezoAk3sX" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1748517326; x=1780053326; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=j0RX+hYzyhMgc0XGcBiN0az+uJ5tRmncGyuo6+y7pf0=; b=ezoAk3sXAncSVwl3wYM+zkYmI0AaI4GorLrp5PMTRMtvbeYMv6cKF5+I cC2iCGHfDtUmb7/HwpMR3chmOe/HJl8bt6d558W76IN+4wZ/om/HovuyF 3y0udPmqItfy5IS0TwgJb9hRknywcqTyLex2C2LDvBSTvzwMJdDVMn5Q1 7EXZdkkkIIZ2yWZtKTB1qZxoP1FgDTRfXbXaKAuO3CIP4/PIoNJOMQ2bD Y4V+OGlBKMfpQHz3IkI8XPOM9pSJVWOt8n3altGsdcsR0akf6cI7tu8u5 nJwh+/U+ttBrx41CyNaYv5M2PywOOZ6Oh3BVVJYhh9MXRqVUOomimGcfj A==; X-CSE-ConnectionGUID: epbf1rHeRzm0zrx+bBqBFg== X-CSE-MsgGUID: Ab1EtAXJSyqm6Hl46EnxqA== X-IronPort-AV: E=McAfee;i="6700,10204,11447"; a="68123205" X-IronPort-AV: E=Sophos;i="6.15,192,1739865600"; d="scan'208";a="68123205" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 May 2025 04:15:26 -0700 X-CSE-ConnectionGUID: VMCMRwHRSgWM+cr3nZGDXA== X-CSE-MsgGUID: Xeb4XZU9RIyzkw+VwsG9Hg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,192,1739865600"; d="scan'208";a="143510606" Received: from unknown (HELO bnilawar-desk2.iind.intel.com) ([10.190.239.41]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 May 2025 04:15:22 -0700 From: Badal Nilawar To: intel-xe@lists.freedesktop.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org Cc: anshuman.gupta@intel.com, rafael@kernel.org, lenb@kernel.org, bhelgaas@google.com, ilpo.jarvinen@linux.intel.com, lucas.demarchi@intel.com, rodrigo.vivi@intel.com, varun.gupta@intel.com, ville.syrjala@linux.intel.com, uma.shankar@intel.com Subject: [PATCH v4 11/11] drm/xe/vrsr: Introduce a debugfs node named vrsr_capable Date: Thu, 29 May 2025 16:46:54 +0530 Message-Id: <20250529111654.3140766-12-badal.nilawar@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250529111654.3140766-1-badal.nilawar@intel.com> References: <20250529111654.3140766-1-badal.nilawar@intel.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add a debugfs node named vrsr_capable to check if the device supports VRSR. Signed-off-by: Badal Nilawar --- drivers/gpu/drm/xe/xe_debugfs.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/gpu/drm/xe/xe_debugfs.c b/drivers/gpu/drm/xe/xe_debugfs.c index d83cd6ed3fa8..d969a8f6d430 100644 --- a/drivers/gpu/drm/xe/xe_debugfs.c +++ b/drivers/gpu/drm/xe/xe_debugfs.c @@ -226,6 +226,23 @@ static const struct file_operations atomic_svm_timeslice_ms_fops = { .write = atomic_svm_timeslice_ms_set, }; +static ssize_t vrsr_capable_show(struct file *f, char __user *ubuf, + size_t size, loff_t *pos) +{ + struct xe_device *xe = file_inode(f)->i_private; + char buf[32]; + int len = 0; + + len = scnprintf(buf, sizeof(buf), "%s\n", xe->d3cold.vrsr_capable ? "true" : "false"); + + return simple_read_from_buffer(ubuf, size, pos, buf, len); +} + +static const struct file_operations vrsr_capable_fops = { + .owner = THIS_MODULE, + .read = vrsr_capable_show, +}; + void xe_debugfs_register(struct xe_device *xe) { struct ttm_device *bdev = &xe->ttm; @@ -249,6 +266,9 @@ void xe_debugfs_register(struct xe_device *xe) debugfs_create_file("atomic_svm_timeslice_ms", 0600, root, xe, &atomic_svm_timeslice_ms_fops); + debugfs_create_file("vrsr_capable", 0400, root, xe, + &vrsr_capable_fops); + for (mem_type = XE_PL_VRAM0; mem_type <= XE_PL_VRAM1; ++mem_type) { man = ttm_manager_type(bdev, mem_type);