Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp94167rdh; Wed, 22 Nov 2023 20:06:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IFbivXTLUYyTBmYHpd9L70r4r3PZhZ9I8OXB2+sri4gH8W5smPkJgP20HdPvSRDGLpkzvo/ X-Received: by 2002:a05:6871:328f:b0:1f9:6e14:46b0 with SMTP id mp15-20020a056871328f00b001f96e1446b0mr5880986oac.0.1700712371120; Wed, 22 Nov 2023 20:06:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700712371; cv=none; d=google.com; s=arc-20160816; b=xCXspSK61erY7roa9+vfjs6bH4toAx1Bjivadf0+xOaqKekeKoXJiRVDuTlg6uViWC OvAGpFfev0L4yVNeEWuUa/1IMF+VNkt33wnclUZoWtQzteWB5yKBVNP5/FpkfxmYGWwB 1ixZWdJNujl73Gmgbzj0JQBzC5tQhMZbCvdsSXJcUqkENJ8cAI2eav1mr2iKqvO5MAaf I8jlhfTheIbKJZXYjZoHK2iuAyaOpDgknuUZhBNbevP8ivyfTiFqaClkBJZC/9NSM0pV tbRRdjMc3WmG4J15oUyLnscbAxYZ02LsR2NpOaDfEyK8llh6om2qiw0ml5+qxWQkkwT+ ts4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=83XQ7nfafu60dQ4dWKaNHvvi17ctMY/aL9i+1It06Fk=; fh=d9G4dsZtlI8UONIvGKwhW94hCYEPGxy6CqYeKEG646A=; b=zKTNvCH83c0IK8o2zpv7zcJCGsbDJir0+bPLttNMwpAIGNIIBZgzZL/vV4rND+/z7c vstmFT3nVJ8/jhr1fCoY7wHJ8AX4LHRXp6taIB8flaf7Lkqx5L6K7wopSsGFQ4cOWkBB V3uSPRXjUNvYaKeQKMbwN1NZcaPqH/0XhtvIu9PgfjSwJNlGrVaGj50YvRpyOyELtlOG +X2Y3tKoDPK7RPkGApKtoKxAcY8paNUp7CkKj5QgbKyWz2WQdB5fZCBLZ13+eG7KH5KX kf3OjAvTBI4COzL6hlWdG5DG6bvEJjwAlNTkE/Mu3WGI8Ua2SvtRfJwJc3E5pfLESomk ZE0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GlsNJb0m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id y129-20020a636487000000b005c201af09fdsi496414pgb.575.2023.11.22.20.06.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 20:06:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GlsNJb0m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 0DAB9826102F; Wed, 22 Nov 2023 20:06:08 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344776AbjKWEFK (ORCPT + 99 others); Wed, 22 Nov 2023 23:05:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233871AbjKWEDx (ORCPT ); Wed, 22 Nov 2023 23:03:53 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17F4ED49; Wed, 22 Nov 2023 20:04:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700712240; x=1732248240; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=HDNtUtHtlpXuPd68Eb4FPjR3XEuwrw3TEP0vEY5p49w=; b=GlsNJb0mRdNhNgGHBfe4yu9MtvIIy9EYeoFSMxWSa/IdKXsE4GUCKKBX KAlggv+5nY5Vge2bom7TO+u7BrELQhukhha4/P7EJ/QBSlSZKMEu6sfsi To+vfGs0oqxv5GUircg6x1DvDTupX3bQk4drkCTWL35HzeMWwk375CNIl Nt73NnThGl/9u5FmU+LAOybpII7s1A4idYXBk1hhjzk3xJpny+qZ9SbD6 vvENKEVMq+9Ry/gKD2o0TuIxJDMiJYNcLj6gjgSXcqM8WDlcRG5x/NgrJ JILl6PWSUjxvwMdKCNItxRGCL195S8m/ZqsFGIgcunq2Be6IvZDg5VXje w==; X-IronPort-AV: E=McAfee;i="6600,9927,10902"; a="389347949" X-IronPort-AV: E=Sophos;i="6.04,220,1695711600"; d="scan'208";a="389347949" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Nov 2023 20:03:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10902"; a="801925658" X-IronPort-AV: E=Sophos;i="6.04,220,1695711600"; d="scan'208";a="801925658" Received: from linux.intel.com ([10.54.29.200]) by orsmga001.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Nov 2023 20:03:57 -0800 Received: from debox1-desk4.lan (snpatel1-mobl.amr.corp.intel.com [10.209.89.91]) by linux.intel.com (Postfix) with ESMTP id 2F951580DB4; Wed, 22 Nov 2023 20:03:57 -0800 (PST) From: "David E. Box" To: linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, ilpo.jarvinen@linux.intel.com, rajvi.jingar@linux.intel.com Subject: [PATCH V5 15/20] platform/x86/intel/pmc: Find and register PMC telemetry entries Date: Wed, 22 Nov 2023 20:03:50 -0800 Message-Id: <20231123040355.82139-16-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231123040355.82139-1-david.e.box@linux.intel.com> References: <20231123040355.82139-1-david.e.box@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 22 Nov 2023 20:06:08 -0800 (PST) The PMC SSRAM device contains counters that are structured in Intel Platform Monitoring Technology (PMT) telemetry regions. Look for and register these telemetry regions from the driver so that they may be read using the Intel PMT ABI. Signed-off-by: David E. Box Reviewed-by: Ilpo Järvinen --- V5 - no change V4 - no change V3 - no change V2 - no change drivers/platform/x86/intel/pmc/Kconfig | 1 + drivers/platform/x86/intel/pmc/core_ssram.c | 49 +++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/drivers/platform/x86/intel/pmc/Kconfig b/drivers/platform/x86/intel/pmc/Kconfig index b526597e4deb..d2f651fbec2c 100644 --- a/drivers/platform/x86/intel/pmc/Kconfig +++ b/drivers/platform/x86/intel/pmc/Kconfig @@ -7,6 +7,7 @@ config INTEL_PMC_CORE tristate "Intel PMC Core driver" depends on PCI depends on ACPI + depends on INTEL_PMT_TELEMETRY help The Intel Platform Controller Hub for Intel Core SoCs provides access to Power Management Controller registers via various interfaces. This diff --git a/drivers/platform/x86/intel/pmc/core_ssram.c b/drivers/platform/x86/intel/pmc/core_ssram.c index cb44394d88ce..a18e3a2e90fe 100644 --- a/drivers/platform/x86/intel/pmc/core_ssram.c +++ b/drivers/platform/x86/intel/pmc/core_ssram.c @@ -13,6 +13,8 @@ #include #include "core.h" +#include "../vsec.h" +#include "../pmt/telemetry.h" #define SSRAM_HDR_SIZE 0x100 #define SSRAM_PWRM_OFFSET 0x14 @@ -22,6 +24,49 @@ #define SSRAM_IOE_OFFSET 0x68 #define SSRAM_DEVID_OFFSET 0x70 +static void +pmc_add_pmt(struct pmc_dev *pmcdev, u64 ssram_base, void __iomem *ssram) +{ + struct pci_dev *pcidev = pmcdev->ssram_pcidev; + struct intel_vsec_platform_info info = {}; + struct intel_vsec_header *headers[2] = {}; + struct intel_vsec_header header; + void __iomem *dvsec; + u32 dvsec_offset; + u32 table, hdr; + + ssram = ioremap(ssram_base, SSRAM_HDR_SIZE); + if (!ssram) + return; + + dvsec_offset = readl(ssram + SSRAM_DVSEC_OFFSET); + iounmap(ssram); + + dvsec = ioremap(ssram_base + dvsec_offset, SSRAM_DVSEC_SIZE); + if (!dvsec) + return; + + hdr = readl(dvsec + PCI_DVSEC_HEADER1); + header.id = readw(dvsec + PCI_DVSEC_HEADER2); + header.rev = PCI_DVSEC_HEADER1_REV(hdr); + header.length = PCI_DVSEC_HEADER1_LEN(hdr); + header.num_entries = readb(dvsec + INTEL_DVSEC_ENTRIES); + header.entry_size = readb(dvsec + INTEL_DVSEC_SIZE); + + table = readl(dvsec + INTEL_DVSEC_TABLE); + header.tbir = INTEL_DVSEC_TABLE_BAR(table); + header.offset = INTEL_DVSEC_TABLE_OFFSET(table); + iounmap(dvsec); + + headers[0] = &header; + info.caps = VSEC_CAP_TELEMETRY; + info.headers = headers; + info.base_addr = ssram_base; + info.parent = &pmcdev->pdev->dev; + + intel_vsec_register(pcidev, &info); +} + static const struct pmc_reg_map *pmc_core_find_regmap(struct pmc_info *list, u16 devid) { for (; list->map; ++list) @@ -99,6 +144,9 @@ pmc_core_ssram_get_pmc(struct pmc_dev *pmcdev, int pmc_idx, u32 offset) pwrm_base = get_base(ssram, SSRAM_PWRM_OFFSET); devid = readw(ssram + SSRAM_DEVID_OFFSET); + /* Find and register and PMC telemetry entries */ + pmc_add_pmt(pmcdev, ssram_base, ssram); + map = pmc_core_find_regmap(pmcdev->regmap_list, devid); if (!map) return -ENODEV; @@ -138,3 +186,4 @@ int pmc_core_ssram_init(struct pmc_dev *pmcdev) return ret; } +MODULE_IMPORT_NS(INTEL_VSEC); -- 2.34.1