From patchwork Thu Feb 2 01:07:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: srinivas pandruvada X-Patchwork-Id: 51620 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp606815wrn; Wed, 1 Feb 2023 17:10:55 -0800 (PST) X-Google-Smtp-Source: AK7set/1uTcPP9v7xItveEvlc6VPh/YvY9nIC07PQ/RcYZV9XSnlbIePJnkIjBGJ8s+lgc+krVwv X-Received: by 2002:a17:906:7e4a:b0:886:7e24:82eb with SMTP id z10-20020a1709067e4a00b008867e2482ebmr4110090ejr.21.1675300255193; Wed, 01 Feb 2023 17:10:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675300255; cv=none; d=google.com; s=arc-20160816; b=WZhdR7agkUvuspY0xqOiG6GQN9axcSOdsN/x4sJecqR02Ylj35K5T7M58bDy62DEnP P/jz2JOtqJ2b6VZ30yLgOSVuprVoHv5GL1e38SEama6ZzRNu8Cd//94oqLXap6UNksih vSNr2yc+1FYm8erw6uxJQ+f3y6aXZzBtDq5d4SgHQFC3Aa3SOvwMYmd+4N0XZ63WIcU6 9SCFSYGAp2LnVxv39X9xOM1EzkVa5Yc8C620JQrzd69Io6WnjGy2i95xAzjpne+T1AW4 vnZX0pbPc67ZMzDm0fYYLUrMDsYD9kThHBxFdSVNH+fMPIBOvmHNZmHypC1Ukc2Q+ckv q0CA== 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:cc:to:from :dkim-signature; bh=EYQQXEkmeahNiw925FS0Vgzin1uSKNiBCNQDU58sgDI=; b=tqDezUiQDnzgMeJRHfBhEDoo8Q/59STnETNdu1d35OfwuI4Fo7RIlqgliQfQhM2Noc Y5G1L2f/ZElTGJ5YvHUyWbHzhYutiFjPh2Kqlhsz/cxGrwtAg729BJcRQrJx6LhyV4WY hWF1SmpERQdVRrvMaHhBbLxkZrl0o+6QkEjLzQkyjsW/diIyyHjcpxI7z8v/wQieINGB ssp140Vej9LNfKOfzXuPXwcVLhDocH27cidDERp5n7NAt64zNr0Y2dkEv/72q27OV7vl /OuIv+jCCz/swjofq4PJ9+DSJg5VpMPgbX0N8U78WBvEPRfKtBBfsNgvgbgONtKgl9pm hWwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BdWTLquQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t30-20020a50ab5e000000b0046844a8111dsi6457116edc.533.2023.02.01.17.10.31; Wed, 01 Feb 2023 17:10:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BdWTLquQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230203AbjBBBJE (ORCPT + 99 others); Wed, 1 Feb 2023 20:09:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229471AbjBBBJD (ORCPT ); Wed, 1 Feb 2023 20:09:03 -0500 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E1493FF15; Wed, 1 Feb 2023 17:09:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675300141; x=1706836141; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3lMOfD9F6HuX4w1wpmWNiLldjGCwlcw1Bc5PlcqtZGk=; b=BdWTLquQStoqvr3AYh73dCP9fXsv9OUc571XyhIk1WuS/richcZrytHC PRJNhNEH1J+nn9gFFlTxyTuJDTCC5jLmDFUpWJJ6xo9muWw9eaEdJWYoF zBdoVZqRi2N9Fl8gbPNoNpCvt6/N0o/JDq3BY+eB/mduVbRzwAOEBvZYc qN/0BcWJhvyhvmSlnrDjc+sLaM2vrt8wlb72UZhacA47AjFDJW2Rig9Aq +RCkE6VFlpwS6GJHqu4K6K2ZNs6+RaibC7oLayq67TdhQs1TCZ9kY/GHW 3OdvL4J4WUHfSEA1g/YegcN4BRvClZYNgfZaw2zF03+nMXD/+TmS/2rLm A==; X-IronPort-AV: E=McAfee;i="6500,9779,10608"; a="355654303" X-IronPort-AV: E=Sophos;i="5.97,266,1669104000"; d="scan'208";a="355654303" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2023 17:08:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10608"; a="665087924" X-IronPort-AV: E=Sophos;i="5.97,266,1669104000"; d="scan'208";a="665087924" Received: from spandruv-desk.jf.intel.com ([10.54.75.8]) by orsmga002.jf.intel.com with ESMTP; 01 Feb 2023 17:08:15 -0800 From: Srinivas Pandruvada To: hdegoede@redhat.com, markgross@kernel.org Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Pandruvada , "David E . Box" Subject: [PATCH 1/7] platform/x86/intel/vsec: Add TPMI ID Date: Wed, 1 Feb 2023 17:07:32 -0800 Message-Id: <20230202010738.2186174-2-srinivas.pandruvada@linux.intel.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230202010738.2186174-1-srinivas.pandruvada@linux.intel.com> References: <20230202010738.2186174-1-srinivas.pandruvada@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756679639967457243?= X-GMAIL-MSGID: =?utf-8?q?1756679639967457243?= Add TPMI (Topology Aware Register and PM Capsule Interface) VSEC ID to create an aux device. This will allow TPMI driver to enumerate on this aux device. Signed-off-by: Srinivas Pandruvada Acked-by: David E. Box --- drivers/platform/x86/intel/vsec.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/platform/x86/intel/vsec.c b/drivers/platform/x86/intel/vsec.c index bb81b8b1f7e9..a82b2a5ed99d 100644 --- a/drivers/platform/x86/intel/vsec.c +++ b/drivers/platform/x86/intel/vsec.c @@ -64,6 +64,7 @@ enum intel_vsec_id { VSEC_ID_WATCHER = 3, VSEC_ID_CRASHLOG = 4, VSEC_ID_SDSI = 65, + VSEC_ID_TPMI = 66, }; static enum intel_vsec_id intel_vsec_allow_list[] = { @@ -71,6 +72,7 @@ static enum intel_vsec_id intel_vsec_allow_list[] = { VSEC_ID_WATCHER, VSEC_ID_CRASHLOG, VSEC_ID_SDSI, + VSEC_ID_TPMI, }; static const char *intel_vsec_name(enum intel_vsec_id id) @@ -88,6 +90,9 @@ static const char *intel_vsec_name(enum intel_vsec_id id) case VSEC_ID_SDSI: return "sdsi"; + case VSEC_ID_TPMI: + return "tpmi"; + default: return NULL; } From patchwork Thu Feb 2 01:07:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: srinivas pandruvada X-Patchwork-Id: 51619 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp606698wrn; Wed, 1 Feb 2023 17:10:37 -0800 (PST) X-Google-Smtp-Source: AK7set9EYB1W0nIiI9Y4N2/i3fJwcL0/QStpXZ36kqAaoigWMZ6Iq8H1J4qbHOe4MCjrkv2g0ZSv X-Received: by 2002:a17:906:fb19:b0:86b:9216:2ddb with SMTP id lz25-20020a170906fb1900b0086b92162ddbmr4787484ejb.52.1675300237748; Wed, 01 Feb 2023 17:10:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675300237; cv=none; d=google.com; s=arc-20160816; b=ZaFnHwnwiryOY1otAnrPWzcYuDzmah/SLsTB/M6aCBLGvy+F6CJOtWQWzoNQHOiwm7 gtFcOCCES4SxONS2NdwlbXfkbDeJx2n7bvYzaSI6x/RKpZe8x80gmiBMVJxf0oXstVK5 /SZfdIZZ5xqocyO+9qO6XGGfx0KdQYhkc9lrT56sO95XpViKHAeei5gdrxuomgfu2z4A 7eFaFdSkiIbrjGUGZFtHt7sY7J/WfG1q5zbdAfoxkuD453yNAaYPblvckv6Lo0qjPgEd tcwxdOkMgbzzATWsb+uQ0TcXMru9+4M9CORxiQOvjK8+nCZHu21K+OixfZ4ZN4/yyor/ i9XA== 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:cc:to:from :dkim-signature; bh=uEOBi+OneXLPh+C2otbc5+cdHJ4DR2bQqClFkLUNHUg=; b=nVZKjOZZamsbabfMySo5mEOrtoLu5JN0pRIy1ZPMtFNnz2A6oJn/Xze+xMMZc/P1P3 bu+6vOPdDCt0gvsmFHwQsKxRvY7Tviq6+CrlsmB1xtFQ6EsCna3iT/Y9qwfiy4eU27QH AXE7hfMcRW0bozdlBSHe68yjaGUyHV204uyh/yqkzLB3o1bDsy7B0V4v8FQMAaMBn/P3 RH8qtSfDgKFIZVIZHLtjNgosSfU+vdkpXaCLOPmnAc9Qt/rX/oxUD217nDIsrrGfvMUX FO1qaKu8nA6ffVet/AmkuQ7m5uH0Jki2PASkzRpQx1HsGnMezzRVQ5YxKiml5rdLc4Qq gPAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="HqUE/Ji8"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z4-20020a056402274400b004a23fed6eddsi15979780edd.449.2023.02.01.17.10.14; Wed, 01 Feb 2023 17:10:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="HqUE/Ji8"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230462AbjBBBJQ (ORCPT + 99 others); Wed, 1 Feb 2023 20:09:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229551AbjBBBJD (ORCPT ); Wed, 1 Feb 2023 20:09:03 -0500 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1F0A4ED26; Wed, 1 Feb 2023 17:09:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675300141; x=1706836141; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=l3Pi5pRFRYGc5u8IPh/RxqSovVxp2fgjAvKiIcXzht4=; b=HqUE/Ji8t4NpBP4KdByyyG6SiFnxtagafbT2GkZuoXCeNtpwSFCWxMgG Psyf452JjuaCw6WORY/6kOYsigAiEEnfsKA6MiRdn6LBccCivqy9NKhDW DYt8A0ryQNAaWtbP8RY7dEnrv6aWwzwYGFfTsd1zhFRZ1wHkDNmk/Kyb4 2nvbYdK3Ji1cIjtg0RlCt/vZbBPd5WU8bSaPmOFKMV7Ym4Su4ehlNWO7n k7DV4YW9Fgi4EfcvRKeWUw6ryWZAZz4ATkoJSjQ9da1BAyv0U7UbUhWnt kN4yvv4K75ltez7KLWPNSGJmXTmZ2Mg7d5a8OTUaCL3Lu2p1WSE3rsWS3 g==; X-IronPort-AV: E=McAfee;i="6500,9779,10608"; a="355654307" X-IronPort-AV: E=Sophos;i="5.97,266,1669104000"; d="scan'208";a="355654307" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2023 17:08:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10608"; a="665087925" X-IronPort-AV: E=Sophos;i="5.97,266,1669104000"; d="scan'208";a="665087925" Received: from spandruv-desk.jf.intel.com ([10.54.75.8]) by orsmga002.jf.intel.com with ESMTP; 01 Feb 2023 17:08:15 -0800 From: Srinivas Pandruvada To: hdegoede@redhat.com, markgross@kernel.org Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Pandruvada , "David E . Box" Subject: [PATCH 2/7] platform/x86/intel/vsec: Enhance and Export intel_vsec_add_aux() Date: Wed, 1 Feb 2023 17:07:33 -0800 Message-Id: <20230202010738.2186174-3-srinivas.pandruvada@linux.intel.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230202010738.2186174-1-srinivas.pandruvada@linux.intel.com> References: <20230202010738.2186174-1-srinivas.pandruvada@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756679622161801987?= X-GMAIL-MSGID: =?utf-8?q?1756679622161801987?= Remove static for intel_vsec_add_aux() and export this interface so that it can be used by other vsec related modules. This driver creates aux devices by parsing PCI-VSEC, which allows individual drivers to load on those devices. Those driver may further create more devices on aux bus by parsing the PCI MMIO region. For example, TPMI (Topology Aware Register and PM Capsule Interface) creates device nodes for power management features by parsing MMIO region. When TPMI driver creates devices, it can reuse existing function intel_vsec_add_aux() to create aux devices with TPMI device as the parent. Signed-off-by: Srinivas Pandruvada Acked-by: David E. Box --- drivers/platform/x86/intel/vsec.c | 16 +++++++++++----- drivers/platform/x86/intel/vsec.h | 4 ++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/platform/x86/intel/vsec.c b/drivers/platform/x86/intel/vsec.c index a82b2a5ed99d..b936fc5776d7 100644 --- a/drivers/platform/x86/intel/vsec.c +++ b/drivers/platform/x86/intel/vsec.c @@ -138,8 +138,9 @@ static void intel_vsec_dev_release(struct device *dev) kfree(intel_vsec_dev); } -static int intel_vsec_add_aux(struct pci_dev *pdev, struct intel_vsec_device *intel_vsec_dev, - const char *name) +int intel_vsec_add_aux(struct pci_dev *pdev, struct device *parent, + struct intel_vsec_device *intel_vsec_dev, + const char *name) { struct auxiliary_device *auxdev = &intel_vsec_dev->auxdev; int ret, id; @@ -150,9 +151,12 @@ static int intel_vsec_add_aux(struct pci_dev *pdev, struct intel_vsec_device *in return ret; } + if (!parent) + parent = &pdev->dev; + auxdev->id = ret; auxdev->name = name; - auxdev->dev.parent = &pdev->dev; + auxdev->dev.parent = parent; auxdev->dev.release = intel_vsec_dev_release; ret = auxiliary_device_init(auxdev); @@ -169,7 +173,7 @@ static int intel_vsec_add_aux(struct pci_dev *pdev, struct intel_vsec_device *in return ret; } - ret = devm_add_action_or_reset(&pdev->dev, intel_vsec_remove_aux, + ret = devm_add_action_or_reset(parent, intel_vsec_remove_aux, auxdev); if (ret < 0) return ret; @@ -182,6 +186,7 @@ static int intel_vsec_add_aux(struct pci_dev *pdev, struct intel_vsec_device *in return 0; } +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) @@ -239,7 +244,8 @@ 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, intel_vsec_dev, intel_vsec_name(header->id)); + return intel_vsec_add_aux(pdev, NULL, intel_vsec_dev, + intel_vsec_name(header->id)); } static bool intel_vsec_walk_header(struct pci_dev *pdev, diff --git a/drivers/platform/x86/intel/vsec.h b/drivers/platform/x86/intel/vsec.h index 3deeb05cf394..d02c340fd458 100644 --- a/drivers/platform/x86/intel/vsec.h +++ b/drivers/platform/x86/intel/vsec.h @@ -40,6 +40,10 @@ struct intel_vsec_device { int num_resources; }; +int intel_vsec_add_aux(struct pci_dev *pdev, struct device *parent, + struct intel_vsec_device *intel_vsec_dev, + const char *name); + static inline struct intel_vsec_device *dev_to_ivdev(struct device *dev) { return container_of(dev, struct intel_vsec_device, auxdev.dev); From patchwork Thu Feb 2 01:07:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: srinivas pandruvada X-Patchwork-Id: 51618 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp606640wrn; Wed, 1 Feb 2023 17:10:28 -0800 (PST) X-Google-Smtp-Source: AK7set89+c9MGfE9yLxPeVSdKCOMdx8+9RRd+kwoSYOEF78NGg6GQr5JhmcIRfFEAFmmEUgqGRn5 X-Received: by 2002:a05:6402:e0e:b0:4a2:7b8d:f3c4 with SMTP id h14-20020a0564020e0e00b004a27b8df3c4mr4933741edh.7.1675300228152; Wed, 01 Feb 2023 17:10:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675300228; cv=none; d=google.com; s=arc-20160816; b=HJOp7NX9x2pdEmWpi6pyJITQwF+WA6BdBN99s9T+cEzGgEs1/+aLI+CHKrkpX7OWQF Yir1so1yLOcVWsFwrXOXIRJOn/26HJe95/rZiihmYiMRkmbAHl92yP6GZF+SX6S+Jj1u LjjPQ4lykxlD5qdn3bgL9GoltQdZ1A6DpAhLWt1fGANKGpgerhwMO/5mkzuFOPb3z5BB Ay0A1EZSL1IT2+8CoH9aUEB+M0nLRHIJ5l5dHqeGikP0CqbwjBeMbW77NQjM77VBZhdP TgjxLvBoE8BUv8nr8p0+JfkmKmG6psdCsqUsB1h7dzAKgPebYHKmt403xMb25Ey/va6U xo/Q== 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:cc:to:from :dkim-signature; bh=4+LIOY0szxUFLbybVW2IEoov6yAwozgeYMl5/cjGTSU=; b=mFoNGyl0QqrYvBYTOAETIualgFwQqauvBpEnilUbZuv8Y6ie6KEMwinCRSBpKtekdb dCj9tJI4owMyfObDB3ME4UOWsdFtPqY3nRjU0RqhNN2cQnggcLXeOFbG5v0AfClUrWIL AmZOu4Vdepn2fJopxgO3hXoD/FredH4NByh6KUuH7Z34Ap8XRltuRV0TRnVbdvVlKpKq uldqtdl4I69tV0SBaOg4ZZNy7fPvLoNBVH69nN51d7jzEvcuHZlgDRCwlhQPU1605ezq tczQglRbCgdAZGR2Z8X85HzQY1g6kdAb6zNKOo+VV8+VzzrdzykPhEguUjrCM/+ICvRY I8Tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hGvxJRNW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b8-20020a509f08000000b004a213b19ba2si19973259edf.1.2023.02.01.17.10.04; Wed, 01 Feb 2023 17:10:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hGvxJRNW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230417AbjBBBJN (ORCPT + 99 others); Wed, 1 Feb 2023 20:09:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229632AbjBBBJD (ORCPT ); Wed, 1 Feb 2023 20:09:03 -0500 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECE7246174; Wed, 1 Feb 2023 17:09:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675300142; x=1706836142; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=MmA/+gLVYlCrWM54OgGMSsjZO5kDppV+ZBRtY3CYSqs=; b=hGvxJRNW5Ar8lsa3s+3GYq8+lZzbsZ6jIMY8p3N/+6zYpF/MCDLrv71P QLku44ib6x22vepuL9MARyKijpYchByO/1h6nCplsQxc9oFDO/KjDFT6i 5Ts2vC9OGA4+EhefUIv0oFn0u7Dd3bdYxa8JX6ocSuUvqnL+JwdQXHkUX tiUENxa9IGzXopQh4SrXln6zGtA/VzR3hwyZE6ndgHfQUVkbxhS8LHjl4 8LFM2YG59Gc3qCXYOYE+8f28xGUfIHIocXtpq/NZ1xW7OpCU3LYO11ilI INaCeFxMWK8FmdM8KGYw4+ED/d2in9qWHlHJgBw3gX8z3hl/N+SNB8xIz A==; X-IronPort-AV: E=McAfee;i="6500,9779,10608"; a="355654310" X-IronPort-AV: E=Sophos;i="5.97,266,1669104000"; d="scan'208";a="355654310" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2023 17:08:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10608"; a="665087926" X-IronPort-AV: E=Sophos;i="5.97,266,1669104000"; d="scan'208";a="665087926" Received: from spandruv-desk.jf.intel.com ([10.54.75.8]) by orsmga002.jf.intel.com with ESMTP; 01 Feb 2023 17:08:15 -0800 From: Srinivas Pandruvada To: hdegoede@redhat.com, markgross@kernel.org Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Pandruvada , "David E . Box" Subject: [PATCH 3/7] platform/x86/intel/vsec: Support private data Date: Wed, 1 Feb 2023 17:07:34 -0800 Message-Id: <20230202010738.2186174-4-srinivas.pandruvada@linux.intel.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230202010738.2186174-1-srinivas.pandruvada@linux.intel.com> References: <20230202010738.2186174-1-srinivas.pandruvada@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756679612376593069?= X-GMAIL-MSGID: =?utf-8?q?1756679612376593069?= Add fields to struct intel_vsec_device, so that core module (which creates aux bus devices) can pass private data to the client drivers. For example there is one vsec device instance per CPU package. On a multi package system, this private data can be used to pass the package ID. This package id can be used by client drivers to change power settings for a specific CPU package by targeting MMIO space of the correct PCI device. Signed-off-by: Srinivas Pandruvada Acked-by: David E. Box --- drivers/platform/x86/intel/vsec.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/platform/x86/intel/vsec.h b/drivers/platform/x86/intel/vsec.h index d02c340fd458..ae8fe92c5595 100644 --- a/drivers/platform/x86/intel/vsec.h +++ b/drivers/platform/x86/intel/vsec.h @@ -38,6 +38,8 @@ struct intel_vsec_device { struct ida *ida; struct intel_vsec_platform_info *info; int num_resources; + void *priv_data; + size_t priv_data_size; }; int intel_vsec_add_aux(struct pci_dev *pdev, struct device *parent, From patchwork Thu Feb 2 01:07:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: srinivas pandruvada X-Patchwork-Id: 51623 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp607588wrn; Wed, 1 Feb 2023 17:12:49 -0800 (PST) X-Google-Smtp-Source: AK7set/QoWhbZVzhDE2s5j9/7LAWw7TRIdFiJ2ntTpbD5cc/L1pA/t/O7mdZqYNedgg/IrJyyenx X-Received: by 2002:a17:903:1c5:b0:197:90be:ac6e with SMTP id e5-20020a17090301c500b0019790beac6emr6777135plh.38.1675300369395; Wed, 01 Feb 2023 17:12:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675300369; cv=none; d=google.com; s=arc-20160816; b=tk/TAJ70QHKTwkGqIDaKPvFDrfu8p5w6UU28yE7twXOHFAuWLpOQv/b/cuVONYU63u gWqVen2NzFwv1FBE9a1Y3EjThyyoDuTSfooVgkpDBbiDwMamiabQjxkvZnKrV0reWNJG vZvtQSZGXt0TzLvijIl27rL1xpm+RtnxS2IDFtyO+d4ZRDkd/xI2UiyACHznYsSdkZjd 5JsEZrdJUQ3tX4zjsBTk6m+7TMyaFa2HYcwYI5l1CkT3WU5t/Fx5jkkHBQzZZsB+TOei auNfxOuOMQId6D/S2xJJQqokVbem2pnO5wODFJeudqNhMaFV09WbyBPFzzQ6dLUkLifr rAEw== 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:cc:to:from :dkim-signature; bh=XEsTmwbWGynnm5B8zBJsq5jZ77QI5KqbzDFA0bDNg24=; b=rG9VchlLgvZ9fOngupB+mNIneT0yXnfEQ++EfkVgBCEwl0ArdAOoRLboC5zHY/ejkv PGhxes3ho4lHb5ZfmQcVn3QJn187eX92DzoqUiYysnDC7R5RBcKtCHP1g6R8I3nHPfGc BpmSvol+36kH851R7xOYX1x1QM9hmR75BCGEyX6gAFzmo34mFWhws7sjNk0M55lRzyLk +c90PSo7YSz3bLOmgr5tuJ+tS91N0b4RUgjAGFXocjgrHfQT+YWp4iuzNkgh6y1CxRT5 rTstG5pOIeU2RZxtUeBSG0HWa2hLubWgDhtJMa//MZVoINrGShZMJGBDYjIgR4np45Mw Wq+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=IwlfkfPN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b10-20020a170902bd4a00b00196799d9504si11776595plx.161.2023.02.01.17.12.36; Wed, 01 Feb 2023 17:12:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=IwlfkfPN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230515AbjBBBJZ (ORCPT + 99 others); Wed, 1 Feb 2023 20:09:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230246AbjBBBJE (ORCPT ); Wed, 1 Feb 2023 20:09:04 -0500 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12439976B; Wed, 1 Feb 2023 17:09:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675300143; x=1706836143; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8OTCFgot6YtkvyOUn1WN3r4ERlKA92jPkF4SlfqW0C8=; b=IwlfkfPNOzvHaRuuKutxsyaK9oSWrGoYhrF05XDuMaCAZTYSoOgWVmk7 9NJNWviU/GbUV5oMuzb3jHhJL2lZ78HMyrNPDiY4h2Qo01e6lR4jrkOvK fs3FZlamb3WA/O7wNt3ppeHo2GXmfkAcrMecZsNINXcMOVr4mausV8H7H ak+JHoALSbxV2iTDN+YITtODvmosXEmoVRNzLE83OTllroIwojmH5i8Ue Kf1/YBOWx/HSMbavs+003EMpJqRdBkXCmRL12I4kKh2Sen9yJNn+zaTuM /lciBTNOUBnmg5p/iYHHve5/4aacPqP/rZLRoZUD5NJqIB+f9c0mG6Xo9 A==; X-IronPort-AV: E=McAfee;i="6500,9779,10608"; a="355654314" X-IronPort-AV: E=Sophos;i="5.97,266,1669104000"; d="scan'208";a="355654314" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2023 17:08:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10608"; a="665087930" X-IronPort-AV: E=Sophos;i="5.97,266,1669104000"; d="scan'208";a="665087930" Received: from spandruv-desk.jf.intel.com ([10.54.75.8]) by orsmga002.jf.intel.com with ESMTP; 01 Feb 2023 17:08:15 -0800 From: Srinivas Pandruvada To: hdegoede@redhat.com, markgross@kernel.org Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Pandruvada , Pierre-Louis Bossart , "Rafael J . Wysocki" Subject: [PATCH 4/7] platform/x86/intel: Intel TPMI enumeration driver Date: Wed, 1 Feb 2023 17:07:35 -0800 Message-Id: <20230202010738.2186174-5-srinivas.pandruvada@linux.intel.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230202010738.2186174-1-srinivas.pandruvada@linux.intel.com> References: <20230202010738.2186174-1-srinivas.pandruvada@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756679759707796490?= X-GMAIL-MSGID: =?utf-8?q?1756679759707796490?= The TPMI (Topology Aware Register and PM Capsule Interface) provides a flexible, extendable and PCIe enumerable MMIO interface for PM features. For example Intel RAPL (Running Average Power Limit) provides a MMIO interface using TPMI. This has advantage over traditional MSR (Model Specific Register) interface, where a thread needs to be scheduled on the target CPU to read or write. Also the RAPL features vary between CPU models, and hence lot of model specific code. Here TPMI provides an architectural interface by providing hierarchical tables and fields, which will not need any model specific implementation. The TPMI interface uses a PCI VSEC structure to expose the location of MMIO region. This VSEC structure is present in the PCI configuration space of the Intel Out-of-Band (OOB) device, which is handled by the Intel VSEC driver. The Intel VSEC driver parses VSEC structures present in the PCI configuration space of the given device and creates an auxiliary device object for each of them. In particular, it creates an auxiliary device object representing TPMI that can be bound by an auxiliary driver. Introduce a TPMI driver that will bind to the TPMI auxiliary device object created by the Intel VSEC driver. The TPMI specification defines a PFS (PM Feature Structure) table. This table is present in the TPMI MMIO region. The starting address of PFS is derived from the tBIR (Bar Indicator Register) and "Address" field from the VSEC header. Each TPMI PM feature has one entry in the PFS with a unique TPMI ID and its access details. The TPMI driver creates device nodes for the supported PM features. The names of the devices created by the TPMI driver start with the "intel_vsec.tpmi-" prefix which is followed by a specific name of the given PM feature (for example, "intel_vsec.tpmi-rapl.0"). The device nodes are create by using interface "intel_vsec_add_aux()" provided by the Intel VSEC driver. Signed-off-by: Srinivas Pandruvada Reviewed-by: Pierre-Louis Bossart Acked-by: Rafael J. Wysocki --- drivers/platform/x86/intel/Kconfig | 13 ++ drivers/platform/x86/intel/Makefile | 4 + drivers/platform/x86/intel/tpmi.c | 321 ++++++++++++++++++++++++++++ 3 files changed, 338 insertions(+) create mode 100644 drivers/platform/x86/intel/tpmi.c diff --git a/drivers/platform/x86/intel/Kconfig b/drivers/platform/x86/intel/Kconfig index d5a33473e838..bbbd9e54e9ee 100644 --- a/drivers/platform/x86/intel/Kconfig +++ b/drivers/platform/x86/intel/Kconfig @@ -182,6 +182,19 @@ config INTEL_SMARTCONNECT This driver checks to determine whether the device has Intel Smart Connect enabled, and if so disables it. +config INTEL_TPMI + tristate "Intel Topology Aware Register and PM Capsule Interface (TPMI)" + depends on INTEL_VSEC + depends on X86_64 + help + The Intel Topology Aware Register and PM Capsule Interface (TPMI), + provides enumerable MMIO interface for power management features. + This driver creates devices, so that other PM feature driver can + be loaded for PM specific feature operation. + + To compile this driver as a module, choose M here: the module will + be called intel_vsec_tpmi. + config INTEL_TURBO_MAX_3 bool "Intel Turbo Boost Max Technology 3.0 enumeration driver" depends on X86_64 && SCHED_MC_PRIO diff --git a/drivers/platform/x86/intel/Makefile b/drivers/platform/x86/intel/Makefile index 717933dd0cfd..411df4040427 100644 --- a/drivers/platform/x86/intel/Makefile +++ b/drivers/platform/x86/intel/Makefile @@ -47,6 +47,10 @@ obj-$(CONFIG_INTEL_MRFLD_PWRBTN) += intel_mrfld_pwrbtn.o intel_punit_ipc-y := punit_ipc.o obj-$(CONFIG_INTEL_PUNIT_IPC) += intel_punit_ipc.o +# TPMI drivers +intel_vsec_tpmi-y := tpmi.o +obj-$(CONFIG_INTEL_TPMI) += intel_vsec_tpmi.o + # Intel Uncore drivers intel-rst-y := rst.o obj-$(CONFIG_INTEL_RST) += intel-rst.o diff --git a/drivers/platform/x86/intel/tpmi.c b/drivers/platform/x86/intel/tpmi.c new file mode 100644 index 000000000000..1b87b46ba8a9 --- /dev/null +++ b/drivers/platform/x86/intel/tpmi.c @@ -0,0 +1,321 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * intel-tpmi : Driver to enumerate TPMI features and create devices + * + * Copyright (c) 2023, Intel Corporation. + * All Rights Reserved. + * + * The TPMI (Topology Aware Register and PM Capsule Interface) provides a + * flexible, extendable and PCIe enumerable MMIO interface for PM features. + * + * For example Intel RAPL (Running Average Power Limit) provides a MMIO + * interface using TPMI. This has advantage over traditional MSR + * (Model Specific Register) interface, where a thread needs to be scheduled + * on the target CPU to read or write. Also the RAPL features vary between + * CPU models, and hence lot of model specific code. Here TPMI provides an + * architectural interface by providing hierarchical tables and fields, + * which will not need any model specific implementation. + * + * The TPMI interface uses a PCI VSEC structure to expose the location of + * MMIO region. + * + * This VSEC structure is present in the PCI configuration space of the + * Intel Out-of-Band (OOB) device, which is handled by the Intel VSEC + * driver. The Intel VSEC driver parses VSEC structures present in the PCI + * configuration space of the given device and creates an auxiliary device + * object for each of them. In particular, it creates an auxiliary device + * object representing TPMI that can be bound by an auxiliary driver. + * + * This TPMI driver will bind to the TPMI auxiliary device object created + * by the Intel VSEC driver. + * + * The TPMI specification defines a PFS (PM Feature Structure) table. + * This table is present in the TPMI MMIO region. The starting address + * of PFS is derived from the tBIR (Bar Indicator Register) and "Address" + * field from the VSEC header. + * + * Each TPMI PM feature has one entry in the PFS with a unique TPMI + * ID and its access details. The TPMI driver creates device nodes + * for the supported PM features. + * + * The names of the devices created by the TPMI driver start with the + * "intel_vsec.tpmi-" prefix which is followed by a specific name of the + * given PM feature (for example, "intel_vsec.tpmi-rapl.0"). + * + * The device nodes are create by using interface "intel_vsec_add_aux()" + * provided by the Intel VSEC driver. + */ + +#include +#include +#include +#include + +#include "vsec.h" + +/** + * struct intel_tpmi_pfs_entry - TPMI PM Feature Structure (PFS) entry + * @tpmi_id: TPMI feature identifier (what the feature is and its data format). + * @num_entries: Number of feature interface instances present in the PFS. + * This represents the maximum number of Power domains in the SoC. + * @entry_size: Interface instance entry size in 32-bit words. + * @cap_offset: Offset from the PM_Features base address to the base of the PM VSEC + * register bank in KB. + * @attribute: Feature attribute: 0=BIOS. 1=OS. 2-3=Reserved. + * @reserved: Bits for use in the future. + * + * Represents one TPMI feature entry data in the PFS retrieved as is + * from the hardware. + */ +struct intel_tpmi_pfs_entry { + u64 tpmi_id:8; + u64 num_entries:8; + u64 entry_size:16; + u64 cap_offset:16; + u64 attribute:2; + u64 reserved:14; +} __packed; + +/** + * struct intel_tpmi_pm_feature - TPMI PM Feature information for a TPMI ID + * @pfs_header: PFS header retireved from the hardware. + * @vsec_offset: Starting MMIO address for this feature in bytes. Essentially + * this offset = "Address" from VSEC header + PFS Capability + * offset for this feature entry. + * + * Represents TPMI instance information for one TPMI ID. + */ +struct intel_tpmi_pm_feature { + struct intel_tpmi_pfs_entry pfs_header; + unsigned int vsec_offset; +}; + +/** + * struct intel_tpmi_info - TPMI information for all IDs in an instance + * @tpmi_features: Pointer to a list of TPMI feature instances + * @vsec_dev: Pointer to intel_vsec_device structure for this TPMI device + * @feature_count: Number of TPMI of TPMI instances pointed by tpmi_features + * @pfs_start: Start of PFS offset for the TPMI instances in this device + * + * Stores the information for all TPMI devices enumerated from a single PCI device. + */ +struct intel_tpmi_info { + struct intel_tpmi_pm_feature *tpmi_features; + struct intel_vsec_device *vsec_dev; + int feature_count; + u64 pfs_start; +}; + +/* + * List of supported TMPI IDs. + * Some TMPI IDs are not used by Linux, so the numbers are not consecutive. + */ +enum intel_tpmi_id { + TPMI_ID_RAPL = 0, /* Running Average Power Limit */ + TPMI_ID_PEM = 1, /* Power and Perf excursion Monitor */ + TPMI_ID_UNCORE = 2, /* Uncore Frequency Scaling */ + TPMI_ID_SST = 5, /* Speed Select Technology */ +}; + +/* Used during auxbus device creation */ +static DEFINE_IDA(intel_vsec_tpmi_ida); + +static const char *intel_tpmi_name(enum intel_tpmi_id id) +{ + switch (id) { + case TPMI_ID_RAPL: + return "rapl"; + case TPMI_ID_PEM: + return "pem"; + case TPMI_ID_UNCORE: + return "uncore"; + case TPMI_ID_SST: + return "sst"; + default: + return NULL; + } +} + +/* String Length for tpmi-"feature_name(upto 8 bytes)" */ +#define TPMI_FEATURE_NAME_LEN 14 + +static int tpmi_create_device(struct intel_tpmi_info *tpmi_info, + struct intel_tpmi_pm_feature *pfs, + u64 pfs_start) +{ + struct intel_vsec_device *vsec_dev = tpmi_info->vsec_dev; + char feature_id_name[TPMI_FEATURE_NAME_LEN]; + struct intel_vsec_device *feature_vsec_dev; + struct resource *res, *tmp; + const char *name; + int ret, i; + + name = intel_tpmi_name(pfs->pfs_header.tpmi_id); + if (!name) + return -EOPNOTSUPP; + + feature_vsec_dev = kzalloc(sizeof(*feature_vsec_dev), GFP_KERNEL); + if (!feature_vsec_dev) + return -ENOMEM; + + res = kcalloc(pfs->pfs_header.num_entries, sizeof(*res), GFP_KERNEL); + if (!res) { + ret = -ENOMEM; + goto free_vsec; + } + + snprintf(feature_id_name, sizeof(feature_id_name), "tpmi-%s", name); + + for (i = 0, tmp = res; i < pfs->pfs_header.num_entries; i++, tmp++) { + u64 entry_size_bytes = pfs->pfs_header.entry_size * 4; + + tmp->start = pfs->vsec_offset + entry_size_bytes * i; + tmp->end = tmp->start + entry_size_bytes - 1; + tmp->flags = IORESOURCE_MEM; + } + + feature_vsec_dev->pcidev = vsec_dev->pcidev; + feature_vsec_dev->resource = res; + feature_vsec_dev->num_resources = pfs->pfs_header.num_entries; + feature_vsec_dev->ida = &intel_vsec_tpmi_ida; + + /* + * intel_vsec_add_aux() is resource managed, no explicit + * delete is required on error or on module unload. + */ + ret = intel_vsec_add_aux(vsec_dev->pcidev, &vsec_dev->auxdev.dev, + feature_vsec_dev, feature_id_name); + if (ret) + goto free_res; + + return 0; + +free_res: + kfree(res); +free_vsec: + kfree(feature_vsec_dev); + + return ret; +} + +static int tpmi_create_devices(struct intel_tpmi_info *tpmi_info) +{ + struct intel_vsec_device *vsec_dev = tpmi_info->vsec_dev; + int ret, i; + + for (i = 0; i < vsec_dev->num_resources; i++) { + ret = tpmi_create_device(tpmi_info, &tpmi_info->tpmi_features[i], + tpmi_info->pfs_start); + /* + * Fail, if the supported features fails to create device, + * otherwise, continue. Even if one device failed to create, + * fail the loading of driver. Since intel_vsec_add_aux() + * is resource managed, no clean up is required for the + * successfully created devices. + */ + if (ret && ret != -EOPNOTSUPP) + return ret; + } + + return 0; +} + +static int tpmi_fetch_pfs_header(struct intel_tpmi_pm_feature *pfs, u64 start, int size) +{ + void __iomem *pfs_mem; + + pfs_mem = ioremap(start, size); + if (!pfs_mem) + return -ENOMEM; + + memcpy_fromio(&pfs->pfs_header, pfs_mem, sizeof(pfs->pfs_header)); + + iounmap(pfs_mem); + + return 0; +} + +static int intel_vsec_tpmi_init(struct auxiliary_device *auxdev) +{ + struct intel_vsec_device *vsec_dev = auxdev_to_ivdev(auxdev); + struct intel_tpmi_info *tpmi_info; + u64 pfs_start = 0; + int i; + + tpmi_info = devm_kzalloc(&auxdev->dev, sizeof(*tpmi_info), GFP_KERNEL); + if (!tpmi_info) + return -ENOMEM; + + tpmi_info->vsec_dev = vsec_dev; + tpmi_info->feature_count = vsec_dev->num_resources; + + tpmi_info->tpmi_features = devm_kcalloc(&auxdev->dev, vsec_dev->num_resources, + sizeof(*tpmi_info->tpmi_features), + GFP_KERNEL); + if (!tpmi_info->tpmi_features) + return -ENOMEM; + + for (i = 0; i < vsec_dev->num_resources; i++) { + struct intel_tpmi_pm_feature *pfs; + struct resource *res; + u64 res_start; + int size, ret; + + pfs = &tpmi_info->tpmi_features[i]; + + res = &vsec_dev->resource[i]; + if (!res) + continue; + + res_start = res->start; + size = resource_size(res); + if (size < 0) + continue; + + ret = tpmi_fetch_pfs_header(pfs, res_start, size); + if (ret) + continue; + + if (!pfs_start) + pfs_start = res_start; + + pfs->pfs_header.cap_offset *= 1024; + + pfs->vsec_offset = pfs_start + pfs->pfs_header.cap_offset; + } + + tpmi_info->pfs_start = pfs_start; + + auxiliary_set_drvdata(auxdev, tpmi_info); + + return tpmi_create_devices(tpmi_info); +} + +static int tpmi_probe(struct auxiliary_device *auxdev, + const struct auxiliary_device_id *id) +{ + return intel_vsec_tpmi_init(auxdev); +} + +/* + * Remove callback is not needed currently as there is no + * cleanup required. All memory allocs are device managed. All + * devices created by this modules are also device managed. + */ + +static const struct auxiliary_device_id tpmi_id_table[] = { + { .name = "intel_vsec.tpmi" }, + {} +}; +MODULE_DEVICE_TABLE(auxiliary, tpmi_id_table); + +static struct auxiliary_driver tpmi_aux_driver = { + .id_table = tpmi_id_table, + .probe = tpmi_probe, +}; + +module_auxiliary_driver(tpmi_aux_driver); + +MODULE_IMPORT_NS(INTEL_VSEC); +MODULE_DESCRIPTION("Intel TPMI enumeration module"); +MODULE_LICENSE("GPL"); From patchwork Thu Feb 2 01:07:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: srinivas pandruvada X-Patchwork-Id: 51621 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp606858wrn; Wed, 1 Feb 2023 17:11:02 -0800 (PST) X-Google-Smtp-Source: AK7set8IDXJS4ID7FMUNdKMM+yfQ9KiGLE39GUk0WtnrG0dgnirOcspdlTV1t7ZbUwTFL+Na7XV+ X-Received: by 2002:a05:6402:27d2:b0:4a0:8bcc:3cb6 with SMTP id c18-20020a05640227d200b004a08bcc3cb6mr5848656ede.17.1675300262789; Wed, 01 Feb 2023 17:11:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675300262; cv=none; d=google.com; s=arc-20160816; b=ACpzs3ecY38SKvJPDFGwwaaCDzfJZtXeaz474GL98cV4UL1adFXeCwty9y8RlHZdcs 4AG7QeGQ9s+7EbbbPoYL4xQRpG+G29uh9H5PNkbKcMnCuI2nS3z3UWnKvqctZ3YI3qA1 dtRiz5hnjaNICjP9y+BFqbb+unzZtmtZ92demu69q1Hx1a2KQF3dMWpK6SUlt57IQhfX LMtt6R1XgFUMm7Om89xiKHg2fNrSXD/SNE7oB1tw/PMAnXhy0KuH8UYt3NxgQOB/wS+m tyOuG5CyLXVVhhJ85lQFzqbOe7lMks4EiPnIXNYXFeoXKp4jMlBrMdf87dzX/PjgA/Bz mrOQ== 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:cc:to:from :dkim-signature; bh=XplptR4KRPYLmZcnEtZrnlQa/vWDEtr5QWrm7UERRWA=; b=OfEqFlfBpQ2eSPLQJs1tvF5ppSkwCvRlwKGgyDQmj87+K2Ul4eONQpyOW7dLSWEus8 fDeF26ts9WOHyPnEw3HNVnh3I+wmDBIYcsz6qlV/NaFFWwGFzE7EWFi19LAxv8HRd0MH v8cRAJk3JZGFCWFgP1EuBl8A4XO6J31Rwn3cmgAPAQH6TtHcSCAtKIzDuzC5E+laswE9 3SvZ2COzfGqBVfkJ6F4h9Lut0jtRpgx5HtUX+jKDKy507umHridolsBG7/pLdRGsylJ6 U3iq3RX9efb3cvxqwoMrv1LaKiZqzso/yosQ8zEpUuvLi6h+0lNKL+ZaMH5LdSuR0Jps qbxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=MbBslAig; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e12-20020a50a68c000000b0049ea121e9a9si24561205edc.551.2023.02.01.17.10.38; Wed, 01 Feb 2023 17:11:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=MbBslAig; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230255AbjBBBJT (ORCPT + 99 others); Wed, 1 Feb 2023 20:09:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229471AbjBBBJF (ORCPT ); Wed, 1 Feb 2023 20:09:05 -0500 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21B833F2A9; Wed, 1 Feb 2023 17:09:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675300144; x=1706836144; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=W9mXuUmIuslWBT27rQo8alF+yF0ZIU0Acn//rOj9SSc=; b=MbBslAigMaIQSHV3SsHLUVDQ0QEhHiNp/x9Hl08TmKlH2s7le61YW4ZQ JjS3ai1WWfErCYhqrVnW6NY5st8HwQ/VrWNkQuxlTV7V6zyWuGAhgAtKG MEBRgJng1KelTyz5qEynwNtVk5j8KsBEziZEjizEFw1bMdAuEX/CYSfJu RcGJdallCR+yhyY1GQYncHJeI5Zorm0IOVxLVfBD8S66GzRIzyRRdqoQf dEoUGh/kpRcXJMbL28nrZJKhwGiYQUy5P3pl3tWxHHDrIpTmehu9RktIg mwkQeKgc3a0pKSfGhQyw03lM7lHIsB5gUanSwj7iPqNYE+1U1Bt7tV7qg w==; X-IronPort-AV: E=McAfee;i="6500,9779,10608"; a="355654317" X-IronPort-AV: E=Sophos;i="5.97,266,1669104000"; d="scan'208";a="355654317" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2023 17:08:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10608"; a="665087933" X-IronPort-AV: E=Sophos;i="5.97,266,1669104000"; d="scan'208";a="665087933" Received: from spandruv-desk.jf.intel.com ([10.54.75.8]) by orsmga002.jf.intel.com with ESMTP; 01 Feb 2023 17:08:16 -0800 From: Srinivas Pandruvada To: hdegoede@redhat.com, markgross@kernel.org Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Pandruvada , Pierre-Louis Bossart , "Rafael J . Wysocki" Subject: [PATCH 5/7] platform/x86/intel/tpmi: Process CPU package mapping Date: Wed, 1 Feb 2023 17:07:36 -0800 Message-Id: <20230202010738.2186174-6-srinivas.pandruvada@linux.intel.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230202010738.2186174-1-srinivas.pandruvada@linux.intel.com> References: <20230202010738.2186174-1-srinivas.pandruvada@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756679648268897793?= X-GMAIL-MSGID: =?utf-8?q?1756679648268897793?= There is one Intel Out-of-Band (OOB) PCI device per CPU package. Since TPMI feature is exposed via OOB PCI device, there will be multiple TPMI device instances on a multi CPU package system. There are several PM features, which needs to associate APIC based CPU package ID information to a TPMI instance. For example if Intel Speed Select feature requires control of a CPU package, it needs to identify right TPMI device instance. There is one special TPMI ID (ID = 0x81) in the PFS. The MMIO region of this TPMI ID points to a mapping table: - PCI Bus ID - PCI Device ID - APIC based Package ID This mapping information can be used by any PM feature driver which requires mapping from a CPU package to a TPMI device instance. Unlike other TPMI features, device node is not created for this feature ID (0x81). Instead store the mapping information as platform data, which is part of the per PCI device TPMI instance (struct intel_tpmi_info). Later the TPMI feature drivers can get the mapping information using an interface "tpmi_get_platform_data()" Signed-off-by: Srinivas Pandruvada Reviewed-by: Pierre-Louis Bossart Acked-by: Rafael J. Wysocki --- drivers/platform/x86/intel/tpmi.c | 72 +++++++++++++++++++++++++++++++ include/linux/intel_tpmi.h | 28 ++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 include/linux/intel_tpmi.h diff --git a/drivers/platform/x86/intel/tpmi.c b/drivers/platform/x86/intel/tpmi.c index 1b87b46ba8a9..e612da579b29 100644 --- a/drivers/platform/x86/intel/tpmi.c +++ b/drivers/platform/x86/intel/tpmi.c @@ -47,6 +47,7 @@ */ #include +#include #include #include #include @@ -96,6 +97,7 @@ struct intel_tpmi_pm_feature { * @vsec_dev: Pointer to intel_vsec_device structure for this TPMI device * @feature_count: Number of TPMI of TPMI instances pointed by tpmi_features * @pfs_start: Start of PFS offset for the TPMI instances in this device + * @plat_info: Stores platform info which can be used by the client drivers * * Stores the information for all TPMI devices enumerated from a single PCI device. */ @@ -104,8 +106,30 @@ struct intel_tpmi_info { struct intel_vsec_device *vsec_dev; int feature_count; u64 pfs_start; + struct intel_tpmi_plat_info plat_info; }; +/** + * struct tpmi_info_header - CPU package ID to PCI device mapping information + * @fn: PCI function number + * @dev: PCI device number + * @bus: PCI bus number + * @pkg: CPU Package id + * @reserved: Reserved for future use + * @lock: When set to 1 the register is locked and becomes read-only + * until next reset. Not for use by the OS driver. + * + * The structure to read hardware provided mapping information. + */ +struct tpmi_info_header { + u64 fn:3; + u64 dev:5; + u64 bus:8; + u64 pkg:8; + u64 reserved:39; + u64 lock:1; +} __packed; + /* * List of supported TMPI IDs. * Some TMPI IDs are not used by Linux, so the numbers are not consecutive. @@ -115,11 +139,20 @@ enum intel_tpmi_id { TPMI_ID_PEM = 1, /* Power and Perf excursion Monitor */ TPMI_ID_UNCORE = 2, /* Uncore Frequency Scaling */ TPMI_ID_SST = 5, /* Speed Select Technology */ + TPMI_INFO_ID = 0x81, /* Special ID for PCI BDF and Package ID information */ }; /* Used during auxbus device creation */ static DEFINE_IDA(intel_vsec_tpmi_ida); +struct intel_tpmi_plat_info *tpmi_get_platform_data(struct auxiliary_device *auxdev) +{ + struct intel_vsec_device *vsec_dev = auxdev_to_ivdev(auxdev); + + return vsec_dev->priv_data; +} +EXPORT_SYMBOL_NS_GPL(tpmi_get_platform_data, INTEL_TPMI); + static const char *intel_tpmi_name(enum intel_tpmi_id id) { switch (id) { @@ -177,6 +210,8 @@ static int tpmi_create_device(struct intel_tpmi_info *tpmi_info, feature_vsec_dev->pcidev = vsec_dev->pcidev; feature_vsec_dev->resource = res; feature_vsec_dev->num_resources = pfs->pfs_header.num_entries; + feature_vsec_dev->priv_data = &tpmi_info->plat_info; + feature_vsec_dev->priv_data_size = sizeof(tpmi_info->plat_info); feature_vsec_dev->ida = &intel_vsec_tpmi_ida; /* @@ -220,6 +255,31 @@ static int tpmi_create_devices(struct intel_tpmi_info *tpmi_info) return 0; } +#define TPMI_INFO_BUS_INFO_OFFSET 0x08 + +static int tpmi_process_info(struct intel_tpmi_info *tpmi_info, + struct intel_tpmi_pm_feature *pfs) +{ + struct tpmi_info_header header; + void __iomem *info_mem; + + info_mem = ioremap(pfs->vsec_offset + TPMI_INFO_BUS_INFO_OFFSET, + pfs->pfs_header.entry_size * 4 - TPMI_INFO_BUS_INFO_OFFSET); + if (!info_mem) + return -ENOMEM; + + memcpy_fromio(&header, info_mem, sizeof(header)); + + tpmi_info->plat_info.package_id = header.pkg; + tpmi_info->plat_info.bus_number = header.bus; + tpmi_info->plat_info.device_number = header.dev; + tpmi_info->plat_info.function_number = header.fn; + + iounmap(info_mem); + + return 0; +} + static int tpmi_fetch_pfs_header(struct intel_tpmi_pm_feature *pfs, u64 start, int size) { void __iomem *pfs_mem; @@ -238,6 +298,7 @@ static int tpmi_fetch_pfs_header(struct intel_tpmi_pm_feature *pfs, u64 start, i static int intel_vsec_tpmi_init(struct auxiliary_device *auxdev) { struct intel_vsec_device *vsec_dev = auxdev_to_ivdev(auxdev); + struct pci_dev *pci_dev = vsec_dev->pcidev; struct intel_tpmi_info *tpmi_info; u64 pfs_start = 0; int i; @@ -248,6 +309,7 @@ static int intel_vsec_tpmi_init(struct auxiliary_device *auxdev) tpmi_info->vsec_dev = vsec_dev; tpmi_info->feature_count = vsec_dev->num_resources; + tpmi_info->plat_info.bus_number = pci_dev->bus->number; tpmi_info->tpmi_features = devm_kcalloc(&auxdev->dev, vsec_dev->num_resources, sizeof(*tpmi_info->tpmi_features), @@ -282,6 +344,16 @@ static int intel_vsec_tpmi_init(struct auxiliary_device *auxdev) pfs->pfs_header.cap_offset *= 1024; pfs->vsec_offset = pfs_start + pfs->pfs_header.cap_offset; + + /* + * Process TPMI_INFO to get PCI device to CPU package ID. + * Device nodes for TPMI features are not created in this + * for loop. So, the mapping information will be available + * when actual device nodes created outside this + * loop via tpmi_create_devices(). + */ + if (pfs->pfs_header.tpmi_id == TPMI_INFO_ID) + tpmi_process_info(tpmi_info, pfs); } tpmi_info->pfs_start = pfs_start; diff --git a/include/linux/intel_tpmi.h b/include/linux/intel_tpmi.h new file mode 100644 index 000000000000..5b665320ecb4 --- /dev/null +++ b/include/linux/intel_tpmi.h @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * intel_tpmi.h: Intel TPMI core external interface + */ + +#ifndef _INTEL_TPMI_H_ +#define _INTEL_TPMI_H_ + +/** + * struct intel_tpmi_plat_info - Platform information for a TPMI device instance + * @package_id: CPU Package id + * @bus_number: PCI bus number + * @device_number: PCI device number + * @function_number: PCI function number + * + * Structure to store platform data for a TPMI device instance. This + * struct is used to return data via tpmi_get_platform_data(). + */ +struct intel_tpmi_plat_info { + u8 package_id; + u8 bus_number; + u8 device_number; + u8 function_number; +}; + +struct intel_tpmi_plat_info *tpmi_get_platform_data(struct auxiliary_device *auxdev); + +#endif From patchwork Thu Feb 2 01:07:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: srinivas pandruvada X-Patchwork-Id: 51622 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp607159wrn; Wed, 1 Feb 2023 17:11:50 -0800 (PST) X-Google-Smtp-Source: AK7set/PvuGi5WVDdU/p1fw0EuT3NgK8s6SRc9yqm3gOMS2m4X5eKMnUfyjPXNiuKh64NrIZWCCi X-Received: by 2002:a17:907:a706:b0:88c:a14a:d039 with SMTP id vw6-20020a170907a70600b0088ca14ad039mr5779235ejc.69.1675300310380; Wed, 01 Feb 2023 17:11:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675300310; cv=none; d=google.com; s=arc-20160816; b=bPffqRrGaIvu6pz/h3Y2O7Cw5r58WqE32B7TvLJei8Ik5/xnpPvx3UFpu068CCzCZU mT2mIcriOYtxdsMi91wYoYbGXaM7r4w6+K8T6LzTkTHh8c/Ogkb8/Gv09LzpPa6AhZ4G x9VbZQIn0CsPBrYTlVjiI5R4SEp7D/kMSyCleT8hR39QsHCBqDR434K025c+r8yIypE+ XV5Vye2b6CEp8fI6XF6jqjk/yFgBXtD0RrD1ph2OHlM5QmPF3MnblXj2irvKhORRYsUX 9VZBjy3QGXgEVpyPrvzMFb2rSEfrFu5ppNbn/V3E90P1x2prCIjBnrBErIckin0BHoGn 57nQ== 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:cc:to:from :dkim-signature; bh=Se45wc6HCUYwZrGQQW5OoQ3Wt9jspM61sXZj9uPCUuc=; b=kc60kM96NY6w+pFoMIN2gzOVVj1T6d+h8okHbBluIrKHehY5zFIadf19zZI3Nt4nVc KqNms2OZs6cvXsznNom2hsKfnBv3YAN4VIWvq0SZQ7MEk1E1jQBJvJam0XyGaEblTxiP 5nrL6sSL/Lcm6d3WBnn9M0wa3+xkYg5sOcDzQy+1QyrArOGFz0fyasIR7vo3DD5G0CoX q4Ms4iHpd+tQiqXTbadAwaZ+mctTMozAeGD8+mjNALYTJPmKaVqnkgp/vCs9lDmEDKUz /40MaxCS6E7l5tE1iFkcTMRtJNu7uYNBzZ7Ap7s//ZgTpsWpfJ/jx3gud6ikOvsw4oix ueFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Q7LpxGFM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ss2-20020a170907c00200b007a1d4f0e7fcsi26329918ejc.655.2023.02.01.17.11.26; Wed, 01 Feb 2023 17:11:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Q7LpxGFM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230494AbjBBBJW (ORCPT + 99 others); Wed, 1 Feb 2023 20:09:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230225AbjBBBJE (ORCPT ); Wed, 1 Feb 2023 20:09:04 -0500 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25B663FF15; Wed, 1 Feb 2023 17:09:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675300144; x=1706836144; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FYv6jDBrHFQqFs42e2Uh3HApFnR2DRe1FCshvQDOYek=; b=Q7LpxGFMbxmJ/zMy0X0JoucUlbtduOrZ3BCS8FW9Ko+AYyhPgGufReFG rzW1hHxfOro9Xqi5SZOcmVxyygneg2V1VYeCS+jVYCw+nv7TK6RbaGSuO bdmRutUGCuO5NYHrkrsa2w/tI1eURGXgAQCOiUObjNpLQu7x6OZ/kaJZq Fa35rbnPhKC5T6CJ1EVIjS9fqrNDHUnrR1hXSAfVJtc984Lhjp7iosdZc SNGp/0qGQTwP1uM2aI3RNTkLMwWwWFXPMN4t03iowGiPyG9c2mmRYkUnu 1LVcDAAcO//k+wrnQfgiE0ItvA8/L7qtOmAYAxF/j6Ibk8OW+/wHXjlep g==; X-IronPort-AV: E=McAfee;i="6500,9779,10608"; a="355654320" X-IronPort-AV: E=Sophos;i="5.97,266,1669104000"; d="scan'208";a="355654320" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2023 17:08:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10608"; a="665087936" X-IronPort-AV: E=Sophos;i="5.97,266,1669104000"; d="scan'208";a="665087936" Received: from spandruv-desk.jf.intel.com ([10.54.75.8]) by orsmga002.jf.intel.com with ESMTP; 01 Feb 2023 17:08:16 -0800 From: Srinivas Pandruvada To: hdegoede@redhat.com, markgross@kernel.org Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Pandruvada , Pierre-Louis Bossart , "Rafael J . Wysocki" Subject: [PATCH 6/7] platform/x86/intel/tpmi: ADD tpmi external interface for tpmi feature drivers Date: Wed, 1 Feb 2023 17:07:37 -0800 Message-Id: <20230202010738.2186174-7-srinivas.pandruvada@linux.intel.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230202010738.2186174-1-srinivas.pandruvada@linux.intel.com> References: <20230202010738.2186174-1-srinivas.pandruvada@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756679697886263960?= X-GMAIL-MSGID: =?utf-8?q?1756679697886263960?= Add interface to get resources and platform data. This will avoid code duplication. These interfaces includes: - Get resource count - Get resource at an index Signed-off-by: Srinivas Pandruvada Reviewed-by: Pierre-Louis Bossart Acked-by: Rafael J. Wysocki --- drivers/platform/x86/intel/tpmi.c | 22 ++++++++++++++++++++++ include/linux/intel_tpmi.h | 2 ++ 2 files changed, 24 insertions(+) diff --git a/drivers/platform/x86/intel/tpmi.c b/drivers/platform/x86/intel/tpmi.c index e612da579b29..c60733261c89 100644 --- a/drivers/platform/x86/intel/tpmi.c +++ b/drivers/platform/x86/intel/tpmi.c @@ -153,6 +153,28 @@ struct intel_tpmi_plat_info *tpmi_get_platform_data(struct auxiliary_device *aux } EXPORT_SYMBOL_NS_GPL(tpmi_get_platform_data, INTEL_TPMI); +int tpmi_get_resource_count(struct auxiliary_device *auxdev) +{ + struct intel_vsec_device *vsec_dev = auxdev_to_ivdev(auxdev); + + if (vsec_dev) + return vsec_dev->num_resources; + + return 0; +} +EXPORT_SYMBOL_NS_GPL(tpmi_get_resource_count, INTEL_TPMI); + +struct resource *tpmi_get_resource_at_index(struct auxiliary_device *auxdev, int index) +{ + struct intel_vsec_device *vsec_dev = auxdev_to_ivdev(auxdev); + + if (vsec_dev && index < vsec_dev->num_resources) + return &vsec_dev->resource[index]; + + return NULL; +} +EXPORT_SYMBOL_NS_GPL(tpmi_get_resource_at_index, INTEL_TPMI); + static const char *intel_tpmi_name(enum intel_tpmi_id id) { switch (id) { diff --git a/include/linux/intel_tpmi.h b/include/linux/intel_tpmi.h index 5b665320ecb4..f505788c05da 100644 --- a/include/linux/intel_tpmi.h +++ b/include/linux/intel_tpmi.h @@ -24,5 +24,7 @@ struct intel_tpmi_plat_info { }; struct intel_tpmi_plat_info *tpmi_get_platform_data(struct auxiliary_device *auxdev); +struct resource *tpmi_get_resource_at_index(struct auxiliary_device *auxdev, int index); +int tpmi_get_resource_count(struct auxiliary_device *auxdev); #endif From patchwork Thu Feb 2 01:07:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: srinivas pandruvada X-Patchwork-Id: 51624 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp607680wrn; Wed, 1 Feb 2023 17:13:01 -0800 (PST) X-Google-Smtp-Source: AK7set8QQN0Vt2OR9iUEmbQKGxyWI2Jna5dRkBjk5xlPlnLjbK7pQsASs11MQjzQDNUWTkN91GD4 X-Received: by 2002:a50:9989:0:b0:4a2:2f63:9d29 with SMTP id m9-20020a509989000000b004a22f639d29mr85766edb.7.1675300380918; Wed, 01 Feb 2023 17:13:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675300380; cv=none; d=google.com; s=arc-20160816; b=PXZj5MfBXhwnkTKj+bdA4QeF0F2hhSgmPSkm0eLWugQxatt+nn3SAS/yoRKsw8BtZ5 MsAJMyKp59mjiXBAu3gwHMO+la60jLSNYsqS36QGkFzD/OVqiyWcwtDamXD4Q86M+LTS stiMdWjG8NhfT9w1aURV2v4/nNkG2tP6ruYP+dkU5EH3isg3lkQjrtXFOc+vi2VgEM4x ZjI+2VJ4sgWqAKvFM/miJRrZbOEx2/iRJr9qzZYmXq+RiY3B7GcQLBA1Q7vblDNczTEX f0T0riuXPxwA2/Hw4evgkRLpYQBsqXxwUGWsTvTO7iB9zoV4fwtFf7q5P5GcbehnoFag 6g3g== 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:cc:to:from :dkim-signature; bh=io/QYi+nGSIfJBqHMTdLUrzrUgBlbAYbpXI4+cnZnKU=; b=XacbBVg4OKhT/i2/ouJ2vGtTtWcsRnsVymH1FslHdlXZOYgnMXQ/XtCKze2Luyv9jQ cTZuZxuecqswdpHmtsP4W7SK5Mres9mhzuOxerx9/k4Dk+YQMV6W8APcj7DpIgk5T4ev 4nintmq94+5V5cGbEXI4riycRT84hpKidAQbWeveOrQT2TaJSsgv6P047oqo1pTgmrPt tZsOs/7HJZvbup0e+C50UVpVRGwULOlKQVjFphc/57YF4G/ql1e+7tJBIR8Yn2w2SyXK L+R/EKorIpqJ++rbWHzYbT2K65XUI4pF/f9z0vwN/nogCnhmpQcI5FmHDimfdpoF5Vc+ KyJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=iToKyzw6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b8-20020a509f08000000b004a213b19ba2si19973259edf.1.2023.02.01.17.12.36; Wed, 01 Feb 2023 17:13:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=iToKyzw6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231129AbjBBBJ2 (ORCPT + 99 others); Wed, 1 Feb 2023 20:09:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230286AbjBBBJF (ORCPT ); Wed, 1 Feb 2023 20:09:05 -0500 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA331474C5; Wed, 1 Feb 2023 17:09:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675300144; x=1706836144; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=r3hG+Ca6d73zopTx9WXAswSjukXC6pV6ULXWYPlyX0Y=; b=iToKyzw60lBn0HRnLGALEPoDOAlAU0T41AuBLCmDcwOJmKZmjoGJe2Ku QZf5jDUJxPXNpyDIwI9nrhqzBkTnQAeshT1Ch0x1T35FWAjzHGlnU5i6N eGZKhExXr/wp39vJkDgunKCO+QYJYz5j+TnXOJaXZcRNUdWN4vBulrrP9 sm1rNgCOKW3GYr0kmON+WIIChoyd9jKKJ5eLmuE3Vk9tF2IKzCF841XVj FAPvxe9e4teLvh0pkZpmigPWsdlh7a1VudYCqawgKNThAgXekdoiiGftc cC0ZeFNodD1YCO5AVCVAQaphoqrigPdU/dSmWBLgVQ1ZerCnRKxibyKpQ Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10608"; a="355654322" X-IronPort-AV: E=Sophos;i="5.97,266,1669104000"; d="scan'208";a="355654322" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2023 17:08:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10608"; a="665087937" X-IronPort-AV: E=Sophos;i="5.97,266,1669104000"; d="scan'208";a="665087937" Received: from spandruv-desk.jf.intel.com ([10.54.75.8]) by orsmga002.jf.intel.com with ESMTP; 01 Feb 2023 17:08:16 -0800 From: Srinivas Pandruvada To: hdegoede@redhat.com, markgross@kernel.org Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Pandruvada Subject: [PATCH 7/7] MAINTAINERS: Add entry for TPMI driver Date: Wed, 1 Feb 2023 17:07:38 -0800 Message-Id: <20230202010738.2186174-8-srinivas.pandruvada@linux.intel.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230202010738.2186174-1-srinivas.pandruvada@linux.intel.com> References: <20230202010738.2186174-1-srinivas.pandruvada@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756679772376164514?= X-GMAIL-MSGID: =?utf-8?q?1756679772376164514?= Add entry for TPMI (Topology Aware Register and PM Capsule Interface) driver. Signed-off-by: Srinivas Pandruvada --- MAINTAINERS | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index f61eb221415b..6f3aaa7161d6 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -10683,6 +10683,12 @@ S: Maintained F: arch/x86/include/asm/intel_telemetry.h F: drivers/platform/x86/intel/telemetry/ +INTEL TPMI DRIVER +M: Srinivas Pandruvada +L: platform-driver-x86@vger.kernel.org +S: Maintained +F: drivers/platform/x86/intel/tpmi.c + INTEL UNCORE FREQUENCY CONTROL M: Srinivas Pandruvada L: platform-driver-x86@vger.kernel.org