From patchwork Fri Jun 28 15:09:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael J. Ruhl" X-Patchwork-Id: 13716315 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (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 95B261C2314 for ; Fri, 28 Jun 2024 15:10:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719587434; cv=none; b=W6uNtRc7jVTbrEuOexJcx9OtBYz2G/drjwjBxvjpeUCnfA/AAPDTYPrULCAisqZZJEkdvVR1C2LTFIqyrvx5AE7ifupEobQSYy4j1Bngj6amb8LY0LzaFdSzNld7LlAtb/TTdNvVyCyUXddve5f0UEg7q55TtQAaPmvo3xWF/lo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719587434; c=relaxed/simple; bh=x81i09PBMcVOiSOP9NKPVAuNFzM/iEpE5ATlbAX2gTE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Tdvo2jdklYTF1+lIAX1gLjLiClGQF0gPpBX4NgSybpxN4SVAA9szTEeZLXe91ejKsTAWtIBlXFrKhZ4onxZsCAKxI/cJQyqNfLPW57bZxvrqlqCmWUop+8pIxRJDo2p3+T1v/f2HD8uH969ZcXjhaZumk8oxL0Ew5ZGmVgtfuZQ= 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=Pakf9JhW; arc=none smtp.client-ip=192.198.163.9 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="Pakf9JhW" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719587432; x=1751123432; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=x81i09PBMcVOiSOP9NKPVAuNFzM/iEpE5ATlbAX2gTE=; b=Pakf9JhWdi2HuZmcWC1eK6QGEXs5GlCtGY1XLbuOyZSy5bjY6cjOrYec DYGU1SVnz3lA+5IKUl9CPEQdcppH9bN1s1CX/CJUuFtaY8TLl55iZ3Msk R8L27vl4v+X2GgyLHU3zyEeBW6H0KLj0pU2ZrEGgYU6ToT++rie06ycSB F+/Cp6Q6in6bEIqo6gl6+3uH2TBntGoRfTtnpgqMbRgIfQWn4B6Nt6+eD nRH5Ofm+GHHM2rfk6LpEn4SLxup9c+r2UUOfuNmiElMGcZKvy3l5SauFa BeyRMGayhCMVMIegRgSkx8cDV/3ZeSEIjkbdaNolFq8MpGGk456x21oQz A==; X-CSE-ConnectionGUID: JNyVvLcMQryT2N2Fu9wYOg== X-CSE-MsgGUID: GzN1h71SRVGJJZgHnrhj8Q== X-IronPort-AV: E=McAfee;i="6700,10204,11117"; a="27460840" X-IronPort-AV: E=Sophos;i="6.09,169,1716274800"; d="scan'208";a="27460840" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2024 08:10:31 -0700 X-CSE-ConnectionGUID: BtPmuanvRjmI3HSsuWatxA== X-CSE-MsgGUID: nQMLXGdNSme9edyBvdhGRw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,169,1716274800"; d="scan'208";a="44848118" Received: from awvttdev-05.aw.intel.com ([10.228.212.156]) by fmviesa010-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2024 08:10:30 -0700 From: "Michael J. Ruhl" To: intel-xe@lists.freedesktop.org, platform-driver-x86@vger.kernel.org, david.e.box@linux.intel.com, ilpo.jarvinen@linux.intel.com Cc: michael.j.ruhl@intel.com Subject: [PATCH v4 1/6] platform/x86/intel/vsec.h: Move to include/linux Date: Fri, 28 Jun 2024 11:09:39 -0400 Message-ID: <20240628150945.3363575-2-michael.j.ruhl@intel.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240628150945.3363575-1-michael.j.ruhl@intel.com> References: <20240628150945.3363575-1-michael.j.ruhl@intel.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "David E. Box" Some drivers outside of PDX86 need access to the vsec header. Move it to include/linux to make it easier to include. Signed-off-by: David E. Box --- MAINTAINERS | 1 + drivers/platform/x86/intel/pmc/core_ssram.c | 2 +- drivers/platform/x86/intel/pmt/class.c | 2 +- drivers/platform/x86/intel/pmt/class.h | 2 +- drivers/platform/x86/intel/pmt/crashlog.c | 2 +- drivers/platform/x86/intel/pmt/telemetry.c | 2 +- drivers/platform/x86/intel/sdsi.c | 3 +-- drivers/platform/x86/intel/tpmi.c | 3 +-- drivers/platform/x86/intel/vsec.c | 7 +++---- .../x86/intel/vsec.h => include/linux/intel_vsec.h | 11 +++++++++-- 10 files changed, 20 insertions(+), 15 deletions(-) rename drivers/platform/x86/intel/vsec.h => include/linux/intel_vsec.h (92%) diff --git a/MAINTAINERS b/MAINTAINERS index cd970e09de1b..7bd3b7acd0e0 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -11420,6 +11420,7 @@ INTEL VENDOR SPECIFIC EXTENDED CAPABILITIES DRIVER M: David E. Box S: Supported F: drivers/platform/x86/intel/vsec.* +F: include/linux/intel_vsec.h INTEL VIRTUAL BUTTON DRIVER M: AceLan Kao diff --git a/drivers/platform/x86/intel/pmc/core_ssram.c b/drivers/platform/x86/intel/pmc/core_ssram.c index 1bde86c54eb9..baddaaec25ee 100644 --- a/drivers/platform/x86/intel/pmc/core_ssram.c +++ b/drivers/platform/x86/intel/pmc/core_ssram.c @@ -9,11 +9,11 @@ */ #include +#include #include #include #include "core.h" -#include "../vsec.h" #include "../pmt/telemetry.h" #define SSRAM_HDR_SIZE 0x100 diff --git a/drivers/platform/x86/intel/pmt/class.c b/drivers/platform/x86/intel/pmt/class.c index 4b53940a64e2..d7939b28e937 100644 --- a/drivers/platform/x86/intel/pmt/class.c +++ b/drivers/platform/x86/intel/pmt/class.c @@ -9,12 +9,12 @@ */ #include +#include #include #include #include #include -#include "../vsec.h" #include "class.h" #define PMT_XA_START 1 diff --git a/drivers/platform/x86/intel/pmt/class.h b/drivers/platform/x86/intel/pmt/class.h index d23c63b73ab7..d6f9ccaf28c8 100644 --- a/drivers/platform/x86/intel/pmt/class.h +++ b/drivers/platform/x86/intel/pmt/class.h @@ -2,13 +2,13 @@ #ifndef _INTEL_PMT_CLASS_H #define _INTEL_PMT_CLASS_H +#include #include #include #include #include #include -#include "../vsec.h" #include "telemetry.h" /* PMT access types */ diff --git a/drivers/platform/x86/intel/pmt/crashlog.c b/drivers/platform/x86/intel/pmt/crashlog.c index 4014c02cafdb..9079d5dffc03 100644 --- a/drivers/platform/x86/intel/pmt/crashlog.c +++ b/drivers/platform/x86/intel/pmt/crashlog.c @@ -9,6 +9,7 @@ */ #include +#include #include #include #include @@ -16,7 +17,6 @@ #include #include -#include "../vsec.h" #include "class.h" /* Crashlog discovery header types */ diff --git a/drivers/platform/x86/intel/pmt/telemetry.c b/drivers/platform/x86/intel/pmt/telemetry.c index 09258564dfc4..3478f891ea0b 100644 --- a/drivers/platform/x86/intel/pmt/telemetry.c +++ b/drivers/platform/x86/intel/pmt/telemetry.c @@ -9,6 +9,7 @@ */ #include +#include #include #include #include @@ -16,7 +17,6 @@ #include #include -#include "../vsec.h" #include "class.h" #define TELEM_SIZE_OFFSET 0x0 diff --git a/drivers/platform/x86/intel/sdsi.c b/drivers/platform/x86/intel/sdsi.c index 277e4f4b20ac..9d137621f0e6 100644 --- a/drivers/platform/x86/intel/sdsi.c +++ b/drivers/platform/x86/intel/sdsi.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -22,8 +23,6 @@ #include #include -#include "vsec.h" - #define ACCESS_TYPE_BARID 2 #define ACCESS_TYPE_LOCAL 3 diff --git a/drivers/platform/x86/intel/tpmi.c b/drivers/platform/x86/intel/tpmi.c index 6c0cbccd80bb..b9fa1cbfdcf7 100644 --- a/drivers/platform/x86/intel/tpmi.c +++ b/drivers/platform/x86/intel/tpmi.c @@ -51,6 +51,7 @@ #include #include #include +#include #include #include #include @@ -59,8 +60,6 @@ #include #include -#include "vsec.h" - /** * struct intel_tpmi_pfs_entry - TPMI PM Feature Structure (PFS) entry * @tpmi_id: TPMI feature identifier (what the feature is and its data format). diff --git a/drivers/platform/x86/intel/vsec.c b/drivers/platform/x86/intel/vsec.c index 0fdfaf3a4f5c..2b46807f868b 100644 --- a/drivers/platform/x86/intel/vsec.c +++ b/drivers/platform/x86/intel/vsec.c @@ -17,14 +17,13 @@ #include #include #include -#include #include +#include +#include #include #include #include -#include "vsec.h" - #define PMT_XA_START 0 #define PMT_XA_MAX INT_MAX #define PMT_XA_LIMIT XA_LIMIT(PMT_XA_START, PMT_XA_MAX) @@ -341,7 +340,7 @@ static bool intel_vsec_walk_vsec(struct pci_dev *pdev, void intel_vsec_register(struct pci_dev *pdev, struct intel_vsec_platform_info *info) { - if (!pdev || !info) + if (!pdev || !info || !info->headers) return; intel_vsec_walk_header(pdev, info); diff --git a/drivers/platform/x86/intel/vsec.h b/include/linux/intel_vsec.h similarity index 92% rename from drivers/platform/x86/intel/vsec.h rename to include/linux/intel_vsec.h index e23e76129691..ff7998cadab4 100644 --- a/drivers/platform/x86/intel/vsec.h +++ b/include/linux/intel_vsec.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _VSEC_H -#define _VSEC_H +#ifndef _INTEL_VSEC_H +#define _INTEL_VSEC_H #include #include @@ -103,6 +103,13 @@ static inline struct intel_vsec_device *auxdev_to_ivdev(struct auxiliary_device return container_of(auxdev, struct intel_vsec_device, auxdev); } +#if IS_ENABLED(CONFIG_INTEL_VSEC) void intel_vsec_register(struct pci_dev *pdev, struct intel_vsec_platform_info *info); +#else +static inline void intel_vsec_register(struct pci_dev *pdev, + struct intel_vsec_platform_info *info) +{ +} +#endif #endif From patchwork Fri Jun 28 15:09:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael J. Ruhl" X-Patchwork-Id: 13716316 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (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 40D051C2322 for ; Fri, 28 Jun 2024 15:10:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719587434; cv=none; b=gdKLdTLPx1AlnyTlk326e87vQUHbq9ZaWVhMxX+uoER5sUFkYSplkIiNzj8QgznfMO5JjzQp3slt7Alv6rzo/5uN+DVzTPfvuapYmfzt6KajxAPGOQTfpQTwvxR51s4bdJDZ+Z59ou/YPhRtiD4bjPF5gAo9+elabB0t3y7EmvI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719587434; c=relaxed/simple; bh=R8dbb3VgmZF9CuqsKQAVTfcfpL/OtdrfBMNafCLJTlQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jPO77jEDdDrAYjBS5RvcbFIQ7n6Kp5LQFaZ0pbpHC5f0dlusDYTMyJk1D9Z4q0rGDyD5j2pzRccUHG5/DbikANM5sXKTIPQw/LrG8ZGENqDfl0A5+bZ5NBewmoUPghRsiKp6JiqmiFblsczxuOTS/KlUEql8IHoV9OFWZ2NmQVA= 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=keVZd9NB; arc=none smtp.client-ip=192.198.163.9 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="keVZd9NB" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719587433; x=1751123433; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=R8dbb3VgmZF9CuqsKQAVTfcfpL/OtdrfBMNafCLJTlQ=; b=keVZd9NBlMPQcFyG7V3ySJiJElZEOsdnRFjS3xnDC9l0APnFHdxDOzuC a4Rp/t+qigm12tWeqjc75jGLK+wdXtvymgeiwTI36M27rE7N7YWV7lDd9 e2pchCrKcvvlUZe+h43++TKQ2y1hzP+Er2LC0P8Vgs71+2QtTJFxm2vrY f72MhhC9q1tw9MSOsN0wF/CIqMYjFBx524xUPFa9pKEaRC2O2f+2Zeqr2 fSAsmHldfC5CdPQijVD+g8ZgBngjN3l28+uBv/qHPTKRU/Mf7WlfwmXXz HWY6nYpFJpuP/3xkmme1WL8s39P0VJ8CmIdTTlHm+ragoEtH7gaFBVKJo A==; X-CSE-ConnectionGUID: yAqIfKfORay5SRBLoKkgcA== X-CSE-MsgGUID: SeyrWctBSei9YFhI+/oGHw== X-IronPort-AV: E=McAfee;i="6700,10204,11117"; a="27460846" X-IronPort-AV: E=Sophos;i="6.09,169,1716274800"; d="scan'208";a="27460846" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2024 08:10:32 -0700 X-CSE-ConnectionGUID: ooUVYUKcSvCVLO1TFVn/Qw== X-CSE-MsgGUID: xG6KHdMnTN+Ymp91fqQQJg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,169,1716274800"; d="scan'208";a="44848122" Received: from awvttdev-05.aw.intel.com ([10.228.212.156]) by fmviesa010-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2024 08:10:31 -0700 From: "Michael J. Ruhl" To: intel-xe@lists.freedesktop.org, platform-driver-x86@vger.kernel.org, david.e.box@linux.intel.com, ilpo.jarvinen@linux.intel.com Cc: michael.j.ruhl@intel.com Subject: [PATCH v4 2/6] platform/x86/intel/vsec: Add PMT read callbacks Date: Fri, 28 Jun 2024 11:09:40 -0400 Message-ID: <20240628150945.3363575-3-michael.j.ruhl@intel.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240628150945.3363575-1-michael.j.ruhl@intel.com> References: <20240628150945.3363575-1-michael.j.ruhl@intel.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "David E. Box" Some PMT providers require device specific actions before their telemetry can be read. Provide assignable PMT read callbacks to allow providers to perform those actions. Signed-off-by: David E. Box --- drivers/platform/x86/intel/vsec.c | 1 + include/linux/intel_vsec.h | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/drivers/platform/x86/intel/vsec.c b/drivers/platform/x86/intel/vsec.c index 2b46807f868b..7b5cc9993974 100644 --- a/drivers/platform/x86/intel/vsec.c +++ b/drivers/platform/x86/intel/vsec.c @@ -212,6 +212,7 @@ static int intel_vsec_add_dev(struct pci_dev *pdev, struct intel_vsec_header *he intel_vsec_dev->num_resources = header->num_entries; intel_vsec_dev->quirks = info->quirks; intel_vsec_dev->base_addr = info->base_addr; + intel_vsec_dev->priv_data = info->priv_data; if (header->id == VSEC_ID_SDSI) intel_vsec_dev->ida = &intel_vsec_sdsi_ida; diff --git a/include/linux/intel_vsec.h b/include/linux/intel_vsec.h index ff7998cadab4..003301783331 100644 --- a/include/linux/intel_vsec.h +++ b/include/linux/intel_vsec.h @@ -67,10 +67,15 @@ enum intel_vsec_quirks { VSEC_QUIRK_EARLY_HW = BIT(4), }; +struct pmt_callbacks { + int (*read_telem)(void *args, u32 guid, u64 *data, u32 count); +}; + /* Platform specific data */ struct intel_vsec_platform_info { struct device *parent; struct intel_vsec_header **headers; + void *priv_data; unsigned long caps; unsigned long quirks; u64 base_addr; From patchwork Fri Jun 28 15:09:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael J. Ruhl" X-Patchwork-Id: 13716317 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (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 173B61C2330 for ; Fri, 28 Jun 2024 15:10:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719587439; cv=none; b=vBZUpgWPh10c4RUV3qYmC0vCXqOVDUuDsSZGrvs1dXHHAKJ7eHU2tBaHFMjENNJRvsAzBQbtgrCkV97dD3WTaxp/dNAyOcJpYg/ZK8F5jfHG1AQgtnSLPWT8gTnqufpcVMpdbpu5P89M9ZT8JDXLoUBVVD85uh5sUm6WGu/H7cs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719587439; c=relaxed/simple; bh=PzNioSfRXQpfuHXKkF+ye0zuWnIiOoNw3FQ8TQqipSU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RsQeTl1F0vuqMoIKRsTEcWOMtZCXOe0KnMOqUos/TLuWgqTBxVNrpflz+Ga0+iWqAVr5oDXnVnh9AewS2qq908OogOcChfk9k7gRyJ85mGOah7QzjGxkP2KJ5L/jpj86LLg2/u6znLgar23x3nOTQ4RuuiB/uykU70rYbnxVi64= 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=FATJMTZs; arc=none smtp.client-ip=192.198.163.9 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="FATJMTZs" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719587438; x=1751123438; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PzNioSfRXQpfuHXKkF+ye0zuWnIiOoNw3FQ8TQqipSU=; b=FATJMTZsvqdmh0l79wcLPL0uRgAYkUC0fWHQ3eEnIWrWgsILU3ke3gFz 0/bt4Z5FQ2TYijaRhQrOu2nbqLGXBRAvs7Z/03OibnFvpU8erRcJgkHuH f3Z452WWJN+zJREfMjG/Oj/erUjk5GyXQesxg519EFaWtIALpuWCyxAvK Z3j3cJjooxPnghPvEHyU9+ZIp35Z9/jKwUOkp86scesIk/4UExamiAkOR 2PJV2QNhXOo5e3xK+4JEB7EOhNV8GEs4gdBVYuh/kE0Z6X5VvqXWqhEgx RTRpq5x5We4hU+JKJ6/jNDpbm3sRwp4P80DO6qb35B1sp8oZMcY/KbQvg w==; X-CSE-ConnectionGUID: /1bebCB5RECcZ8FD3rpNhA== X-CSE-MsgGUID: hg2E7uHOT4ehY/BerFkttA== X-IronPort-AV: E=McAfee;i="6700,10204,11117"; a="27460867" X-IronPort-AV: E=Sophos;i="6.09,169,1716274800"; d="scan'208";a="27460867" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2024 08:10:37 -0700 X-CSE-ConnectionGUID: 8wtfKrOoSC21IB1GrdeX9g== X-CSE-MsgGUID: MquSr8dwQdOAj00AyvZajg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,169,1716274800"; d="scan'208";a="44848136" Received: from awvttdev-05.aw.intel.com ([10.228.212.156]) by fmviesa010-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2024 08:10:36 -0700 From: "Michael J. Ruhl" To: intel-xe@lists.freedesktop.org, platform-driver-x86@vger.kernel.org, david.e.box@linux.intel.com, ilpo.jarvinen@linux.intel.com Cc: michael.j.ruhl@intel.com Subject: [PATCH v4 3/6] platform/x86/intel/pmt: Use PMT callbacks Date: Fri, 28 Jun 2024 11:09:41 -0400 Message-ID: <20240628150945.3363575-4-michael.j.ruhl@intel.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240628150945.3363575-1-michael.j.ruhl@intel.com> References: <20240628150945.3363575-1-michael.j.ruhl@intel.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "David E. Box" PMT providers may require device specific actions before their telemetry may be read. If the read_telem() is assigned, call it instead of memcpy_fromio() and return. Since this needs to be done in multiple locations, add pmt_telem_read_mmio() as a wrapper function to perform this and any other needed checks. Signed-off-by: David E. Box --- drivers/platform/x86/intel/pmt/class.c | 26 +++++++++++++++++----- drivers/platform/x86/intel/pmt/class.h | 8 +++++-- drivers/platform/x86/intel/pmt/telemetry.c | 10 +++++---- 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/drivers/platform/x86/intel/pmt/class.c b/drivers/platform/x86/intel/pmt/class.c index d7939b28e937..c04bb7f97a4d 100644 --- a/drivers/platform/x86/intel/pmt/class.c +++ b/drivers/platform/x86/intel/pmt/class.c @@ -58,6 +58,22 @@ pmt_memcpy64_fromio(void *to, const u64 __iomem *from, size_t count) return count; } +int pmt_telem_read_mmio(struct pci_dev *pdev, struct pmt_callbacks *cb, u32 guid, void *buf, + void __iomem *addr, u32 count) +{ + if (cb && cb->read_telem) + return cb->read_telem(pdev, guid, buf, count); + + if (guid == GUID_SPR_PUNIT) + /* PUNIT on SPR only supports aligned 64-bit read */ + return pmt_memcpy64_fromio(buf, addr, count); + + memcpy_fromio(buf, addr, count); + + return count; +} +EXPORT_SYMBOL_NS_GPL(pmt_telem_read_mmio, INTEL_PMT); + /* * sysfs */ @@ -79,11 +95,8 @@ intel_pmt_read(struct file *filp, struct kobject *kobj, if (count > entry->size - off) count = entry->size - off; - if (entry->guid == GUID_SPR_PUNIT) - /* PUNIT on SPR only supports aligned 64-bit read */ - count = pmt_memcpy64_fromio(buf, entry->base + off, count); - else - memcpy_fromio(buf, entry->base + off, count); + count = pmt_telem_read_mmio(entry->ep->pcidev, entry->cb, entry->header.guid, buf, + entry->base + off, count); return count; } @@ -239,6 +252,7 @@ static int intel_pmt_populate_entry(struct intel_pmt_entry *entry, entry->guid = header->guid; entry->size = header->size; + entry->cb = ivdev->priv_data; return 0; } @@ -300,7 +314,7 @@ static int intel_pmt_dev_register(struct intel_pmt_entry *entry, goto fail_ioremap; if (ns->pmt_add_endpoint) { - ret = ns->pmt_add_endpoint(entry, ivdev->pcidev); + ret = ns->pmt_add_endpoint(ivdev, entry); if (ret) goto fail_add_endpoint; } diff --git a/drivers/platform/x86/intel/pmt/class.h b/drivers/platform/x86/intel/pmt/class.h index d6f9ccaf28c8..a267ac964423 100644 --- a/drivers/platform/x86/intel/pmt/class.h +++ b/drivers/platform/x86/intel/pmt/class.h @@ -24,6 +24,7 @@ struct pci_dev; struct telem_endpoint { struct pci_dev *pcidev; struct telem_header header; + struct pmt_callbacks *cb; void __iomem *base; bool present; struct kref kref; @@ -43,6 +44,7 @@ struct intel_pmt_entry { struct kobject *kobj; void __iomem *disc_table; void __iomem *base; + struct pmt_callbacks *cb; unsigned long base_addr; size_t size; u32 guid; @@ -55,10 +57,12 @@ struct intel_pmt_namespace { const struct attribute_group *attr_grp; int (*pmt_header_decode)(struct intel_pmt_entry *entry, struct device *dev); - int (*pmt_add_endpoint)(struct intel_pmt_entry *entry, - struct pci_dev *pdev); + int (*pmt_add_endpoint)(struct intel_vsec_device *ivdev, + struct intel_pmt_entry *entry); }; +int pmt_telem_read_mmio(struct pci_dev *pdev, struct pmt_callbacks *cb, u32 guid, void *buf, + void __iomem *addr, u32 count); bool intel_pmt_is_early_client_hw(struct device *dev); int intel_pmt_dev_create(struct intel_pmt_entry *entry, struct intel_pmt_namespace *ns, diff --git a/drivers/platform/x86/intel/pmt/telemetry.c b/drivers/platform/x86/intel/pmt/telemetry.c index 3478f891ea0b..c9feac859e57 100644 --- a/drivers/platform/x86/intel/pmt/telemetry.c +++ b/drivers/platform/x86/intel/pmt/telemetry.c @@ -93,8 +93,8 @@ static int pmt_telem_header_decode(struct intel_pmt_entry *entry, return 0; } -static int pmt_telem_add_endpoint(struct intel_pmt_entry *entry, - struct pci_dev *pdev) +static int pmt_telem_add_endpoint(struct intel_vsec_device *ivdev, + struct intel_pmt_entry *entry) { struct telem_endpoint *ep; @@ -104,13 +104,14 @@ static int pmt_telem_add_endpoint(struct intel_pmt_entry *entry, return -ENOMEM; ep = entry->ep; - ep->pcidev = pdev; + ep->pcidev = ivdev->pcidev; ep->header.access_type = entry->header.access_type; ep->header.guid = entry->header.guid; ep->header.base_offset = entry->header.base_offset; ep->header.size = entry->header.size; ep->base = entry->base; ep->present = true; + ep->cb = ivdev->priv_data; kref_init(&ep->kref); @@ -218,7 +219,8 @@ int pmt_telem_read(struct telem_endpoint *ep, u32 id, u64 *data, u32 count) if (offset + NUM_BYTES_QWORD(count) > size) return -EINVAL; - memcpy_fromio(data, ep->base + offset, NUM_BYTES_QWORD(count)); + pmt_telem_read_mmio(ep->pcidev, ep->cb, ep->header.guid, data, ep->base + offset, + NUM_BYTES_QWORD(count)); return ep->present ? 0 : -EPIPE; } From patchwork Fri Jun 28 15:09:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael J. Ruhl" X-Patchwork-Id: 13716318 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (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 1FC041C2331 for ; Fri, 28 Jun 2024 15:10:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719587440; cv=none; b=hm3s+DH0hJem8MAz3JhlcMrYMkmgkgsnFxEjfO3alHV8qZ2xSoEEBbYqlL1dCnjMG+gfRhKj2FxVnmaZHp5lvAbC25YcV2ZbSeXDaaC5i82x9rc/YJRJyNqouK3JKme6Q0yDP+P9vW1v81NRCrEgeQpQ+QDF12unjoq0pCOlf+g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719587440; c=relaxed/simple; bh=FTymvErby3W/rq88oQmQ5K92IMH9O8oXQ2BPB+qFxrM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=dMAzeZvabgXcU4xuoW4U5MkJkDBFWcbix7kmSYLR7Lgb87bNONGtrE3Q1tcWzg/Dqb3uDBJxTrAL0E5g2smW0o8IIrlpqBukNHv+3VTfsx/e0N6ed0eZ4ojeReX90amhkCYeKx7NSFR7L6BJH5cjuNJeF3UU89rGpgi+xi258q4= 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=j6TJ+bjX; arc=none smtp.client-ip=192.198.163.9 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="j6TJ+bjX" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719587439; x=1751123439; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FTymvErby3W/rq88oQmQ5K92IMH9O8oXQ2BPB+qFxrM=; b=j6TJ+bjXsHCrEOZUtcBuuy1GJ6o156kRd7dWxNre8389sTHuoOsuAA8B wWeZ8FcyX/7mVFZGfwmnPqfgd7aH4cK+R+z0R/FXjVDA/XuPOetdhUGCY AfY2yqOGpgzqMX0OvSddvp/goP3VX3BZKXYi3KCo6Si01FGDBUb1w3aL3 jjL6RuQlu1BuyAl/W3bWFrvtI1fpZNrVLabmomB5P8XnD2O9veFb64mId SpLQ2c2553Irq4Rceh2wUzryGfrl0rToVSjb36W+BkMxr0ymVpzmdT1An Yjv7CETulOyLc6gJYFzWy5kUPDp5MRXqqGsKZSiMjClMJS6/LvnBHgU5i A==; X-CSE-ConnectionGUID: BKs1PRzZRv2MFofxd4EPAA== X-CSE-MsgGUID: 1lzqw2coQsKYrfaObIcnLg== X-IronPort-AV: E=McAfee;i="6700,10204,11117"; a="27460873" X-IronPort-AV: E=Sophos;i="6.09,169,1716274800"; d="scan'208";a="27460873" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2024 08:10:39 -0700 X-CSE-ConnectionGUID: ossWUiStRDOJU0j+6ddkbQ== X-CSE-MsgGUID: L12R+Jy0QA+REZ+PgTtkUQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,169,1716274800"; d="scan'208";a="44848144" Received: from awvttdev-05.aw.intel.com ([10.228.212.156]) by fmviesa010-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2024 08:10:37 -0700 From: "Michael J. Ruhl" To: intel-xe@lists.freedesktop.org, platform-driver-x86@vger.kernel.org, david.e.box@linux.intel.com, ilpo.jarvinen@linux.intel.com Cc: michael.j.ruhl@intel.com Subject: [PATCH v4 4/6] drm/xe/vsec: Support BMG devices Date: Fri, 28 Jun 2024 11:09:42 -0400 Message-ID: <20240628150945.3363575-5-michael.j.ruhl@intel.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240628150945.3363575-1-michael.j.ruhl@intel.com> References: <20240628150945.3363575-1-michael.j.ruhl@intel.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Utilize the PMT callback API to add support for the BMG devices. Signed-off-by: Michael J. Ruhl --- drivers/gpu/drm/xe/Makefile | 1 + drivers/gpu/drm/xe/xe_device.c | 5 + drivers/gpu/drm/xe/xe_device_types.h | 6 + drivers/gpu/drm/xe/xe_vsec.c | 214 +++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_vsec.h | 13 ++ 5 files changed, 239 insertions(+) create mode 100644 drivers/gpu/drm/xe/xe_vsec.c create mode 100644 drivers/gpu/drm/xe/xe_vsec.h diff --git a/drivers/gpu/drm/xe/Makefile b/drivers/gpu/drm/xe/Makefile index b1e03bfe4a68..5860d6db1598 100644 --- a/drivers/gpu/drm/xe/Makefile +++ b/drivers/gpu/drm/xe/Makefile @@ -129,6 +129,7 @@ xe-y += xe_bb.o \ xe_vm.o \ xe_vram.o \ xe_vram_freq.o \ + xe_vsec.o \ xe_wait_user_fence.o \ xe_wa.o \ xe_wopcm.o diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c index cfda7cb5df2c..05a666c7bbb7 100644 --- a/drivers/gpu/drm/xe/xe_device.c +++ b/drivers/gpu/drm/xe/xe_device.c @@ -53,6 +53,7 @@ #include "xe_ttm_sys_mgr.h" #include "xe_vm.h" #include "xe_vram.h" +#include "xe_vsec.h" #include "xe_wait_user_fence.h" static int xe_file_open(struct drm_device *dev, struct drm_file *file) @@ -317,6 +318,8 @@ struct xe_device *xe_device_create(struct pci_dev *pdev, goto err; } + drmm_mutex_init(&xe->drm, &xe->pmt.lock); + err = xe_display_create(xe); if (WARN_ON(err)) goto err; @@ -692,6 +695,8 @@ int xe_device_probe(struct xe_device *xe) for_each_gt(gt, xe, id) xe_gt_sanitize_freq(gt); + xe_vsec_init(xe); + return devm_add_action_or_reset(xe->drm.dev, xe_device_sanitize, xe); err_fini_display: diff --git a/drivers/gpu/drm/xe/xe_device_types.h b/drivers/gpu/drm/xe/xe_device_types.h index c37be471d11c..11513d8f3a8b 100644 --- a/drivers/gpu/drm/xe/xe_device_types.h +++ b/drivers/gpu/drm/xe/xe_device_types.h @@ -451,6 +451,12 @@ struct xe_device { struct mutex lock; } d3cold; + /** @pmt: Support the PMT driver callback interface */ + struct { + /** @pmt.lock: protect access for telemetry data */ + struct mutex lock; + } pmt; + /** * @pm_callback_task: Track the active task that is running in either * the runtime_suspend or runtime_resume callbacks. diff --git a/drivers/gpu/drm/xe/xe_vsec.c b/drivers/gpu/drm/xe/xe_vsec.c new file mode 100644 index 000000000000..7db1624a335f --- /dev/null +++ b/drivers/gpu/drm/xe/xe_vsec.c @@ -0,0 +1,214 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright © 2022 - 2024 Intel Corporation + */ +#include +#include + +#include "xe_device.h" +#include "xe_device_types.h" +#include "xe_drv.h" +#include "xe_mmio.h" +#include "xe_platform_types.h" +#include "xe_pm.h" +#include "xe_vsec.h" + +#define SOC_BASE 0x280000 + +#define BMG_PMT_BASE 0xDB000 +#define BMG_DISCOVERY_OFFSET (SOC_BASE + BMG_PMT_BASE) + +#define BMG_TELEMETRY_BASE 0xE0000 +#define BMG_TELEMETRY_OFFSET (SOC_BASE + BMG_TELEMETRY_BASE) + +#define GFX_BAR 0 + +#define SG_REMAP_INDEX1 XE_REG(SOC_BASE + 0x08) +#define SG_REMAP_ACCESS(_mem) ((_mem) << 24) +#define SG_REMAP_BITS GENMASK(31, 24) + +static struct intel_vsec_header bmg_telemetry = { + .length = 0x10, + .id = VSEC_ID_TELEMETRY, + .num_entries = 2, + .entry_size = 4, + .tbir = GFX_BAR, + .offset = BMG_DISCOVERY_OFFSET, +}; + +static struct intel_vsec_header *bmg_capabilities[] = { + &bmg_telemetry, + NULL +}; + +enum xe_vsec { + XE_VSEC_UNKNOWN = 0, + XE_VSEC_BMG, +}; + +static struct intel_vsec_platform_info xe_vsec_info[] = { + [XE_VSEC_BMG] = { + .caps = VSEC_CAP_TELEMETRY, + .headers = bmg_capabilities, + }, + { } +}; + +/* GUID Decode information */ +#define GUID_TELEM_ITERATION GENMASK(3, 0) +#define GUID_SEGMENT GENMASK(7, 4) +#define GUID_SOC_SKU GENMASK(11, 8) +#define GUID_DEVICE_ID GENMASK(27, 12) +#define GUID_CAP_TYPE GENMASK(29, 28) +#define GUID_RECORD_ID GENMASK(31, 30) + +enum record_id { + PUNIT, + OOBMSM_0, + OOBMSM_1 +}; + +enum capability { + CRASHLOG, + TELEMETRY, + WATCHER +}; + +/* + * The GUID will have the following bits to decode (high bits first): + * + * X(2bits) - Record-ID (0-PUNIT, 1-OOBMSM_0, 2-OOBMSM_1) + * X(2bits) - Capability Type (Crashlog-0, Telemetry Aggregator-1, Watcher-2) + * XXXX(16bits)– Device ID – changes for each down bin SKU’s (0xE2F8 for BMG) + * X(4bits) - SOC_SKU (SKU_INDEPENDENT-0, X3-1, X2-2, G31-3), + * X(4bits) - Segment (SEGMENT_INDEPENDENT-0, Client-1, Server-2) + * X(4bits) - {Telemetry space iteration number (0,1,..)} + * + */ +static int guid_decode(u32 guid, int *index, u32 *offset) +{ + u32 record_id = (guid & GUID_RECORD_ID) >> 30; + u32 cap_type = (guid & GUID_CAP_TYPE) >> 28; + u32 device_id = (guid & GUID_DEVICE_ID) >> 12; + + if (device_id != 0xE2F8) + return -ENODEV; + + if (record_id > OOBMSM_1 || cap_type > WATCHER) + return -EINVAL; + + *offset = 0; + + if (cap_type == CRASHLOG) { + *index = record_id == PUNIT ? 2 : 4; + return 0; + } + + switch (record_id) { + case PUNIT: + *index = 0; + if (cap_type == TELEMETRY) + *offset = 0x0200; + else /* if (cap_type == WATCHER) */ + *offset = 0x14A0; + break; + + case OOBMSM_0: + *index = 1; + if (cap_type == WATCHER) + *offset = 0x18D8; + break; + + case OOBMSM_1: + *index = 1; + if (cap_type == TELEMETRY) + *offset = 0x1000; + break; + } + + return 0; +} + +static int xe_pmt_telem_read(void *args, u32 guid, u64 *data, u32 count) +{ + struct xe_device *xe = pdev_to_xe_device((struct pci_dev *)args); + void __iomem *telem_addr = xe->tiles[0].mmio.regs + BMG_TELEMETRY_OFFSET; + u32 mem_region; + u32 offset; + int ret; + + ret = guid_decode(guid, &mem_region, &offset); + if (ret) + return ret; + + telem_addr += offset; + + mutex_lock(&xe->pmt.lock); + + /* indicate that we are not at an appropriate power level */ + ret = -ENODATA; + if (xe_pm_runtime_get_if_active(xe) > 0) { + /* set SoC re-mapper index register based on guid memory region */ + xe_mmio_rmw32(xe->tiles[0].primary_gt, SG_REMAP_INDEX1, SG_REMAP_BITS, + SG_REMAP_ACCESS(mem_region)); + + memcpy_fromio(data, telem_addr, count); + ret = count; + xe_pm_runtime_put(xe); + } + mutex_unlock(&xe->pmt.lock); + + return ret; +} + +struct pmt_callbacks xe_pmt_cb = { + .read_telem = xe_pmt_telem_read, +}; + +static const int vsec_platforms[] = { + [XE_BATTLEMAGE] = XE_VSEC_BMG, +}; + +static enum xe_vsec get_platform_info(struct xe_device *xe) +{ + if (xe->info.platform > XE_BATTLEMAGE) + return XE_VSEC_UNKNOWN; + + return vsec_platforms[xe->info.platform]; +} + +/** + * xe_vsec_init - Initialize resources and add intel_vsec auxiliary + * interface + * @xe: valid xe instance + */ +void xe_vsec_init(struct xe_device *xe) +{ + struct intel_vsec_platform_info *info; + struct device *dev = xe->drm.dev; + struct pci_dev *pdev = to_pci_dev(dev); + enum xe_vsec platform; + + platform = get_platform_info(xe); + if (platform == XE_VSEC_UNKNOWN) + return; + + info = &xe_vsec_info[platform]; + if (!info->headers) + return; + + switch (platform) { + case XE_VSEC_BMG: + info->priv_data = &xe_pmt_cb; + break; + default: + break; + } + + /* + * Register a VSEC. Cleanup is handled using device managed + * resources. + */ + intel_vsec_register(pdev, info); +} +MODULE_IMPORT_NS(INTEL_VSEC); diff --git a/drivers/gpu/drm/xe/xe_vsec.h b/drivers/gpu/drm/xe/xe_vsec.h new file mode 100644 index 000000000000..3fd29a21cad6 --- /dev/null +++ b/drivers/gpu/drm/xe/xe_vsec.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright © 2022 - 2024 Intel Corporation + */ + +#ifndef _XE_VSEC_H_ +#define _XE_VSEC_H_ + +struct xe_device; + +void xe_vsec_init(struct xe_device *xe); + +#endif From patchwork Fri Jun 28 15:09:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael J. Ruhl" X-Patchwork-Id: 13716319 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (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 9A8411C233B for ; Fri, 28 Jun 2024 15:10:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719587445; cv=none; b=OS5R3Pup6JYwDcMUk7FYeI31T1CadPPQfm18iLNgJSoy1MKoKcW3EA4hFA2XexzsjhM6lWUmeGY1/knykBfFiuJkQsFInL/ElU3CupXciAqcFFQwv/PNRe9O2Jy0riIoUqjjyG3Dw9JEnexbPpR5YfcjVr5PUl4xghnU3PsGY+Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719587445; c=relaxed/simple; bh=o7pgEsl1M4jkRAL2OMPP8br1xBPkYV2QP+YAJ1OanhY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PxQnVXhqBKgLZdT+hFJ7X4IEjSbV2iihmA4HqO5hvnzK93fmYpwubo1reGPYUMclM6c+REx6Q96eo0zfC3MUSf+1Qe7NU8ZA037EqnGBwYQ0VampYYMzIbjV3eXcqkbalNE02LcECVo1GFcXSRnzF4KDphNiskeSmeSZGq/Rlb8= 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=fR1DOORO; arc=none smtp.client-ip=192.198.163.9 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="fR1DOORO" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719587444; x=1751123444; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=o7pgEsl1M4jkRAL2OMPP8br1xBPkYV2QP+YAJ1OanhY=; b=fR1DOOROLnYL1KNhZK9udZ+JY7t3KaqmQs6y+dySsx+S7ELVtvMA7zmI ocNUZvQkur2GIqazRd2X5T7qf8bcgT5w4I6vSmQII1k4jqKUPoyLdbPE+ 3zN0YWpP3WknUmAeV40hWD2QBnPydlyLTLppfs6+vGDbs7Qd7p4dQHItL 4km09fBEMPHekIfXaQeeOc8756hQEB2OeYqLvqWkhQYeE53UCI8Ja+lHv 7sjTwacVLtrEH4rU2ZLnbQDdKQ72UtjuCoxOSnmUgKlOdsFsI3Pf9fnQU 1PO/cmGgpqgiaL5tGaNLdrD6HVj0Oy4InfyJnFAPH8TfJYDCBgRepkLqr Q==; X-CSE-ConnectionGUID: ewXe/AYUSk2iU1clrOcYSg== X-CSE-MsgGUID: uFS/0Yd/Q56yuUPKm62aCQ== X-IronPort-AV: E=McAfee;i="6700,10204,11117"; a="27460890" X-IronPort-AV: E=Sophos;i="6.09,169,1716274800"; d="scan'208";a="27460890" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2024 08:10:43 -0700 X-CSE-ConnectionGUID: hsa7PlmjRC6LHE4aEMPelA== X-CSE-MsgGUID: ehHR1RmaR/+QTCgxktHl0Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,169,1716274800"; d="scan'208";a="44848157" Received: from awvttdev-05.aw.intel.com ([10.228.212.156]) by fmviesa010-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2024 08:10:42 -0700 From: "Michael J. Ruhl" To: intel-xe@lists.freedesktop.org, platform-driver-x86@vger.kernel.org, david.e.box@linux.intel.com, ilpo.jarvinen@linux.intel.com Cc: michael.j.ruhl@intel.com Subject: [PATCH v4 5/6] platform/x86/intel/pmt: Add support for PMT base adjust Date: Fri, 28 Jun 2024 11:09:43 -0400 Message-ID: <20240628150945.3363575-6-michael.j.ruhl@intel.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240628150945.3363575-1-michael.j.ruhl@intel.com> References: <20240628150945.3363575-1-michael.j.ruhl@intel.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 DVSEC offsets are based on the endpoint BAR. If an endpoint is not avialable allow the offset information to be adjusted by the parent driver. Signed-off-by: Michael J. Ruhl --- drivers/platform/x86/intel/pmt/class.h | 1 + drivers/platform/x86/intel/pmt/telemetry.c | 9 +++++++++ drivers/platform/x86/intel/vsec.c | 1 + include/linux/intel_vsec.h | 2 ++ 4 files changed, 13 insertions(+) diff --git a/drivers/platform/x86/intel/pmt/class.h b/drivers/platform/x86/intel/pmt/class.h index a267ac964423..984cd40ee814 100644 --- a/drivers/platform/x86/intel/pmt/class.h +++ b/drivers/platform/x86/intel/pmt/class.h @@ -46,6 +46,7 @@ struct intel_pmt_entry { void __iomem *base; struct pmt_callbacks *cb; unsigned long base_addr; + s32 base_adjust; size_t size; u32 guid; int devid; diff --git a/drivers/platform/x86/intel/pmt/telemetry.c b/drivers/platform/x86/intel/pmt/telemetry.c index c9feac859e57..5c44e500e8f6 100644 --- a/drivers/platform/x86/intel/pmt/telemetry.c +++ b/drivers/platform/x86/intel/pmt/telemetry.c @@ -78,6 +78,13 @@ static int pmt_telem_header_decode(struct intel_pmt_entry *entry, header->access_type = TELEM_ACCESS(readl(disc_table)); header->guid = readl(disc_table + TELEM_GUID_OFFSET); header->base_offset = readl(disc_table + TELEM_BASE_OFFSET); + if (entry->base_adjust) { + u32 new_base = header->base_offset + entry->base_adjust; + + dev_dbg(dev, "Adjusting baseoffset from 0x%x to 0x%x\n", + header->base_offset, new_base); + header->base_offset = new_base; + } /* Size is measured in DWORDS, but accessor returns bytes */ header->size = TELEM_SIZE(readl(disc_table)); @@ -302,6 +309,8 @@ static int pmt_telem_probe(struct auxiliary_device *auxdev, const struct auxilia for (i = 0; i < intel_vsec_dev->num_resources; i++) { struct intel_pmt_entry *entry = &priv->entry[priv->num_entries]; + entry->base_adjust = intel_vsec_dev->base_adjust; + mutex_lock(&ep_lock); ret = intel_pmt_dev_create(entry, &pmt_telem_ns, intel_vsec_dev, i); mutex_unlock(&ep_lock); diff --git a/drivers/platform/x86/intel/vsec.c b/drivers/platform/x86/intel/vsec.c index 7b5cc9993974..be079d62a7bc 100644 --- a/drivers/platform/x86/intel/vsec.c +++ b/drivers/platform/x86/intel/vsec.c @@ -212,6 +212,7 @@ static int intel_vsec_add_dev(struct pci_dev *pdev, struct intel_vsec_header *he intel_vsec_dev->num_resources = header->num_entries; intel_vsec_dev->quirks = info->quirks; intel_vsec_dev->base_addr = info->base_addr; + intel_vsec_dev->base_adjust = info->base_adjust; intel_vsec_dev->priv_data = info->priv_data; if (header->id == VSEC_ID_SDSI) diff --git a/include/linux/intel_vsec.h b/include/linux/intel_vsec.h index 003301783331..930eab246fa1 100644 --- a/include/linux/intel_vsec.h +++ b/include/linux/intel_vsec.h @@ -79,6 +79,7 @@ struct intel_vsec_platform_info { unsigned long caps; unsigned long quirks; u64 base_addr; + s32 base_adjust; }; struct intel_vsec_device { @@ -92,6 +93,7 @@ struct intel_vsec_device { size_t priv_data_size; unsigned long quirks; u64 base_addr; + s32 base_adjust; }; int intel_vsec_add_aux(struct pci_dev *pdev, struct device *parent, From patchwork Fri Jun 28 15:09:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael J. Ruhl" X-Patchwork-Id: 13716320 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (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 5AE6C1C233C for ; Fri, 28 Jun 2024 15:10:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719587447; cv=none; b=bUvXQedvKF7qvTlcPMmNXu6BNbzyJh0ZhR+zvP8bWYFntpD9oiNONRy7dMh7+wMow5Rw5g3qzHMAL0PZlHZ4GxFIF5dVcW6EZnTKzFCqw+FI90HwH5I5/HiN6uokSnOapNVxL95A//GD7yQ2KhUvsoCHy86t5Cvv3yi9ShUNeYA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719587447; c=relaxed/simple; bh=pWyaJf+wNFYsI8mv3LwikwcqwWXhF3wZBkpHTQmeYH0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dbxVQgUU4Od+z2oxHUKa1WfAW0CGTo+KMQJ/blHmVOSIhG5WXHOla43OWlk5A6q3GY+EiRZaNliGrLEJdZ4eSCC0NxXDWKBEY1LzYu4/2olX9T2diFk3GNEVbs1R9UM6e/0+2SRyj2xGXXMsjuI5qwtTVwHTOVglvkVkh13hF/8= 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=h3Ugpkr7; arc=none smtp.client-ip=192.198.163.9 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="h3Ugpkr7" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719587445; x=1751123445; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=pWyaJf+wNFYsI8mv3LwikwcqwWXhF3wZBkpHTQmeYH0=; b=h3Ugpkr7Kg+xPvmWbAYEy4H3/+TC9IrxXEJsCX95Qrh+7Wg64nkTRwwc 7k78EXJXOLncFJUZFd2556S2XZArPKYq1RP5Hzj7d33EMlxoutR+nh4+v oHwWfpASEp2urvGB/xlQnIEyYdn9rS0KrqciDP4acEslGvYeO0vwom/IY s7XayK8fOHAPhax81XaC2/Z6VPqJxKMHqZaZ5KmU8BFzY2QEHfruGcv5a Jvj6qBQQ6n1RSl1DKhZzzCpU1aUrM/v5Qw8bOcH171itUT3c+GaDYZFbq VXFv8aaGEM5EXSznSLhyviKqIqxeo36DUdAyPF020GvvnNqKHZ+y9qNng A==; X-CSE-ConnectionGUID: bHBG28OjTXaF1itt04sYKw== X-CSE-MsgGUID: g8Zo14NIToSllvl01DN9AQ== X-IronPort-AV: E=McAfee;i="6700,10204,11117"; a="27460895" X-IronPort-AV: E=Sophos;i="6.09,169,1716274800"; d="scan'208";a="27460895" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2024 08:10:44 -0700 X-CSE-ConnectionGUID: fqUMoRhUTuaOYftbf6liSw== X-CSE-MsgGUID: l59i35+uSHK77mhjfsqYFg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,169,1716274800"; d="scan'208";a="44848163" Received: from awvttdev-05.aw.intel.com ([10.228.212.156]) by fmviesa010-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2024 08:10:43 -0700 From: "Michael J. Ruhl" To: intel-xe@lists.freedesktop.org, platform-driver-x86@vger.kernel.org, david.e.box@linux.intel.com, ilpo.jarvinen@linux.intel.com Cc: michael.j.ruhl@intel.com Subject: [PATCH v4 6/6] drm/xe/vsec: Add support for DG2 Date: Fri, 28 Jun 2024 11:09:44 -0400 Message-ID: <20240628150945.3363575-7-michael.j.ruhl@intel.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240628150945.3363575-1-michael.j.ruhl@intel.com> References: <20240628150945.3363575-1-michael.j.ruhl@intel.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 DG2 needs to adjust the discovery offset WRT the GT BAR not the P2SB bar so add the base_adjust value to allow for the difference to be used. Update xe_vsec.c to include DG2 header information. Signed-off-by: Michael J. Ruhl --- drivers/gpu/drm/xe/xe_vsec.c | 81 ++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/drivers/gpu/drm/xe/xe_vsec.c b/drivers/gpu/drm/xe/xe_vsec.c index 7db1624a335f..394a534933d8 100644 --- a/drivers/gpu/drm/xe/xe_vsec.c +++ b/drivers/gpu/drm/xe/xe_vsec.c @@ -15,6 +15,16 @@ #define SOC_BASE 0x280000 +/* from drivers/platform/x86/intel/pmt/telemetry.c */ +#define TELEM_BASE_OFFSET 0x8 + +#define DG2_PMT_BASE 0xE8000 +#define DG2_DISCOVERY_START 0x6000 +#define DG2_TELEM_START 0x4000 + +#define DG2_DISCOVERY_OFFSET (SOC_BASE + DG2_PMT_BASE + DG2_DISCOVERY_START) +#define DG2_TELEM_OFFSET (SOC_BASE + DG2_PMT_BASE + DG2_TELEM_START) + #define BMG_PMT_BASE 0xDB000 #define BMG_DISCOVERY_OFFSET (SOC_BASE + BMG_PMT_BASE) @@ -27,6 +37,20 @@ #define SG_REMAP_ACCESS(_mem) ((_mem) << 24) #define SG_REMAP_BITS GENMASK(31, 24) +static struct intel_vsec_header dg2_telemetry = { + .length = 0x10, + .id = VSEC_ID_TELEMETRY, + .num_entries = 1, + .entry_size = 3, + .tbir = GFX_BAR, + .offset = DG2_DISCOVERY_OFFSET, +}; + +static struct intel_vsec_header *dg2_capabilities[] = { + &dg2_telemetry, + NULL +}; + static struct intel_vsec_header bmg_telemetry = { .length = 0x10, .id = VSEC_ID_TELEMETRY, @@ -43,10 +67,16 @@ static struct intel_vsec_header *bmg_capabilities[] = { enum xe_vsec { XE_VSEC_UNKNOWN = 0, + XE_VSEC_DG2, XE_VSEC_BMG, }; static struct intel_vsec_platform_info xe_vsec_info[] = { + [XE_VSEC_DG2] = { + .caps = VSEC_CAP_TELEMETRY, + .headers = dg2_capabilities, + .quirks = VSEC_QUIRK_EARLY_HW, + }, [XE_VSEC_BMG] = { .caps = VSEC_CAP_TELEMETRY, .headers = bmg_capabilities, @@ -166,6 +196,7 @@ struct pmt_callbacks xe_pmt_cb = { }; static const int vsec_platforms[] = { + [XE_DG2] = XE_VSEC_DG2, [XE_BATTLEMAGE] = XE_VSEC_BMG, }; @@ -177,6 +208,49 @@ static enum xe_vsec get_platform_info(struct xe_device *xe) return vsec_platforms[xe->info.platform]; } +/* + * Access the DG2 PMT MMIO discovery table + * + * The intel_vsec driver does not typically access the discovery table. + * Instead, it creates a memory resource for the table and passes it + * to the PMT telemetry driver. Each discovery table contains 3 items, + * - GUID + * - Telemetry size + * - Telemetry offset (offset from P2SB BAR, not GT) + * + * For DG2 we know what the telemetry offset is, but we still need to + * use the discovery table to pass the GUID and the size. So figure + * out the difference between the P2SB offset and the GT offset and + * save this so that the telemetry driver can use it to adjust the + * value. + */ +static int dg2_adjust_offset(struct pci_dev *pdev, struct device *dev, + struct intel_vsec_platform_info *info) +{ + void __iomem *base; + u32 telem_offset; + u64 addr; + + /* compile check to verify that quirk has P2SB quirk added */ + + addr = pci_resource_start(pdev, GFX_BAR) + info->headers[0]->offset; + base = ioremap_wc(addr, 16); + if (!base) + return -ENOMEM; + + telem_offset = readl(base + TELEM_BASE_OFFSET); + + /* Use the base_addr + P2SB quirk to pass this info */ + if (telem_offset < DG2_TELEM_OFFSET) + info->base_adjust = -(DG2_TELEM_OFFSET - telem_offset); + else + info->base_adjust = -(telem_offset - DG2_TELEM_OFFSET); + + iounmap(base); + + return 0; +} + /** * xe_vsec_init - Initialize resources and add intel_vsec auxiliary * interface @@ -188,6 +262,7 @@ void xe_vsec_init(struct xe_device *xe) struct device *dev = xe->drm.dev; struct pci_dev *pdev = to_pci_dev(dev); enum xe_vsec platform; + u32 ret; platform = get_platform_info(xe); if (platform == XE_VSEC_UNKNOWN) @@ -198,6 +273,12 @@ void xe_vsec_init(struct xe_device *xe) return; switch (platform) { + case XE_VSEC_DG2: + ret = dg2_adjust_offset(pdev, dev, info); + if (ret) + return; + break; + case XE_VSEC_BMG: info->priv_data = &xe_pmt_cb; break;