From patchwork Mon Feb 24 16:48:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Gupta X-Patchwork-Id: 867953 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 176592627F2; Mon, 24 Feb 2025 16:50:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740415820; cv=none; b=LXedfTX13CwgM9svghbPJ+vciNeRd9pz/WpWNqjxfF3LjmlFP5zP8aQEMYGRy5Hs3hP9yQ+Rt4JsyaySspKg1LKQMNvnDDMsYA3XOGY//b6eLycn9PcwMK2i3PUVDHRtObyyD2NxrkoZyBwG9rPbeOFleCdLbYQ8VGuRsmJc2t0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740415820; c=relaxed/simple; bh=uy26mGDGVPF9x/+qQmcXIUmlZvjs+RGZJrKYOCea2Hg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=K7wZvmQxkSNSryw9cpVQ/9cN5uhbndBT0Hgsn0D0ZMYxBBIU3ntf2MoOjvwbddG5UL6KhK4nEUUcqgWIA9nusVtToa8mVJGZrUGCQefx9RHHGA3i5hOJgrdJ/LfjUtTkTg9Z/45mlRVwG4iLg2Zu2Ul0+yaGZGhwiWIAfNh0fdQ= 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=DXY+/hvi; arc=none smtp.client-ip=192.198.163.17 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="DXY+/hvi" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1740415819; x=1771951819; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=uy26mGDGVPF9x/+qQmcXIUmlZvjs+RGZJrKYOCea2Hg=; b=DXY+/hvipjgXWFxgjV7Ux/3UyrUt+BPUsABX/5D0mUeOcGJn7OrXgN/y cLRmfFcYPkiDsIjl3SpBByBU2UWx6XAETRvOQ5RcWunrEi+kdq36ooK6i R8FDzLQFA+yXIYLk8KAM6GGHYrqUOwTWa+XF+UCKZ1sG80osLhr/V2BKZ 0LOtyO8LPMGmM6JbixM1iHFiVejSTRQ5X0dM6nM3ZuvsQ60ZvJpYHUZjd EFy/w/XR6ZS7D6T42+LXuRwPuBuTD4fyxCztq7wXbh6D6UhN55POGvFsS ybaFaTA8QoRtasACrrzkYUWH8s2weNf50iTCwzp/oZoc3LcWx13rdVUTK A==; X-CSE-ConnectionGUID: zw4sDPz+QNuZz0etiz/vfg== X-CSE-MsgGUID: o55O/REcTsWIhzDYeUah6w== X-IronPort-AV: E=McAfee;i="6700,10204,11355"; a="41063195" X-IronPort-AV: E=Sophos;i="6.13,312,1732608000"; d="scan'208";a="41063195" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Feb 2025 08:50:19 -0800 X-CSE-ConnectionGUID: fjPxS7m+SZqQUP7vAkl1PQ== X-CSE-MsgGUID: kThcxfqMQteGnAZGendkBQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,312,1732608000"; d="scan'208";a="121032360" Received: from anshuma1-desk.iind.intel.com ([10.190.239.112]) by ORVIESA003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Feb 2025 08:50:16 -0800 From: Anshuman Gupta To: intel-xe@lists.freedesktop.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org Cc: rafael@kernel.org, lenb@kernel.org, bhelgaas@google.com, ilpo.jarvinen@linux.intel.com, lucas.demarchi@intel.com, rodrigo.vivi@intel.com, badal.nilawar@intel.com, kam.nasim@intel.com, Anshuman Gupta Subject: [RFC 2/6] drm/xe/vrsr: Detect vrsr capability Date: Mon, 24 Feb 2025 22:18:45 +0530 Message-Id: <20250224164849.3746751-3-anshuman.gupta@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250224164849.3746751-1-anshuman.gupta@intel.com> References: <20250224164849.3746751-1-anshuman.gupta@intel.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Detect VRAM Self Refresh(vrsr) Capability. 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 | 27 +++++++++++++++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/drivers/gpu/drm/xe/regs/xe_regs.h b/drivers/gpu/drm/xe/regs/xe_regs.h index 6cf282618836..21563e9d958b 100644 --- a/drivers/gpu/drm/xe/regs/xe_regs.h +++ b/drivers/gpu/drm/xe/regs/xe_regs.h @@ -57,6 +57,9 @@ #define MTL_MPE_FREQUENCY XE_REG(0x13802c) #define MTL_RPE_MASK REG_GENMASK(8, 0) +#define VRAM_CAPABILITY XE_REG(0x138144) +#define VRAM_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 4656305dd45a..c2ab2c91c968 100644 --- a/drivers/gpu/drm/xe/xe_device_types.h +++ b/drivers/gpu/drm/xe/xe_device_types.h @@ -490,6 +490,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: * @@ -500,6 +503,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 12200be7b43d..dead236355d8 100644 --- a/drivers/gpu/drm/xe/xe_pm.c +++ b/drivers/gpu/drm/xe/xe_pm.c @@ -17,12 +17,15 @@ #include "xe_bo_evict.h" #include "xe_device.h" #include "xe_device_sysfs.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 "regs/xe_regs.h" #include "xe_trace.h" #include "xe_wa.h" @@ -236,6 +239,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_CAPABILITY); + xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL); + + return val & VRAM_SUPPORTED; +} + static void xe_pm_runtime_init(struct xe_device *xe) { struct device *dev = xe->drm.dev; @@ -303,6 +328,8 @@ int xe_pm_init(struct xe_device *xe) err = xe_pm_set_vram_threshold(xe, DEFAULT_VRAM_THRESHOLD); if (err) return err; + + xe->d3cold.vrsr_capable = xe_pm_vrsr_capable(xe); } xe_pm_runtime_init(xe); From patchwork Mon Feb 24 16:48:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Gupta X-Patchwork-Id: 867952 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 7ABC62627F2; Mon, 24 Feb 2025 16:50:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740415828; cv=none; b=fAKAUYZy/03Alm9bbKuUSIM0CzOTeoSgojTZB1KRYCXIy5+DYgF3kqKrYWt8GiVTzxTbB8Ahxo1Cfaic01DOQc4+J2dpq3kiFiEXn5FQKZEo0DPBtUbc7Lv/+SjSCWgi03/WmYEcm3mej0r7MkGA2eEnpjkaZuWRx6ynPg/GD6M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740415828; c=relaxed/simple; bh=s1755bRkVQkvuVT5nc9PfQbKU5v1eRuaL7KrfAtQIpA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bx3djOumfx8CVnxoC0xEG6T4xUQ0x51l/db6q7G4w14J7Y7LzuenfievvHEdbT/dODbRcIQb34JdS9iPq18x11Su3y9MDYsfV77JtJcba74fPdCRWRmi8dXbGTagR72q7PUpkOWykAKJbtqgRbLvj7jTh4C5OHKljHc1ysHiCe4= 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=fZOQRzKz; arc=none smtp.client-ip=192.198.163.17 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="fZOQRzKz" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1740415826; x=1771951826; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=s1755bRkVQkvuVT5nc9PfQbKU5v1eRuaL7KrfAtQIpA=; b=fZOQRzKzNkngQYMI6v1DD+2uvafMorSqChiCd6g2KZNVBSDs3/mfdf2G avUM94KncVx7xrUH1EiX4MxS/8Ddap5s8EZCjUauzO0ESov39cEcXacw0 1iRpRjHAUrmlox3YeViCsgA4vSmFZWJuX0y3FN2GwMZa5IjGRiy04k9s8 Xy3X6KKFvd/n1djf/WPOTsP7/lewvyaaMk0tMk96Bxdaf41BUW6F2OsUo tEdQ9eE1Vv0gZb10fqULYkNFbJzLkjfPcma24JEY/CAsIpZrQyeknR5qE TAtzzlZWHp89+RMZeZVZUOpyqbPs5y1hs1oX2yJ/s3Yi7TyqEkIhwp+1Z g==; X-CSE-ConnectionGUID: FJIeg5xcTVi8eakmUz0JcA== X-CSE-MsgGUID: O7tJEg1lRm69pacKY0UO5w== X-IronPort-AV: E=McAfee;i="6700,10204,11355"; a="41063204" X-IronPort-AV: E=Sophos;i="6.13,312,1732608000"; d="scan'208";a="41063204" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Feb 2025 08:50:26 -0800 X-CSE-ConnectionGUID: Zmo+KQ9NTXSKvIx70nocsg== X-CSE-MsgGUID: YuB/u+3YT5GO05mVuqcGqA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,312,1732608000"; d="scan'208";a="121032404" Received: from anshuma1-desk.iind.intel.com ([10.190.239.112]) by ORVIESA003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Feb 2025 08:50:23 -0800 From: Anshuman Gupta To: intel-xe@lists.freedesktop.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org Cc: rafael@kernel.org, lenb@kernel.org, bhelgaas@google.com, ilpo.jarvinen@linux.intel.com, lucas.demarchi@intel.com, rodrigo.vivi@intel.com, badal.nilawar@intel.com, kam.nasim@intel.com, Anshuman Gupta Subject: [RFC 4/6] drm/xe/vrsr: Refactor d3cold.allowed to a enum Date: Mon, 24 Feb 2025 22:18:47 +0530 Message-Id: <20250224164849.3746751-5-anshuman.gupta@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250224164849.3746751-1-anshuman.gupta@intel.com> References: <20250224164849.3746751-1-anshuman.gupta@intel.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add xe_d3_state enum to add support for VRAM Self Refresh d3cold state. Signed-off-by: Anshuman Gupta --- drivers/gpu/drm/xe/xe_device_types.h | 5 +++-- drivers/gpu/drm/xe/xe_pm.c | 6 +++--- drivers/gpu/drm/xe/xe_pm.h | 6 ++++++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_device_types.h b/drivers/gpu/drm/xe/xe_device_types.h index da7946b75cd5..937461939ecc 100644 --- a/drivers/gpu/drm/xe/xe_device_types.h +++ b/drivers/gpu/drm/xe/xe_device_types.h @@ -19,6 +19,7 @@ #include "xe_memirq_types.h" #include "xe_oa_types.h" #include "xe_platform_types.h" +#include "xe_pm.h" #include "xe_pmu_types.h" #include "xe_pt_types.h" #include "xe_sriov_types.h" @@ -488,8 +489,8 @@ struct xe_device { /** @d3cold.capable: Indicates if root port is d3cold capable */ bool capable; - /** @d3cold.allowed: Indicates if d3cold is a valid device state */ - bool allowed; + /** @d3cold.allowed: Indicates d3cold target state */ + enum xe_d3_state allowed; /** @d3cold.vrsr_capable: Indicates if d3cold VRAM Self Refresh is supported */ bool vrsr_capable; diff --git a/drivers/gpu/drm/xe/xe_pm.c b/drivers/gpu/drm/xe/xe_pm.c index 32583651988f..81e67b5693dc 100644 --- a/drivers/gpu/drm/xe/xe_pm.c +++ b/drivers/gpu/drm/xe/xe_pm.c @@ -859,7 +859,7 @@ void xe_pm_d3cold_allowed_toggle(struct xe_device *xe) int i; if (!xe->d3cold.capable) { - xe->d3cold.allowed = false; + xe->d3cold.allowed = XE_D3HOT; return; } @@ -874,9 +874,9 @@ void xe_pm_d3cold_allowed_toggle(struct xe_device *xe) mutex_lock(&xe->d3cold.lock); if (total_vram_used_mb < xe->d3cold.vram_threshold) - xe->d3cold.allowed = true; + xe->d3cold.allowed = XE_D3COLD_OFF; else - xe->d3cold.allowed = false; + xe->d3cold.allowed = XE_D3HOT; mutex_unlock(&xe->d3cold.lock); } diff --git a/drivers/gpu/drm/xe/xe_pm.h b/drivers/gpu/drm/xe/xe_pm.h index c9f176912b46..b7b74757ce21 100644 --- a/drivers/gpu/drm/xe/xe_pm.h +++ b/drivers/gpu/drm/xe/xe_pm.h @@ -12,6 +12,12 @@ struct xe_device; +enum xe_d3_state { + XE_D3HOT = 0, + XE_D3COLD_OFF, + XE_D3COLD_VRSR, +}; + int xe_pm_suspend(struct xe_device *xe); int xe_pm_resume(struct xe_device *xe); From patchwork Mon Feb 24 16:48:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Gupta X-Patchwork-Id: 867951 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 F26132627F2; Mon, 24 Feb 2025 16:50:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740415835; cv=none; b=dq4N0tgOnM+vN04IypkhEGJ9OJwzxYsW78UxPxE8kyP3pMWQz0yv39AxxkvigEvsEDoAn77D2gY/ecqdGyOSea+3NvH2b6cuWVdeuM9JFmQApT/GIi7DrIhJ8ITxnL4n+Dj5Cmr8L/+JID3LfpOwT7CZzE1G+siOx/eVvFZFZt0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740415835; c=relaxed/simple; bh=vMWP1X1cnE+Dg2jsB5PyLd3fB7XjQNnO/YdhAylQXkI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Az5yV7Y6zh0KGvXJCwvgNYd8Hs6bm2yOlr8yFnsGJ6msWpCZ0D6mumjhCpLK/Ifbh0Gy6vLumzNwkvsxMwG1572nB39enkbCWRAm/ceYAjm2mO4CRh2+caXknzHfeieQ+rYnF6f12M6UuE3Z8BqRqJSUULIQe2I94ZPBFtPGokA= 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=WW61np/K; arc=none smtp.client-ip=192.198.163.17 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="WW61np/K" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1740415834; x=1771951834; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vMWP1X1cnE+Dg2jsB5PyLd3fB7XjQNnO/YdhAylQXkI=; b=WW61np/K/CpDvCJxgLALmKliNLC9XlDTzcJuho26yUA8ofkrCPgUOea2 dDmqgwQGv8v6nvbcfmFIFAXAc+wSjIPtBg2PhLpbtqSYtghzL9FfaNo6e 8tjFpYyTTtRT7Ropcy6ZvKuQNdxssmR6Xy6NANsK6DMTrSwr36l5cpPTU aHfa/0Xxu2373rtuP7Q6KlxxxVtxnv4zIoEoDU/b+MfK5hFHlFvuVfejG cvZcz/SuHvXICkF4t2F1YMj5VLYYhVDkkNluu6Cm8Ua2bcaZPgWEX7HWN DcOJyS4IMzrx8MNDoJbq8DuYDT1tITlGJLNSZsQC+9t89N9dhToTYYtvh g==; X-CSE-ConnectionGUID: iPLwvbiWSTyb+B6DPdySmQ== X-CSE-MsgGUID: mYeUAt4rTBKnWOTIsYcynw== X-IronPort-AV: E=McAfee;i="6700,10204,11355"; a="41063227" X-IronPort-AV: E=Sophos;i="6.13,312,1732608000"; d="scan'208";a="41063227" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Feb 2025 08:50:34 -0800 X-CSE-ConnectionGUID: CILdZhPZQgaBWolf7fwafg== X-CSE-MsgGUID: YETGrKstSGKRhD+szY1Yyg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,312,1732608000"; d="scan'208";a="121032469" Received: from anshuma1-desk.iind.intel.com ([10.190.239.112]) by ORVIESA003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Feb 2025 08:50:30 -0800 From: Anshuman Gupta To: intel-xe@lists.freedesktop.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org Cc: rafael@kernel.org, lenb@kernel.org, bhelgaas@google.com, ilpo.jarvinen@linux.intel.com, lucas.demarchi@intel.com, rodrigo.vivi@intel.com, badal.nilawar@intel.com, kam.nasim@intel.com, Anshuman Gupta Subject: [RFC 6/6] drm/xe/vrsr: Enable VRSR Date: Mon, 24 Feb 2025 22:18:49 +0530 Message-Id: <20250224164849.3746751-7-anshuman.gupta@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250224164849.3746751-1-anshuman.gupta@intel.com> References: <20250224164849.3746751-1-anshuman.gupta@intel.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Enabling VRSR in runtime suspend and also in System wide suspend. Also fix couple of typo in xe_pm.c. Signed-off-by: Anshuman Gupta Signed-off-by: Badal Nilawar --- drivers/gpu/drm/xe/xe_pci.c | 4 +-- drivers/gpu/drm/xe/xe_pm.c | 49 +++++++++++++++++++++++++++---------- 2 files changed, 38 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_pci.c b/drivers/gpu/drm/xe/xe_pci.c index 70b697fde5b9..55b42b3a10d2 100644 --- a/drivers/gpu/drm/xe/xe_pci.c +++ b/drivers/gpu/drm/xe/xe_pci.c @@ -967,7 +967,7 @@ static int xe_pci_suspend(struct device *dev) /* * Enabling D3Cold is needed for S2Idle/S0ix. - * It is save to allow here since xe_pm_suspend has evicted + * It is safe to allow here since xe_pm_suspend has evicted * the local memory and the direct complete optimization is disabled. */ d3cold_toggle(pdev, D3COLD_ENABLE); @@ -983,7 +983,7 @@ static int xe_pci_resume(struct device *dev) struct pci_dev *pdev = to_pci_dev(dev); int err; - /* Give back the D3Cold decision to the runtime P M*/ + /* Give back the D3Cold decision to the runtime PM */ d3cold_toggle(pdev, D3COLD_DISABLE); err = pci_set_power_state(pdev, PCI_D0); diff --git a/drivers/gpu/drm/xe/xe_pm.c b/drivers/gpu/drm/xe/xe_pm.c index 6d28aedcb062..5c96f8629a87 100644 --- a/drivers/gpu/drm/xe/xe_pm.c +++ b/drivers/gpu/drm/xe/xe_pm.c @@ -232,10 +232,12 @@ int xe_pm_suspend(struct xe_device *xe) xe_display_pm_suspend(xe); - /* FIXME: Super racey... */ - err = xe_bo_evict_all(xe); - if (err) - goto err_pxp; + if (xe->d3cold.allowed == XE_D3COLD_OFF) { + /* FIXME: Super racey... */ + err = xe_bo_evict_all(xe); + if (err) + goto err_pxp; + } for_each_gt(gt, xe, id) { err = xe_gt_suspend(gt); @@ -247,6 +249,12 @@ int xe_pm_suspend(struct xe_device *xe) xe_display_pm_suspend_late(xe); + if (xe->d3cold.allowed == XE_D3COLD_VRSR) { + err = xe_pm_enable_vrsr(xe, true); + if (err) + goto err_display; + } + drm_dbg(&xe->drm, "Device suspended\n"); return 0; @@ -288,9 +296,11 @@ int xe_pm_resume(struct xe_device *xe) * This only restores pinned memory which is the memory required for the * GT(s) to resume. */ - err = xe_bo_restore_kernel(xe); - if (err) - goto err; + if (xe->d3cold.allowed == XE_D3COLD_OFF) { + err = xe_bo_restore_kernel(xe); + if (err) + goto err; + } xe_irq_resume(xe); @@ -299,9 +309,11 @@ int xe_pm_resume(struct xe_device *xe) xe_display_pm_resume(xe); - err = xe_bo_restore_user(xe); - if (err) - goto err; + if (xe->d3cold.allowed == XE_D3COLD_OFF) { + err = xe_bo_restore_user(xe); + if (err) + goto err; + } xe_pxp_pm_resume(xe->pxp); @@ -543,7 +555,7 @@ int xe_pm_runtime_suspend(struct xe_device *xe) xe_display_pm_runtime_suspend(xe); - if (xe->d3cold.allowed) { + if (xe->d3cold.allowed == XE_D3COLD_OFF) { err = xe_bo_evict_all(xe); if (err) goto out_resume; @@ -559,6 +571,14 @@ int xe_pm_runtime_suspend(struct xe_device *xe) xe_display_pm_runtime_suspend_late(xe); + if (xe->d3cold.allowed == XE_D3COLD_VRSR) { + err = xe_pm_enable_vrsr(xe, true); + if (err) { + drm_err(&xe->drm, "Failed to enable VRSR: %d\n", err); + goto out_resume; + } + } + xe_rpm_lockmap_release(xe); xe_pm_write_callback_task(xe, NULL); return 0; @@ -590,7 +610,7 @@ int xe_pm_runtime_resume(struct xe_device *xe) xe_rpm_lockmap_acquire(xe); - if (xe->d3cold.allowed) { + if (xe->d3cold.allowed == XE_D3COLD_OFF) { err = xe_pcode_ready(xe, true); if (err) goto out; @@ -606,6 +626,9 @@ int xe_pm_runtime_resume(struct xe_device *xe) goto out; } + if (xe->d3cold.allowed == XE_D3COLD_VRSR) + xe_display_pm_resume_early(xe); + xe_irq_resume(xe); for_each_gt(gt, xe, id) @@ -613,7 +636,7 @@ int xe_pm_runtime_resume(struct xe_device *xe) xe_display_pm_runtime_resume(xe); - if (xe->d3cold.allowed) { + if (xe->d3cold.allowed == XE_D3COLD_OFF) { err = xe_bo_restore_user(xe); if (err) goto out;