From patchwork Thu Oct 12 02:38:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "David E. Box" X-Patchwork-Id: 151651 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp942707vqb; Wed, 11 Oct 2023 19:39:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG8jIJPW8OOJ0pOqvFSjcYjvOT5+CX4eu8kk5QSb8m0gjfHTJ0NJws0b9YHoEOxomm1/FTt X-Received: by 2002:a92:db4f:0:b0:34e:2a69:883c with SMTP id w15-20020a92db4f000000b0034e2a69883cmr22780737ilq.1.1697078372315; Wed, 11 Oct 2023 19:39:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697078372; cv=none; d=google.com; s=arc-20160816; b=ZIYa1F+LLr7soAIDLvU3NS4Q0h7M9TLUwrG2yLTeo4jB0Quv5Ae7EiTa1b4w9XfhcT OQ1Ayv+JUdithBIFitA7mM3HE9t7+SR4ooi+LyIby9wKavO+YIfhmejZVmwcEobAu156 8+JAG4sqPBA/rPe1gMO4DD4orR5Qq6aEbK+fNjZrhRQlDvFiwAO78ZrS66+cTih5HwkH YJZUqtZ4Hid5TR/+aBtTzLfo8rR2FIHE36Hf3JE7AgulQ3kktPVY/Z0A2ZvCtXND5K3b sbUvp1Yqitp+tnFiAPvuy3HLfXx4GtLky75qHbbQ2tAB5u7Or3hiOcFXA/hfQT+CMr0v piqg== 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=hQuPadUfF8PiJCIktLu4qTUYs5TlkGN2ehVTg6PmRIs=; fh=d9G4dsZtlI8UONIvGKwhW94hCYEPGxy6CqYeKEG646A=; b=wgOd/RMCjvZgRh/+SO/dYYlG+7x4pYYo7HJh2oLidjUOCIxid62XmyzY+4WWrziMJ3 BgXSlpX2t8/lfjzE14rCN1iqA7pvz9+Y8h6QlLc68QRcBjHrDdgelDQp82V55tUTmSdD djH4MCraILn7lO7uM9fYjs5IiD5D25xCLsS6VCZ0/rP86fnclJJZDctlBevfrq5NtW7D 1w0fvJRM4gIqnB0QnZ2W0WQXJZeHW/B2tVyJyKXRGBGH/DDX7/sCcCIQMoCNLfHh6vrr D5nTpojlVPPr/7KszQs03BeLfBQ7oA2XDXCz6V+nkZwlqaYkctWP5nduqNJ56fgeXrwX YHeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=SsMCzMHf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id l125-20020a633e83000000b005702257f332si1236637pga.21.2023.10.11.19.39.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 19:39:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=SsMCzMHf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id 059368026BD2; Wed, 11 Oct 2023 19:39:21 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234107AbjJLCio (ORCPT + 18 others); Wed, 11 Oct 2023 22:38:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232321AbjJLCin (ORCPT ); Wed, 11 Oct 2023 22:38:43 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0F14A9; Wed, 11 Oct 2023 19:38:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697078321; x=1728614321; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=1vjJ5BX03s5/aGfEOqXNECEgcR/vZRlNbtL4DnJaoeg=; b=SsMCzMHfjkF3d9FyT/jDDz81xiUptH79G3YqRmsPaijnsEdm45Yy6C52 NGDE7cp0SPTJuJnJ0uoG/fXxZ5w9jOUW+HNh8boCAsWRu3qHETh1XwcDi 63rNjvDnWQTtGOur+MffhHcpF+g4SmWCMdTFacrClWAx116zkIwz3NBqH TbwlRTyYDYmg4Yi8O+VoDG0JIbRk73gGqVpqTB4GkEPpEZ2Y9FjTxcVUB +Nqp7YsJ030z6uyaJHv15wBYsF2OmIb6ZZ+pYsK7h47+fmjhpaQcZHvey ujwFPoyedj21G3Sf6Ns+xeAn4ukK3HfZLJbUD8cqHJC3mmdRWArUWJTqH Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="365090366" X-IronPort-AV: E=Sophos;i="6.03,217,1694761200"; d="scan'208";a="365090366" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 19:38:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="824411674" X-IronPort-AV: E=Sophos;i="6.03,217,1694761200"; d="scan'208";a="824411674" Received: from linux.intel.com ([10.54.29.200]) by fmsmga004.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 19:38:41 -0700 Received: from debox1-desk4.intel.com (unknown [10.209.105.238]) by linux.intel.com (Postfix) with ESMTP id C7AE9580D95; Wed, 11 Oct 2023 19:38:40 -0700 (PDT) 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 V3 01/16] platform/x86/intel/vsec: Move structures to header Date: Wed, 11 Oct 2023 19:38:25 -0700 Message-Id: <20231012023840.3845703-2-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231012023840.3845703-1-david.e.box@linux.intel.com> References: <20231012023840.3845703-1-david.e.box@linux.intel.com> MIME-Version: 1.0 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.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 (pete.vger.email [0.0.0.0]); Wed, 11 Oct 2023 19:39:22 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779515651136440287 X-GMAIL-MSGID: 1779515651136440287 In preparation for exporting an API to register Intel Vendor Specific Extended Capabilities (VSEC) from other drivers, move needed structures to the header file. Signed-off-by: David E. Box Reviewed-by: Ilpo Järvinen --- V3 - No change V2 - New patch splitting previous PATCH 1 drivers/platform/x86/intel/vsec.c | 35 ------------------------------ drivers/platform/x86/intel/vsec.h | 36 +++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 35 deletions(-) diff --git a/drivers/platform/x86/intel/vsec.c b/drivers/platform/x86/intel/vsec.c index ae811bb65910..6bb233a23414 100644 --- a/drivers/platform/x86/intel/vsec.c +++ b/drivers/platform/x86/intel/vsec.c @@ -24,13 +24,6 @@ #include "vsec.h" -/* Intel DVSEC offsets */ -#define INTEL_DVSEC_ENTRIES 0xA -#define INTEL_DVSEC_SIZE 0xB -#define INTEL_DVSEC_TABLE 0xC -#define INTEL_DVSEC_TABLE_BAR(x) ((x) & GENMASK(2, 0)) -#define INTEL_DVSEC_TABLE_OFFSET(x) ((x) & GENMASK(31, 3)) -#define TABLE_OFFSET_SHIFT 3 #define PMT_XA_START 0 #define PMT_XA_MAX INT_MAX #define PMT_XA_LIMIT XA_LIMIT(PMT_XA_START, PMT_XA_MAX) @@ -39,34 +32,6 @@ static DEFINE_IDA(intel_vsec_ida); static DEFINE_IDA(intel_vsec_sdsi_ida); static DEFINE_XARRAY_ALLOC(auxdev_array); -/** - * struct intel_vsec_header - Common fields of Intel VSEC and DVSEC registers. - * @rev: Revision ID of the VSEC/DVSEC register space - * @length: Length of the VSEC/DVSEC register space - * @id: ID of the feature - * @num_entries: Number of instances of the feature - * @entry_size: Size of the discovery table for each feature - * @tbir: BAR containing the discovery tables - * @offset: BAR offset of start of the first discovery table - */ -struct intel_vsec_header { - u8 rev; - u16 length; - u16 id; - u8 num_entries; - u8 entry_size; - u8 tbir; - u32 offset; -}; - -enum intel_vsec_id { - VSEC_ID_TELEMETRY = 2, - VSEC_ID_WATCHER = 3, - VSEC_ID_CRASHLOG = 4, - VSEC_ID_SDSI = 65, - VSEC_ID_TPMI = 66, -}; - static const char *intel_vsec_name(enum intel_vsec_id id) { switch (id) { diff --git a/drivers/platform/x86/intel/vsec.h b/drivers/platform/x86/intel/vsec.h index 0a6201b4a0e9..c242c07ea69c 100644 --- a/drivers/platform/x86/intel/vsec.h +++ b/drivers/platform/x86/intel/vsec.h @@ -11,9 +11,45 @@ #define VSEC_CAP_SDSI BIT(3) #define VSEC_CAP_TPMI BIT(4) +/* Intel DVSEC offsets */ +#define INTEL_DVSEC_ENTRIES 0xA +#define INTEL_DVSEC_SIZE 0xB +#define INTEL_DVSEC_TABLE 0xC +#define INTEL_DVSEC_TABLE_BAR(x) ((x) & GENMASK(2, 0)) +#define INTEL_DVSEC_TABLE_OFFSET(x) ((x) & GENMASK(31, 3)) +#define TABLE_OFFSET_SHIFT 3 + struct pci_dev; struct resource; +enum intel_vsec_id { + VSEC_ID_TELEMETRY = 2, + VSEC_ID_WATCHER = 3, + VSEC_ID_CRASHLOG = 4, + VSEC_ID_SDSI = 65, + VSEC_ID_TPMI = 66, +}; + +/** + * struct intel_vsec_header - Common fields of Intel VSEC and DVSEC registers. + * @rev: Revision ID of the VSEC/DVSEC register space + * @length: Length of the VSEC/DVSEC register space + * @id: ID of the feature + * @num_entries: Number of instances of the feature + * @entry_size: Size of the discovery table for each feature + * @tbir: BAR containing the discovery tables + * @offset: BAR offset of start of the first discovery table + */ +struct intel_vsec_header { + u8 rev; + u16 length; + u16 id; + u8 num_entries; + u8 entry_size; + u8 tbir; + u32 offset; +}; + enum intel_vsec_quirks { /* Watcher feature not supported */ VSEC_QUIRK_NO_WATCHER = BIT(0), From patchwork Thu Oct 12 02:38:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "David E. Box" X-Patchwork-Id: 151642 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp942525vqb; Wed, 11 Oct 2023 19:38:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFWSfAPbemBhrJSbPeLt2GUVH0HPZmIJSJypqJvZ0/Bav6Fi0K2YVpnzIZ6/4tltAODf6h1 X-Received: by 2002:a17:90b:1bce:b0:27c:ebab:5c60 with SMTP id oa14-20020a17090b1bce00b0027cebab5c60mr6187589pjb.2.1697078337295; Wed, 11 Oct 2023 19:38:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697078337; cv=none; d=google.com; s=arc-20160816; b=gYU+9tdWYkUHHbXtXEbV3haxl1Aqh9WnYO1uI7tERjf1DBLL579UhiWqvms5jq+JVw ebGpwYhtkChXS8is8XkE8xzEEkValk10OTYGjSIv0/zZaz0DuvQtE7FiUxLXBKxNtzSm Tb6m6oOMZ8iQrkgivYrHwMhD41uE8Kdn3o9Dprvj9NIQ9Iyct7Qzf47Qr9zxkMO9PgND EbN+rv8mp+AcqTxjCvGLZvwS+qHZi0nyhpDH8rE1U1C3YNGUbmHp8l3XGTG3ZiA//O9G pOB9RtPc9XpRT4b6L31x9KNeWRYsJ7V8dwPGYijI4Ep6XIh7bx2XFQqzplhmUvR6b1h+ mA3Q== 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=RW6CoM5IOJ2gjAzELDEVyIvmvI+FCz70bTjE3qpfnx8=; fh=d9G4dsZtlI8UONIvGKwhW94hCYEPGxy6CqYeKEG646A=; b=VvRM0jo7musS2+NY0jHoH0tHR7uI/XhJaNKUiuWxCm/XlmO6VW/EDMonTyNJkGRb2s LG+jpMB3N2OrhSIIj4EEft4jhnYdFr9EFhTSDewVWN+mIoM5J4AtjiJV9d2zj+zogA9E Vh8sTF00ExaP4yYXdxl0t/9AyftcqNEkexcF3V9lDzRO327Njy+j5jsosShPwMzTCuAa 62fQnqmpea2valyRX/KTxX3bM7mkhNsISdyKZ3rVK2O3PZNPjhnApLsQhTSGEkDOqoRR g/4bn3oa470V6MWOmucMaX1570xHY+zqMH1vtvLZ4Qe65k59oFZKPZzXhXG/ph1IZNgu NYZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=CWgYxSN9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id 16-20020a17090a195000b0027ce5a78453si1134332pjh.29.2023.10.11.19.38.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 19:38:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=CWgYxSN9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 6B901802FBA0; Wed, 11 Oct 2023 19:38:56 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376760AbjJLCis (ORCPT + 18 others); Wed, 11 Oct 2023 22:38:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233946AbjJLCin (ORCPT ); Wed, 11 Oct 2023 22:38:43 -0400 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80CDEB6; Wed, 11 Oct 2023 19:38:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697078322; x=1728614322; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=K3cYNR9dHNWIHJ58ypiFOF8RbjVsqUQwkNF18MKRWjs=; b=CWgYxSN95sIW9GyrosmSdr4X7kXPEIlWQIFA2BRpyEmvMIJVkMmSfrfz wgz7Axn9MQRZCv/UfMm8DM4UM0JAWPTu40s+zfXnSCJWxI6U55vn/GEZv 24gv/PWe0MAfF0lg0ZoThOySdiqc8V6Mno42tbdc7N8TdGL5Q6lOFi1oc 6zoUiOf7nblsuZ7hncZfTleXuQcDG4btAs8thRxjuu8ipIaoDXtoavNbR 0PvAvIUVbekqfolRHeGO6JV98thLGK4WeucB/H+fu1nuPW+p9qHJF3UJf 0hCBY8zBLX9lLz3V58tGYTqHy7rNWHT34asXCOOB/kPghccjDK5scSkP1 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="3402622" X-IronPort-AV: E=Sophos;i="6.03,217,1694761200"; d="scan'208";a="3402622" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 19:38:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="783507853" X-IronPort-AV: E=Sophos;i="6.03,217,1694761200"; d="scan'208";a="783507853" Received: from linux.intel.com ([10.54.29.200]) by orsmga008.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 19:38:41 -0700 Received: from debox1-desk4.intel.com (unknown [10.209.105.238]) by linux.intel.com (Postfix) with ESMTP id EB298580DBE; Wed, 11 Oct 2023 19:38:40 -0700 (PDT) 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 V3 02/16] platform/x86/intel/vsec: remove platform_info from vsec device structure Date: Wed, 11 Oct 2023 19:38:26 -0700 Message-Id: <20231012023840.3845703-3-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231012023840.3845703-1-david.e.box@linux.intel.com> References: <20231012023840.3845703-1-david.e.box@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Wed, 11 Oct 2023 19:38:56 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779515614583655000 X-GMAIL-MSGID: 1779515614583655000 In preparation for exporting an API to register Intel Vendor Specific Extended Capabilities (VSEC) from other drivers, remove the pointer to platform_info from intel_vsec_device. This prevents a potential page fault when auxiliary drivers probe and attempt to dereference this pointer to access the needed quirks field. Instead, just add the quirks to intel_vsec_device. Signed-off-by: David E. Box Reviewed-by: Ilpo Järvinen --- V3 - No change V2 - New patch splitting previous PATCH 1 drivers/platform/x86/intel/pmt/class.c | 2 +- drivers/platform/x86/intel/vsec.c | 2 +- drivers/platform/x86/intel/vsec.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/platform/x86/intel/pmt/class.c b/drivers/platform/x86/intel/pmt/class.c index f32a233470de..2ad91d2fd954 100644 --- a/drivers/platform/x86/intel/pmt/class.c +++ b/drivers/platform/x86/intel/pmt/class.c @@ -31,7 +31,7 @@ bool intel_pmt_is_early_client_hw(struct device *dev) * differences from the server platforms (which use the Out Of Band * Management Services Module OOBMSM). */ - return !!(ivdev->info->quirks & VSEC_QUIRK_EARLY_HW); + return !!(ivdev->quirks & VSEC_QUIRK_EARLY_HW); } EXPORT_SYMBOL_NS_GPL(intel_pmt_is_early_client_hw, INTEL_PMT); diff --git a/drivers/platform/x86/intel/vsec.c b/drivers/platform/x86/intel/vsec.c index 6bb233a23414..15866b7d3117 100644 --- a/drivers/platform/x86/intel/vsec.c +++ b/drivers/platform/x86/intel/vsec.c @@ -201,7 +201,7 @@ static int intel_vsec_add_dev(struct pci_dev *pdev, struct intel_vsec_header *he intel_vsec_dev->pcidev = pdev; intel_vsec_dev->resource = res; intel_vsec_dev->num_resources = header->num_entries; - intel_vsec_dev->info = info; + intel_vsec_dev->quirks = info->quirks; if (header->id == VSEC_ID_SDSI) intel_vsec_dev->ida = &intel_vsec_sdsi_ida; diff --git a/drivers/platform/x86/intel/vsec.h b/drivers/platform/x86/intel/vsec.h index c242c07ea69c..8b9fad170503 100644 --- a/drivers/platform/x86/intel/vsec.h +++ b/drivers/platform/x86/intel/vsec.h @@ -79,11 +79,11 @@ struct intel_vsec_device { struct pci_dev *pcidev; struct resource *resource; struct ida *ida; - struct intel_vsec_platform_info *info; int num_resources; int id; /* xa */ void *priv_data; size_t priv_data_size; + unsigned long quirks; }; int intel_vsec_add_aux(struct pci_dev *pdev, struct device *parent, From patchwork Thu Oct 12 02:38:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "David E. Box" X-Patchwork-Id: 151643 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp942543vqb; Wed, 11 Oct 2023 19:38:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEmz/4Uji9wSTCltHvStRB4amOfO3xsvyh7bJbvnCJLzOKKm7WjIjoARnMw9JH1vQnlrLCA X-Received: by 2002:a05:6a20:c18f:b0:16e:26fd:7c02 with SMTP id bg15-20020a056a20c18f00b0016e26fd7c02mr14361126pzb.2.1697078339659; Wed, 11 Oct 2023 19:38:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697078339; cv=none; d=google.com; s=arc-20160816; b=KLqJENzGLRtxMuVgr7a2pUONXcFpRx3deITyPvb/zI7HmHHYHpNYQ2AD8cT7ESniEp r8JBKUxaJTLSMNJrw10uQu5CTIT18uMOBVs+C9yxRURQr8tEJCldSCH4SDGDDSXv88P2 50qU2Ejll600Hha/67AJnfZ6v9fhI5YpZgD5XZFA3CidqbL8RBtiwxj3G6ePO7iInTnK yVuxHP2gxZmcgKTqbJZvnya3iS3+YS4IMGRfJQa1b/YZsjL/mLBHfkgXQrbpjH+/Pd96 loyg1K1noXGeGuZbFIq2FLJYzASONhaI3dFmShXZSbredMDJYy1wc369j/jeBNprk2cq 4LJA== 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=LSGakL5RLvb9KDMfon3EIACwIfqbOQIDxewJadLS5uo=; fh=d9G4dsZtlI8UONIvGKwhW94hCYEPGxy6CqYeKEG646A=; b=ieELTWkWz01PQsGgrvUIBluYU8ekz3YOQDPi+OPusxiQEnzYg8fWrono95PBkhrH59 RFtoQLN1VEepHMIeJaEShmcc5wIv7l+631bfR6dNaYudp9IApVjzvh59pSItvvTzGsRm Cd5uGVvhUZARBw/vDWZR0WvN9wpb5rOA3s9mpv8jgIup5YVhZkzGwyVh7fC5F4DHeR/r i7uEEE0UpQwtiFGSk6FJMGvw4NlLC9BBHKusUSSi+rCjC4kO3SRaOtOhe7ajkUYof7Ei LW4F4U9LTqnsJojgGWYQOSenjRhaWOsK1QCiKX0XqiICHLIPsP3bPwcBGxb2lS/RdY09 t9yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=SFxASy0A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id k1-20020a170902c40100b001beef8ccd05si1239692plk.489.2023.10.11.19.38.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 19:38:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=SFxASy0A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 2CCA4802583F; Wed, 11 Oct 2023 19:38:59 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376775AbjJLCiv (ORCPT + 18 others); Wed, 11 Oct 2023 22:38:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234053AbjJLCio (ORCPT ); Wed, 11 Oct 2023 22:38:44 -0400 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EF13A9; Wed, 11 Oct 2023 19:38:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697078323; x=1728614323; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=mdXRrafSW2vaWofevfN0nlDG8rsooz2jVNY8wgQKLnE=; b=SFxASy0AIWikny/QwYCKHUKEqrX35rFokCGnx5VF9h8aHAuKWBRcrbGm uMdUqpOe69sWj+DqNUdJ5pYrGPxm0AMoc625LzQNcRJz7nl5o7enXEL8+ GBhCe4ImmS0SEq4L859ZI52J/4NC3Bwufb6ViLOstJnOVcuIe++OyVlRc fZkIXbXxrpQu8+uPxvn745GALlg11c3xLdCOUnsmL6t+wqeDJT7HxrXTG ttZEJgSIoY/2hcTymAlvtc8AsaHs7cjJwHvfT+LakVlkZaj++hAaiUboR wvmSJJRpP79AZrJWxi5CEcKTjtI6FS/xb3rEqEt7R4uCLZjLH7FQakAxR A==; X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="3402623" X-IronPort-AV: E=Sophos;i="6.03,217,1694761200"; d="scan'208";a="3402623" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 19:38:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="783507858" X-IronPort-AV: E=Sophos;i="6.03,217,1694761200"; d="scan'208";a="783507858" Received: from linux.intel.com ([10.54.29.200]) by orsmga008.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 19:38:41 -0700 Received: from debox1-desk4.intel.com (unknown [10.209.105.238]) by linux.intel.com (Postfix) with ESMTP id 18E3A580E33; Wed, 11 Oct 2023 19:38:41 -0700 (PDT) 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 V3 03/16] platform/x86/intel/vsec: Use cleanup.h Date: Wed, 11 Oct 2023 19:38:27 -0700 Message-Id: <20231012023840.3845703-4-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231012023840.3845703-1-david.e.box@linux.intel.com> References: <20231012023840.3845703-1-david.e.box@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Wed, 11 Oct 2023 19:38:59 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779515617094260791 X-GMAIL-MSGID: 1779515617094260791 Use cleanup.h helpers to handle cleanup of resources in intel_vsec_add_dev() after failures. Signed-off-by: David E. Box --- V3 - New patch. drivers/platform/x86/intel/vsec.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/platform/x86/intel/vsec.c b/drivers/platform/x86/intel/vsec.c index 15866b7d3117..f03ab89ab7c0 100644 --- a/drivers/platform/x86/intel/vsec.c +++ b/drivers/platform/x86/intel/vsec.c @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -155,10 +156,10 @@ EXPORT_SYMBOL_NS_GPL(intel_vsec_add_aux, INTEL_VSEC); static int intel_vsec_add_dev(struct pci_dev *pdev, struct intel_vsec_header *header, struct intel_vsec_platform_info *info) { - struct intel_vsec_device *intel_vsec_dev; + struct intel_vsec_device __free(kfree) *intel_vsec_dev = NULL; struct resource *res, *tmp; unsigned long quirks = info->quirks; - int i; + int ret, i; if (!intel_vsec_supported(header->id, info->caps)) return -EINVAL; @@ -178,10 +179,8 @@ static int intel_vsec_add_dev(struct pci_dev *pdev, struct intel_vsec_header *he return -ENOMEM; res = kcalloc(header->num_entries, sizeof(*res), GFP_KERNEL); - if (!res) { - kfree(intel_vsec_dev); + if (!res) return -ENOMEM; - } if (quirks & VSEC_QUIRK_TABLE_SHIFT) header->offset >>= TABLE_OFFSET_SHIFT; @@ -208,8 +207,12 @@ static int intel_vsec_add_dev(struct pci_dev *pdev, struct intel_vsec_header *he else intel_vsec_dev->ida = &intel_vsec_ida; - return intel_vsec_add_aux(pdev, NULL, intel_vsec_dev, - intel_vsec_name(header->id)); + ret = intel_vsec_add_aux(pdev, NULL, intel_vsec_dev, + intel_vsec_name(header->id)); + + no_free_ptr(intel_vsec_dev); + + return ret; } static bool intel_vsec_walk_header(struct pci_dev *pdev, From patchwork Thu Oct 12 02:38:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "David E. Box" X-Patchwork-Id: 151645 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp942570vqb; Wed, 11 Oct 2023 19:39:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFthopwqAY6RtkM/IQ8jbEJqYyldagWZisNKIzbkF+35X9ToQ1CCHupVuLick0xMEOOD8GC X-Received: by 2002:a05:6a00:3916:b0:68e:2fd4:288a with SMTP id fh22-20020a056a00391600b0068e2fd4288amr25799514pfb.3.1697078344589; Wed, 11 Oct 2023 19:39:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697078344; cv=none; d=google.com; s=arc-20160816; b=cDumt9BUTqoouXjIBQNTAAVOqMbXuGsdZB02YW7lQApGnXeSufwYUg+k/UojEyABVA uOaugshceilAoHUF4skUnDjoBTeedGVhzZAFqvUf0KIy4zcswn1a6LrgSiCmq5EeVoRj MWKFehTg/9/aWq9AurQpwKXDE017sUlAksgq5NNnYvEGnH6MelWw+CvhzwKYRGVAsRfs hOWSoexVOJujnV0okaS+SVHIq5ml6SNZQhULZNRbP3BsOU3zbM6b9kbWfLItbV0yLrUF 7fvU8cChNsbWEAo7HcbAuXV2HBuWo86bxBSCjgHe/0+bai3uYjd9+1KTzZojSQ7UFDUE 5NDw== 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=x62bBweCxii8cWZbGBa3/NrGEyUkow/ztw3UP9ngrk0=; fh=d9G4dsZtlI8UONIvGKwhW94hCYEPGxy6CqYeKEG646A=; b=qxIk8aTQAeCvrSE3cOx/p7ug8xdIrTPDvtsH9SLJXwDWTOSAsbD5PXDZdc7za03+aT /RowTb0+1oywmCThaQo1ROIuEZoMlDoEJU6dz743KIdS7XnaSbCBRrOVapIa9CFzGjR5 avGRH3N87tDDotGX2B8/GNiN5coP9/9E2g15+QjE8MZPmeYO1EGdLDDH3yv1X5FCBMpI a3qfVMPVcmqe105AIDpDQI8p6ATgxmxQs8DDD14lmSAv3OOEVs/JTtcpvFP7+SY09mov SDLUiL4YjJ5pB6vOlsDekIb6tGdFAH+23HovghO598uLITm2M/v8V+Z1dok2bKCfrlMh uedw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hyY+l7KN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id c21-20020a056a000ad500b0068e3f3c6250si14496724pfl.343.2023.10.11.19.39.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 19:39:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hyY+l7KN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id A4B60813768B; Wed, 11 Oct 2023 19:39:03 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235284AbjJLCi6 (ORCPT + 18 others); Wed, 11 Oct 2023 22:38:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235266AbjJLCip (ORCPT ); Wed, 11 Oct 2023 22:38:45 -0400 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91B8AA4; Wed, 11 Oct 2023 19:38:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697078324; x=1728614324; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=SndSPJp6f/Dsiby12bNuX1NFU1+tow32oLCZ7DwzsmA=; b=hyY+l7KNyjvskz1UP8HpNypqo4CzmowVqEZxtIAOY6eb9feuQoRut1rs Ud7xhfjGXpBcdqx6EYtb968Tx4SwVSPEwc1PKeL9UQiML/f80q0DzvDGd RYdVfnkCee+Svh4M8UxHvxeT09IzdVU1byndKzprre7nGZbljtYrp0Vq4 gy9eGqjKVeHmNz+KSarqxQNhqsW08PfwyFx+l4Dvr3gZmzQNffdPKfgh1 5QKWpzbYBarKVsZaT0Whb27iF6MwN4WFRIaP9St7uYbxRFo9M4G29FX69 KVNLhs6DbKfBHkGnMYGEL6MTK7ePyLAVHIK9UEcimbOR5o77/JvbGq2dR A==; X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="3402624" X-IronPort-AV: E=Sophos;i="6.03,217,1694761200"; d="scan'208";a="3402624" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 19:38:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="783507859" X-IronPort-AV: E=Sophos;i="6.03,217,1694761200"; d="scan'208";a="783507859" Received: from linux.intel.com ([10.54.29.200]) by orsmga008.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 19:38:41 -0700 Received: from debox1-desk4.intel.com (unknown [10.209.105.238]) by linux.intel.com (Postfix) with ESMTP id 3F0AA580D79; Wed, 11 Oct 2023 19:38:41 -0700 (PDT) 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 V3 04/16] platform/x86/intel/vsec: Add intel_vsec_register Date: Wed, 11 Oct 2023 19:38:28 -0700 Message-Id: <20231012023840.3845703-5-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231012023840.3845703-1-david.e.box@linux.intel.com> References: <20231012023840.3845703-1-david.e.box@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Wed, 11 Oct 2023 19:39:03 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779515621977945898 X-GMAIL-MSGID: 1779515621977945898 From: Gayatri Kammela Add and export intel_vsec_register() to allow the registration of Intel extended capabilities from other drivers. Add check to look for memory conflicts before registering a new capability. Add a parent field to intel_vsec_platform_info to allow specifying the parent device for device managed cleanup. Signed-off-by: Gayatri Kammela Signed-off-by: David E. Box --- V3 - Replace kfree on request_mem_region fail with use of cleanup.h helper. V2 - New patch splitting previous PATCH 1 drivers/platform/x86/intel/vsec.c | 22 ++++++++++++++++++++-- drivers/platform/x86/intel/vsec.h | 4 ++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/intel/vsec.c b/drivers/platform/x86/intel/vsec.c index f03ab89ab7c0..1d005077024a 100644 --- a/drivers/platform/x86/intel/vsec.c +++ b/drivers/platform/x86/intel/vsec.c @@ -157,7 +157,8 @@ static int intel_vsec_add_dev(struct pci_dev *pdev, struct intel_vsec_header *he struct intel_vsec_platform_info *info) { struct intel_vsec_device __free(kfree) *intel_vsec_dev = NULL; - struct resource *res, *tmp; + struct resource __free(kfree) *res = NULL; + struct resource *tmp; unsigned long quirks = info->quirks; int ret, i; @@ -195,6 +196,12 @@ static int intel_vsec_add_dev(struct pci_dev *pdev, struct intel_vsec_header *he header->offset + i * (header->entry_size * sizeof(u32)); tmp->end = tmp->start + (header->entry_size * sizeof(u32)) - 1; tmp->flags = IORESOURCE_MEM; + + /* Check resource is not in use */ + if (!request_mem_region(tmp->start, resource_size(tmp), "")) + return -EBUSY; + + release_mem_region(tmp->start, resource_size(tmp)); } intel_vsec_dev->pcidev = pdev; @@ -207,9 +214,10 @@ static int intel_vsec_add_dev(struct pci_dev *pdev, struct intel_vsec_header *he else intel_vsec_dev->ida = &intel_vsec_ida; - ret = intel_vsec_add_aux(pdev, NULL, intel_vsec_dev, + ret = intel_vsec_add_aux(pdev, info->parent, intel_vsec_dev, intel_vsec_name(header->id)); + no_free_ptr(res); no_free_ptr(intel_vsec_dev); return ret; @@ -329,6 +337,16 @@ static bool intel_vsec_walk_vsec(struct pci_dev *pdev, return have_devices; } +void intel_vsec_register(struct pci_dev *pdev, + struct intel_vsec_platform_info *info) +{ + if (!pdev || !info) + return; + + intel_vsec_walk_header(pdev, info); +} +EXPORT_SYMBOL_NS_GPL(intel_vsec_register, INTEL_VSEC); + static int intel_vsec_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) { struct intel_vsec_platform_info *info; diff --git a/drivers/platform/x86/intel/vsec.h b/drivers/platform/x86/intel/vsec.h index 8b9fad170503..bb8b6452df70 100644 --- a/drivers/platform/x86/intel/vsec.h +++ b/drivers/platform/x86/intel/vsec.h @@ -69,6 +69,7 @@ enum intel_vsec_quirks { /* Platform specific data */ struct intel_vsec_platform_info { + struct device *parent; struct intel_vsec_header **headers; unsigned long caps; unsigned long quirks; @@ -99,4 +100,7 @@ static inline struct intel_vsec_device *auxdev_to_ivdev(struct auxiliary_device { return container_of(auxdev, struct intel_vsec_device, auxdev); } + +void intel_vsec_register(struct pci_dev *pdev, + struct intel_vsec_platform_info *info); #endif From patchwork Thu Oct 12 02:38:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "David E. Box" X-Patchwork-Id: 151648 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp942639vqb; Wed, 11 Oct 2023 19:39:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGue07tOed23wT0vIZdJh3ZzkQ7GtmBUsy6El1Kyy0IAAIhK01nyv75KsUTcD9U3p1uNpFE X-Received: by 2002:a05:6870:1d0e:b0:1e9:9e04:1d24 with SMTP id pa14-20020a0568701d0e00b001e99e041d24mr2947530oab.5.1697078358663; Wed, 11 Oct 2023 19:39:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697078358; cv=none; d=google.com; s=arc-20160816; b=aeEebhTUrTKUHZgsfSWvUtzBYrzGUw3Aw69qiZ224kdVMJAGGvd2plCC0BSSUcunAy sb0OyxGrrJnkF4NMxC5WA5ASDwGBL6xMZI92FI6gJTlS8f4tLSt6zTWauqfX5bXPSp4P ZGtA4mZXxWME7bllN6DTUHHrNW67Zzsp0UdLhovwPDbp/heW2cOUonADvyg9BElozjsO UAtRbiQajxJEXWgUcYUBiWDbBAk3Fe+cEQcNX3eLgq8EcnZP3co3Y0BoCwAideanvcUq vOcx1yb0g/0vJoJ63D5WEBUN2bAtwRRRG6CVRJffAVxz0LvA17v6Ap8ctDXy4O4wi08h 5tAg== 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=Pnon3v3HEid4PIvbI8C5TxluM2pja92nS7cQTVYE9Qg=; fh=d9G4dsZtlI8UONIvGKwhW94hCYEPGxy6CqYeKEG646A=; b=zXxuMg/kcG6rOf8POTVdiK++WvG0ZZbw6BG/XWeutIovBW8J09/tMFd1isisi9E3Qs YnJs7vlvjPLdWbvTalYkUA1zd3WZ4ijmzXMP+mMUi/beZOX0SidqffchDaIoNTSefYM6 T7fpTDydv/uQiIxq6VrgzoAKRHRMBPBuE3O+ZPRBWTVnw18YJu094tlHKSLS0ohb/gy0 lkOF0nypJ1OAZyEhEljfJzeugXnZeOqONc3ktgck9+AEir8Py/ylR5wTbhjpKdqZo8oN kvSTGiuaBcKkGL2primpUAeruWuQbRYsSMqk9WmAidafyFhoFXO4bEpvvsCu+PoEy9cA webw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=n++Rde7P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id g6-20020a636b06000000b0058a4883e6casi1057364pgc.225.2023.10.11.19.39.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 19:39:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=n++Rde7P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 78B6C81E64A4; Wed, 11 Oct 2023 19:39:17 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376909AbjJLCjL (ORCPT + 18 others); Wed, 11 Oct 2023 22:39:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376688AbjJLCiq (ORCPT ); Wed, 11 Oct 2023 22:38:46 -0400 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8B47BA; Wed, 11 Oct 2023 19:38:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697078324; x=1728614324; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=pO1E3835P+LdNYS0j3twJPg5eBQFsYzBKgSmmSamrCI=; b=n++Rde7Plr6z3JZ+gROR5DBpiNiaGnqM2ndGDhifvBfyk90AhxIYQ2Z5 FIN1t17zz4ifmWS82fYkIZhelP1mn8F9CIzwB2r1brvctsr5ZxSqPwWQL 7IgVCdmeZCFLUjyd2XPFCZ9X8sHvfq31cFfUV7RaPMAud7jgk0PjxVixk PD+SeFQ0oK1bbbSEN55pRdNZY00bkYdUp1VLSwiNbQNno98bkGCfsl3bA o+HwThNRCFWW7d6bHv3wccaoLqr15wJSOp/5qeA3AHA/APAcVMEnNbhiN AlevIna7+5YfUMvLPD8v+eCwUwxakBY8u+ILwbs5+Qo9M+VJSyuxlWCUX g==; X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="3402625" X-IronPort-AV: E=Sophos;i="6.03,217,1694761200"; d="scan'208";a="3402625" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 19:38:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="783507861" X-IronPort-AV: E=Sophos;i="6.03,217,1694761200"; d="scan'208";a="783507861" Received: from linux.intel.com ([10.54.29.200]) by orsmga008.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 19:38:41 -0700 Received: from debox1-desk4.intel.com (unknown [10.209.105.238]) by linux.intel.com (Postfix) with ESMTP id 6321D580D95; Wed, 11 Oct 2023 19:38:41 -0700 (PDT) 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 V3 05/16] platform/x86/intel/vsec: Add base address field Date: Wed, 11 Oct 2023 19:38:29 -0700 Message-Id: <20231012023840.3845703-6-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231012023840.3845703-1-david.e.box@linux.intel.com> References: <20231012023840.3845703-1-david.e.box@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Wed, 11 Oct 2023 19:39:17 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779515636915420849 X-GMAIL-MSGID: 1779515636915420849 Some devices may emulate PCI VSEC capabilities in MMIO. In such cases the BAR is not readable from a config space. Provide a field for drivers to indicate the base address to be used. Signed-off-by: David E. Box Reviewed-by: Ilpo Järvinen --- V3 - No change V2 - No change drivers/platform/x86/intel/pmt/class.c | 14 +++++++++++--- drivers/platform/x86/intel/vsec.c | 10 ++++++++-- drivers/platform/x86/intel/vsec.h | 2 ++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/drivers/platform/x86/intel/pmt/class.c b/drivers/platform/x86/intel/pmt/class.c index 2ad91d2fd954..32608baaa56c 100644 --- a/drivers/platform/x86/intel/pmt/class.c +++ b/drivers/platform/x86/intel/pmt/class.c @@ -160,10 +160,11 @@ static struct class intel_pmt_class = { static int intel_pmt_populate_entry(struct intel_pmt_entry *entry, struct intel_pmt_header *header, - struct device *dev, + struct intel_vsec_device *ivdev, struct resource *disc_res) { - struct pci_dev *pci_dev = to_pci_dev(dev->parent); + struct pci_dev *pci_dev = ivdev->pcidev; + struct device *dev = &ivdev->auxdev.dev; u8 bir; /* @@ -215,6 +216,13 @@ static int intel_pmt_populate_entry(struct intel_pmt_entry *entry, break; case ACCESS_BARID: + /* Use the provided base address if it exists */ + if (ivdev->base_addr) { + entry->base_addr = ivdev->base_addr + + GET_ADDRESS(header->base_offset); + break; + } + /* * If another BAR was specified then the base offset * represents the offset within that BAR. SO retrieve the @@ -319,7 +327,7 @@ int intel_pmt_dev_create(struct intel_pmt_entry *entry, struct intel_pmt_namespa if (ret) return ret; - ret = intel_pmt_populate_entry(entry, &header, dev, disc_res); + ret = intel_pmt_populate_entry(entry, &header, intel_vsec_dev, disc_res); if (ret) return ret; diff --git a/drivers/platform/x86/intel/vsec.c b/drivers/platform/x86/intel/vsec.c index 1d005077024a..5e18a06395e0 100644 --- a/drivers/platform/x86/intel/vsec.c +++ b/drivers/platform/x86/intel/vsec.c @@ -160,6 +160,7 @@ static int intel_vsec_add_dev(struct pci_dev *pdev, struct intel_vsec_header *he struct resource __free(kfree) *res = NULL; struct resource *tmp; unsigned long quirks = info->quirks; + u64 base_addr; int ret, i; if (!intel_vsec_supported(header->id, info->caps)) @@ -186,14 +187,18 @@ static int intel_vsec_add_dev(struct pci_dev *pdev, struct intel_vsec_header *he if (quirks & VSEC_QUIRK_TABLE_SHIFT) header->offset >>= TABLE_OFFSET_SHIFT; + if (info->base_addr) + base_addr = info->base_addr; + else + base_addr = pdev->resource[header->tbir].start; + /* * The DVSEC/VSEC contains the starting offset and count for a block of * discovery tables. Create a resource array of these tables to the * auxiliary device driver. */ for (i = 0, tmp = res; i < header->num_entries; i++, tmp++) { - tmp->start = pdev->resource[header->tbir].start + - header->offset + i * (header->entry_size * sizeof(u32)); + tmp->start = base_addr + header->offset + i * (header->entry_size * sizeof(u32)); tmp->end = tmp->start + (header->entry_size * sizeof(u32)) - 1; tmp->flags = IORESOURCE_MEM; @@ -208,6 +213,7 @@ static int intel_vsec_add_dev(struct pci_dev *pdev, struct intel_vsec_header *he intel_vsec_dev->resource = res; intel_vsec_dev->num_resources = header->num_entries; intel_vsec_dev->quirks = info->quirks; + intel_vsec_dev->base_addr = info->base_addr; if (header->id == VSEC_ID_SDSI) intel_vsec_dev->ida = &intel_vsec_sdsi_ida; diff --git a/drivers/platform/x86/intel/vsec.h b/drivers/platform/x86/intel/vsec.h index bb8b6452df70..e23e76129691 100644 --- a/drivers/platform/x86/intel/vsec.h +++ b/drivers/platform/x86/intel/vsec.h @@ -73,6 +73,7 @@ struct intel_vsec_platform_info { struct intel_vsec_header **headers; unsigned long caps; unsigned long quirks; + u64 base_addr; }; struct intel_vsec_device { @@ -85,6 +86,7 @@ struct intel_vsec_device { void *priv_data; size_t priv_data_size; unsigned long quirks; + u64 base_addr; }; int intel_vsec_add_aux(struct pci_dev *pdev, struct device *parent, From patchwork Thu Oct 12 02:38:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "David E. Box" X-Patchwork-Id: 151649 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp942653vqb; Wed, 11 Oct 2023 19:39:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGXsQlWQN87YCEyBfUFMKzGaUc+4ECd2ogOk8L1tnNBQFR7rh9bY3cAMTNy+UIO3rMv0dJb X-Received: by 2002:a17:902:f686:b0:1c7:5581:f9c with SMTP id l6-20020a170902f68600b001c755810f9cmr24987270plg.0.1697078362009; Wed, 11 Oct 2023 19:39:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697078361; cv=none; d=google.com; s=arc-20160816; b=X2JTHynMHSNI2G+zXGuJ4P2LOIGnTQF4hMXyqmcai/NQN+ZVNDb5N1+1kpkW3dBH2L VN2v4Bmz6bw3BAuKc2YbIa6WvHrUdYAr0NsQS0cAC8l8lD+pPbNGC2WiNmpDSjo+KJhO APisTP62JlrpaJifJpp/V+UMIY+Rf3H8U2PuHxaCfwcl8VDRlDoJX0ezoVQ6OAFDQmIR 6ieMQno+seDyP4XtJPpkmBNTVVnibHEkdkOpJysuWFrxUrXDOLVYxY0BMkurMfrlLJsS EtL8U8DyrkjVgqPLe7iN+Tha43cj1LYltFWMcCrZvNX0yeK6b0/vyrgNWfjl9TthUOQD +pxQ== 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=bS3rYTqq3JrNjdNA6rIY1I/qDeFplEitgR12cWu/Z2I=; fh=d9G4dsZtlI8UONIvGKwhW94hCYEPGxy6CqYeKEG646A=; b=qJA2Xakaap1A3kQQXhWgiDcJzm6SlcFh0bcPl8WY1WCp8GwaSX6QdKwmwH67U/D0XD 6PN3kLlcVNkefXGuEeCqIrZvT2+gzdpe7jhVz5BVEMQNTXDe3jp5cdd4stTGt8uJc/lU cNDMHPO207tOcggEn6uxvznC1xcXK6XQ6x8br+RP67Yrm970IeQRvuGuEIlPzs+xn8XQ VU6ELTCsCFdcEd6fyk5OkRAvN9aWMXZ8yabXd5OXeufW35eQrmnb/BH+Xs2nUiOSNFBh zUyspGsWCr0XuzAScW7ys7DzZJlPchwrx769X2R+MvpGHySJlIHnOw0ySfJ7TcDUYrl6 u87g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="VCF8ET/c"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id 12-20020a170902c20c00b001c5f15d24ffsi1028433pll.116.2023.10.11.19.39.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 19:39:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="VCF8ET/c"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 9169D80C9C8B; Wed, 11 Oct 2023 19:39:20 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376929AbjJLCjN (ORCPT + 18 others); Wed, 11 Oct 2023 22:39:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376685AbjJLCiq (ORCPT ); Wed, 11 Oct 2023 22:38:46 -0400 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EAE3B6; Wed, 11 Oct 2023 19:38:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697078324; x=1728614324; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=li3+HBcLfyqaB5i1kzrDK0rUdYK4HddNZ3J91qCSsyA=; b=VCF8ET/cgcSJuwntkK8FpbxXub1PRyp9ic+EEmzWB/Pq6Iib+CzvY0/U dweyvMVL5NuFqInHC+gu49/t4R+Ima9t9hxEG+mXcfCSvHZ0FiagUt3Wo fdU6HoyK8tTlWa10XNvPfhVcy2LtD8tBl5cMzilT2Yf1LsaYWr4zye5Rb WDgt4lOzr9Qf6Gvp7vvHKoBqlPktKTEC1w5TwgYeMcoKWR48UKVskFybR ecpThg5aYBWDzhn08HtvkT6Xa2uDhY/qT0IWDHYjtwTqxQOLKz0n5uoQK eFErVfJpTcVDxuqhhNLx3wi5aJWe6oWThxYVtfD83fLC0dhEC1qsjJK5X w==; X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="3402626" X-IronPort-AV: E=Sophos;i="6.03,217,1694761200"; d="scan'208";a="3402626" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 19:38:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="783507863" X-IronPort-AV: E=Sophos;i="6.03,217,1694761200"; d="scan'208";a="783507863" Received: from linux.intel.com ([10.54.29.200]) by orsmga008.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 19:38:41 -0700 Received: from debox1-desk4.intel.com (unknown [10.209.105.238]) by linux.intel.com (Postfix) with ESMTP id 8B458580D79; Wed, 11 Oct 2023 19:38:41 -0700 (PDT) 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 V3 06/16] platform/x86/intel/pmt: Add header to struct intel_pmt_entry Date: Wed, 11 Oct 2023 19:38:30 -0700 Message-Id: <20231012023840.3845703-7-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231012023840.3845703-1-david.e.box@linux.intel.com> References: <20231012023840.3845703-1-david.e.box@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Wed, 11 Oct 2023 19:39:20 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779515640097302694 X-GMAIL-MSGID: 1779515640097302694 The PMT header is passed to several functions. Instead, store the header in struct intel_pmt_entry which is also passed to these functions and shorten the argument list. This simplifies the calls in preparation for later changes. Signed-off-by: David E. Box Reviewed-by: Ilpo Järvinen --- V3 - No change V2 - No change drivers/platform/x86/intel/pmt/class.c | 8 +++----- drivers/platform/x86/intel/pmt/class.h | 16 ++++++++-------- drivers/platform/x86/intel/pmt/crashlog.c | 2 +- drivers/platform/x86/intel/pmt/telemetry.c | 2 +- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/drivers/platform/x86/intel/pmt/class.c b/drivers/platform/x86/intel/pmt/class.c index 32608baaa56c..142a24e3727d 100644 --- a/drivers/platform/x86/intel/pmt/class.c +++ b/drivers/platform/x86/intel/pmt/class.c @@ -159,12 +159,12 @@ static struct class intel_pmt_class = { }; static int intel_pmt_populate_entry(struct intel_pmt_entry *entry, - struct intel_pmt_header *header, struct intel_vsec_device *ivdev, struct resource *disc_res) { struct pci_dev *pci_dev = ivdev->pcidev; struct device *dev = &ivdev->auxdev.dev; + struct intel_pmt_header *header = &entry->header; u8 bir; /* @@ -313,7 +313,6 @@ int intel_pmt_dev_create(struct intel_pmt_entry *entry, struct intel_pmt_namespa struct intel_vsec_device *intel_vsec_dev, int idx) { struct device *dev = &intel_vsec_dev->auxdev.dev; - struct intel_pmt_header header; struct resource *disc_res; int ret; @@ -323,16 +322,15 @@ int intel_pmt_dev_create(struct intel_pmt_entry *entry, struct intel_pmt_namespa if (IS_ERR(entry->disc_table)) return PTR_ERR(entry->disc_table); - ret = ns->pmt_header_decode(entry, &header, dev); + ret = ns->pmt_header_decode(entry, dev); if (ret) return ret; - ret = intel_pmt_populate_entry(entry, &header, intel_vsec_dev, disc_res); + ret = intel_pmt_populate_entry(entry, intel_vsec_dev, disc_res); if (ret) return ret; return intel_pmt_dev_register(entry, ns, dev); - } EXPORT_SYMBOL_NS_GPL(intel_pmt_dev_create, INTEL_PMT); diff --git a/drivers/platform/x86/intel/pmt/class.h b/drivers/platform/x86/intel/pmt/class.h index db11d58867ce..e477a19f6700 100644 --- a/drivers/platform/x86/intel/pmt/class.h +++ b/drivers/platform/x86/intel/pmt/class.h @@ -18,7 +18,15 @@ #define GET_BIR(v) ((v) & GENMASK(2, 0)) #define GET_ADDRESS(v) ((v) & GENMASK(31, 3)) +struct intel_pmt_header { + u32 base_offset; + u32 size; + u32 guid; + u8 access_type; +}; + struct intel_pmt_entry { + struct intel_pmt_header header; struct bin_attribute pmt_bin_attr; struct kobject *kobj; void __iomem *disc_table; @@ -29,19 +37,11 @@ struct intel_pmt_entry { int devid; }; -struct intel_pmt_header { - u32 base_offset; - u32 size; - u32 guid; - u8 access_type; -}; - struct intel_pmt_namespace { const char *name; struct xarray *xa; const struct attribute_group *attr_grp; int (*pmt_header_decode)(struct intel_pmt_entry *entry, - struct intel_pmt_header *header, struct device *dev); }; diff --git a/drivers/platform/x86/intel/pmt/crashlog.c b/drivers/platform/x86/intel/pmt/crashlog.c index bbb3d61d09f4..4014c02cafdb 100644 --- a/drivers/platform/x86/intel/pmt/crashlog.c +++ b/drivers/platform/x86/intel/pmt/crashlog.c @@ -223,10 +223,10 @@ static const struct attribute_group pmt_crashlog_group = { }; static int pmt_crashlog_header_decode(struct intel_pmt_entry *entry, - struct intel_pmt_header *header, struct device *dev) { void __iomem *disc_table = entry->disc_table; + struct intel_pmt_header *header = &entry->header; struct crashlog_entry *crashlog; if (!pmt_crashlog_supported(entry)) diff --git a/drivers/platform/x86/intel/pmt/telemetry.c b/drivers/platform/x86/intel/pmt/telemetry.c index 39cbc87cc28a..f86080e8bebd 100644 --- a/drivers/platform/x86/intel/pmt/telemetry.c +++ b/drivers/platform/x86/intel/pmt/telemetry.c @@ -58,10 +58,10 @@ static bool pmt_telem_region_overlaps(struct intel_pmt_entry *entry, } static int pmt_telem_header_decode(struct intel_pmt_entry *entry, - struct intel_pmt_header *header, struct device *dev) { void __iomem *disc_table = entry->disc_table; + struct intel_pmt_header *header = &entry->header; if (pmt_telem_region_overlaps(entry, dev)) return 1; From patchwork Thu Oct 12 02:38:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "David E. Box" X-Patchwork-Id: 151646 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp942601vqb; Wed, 11 Oct 2023 19:39:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHjzIhw1qKab83F3OucBZBGNbT3T6CO2cNuRf9Y2yYuoClqmT0Kn6rsb/2ekrpxBEjvsZHU X-Received: by 2002:a05:6a00:1d8f:b0:692:afaf:32b4 with SMTP id z15-20020a056a001d8f00b00692afaf32b4mr24705340pfw.0.1697078351609; Wed, 11 Oct 2023 19:39:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697078351; cv=none; d=google.com; s=arc-20160816; b=NsEjxPfFEhDjR9zeROijn5dv1FFq96Apn316Gfr6Gf0xth73TKgTfQQ7K7wZ4BRrxY 53xjbpzoIRcs1ZzuuhAh45bTJUSpHRJkdEexnmodUI08tnt7nryfzTdEJqF7deitucJY +q6bol1+WlpDFHhIwjXahsrF9yvCqlkGFqL8vTVWIKdAoeV9VKDPL+1ZdfZOuuMeS+B3 isVBCWl+LdSJYwWwQCbQu5vkpUj4gpU0f9Gar49jHLPl9XPs9T9lnyIUEiaIgSuD2Nnm VgfkFjz3lY3nwWPcM2DUD6WGbvZBnprqcxOFSBVN7vlLWqV3GQWmKqMyPl8rX0oEpvrq nGGA== 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=pK7uAJ9yPGy3iyr5fIALbRmnt71kQ+nAlksVWhH+5/o=; fh=d9G4dsZtlI8UONIvGKwhW94hCYEPGxy6CqYeKEG646A=; b=XPAOj8Ek/XafvdPdxBoaRLlz/T9UQi36pmJpnqqJLDBcXPU+YsqeuJKb4Y3p8fNckF GUrV7biQ1hwOHNP6m4p1dO26Ec3B8f6pVxAwIWzJpVzrcXOBaWHO1AjP6Zmrdnla1uK/ X07zHlB9juaUSOedd7uiJilKPKGflnrxBi56KUSOrvTWZKhTKqnTIwJnMxKUPyEJho1k 3Gt9kd5kieOaF6nZU7CJABYJr7u435FGzmYRFq19IAqLtL0WItq4vH4VkPIZ4XsKsw8q uaeImdyqM2diCLXxNN+XN/3aQUtr1AKR6kvWU8+KkXY6R14zLznPwpczWYoGsqDZBD3C tldw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QJ3wui13; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id r26-20020a63441a000000b00578e98dec9dsi1091974pga.160.2023.10.11.19.39.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 19:39:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QJ3wui13; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 3C05481B94CD; Wed, 11 Oct 2023 19:39:10 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376856AbjJLCjB (ORCPT + 18 others); Wed, 11 Oct 2023 22:39:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232321AbjJLCip (ORCPT ); Wed, 11 Oct 2023 22:38:45 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C013EB7; Wed, 11 Oct 2023 19:38:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697078322; x=1728614322; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=GCbXbMp6rA7KWMQHfNpw0ennIHhIrIHoV7CLFQMGNwQ=; b=QJ3wui13KmMCjdfKozL8thUU7wHr+bleLWd4yqX9y20NTIq0wmlCRAOt Ybn6PFaa9LUHouOJNO7InBQ9UM7jhYGd6R4Xd6s73wTIM5QkCIBzEQODN w0+8YILDI3PnF+D8EeVRQbhWdGgsaDoumXJ0Ojpsb586i1Q3Urr4ikkqH 8/Nn+RZQGdUAPgG1LDm5kx9fgKOv4xe/w712Qp+jjLfkNafSgg9yHI3ZF K2srLaHgyLYijpmrkZqx2DDqcFqLZFe2PI7Wopimv1OspvTGOhTzTOOSI QLbvsf88dSPJtQ5PHifhNFYUQfx0yjTPVyJyfnq5B/joGUbP9tI2OIeYt A==; X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="365090376" X-IronPort-AV: E=Sophos;i="6.03,217,1694761200"; d="scan'208";a="365090376" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 19:38:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="824411675" X-IronPort-AV: E=Sophos;i="6.03,217,1694761200"; d="scan'208";a="824411675" Received: from linux.intel.com ([10.54.29.200]) by fmsmga004.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 19:38:42 -0700 Received: from debox1-desk4.intel.com (unknown [10.209.105.238]) by linux.intel.com (Postfix) with ESMTP id ADE7C580D95; Wed, 11 Oct 2023 19:38:41 -0700 (PDT) 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 V3 07/16] platform/x86/intel/pmt: telemetry: Export API to read telemetry Date: Wed, 11 Oct 2023 19:38:31 -0700 Message-Id: <20231012023840.3845703-8-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231012023840.3845703-1-david.e.box@linux.intel.com> References: <20231012023840.3845703-1-david.e.box@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Wed, 11 Oct 2023 19:39:10 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779515629749875095 X-GMAIL-MSGID: 1779515629749875095 Export symbols to allow access to Intel PMT Telemetry data on available devices. Provides APIs to search, register, and read telemetry using a kref managed pointer that serves as a handle to a telemetry endpoint. To simplify searching for present devices, have the IDA start at 1 instead of 0 so that 0 can be used to indicate end of search. Signed-off-by: David E. Box Reviewed-by: Ilpo Järvinen --- V3 - Add comment for mutex lock - Fix multiline comments - Fix line lengths - Fix space/tab inconsistences in header doc V2 - Add explanation of PMT_XA_START change in changelog - change return and argument type of pmt_telem_get_next_endpoint() to unsigned long - style fixes drivers/platform/x86/intel/pmt/class.c | 21 ++- drivers/platform/x86/intel/pmt/class.h | 14 ++ drivers/platform/x86/intel/pmt/telemetry.c | 191 ++++++++++++++++++++- drivers/platform/x86/intel/pmt/telemetry.h | 126 ++++++++++++++ 4 files changed, 344 insertions(+), 8 deletions(-) create mode 100644 drivers/platform/x86/intel/pmt/telemetry.h diff --git a/drivers/platform/x86/intel/pmt/class.c b/drivers/platform/x86/intel/pmt/class.c index 142a24e3727d..4b53940a64e2 100644 --- a/drivers/platform/x86/intel/pmt/class.c +++ b/drivers/platform/x86/intel/pmt/class.c @@ -17,7 +17,7 @@ #include "../vsec.h" #include "class.h" -#define PMT_XA_START 0 +#define PMT_XA_START 1 #define PMT_XA_MAX INT_MAX #define PMT_XA_LIMIT XA_LIMIT(PMT_XA_START, PMT_XA_MAX) #define GUID_SPR_PUNIT 0x9956f43f @@ -247,6 +247,7 @@ static int intel_pmt_dev_register(struct intel_pmt_entry *entry, struct intel_pmt_namespace *ns, struct device *parent) { + struct intel_vsec_device *ivdev = dev_to_ivdev(parent); struct resource res = {0}; struct device *dev; int ret; @@ -270,7 +271,7 @@ static int intel_pmt_dev_register(struct intel_pmt_entry *entry, if (ns->attr_grp) { ret = sysfs_create_group(entry->kobj, ns->attr_grp); if (ret) - goto fail_sysfs; + goto fail_sysfs_create_group; } /* if size is 0 assume no data buffer, so no file needed */ @@ -295,13 +296,23 @@ static int intel_pmt_dev_register(struct intel_pmt_entry *entry, entry->pmt_bin_attr.size = entry->size; ret = sysfs_create_bin_file(&dev->kobj, &entry->pmt_bin_attr); - if (!ret) - return 0; + if (ret) + goto fail_ioremap; + if (ns->pmt_add_endpoint) { + ret = ns->pmt_add_endpoint(entry, ivdev->pcidev); + if (ret) + goto fail_add_endpoint; + } + + return 0; + +fail_add_endpoint: + sysfs_remove_bin_file(entry->kobj, &entry->pmt_bin_attr); fail_ioremap: if (ns->attr_grp) sysfs_remove_group(entry->kobj, ns->attr_grp); -fail_sysfs: +fail_sysfs_create_group: device_unregister(dev); fail_dev_create: xa_erase(ns->xa, entry->devid); diff --git a/drivers/platform/x86/intel/pmt/class.h b/drivers/platform/x86/intel/pmt/class.h index e477a19f6700..d23c63b73ab7 100644 --- a/drivers/platform/x86/intel/pmt/class.h +++ b/drivers/platform/x86/intel/pmt/class.h @@ -9,6 +9,7 @@ #include #include "../vsec.h" +#include "telemetry.h" /* PMT access types */ #define ACCESS_BARID 2 @@ -18,6 +19,16 @@ #define GET_BIR(v) ((v) & GENMASK(2, 0)) #define GET_ADDRESS(v) ((v) & GENMASK(31, 3)) +struct pci_dev; + +struct telem_endpoint { + struct pci_dev *pcidev; + struct telem_header header; + void __iomem *base; + bool present; + struct kref kref; +}; + struct intel_pmt_header { u32 base_offset; u32 size; @@ -26,6 +37,7 @@ struct intel_pmt_header { }; struct intel_pmt_entry { + struct telem_endpoint *ep; struct intel_pmt_header header; struct bin_attribute pmt_bin_attr; struct kobject *kobj; @@ -43,6 +55,8 @@ 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); }; bool intel_pmt_is_early_client_hw(struct device *dev); diff --git a/drivers/platform/x86/intel/pmt/telemetry.c b/drivers/platform/x86/intel/pmt/telemetry.c index f86080e8bebd..09258564dfc4 100644 --- a/drivers/platform/x86/intel/pmt/telemetry.c +++ b/drivers/platform/x86/intel/pmt/telemetry.c @@ -30,6 +30,15 @@ /* Used by client hardware to identify a fixed telemetry entry*/ #define TELEM_CLIENT_FIXED_BLOCK_GUID 0x10000000 +#define NUM_BYTES_QWORD(v) ((v) << 3) +#define SAMPLE_ID_OFFSET(v) ((v) << 3) + +#define NUM_BYTES_DWORD(v) ((v) << 2) +#define SAMPLE_ID_OFFSET32(v) ((v) << 2) + +/* Protects access to the xarray of telemetry endpoint handles */ +static DEFINE_MUTEX(ep_lock); + enum telem_type { TELEM_TYPE_PUNIT = 0, TELEM_TYPE_CRASHLOG, @@ -84,21 +93,195 @@ 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) +{ + struct telem_endpoint *ep; + + /* Endpoint lifetimes are managed by kref, not devres */ + entry->ep = kzalloc(sizeof(*(entry->ep)), GFP_KERNEL); + if (!entry->ep) + return -ENOMEM; + + ep = entry->ep; + ep->pcidev = pdev; + 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; + + kref_init(&ep->kref); + + return 0; +} + static DEFINE_XARRAY_ALLOC(telem_array); static struct intel_pmt_namespace pmt_telem_ns = { .name = "telem", .xa = &telem_array, .pmt_header_decode = pmt_telem_header_decode, + .pmt_add_endpoint = pmt_telem_add_endpoint, }; +/* Called when all users unregister and the device is removed */ +static void pmt_telem_ep_release(struct kref *kref) +{ + struct telem_endpoint *ep; + + ep = container_of(kref, struct telem_endpoint, kref); + kfree(ep); +} + +unsigned long pmt_telem_get_next_endpoint(unsigned long start) +{ + struct intel_pmt_entry *entry; + unsigned long found_idx; + + mutex_lock(&ep_lock); + xa_for_each_start(&telem_array, found_idx, entry, start) { + /* + * Return first found index after start. + * 0 is not valid id. + */ + if (found_idx > start) + break; + } + mutex_unlock(&ep_lock); + + return found_idx == start ? 0 : found_idx; +} +EXPORT_SYMBOL_NS_GPL(pmt_telem_get_next_endpoint, INTEL_PMT_TELEMETRY); + +struct telem_endpoint *pmt_telem_register_endpoint(int devid) +{ + struct intel_pmt_entry *entry; + unsigned long index = devid; + + mutex_lock(&ep_lock); + entry = xa_find(&telem_array, &index, index, XA_PRESENT); + if (!entry) { + mutex_unlock(&ep_lock); + return ERR_PTR(-ENXIO); + } + + kref_get(&entry->ep->kref); + mutex_unlock(&ep_lock); + + return entry->ep; +} +EXPORT_SYMBOL_NS_GPL(pmt_telem_register_endpoint, INTEL_PMT_TELEMETRY); + +void pmt_telem_unregister_endpoint(struct telem_endpoint *ep) +{ + kref_put(&ep->kref, pmt_telem_ep_release); +} +EXPORT_SYMBOL_NS_GPL(pmt_telem_unregister_endpoint, INTEL_PMT_TELEMETRY); + +int pmt_telem_get_endpoint_info(int devid, struct telem_endpoint_info *info) +{ + struct intel_pmt_entry *entry; + unsigned long index = devid; + int err = 0; + + if (!info) + return -EINVAL; + + mutex_lock(&ep_lock); + entry = xa_find(&telem_array, &index, index, XA_PRESENT); + if (!entry) { + err = -ENXIO; + goto unlock; + } + + info->pdev = entry->ep->pcidev; + info->header = entry->ep->header; + +unlock: + mutex_unlock(&ep_lock); + return err; + +} +EXPORT_SYMBOL_NS_GPL(pmt_telem_get_endpoint_info, INTEL_PMT_TELEMETRY); + +int pmt_telem_read(struct telem_endpoint *ep, u32 id, u64 *data, u32 count) +{ + u32 offset, size; + + if (!ep->present) + return -ENODEV; + + offset = SAMPLE_ID_OFFSET(id); + size = ep->header.size; + + if (offset + NUM_BYTES_QWORD(count) > size) + return -EINVAL; + + memcpy_fromio(data, ep->base + offset, NUM_BYTES_QWORD(count)); + + return ep->present ? 0 : -EPIPE; +} +EXPORT_SYMBOL_NS_GPL(pmt_telem_read, INTEL_PMT_TELEMETRY); + +int pmt_telem_read32(struct telem_endpoint *ep, u32 id, u32 *data, u32 count) +{ + u32 offset, size; + + if (!ep->present) + return -ENODEV; + + offset = SAMPLE_ID_OFFSET32(id); + size = ep->header.size; + + if (offset + NUM_BYTES_DWORD(count) > size) + return -EINVAL; + + memcpy_fromio(data, ep->base + offset, NUM_BYTES_DWORD(count)); + + return ep->present ? 0 : -EPIPE; +} +EXPORT_SYMBOL_NS_GPL(pmt_telem_read32, INTEL_PMT_TELEMETRY); + +struct telem_endpoint * +pmt_telem_find_and_register_endpoint(struct pci_dev *pcidev, u32 guid, u16 pos) +{ + int devid = 0; + int inst = 0; + int err = 0; + + while ((devid = pmt_telem_get_next_endpoint(devid))) { + struct telem_endpoint_info ep_info; + + err = pmt_telem_get_endpoint_info(devid, &ep_info); + if (err) + return ERR_PTR(err); + + if (ep_info.header.guid == guid && ep_info.pdev == pcidev) { + if (inst == pos) + return pmt_telem_register_endpoint(devid); + ++inst; + } + } + + return ERR_PTR(-ENXIO); +} +EXPORT_SYMBOL_NS_GPL(pmt_telem_find_and_register_endpoint, INTEL_PMT_TELEMETRY); + static void pmt_telem_remove(struct auxiliary_device *auxdev) { struct pmt_telem_priv *priv = auxiliary_get_drvdata(auxdev); int i; - for (i = 0; i < priv->num_entries; i++) - intel_pmt_dev_destroy(&priv->entry[i], &pmt_telem_ns); -} + mutex_lock(&ep_lock); + for (i = 0; i < priv->num_entries; i++) { + struct intel_pmt_entry *entry = &priv->entry[i]; + + kref_put(&entry->ep->kref, pmt_telem_ep_release); + intel_pmt_dev_destroy(entry, &pmt_telem_ns); + } + mutex_unlock(&ep_lock); +}; static int pmt_telem_probe(struct auxiliary_device *auxdev, const struct auxiliary_device_id *id) { @@ -117,7 +300,9 @@ 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]; + mutex_lock(&ep_lock); ret = intel_pmt_dev_create(entry, &pmt_telem_ns, intel_vsec_dev, i); + mutex_unlock(&ep_lock); if (ret < 0) goto abort_probe; if (ret) diff --git a/drivers/platform/x86/intel/pmt/telemetry.h b/drivers/platform/x86/intel/pmt/telemetry.h new file mode 100644 index 000000000000..d45af5512b4e --- /dev/null +++ b/drivers/platform/x86/intel/pmt/telemetry.h @@ -0,0 +1,126 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _TELEMETRY_H +#define _TELEMETRY_H + +/* Telemetry types */ +#define PMT_TELEM_TELEMETRY 0 +#define PMT_TELEM_CRASHLOG 1 + +struct telem_endpoint; +struct pci_dev; + +struct telem_header { + u8 access_type; + u16 size; + u32 guid; + u32 base_offset; +}; + +struct telem_endpoint_info { + struct pci_dev *pdev; + struct telem_header header; +}; + +/** + * pmt_telem_get_next_endpoint() - Get next device id for a telemetry endpoint + * @start: starting devid to look from + * + * This functions can be used in a while loop predicate to retrieve the devid + * of all available telemetry endpoints. Functions pmt_telem_get_next_endpoint() + * and pmt_telem_register_endpoint() can be used inside of the loop to examine + * endpoint info and register to receive a pointer to the endpoint. The pointer + * is then usable in the telemetry read calls to access the telemetry data. + * + * Return: + * * devid - devid of the next present endpoint from start + * * 0 - when no more endpoints are present after start + */ +unsigned long pmt_telem_get_next_endpoint(unsigned long start); + +/** + * pmt_telem_register_endpoint() - Register a telemetry endpoint + * @devid: device id/handle of the telemetry endpoint + * + * Increments the kref usage counter for the endpoint. + * + * Return: + * * endpoint - On success returns pointer to the telemetry endpoint + * * -ENXIO - telemetry endpoint not found + */ +struct telem_endpoint *pmt_telem_register_endpoint(int devid); + +/** + * pmt_telem_unregister_endpoint() - Unregister a telemetry endpoint + * @ep: ep structure to populate. + * + * Decrements the kref usage counter for the endpoint. + */ +void pmt_telem_unregister_endpoint(struct telem_endpoint *ep); + +/** + * pmt_telem_get_endpoint_info() - Get info for an endpoint from its devid + * @devid: device id/handle of the telemetry endpoint + * @info: Endpoint info structure to be populated + * + * Return: + * * 0 - Success + * * -ENXIO - telemetry endpoint not found for the devid + * * -EINVAL - @info is NULL + */ +int pmt_telem_get_endpoint_info(int devid, struct telem_endpoint_info *info); + +/** + * pmt_telem_find_and_register_endpoint() - Get a telemetry endpoint from + * pci_dev device, guid and pos + * @pdev: PCI device inside the Intel vsec + * @guid: GUID of the telemetry space + * @pos: Instance of the guid + * + * Return: + * * endpoint - On success returns pointer to the telemetry endpoint + * * -ENXIO - telemetry endpoint not found + */ +struct telem_endpoint *pmt_telem_find_and_register_endpoint(struct pci_dev *pcidev, + u32 guid, u16 pos); + +/** + * pmt_telem_read() - Read qwords from counter sram using sample id + * @ep: Telemetry endpoint to be read + * @id: The beginning sample id of the metric(s) to be read + * @data: Allocated qword buffer + * @count: Number of qwords requested + * + * Callers must ensure reads are aligned. When the call returns -ENODEV, + * the device has been removed and callers should unregister the telemetry + * endpoint. + * + * Return: + * * 0 - Success + * * -ENODEV - The device is not present. + * * -EINVAL - The offset is out bounds + * * -EPIPE - The device was removed during the read. Data written + * but should be considered invalid. + */ +int pmt_telem_read(struct telem_endpoint *ep, u32 id, u64 *data, u32 count); + +/** + * pmt_telem_read32() - Read qwords from counter sram using sample id + * @ep: Telemetry endpoint to be read + * @id: The beginning sample id of the metric(s) to be read + * @data: Allocated dword buffer + * @count: Number of dwords requested + * + * Callers must ensure reads are aligned. When the call returns -ENODEV, + * the device has been removed and callers should unregister the telemetry + * endpoint. + * + * Return: + * * 0 - Success + * * -ENODEV - The device is not present. + * * -EINVAL - The offset is out bounds + * * -EPIPE - The device was removed during the read. Data written + * but should be considered invalid. + */ +int pmt_telem_read32(struct telem_endpoint *ep, u32 id, u32 *data, u32 count); + +#endif From patchwork Thu Oct 12 02:38:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "David E. Box" X-Patchwork-Id: 151644 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp942556vqb; Wed, 11 Oct 2023 19:39:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFPwErhDY4Wn70FaOCcnxh2Yotuqpne7oQrL+Pb6sq7+Ms3Ek4ETY04txXKc8lF/ODQriit X-Received: by 2002:a17:90b:1d87:b0:27d:2261:73e4 with SMTP id pf7-20020a17090b1d8700b0027d226173e4mr170825pjb.2.1697078342580; Wed, 11 Oct 2023 19:39:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697078342; cv=none; d=google.com; s=arc-20160816; b=xA9hPdct+0upB7Y3Zk6U1NIUDiIoycJnttycFi0O0nnEZqiitCTFdbS8xsS4eIHbsn 2ej0rKDjqqjB6s2HCc9BEMV8jDGBUS1VU3u3UGHHZ2DbrE3rsDmaOWAGN1yPZQZd3g/D eJrmfRTGAdakaqWCouWi6p6lC899xReXo4WJq2vsxa6w3EbA0eBS3b9j67pkeKHu6ZFw b7lYy9Hx4ycLcD8WEQykY+h+WS2aReR3/gEXOnh/zeQ6l2zMhWrujBwtu2d85T08mkDy /CSPZoGUChrTEmYQzzvCxvZe+r6MiN18roJ882nmISKXcr4xFthUO093qtJmnYSfGD6I rKow== 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=jU7f5RSThWsM6BimebziPTWDrG/6cxnKdl+G5V1e1wg=; fh=d9G4dsZtlI8UONIvGKwhW94hCYEPGxy6CqYeKEG646A=; b=Su//RwswRzEFJbjOFnsnz/9xCDi3Slw+si30dNwfxmn5XXLltR6eeamwJ1hYYt7Jvj FJZ/NWzPtwv6imvWfTk9MUmBTJMMUVUnvgt1Rz2RpmfxVd6kClwN9NgP4FtGSKBgDxkh 8oHImuK4bfdcRGyVE3cKGZFIkG9tLf8N0K0pX+d3bRSU817d05JFsWWTZDOa9IOH64PG GViwGLBjraZhlQhVebLShFoXEx1FHwOfRJbok6xwPTMcryrI9nXDV/JmE8eAlB3Oh1oy 0h9B9SFjDInNE4HBgHpP6cgoWksu4sq57YavnFFLm0rt0wf9MruQuIcEkhyVu1MUs6uU 9S1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=PEyNocds; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id gp9-20020a17090adf0900b0027d1b42875bsi969124pjb.64.2023.10.11.19.39.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 19:39:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=PEyNocds; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 4FC4380EE0C7; Wed, 11 Oct 2023 19:39:01 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235278AbjJLCiy (ORCPT + 18 others); Wed, 11 Oct 2023 22:38:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235226AbjJLCio (ORCPT ); Wed, 11 Oct 2023 22:38:44 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5B27B8; Wed, 11 Oct 2023 19:38:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697078322; x=1728614322; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=jZnpoDSWpoGCN8CQAkL/cFSX9jsCJnInii4ydnXB2CM=; b=PEyNocdsHZ6Xjg4e1NLdXS4ZUAFAyrWI+Zq6tVLiliGK6eNQi5UHtbrh H9+15dQSBLPvP7Karyxs1GbsjjHoWVEePGWsDjdyo83/yWNBcDQZyXGnw E0bqa5ugptecfPz4smK4/gRyyr/ckUlnMAZt7Ih/Q4ndagJTbUy3LqWKb WwwLOHCuPj/2sXik7Sb65yXsjqetpAVo3A/m8pH0zrERUxM/E/73EAOd4 s7vfycLdI5ONSozyaEQwCLF6vSDxoKJ22Xc250N5Bz1bMyXn11+0td845 k49HtSFBNkXpnRyxqmMivWms/xhEPnWaX1/gLoIlYXSNdK5gmBjBBx1V4 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="365090378" X-IronPort-AV: E=Sophos;i="6.03,217,1694761200"; d="scan'208";a="365090378" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 19:38:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="824411676" X-IronPort-AV: E=Sophos;i="6.03,217,1694761200"; d="scan'208";a="824411676" Received: from linux.intel.com ([10.54.29.200]) by fmsmga004.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 19:38:42 -0700 Received: from debox1-desk4.intel.com (unknown [10.209.105.238]) by linux.intel.com (Postfix) with ESMTP id D1113580D79; Wed, 11 Oct 2023 19:38:41 -0700 (PDT) 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 V3 08/16] platform/x86:intel/pmc: Call pmc_get_low_power_modes from platform init Date: Wed, 11 Oct 2023 19:38:32 -0700 Message-Id: <20231012023840.3845703-9-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231012023840.3845703-1-david.e.box@linux.intel.com> References: <20231012023840.3845703-1-david.e.box@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Wed, 11 Oct 2023 19:39:01 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779515620129975814 X-GMAIL-MSGID: 1779515620129975814 From: Xi Pardee In order to setup a table of low power mode requirements for Meteor Lake, pmc_core_get_low_power_modes() will need to be run from platform init code so that the enabled modes are known, allowing the use of the pmc_for_each_mode helper. Make the function global and call it from the platform init code. Signed-off-by: Xi Pardee Signed-off-by: David E. Box Reviewed-by: Ilpo Järvinen --- V3 - No change V2 - Added clearer explanation for the change in the changelog drivers/platform/x86/intel/pmc/adl.c | 2 ++ drivers/platform/x86/intel/pmc/cnp.c | 2 ++ drivers/platform/x86/intel/pmc/core.c | 7 +++---- drivers/platform/x86/intel/pmc/core.h | 1 + drivers/platform/x86/intel/pmc/icl.c | 10 +++++++++- drivers/platform/x86/intel/pmc/mtl.c | 4 +++- drivers/platform/x86/intel/pmc/spt.c | 10 +++++++++- drivers/platform/x86/intel/pmc/tgl.c | 1 + 8 files changed, 30 insertions(+), 7 deletions(-) diff --git a/drivers/platform/x86/intel/pmc/adl.c b/drivers/platform/x86/intel/pmc/adl.c index 5006008e01be..64c492391ede 100644 --- a/drivers/platform/x86/intel/pmc/adl.c +++ b/drivers/platform/x86/intel/pmc/adl.c @@ -319,6 +319,8 @@ int adl_core_init(struct pmc_dev *pmcdev) if (ret) return ret; + pmc_core_get_low_power_modes(pmcdev); + /* Due to a hardware limitation, the GBE LTR blocks PC10 * when a cable is attached. Tell the PMC to ignore it. */ diff --git a/drivers/platform/x86/intel/pmc/cnp.c b/drivers/platform/x86/intel/pmc/cnp.c index 420aaa1d7c76..59298f184d0e 100644 --- a/drivers/platform/x86/intel/pmc/cnp.c +++ b/drivers/platform/x86/intel/pmc/cnp.c @@ -214,6 +214,8 @@ int cnp_core_init(struct pmc_dev *pmcdev) if (ret) return ret; + pmc_core_get_low_power_modes(pmcdev); + /* Due to a hardware limitation, the GBE LTR blocks PC10 * when a cable is attached. Tell the PMC to ignore it. */ diff --git a/drivers/platform/x86/intel/pmc/core.c b/drivers/platform/x86/intel/pmc/core.c index 5a36b3f77bc5..e58c8cc286a3 100644 --- a/drivers/platform/x86/intel/pmc/core.c +++ b/drivers/platform/x86/intel/pmc/core.c @@ -966,9 +966,8 @@ static bool pmc_core_pri_verify(u32 lpm_pri, u8 *mode_order) return true; } -static void pmc_core_get_low_power_modes(struct platform_device *pdev) +void pmc_core_get_low_power_modes(struct pmc_dev *pmcdev) { - struct pmc_dev *pmcdev = platform_get_drvdata(pdev); struct pmc *pmc = pmcdev->pmcs[PMC_IDX_MAIN]; u8 pri_order[LPM_MAX_NUM_MODES] = LPM_DEFAULT_PRI; u8 mode_order[LPM_MAX_NUM_MODES]; @@ -1000,7 +999,8 @@ static void pmc_core_get_low_power_modes(struct platform_device *pdev) for (mode = 0; mode < LPM_MAX_NUM_MODES; mode++) pri_order[mode_order[mode]] = mode; else - dev_warn(&pdev->dev, "Assuming a default substate order for this platform\n"); + dev_warn(&pmcdev->pdev->dev, + "Assuming a default substate order for this platform\n"); /* * Loop through all modes from lowest to highest priority, @@ -1250,7 +1250,6 @@ static int pmc_core_probe(struct platform_device *pdev) } pmcdev->pmc_xram_read_bit = pmc_core_check_read_lock_bit(primary_pmc); - pmc_core_get_low_power_modes(pdev); pmc_core_do_dmi_quirks(primary_pmc); pmc_core_dbgfs_register(pmcdev); diff --git a/drivers/platform/x86/intel/pmc/core.h b/drivers/platform/x86/intel/pmc/core.h index 0729f593c6a7..ccf24e0f5e50 100644 --- a/drivers/platform/x86/intel/pmc/core.h +++ b/drivers/platform/x86/intel/pmc/core.h @@ -490,6 +490,7 @@ extern int pmc_core_send_ltr_ignore(struct pmc_dev *pmcdev, u32 value); int pmc_core_resume_common(struct pmc_dev *pmcdev); int get_primary_reg_base(struct pmc *pmc); +extern void pmc_core_get_low_power_modes(struct pmc_dev *pmcdev); extern void pmc_core_ssram_init(struct pmc_dev *pmcdev); diff --git a/drivers/platform/x86/intel/pmc/icl.c b/drivers/platform/x86/intel/pmc/icl.c index d08e3174230d..71b0fd6cb7d8 100644 --- a/drivers/platform/x86/intel/pmc/icl.c +++ b/drivers/platform/x86/intel/pmc/icl.c @@ -53,7 +53,15 @@ const struct pmc_reg_map icl_reg_map = { int icl_core_init(struct pmc_dev *pmcdev) { struct pmc *pmc = pmcdev->pmcs[PMC_IDX_MAIN]; + int ret; pmc->map = &icl_reg_map; - return get_primary_reg_base(pmc); + + ret = get_primary_reg_base(pmc); + if (ret) + return ret; + + pmc_core_get_low_power_modes(pmcdev); + + return ret; } diff --git a/drivers/platform/x86/intel/pmc/mtl.c b/drivers/platform/x86/intel/pmc/mtl.c index 2204bc666980..c3b5f4fe01d1 100644 --- a/drivers/platform/x86/intel/pmc/mtl.c +++ b/drivers/platform/x86/intel/pmc/mtl.c @@ -985,7 +985,7 @@ static int mtl_resume(struct pmc_dev *pmcdev) int mtl_core_init(struct pmc_dev *pmcdev) { struct pmc *pmc = pmcdev->pmcs[PMC_IDX_SOC]; - int ret = 0; + int ret; mtl_d3_fixup(); @@ -1002,6 +1002,8 @@ int mtl_core_init(struct pmc_dev *pmcdev) return ret; } + pmc_core_get_low_power_modes(pmcdev); + /* Due to a hardware limitation, the GBE LTR blocks PC10 * when a cable is attached. Tell the PMC to ignore it. */ diff --git a/drivers/platform/x86/intel/pmc/spt.c b/drivers/platform/x86/intel/pmc/spt.c index 4b6f5cbda16c..ab993a69e33e 100644 --- a/drivers/platform/x86/intel/pmc/spt.c +++ b/drivers/platform/x86/intel/pmc/spt.c @@ -137,7 +137,15 @@ const struct pmc_reg_map spt_reg_map = { int spt_core_init(struct pmc_dev *pmcdev) { struct pmc *pmc = pmcdev->pmcs[PMC_IDX_MAIN]; + int ret; pmc->map = &spt_reg_map; - return get_primary_reg_base(pmc); + + ret = get_primary_reg_base(pmc); + if (ret) + return ret; + + pmc_core_get_low_power_modes(pmcdev); + + return ret; } diff --git a/drivers/platform/x86/intel/pmc/tgl.c b/drivers/platform/x86/intel/pmc/tgl.c index 2449940102db..d5f1d2223c5a 100644 --- a/drivers/platform/x86/intel/pmc/tgl.c +++ b/drivers/platform/x86/intel/pmc/tgl.c @@ -263,6 +263,7 @@ int tgl_core_init(struct pmc_dev *pmcdev) if (ret) return ret; + pmc_core_get_low_power_modes(pmcdev); pmc_core_get_tgl_lpm_reqs(pmcdev->pdev); /* Due to a hardware limitation, the GBE LTR blocks PC10 * when a cable is attached. Tell the PMC to ignore it. From patchwork Thu Oct 12 02:38:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "David E. Box" X-Patchwork-Id: 151647 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp942619vqb; Wed, 11 Oct 2023 19:39:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFW7QlQY5e/cAPCAC33+GCD3HRWSXD7OuoHBvvIlcPlmr3mQR40BCucy5KF6n/JSw5bBOMi X-Received: by 2002:a17:902:ce86:b0:1c4:2b71:7dc9 with SMTP id f6-20020a170902ce8600b001c42b717dc9mr25752460plg.4.1697078354044; Wed, 11 Oct 2023 19:39:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697078354; cv=none; d=google.com; s=arc-20160816; b=yzCcK6Oj+SchTcHkrfgh4N/y2L6+n/U+fPW5t7OClP9wEOdAFwvTPxNn1/zN48YVmr Qz5pGU4i1cy5OzLOtxhaSTjTi4EVVf34ccB5SC0VDMG40sgQaanh1mdnxX6m9GUOoXlf V+TtQrmBpF9q/qavKaCzqMnbUCvOTYNmoCyLyc9bnAH8jYqsDP0qMgyFhDNot844hi+I ppTYF680d7PVxn9GWEbFWlB9SFhQuFypiH2Np02cKQ48/wbLtubsHCUszS6rvRuAqSlb qa2M0rlS9hcNXALdoieC7oej2/P/V7GAQr5Ym3HlgO4loHwWq8GFsE2M9w3/xy8SblQT aKbw== 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=umLr56wvwwTFCDz7qvq1CqBm/ZkhkEf6nEde0oSKtz8=; fh=d9G4dsZtlI8UONIvGKwhW94hCYEPGxy6CqYeKEG646A=; b=MwZfPPD/HA4O1K79Gl5aeMiVPklyqmoWlI+H3yFCbddqrcFMpS4HmYh0AwAhdEv1YC r62oGMDPJt7hmBjkkmbgL43kZTHQgHX+PWlFhZ5r8kHX5yfAWd+g8KoYCd9lxQUIbCri r/I2mBg5iM9HNhLK/vyqT9lFrZwe4TEGyqtGjW2EpB8L0mXQQFsjywTOjW6bYYTqHXHs 6uAoD2wqrzCNhVbIclgv2tEYtz5cTwAnhHFTJgpTrLCuxjlc3CzTBeoFNPd+aB9b14dF AwclYnRo4HGUZsRvRfkPGEgpsC4HuchJghK1O2RP6P3qNb0+IJ21NnkOl7eb0ar8n9Ru D4vQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZuIHGRmJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id l18-20020a170902eb1200b001c9c8c4c6d0si1058663plb.26.2023.10.11.19.39.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 19:39:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZuIHGRmJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id C00A081B94D3; Wed, 11 Oct 2023 19:39:12 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376760AbjJLCjG (ORCPT + 18 others); Wed, 11 Oct 2023 22:39:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376738AbjJLCiq (ORCPT ); Wed, 11 Oct 2023 22:38:46 -0400 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5EDCA9; Wed, 11 Oct 2023 19:38:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697078325; x=1728614325; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=UD0nNSwyIv4IWeehjiEni1fHYTZyMVgwi/kofK50zJE=; b=ZuIHGRmJ/U1q22Dnl9T/S3vOzZp9jZCoTTuVjD1VBRBN5WhKjDCBueuk im3+QGQGrmWQiR4/0UjDyLJkYTokfanPscqzQerUC2otT6gMCFfk/T4uj IZc3vlesVON+xFfngqxAVnq5D19NJyRLZk9TNjEeyOrhdfjkcyi9iachl KuAsJqNupnRRngMrH7jTlIsOgiR/CEsSPCB56dS5gGfxTmTr6hb7AShYR /1edjFIA9JU2fPVe85kGGLbRNNeSiKEC/ZZdUEv2pbWluyKo/vhts+AIu suKnqL2gb1wxRA+/KVkAcmDzBAa78a/UfMY+/99h0RytxphZNe3X5wzaZ g==; X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="3402628" X-IronPort-AV: E=Sophos;i="6.03,217,1694761200"; d="scan'208";a="3402628" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 19:38:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="783507864" X-IronPort-AV: E=Sophos;i="6.03,217,1694761200"; d="scan'208";a="783507864" Received: from linux.intel.com ([10.54.29.200]) by orsmga008.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 19:38:42 -0700 Received: from debox1-desk4.intel.com (unknown [10.209.105.238]) by linux.intel.com (Postfix) with ESMTP id F3DA3580E33; Wed, 11 Oct 2023 19:38:41 -0700 (PDT) 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 V3 09/16] platform/x86/intel/pmc: Allow pmc_core_ssram_init to fail Date: Wed, 11 Oct 2023 19:38:33 -0700 Message-Id: <20231012023840.3845703-10-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231012023840.3845703-1-david.e.box@linux.intel.com> References: <20231012023840.3845703-1-david.e.box@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Wed, 11 Oct 2023 19:39:12 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779515632081719607 X-GMAIL-MSGID: 1779515632081719607 Currently, if the PMC SSRAM initialization fails, no error is returned and the only indication is that a PMC device has not been created. Instead, allow an error to be returned and handled directly by the caller. Signed-off-by: David E. Box --- V3 - New patch split from V2 PATCH 9 - Add dev_warn on pmc_core_ssram_init fail drivers/platform/x86/intel/pmc/core.h | 2 +- drivers/platform/x86/intel/pmc/core.h | 2 +- drivers/platform/x86/intel/pmc/core_ssram.c | 21 +++++++++++++-------- drivers/platform/x86/intel/pmc/mtl.c | 12 ++++++++---- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/drivers/platform/x86/intel/pmc/core.h b/drivers/platform/x86/intel/pmc/core.h index ccf24e0f5e50..edaa70067e41 100644 --- a/drivers/platform/x86/intel/pmc/core.h +++ b/drivers/platform/x86/intel/pmc/core.h @@ -492,7 +492,7 @@ int pmc_core_resume_common(struct pmc_dev *pmcdev); int get_primary_reg_base(struct pmc *pmc); extern void pmc_core_get_low_power_modes(struct pmc_dev *pmcdev); -extern void pmc_core_ssram_init(struct pmc_dev *pmcdev); +extern int pmc_core_ssram_init(struct pmc_dev *pmcdev); int spt_core_init(struct pmc_dev *pmcdev); int cnp_core_init(struct pmc_dev *pmcdev); diff --git a/drivers/platform/x86/intel/pmc/core_ssram.c b/drivers/platform/x86/intel/pmc/core_ssram.c index 13fa16f0d52e..815950713e25 100644 --- a/drivers/platform/x86/intel/pmc/core_ssram.c +++ b/drivers/platform/x86/intel/pmc/core_ssram.c @@ -35,20 +35,20 @@ static inline u64 get_base(void __iomem *addr, u32 offset) return lo_hi_readq(addr + offset) & GENMASK_ULL(63, 3); } -static void +static int pmc_core_pmc_add(struct pmc_dev *pmcdev, u64 pwrm_base, const struct pmc_reg_map *reg_map, int pmc_index) { struct pmc *pmc = pmcdev->pmcs[pmc_index]; if (!pwrm_base) - return; + return -ENODEV; /* Memory for primary PMC has been allocated in core.c */ if (!pmc) { pmc = devm_kzalloc(&pmcdev->pdev->dev, sizeof(*pmc), GFP_KERNEL); if (!pmc) - return; + return -ENOMEM; } pmc->map = reg_map; @@ -57,10 +57,12 @@ pmc_core_pmc_add(struct pmc_dev *pmcdev, u64 pwrm_base, if (!pmc->regbase) { devm_kfree(&pmcdev->pdev->dev, pmc); - return; + return -ENOMEM; } pmcdev->pmcs[pmc_index] = pmc; + + return 0; } static void @@ -96,7 +98,7 @@ pmc_core_ssram_get_pmc(struct pmc_dev *pmcdev, void __iomem *ssram, u32 offset, iounmap(ssram); } -void pmc_core_ssram_init(struct pmc_dev *pmcdev) +int pmc_core_ssram_init(struct pmc_dev *pmcdev) { void __iomem *ssram; struct pci_dev *pcidev; @@ -105,7 +107,7 @@ void pmc_core_ssram_init(struct pmc_dev *pmcdev) pcidev = pci_get_domain_bus_and_slot(0, 0, PCI_DEVFN(20, 2)); if (!pcidev) - goto out; + return -ENODEV; ret = pcim_enable_device(pcidev); if (ret) @@ -123,11 +125,14 @@ void pmc_core_ssram_init(struct pmc_dev *pmcdev) pmc_core_ssram_get_pmc(pmcdev, ssram, SSRAM_PCH_OFFSET, PMC_IDX_PCH); iounmap(ssram); -out: - return; + + return 0; disable_dev: + pmcdev->ssram_pcidev = NULL; pci_disable_device(pcidev); release_dev: pci_dev_put(pcidev); + + return ret; } diff --git a/drivers/platform/x86/intel/pmc/mtl.c b/drivers/platform/x86/intel/pmc/mtl.c index c3b5f4fe01d1..d1d3d33fb4b8 100644 --- a/drivers/platform/x86/intel/pmc/mtl.c +++ b/drivers/platform/x86/intel/pmc/mtl.c @@ -990,12 +990,16 @@ int mtl_core_init(struct pmc_dev *pmcdev) mtl_d3_fixup(); pmcdev->resume = mtl_resume; - pmcdev->regmap_list = mtl_pmc_info_list; - pmc_core_ssram_init(pmcdev); - /* If regbase not assigned, set map and discover using legacy method */ - if (!pmc->regbase) { + /* + * If ssram init fails use legacy method to at least get the + * primary PMC + */ + ret = pmc_core_ssram_init(pmcdev); + if (ret) { + dev_warn(&pmcdev->pdev->dev, + "ssram init failed, %d, using legacy init\n", ret); pmc->map = &mtl_socm_reg_map; ret = get_primary_reg_base(pmc); if (ret) From patchwork Thu Oct 12 02:38:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "David E. Box" X-Patchwork-Id: 151654 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp942745vqb; Wed, 11 Oct 2023 19:39:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF3HCrWgfXhMLTNbJ9IzMjCB+ONUbh9x1QIGAlrsxBudnB7IqigM3eAUs+w/Xeb9g4SHcJ4 X-Received: by 2002:a17:903:22cc:b0:1b8:2ba0:c9a8 with SMTP id y12-20020a17090322cc00b001b82ba0c9a8mr25160082plg.2.1697078383222; Wed, 11 Oct 2023 19:39:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697078383; cv=none; d=google.com; s=arc-20160816; b=HdXDjslawJKWMKSiXHlCRCKxAO3aH4tTVV71WWkyUMz594yqsty5N9ND2jWuB66WZV c4VEhVhT2D0+2RMHvJobXtBWELyN2+25CylzaG+6yR0K8cH+aePWHI5QoZN0QWOwW60A dDzW1BNXOgqTU+BxFzONE2Qeji1oTiaV7oaAWpxPmGamuAmhtqdaFQKe0ugoahEJt5FO +4KirreuD1+VkGzZoMOrnJLVRVleBjFWIhs6qW1dIZBKNqcMKxe1gSH4abS8bda6N0xg NfcdYEFAO4gZulJEomzIZvJ2dflBvM36L5hnNlHkvscD5+bLoKmyRAru/h7n1tRMR81o T/oQ== 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=78Cy/46cxOVo/NLBE5+osq6JDWRJgicUIu3oCN/ApJA=; fh=d9G4dsZtlI8UONIvGKwhW94hCYEPGxy6CqYeKEG646A=; b=Z27EI76uXeD5UN2rW57Eb9zFH4UnF7qWDMv/Yhp1N4Qabiv+lcgPVwoaj/R/ABfVt0 T0zIV2UwjKauCXVLuPxo2txZsaTLmeiohK2KZ68CKCyIL+ruTS5+VrK/9fknMJYFQ5T+ fHVbVG6kGN29CKRDxwbDtyFg/HqC6Rh0feo1EFxsVZJ9FGdUb3J0lrAm0UzKus4lXP/z 7Rw65xhy8FGazNRhlV3L6BmRdNTZf1Q/bUhu2gfSxYQwOa8xOqJvhmDKZhNGxXU3EhXg kGv9CGm/wRbl8pZiXkvg9bI2I6XHRdHHVx8SM2e478BylH7GlMnJXbBVZlq//9zUxQ17 +1+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BEawEjhN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id 1-20020a170902ee4100b001c9e0fcf90esi251280plo.60.2023.10.11.19.39.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 19:39:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BEawEjhN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 95BF781E6EE3; Wed, 11 Oct 2023 19:39:42 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376859AbjJLCjf (ORCPT + 18 others); Wed, 11 Oct 2023 22:39:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376743AbjJLCir (ORCPT ); Wed, 11 Oct 2023 22:38:47 -0400 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34DA9A4; Wed, 11 Oct 2023 19:38:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697078326; x=1728614326; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=tjwv376/Em55sOxjhruTUpiSwRHY1GDeDxUXzacac6o=; b=BEawEjhNr3a0ETmoU3yLZV9aAPTVxMIpP7nR1PdTjyKyN9baGC6epP/b f8Ny0yw/n87feiVhCT2zOQr+41T22aXQ/vJxFEJ2+8ZugKCVj1jDK1ry7 p6XiHRtAorUyPkoZpsSKFMU9hHoLWlYtaGc0n+IkDFvqIlYj3H27mSO11 OmSkZvzwZPnHFaetlAPhXLHeLW2KHJy6BeHYrI2KM4oXO/VXMNG3kTyzU wDSw1KzIUa/TevBEqzS1XRpPG2IkfKteiYNHPTP8eCAFNBtKizhktiiRw yI3KHo/EEPxFE1GBy+GL4iFEuJl7mPEp15rWmN2lcuhAHO7aN6jvfwbxy Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="3402630" X-IronPort-AV: E=Sophos;i="6.03,217,1694761200"; d="scan'208";a="3402630" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 19:38:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="783507866" X-IronPort-AV: E=Sophos;i="6.03,217,1694761200"; d="scan'208";a="783507866" Received: from linux.intel.com ([10.54.29.200]) by orsmga008.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 19:38:42 -0700 Received: from debox1-desk4.intel.com (unknown [10.209.105.238]) by linux.intel.com (Postfix) with ESMTP id 1E907580E38; Wed, 11 Oct 2023 19:38:42 -0700 (PDT) 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 V3 10/16] platform/x86/intel/pmc: Split pmc_core_ssram_get_pmc() Date: Wed, 11 Oct 2023 19:38:34 -0700 Message-Id: <20231012023840.3845703-11-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231012023840.3845703-1-david.e.box@linux.intel.com> References: <20231012023840.3845703-1-david.e.box@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Wed, 11 Oct 2023 19:39:42 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779515662871603220 X-GMAIL-MSGID: 1779515662871603220 On supported hardware, each PMC may have an associated SSRAM device for accessing additional counters. However, only the SSRAM of the first (primary) PMC is discoverable as a PCI device to the OS. The remaining (secondary) devices are hidden but their BARs are still accessible and their addresses are stored in the BAR of the exposed device. Clean up the code handling the SSRAM discovery. Create two separate functions for accessing the primary and secondary SSRAM devices. Signed-off-by: David E. Box --- V3 - New patch split from previous PATCH 2 - Update changelog - Use cleanup.h to cleanup ioremap V2 - no change drivers/platform/x86/intel/pmc/core_ssram.c | 93 ++++++++++++++------- 1 file changed, 61 insertions(+), 32 deletions(-) diff --git a/drivers/platform/x86/intel/pmc/core_ssram.c b/drivers/platform/x86/intel/pmc/core_ssram.c index 815950713e25..af405d11919f 100644 --- a/drivers/platform/x86/intel/pmc/core_ssram.c +++ b/drivers/platform/x86/intel/pmc/core_ssram.c @@ -8,6 +8,7 @@ * */ +#include #include #include @@ -21,6 +22,8 @@ #define SSRAM_IOE_OFFSET 0x68 #define SSRAM_DEVID_OFFSET 0x70 +DEFINE_FREE(pmc_core_iounmap, void __iomem *, iounmap(_T)); + static const struct pmc_reg_map *pmc_core_find_regmap(struct pmc_info *list, u16 devid) { for (; list->map; ++list) @@ -65,44 +68,74 @@ pmc_core_pmc_add(struct pmc_dev *pmcdev, u64 pwrm_base, return 0; } -static void -pmc_core_ssram_get_pmc(struct pmc_dev *pmcdev, void __iomem *ssram, u32 offset, - int pmc_idx) +static int +pmc_core_get_secondary_pmc(struct pmc_dev *pmcdev, int pmc_idx, u32 offset) { - u64 pwrm_base; + struct pci_dev *ssram_pcidev = pmcdev->ssram_pcidev; + void __iomem __free(pmc_core_iounmap) *main_ssram = NULL; + void __iomem __free(pmc_core_iounmap) *secondary_ssram = NULL; + const struct pmc_reg_map *map; + u64 ssram_base, pwrm_base; u16 devid; - if (pmc_idx != PMC_IDX_SOC) { - u64 ssram_base = get_base(ssram, offset); + if (!pmcdev->regmap_list) + return -ENOENT; - if (!ssram_base) - return; + /* + * The secondary PMC BARS (which are behind hidden PCI devices) are read + * from fixed offsets in MMIO of the primary PMC BAR. + */ + ssram_base = ssram_pcidev->resource[0].start; + main_ssram = ioremap(ssram_base, SSRAM_HDR_SIZE); + if (!main_ssram) + return -ENOMEM; - ssram = ioremap(ssram_base, SSRAM_HDR_SIZE); - if (!ssram) - return; - } + ssram_base = get_base(main_ssram, offset); + secondary_ssram = ioremap(ssram_base, SSRAM_HDR_SIZE); + if (!secondary_ssram) + return -ENOMEM; + + pwrm_base = get_base(secondary_ssram, SSRAM_PWRM_OFFSET); + devid = readw(secondary_ssram + SSRAM_DEVID_OFFSET); + + map = pmc_core_find_regmap(pmcdev->regmap_list, devid); + if (!map) + return -ENODEV; + + return pmc_core_pmc_add(pmcdev, pwrm_base, map, pmc_idx); +} + +static int +pmc_core_get_primary_pmc(struct pmc_dev *pmcdev) +{ + struct pci_dev *ssram_pcidev = pmcdev->ssram_pcidev; + void __iomem __free(pmc_core_iounmap) *ssram; + const struct pmc_reg_map *map; + u64 ssram_base, pwrm_base; + u16 devid; + + if (!pmcdev->regmap_list) + return -ENOENT; + + /* The primary PMC (SOC die) BAR is BAR 0 in config space. */ + ssram_base = ssram_pcidev->resource[0].start; + ssram = ioremap(ssram_base, SSRAM_HDR_SIZE); + if (!ssram) + return -ENOMEM; pwrm_base = get_base(ssram, SSRAM_PWRM_OFFSET); devid = readw(ssram + SSRAM_DEVID_OFFSET); - if (pmcdev->regmap_list) { - const struct pmc_reg_map *map; + map = pmc_core_find_regmap(pmcdev->regmap_list, devid); + if (!map) + return -ENODEV; - map = pmc_core_find_regmap(pmcdev->regmap_list, devid); - if (map) - pmc_core_pmc_add(pmcdev, pwrm_base, map, pmc_idx); - } - - if (pmc_idx != PMC_IDX_SOC) - iounmap(ssram); + return pmc_core_pmc_add(pmcdev, pwrm_base, map, PMC_IDX_MAIN); } int pmc_core_ssram_init(struct pmc_dev *pmcdev) { - void __iomem *ssram; struct pci_dev *pcidev; - u64 ssram_base; int ret; pcidev = pci_get_domain_bus_and_slot(0, 0, PCI_DEVFN(20, 2)); @@ -113,18 +146,14 @@ int pmc_core_ssram_init(struct pmc_dev *pmcdev) if (ret) goto release_dev; - ssram_base = pcidev->resource[0].start; - ssram = ioremap(ssram_base, SSRAM_HDR_SIZE); - if (!ssram) - goto disable_dev; - pmcdev->ssram_pcidev = pcidev; - pmc_core_ssram_get_pmc(pmcdev, ssram, 0, PMC_IDX_SOC); - pmc_core_ssram_get_pmc(pmcdev, ssram, SSRAM_IOE_OFFSET, PMC_IDX_IOE); - pmc_core_ssram_get_pmc(pmcdev, ssram, SSRAM_PCH_OFFSET, PMC_IDX_PCH); + ret = pmc_core_get_primary_pmc(pmcdev); + if (ret) + goto disable_dev; - iounmap(ssram); + pmc_core_get_secondary_pmc(pmcdev, PMC_IDX_IOE, SSRAM_IOE_OFFSET); + pmc_core_get_secondary_pmc(pmcdev, PMC_IDX_PCH, SSRAM_PCH_OFFSET); return 0; From patchwork Thu Oct 12 02:38:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "David E. Box" X-Patchwork-Id: 151656 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp942967vqb; Wed, 11 Oct 2023 19:40:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFFSdY+LQlXg3AcR95vH0xs8p3LjngZqjrLd/rRKcTa7lk5TdFb5qJP8V6qBzLUMJ/Bg5o4 X-Received: by 2002:a05:6a00:3985:b0:68f:c8b3:3077 with SMTP id fi5-20020a056a00398500b0068fc8b33077mr24672762pfb.1.1697078418687; Wed, 11 Oct 2023 19:40:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697078418; cv=none; d=google.com; s=arc-20160816; b=RcK649+X9c3Wmvc7agS8xMjm+suMgYQ+r9Aab1KO8n9tPn3RPkaXQvNH7sE1EJNqDw 6qIQy6qLzUApvnv6Hm3Ay5suEPEJvw5icuf+ogNuyUjo2GRCFaT3vbj9suR94Q1nxvej SQQLuQx5xtCnjeiPgElMwlKi0k3kJMODJdSxwUaAaKjJx+6RAKXLkl3Q2UVjV8qZBXDF ECNul0xouQHTRgDWuwAcu+hkrL4yyLbefOSu7pY8XeRHsxca7kt8iYgyKvnMbpvnx//J dl6Le6FT4yU0Z8ZrYFWeipUzDWWaBtuqE9CmRhPqcIKwMvJ97wiHh8dEEZ91zllkeMTt 5Oww== 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=OC3igH2o6ZcbtvzcfFSK2NeKhCI6fnrDM0zSpoGd+4c=; fh=d9G4dsZtlI8UONIvGKwhW94hCYEPGxy6CqYeKEG646A=; b=yxn/XSLlXa2GZTXWYigFC/0B4cgIHHv6LU2Pv2pNplOvj4gwmFVoiqXTXWpZkTJmr/ nwMs1eisEDwB/FkDubpOil6cITQ7x6KyQEb6sXgUppwZYgZrTWVqkzoKblODfrUkzXuO Eh1SKUTPbNRKNfLEKUut6yb5yrDNE2FQ13Qj97SnUKwS406NSrh4xFCZkkQWK5NAIVei LIu11oXCLrPCbvktYDnzsYRZ/3WLI7kLQTVykkwf/FBfIXM+FwYFF96L8fFBN95o3Avy C7ZibxcZNqaPNKKnaQ+JysDatImFxX7mtiRwU2wuvzJF/vV4RLOTbjISi6mDcu4zo0Hs KVIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=I6MkHaCk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id d18-20020a637352000000b005789abf4414si1184723pgn.399.2023.10.11.19.40.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 19:40:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=I6MkHaCk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id F129080236CE; Wed, 11 Oct 2023 19:40:09 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235317AbjJLCjj (ORCPT + 18 others); Wed, 11 Oct 2023 22:39:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376765AbjJLCis (ORCPT ); Wed, 11 Oct 2023 22:38:48 -0400 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C2BDB7; Wed, 11 Oct 2023 19:38:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697078326; x=1728614326; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=uHfPe43lFQFWfjD3bQWKOket+QwgyI5JRCRQGD5er7k=; b=I6MkHaCkozJn10wzm+e86hx7xx7dvCGGO+/1oolAbG4buj3wytCpUWDT lHOYbJW5B3/btkOzj5iPXNABZYPXy49PveOeQWhC+ucj4Cuv2G5IpvF/A k0amkOAw0oAB08I5lC9bCer5PBnFHpmcHxW2fxUMFxp3WOjMPjAmX7Rnz tNOHBbw+bsCMHLiLGddxyRb2ykoqFah+82fjAa99SIUrazpVtqpT91VZu kgRAD8pCPIy3cc/WHLcFTAQltbt9XtYow++YOIhZruUqb0z8UN78pB8SA dIUYLoxcWcoxJXycFhbe8vwH9jBBGZeEdcykenbGx8LJHZU0/PEYLZ9be w==; X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="3402632" X-IronPort-AV: E=Sophos;i="6.03,217,1694761200"; d="scan'208";a="3402632" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 19:38:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="783507867" X-IronPort-AV: E=Sophos;i="6.03,217,1694761200"; d="scan'208";a="783507867" Received: from linux.intel.com ([10.54.29.200]) by orsmga008.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 19:38:42 -0700 Received: from debox1-desk4.intel.com (unknown [10.209.105.238]) by linux.intel.com (Postfix) with ESMTP id 422A3580D95; Wed, 11 Oct 2023 19:38:42 -0700 (PDT) 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 V3 11/16] platform/x86/intel/pmc: Find and register PMC telemetry entries Date: Wed, 11 Oct 2023 19:38:35 -0700 Message-Id: <20231012023840.3845703-12-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231012023840.3845703-1-david.e.box@linux.intel.com> References: <20231012023840.3845703-1-david.e.box@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLACK autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Wed, 11 Oct 2023 19:40:10 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779515699961085318 X-GMAIL-MSGID: 1779515699961085318 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 --- V3 - no change V2 - no change drivers/platform/x86/intel/pmc/Kconfig | 1 + drivers/platform/x86/intel/pmc/core_ssram.c | 52 +++++++++++++++++++++ 2 files changed, 53 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 af405d11919f..1ecfa3804117 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 @@ -24,6 +26,49 @@ DEFINE_FREE(pmc_core_iounmap, void __iomem *, iounmap(_T)); +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) @@ -98,6 +143,9 @@ pmc_core_get_secondary_pmc(struct pmc_dev *pmcdev, int pmc_idx, u32 offset) pwrm_base = get_base(secondary_ssram, SSRAM_PWRM_OFFSET); devid = readw(secondary_ssram + SSRAM_DEVID_OFFSET); + /* Find and register and PMC telemetry entries */ + pmc_add_pmt(pmcdev, ssram_base, main_ssram); + map = pmc_core_find_regmap(pmcdev->regmap_list, devid); if (!map) return -ENODEV; @@ -126,6 +174,9 @@ pmc_core_get_primary_pmc(struct pmc_dev *pmcdev) 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; @@ -165,3 +216,4 @@ int pmc_core_ssram_init(struct pmc_dev *pmcdev) return ret; } +MODULE_IMPORT_NS(INTEL_VSEC); From patchwork Thu Oct 12 02:38:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "David E. Box" X-Patchwork-Id: 151657 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp943337vqb; Wed, 11 Oct 2023 19:41:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHwZ5haladYHlWigHx76oYL3kmPN8VMZMebsuIYVH3GVPvYbr61q/u8wiSbwal3l+gBpPe8 X-Received: by 2002:a05:6a21:3394:b0:163:ab09:193e with SMTP id yy20-20020a056a21339400b00163ab09193emr26278797pzb.1.1697078501390; Wed, 11 Oct 2023 19:41:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697078501; cv=none; d=google.com; s=arc-20160816; b=WZfm/j1S9VcqNl00e0wdSKd/VtCQX419EF4VGQEowO4EruyjV8NEcs2uxmG9+MWU0A cI7SzofA2LoNogpvC9lBnXdSw5SgeXHwjOzj0N7SNeQLCl086mACUpc7HqjV7y95wdEm IhFSo/p2wCKGx0WOOxdh4wJ4vMOgpYLmBIvUHnT2hVtk7DPMyhxdNGG8Criu2UWO178i z8G1xFSZURO19IDB/6Mu80BqPGIIPNqrznFbFs8JTVZGowpcxVlIQVKdLK2rpIoEGMMX 7XiPDd909XSdpdNlXdnBHElBeXusCutGYq6tqqMFFsUD9UVI+iEeNgYPXXyGJRJVB96o o4iw== 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=/LFHDAXx6u2dqfViBXCaiL9MWTjuvBC3sZZFfLht+rw=; fh=d9G4dsZtlI8UONIvGKwhW94hCYEPGxy6CqYeKEG646A=; b=tjvgPvx43aAFeaitZe5BQabAsiRGj6Ge7xeB/nmEO/bojF1ibUfe6suz5b1BljtBQA W6BjS0W3ZkZCNGE3HvuVklEUHVUWyCZs4OuPvSWJPtbkSQpD0Zm7fBGazB4bJrKVIsYK y+FmmIPDsD32fhIIaeUuWgCWFKjsAjUgk671N6/NNkE8ZtJYGfRB9vQpJsXpC0e04ie1 bsQrOFsKUczHCBtKhxUyxq7y13AZNAnbULBA0yJEUx/bs12v9Q1AnY9zMWgxENyRRA/j 9+CfWQAC664S29I3mD8fkxur757Uzp41VMt/Z6fQgrKYivqXFKKjeAzSApKWmNt9UcOD F2dA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="X1s/txOp"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id i16-20020a17090332d000b001bc8a9f5e52si1136439plr.135.2023.10.11.19.41.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 19:41:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="X1s/txOp"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id DC474801BFC2; Wed, 11 Oct 2023 19:40:22 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376948AbjJLCjc (ORCPT + 18 others); Wed, 11 Oct 2023 22:39:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376785AbjJLCiw (ORCPT ); Wed, 11 Oct 2023 22:38:52 -0400 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 630B5B8; Wed, 11 Oct 2023 19:38:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697078326; x=1728614326; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=mBii77f6Tub8OeZTcO0T88l7WLLb4F5mDZGSeHY9/WM=; b=X1s/txOpv3H2o21tsvpq6iRNVJKL6YFsLWbQO80/kcjqPr9dp3S13kuR SpQJbmV3Tp33WIhVIDUKZVFqKTkggwgaUtZN/7bysXlYXhWuIH1stOgD5 J3jaHzM7T7QScp6F/CWFOLdSUBkFxDOleiMrCJwY41qVPvaolg7f7dlp8 Ae4FQ+PihOeJlB9zuOHw00bJdBacL+xZDp8EKwpzL09w6kUgDlmWG+8mk Esg46nPNYPZ8dj6yYKQcsalfRBJ5AeXBVm82AuAP89G2lQe9VkJm/bVn5 lsj8Q9yYfHqHY+EvXMHyaYztU3WEVHLMd7Gm/uspN25Hl/aUbC2UCAkdP g==; X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="3402633" X-IronPort-AV: E=Sophos;i="6.03,217,1694761200"; d="scan'208";a="3402633" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 19:38:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="783507868" X-IronPort-AV: E=Sophos;i="6.03,217,1694761200"; d="scan'208";a="783507868" Received: from linux.intel.com ([10.54.29.200]) by orsmga008.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 19:38:42 -0700 Received: from debox1-desk4.intel.com (unknown [10.209.105.238]) by linux.intel.com (Postfix) with ESMTP id 98A2D580DBE; Wed, 11 Oct 2023 19:38:42 -0700 (PDT) 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 V3 12/16] platform/x86/intel/pmc: Display LPM requirements for multiple PMCs Date: Wed, 11 Oct 2023 19:38:36 -0700 Message-Id: <20231012023840.3845703-13-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231012023840.3845703-1-david.e.box@linux.intel.com> References: <20231012023840.3845703-1-david.e.box@linux.intel.com> MIME-Version: 1.0 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.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 (howler.vger.email [0.0.0.0]); Wed, 11 Oct 2023 19:40:23 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779515786564416771 X-GMAIL-MSGID: 1779515786564416771 From: Rajvi Jingar Update the substate_requirements attribute to display the requirements for all the PMCs on a package. Signed-off-by: Rajvi Jingar Signed-off-by: David E. Box --- V3 - Add missing submitter signoff V2 - no change drivers/platform/x86/intel/pmc/core.c | 129 ++++++++++++++------------ 1 file changed, 71 insertions(+), 58 deletions(-) diff --git a/drivers/platform/x86/intel/pmc/core.c b/drivers/platform/x86/intel/pmc/core.c index e58c8cc286a3..df2bcead1723 100644 --- a/drivers/platform/x86/intel/pmc/core.c +++ b/drivers/platform/x86/intel/pmc/core.c @@ -728,7 +728,7 @@ static int pmc_core_substate_l_sts_regs_show(struct seq_file *s, void *unused) } DEFINE_SHOW_ATTRIBUTE(pmc_core_substate_l_sts_regs); -static void pmc_core_substate_req_header_show(struct seq_file *s) +static void pmc_core_substate_req_header_show(struct seq_file *s, int pmc_index) { struct pmc_dev *pmcdev = s->private; int i, mode; @@ -743,68 +743,81 @@ static void pmc_core_substate_req_header_show(struct seq_file *s) static int pmc_core_substate_req_regs_show(struct seq_file *s, void *unused) { struct pmc_dev *pmcdev = s->private; - struct pmc *pmc = pmcdev->pmcs[PMC_IDX_MAIN]; - const struct pmc_bit_map **maps = pmc->map->lpm_sts; - const struct pmc_bit_map *map; - const int num_maps = pmc->map->lpm_num_maps; - u32 sts_offset = pmc->map->lpm_status_offset; - u32 *lpm_req_regs = pmc->lpm_req_regs; - int mp; - - /* Display the header */ - pmc_core_substate_req_header_show(s); - - /* Loop over maps */ - for (mp = 0; mp < num_maps; mp++) { - u32 req_mask = 0; - u32 lpm_status; - int mode, idx, i, len = 32; - - /* - * Capture the requirements and create a mask so that we only - * show an element if it's required for at least one of the - * enabled low power modes - */ - pmc_for_each_mode(idx, mode, pmcdev) - req_mask |= lpm_req_regs[mp + (mode * num_maps)]; - - /* Get the last latched status for this map */ - lpm_status = pmc_core_reg_read(pmc, sts_offset + (mp * 4)); - - /* Loop over elements in this map */ - map = maps[mp]; - for (i = 0; map[i].name && i < len; i++) { - u32 bit_mask = map[i].bit_mask; - - if (!(bit_mask & req_mask)) - /* - * Not required for any enabled states - * so don't display - */ - continue; - - /* Display the element name in the first column */ - seq_printf(s, "%30s |", map[i].name); - - /* Loop over the enabled states and display if required */ - pmc_for_each_mode(idx, mode, pmcdev) { - if (lpm_req_regs[mp + (mode * num_maps)] & bit_mask) - seq_printf(s, " %9s |", - "Required"); + u32 sts_offset; + u32 *lpm_req_regs; + int num_maps, mp, pmc_index; + + for (pmc_index = 0; pmc_index < ARRAY_SIZE(pmcdev->pmcs); ++pmc_index) { + struct pmc *pmc = pmcdev->pmcs[pmc_index]; + const struct pmc_bit_map **maps; + + if (!pmc) + continue; + + maps = pmc->map->lpm_sts; + num_maps = pmc->map->lpm_num_maps; + sts_offset = pmc->map->lpm_status_offset; + lpm_req_regs = pmc->lpm_req_regs; + + if (!lpm_req_regs) + continue; + + /* Display the header */ + pmc_core_substate_req_header_show(s, pmc_index); + + /* Loop over maps */ + for (mp = 0; mp < num_maps; mp++) { + u32 req_mask = 0; + u32 lpm_status; + const struct pmc_bit_map *map; + int mode, idx, i, len = 32; + + /* + * Capture the requirements and create a mask so that we only + * show an element if it's required for at least one of the + * enabled low power modes + */ + pmc_for_each_mode(idx, mode, pmcdev) + req_mask |= lpm_req_regs[mp + (mode * num_maps)]; + + /* Get the last latched status for this map */ + lpm_status = pmc_core_reg_read(pmc, sts_offset + (mp * 4)); + + /* Loop over elements in this map */ + map = maps[mp]; + for (i = 0; map[i].name && i < len; i++) { + u32 bit_mask = map[i].bit_mask; + + if (!(bit_mask & req_mask)) { + /* + * Not required for any enabled states + * so don't display + */ + continue; + } + + /* Display the element name in the first column */ + seq_printf(s, "pmc%d: %26s |", pmc_index, map[i].name); + + /* Loop over the enabled states and display if required */ + pmc_for_each_mode(idx, mode, pmcdev) { + if (lpm_req_regs[mp + (mode * num_maps)] & bit_mask) + seq_printf(s, " %9s |", + "Required"); + else + seq_printf(s, " %9s |", " "); + } + + /* In Status column, show the last captured state of this agent */ + if (lpm_status & bit_mask) + seq_printf(s, " %9s |", "Yes"); else seq_printf(s, " %9s |", " "); + + seq_puts(s, "\n"); } - - /* In Status column, show the last captured state of this agent */ - if (lpm_status & bit_mask) - seq_printf(s, " %9s |", "Yes"); - else - seq_printf(s, " %9s |", " "); - - seq_puts(s, "\n"); } } - return 0; } DEFINE_SHOW_ATTRIBUTE(pmc_core_substate_req_regs); From patchwork Thu Oct 12 02:38:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "David E. Box" X-Patchwork-Id: 151653 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp942712vqb; Wed, 11 Oct 2023 19:39:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEcqBBIxmAAnyb1hT352iTv1Ljvcop+SavDpLcdu10K8qNG3yN8Z2CCb5vtuNsTAs92zY35 X-Received: by 2002:a05:6a00:d46:b0:68e:369b:a123 with SMTP id n6-20020a056a000d4600b0068e369ba123mr24839047pfv.1.1697078373677; Wed, 11 Oct 2023 19:39:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697078373; cv=none; d=google.com; s=arc-20160816; b=H/japW5qCGrS2i76THScyGvUdsb0KmPs/qEPBUoFyOwfhX46bOKmhMPUE69tPzI6zS Ne12g65DhBGlZGmDya4+PoT2nkamiXfTY6PD+JLIGxkeoBKz8MhtX7QkYGhd0XOj80pO ub2LTAcyzm5BI1Fa0Ezmyj12sfGo8nmtRd4MFbtoBox23UdUdG9NZDrYbcdRxyPUvzmO OJndlK4Sm8IKFVI4Mup9AEPkjriVhDRZeyCqDP2hIEMeBxUYm7fP3s7xkvmUPAoXgcEq X/MLHwakdK8yyjaDLA0wsbzyjJumFEVyOqABipYSJme1GNjCNuvU9AYZJy2HRaXAiYg0 iasw== 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=9atlWHp0xJkqL3c/BNMAi2NiIew41a3TXfuarv4gkA0=; fh=d9G4dsZtlI8UONIvGKwhW94hCYEPGxy6CqYeKEG646A=; b=Mo9iOxXZDAWtbqsOrdsXnReInPwqypZEd3SQR7HYTHDN7QylXhYVLCfR5VvIFW1zlM MMfYTHG0IHu431QMEzgWAetiKpRsXLEg31hAUAKPP/lqCjS0NdqrIpFCWzflHRPtG6KK QI6a0yO2b3Om3Q8WZ0jr/wRUpWJ/cgJZ8FcUqHvge7btdyDFAblgjuZqwr5S8ZHC6CR6 Oia+o6CeRQwiALHqxTZucqeJBvkV62+1jLwfCoZe7IpVw6Y9hDL/l7e5PfJEbBTQHbZH w2qgkm+bQzz57WHjodg0MuD7V+4fzRyzqYX+LWSW6FL3YeAv4JwMbO5YD4wfHlwLJp5m +iMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JFmrl1ts; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id bw10-20020a056a00408a00b006935df3019esi5020566pfb.235.2023.10.11.19.39.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 19:39:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JFmrl1ts; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id CD438811F106; Wed, 11 Oct 2023 19:39:32 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376898AbjJLCj0 (ORCPT + 18 others); Wed, 11 Oct 2023 22:39:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376798AbjJLCiw (ORCPT ); Wed, 11 Oct 2023 22:38:52 -0400 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9550C4; Wed, 11 Oct 2023 19:38:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697078328; x=1728614328; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=hDbmbTK4elmt4RXlTekpC9ipRQ5iuRRveAhVVHEUxms=; b=JFmrl1tsYUHR3iitGlK5lvGt/3GkE89/gKSyHnW7YDfIsM1Z+61PQXVO whdFcjgibtHi8oFDfUgl0XxaREK283vdLioQPMZ7pPBPxI1M46INF9cRY y0kAeuphsyQ8NP9t4CpprLLzrBxwGovPhM7rnM/eej1ip/CC2/Y6WQlZu EQbTF/SLflFOC1rIIauiE5FKBqK7IGR3foiUpFqxW60nQWNbT1uu/gaYW dj8Y6srmsK+as5yvDuLpw3yPdj1ICIUN49F9xgoSCcL53PhHiZuVeO7k0 zH4U9yv0j5UXHhRFyoAaHNL85qSIs1/4vlRKzw9wYDkS7GPVjP9RiO5Ml Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="3402634" X-IronPort-AV: E=Sophos;i="6.03,217,1694761200"; d="scan'208";a="3402634" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 19:38:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="783507870" X-IronPort-AV: E=Sophos;i="6.03,217,1694761200"; d="scan'208";a="783507870" Received: from linux.intel.com ([10.54.29.200]) by orsmga008.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 19:38:42 -0700 Received: from debox1-desk4.intel.com (unknown [10.209.105.238]) by linux.intel.com (Postfix) with ESMTP id BA4B8580D79; Wed, 11 Oct 2023 19:38:42 -0700 (PDT) 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 V3 13/16] platform/x86/intel/pmc: Retrieve LPM information using Intel PMT Date: Wed, 11 Oct 2023 19:38:37 -0700 Message-Id: <20231012023840.3845703-14-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231012023840.3845703-1-david.e.box@linux.intel.com> References: <20231012023840.3845703-1-david.e.box@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Wed, 11 Oct 2023 19:39:32 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779515652880168151 X-GMAIL-MSGID: 1779515652880168151 From: Xi Pardee On supported platforms, the low power mode (LPM) requirements for entering each idle substate are described in Platform Monitoring Technology (PMT) telemetry entries. Provide a function for platform code to attempt to find and read the requirements from the telemetry entries. Signed-off-by: Xi Pardee Signed-off-by: David E. Box --- V3 - no change V2 - remove extra parens drivers/platform/x86/intel/pmc/core.h | 3 + drivers/platform/x86/intel/pmc/core_ssram.c | 135 ++++++++++++++++++++ 2 files changed, 138 insertions(+) diff --git a/drivers/platform/x86/intel/pmc/core.h b/drivers/platform/x86/intel/pmc/core.h index edaa70067e41..85b6f6ae4995 100644 --- a/drivers/platform/x86/intel/pmc/core.h +++ b/drivers/platform/x86/intel/pmc/core.h @@ -320,6 +320,7 @@ struct pmc_reg_map { const u32 lpm_status_offset; const u32 lpm_live_status_offset; const u32 etr3_offset; + const u8 *lpm_reg_index; }; /** @@ -329,6 +330,7 @@ struct pmc_reg_map { * specific attributes */ struct pmc_info { + u32 guid; u16 devid; const struct pmc_reg_map *map; }; @@ -486,6 +488,7 @@ extern const struct pmc_bit_map *mtl_ioem_lpm_maps[]; extern const struct pmc_reg_map mtl_ioem_reg_map; extern void pmc_core_get_tgl_lpm_reqs(struct platform_device *pdev); +extern int pmc_core_ssram_get_lpm_reqs(struct pmc_dev *pmcdev); extern int pmc_core_send_ltr_ignore(struct pmc_dev *pmcdev, u32 value); int pmc_core_resume_common(struct pmc_dev *pmcdev); diff --git a/drivers/platform/x86/intel/pmc/core_ssram.c b/drivers/platform/x86/intel/pmc/core_ssram.c index 1ecfa3804117..8cd5bc4e77f6 100644 --- a/drivers/platform/x86/intel/pmc/core_ssram.c +++ b/drivers/platform/x86/intel/pmc/core_ssram.c @@ -26,6 +26,140 @@ DEFINE_FREE(pmc_core_iounmap, void __iomem *, iounmap(_T)); +/* PCH query */ +#define LPM_HEADER_OFFSET 1 +#define LPM_REG_COUNT 28 +#define LPM_MODE_OFFSET 1 + +static u32 pmc_core_find_guid(struct pmc_info *list, const struct pmc_reg_map *map) +{ + for (; list->map; ++list) + if (list->map == map) + return list->guid; + + return 0; +} + +static int pmc_core_get_lpm_req(struct pmc_dev *pmcdev, struct pmc *pmc) +{ + struct telem_endpoint *ep; + const u8 *lpm_indices; + int num_maps, mode_offset = 0; + int ret, mode, i; + int lpm_size; + u32 guid; + + lpm_indices = pmc->map->lpm_reg_index; + num_maps = pmc->map->lpm_num_maps; + lpm_size = LPM_MAX_NUM_MODES * num_maps; + + guid = pmc_core_find_guid(pmcdev->regmap_list, pmc->map); + if (!guid) + return -ENXIO; + + ep = pmt_telem_find_and_register_endpoint(pmcdev->ssram_pcidev, guid, 0); + if (IS_ERR(ep)) { + dev_dbg(&pmcdev->pdev->dev, "couldn't get telem endpoint %ld", + PTR_ERR(ep)); + return -EPROBE_DEFER; + } + + pmc->lpm_req_regs = devm_kzalloc(&pmcdev->pdev->dev, + lpm_size * sizeof(u32), + GFP_KERNEL); + if (!pmc->lpm_req_regs) { + ret = -ENOMEM; + goto unregister_ep; + } + + /* + * PMC Low Power Mode (LPM) table + * + * In telemetry space, the LPM table contains a 4 byte header followed + * by 8 consecutive mode blocks (one for each LPM mode). Each block + * has a 4 byte header followed by a set of registers that describe the + * IP state requirements for the given mode. The IP mapping is platform + * specific but the same for each block, making for easy analysis. + * Platforms only use a subset of the space to track the requirements + * for their IPs. Callers provide the requirement registers they use as + * a list of indices. Each requirement register is associated with an + * IP map that's maintained by the caller. + * + * Header + * +----+----------------------------+----------------------------+ + * | 0 | REVISION | ENABLED MODES | + * +----+--------------+-------------+-------------+--------------+ + * + * Low Power Mode 0 Block + * +----+--------------+-------------+-------------+--------------+ + * | 1 | SUB ID | SIZE | MAJOR | MINOR | + * +----+--------------+-------------+-------------+--------------+ + * | 2 | LPM0 Requirements 0 | + * +----+---------------------------------------------------------+ + * | | ... | + * +----+---------------------------------------------------------+ + * | 29 | LPM0 Requirements 27 | + * +----+---------------------------------------------------------+ + * + * ... + * + * Low Power Mode 7 Block + * +----+--------------+-------------+-------------+--------------+ + * | | SUB ID | SIZE | MAJOR | MINOR | + * +----+--------------+-------------+-------------+--------------+ + * | 60 | LPM7 Requirements 0 | + * +----+---------------------------------------------------------+ + * | | ... | + * +----+---------------------------------------------------------+ + * | 87 | LPM7 Requirements 27 | + * +----+---------------------------------------------------------+ + * + */ + mode_offset = LPM_HEADER_OFFSET + LPM_MODE_OFFSET; + pmc_for_each_mode(i, mode, pmcdev) { + u32 *req_offset = pmc->lpm_req_regs + (mode * num_maps); + int m; + + for (m = 0; m < num_maps; m++) { + u8 sample_id = lpm_indices[m] + mode_offset; + + ret = pmt_telem_read32(ep, sample_id, req_offset, 1); + if (ret) { + dev_err(&pmcdev->pdev->dev, + "couldn't read Low Power Mode requirements: %d\n", ret); + devm_kfree(&pmcdev->pdev->dev, pmc->lpm_req_regs); + goto unregister_ep; + } + ++req_offset; + } + mode_offset += LPM_REG_COUNT + LPM_MODE_OFFSET; + } + +unregister_ep: + pmt_telem_unregister_endpoint(ep); + + return ret; +} + +int pmc_core_ssram_get_lpm_reqs(struct pmc_dev *pmcdev) +{ + int ret, i; + + if (!pmcdev->ssram_pcidev) + return -ENODEV; + + for (i = 0; i < ARRAY_SIZE(pmcdev->pmcs); ++i) { + if (!pmcdev->pmcs[i]) + continue; + + ret = pmc_core_get_lpm_req(pmcdev, pmcdev->pmcs[i]); + if (ret) + return ret; + } + + return 0; +} + static void pmc_add_pmt(struct pmc_dev *pmcdev, u64 ssram_base, void __iomem *ssram) { @@ -217,3 +351,4 @@ int pmc_core_ssram_init(struct pmc_dev *pmcdev) return ret; } MODULE_IMPORT_NS(INTEL_VSEC); +MODULE_IMPORT_NS(INTEL_PMT_TELEMETRY); From patchwork Thu Oct 12 02:38:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "David E. Box" X-Patchwork-Id: 151650 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp942674vqb; Wed, 11 Oct 2023 19:39:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF9GTBW5fqaPhOQ3fSSxdMNhzXbrwF8mDDMZpE4YgyfhXGl/Uh9BuEjmcMH1ZrsW6wW6qmj X-Received: by 2002:a05:6808:2087:b0:3b2:9c2f:50e0 with SMTP id s7-20020a056808208700b003b29c2f50e0mr4185324oiw.5.1697078366232; Wed, 11 Oct 2023 19:39:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697078366; cv=none; d=google.com; s=arc-20160816; b=dzdKafWEwZRK2KEHfwuLNKWpkBSAI+cy3a5jSaad7zfR8Mya1AuHyvCICY+LVirpAN h6MSEJia2XygJ9o6LbRFK99yksB/eeH5el3Y3V+jObHkETUpkZx3roPkXIBEVieaY3Wt /p8tRqE1fOFcJzEnLdI4ESfmJyVfKpBqYZX244U/9wJEy4+VYFLmqUj3jxlZdo2yUqiy w/mEz10lt2oLKrLSFnLI73LMtzlKJw4W/wUcp7JT2X64fp7AScyX3dATwF13obytU6UX d8AdEKg7DqG60JMYEgIKl2HsodnoLVlrm/qEHfvwPftTRlEuHgeZdWrNg4dYH+7atxGY QAiw== 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=hEb2fwfLmWoFBG/StKS6CR3sAA2cIokXkIgGPZhqEOk=; fh=d9G4dsZtlI8UONIvGKwhW94hCYEPGxy6CqYeKEG646A=; b=myejAOwdQyk+20y2hCqJmEowQCNc7Vl0VGF+6GBQDro4g3gyOuOoxNiPedzPM6dzU6 bxPWTkotqQ0CSCAeA373T4hFYTWYDjUYX7OlmOd4kHOOtrCu6witx3mmu6NpPiIRcABV tSs7llgsPrUXUaEYwd7e1cavH8PecUu+7n0jObBOIkOnWSc2GCaOJ5c9qrESyYw2GxiT EgcAFH3pcXJJFodZGC4zX4stpZOJ9/Uk7OMIePWz0nR3TJHxqH6DMeRIMAoVAGMnpAG4 iOUqkOIZJ6Fw9MwpA/25ic2trcZHq9ZIzPI59jLkbz8fgdFXdh08eYbPatxbqyxsI7gv LLrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fvnW5TuX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id q9-20020a056a00084900b0069347c30c86si14080761pfk.253.2023.10.11.19.39.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 19:39:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fvnW5TuX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 8291B81E6ED1; Wed, 11 Oct 2023 19:39:25 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376943AbjJLCjU (ORCPT + 18 others); Wed, 11 Oct 2023 22:39:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376819AbjJLCiw (ORCPT ); Wed, 11 Oct 2023 22:38:52 -0400 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A77AEC9; Wed, 11 Oct 2023 19:38:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697078329; x=1728614329; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=ZIJn169qKYFjovRIa+YjRGZ9Y5e+FdT/Su2+0S8I/a4=; b=fvnW5TuXFSmrEvSDSr9YunLSDXTLSrFrpcgAxFw+maH90Almz5wYt1RK QS/RMIElKepVp/12PgEb64d/fJdXZqLknjOohWqSiESmY5A/uuS0jy2X7 p6V3AR2vHCWurJoCdLXzcwOb6A7TZ4Vmg9oj2tDzWIZuNm8eUzGBcM1HW JMKfkleHa+rHOlK1kFp824JBW+scCqeLFt7xyarXBELJCdilE8iVyrWh4 LsAFwLaJ6RAmOdUMT9/uCljgfCVTx/NjHExmBaHjG4bxu9L+k76GAg5JC E1ld9Xtvf0sRIhC1Xv/UPucjm27i4ke7MxUmWve7y7EWlFiCGW1LXyPpu g==; X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="3402635" X-IronPort-AV: E=Sophos;i="6.03,217,1694761200"; d="scan'208";a="3402635" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 19:38:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="783507872" X-IronPort-AV: E=Sophos;i="6.03,217,1694761200"; d="scan'208";a="783507872" Received: from linux.intel.com ([10.54.29.200]) by orsmga008.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 19:38:43 -0700 Received: from debox1-desk4.intel.com (unknown [10.209.105.238]) by linux.intel.com (Postfix) with ESMTP id DCF19580D95; Wed, 11 Oct 2023 19:38:42 -0700 (PDT) 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 V3 14/16] platform/x86/intel/pmc: Read low power mode requirements for MTL-M and MTL-P Date: Wed, 11 Oct 2023 19:38:38 -0700 Message-Id: <20231012023840.3845703-15-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231012023840.3845703-1-david.e.box@linux.intel.com> References: <20231012023840.3845703-1-david.e.box@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Wed, 11 Oct 2023 19:39:25 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779515644788726831 X-GMAIL-MSGID: 1779515644788726831 From: Xi Pardee Add support to read the low power mode requirements for Meteor Lake M and Meteor Lake P. Signed-off-by: Xi Pardee Signed-off-by: David E. Box Reviewed-by: Ilpo Järvinen --- V3 - directly return value from pmc_core_ssram_get_lpm_reqs() V2 - fixed unused return value drivers/platform/x86/intel/pmc/mtl.c | 39 +++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/drivers/platform/x86/intel/pmc/mtl.c b/drivers/platform/x86/intel/pmc/mtl.c index d1d3d33fb4b8..7ceeae507f4c 100644 --- a/drivers/platform/x86/intel/pmc/mtl.c +++ b/drivers/platform/x86/intel/pmc/mtl.c @@ -11,6 +11,13 @@ #include #include "core.h" +/* PMC SSRAM PMT Telemetry GUIDS */ +#define SOCP_LPM_REQ_GUID 0x2625030 +#define IOEM_LPM_REQ_GUID 0x4357464 +#define IOEP_LPM_REQ_GUID 0x5077612 + +static const u8 MTL_LPM_REG_INDEX[] = {0, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 20}; + /* * Die Mapping to Product. * Product SOCDie IOEDie PCHDie @@ -465,6 +472,7 @@ const struct pmc_reg_map mtl_socm_reg_map = { .lpm_sts = mtl_socm_lpm_maps, .lpm_status_offset = MTL_LPM_STATUS_OFFSET, .lpm_live_status_offset = MTL_LPM_LIVE_STATUS_OFFSET, + .lpm_reg_index = MTL_LPM_REG_INDEX, }; const struct pmc_bit_map mtl_ioep_pfear_map[] = { @@ -782,6 +790,13 @@ const struct pmc_reg_map mtl_ioep_reg_map = { .ltr_show_sts = mtl_ioep_ltr_show_map, .ltr_ignore_offset = CNP_PMC_LTR_IGNORE_OFFSET, .ltr_ignore_max = ADL_NUM_IP_IGN_ALLOWED, + .lpm_num_maps = ADL_LPM_NUM_MAPS, + .lpm_res_counter_step_x2 = TGL_PMC_LPM_RES_COUNTER_STEP_X2, + .lpm_residency_offset = MTL_LPM_RESIDENCY_OFFSET, + .lpm_priority_offset = MTL_LPM_PRI_OFFSET, + .lpm_en_offset = MTL_LPM_EN_OFFSET, + .lpm_sts_latch_en_offset = MTL_LPM_STATUS_LATCH_EN_OFFSET, + .lpm_reg_index = MTL_LPM_REG_INDEX, }; const struct pmc_bit_map mtl_ioem_pfear_map[] = { @@ -922,6 +937,13 @@ const struct pmc_reg_map mtl_ioem_reg_map = { .ltr_show_sts = mtl_ioep_ltr_show_map, .ltr_ignore_offset = CNP_PMC_LTR_IGNORE_OFFSET, .ltr_ignore_max = ADL_NUM_IP_IGN_ALLOWED, + .lpm_sts_latch_en_offset = MTL_LPM_STATUS_LATCH_EN_OFFSET, + .lpm_num_maps = ADL_LPM_NUM_MAPS, + .lpm_priority_offset = MTL_LPM_PRI_OFFSET, + .lpm_en_offset = MTL_LPM_EN_OFFSET, + .lpm_res_counter_step_x2 = TGL_PMC_LPM_RES_COUNTER_STEP_X2, + .lpm_residency_offset = MTL_LPM_RESIDENCY_OFFSET, + .lpm_reg_index = MTL_LPM_REG_INDEX, }; #define PMC_DEVID_SOCM 0x7e7f @@ -929,16 +951,19 @@ const struct pmc_reg_map mtl_ioem_reg_map = { #define PMC_DEVID_IOEM 0x7ebf static struct pmc_info mtl_pmc_info_list[] = { { - .devid = PMC_DEVID_SOCM, - .map = &mtl_socm_reg_map, + .guid = SOCP_LPM_REQ_GUID, + .devid = PMC_DEVID_SOCM, + .map = &mtl_socm_reg_map, }, { - .devid = PMC_DEVID_IOEP, - .map = &mtl_ioep_reg_map, + .guid = IOEP_LPM_REQ_GUID, + .devid = PMC_DEVID_IOEP, + .map = &mtl_ioep_reg_map, }, { - .devid = PMC_DEVID_IOEM, - .map = &mtl_ioem_reg_map + .guid = IOEM_LPM_REQ_GUID, + .devid = PMC_DEVID_IOEM, + .map = &mtl_ioem_reg_map }, {} }; @@ -1014,5 +1039,5 @@ int mtl_core_init(struct pmc_dev *pmcdev) dev_dbg(&pmcdev->pdev->dev, "ignoring GBE LTR\n"); pmc_core_send_ltr_ignore(pmcdev, 3); - return 0; + return pmc_core_ssram_get_lpm_reqs(pmcdev); } From patchwork Thu Oct 12 02:38:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "David E. Box" X-Patchwork-Id: 151655 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp942914vqb; Wed, 11 Oct 2023 19:40:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG5fKAZjBvTOQeN3jDCOHSLm3Zxo5uskYXXUgKgMf0oQ8VPBaYKxDsDOEyP4r/gTd0qi8xR X-Received: by 2002:a17:90a:3da1:b0:274:60c7:e15a with SMTP id i30-20020a17090a3da100b0027460c7e15amr20375036pjc.4.1697078408560; Wed, 11 Oct 2023 19:40:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697078408; cv=none; d=google.com; s=arc-20160816; b=a2noMMNtIsMfX3H3qKjXx83XDanh6yaCuzX6uvejc9hbQzsP7Uh5NxvcQExd6VPnHK hpvZlNuJDbh2RMfuuh/8mh3gORoSVRtJpx02aieNBU5NBvoNsj5WKKkkaDkDaD0fOe3t gXspPhtJHnepAeiWfc6vx5iaENfet+thmrrgT9rwQHiOqVUTUD45iwce+g6yGOuRVV4j gj6Fmo+VJpSdYKdiTftTP4xDTVGMDgdVqRObaKC/JfXdvj3NoOug1Gk2TmgpkAAYpyNM HX6nPLyeaMLfZPCuCBS16oZ8JFykcnh6lnBdWYKcfYgDqCIMyzOIJo2YFq08GzRNF9J9 0YBg== 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=h97q/+UUEXUtLo+azj3EnKaZZWxf2+Xs4GqkuMuYsSM=; fh=d9G4dsZtlI8UONIvGKwhW94hCYEPGxy6CqYeKEG646A=; b=co7keTBMXqIkXIopeBROiCNaNuU4iU4B2WvmW7c+UtK7GvTiL0k4vwQMSfxA99O8YE RLMJPwpN9ER3rWZeIUUFs/zLOafst8e3QnAMZjo3d1vH5YpIzlHJfdZsgfE8FiwpcxXB +3QhAwC8pAJmbQjECdzWoozXGrovl8UraSrWq9d3j40miotIwEuYSww9KgoXcthB0Drw AIZdfmJ+eQyL+PHUYoIhIhHvqc07ULYBFmIItjvbH4GoUwX9uhcLzb0yv87/pnXdt4h2 Eoc2Vb3yzo3MGpGKagQpRpk9Yp89aUXKIVGtfo3+RO7Zd0mTq2YsZW+RIZp65pjJpsRT tXdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YeaAO9+A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id lk8-20020a17090b33c800b0027d182886aasi1351213pjb.179.2023.10.11.19.40.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 19:40:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YeaAO9+A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id DA093812E34A; Wed, 11 Oct 2023 19:39:53 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376937AbjJLCjR (ORCPT + 18 others); Wed, 11 Oct 2023 22:39:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376806AbjJLCiw (ORCPT ); Wed, 11 Oct 2023 22:38:52 -0400 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E833C6; Wed, 11 Oct 2023 19:38:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697078328; x=1728614328; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=ur94IR6OdCejLPVD9UGB+HF3JbE3eQmG5tryg1LLLJs=; b=YeaAO9+AClEfp0mKxC76fYRLtBvysQ9WwxYJVavY06cJO2yrxaMwBQ20 j5p4RNkyQlJCvZMmoh8OOAHRsbd9ugxqYuzfLs9aRysLiQLxg+u5ybSVb znY3Ydb3Ua8dhkxyN6NACO9eH4w1WRCaqafRce3igWFmSUY2fMC1y5RXw p4EQ8dOpKZ8AY+oF1XwmCmqD+RgybQWUx4FNLe6qvWaJM5gzv9M78Y/Sf CAifQ+a4lHRKOim9daFmVUjNMCcOhdMNqpll5hVCROVZyOChqcO2L8VGn IP++SONoI7S2ST+34MDc1hMBqt2pT0MX4fXgmyCPz2isQwfBMeGuMIA4u w==; X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="3402636" X-IronPort-AV: E=Sophos;i="6.03,217,1694761200"; d="scan'208";a="3402636" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 19:38:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="783507874" X-IronPort-AV: E=Sophos;i="6.03,217,1694761200"; d="scan'208";a="783507874" Received: from linux.intel.com ([10.54.29.200]) by orsmga008.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 19:38:43 -0700 Received: from debox1-desk4.intel.com (unknown [10.209.105.238]) by linux.intel.com (Postfix) with ESMTP id 0A719580DBE; Wed, 11 Oct 2023 19:38:43 -0700 (PDT) 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 V3 15/16] platform/x86/intel/pmc: Add debug attribute for Die C6 counter Date: Wed, 11 Oct 2023 19:38:39 -0700 Message-Id: <20231012023840.3845703-16-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231012023840.3845703-1-david.e.box@linux.intel.com> References: <20231012023840.3845703-1-david.e.box@linux.intel.com> MIME-Version: 1.0 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.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 (pete.vger.email [0.0.0.0]); Wed, 11 Oct 2023 19:39:53 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779515689147510767 X-GMAIL-MSGID: 1779515689147510767 Add a "die_c6_us_show" debugfs attribute. Reads the counter value using Intel Platform Monitoring Technology (PMT) driver API. This counter is useful for determining the idle residency of CPUs in the compute tile. Signed-off-by: David E. Box --- V3 - Split previous PATCH V2 13. Separates implementation (this patch) from platform specific use (next patch) V2 - Remove use of __func__ - Use HZ_PER_MHZ - Fix missing newlines in printks drivers/platform/x86/intel/pmc/core.c | 55 +++++++++++++++++++++++++++ drivers/platform/x86/intel/pmc/core.h | 4 ++ 2 files changed, 59 insertions(+) diff --git a/drivers/platform/x86/intel/pmc/core.c b/drivers/platform/x86/intel/pmc/core.c index df2bcead1723..b90ee8c896f4 100644 --- a/drivers/platform/x86/intel/pmc/core.c +++ b/drivers/platform/x86/intel/pmc/core.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -27,6 +28,7 @@ #include #include "core.h" +#include "../pmt/telemetry.h" /* Maximum number of modes supported by platfoms that has low power mode capability */ const char *pmc_lpm_modes[] = { @@ -822,6 +824,47 @@ static int pmc_core_substate_req_regs_show(struct seq_file *s, void *unused) } DEFINE_SHOW_ATTRIBUTE(pmc_core_substate_req_regs); +static unsigned int pmc_core_get_crystal_freq(void) +{ + unsigned int eax_denominator, ebx_numerator, ecx_hz, edx; + + if (boot_cpu_data.cpuid_level < 0x15) + return 0; + + eax_denominator = ebx_numerator = ecx_hz = edx = 0; + + /* CPUID 15H TSC/Crystal ratio, plus optionally Crystal Hz */ + cpuid(0x15, &eax_denominator, &ebx_numerator, &ecx_hz, &edx); + + if (ebx_numerator == 0 || eax_denominator == 0) + return 0; + + return ecx_hz; +} + +static int pmc_core_die_c6_us_show(struct seq_file *s, void *unused) +{ + struct pmc_dev *pmcdev = s->private; + u64 die_c6_res, count; + int ret; + + if (!pmcdev->crystal_freq) { + dev_warn_once(&pmcdev->pdev->dev, "Bad crystal frequency\n"); + return -EINVAL; + } + + ret = pmt_telem_read(pmcdev->punit_ep, pmcdev->die_c6_offset, + &count, 1); + if (ret) + return ret; + + die_c6_res = div64_u64(count * HZ_PER_MHZ, pmcdev->crystal_freq); + seq_printf(s, "%llu\n", die_c6_res); + + return 0; +} +DEFINE_SHOW_ATTRIBUTE(pmc_core_die_c6_us); + static int pmc_core_lpm_latch_mode_show(struct seq_file *s, void *unused) { struct pmc_dev *pmcdev = s->private; @@ -1118,6 +1161,12 @@ static void pmc_core_dbgfs_register(struct pmc_dev *pmcdev) pmcdev->dbgfs_dir, pmcdev, &pmc_core_substate_req_regs_fops); } + + if (pmcdev->has_die_c6) { + debugfs_create_file("die_c6_us_show", 0444, + pmcdev->dbgfs_dir, pmcdev, + &pmc_core_die_c6_us_fops); + } } static const struct x86_cpu_id intel_pmc_core_ids[] = { @@ -1212,6 +1261,10 @@ static void pmc_core_clean_structure(struct platform_device *pdev) pci_dev_put(pmcdev->ssram_pcidev); pci_disable_device(pmcdev->ssram_pcidev); } + + if (pmcdev->punit_ep) + pmt_telem_unregister_endpoint(pmcdev->punit_ep); + platform_set_drvdata(pdev, NULL); mutex_destroy(&pmcdev->lock); } @@ -1232,6 +1285,8 @@ static int pmc_core_probe(struct platform_device *pdev) if (!pmcdev) return -ENOMEM; + pmcdev->crystal_freq = pmc_core_get_crystal_freq(); + platform_set_drvdata(pdev, pmcdev); pmcdev->pdev = pdev; diff --git a/drivers/platform/x86/intel/pmc/core.h b/drivers/platform/x86/intel/pmc/core.h index 85b6f6ae4995..6d7673145f90 100644 --- a/drivers/platform/x86/intel/pmc/core.h +++ b/drivers/platform/x86/intel/pmc/core.h @@ -16,6 +16,8 @@ #include #include +struct telem_endpoint; + #define SLP_S0_RES_COUNTER_MASK GENMASK(31, 0) #define PMC_BASE_ADDR_DEFAULT 0xFE000000 @@ -357,6 +359,7 @@ struct pmc { * @devs: pointer to an array of pmc pointers * @pdev: pointer to platform_device struct * @ssram_pcidev: pointer to pci device struct for the PMC SSRAM + * @crystal_freq: crystal frequency from cpuid * @dbgfs_dir: path to debugfs interface * @pmc_xram_read_bit: flag to indicate whether PMC XRAM shadow registers * used to read MPHY PG and PLL status are available @@ -374,6 +377,7 @@ struct pmc_dev { struct dentry *dbgfs_dir; struct platform_device *pdev; struct pci_dev *ssram_pcidev; + unsigned int crystal_freq; int pmc_xram_read_bit; struct mutex lock; /* generic mutex lock for PMC Core */ From patchwork Thu Oct 12 02:38:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "David E. Box" X-Patchwork-Id: 151652 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp942713vqb; Wed, 11 Oct 2023 19:39:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHPgW6DcEwlVECpUEyJZyurmy4AKQx1yYa9gtUychcNFI9JQxspKzmjkYc0ShXaxY8iV+OI X-Received: by 2002:a05:6808:3388:b0:3ab:8ae5:e7c6 with SMTP id ce8-20020a056808338800b003ab8ae5e7c6mr22072744oib.1.1697078373807; Wed, 11 Oct 2023 19:39:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697078373; cv=none; d=google.com; s=arc-20160816; b=W/PaLnriPDmSvbgO0U/Wghg5pJwZxCt9Vj5IoMbpSXSi7u2b7CEEyi6lTohDzXUzig 5g+/pub8L5QVoTfyf7b9r8SXMD+KElx65U6mODWpBbPzKMogVEUbeuZEsAJwhiOYuU7c l6qA43N0iuEDM+ECsoy7YJTiADB9joCknQNWITtDEfc9d8Tp4/5oEn0Vda+SY55u0SNS AeCYOg5Kd/uKQVDboe919ya9roH+7gmXrxe/NhDYf7JoJX4If+FEmv4XQ5uCgW048OOh IMqpGZlSDmKps/x/1SXs1iRo/f3JW0KqlbB6Pe6sx5DX9zg5SbsKDbFWumdo+oANFYSP f34Q== 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=5igJtFsutkmRQEwx1ypnmXXt1/Gn0R8UBV0I7i4d3SM=; fh=d9G4dsZtlI8UONIvGKwhW94hCYEPGxy6CqYeKEG646A=; b=tmUtzH6SjtzAgdBDGlJiBVYGFUt2zfqKgOPeFmLJhyDpaj9mH0WOIJ/w+vZBT0KWno L32Jb4d4HPDXd42aF5G4Rmn0UxjlWi1VWt+gkkDaUCiO2zdk+8atQ7HEy6IVA9ah2Y8o +XeFrbx3CBsQtTRo46AXxsOpxlG9o8jXhmPDCOdoMitMXBixhUuXWoxD+kgWtToGg4LS 4Rrp+wrM9DiI4BKHFL8ccjyaJZr2wH04tn24QfPHbVB/YYaY8l4vRCxCCVkM20Lk1NIJ C4+AVauEHAzGE4r58LwFQzc5St328P0D5NH09I4cKguGa1QNMZ5MulCu5Uey2P5gfyzX zcfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=brkMSsvf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id n27-20020a634d5b000000b00578dfa34d95si1129336pgl.574.2023.10.11.19.39.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 19:39:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=brkMSsvf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 579B281E64BD; Wed, 11 Oct 2023 19:39:32 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376666AbjJLCj3 (ORCPT + 18 others); Wed, 11 Oct 2023 22:39:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376824AbjJLCiw (ORCPT ); Wed, 11 Oct 2023 22:38:52 -0400 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4629DD3; Wed, 11 Oct 2023 19:38:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697078329; x=1728614329; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=oAUveAvdtna8f06zEJwix8Mg346cwI/ZjTYXEiCeEBw=; b=brkMSsvfPC7g7UMklXlFC1d+QVTA/1UKguKP2dDGowLq0ApCMDi6eEwO B1L+P3mPRlepIhdZrIrDs38YkurZcsOi2aIkojAYVlWegAUuyTVQFmPwk ABF/RZWNXx8QA/tO2ydIWUwxWhfRMKWKtDhiMVxVbF6dqixz3S1VvyaE0 cBoude7xTylyTwB36YDNZW4+dzsIwjvn70PmeFMdQfHC76VvzQWPtV9Jd zQ7etwttgs14lJoYc0UnnJsdoJ7DT7jo+opc9GqNPBdPj3C7r6AhlxLzJ nhJEf4+yaeJqT3JRu75WqUmJCV7Omx8IhCFMv1+GXu8qg5qj4Mby5fQh4 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="3402637" X-IronPort-AV: E=Sophos;i="6.03,217,1694761200"; d="scan'208";a="3402637" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 19:38:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="783507875" X-IronPort-AV: E=Sophos;i="6.03,217,1694761200"; d="scan'208";a="783507875" Received: from linux.intel.com ([10.54.29.200]) by orsmga008.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 19:38:43 -0700 Received: from debox1-desk4.intel.com (unknown [10.209.105.238]) by linux.intel.com (Postfix) with ESMTP id 30186580D79; Wed, 11 Oct 2023 19:38:43 -0700 (PDT) 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 V3 16/16] platform/x86/intel/pmc: Show Die C6 counter on Meteor Lake Date: Wed, 11 Oct 2023 19:38:40 -0700 Message-Id: <20231012023840.3845703-17-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231012023840.3845703-1-david.e.box@linux.intel.com> References: <20231012023840.3845703-1-david.e.box@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Wed, 11 Oct 2023 19:39:32 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779515652818256170 X-GMAIL-MSGID: 1779515652818256170 Expose the Die C6 counter on Meteor Lake. Signed-off-by: David E. Box --- V3 - Split PATCH V2 13. Separates implementation (previous patch) from platform specific use (this patch) drivers/platform/x86/intel/pmc/mtl.c | 32 ++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/drivers/platform/x86/intel/pmc/mtl.c b/drivers/platform/x86/intel/pmc/mtl.c index 7ceeae507f4c..38c2f946ec23 100644 --- a/drivers/platform/x86/intel/pmc/mtl.c +++ b/drivers/platform/x86/intel/pmc/mtl.c @@ -10,12 +10,17 @@ #include #include "core.h" +#include "../pmt/telemetry.h" /* PMC SSRAM PMT Telemetry GUIDS */ #define SOCP_LPM_REQ_GUID 0x2625030 #define IOEM_LPM_REQ_GUID 0x4357464 #define IOEP_LPM_REQ_GUID 0x5077612 +/* Die C6 from PUNIT telemetry */ +#define MTL_PMT_DMU_DIE_C6_OFFSET 15 +#define MTL_PMT_DMU_GUID 0x1A067102 + static const u8 MTL_LPM_REG_INDEX[] = {0, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 20}; /* @@ -968,6 +973,32 @@ static struct pmc_info mtl_pmc_info_list[] = { {} }; +static void mtl_punit_pmt_init(struct pmc_dev *pmcdev) +{ + struct telem_endpoint *ep; + struct pci_dev *pcidev; + + pcidev = pci_get_domain_bus_and_slot(0, 0, PCI_DEVFN(10, 0)); + if (!pcidev) { + dev_err(&pmcdev->pdev->dev, "PUNIT PMT device not found.\n"); + return; + } + + ep = pmt_telem_find_and_register_endpoint(pcidev, MTL_PMT_DMU_GUID, 0); + if (IS_ERR(ep)) { + dev_err(&pmcdev->pdev->dev, + "pmc_core: couldn't get DMU telem endpoint, %ld\n", + PTR_ERR(ep)); + return; + } + + pci_dev_put(pcidev); + pmcdev->punit_ep = ep; + + pmcdev->has_die_c6 = true; + pmcdev->die_c6_offset = MTL_PMT_DMU_DIE_C6_OFFSET; +} + #define MTL_GNA_PCI_DEV 0x7e4c #define MTL_IPU_PCI_DEV 0x7d19 #define MTL_VPU_PCI_DEV 0x7d1d @@ -1032,6 +1063,7 @@ int mtl_core_init(struct pmc_dev *pmcdev) } pmc_core_get_low_power_modes(pmcdev); + mtl_punit_pmt_init(pmcdev); /* Due to a hardware limitation, the GBE LTR blocks PC10 * when a cable is attached. Tell the PMC to ignore it.