Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp94134rdh; Wed, 22 Nov 2023 20:06:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IG11eW/8beNPRGzvHXi69QsNLVVkXneEW7M0RrAHhmuo8A8BV57T3q7fCtFE/AGqlsYzvya X-Received: by 2002:a05:6a20:3d1e:b0:18a:e86f:f246 with SMTP id y30-20020a056a203d1e00b0018ae86ff246mr5423245pzi.10.1700712366269; Wed, 22 Nov 2023 20:06:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700712366; cv=none; d=google.com; s=arc-20160816; b=vk7SCWAFn5aTg2PAOhxrMkrgo/DCGOusNLKexFGroNnUg97VKeyvxxj5h8PXmqJUXC Mzy3VQxF1C8N53wIDgCvEtG3Dm5N1xFUXFkHToyM+Qk87HLgeCyhwtGVOQsuDDi78TTh i1Md0GlUdn6Hfct4hc0Mgum9FuiBOw3NmGukQheaI03BFe9ITZ0Nv0P+AD+ovzUuR+H6 Ijzjbb8xOXW4RZPtRXAvFWkNPh6reAgKnUoAWJSMyVfkwoxdH+XGyTqV97EAYkGbtU+z vmJ/XnRKHQfdLrA/WUyGYQJOgaUHV4WTUOeFjl7jlLh5MzzXfgQ6jE9JteygGQ+kJxbr U0Ow== 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=lxBpE44e3S0YJHxtJh1VPUxolgU8Z90GlPLOtqq2+D8=; fh=d9G4dsZtlI8UONIvGKwhW94hCYEPGxy6CqYeKEG646A=; b=Jn4i4ci7/B9+dtbSlNSMFDkie5789lRQNftIbVBiTXN0NEAi1TkBnNrPJ720eQk/2d eUfGab6adBYQRzOhe/MnckMikKLSg+iQxdz1fV2d5TSjCb1S/QhAx/kIk72NV86plfhz a2iL3rsSc51G/NP8XtLsijLGzFB6TOAKfDIfkE9hE7RkbuMyqnBbsbIhAMHLfeRz3itu LaRHT4FFeBrEWP3O5cwGtDUXeBHBqgtFVWx9rWYSppOIJBJG2yVAqnBoHReTUxQLsw4G PBJmqyHWoSCOcuv2Zl3PGDcr8czg7SyUOSuhcdCYW0s+PPuUZicOcDjKMn7S9ntrCenh f2yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fLZjiN3v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id b129-20020a636787000000b005be1ee5bea2si494537pgc.374.2023.11.22.20.06.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 20:06:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fLZjiN3v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 08039807AFDC; Wed, 22 Nov 2023 20:05:59 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344575AbjKWEFE (ORCPT + 99 others); Wed, 22 Nov 2023 23:05:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233940AbjKWEDy (ORCPT ); Wed, 22 Nov 2023 23:03:54 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7094AD4A; Wed, 22 Nov 2023 20:04:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700712240; x=1732248240; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=BtwJjW1Os9r1Wzy3UXn5z9j7KPpzsXo9S152/9CIcXw=; b=fLZjiN3vhluZxE6/2SwwypBjFaOkhyMfXvJ23+t6rdqFz9cH2/mvZEui RtKnPSzuht//rRWRu3wd6AwiZXVtG6olBbewC3P9nTGeUnD9WLSSV9MsK PCOk6DhUT3sSy63tFKpWitffcuKCZUtlbOJixenYNcfOFRP/lT6sij6wu w22HD0ooY98SF4IFqwvp6UhosvCB4ZHiXjnj+LaS6wohDRzsxPL41q9ks YkhiToKM9VdpV+9JOGATXznfkagwVxhKT4H8oBxCHd9mpNstd43BdM1qf msy9zgOBNVMu/pTY4WbBVzKL+iYtBHPq2B8NMxzNnMMvTua8vdZ96DNqv A==; X-IronPort-AV: E=McAfee;i="6600,9927,10902"; a="389347951" X-IronPort-AV: E=Sophos;i="6.04,220,1695711600"; d="scan'208";a="389347951" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Nov 2023 20:03:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10902"; a="801925659" X-IronPort-AV: E=Sophos;i="6.04,220,1695711600"; d="scan'208";a="801925659" Received: from linux.intel.com ([10.54.29.200]) by orsmga001.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Nov 2023 20:03:57 -0800 Received: from debox1-desk4.lan (snpatel1-mobl.amr.corp.intel.com [10.209.89.91]) by linux.intel.com (Postfix) with ESMTP id 50714580D81; Wed, 22 Nov 2023 20:03:57 -0800 (PST) From: "David E. Box" To: linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, ilpo.jarvinen@linux.intel.com, rajvi.jingar@linux.intel.com Subject: [PATCH V5 16/20] platform/x86/intel/pmc: Display LPM requirements for multiple PMCs Date: Wed, 22 Nov 2023 20:03:51 -0800 Message-Id: <20231123040355.82139-17-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231123040355.82139-1-david.e.box@linux.intel.com> References: <20231123040355.82139-1-david.e.box@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on 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, 22 Nov 2023 20:05:59 -0800 (PST) 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 --- V5 - Use conditional instead of if/else to do seq_printf() V4 - No change V3 - Add missing submitter signoff V2 - no change drivers/platform/x86/intel/pmc/core.c | 128 ++++++++++++++------------ 1 file changed, 68 insertions(+), 60 deletions(-) diff --git a/drivers/platform/x86/intel/pmc/core.c b/drivers/platform/x86/intel/pmc/core.c index 3894119d61b0..4a38d52558fd 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,76 @@ 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"); - else - seq_printf(s, " %9s |", " "); + 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) { + bool required = lpm_req_regs[mp + (mode * num_maps)] & + bit_mask; + seq_printf(s, " %9s |", required ? "Required" : " "); + } + + /* In Status column, show the last captured state of this agent */ + seq_printf(s, " %9s |", lpm_status & bit_mask ? "Yes" : " "); + + 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); -- 2.34.1