From patchwork Fri Feb 9 08:39:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shravan Kumar Ramani X-Patchwork-Id: 198782 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp710855dyd; Fri, 9 Feb 2024 00:41:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IGNMV57VFIQ9rlPQDBal/qYfEOa6IaiO6eO2j7XcHOCUXHEyS8u4Iu9BJi8zIDLvfkD7UKn X-Received: by 2002:a05:620a:199a:b0:785:936b:503c with SMTP id bm26-20020a05620a199a00b00785936b503cmr1288682qkb.0.1707468093046; Fri, 09 Feb 2024 00:41:33 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVxWBHOfzxG9cIwEGjl7ZPMf5Hu2icVOHyjWkhOJj4KPMbtlQ+qNXqXGuAAXmhldYcesyNSM30spJjvPckSo6fl94DcCA== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id b14-20020a05620a0cce00b007857ad9bd10si1467095qkj.315.2024.02.09.00.41.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 00:41:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59118-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=OOXDHFVf; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-59118-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59118-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id BF93C1C218C5 for ; Fri, 9 Feb 2024 08:41:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C45D36774E; Fri, 9 Feb 2024 08:40:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="OOXDHFVf" Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A4B95664A3; Fri, 9 Feb 2024 08:40:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.40 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707468038; cv=fail; b=YRGaHPBUOwQnDEaeg64nhhBhDfyzvlOjXrbQylzSIf1UqY7oBgF8HoUJtP5jHsmqA9qu6XU9xoe6ixcBAKgNsHC4BVMbiS6ZrOew5hzTz3BGs86W5IkgYXjlcAQE+sqse4gEdZKozbZI8AJVwpUYlKxKPyNtV4Jej7FPZVPBSNY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707468038; c=relaxed/simple; bh=iwxIfL3BRl2s/RdxnJ/l/m0BxRF2hXa5DFn8OSL4O0U=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JtDZeZqiXuti/N7HHRzs67ypE1qeM08k6dZCH0swXcBX5uaifswhwCanzwJL0YHmqajgHqs7fD2MAE5Jab0z28/7lNTwbEGw9kI5o07/6GQrMAWhR/hHGEOnG/sOgnoyNkreoedVcQMM6hLbgPEOfqeEWanIGtk3Y2jp4096u4U= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=OOXDHFVf; arc=fail smtp.client-ip=40.107.236.40 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W+9t9cs+Th2aFkQOxXQc1MHO1cRd0GLYGsNmZrPn9nbuaM8z107XWW9Tb4ixZg0Pu3Dlyo/x2y7aU1SdnN3/4AU7ZG6VIkUOvg10LmC9P1QVDXboCGrPC6m7u6mmdQdEeIeCRRl+pxMjGmb18NNO9AXVy3YbBqSxeXKzfLD1BjqRPsUBAzB+V/8Dbs0wt4mcZZkRNmla6jfBJRjprW5OlFmwrfHL4EuXS97corr+57dHdRSujCb8F85yPvtQfmzomSsE1BJKwDg0VjHQ6nwWRHf+hm74C69QZqO/1NB0qEzkaz/1X0qhVeO3ly76No98RYhCH8Ypp1rJaNEGE2BPVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=vedIqzSP9LYhLSc7fEzE8oeyW7b9RTVcMS1qheeKS0w=; b=TPKzBMK+xSQIGXb2y31lwXvB0fKass1n6ADSAGFLDQ5V0kNQVTjnSEBL5xVFD/OcT8IhpuLeWoEVsB73MnhkKzOPrjPdcZww2Kkxdky5NPLisOPFVp4h89MGIlfABMeVH8pmOXCXMw0Q7S0L8FMGdU8S1z2HM60nFUMP3a8kOnHKh2WHENvw5S2f8mystCtPgF3djdllIGtRDGpddCMIexnlS4MCtJkFwlClAIddzHVP6gRBRyiAk/guLaFnO5CztfA5Qafck1Tdba97ksdf/3noKjdwscshxGfaOM7KzgDFZFRO9nG5/xAFs27ZnlHlrRkC9EYvRzjQXTfUOq4iUA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=redhat.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vedIqzSP9LYhLSc7fEzE8oeyW7b9RTVcMS1qheeKS0w=; b=OOXDHFVfxRwVevCVPcVCEyZcoemLfleoYcm+UovPVe5agN2kfhc92goJJRKPHp4y1MivgpkUxzOgnpXwTskj61CSwt6JOXIAAAkukPw0CdvoRKcUDBfQ5wA9U6i6ipfrFhsMs4bPYKNPeXkmW6XHGyFFkeU9KdtoCO4pPcT+ZzD0D1W1kUbuH7rYO0VPxrJNuSKWh9rjEQL+7cmTHdVrkC/Z+dp+5L1nUJUUE/W0tQc5CeZq0WJ60fmp/pVm/eD9U4vy4ZYdWkfrdmxdQAWZRs+bszJn7SgD271sJIkQ7PZ8VC0lAi4geJ+VQ3zPHXJPU7jSNX5o+KP6ve7cZYYkaA== Received: from DM6PR03CA0102.namprd03.prod.outlook.com (2603:10b6:5:333::35) by DM6PR12MB4878.namprd12.prod.outlook.com (2603:10b6:5:1b8::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.17; Fri, 9 Feb 2024 08:40:33 +0000 Received: from SN1PEPF0002BA4B.namprd03.prod.outlook.com (2603:10b6:5:333:cafe::50) by DM6PR03CA0102.outlook.office365.com (2603:10b6:5:333::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.38 via Frontend Transport; Fri, 9 Feb 2024 08:40:33 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by SN1PEPF0002BA4B.mail.protection.outlook.com (10.167.242.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.19 via Frontend Transport; Fri, 9 Feb 2024 08:40:33 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Fri, 9 Feb 2024 00:40:11 -0800 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail202.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Fri, 9 Feb 2024 00:40:11 -0800 Received: from vdi.nvidia.com (10.127.8.14) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.1258.12 via Frontend Transport; Fri, 9 Feb 2024 00:40:10 -0800 From: Shravan Kumar Ramani To: Hans de Goede , Ilpo Jarvinen , Vadim Pasternak , "David Thompson" CC: Shravan Kumar Ramani , , Subject: [PATCH v2 1/4] platform/mellanox: mlxbf-pmc: Replace uintN_t with kernel-style types Date: Fri, 9 Feb 2024 03:39:54 -0500 Message-ID: <73cd5e838695f8e20b022a523dcade108685350b.1707466888.git.shravankr@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002BA4B:EE_|DM6PR12MB4878:EE_ X-MS-Office365-Filtering-Correlation-Id: c9e8504f-e098-4745-ea1e-08dc294ac7cc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yFlGNlNpiJ81xv40VSkEZmtql2vi9YXAmudJZYAwZk+3vRwm7XUeYTcWEJemDSMEPqYp5Pb3AJWAlbK8xvlTjm0SalI5o91svlDEtqgWMmvTuBm61DrZnXPjzanV/1ziaY4M6Kiag/btpOyUqdeava38z9OOUJm4xjd5qimq6IsNFJhoePSkm2tEZVC2LB+T7+eijuxV7ylfeqqrNmekURiDDp7Tnfn3s7u/+KwIpWUp4WychyZytmnI54fbs8tZOx96auhOd5jdWlX7GLtVUowO7dKzRMB7e60skeDbKUsIjZY1k/9LgK0A/mxW0HQAG8MjewXPuCeN6BG51SS9LwBhvnJD3U/EkrnOOZoxBn08yv83D8yJg9dgTcqAOtXuopXDmhChghS7YPGURUkypDLpF+YSutWUngop74JtmarCsn15gNw/rlOfvZp3n3fwyicNzLVi93kPdX5DeX/LHUEki0D8TH+4zPrFIDEB4wwGAaaj37RLBJ1dleyJgWAI8IHxw28N2or1GwMJy9NoozY6M1DEsYyQK32wv/zmcAWsk/QYQ59J5YdUTbZnMDuIWj94buis5wcHJB9nrKS+qQ12Q6ie1J63j/2Zl3M2saY= X-Forefront-Antispam-Report: CIP:216.228.118.233;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge2.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(136003)(376002)(39860400002)(396003)(346002)(230922051799003)(64100799003)(1800799012)(451199024)(82310400011)(186009)(40470700004)(46966006)(36840700001)(41300700001)(7696005)(2616005)(30864003)(6666004)(2906002)(4326008)(86362001)(8676002)(426003)(70206006)(5660300002)(70586007)(26005)(336012)(6636002)(316002)(110136005)(478600001)(82740400003)(83380400001)(7636003)(54906003)(356005)(36756003)(8936002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2024 08:40:33.4775 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c9e8504f-e098-4745-ea1e-08dc294ac7cc X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.233];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF0002BA4B.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4878 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790410063498483889 X-GMAIL-MSGID: 1790410063498483889 Signed-off-by: Shravan Kumar Ramani --- drivers/platform/mellanox/mlxbf-pmc.c | 121 +++++++++++++------------- 1 file changed, 59 insertions(+), 62 deletions(-) diff --git a/drivers/platform/mellanox/mlxbf-pmc.c b/drivers/platform/mellanox/mlxbf-pmc.c index b1995ac268d7..71d919832e2a 100644 --- a/drivers/platform/mellanox/mlxbf-pmc.c +++ b/drivers/platform/mellanox/mlxbf-pmc.c @@ -149,17 +149,17 @@ struct mlxbf_pmc_block_info { */ struct mlxbf_pmc_context { struct platform_device *pdev; - uint32_t total_blocks; - uint32_t tile_count; - uint8_t llt_enable; - uint8_t mss_enable; - uint32_t group_num; + u32 total_blocks; + u32 tile_count; + u8 llt_enable; + u8 mss_enable; + u32 group_num; struct device *hwmon_dev; const char *block_name[MLXBF_PMC_MAX_BLOCKS]; struct mlxbf_pmc_block_info block[MLXBF_PMC_MAX_BLOCKS]; const struct attribute_group *groups[MLXBF_PMC_MAX_BLOCKS]; bool svc_sreg_support; - uint32_t sreg_tbl_perf; + u32 sreg_tbl_perf; unsigned int event_set; }; @@ -865,8 +865,8 @@ static struct mlxbf_pmc_context *pmc; static const char *mlxbf_pmc_svc_uuid_str = "89c036b4-e7d7-11e6-8797-001aca00bfc4"; /* Calls an SMC to access a performance register */ -static int mlxbf_pmc_secure_read(void __iomem *addr, uint32_t command, - uint64_t *result) +static int mlxbf_pmc_secure_read(void __iomem *addr, u32 command, + u64 *result) { struct arm_smccc_res res; int status, err = 0; @@ -892,8 +892,8 @@ static int mlxbf_pmc_secure_read(void __iomem *addr, uint32_t command, } /* Read from a performance counter */ -static int mlxbf_pmc_read(void __iomem *addr, uint32_t command, - uint64_t *result) +static int mlxbf_pmc_read(void __iomem *addr, u32 command, + u64 *result) { if (pmc->svc_sreg_support) return mlxbf_pmc_secure_read(addr, command, result); @@ -907,22 +907,22 @@ static int mlxbf_pmc_read(void __iomem *addr, uint32_t command, } /* Convenience function for 32-bit reads */ -static int mlxbf_pmc_readl(void __iomem *addr, uint32_t *result) +static int mlxbf_pmc_readl(void __iomem *addr, u32 *result) { - uint64_t read_out; + u64 read_out; int status; status = mlxbf_pmc_read(addr, MLXBF_PMC_READ_REG_32, &read_out); if (status) return status; - *result = (uint32_t)read_out; + *result = (u32)read_out; return 0; } /* Calls an SMC to access a performance register */ -static int mlxbf_pmc_secure_write(void __iomem *addr, uint32_t command, - uint64_t value) +static int mlxbf_pmc_secure_write(void __iomem *addr, u32 command, + u64 value) { struct arm_smccc_res res; int status, err = 0; @@ -945,7 +945,7 @@ static int mlxbf_pmc_secure_write(void __iomem *addr, uint32_t command, } /* Write to a performance counter */ -static int mlxbf_pmc_write(void __iomem *addr, int command, uint64_t value) +static int mlxbf_pmc_write(void __iomem *addr, int command, u64 value) { if (pmc->svc_sreg_support) return mlxbf_pmc_secure_write(addr, command, value); @@ -959,7 +959,7 @@ static int mlxbf_pmc_write(void __iomem *addr, int command, uint64_t value) } /* Check if the register offset is within the mapped region for the block */ -static bool mlxbf_pmc_valid_range(int blk_num, uint32_t offset) +static bool mlxbf_pmc_valid_range(int blk_num, u32 offset) { if ((offset >= 0) && !(offset % MLXBF_PMC_REG_SIZE) && (offset + MLXBF_PMC_REG_SIZE <= pmc->block[blk_num].blk_size)) @@ -1082,7 +1082,7 @@ static char *mlxbf_pmc_get_event_name(const char *blk, int evt) /* Method to enable/disable/reset l3cache counters */ static int mlxbf_pmc_config_l3_counters(int blk_num, bool enable, bool reset) { - uint32_t perfcnt_cfg = 0; + u32 perfcnt_cfg = 0; if (enable) perfcnt_cfg |= MLXBF_PMC_L3C_PERF_CNT_CFG_EN; @@ -1095,12 +1095,10 @@ static int mlxbf_pmc_config_l3_counters(int blk_num, bool enable, bool reset) } /* Method to handle l3cache counter programming */ -static int mlxbf_pmc_program_l3_counter(int blk_num, uint32_t cnt_num, - uint32_t evt) +static int mlxbf_pmc_program_l3_counter(int blk_num, u32 cnt_num, + u32 evt) { - uint32_t perfcnt_sel_1 = 0; - uint32_t perfcnt_sel = 0; - uint32_t *wordaddr; + u32 perfcnt_sel_1 = 0, perfcnt_sel = 0, *wordaddr; void __iomem *pmcaddr; int ret; @@ -1162,11 +1160,11 @@ static int mlxbf_pmc_program_l3_counter(int blk_num, uint32_t cnt_num, } /* Method to handle crspace counter programming */ -static int mlxbf_pmc_program_crspace_counter(int blk_num, uint32_t cnt_num, - uint32_t evt) +static int mlxbf_pmc_program_crspace_counter(int blk_num, u32 cnt_num, + u32 evt) { - uint32_t word; void *addr; + u32 word; int ret; addr = pmc->block[blk_num].mmio_base + @@ -1187,7 +1185,7 @@ static int mlxbf_pmc_program_crspace_counter(int blk_num, uint32_t cnt_num, } /* Method to clear crspace counter value */ -static int mlxbf_pmc_clear_crspace_counter(int blk_num, uint32_t cnt_num) +static int mlxbf_pmc_clear_crspace_counter(int blk_num, u32 cnt_num) { void *addr; @@ -1199,10 +1197,10 @@ static int mlxbf_pmc_clear_crspace_counter(int blk_num, uint32_t cnt_num) } /* Method to program a counter to monitor an event */ -static int mlxbf_pmc_program_counter(int blk_num, uint32_t cnt_num, - uint32_t evt, bool is_l3) +static int mlxbf_pmc_program_counter(int blk_num, u32 cnt_num, + u32 evt, bool is_l3) { - uint64_t perfctl, perfevt, perfmon_cfg; + u64 perfctl, perfevt, perfmon_cfg; if (cnt_num >= pmc->block[blk_num].counters) return -ENODEV; @@ -1263,12 +1261,12 @@ static int mlxbf_pmc_program_counter(int blk_num, uint32_t cnt_num, } /* Method to handle l3 counter reads */ -static int mlxbf_pmc_read_l3_counter(int blk_num, uint32_t cnt_num, - uint64_t *result) +static int mlxbf_pmc_read_l3_counter(int blk_num, u32 cnt_num, + u64 *result) { - uint32_t perfcnt_low = 0, perfcnt_high = 0; - uint64_t value; + u32 perfcnt_low = 0, perfcnt_high = 0; int status; + u64 value; status = mlxbf_pmc_readl(pmc->block[blk_num].mmio_base + MLXBF_PMC_L3C_PERF_CNT_LOW + @@ -1295,11 +1293,11 @@ static int mlxbf_pmc_read_l3_counter(int blk_num, uint32_t cnt_num, } /* Method to handle crspace counter reads */ -static int mlxbf_pmc_read_crspace_counter(int blk_num, uint32_t cnt_num, - uint64_t *result) +static int mlxbf_pmc_read_crspace_counter(int blk_num, u32 cnt_num, + u64 *result) { - uint32_t value; int status = 0; + u32 value; status = mlxbf_pmc_readl(pmc->block[blk_num].mmio_base + MLXBF_PMC_CRSPACE_PERFMON_VAL0(pmc->block[blk_num].counters) + @@ -1313,11 +1311,11 @@ static int mlxbf_pmc_read_crspace_counter(int blk_num, uint32_t cnt_num, } /* Method to read the counter value */ -static int mlxbf_pmc_read_counter(int blk_num, uint32_t cnt_num, bool is_l3, - uint64_t *result) +static int mlxbf_pmc_read_counter(int blk_num, u32 cnt_num, bool is_l3, + u64 *result) { - uint32_t perfcfg_offset, perfval_offset; - uint64_t perfmon_cfg; + u32 perfcfg_offset, perfval_offset; + u64 perfmon_cfg; int status; if (cnt_num >= pmc->block[blk_num].counters) @@ -1351,13 +1349,12 @@ static int mlxbf_pmc_read_counter(int blk_num, uint32_t cnt_num, bool is_l3, } /* Method to read L3 block event */ -static int mlxbf_pmc_read_l3_event(int blk_num, uint32_t cnt_num, - uint64_t *result) +static int mlxbf_pmc_read_l3_event(int blk_num, u32 cnt_num, + u64 *result) { - uint32_t perfcnt_sel = 0, perfcnt_sel_1 = 0; - uint32_t *wordaddr; + u32 perfcnt_sel = 0, perfcnt_sel_1 = 0, *wordaddr; void __iomem *pmcaddr; - uint64_t evt; + u64 evt; /* Select appropriate register information */ switch (cnt_num) { @@ -1405,10 +1402,10 @@ static int mlxbf_pmc_read_l3_event(int blk_num, uint32_t cnt_num, } /* Method to read crspace block event */ -static int mlxbf_pmc_read_crspace_event(int blk_num, uint32_t cnt_num, - uint64_t *result) +static int mlxbf_pmc_read_crspace_event(int blk_num, u32 cnt_num, + u64 *result) { - uint32_t word, evt; + u32 word, evt; void *addr; int ret; @@ -1429,11 +1426,11 @@ static int mlxbf_pmc_read_crspace_event(int blk_num, uint32_t cnt_num, } /* Method to find the event currently being monitored by a counter */ -static int mlxbf_pmc_read_event(int blk_num, uint32_t cnt_num, bool is_l3, - uint64_t *result) +static int mlxbf_pmc_read_event(int blk_num, u32 cnt_num, bool is_l3, + u64 *result) { - uint32_t perfcfg_offset, perfval_offset; - uint64_t perfmon_cfg, perfevt; + u32 perfcfg_offset, perfval_offset; + u64 perfmon_cfg, perfevt; if (cnt_num >= pmc->block[blk_num].counters) return -EINVAL; @@ -1469,9 +1466,9 @@ static int mlxbf_pmc_read_event(int blk_num, uint32_t cnt_num, bool is_l3, } /* Method to read a register */ -static int mlxbf_pmc_read_reg(int blk_num, uint32_t offset, uint64_t *result) +static int mlxbf_pmc_read_reg(int blk_num, u32 offset, u64 *result) { - uint32_t ecc_out; + u32 ecc_out; if (strstr(pmc->block_name[blk_num], "ecc")) { if (mlxbf_pmc_readl(pmc->block[blk_num].mmio_base + offset, @@ -1490,7 +1487,7 @@ static int mlxbf_pmc_read_reg(int blk_num, uint32_t offset, uint64_t *result) } /* Method to write to a register */ -static int mlxbf_pmc_write_reg(int blk_num, uint32_t offset, uint64_t data) +static int mlxbf_pmc_write_reg(int blk_num, u32 offset, u64 data) { if (strstr(pmc->block_name[blk_num], "ecc")) { return mlxbf_pmc_write(pmc->block[blk_num].mmio_base + offset, @@ -1512,7 +1509,7 @@ static ssize_t mlxbf_pmc_counter_show(struct device *dev, attr, struct mlxbf_pmc_attribute, dev_attr); int blk_num, cnt_num, offset; bool is_l3 = false; - uint64_t value; + u64 value; blk_num = attr_counter->nr; cnt_num = attr_counter->index; @@ -1546,7 +1543,7 @@ static ssize_t mlxbf_pmc_counter_store(struct device *dev, attr, struct mlxbf_pmc_attribute, dev_attr); int blk_num, cnt_num, offset, err, data; bool is_l3 = false; - uint64_t evt_num; + u64 evt_num; blk_num = attr_counter->nr; cnt_num = attr_counter->index; @@ -1597,7 +1594,7 @@ static ssize_t mlxbf_pmc_event_show(struct device *dev, attr, struct mlxbf_pmc_attribute, dev_attr); int blk_num, cnt_num, err; bool is_l3 = false; - uint64_t evt_num; + u64 evt_num; char *evt_name; blk_num = attr_event->nr; @@ -1686,7 +1683,7 @@ static ssize_t mlxbf_pmc_enable_show(struct device *dev, { struct mlxbf_pmc_attribute *attr_enable = container_of( attr, struct mlxbf_pmc_attribute, dev_attr); - uint32_t perfcnt_cfg, word; + u32 perfcnt_cfg, word; int blk_num, value; blk_num = attr_enable->nr; @@ -1718,7 +1715,7 @@ static ssize_t mlxbf_pmc_enable_store(struct device *dev, struct mlxbf_pmc_attribute *attr_enable = container_of( attr, struct mlxbf_pmc_attribute, dev_attr); int err, en, blk_num; - uint32_t word; + u32 word; blk_num = attr_enable->nr; @@ -1914,7 +1911,7 @@ static bool mlxbf_pmc_guid_match(const guid_t *guid, /* Helper to map the Performance Counters from the varios blocks */ static int mlxbf_pmc_map_counters(struct device *dev) { - uint64_t info[MLXBF_PMC_INFO_SZ]; + u64 info[MLXBF_PMC_INFO_SZ]; int i, tile_num, ret; for (i = 0; i < pmc->total_blocks; ++i) { From patchwork Fri Feb 9 08:39:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shravan Kumar Ramani X-Patchwork-Id: 198784 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp711111dyd; Fri, 9 Feb 2024 00:42:12 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUqJqee0MdmtfG6s78Xdgx0d6hmkW+LhMHJISB8kYIKh55gZhx673mhcZT9s1GBE9XOETj90z1iEyphHAyN1TbHarxC5w== X-Google-Smtp-Source: AGHT+IEGHuCabQ7KQP3GPnkBSV5X/kYL3PuFLGr/e3Ct/9MnWHiWRQslRy0BuWNb617iJHBfXLZr X-Received: by 2002:a05:6902:543:b0:dc6:ce0e:ad47 with SMTP id z3-20020a056902054300b00dc6ce0ead47mr804820ybs.56.1707468132461; Fri, 09 Feb 2024 00:42:12 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUKXtg2p9yWhFA0B4YaR2SwY83FXXTrWsdNzNMcZegTEpfXiBtHhMxwWTFswxYc2qrSnMq7oikEe4PWCJ8zlRm5KbmCBg== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id y14-20020a056a00190e00b006dfde776206si1267299pfi.75.2024.02.09.00.42.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 00:42:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59120-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=O0DQex96; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-59120-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59120-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 361DC287143 for ; Fri, 9 Feb 2024 08:42:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CD4E3664A1; Fri, 9 Feb 2024 08:40:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="O0DQex96" Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2081.outbound.protection.outlook.com [40.107.212.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F40E3664DB; Fri, 9 Feb 2024 08:40:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.212.81 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707468043; cv=fail; b=AlQXhhYkJn0HU+Dpd10l6Ne478k0hUTaSSHnhAJginTpHZPW5tgwIqT0RC3G8HPzWZ6zRoCWcU3S3+HDtosFJEcPHwBRBTAaDIeL+P7dPYkcmH/PU0AtJyRgbezu2OvL32MTna8EiARMX1p5WrTj7xVp1tcplaojEVdSqjGRcBw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707468043; c=relaxed/simple; bh=C5DMkE375gwWFihpjm9SxnxJJY+5nkUgcqSKoDlHnIk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Mp0drcR/dDkmKFLMMjrlwHNY4E2hyZyBxTEVX1Ye0VfDm9lqPl2UJlcS8hYUAGxj/WEyaVN9ikMM9ErPy/2ZSV9IOk6ew7HL8TePKk9dCJRnIY26u4ekH8aLHofkWlm/iGuNzHrsYb7Lfl4KCcT1VeMdOTRgoETsibMvtC+rYcs= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=O0DQex96; arc=fail smtp.client-ip=40.107.212.81 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HVVQWpCZU5JjxyObKx2H1OOloAqUQJNxGmKX+oPdd3NPMwRRkzqant2UKdZKIOcN/uYfZfvrR7UeZsCES7D4OnQpT3t+AqWHhABD1JBbhvtUNS3tl072RTT8cf5Wu0wZpxRiWje0ekBgRbGxnr81WTSPFRpTJGZ81lxXqd3mkjuHJBDl1YB9JXaiuzl4X01jwH3pxDfrn9wLLFSUxMby+QLEsrlecu6te1xpVolBHHq2e8OMdiCrqQuaeMskahDX1Gpc+n8WcUXiKSLf9XN4xOKwq07VZv6bnPRGMSaXmP2NZnyXgFNZsP7PlTv6n1fcAdNjKxHE6skH1K7CtNRTnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=k3eD7DfcGlmCj0sr/Pozml4CO2RM3R9Nwdj5Ax0/XQY=; b=nNhIc5MZpx59mh5uhjKSiKCWyNt3lM+Eb7BRkyn6uYokUjTUb8mxb1n0vH4Hj1cnByIlG3VKQlA6YGs0oG9uA7XLeROtDZvXG35Kr8ypaE7i8mPTZA6t7APDqmELkCK8ssKnsog/jep9VXldEdo8dUMhXrmWQ6tTF1opCZCaTj3csTzs1P2ULkv5CPtS0NgRDYgbL4PBr5sCX8dIg6+nocK8/N5aaJ4bz9897terW7LFrvDXXPjLiZeF4loFheMoyq2zx5nNbgFri6TLy5hoI+eL+6wvU5sZGO0pZumiWlkOcQ7segu7EkGDkZ1q7jWThYBVKoKzZc5cdVeT9PXQRw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=redhat.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=k3eD7DfcGlmCj0sr/Pozml4CO2RM3R9Nwdj5Ax0/XQY=; b=O0DQex966qT4eaDdvZqI1PkAiRPDBC3krDKde5txatng3Rotc8YbxRCVgBQDtGUrBdZUJvv9C30gdjeU6smjA1c0py2otmtA4S/p5CXUM8MAANdDrgUPwgjtKXfiw/7Xw3ThJ/Q9xtgQyeyl24jR4tBT6qKd8J6HiIk+m7KmCp0mVvor1Ft3tcxcUH9p3/oclFGCE9ILMx5UFAZuf2hbMurW9hUG9hr2bhiSoOfML9LR7RSbhiVbBbYvhxbpqyl7u5iKtbfCT+wdJV14Tpxqc98+CdrI4aCg7G9KHMUYdwZzj8WxsesuTJXhbeVAGbY39qK5K/3fhnmJS+OXbaEhNw== Received: from PR0P264CA0156.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:1b::24) by DS7PR12MB8229.namprd12.prod.outlook.com (2603:10b6:8:ea::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.12; Fri, 9 Feb 2024 08:40:36 +0000 Received: from SN1PEPF0002BA4F.namprd03.prod.outlook.com (2603:10a6:100:1b:cafe::ef) by PR0P264CA0156.outlook.office365.com (2603:10a6:100:1b::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.37 via Frontend Transport; Fri, 9 Feb 2024 08:40:35 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by SN1PEPF0002BA4F.mail.protection.outlook.com (10.167.242.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.19 via Frontend Transport; Fri, 9 Feb 2024 08:40:34 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Fri, 9 Feb 2024 00:40:14 -0800 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail202.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Fri, 9 Feb 2024 00:40:13 -0800 Received: from vdi.nvidia.com (10.127.8.14) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.1258.12 via Frontend Transport; Fri, 9 Feb 2024 00:40:12 -0800 From: Shravan Kumar Ramani To: Hans de Goede , Ilpo Jarvinen , Vadim Pasternak , "David Thompson" CC: Shravan Kumar Ramani , , Subject: [PATCH v2 2/4] platform/mellanox: mlxbf-pmc: Fix signed/unsigned mix-up Date: Fri, 9 Feb 2024 03:39:55 -0500 Message-ID: <366b8fc6f5d77c01f9e0e2ad25627df583729017.1707466888.git.shravankr@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002BA4F:EE_|DS7PR12MB8229:EE_ X-MS-Office365-Filtering-Correlation-Id: 7fab728d-7f29-4c86-ab3a-08dc294ac87e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2XspLSM55HziTuwygXiuyZ1TtbFx85AAG7AK0YBUASuefBQ+yo4uM26CjHw1u8/ZZ+OhinKGRoshtzvXryIQkxF6UEzg7ZCkRMY8bYttUasi4KKs1df2nW1k6MPljJWlKQXhgdZqZ8zefWkr2CJQPZOV11Yqf3ClwJa3qTjF4QopoSz3nkUm0HLxOwhKDTUG/Yw4XbVskYOPQTqPGY5D8TDbZ7etc9LycvmTUN3ho2SgWfHJERgVrum38e3OtiL/+drzAdAjnD1yzGmQnTTHnNU7JsAOfVykAwpVi0zF0BWZ767wkZxdFcaZl/9+3zZZGbQejTG+pl8zL961CmMQUEHqgwOuQZdhThkkjp+ltcJOlnLvOTziZDYoiOyJRtYaS7zAfo6GI3FJGUBu7M/QvLZEDP3tzd6jauGzM7czQssDeKoq4j+tTwGNj19GqUt5+FbYeTxzJ3FB/FfroFcjBxpXVUJI5H/QmQMELBr/6fE7V098cVMDNGHvT+62aEjj3qdh4aHnHOV0wWHrxf8CZIeQPS1Ep69ts/ZOncGS2oOz7GqImtZycYZ+eQDqicXtPSb9jaOh8j9J4ars6OxB0UP50sgm8h93X5G+GYBj02I= X-Forefront-Antispam-Report: CIP:216.228.118.233;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge2.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(136003)(346002)(376002)(39860400002)(396003)(230922051799003)(64100799003)(1800799012)(451199024)(186009)(82310400011)(36840700001)(40470700004)(46966006)(36756003)(478600001)(41300700001)(86362001)(356005)(30864003)(2906002)(7636003)(5660300002)(82740400003)(54906003)(2616005)(110136005)(316002)(4326008)(70586007)(8936002)(8676002)(70206006)(6636002)(26005)(336012)(426003)(83380400001)(7696005)(6666004);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2024 08:40:34.6581 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7fab728d-7f29-4c86-ab3a-08dc294ac87e X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.233];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF0002BA4F.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB8229 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790410104853353624 X-GMAIL-MSGID: 1790410104853353624 Signed-off-by: Shravan Kumar Ramani --- drivers/platform/mellanox/mlxbf-pmc.c | 110 ++++++++++++++------------ 1 file changed, 58 insertions(+), 52 deletions(-) diff --git a/drivers/platform/mellanox/mlxbf-pmc.c b/drivers/platform/mellanox/mlxbf-pmc.c index 71d919832e2a..e3f1ae772e43 100644 --- a/drivers/platform/mellanox/mlxbf-pmc.c +++ b/drivers/platform/mellanox/mlxbf-pmc.c @@ -99,8 +99,8 @@ */ struct mlxbf_pmc_attribute { struct device_attribute dev_attr; - int index; - int nr; + unsigned int index; + unsigned int nr; }; /** @@ -121,7 +121,7 @@ struct mlxbf_pmc_block_info { void __iomem *mmio_base; size_t blk_size; size_t counters; - int type; + unsigned int type; struct mlxbf_pmc_attribute *attr_counter; struct mlxbf_pmc_attribute *attr_event; struct mlxbf_pmc_attribute attr_event_list; @@ -169,7 +169,7 @@ struct mlxbf_pmc_context { * @evt_name: Name of the event */ struct mlxbf_pmc_events { - int evt_num; + u32 evt_num; char *evt_name; }; @@ -959,7 +959,7 @@ static int mlxbf_pmc_write(void __iomem *addr, int command, u64 value) } /* Check if the register offset is within the mapped region for the block */ -static bool mlxbf_pmc_valid_range(int blk_num, u32 offset) +static bool mlxbf_pmc_valid_range(unsigned int blk_num, u32 offset) { if ((offset >= 0) && !(offset % MLXBF_PMC_REG_SIZE) && (offset + MLXBF_PMC_REG_SIZE <= pmc->block[blk_num].blk_size)) @@ -970,7 +970,7 @@ static bool mlxbf_pmc_valid_range(int blk_num, u32 offset) /* Get the event list corresponding to a certain block */ static const struct mlxbf_pmc_events *mlxbf_pmc_event_list(const char *blk, - int *size) + unsigned int *size) { const struct mlxbf_pmc_events *events; @@ -1047,7 +1047,7 @@ static const struct mlxbf_pmc_events *mlxbf_pmc_event_list(const char *blk, static int mlxbf_pmc_get_event_num(const char *blk, const char *evt) { const struct mlxbf_pmc_events *events; - int i, size; + unsigned int size, i; events = mlxbf_pmc_event_list(blk, &size); if (!events) @@ -1062,10 +1062,10 @@ static int mlxbf_pmc_get_event_num(const char *blk, const char *evt) } /* Get the event number given the name */ -static char *mlxbf_pmc_get_event_name(const char *blk, int evt) +static char *mlxbf_pmc_get_event_name(const char *blk, u32 evt) { const struct mlxbf_pmc_events *events; - int i, size; + unsigned int size, i; events = mlxbf_pmc_event_list(blk, &size); if (!events) @@ -1080,7 +1080,7 @@ static char *mlxbf_pmc_get_event_name(const char *blk, int evt) } /* Method to enable/disable/reset l3cache counters */ -static int mlxbf_pmc_config_l3_counters(int blk_num, bool enable, bool reset) +static int mlxbf_pmc_config_l3_counters(unsigned int blk_num, bool enable, bool reset) { u32 perfcnt_cfg = 0; @@ -1095,7 +1095,7 @@ static int mlxbf_pmc_config_l3_counters(int blk_num, bool enable, bool reset) } /* Method to handle l3cache counter programming */ -static int mlxbf_pmc_program_l3_counter(int blk_num, u32 cnt_num, +static int mlxbf_pmc_program_l3_counter(unsigned int blk_num, u32 cnt_num, u32 evt) { u32 perfcnt_sel_1 = 0, perfcnt_sel = 0, *wordaddr; @@ -1160,7 +1160,7 @@ static int mlxbf_pmc_program_l3_counter(int blk_num, u32 cnt_num, } /* Method to handle crspace counter programming */ -static int mlxbf_pmc_program_crspace_counter(int blk_num, u32 cnt_num, +static int mlxbf_pmc_program_crspace_counter(unsigned int blk_num, u32 cnt_num, u32 evt) { void *addr; @@ -1185,7 +1185,7 @@ static int mlxbf_pmc_program_crspace_counter(int blk_num, u32 cnt_num, } /* Method to clear crspace counter value */ -static int mlxbf_pmc_clear_crspace_counter(int blk_num, u32 cnt_num) +static int mlxbf_pmc_clear_crspace_counter(unsigned int blk_num, u32 cnt_num) { void *addr; @@ -1197,7 +1197,7 @@ static int mlxbf_pmc_clear_crspace_counter(int blk_num, u32 cnt_num) } /* Method to program a counter to monitor an event */ -static int mlxbf_pmc_program_counter(int blk_num, u32 cnt_num, +static int mlxbf_pmc_program_counter(unsigned int blk_num, u32 cnt_num, u32 evt, bool is_l3) { u64 perfctl, perfevt, perfmon_cfg; @@ -1261,7 +1261,7 @@ static int mlxbf_pmc_program_counter(int blk_num, u32 cnt_num, } /* Method to handle l3 counter reads */ -static int mlxbf_pmc_read_l3_counter(int blk_num, u32 cnt_num, +static int mlxbf_pmc_read_l3_counter(unsigned int blk_num, u32 cnt_num, u64 *result) { u32 perfcnt_low = 0, perfcnt_high = 0; @@ -1293,7 +1293,7 @@ static int mlxbf_pmc_read_l3_counter(int blk_num, u32 cnt_num, } /* Method to handle crspace counter reads */ -static int mlxbf_pmc_read_crspace_counter(int blk_num, u32 cnt_num, +static int mlxbf_pmc_read_crspace_counter(unsigned int blk_num, u32 cnt_num, u64 *result) { int status = 0; @@ -1311,7 +1311,7 @@ static int mlxbf_pmc_read_crspace_counter(int blk_num, u32 cnt_num, } /* Method to read the counter value */ -static int mlxbf_pmc_read_counter(int blk_num, u32 cnt_num, bool is_l3, +static int mlxbf_pmc_read_counter(unsigned int blk_num, u32 cnt_num, bool is_l3, u64 *result) { u32 perfcfg_offset, perfval_offset; @@ -1349,7 +1349,7 @@ static int mlxbf_pmc_read_counter(int blk_num, u32 cnt_num, bool is_l3, } /* Method to read L3 block event */ -static int mlxbf_pmc_read_l3_event(int blk_num, u32 cnt_num, +static int mlxbf_pmc_read_l3_event(unsigned int blk_num, u32 cnt_num, u64 *result) { u32 perfcnt_sel = 0, perfcnt_sel_1 = 0, *wordaddr; @@ -1402,7 +1402,7 @@ static int mlxbf_pmc_read_l3_event(int blk_num, u32 cnt_num, } /* Method to read crspace block event */ -static int mlxbf_pmc_read_crspace_event(int blk_num, u32 cnt_num, +static int mlxbf_pmc_read_crspace_event(unsigned int blk_num, u32 cnt_num, u64 *result) { u32 word, evt; @@ -1426,7 +1426,7 @@ static int mlxbf_pmc_read_crspace_event(int blk_num, u32 cnt_num, } /* Method to find the event currently being monitored by a counter */ -static int mlxbf_pmc_read_event(int blk_num, u32 cnt_num, bool is_l3, +static int mlxbf_pmc_read_event(unsigned int blk_num, u32 cnt_num, bool is_l3, u64 *result) { u32 perfcfg_offset, perfval_offset; @@ -1466,7 +1466,7 @@ static int mlxbf_pmc_read_event(int blk_num, u32 cnt_num, bool is_l3, } /* Method to read a register */ -static int mlxbf_pmc_read_reg(int blk_num, u32 offset, u64 *result) +static int mlxbf_pmc_read_reg(unsigned int blk_num, u32 offset, u64 *result) { u32 ecc_out; @@ -1487,7 +1487,7 @@ static int mlxbf_pmc_read_reg(int blk_num, u32 offset, u64 *result) } /* Method to write to a register */ -static int mlxbf_pmc_write_reg(int blk_num, u32 offset, u64 data) +static int mlxbf_pmc_write_reg(unsigned int blk_num, u32 offset, u64 data) { if (strstr(pmc->block_name[blk_num], "ecc")) { return mlxbf_pmc_write(pmc->block[blk_num].mmio_base + offset, @@ -1507,7 +1507,7 @@ static ssize_t mlxbf_pmc_counter_show(struct device *dev, { struct mlxbf_pmc_attribute *attr_counter = container_of( attr, struct mlxbf_pmc_attribute, dev_attr); - int blk_num, cnt_num, offset; + unsigned int blk_num, cnt_num, offset; bool is_l3 = false; u64 value; @@ -1541,14 +1541,15 @@ static ssize_t mlxbf_pmc_counter_store(struct device *dev, { struct mlxbf_pmc_attribute *attr_counter = container_of( attr, struct mlxbf_pmc_attribute, dev_attr); - int blk_num, cnt_num, offset, err, data; + unsigned int blk_num, cnt_num, offset, data; bool is_l3 = false; u64 evt_num; + int err; blk_num = attr_counter->nr; cnt_num = attr_counter->index; - err = kstrtoint(buf, 0, &data); + err = kstrtouint(buf, 0, &data); if (err < 0) return err; @@ -1577,7 +1578,7 @@ static ssize_t mlxbf_pmc_counter_store(struct device *dev, if (err) return err; } else if (pmc->block[blk_num].type == MLXBF_PMC_TYPE_CRSPACE) { - if (sscanf(attr->attr.name, "counter%d", &cnt_num) != 1) + if (sscanf(attr->attr.name, "counter%u", &cnt_num) != 1) return -EINVAL; err = mlxbf_pmc_clear_crspace_counter(blk_num, cnt_num); } else @@ -1592,10 +1593,11 @@ static ssize_t mlxbf_pmc_event_show(struct device *dev, { struct mlxbf_pmc_attribute *attr_event = container_of( attr, struct mlxbf_pmc_attribute, dev_attr); - int blk_num, cnt_num, err; + unsigned int blk_num, cnt_num; bool is_l3 = false; - u64 evt_num; char *evt_name; + u64 evt_num; + int err; blk_num = attr_event->nr; cnt_num = attr_event->index; @@ -1621,8 +1623,9 @@ static ssize_t mlxbf_pmc_event_store(struct device *dev, { struct mlxbf_pmc_attribute *attr_event = container_of( attr, struct mlxbf_pmc_attribute, dev_attr); - int blk_num, cnt_num, evt_num, err; + unsigned int blk_num, cnt_num, evt_num; bool is_l3 = false; + int err; blk_num = attr_event->nr; cnt_num = attr_event->index; @@ -1633,7 +1636,7 @@ static ssize_t mlxbf_pmc_event_store(struct device *dev, if (evt_num < 0) return -EINVAL; } else { - err = kstrtoint(buf, 0, &evt_num); + err = kstrtouint(buf, 0, &evt_num); if (err < 0) return err; } @@ -1655,9 +1658,10 @@ static ssize_t mlxbf_pmc_event_list_show(struct device *dev, { struct mlxbf_pmc_attribute *attr_event_list = container_of( attr, struct mlxbf_pmc_attribute, dev_attr); - int blk_num, i, size, len = 0, ret = 0; + unsigned int blk_num, i, size, len = 0; const struct mlxbf_pmc_events *events; char e_info[MLXBF_PMC_EVENT_INFO_LEN]; + int ret = 0; blk_num = attr_event_list->nr; @@ -1683,8 +1687,8 @@ static ssize_t mlxbf_pmc_enable_show(struct device *dev, { struct mlxbf_pmc_attribute *attr_enable = container_of( attr, struct mlxbf_pmc_attribute, dev_attr); + unsigned int blk_num, value; u32 perfcnt_cfg, word; - int blk_num, value; blk_num = attr_enable->nr; @@ -1704,7 +1708,7 @@ static ssize_t mlxbf_pmc_enable_show(struct device *dev, value = FIELD_GET(MLXBF_PMC_L3C_PERF_CNT_CFG_EN, perfcnt_cfg); } - return sysfs_emit(buf, "%d\n", value); + return sysfs_emit(buf, "%u\n", value); } /* Store function for "enable" sysfs files - only for l3cache & crspace */ @@ -1714,12 +1718,13 @@ static ssize_t mlxbf_pmc_enable_store(struct device *dev, { struct mlxbf_pmc_attribute *attr_enable = container_of( attr, struct mlxbf_pmc_attribute, dev_attr); - int err, en, blk_num; + unsigned int en, blk_num; u32 word; + int err; blk_num = attr_enable->nr; - err = kstrtoint(buf, 0, &en); + err = kstrtouint(buf, 0, &en); if (err < 0) return err; @@ -1757,10 +1762,10 @@ static ssize_t mlxbf_pmc_enable_store(struct device *dev, } /* Populate attributes for blocks with counters to monitor performance */ -static int mlxbf_pmc_init_perftype_counter(struct device *dev, int blk_num) +static int mlxbf_pmc_init_perftype_counter(struct device *dev, unsigned int blk_num) { struct mlxbf_pmc_attribute *attr; - int i = 0, j = 0; + unsigned int i = 0, j = 0; /* "event_list" sysfs to list events supported by the block */ attr = &pmc->block[blk_num].attr_event_list; @@ -1810,7 +1815,7 @@ static int mlxbf_pmc_init_perftype_counter(struct device *dev, int blk_num) attr->index = j; attr->nr = blk_num; attr->dev_attr.attr.name = devm_kasprintf(dev, GFP_KERNEL, - "counter%d", j); + "counter%u", j); if (!attr->dev_attr.attr.name) return -ENOMEM; pmc->block[blk_num].block_attr[++i] = &attr->dev_attr.attr; @@ -1823,7 +1828,7 @@ static int mlxbf_pmc_init_perftype_counter(struct device *dev, int blk_num) attr->index = j; attr->nr = blk_num; attr->dev_attr.attr.name = devm_kasprintf(dev, GFP_KERNEL, - "event%d", j); + "event%u", j); if (!attr->dev_attr.attr.name) return -ENOMEM; pmc->block[blk_num].block_attr[++i] = &attr->dev_attr.attr; @@ -1834,11 +1839,11 @@ static int mlxbf_pmc_init_perftype_counter(struct device *dev, int blk_num) } /* Populate attributes for blocks with registers to monitor performance */ -static int mlxbf_pmc_init_perftype_reg(struct device *dev, int blk_num) +static int mlxbf_pmc_init_perftype_reg(struct device *dev, unsigned int blk_num) { - struct mlxbf_pmc_attribute *attr; const struct mlxbf_pmc_events *events; - int i = 0, j = 0; + struct mlxbf_pmc_attribute *attr; + unsigned int i = 0, j = 0; events = mlxbf_pmc_event_list(pmc->block_name[blk_num], &j); if (!events) @@ -1869,7 +1874,7 @@ static int mlxbf_pmc_init_perftype_reg(struct device *dev, int blk_num) } /* Helper to create the bfperf sysfs sub-directories and files */ -static int mlxbf_pmc_create_groups(struct device *dev, int blk_num) +static int mlxbf_pmc_create_groups(struct device *dev, unsigned int blk_num) { int err; @@ -1912,18 +1917,19 @@ static bool mlxbf_pmc_guid_match(const guid_t *guid, static int mlxbf_pmc_map_counters(struct device *dev) { u64 info[MLXBF_PMC_INFO_SZ]; - int i, tile_num, ret; + unsigned int tile_num, i; + int ret; for (i = 0; i < pmc->total_blocks; ++i) { /* Create sysfs for tiles only if block number < tile_count */ if (strstr(pmc->block_name[i], "tilenet")) { - if (sscanf(pmc->block_name[i], "tilenet%d", &tile_num) != 1) + if (sscanf(pmc->block_name[i], "tilenet%u", &tile_num) != 1) continue; if (tile_num >= pmc->tile_count) continue; } else if (strstr(pmc->block_name[i], "tile")) { - if (sscanf(pmc->block_name[i], "tile%d", &tile_num) != 1) + if (sscanf(pmc->block_name[i], "tile%u", &tile_num) != 1) continue; if (tile_num >= pmc->tile_count) @@ -1933,9 +1939,9 @@ static int mlxbf_pmc_map_counters(struct device *dev) /* Create sysfs only for enabled MSS blocks */ if (strstr(pmc->block_name[i], "mss") && pmc->event_set == MLXBF_PMC_EVENT_SET_BF3) { - int mss_num; + unsigned int mss_num; - if (sscanf(pmc->block_name[i], "mss%d", &mss_num) != 1) + if (sscanf(pmc->block_name[i], "mss%u", &mss_num) != 1) continue; if (!((pmc->mss_enable >> mss_num) & 0x1)) @@ -1944,17 +1950,17 @@ static int mlxbf_pmc_map_counters(struct device *dev) /* Create sysfs only for enabled LLT blocks */ if (strstr(pmc->block_name[i], "llt_miss")) { - int llt_num; + unsigned int llt_num; - if (sscanf(pmc->block_name[i], "llt_miss%d", &llt_num) != 1) + if (sscanf(pmc->block_name[i], "llt_miss%u", &llt_num) != 1) continue; if (!((pmc->llt_enable >> llt_num) & 0x1)) continue; } else if (strstr(pmc->block_name[i], "llt")) { - int llt_num; + unsigned int llt_num; - if (sscanf(pmc->block_name[i], "llt%d", &llt_num) != 1) + if (sscanf(pmc->block_name[i], "llt%u", &llt_num) != 1) continue; if (!((pmc->llt_enable >> llt_num) & 0x1)) From patchwork Fri Feb 9 08:39:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shravan Kumar Ramani X-Patchwork-Id: 198783 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp711034dyd; Fri, 9 Feb 2024 00:42:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IGykvVU7bIMODvre4XvmJUA3XaMlw1fzpfmecsJHE7ryeY/qEha2EKl94FKO3ztvhwGIHVH X-Received: by 2002:a05:6a21:9703:b0:19c:9ebc:93b1 with SMTP id ub3-20020a056a21970300b0019c9ebc93b1mr839483pzb.59.1707468123182; Fri, 09 Feb 2024 00:42:03 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUp3/BSzuHLWbTw/RxXEJPvXZZj9DU35vF+NzjJtvNXvL/QiC4HNJxaaa9DmtStU8I6AaMvNzSr8TvVAehfH3lv+kC78g== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id e63-20020a17090a6fc500b00296f79733d1si1246073pjk.115.2024.02.09.00.42.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 00:42:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59119-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=oKannA62; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-59119-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59119-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id E57B3287365 for ; Fri, 9 Feb 2024 08:42:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0B7CE67C5D; Fri, 9 Feb 2024 08:40:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="oKannA62" Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2054.outbound.protection.outlook.com [40.107.223.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 45B25664A2; Fri, 9 Feb 2024 08:40:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.54 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707468043; cv=fail; b=ghYlM6f86RGH6Aq89q08dFHqVTSU4qIYkTYDHBGQyn8yBLpO482y3fjV/rPOa0lT9rroER3hY5+Be7g8j4TdHK9dnoUGVhOKBp3522COkuxT6SQvxBpdXI9YJRUkiH/DPD6uVl4rWLaqevT1OimflS7WkCZDqYCU9QBNDEk4Lc8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707468043; c=relaxed/simple; bh=lOK1DwaZlHVX926/hU7fLkjHIgtZhm5gxIiTs2GlNq4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=dMhsHLbUiy2C6G2IzrolV3yDCpgNPWvGpLnoP05fy5phPCCyQgw4wxvuGZPYkzkoZm8JEjXgszCPIkhX/ASxRrnz+aJaiDBZJ99SLT1XUAj2c60wqXNsO6DOJA/96n7v/Tje5xJ3haUZTY6CzPsZutFwFtq8xAqI664P1j9Q0Io= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=oKannA62; arc=fail smtp.client-ip=40.107.223.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UN8CpQkn2ZjhJGpG/9fNoxflXJ2HbNUA/MwhlmHRvKg5KfndkaeXX0kkPoBOyJRghiHHtUYLnjEXuB0qUlSxQh6GrIoy3xTxV44ebkSdo6X+2mty+Ir00cCB8cjiMnnp54ViHDJHKpKWHxjC2jUfN9i0CYfIsFsLDbYTYxRc1J8VEQerBwNQ2UjKIgzn1u4+6qZx9pxPq2J9cm4O9G73vFPfkd/CNiz6pHW1ZqeMxZrf35/SKC1yZjq0IZRG0ZPzjpKQ+PNqapvCUDH4NxVpUD62fJwofKRTh6JblnrVM9/vrK3QUhXLLh5pdp8vn+jrt15OZvWK942xszUcG7aGZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=TDu3fl6DoOoIzRAZuGSuq/jUHs2oXp91UUbXPaWWQ4Q=; b=AoKE7SBYxSonbU/Vs8rkyNyjg0IC4yN6hRU51GIHl3oQthFyOhVjHZCBTBxly0Z5ksS9QyaotDqBVhM7imcFGcUgwW4avb3P7hqUO7x+BowyNYrZ/PMwncTCToE2mYS4U8ShP+9UB8IBUjZlvKSKoOkNIi2xFnbkPLANGFMmXvIqaH0p4QLoB43A0hTE4V4cJcx3fz7nK2bMB0QcB5y4TVCq8MZHZNZGISplD+IgkrOqxVmaQEXXB3hLBTSh76ZTTdCIz6zrnYnHTgCRNws8fvkpoLcbsIt7Q49fSp0dcBbLmmlhixvDTq/fPyws0tY4q/AdS3hRGNwW135qmOJPXA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=redhat.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TDu3fl6DoOoIzRAZuGSuq/jUHs2oXp91UUbXPaWWQ4Q=; b=oKannA62YvsNqrTL3a+g0CNFcQPY3q1YkryL7fpkxfK6Qut3m290/29bij6ORlX36068FsnwHdHYXrdkYfQ/pzCFJszsm/AUwoVjMX0Lc9Y4cTUGbM9UB4RebQrh+LnpxNtK5ux2HrVeojnKF5sFk+4TdP17DOgXpK24pqOLPO7jsbNXoHe71yz/fdAQySqMio6lcoAmMvJ5Qf971XC7AUejTqyndIY6K9FFhSSO4KZtWhLg9nnhAaVGul/BuKD3Kvjhfg90s22zwabdpgBZrZf5UHZxC1dYTmoM2shlVPJiZvryNRMU7w3pWfCrsmdP/APj0piGB/a2hRAOnfZmLg== Received: from DM6PR03CA0098.namprd03.prod.outlook.com (2603:10b6:5:333::31) by CY8PR12MB8215.namprd12.prod.outlook.com (2603:10b6:930:77::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.13; Fri, 9 Feb 2024 08:40:37 +0000 Received: from SN1PEPF0002BA4B.namprd03.prod.outlook.com (2603:10b6:5:333:cafe::ef) by DM6PR03CA0098.outlook.office365.com (2603:10b6:5:333::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.39 via Frontend Transport; Fri, 9 Feb 2024 08:40:37 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by SN1PEPF0002BA4B.mail.protection.outlook.com (10.167.242.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.19 via Frontend Transport; Fri, 9 Feb 2024 08:40:36 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Fri, 9 Feb 2024 00:40:16 -0800 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Fri, 9 Feb 2024 00:40:15 -0800 Received: from vdi.nvidia.com (10.127.8.14) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.1258.12 via Frontend Transport; Fri, 9 Feb 2024 00:40:15 -0800 From: Shravan Kumar Ramani To: Hans de Goede , Ilpo Jarvinen , Vadim Pasternak , "David Thompson" CC: Shravan Kumar Ramani , , Subject: [PATCH v2 3/4] platform/mellanox: mlxbf-pmc: Add support for 64-bit counters and cycle count Date: Fri, 9 Feb 2024 03:39:56 -0500 Message-ID: <737777a08e6decf3033334ad2d6e49c9f374e026.1707466888.git.shravankr@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002BA4B:EE_|CY8PR12MB8215:EE_ X-MS-Office365-Filtering-Correlation-Id: 10008fda-7da4-4794-20de-08dc294ac9cb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jmRNJbP8fwlh0JO9mhD+Y9Ac0beXtDlp+CVonFLt0V6VTuXuebTVZ3LfGy++Rbu+yDTNz6dzQEFPtFyiY7aLLVDYwE42Z2MrOcQgl2bv+8NzDsfT8EqIhD1Q3LwL3wf5+Sqh7jVz163DlGGbJUYa26OAj/tV49l3P3Vv6MyMhPNJa8X7JigfLecctIM4E+RYr0FJlFpGRUTYjWBlXPl3xkWtv1DT439Evv76XhQjlWuJkdQ3OnoX1v1nes4+SEghYLwu6eHo6bCq87NqbxvsUhHzo1o2mIPkrUSOLFppRgGy4ecxzykwP0kHSwysm0uUFCogq790KAHSvbnXMeFR9V8XqBB0CRguky2N3IklWAcF9hj6flg1z3c9ujXKvBUES/AwSTcBWXKXD6uh2FxQIFtirimE7yRWUFZZUBjOTB8/ialtiOygWZcgsQPMnhqGvLtw8vu/mo2HSxCN4vxSz5kHXPr5MSacsk7r+J4MKvhrPoQzpoFMzsZ2OKrVu+mQ+KyDZtDapJZv19jNjUe9z7mzD1aH8iFMSjaAYJr6PF807xt24k2IzF7rKSKepzYMQ8/8VNrwwqLft73m/281s01rZZ/NuRvIh1PR4q/hPl8= X-Forefront-Antispam-Report: CIP:216.228.118.233;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge2.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(376002)(136003)(39860400002)(346002)(396003)(230922051799003)(451199024)(186009)(82310400011)(1800799012)(64100799003)(46966006)(40470700004)(36840700001)(5660300002)(70206006)(4326008)(8676002)(70586007)(8936002)(2906002)(83380400001)(26005)(426003)(336012)(82740400003)(356005)(7636003)(36756003)(86362001)(110136005)(6636002)(54906003)(6666004)(316002)(41300700001)(2616005)(478600001)(7696005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2024 08:40:36.8212 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 10008fda-7da4-4794-20de-08dc294ac9cb X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.233];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF0002BA4B.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB8215 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790410095200297359 X-GMAIL-MSGID: 1790410095200297359 Add support for programming any counter to monitor the cycle count. Since counting of cycles using 32-bit ocunters would result in frequent wraparounds, add the ability to combine 2 adjacent 32-bit counters to form 1 64-bit counter. Both these features are supported by BlueField-3 PMC hardware, hence the required bit-fields are exposed by the driver via sysfs to allow the user to configure as needed. Signed-off-by: Shravan Kumar Ramani Reviewed-by: David Thompson Reviewed-by: Vadim Pasternak --- drivers/platform/mellanox/mlxbf-pmc.c | 134 ++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) diff --git a/drivers/platform/mellanox/mlxbf-pmc.c b/drivers/platform/mellanox/mlxbf-pmc.c index e3f1ae772e43..1b9356a3ffab 100644 --- a/drivers/platform/mellanox/mlxbf-pmc.c +++ b/drivers/platform/mellanox/mlxbf-pmc.c @@ -88,6 +88,8 @@ #define MLXBF_PMC_CRSPACE_PERFMON_CTL(n) (n * MLXBF_PMC_CRSPACE_PERFMON_REG0_SZ) #define MLXBF_PMC_CRSPACE_PERFMON_EN BIT(30) #define MLXBF_PMC_CRSPACE_PERFMON_CLR BIT(28) +#define MLXBF_PMC_CRSPACE_PERFMON_UOC GENMASK(15, 0) +#define MLXBF_PMC_CRSPACE_PERFMON_COUNT_CLOCK(n) (MLXBF_PMC_CRSPACE_PERFMON_CTL(n) + 0x4) #define MLXBF_PMC_CRSPACE_PERFMON_VAL0(n) (MLXBF_PMC_CRSPACE_PERFMON_CTL(n) + 0xc) /** @@ -114,6 +116,8 @@ struct mlxbf_pmc_attribute { * @attr_event: Attributes for "event" sysfs files * @attr_event_list: Attributes for "event_list" sysfs files * @attr_enable: Attributes for "enable" sysfs files + * @attr_use_odd_counter: Attributes for "use_odd_counter" sysfs files + * @attr_count_clock: Attributes for "count_clock" sysfs files * @block_attr: All attributes needed for the block * @block_attr_grp: Attribute group for the block */ @@ -126,6 +130,8 @@ struct mlxbf_pmc_block_info { struct mlxbf_pmc_attribute *attr_event; struct mlxbf_pmc_attribute attr_event_list; struct mlxbf_pmc_attribute attr_enable; + struct mlxbf_pmc_attribute attr_use_odd_counter; + struct mlxbf_pmc_attribute attr_count_clock; struct attribute *block_attr[MLXBF_PMC_MAX_ATTRS]; struct attribute_group block_attr_grp; }; @@ -1761,6 +1767,103 @@ static ssize_t mlxbf_pmc_enable_store(struct device *dev, return count; } +/* Show function for "use_odd_counter" sysfs files - only for crspace */ +static ssize_t mlxbf_pmc_use_odd_counter_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct mlxbf_pmc_attribute *attr_use_odd_counter = container_of( + attr, struct mlxbf_pmc_attribute, dev_attr); + unsigned int blk_num; + u32 value, reg; + + blk_num = attr_use_odd_counter->nr; + + if (mlxbf_pmc_readl(pmc->block[blk_num].mmio_base + + MLXBF_PMC_CRSPACE_PERFMON_CTL(pmc->block[blk_num].counters), + ®)) + return -EINVAL; + + value = FIELD_GET(MLXBF_PMC_CRSPACE_PERFMON_UOC, reg); + + return sysfs_emit(buf, "%u\n", value); +} + +/* Store function for "use_odd_counter" sysfs files - only for crspace */ +static ssize_t mlxbf_pmc_use_odd_counter_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct mlxbf_pmc_attribute *attr_use_odd_counter = container_of( + attr, struct mlxbf_pmc_attribute, dev_attr); + unsigned int blk_num; + u32 uoc, reg; + int err; + + blk_num = attr_use_odd_counter->nr; + + err = kstrtouint(buf, 0, &uoc); + if (err < 0) + return err; + + err = mlxbf_pmc_readl(pmc->block[blk_num].mmio_base + + MLXBF_PMC_CRSPACE_PERFMON_CTL(pmc->block[blk_num].counters), + ®); + if (err) + return -EINVAL; + + reg &= ~MLXBF_PMC_CRSPACE_PERFMON_UOC; + reg |= FIELD_PREP(MLXBF_PMC_CRSPACE_PERFMON_UOC, uoc); + + mlxbf_pmc_write(pmc->block[blk_num].mmio_base + + MLXBF_PMC_CRSPACE_PERFMON_CTL(pmc->block[blk_num].counters), + MLXBF_PMC_WRITE_REG_32, reg); + + return count; +} + +/* Show function for "count_clock" sysfs files - only for crspace */ +static ssize_t mlxbf_pmc_count_clock_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct mlxbf_pmc_attribute *attr_count_clock = container_of( + attr, struct mlxbf_pmc_attribute, dev_attr); + unsigned int blk_num; + u32 reg; + + blk_num = attr_count_clock->nr; + + if (mlxbf_pmc_readl(pmc->block[blk_num].mmio_base + + MLXBF_PMC_CRSPACE_PERFMON_COUNT_CLOCK(pmc->block[blk_num].counters), + ®)) + return -EINVAL; + + return sysfs_emit(buf, "%u\n", reg); +} + +/* Store function for "count_clock" sysfs files - only for crspace */ +static ssize_t mlxbf_pmc_count_clock_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct mlxbf_pmc_attribute *attr_count_clock = container_of( + attr, struct mlxbf_pmc_attribute, dev_attr); + unsigned int blk_num; + u32 reg; + int err; + + blk_num = attr_count_clock->nr; + + err = kstrtouint(buf, 0, ®); + if (err < 0) + return err; + + mlxbf_pmc_write(pmc->block[blk_num].mmio_base + + MLXBF_PMC_CRSPACE_PERFMON_COUNT_CLOCK(pmc->block[blk_num].counters), + MLXBF_PMC_WRITE_REG_32, reg); + + return count; +} + /* Populate attributes for blocks with counters to monitor performance */ static int mlxbf_pmc_init_perftype_counter(struct device *dev, unsigned int blk_num) { @@ -1794,6 +1897,37 @@ static int mlxbf_pmc_init_perftype_counter(struct device *dev, unsigned int blk_ attr = NULL; } + if (pmc->block[blk_num].type == MLXBF_PMC_TYPE_CRSPACE) { + /* + * Couple adjacent odd and even 32-bit counters to form 64-bit counters + * using "use_odd_counter" sysfs which has one bit per even counter. + */ + attr = &pmc->block[blk_num].attr_use_odd_counter; + attr->dev_attr.attr.mode = 0644; + attr->dev_attr.show = mlxbf_pmc_use_odd_counter_show; + attr->dev_attr.store = mlxbf_pmc_use_odd_counter_store; + attr->nr = blk_num; + attr->dev_attr.attr.name = devm_kasprintf(dev, GFP_KERNEL, + "use_odd_counter"); + if (!attr->dev_attr.attr.name) + return -ENOMEM; + pmc->block[blk_num].block_attr[++i] = &attr->dev_attr.attr; + attr = NULL; + + /* Program crspace counters to count clock cycles using "count_clock" sysfs */ + attr = &pmc->block[blk_num].attr_count_clock; + attr->dev_attr.attr.mode = 0644; + attr->dev_attr.show = mlxbf_pmc_count_clock_show; + attr->dev_attr.store = mlxbf_pmc_count_clock_store; + attr->nr = blk_num; + attr->dev_attr.attr.name = devm_kasprintf(dev, GFP_KERNEL, + "count_clock"); + if (!attr->dev_attr.attr.name) + return -ENOMEM; + pmc->block[blk_num].block_attr[++i] = &attr->dev_attr.attr; + attr = NULL; + } + pmc->block[blk_num].attr_counter = devm_kcalloc( dev, pmc->block[blk_num].counters, sizeof(struct mlxbf_pmc_attribute), GFP_KERNEL); From patchwork Fri Feb 9 08:39:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shravan Kumar Ramani X-Patchwork-Id: 198788 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp714745dyd; Fri, 9 Feb 2024 00:52:04 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUycAwnmIbfdMoyhtEDzgC59OjpfJUsBNgF2QklFtgs2Bdn/wIiiaKcKGX5Q7bWLdUsYeUJwcOaiGPbN+G06EHmiIybVQ== X-Google-Smtp-Source: AGHT+IFzVrx71cfDpKbGGoUwNudwo939USd1jg4eD5YZDyxPd2mB9fQBoUC2LOz0PAGP7RGYDGJU X-Received: by 2002:a05:6a21:1646:b0:19e:986d:c16a with SMTP id no6-20020a056a21164600b0019e986dc16amr1356391pzb.9.1707468724797; Fri, 09 Feb 2024 00:52:04 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXhZKDAoRTKGcwJlWOeVRybc7TsaxCqohER+vLSlstXYKImJNCRzPxTSDm4wEhowUSutC+RSKhlEveYWo6gI7bXEiBhZQ== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id j16-20020a170903025000b001d9a29eff0esi1296349plh.394.2024.02.09.00.52.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 00:52:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59121-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=Ys4FPkRf; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-59121-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59121-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 2929AB29B99 for ; Fri, 9 Feb 2024 08:42:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F0E8A67E7D; Fri, 9 Feb 2024 08:40:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="Ys4FPkRf" Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2069.outbound.protection.outlook.com [40.107.96.69]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CB06F664AF; Fri, 9 Feb 2024 08:40:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.96.69 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707468043; cv=fail; b=sMFo+FffWy7UJ2qTxChNz4TiBQMEQ6YYNzp7P4w+mL0i+SlXe3hE6ivhtpo1qxy2PK6VMVQkmpz+YuQGTOSD7YEEXeYsJd0JjKW8bQlnzd+8FAP8fnv7jUJv0stcbMSOKZOluRfDWDwlWAVAoPiGYgf8AXT2+h/jMIN/xMU5qzw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707468043; c=relaxed/simple; bh=AJ62I58qI5mfqqgdroIvrS3CHWUodvRfFiWOQuQOAvY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cx5R5CTw6hN43dhHNc8cxsXNU2vmFwpSlhjvyucS/G7392wsVEmfoVQI+pCXvMbtQ5X2dftZxsuyqZKqSM1jkLltUX6ZdhurBM3ST+meE+42IjDrdbfSkNSIEO6QrWYmc6uU9D7MW9I1yybuj62gcngTEkGcfd8bg3IywyVvWcc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=Ys4FPkRf; arc=fail smtp.client-ip=40.107.96.69 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LFhUp0CrxfkRFjMz3wNJ1wSknXryK6HmhmqtSWNHZX9KWHJsklVkv4/PFf65iPbHDoCVmc/Uhgz5Vepl+8FfhSFZKSYIlmoSM2dctl8sy2IrsM39gDk7LabD/2aU44bB0+AsVA3M4H3dZwNEjr7BtsVLA7exYhjDLsVkOabfdZb6xHZmkdP6lJo0ApDP8rSKlRc0KrUNqR2PcG7jOESMrvUBVHBT7eNa5SP6auNsuX1bJgd9zhktZW6p6CcnQyVUvaoBL5Y2fU1yAFax1qD5HLfOIWePGX/i26nQ41ghTm7S2ha+sBAKOOxQ9N+CHiOW9HEXWRGW7NY2ZToOzPnS6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=FJJEpo6/ZROJHbJTLawterEZ5OhsQAaRnNa93pxuNC4=; b=XKdw49OS+P1EJCgEwewLfQgGW08aioYjkLvPHB3DP4MgcUtpPM8+h3UJ/HSvZe4iDPddydEJ2Sg6NdCsAQqnzv3iiBhqValRHxq3yq68XY/GqFJYlxXhFfa/oJ2k2XzpnyStcR6JwiOn7AH0/97qEvkL1FJU0PSfAjImhcmOL93hlLTn5muTonHtthQKna+tBj3gUtvQyDnwPieGMPuwgn8IKrhBBH2lg3ugXGek8B8hkRbAE+ZsseSqpFQ76uT9EFJwTu0aUroUqUSB+SwXY0zPFdli9Tp1Yf0sELtdsrSX91sSHJ/nsaMGJeqrfPT9i84K0oji7os4fIfRywwrdg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=redhat.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FJJEpo6/ZROJHbJTLawterEZ5OhsQAaRnNa93pxuNC4=; b=Ys4FPkRfWsRVrDrEgWio04MxdMGM5/kU8TiTOCRCplnC/uo9IwWKIM3ZWL9PexVKx9Z55IWKkRU4krMO9dr7H68wy3oBAE3h47Qb+nXyG02MOvsLNpisqfTzr4LSeSi3GekVGulULtIjVSLl2f+FqJQGC0iKQfWTXqMztEhNSjgcHtmC87czfGye93R9tJBnxvhaOBXhf/LHqKbOfoz/4HQRE6QALnfRgFjnJ1jBDoYUXSEBe11q+xHEvGNUgjC43akoE98DCMaIhjFm2qd+kEpLx3ZFvEghSj2HPeztkcgjqsHP9Tdd6RSzmFUkr/NDDhpSt266ph1idOt+MX2Viw== Received: from SN7PR04CA0014.namprd04.prod.outlook.com (2603:10b6:806:f2::19) by DS0PR12MB6485.namprd12.prod.outlook.com (2603:10b6:8:c6::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.14; Fri, 9 Feb 2024 08:40:39 +0000 Received: from SN1PEPF0002BA52.namprd03.prod.outlook.com (2603:10b6:806:f2:cafe::d5) by SN7PR04CA0014.outlook.office365.com (2603:10b6:806:f2::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.44 via Frontend Transport; Fri, 9 Feb 2024 08:40:38 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by SN1PEPF0002BA52.mail.protection.outlook.com (10.167.242.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.19 via Frontend Transport; Fri, 9 Feb 2024 08:40:38 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Fri, 9 Feb 2024 00:40:19 -0800 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Fri, 9 Feb 2024 00:40:18 -0800 Received: from vdi.nvidia.com (10.127.8.14) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.1258.12 via Frontend Transport; Fri, 9 Feb 2024 00:40:17 -0800 From: Shravan Kumar Ramani To: Hans de Goede , Ilpo Jarvinen , Vadim Pasternak , "David Thompson" CC: Shravan Kumar Ramani , , Subject: [PATCH v2 4/4] platform/mellanox: mlxbf-pmc: Add support for clock_measure performance block Date: Fri, 9 Feb 2024 03:39:57 -0500 Message-ID: <891f85f39028753c8282436dc4d1efb2cb55eead.1707466888.git.shravankr@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002BA52:EE_|DS0PR12MB6485:EE_ X-MS-Office365-Filtering-Correlation-Id: 4d28f74b-6625-49e1-2ff2-08dc294acaee X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0P87XwFYfHFBNbnNhynYuAdPBk1wK4kbL7DjXVeqXbTV9IkMvhTwS6jAAjudu11PhzU1Kdk7nlmeCSl9l25l6RcF07YWc/dFZtejrh0gR/Bh+VIsiN3EAyWOMx2bgY+qmzgSgsFAAGwWmEcuKB8xnYsH4DQnLcs4NjZ+Yo65Z3qvY/Y7EgDqFRlNK+oBE4uCyR06meD8XqdGs1wOAa5cbsFec6aBSSPLwhdP+DhjwjgunT/ST0EcUVgjC4EsfLiGrA5oHi9PbBsRfWnVnCrHiX3Vwr9bH1F5ZLQBYe+4nHY0W0XUSx4Od+iJoiHrqvbuCkGK4qIqXXCdPwDogWF3FztG3EjIjDFABYHByTXRX65ocrS5uft8oNLTwg+4ZtZa7a9CZ9908xHr4q/XtuJpDiirjXqUcln8GfKWoKkzH6YJ8orE23Zu5PKNcG1AhYPyrC+9Vo3oYsJXs7OrV5ADL+gfMYjYg86y9f66l0d/ukc9Jy+LecH9oMDl7TUnNIZt92dI0PIydC/JpfyVSo7DgIZjBs0p6PqnXpWaL61wI5ZNUlxpcnLUDpYHHGCPJVkbBXpASRRsEX+yYelj+tkWfHMo9W/+dFMwRpkLXKaoJGs= X-Forefront-Antispam-Report: CIP:216.228.118.233;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge2.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(136003)(346002)(39860400002)(396003)(376002)(230922051799003)(451199024)(1800799012)(64100799003)(82310400011)(186009)(46966006)(40470700004)(36840700001)(82740400003)(7636003)(2616005)(83380400001)(2906002)(316002)(8936002)(6666004)(5660300002)(110136005)(7696005)(426003)(8676002)(336012)(4326008)(70586007)(70206006)(54906003)(6636002)(356005)(478600001)(26005)(36756003)(86362001)(41300700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2024 08:40:38.7287 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4d28f74b-6625-49e1-2ff2-08dc294acaee X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.233];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF0002BA52.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB6485 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790410726005626332 X-GMAIL-MSGID: 1790410726005626332 The HW clock_measure counter info is passed to the driver from ACPI. Create a new sub-directory for clock_measure events and provide read access to the user. Writes are blocked since the fields are RO. Signed-off-by: Shravan Kumar Ramani Reviewed-by: David Thompson Reviewed-by: Vadim Pasternak --- drivers/platform/mellanox/mlxbf-pmc.c | 46 ++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/drivers/platform/mellanox/mlxbf-pmc.c b/drivers/platform/mellanox/mlxbf-pmc.c index 1b9356a3ffab..565951c69a0f 100644 --- a/drivers/platform/mellanox/mlxbf-pmc.c +++ b/drivers/platform/mellanox/mlxbf-pmc.c @@ -865,6 +865,37 @@ static const struct mlxbf_pmc_events mlxbf_pmc_llt_miss_events[] = { {75, "HISTOGRAM_HISTOGRAM_BIN9"}, }; +static const struct mlxbf_pmc_events mlxbf_pmc_clock_events[] = { + { 0x0, "FMON_CLK_LAST_COUNT_PLL_D1_INST0" }, + { 0x4, "REFERENCE_WINDOW_WIDTH_PLL_D1_INST0" }, + { 0x8, "FMON_CLK_LAST_COUNT_PLL_D1_INST1" }, + { 0xc, "REFERENCE_WINDOW_WIDTH_PLL_D1_INST1" }, + { 0x10, "FMON_CLK_LAST_COUNT_PLL_G1" }, + { 0x14, "REFERENCE_WINDOW_WIDTH_PLL_G1" }, + { 0x18, "FMON_CLK_LAST_COUNT_PLL_W1" }, + { 0x1c, "REFERENCE_WINDOW_WIDTH_PLL_W1" }, + { 0x20, "FMON_CLK_LAST_COUNT_PLL_T1" }, + { 0x24, "REFERENCE_WINDOW_WIDTH_PLL_T1" }, + { 0x28, "FMON_CLK_LAST_COUNT_PLL_A0" }, + { 0x2c, "REFERENCE_WINDOW_WIDTH_PLL_A0" }, + { 0x30, "FMON_CLK_LAST_COUNT_PLL_C0" }, + { 0x34, "REFERENCE_WINDOW_WIDTH_PLL_C0" }, + { 0x38, "FMON_CLK_LAST_COUNT_PLL_N1" }, + { 0x3c, "REFERENCE_WINDOW_WIDTH_PLL_N1" }, + { 0x40, "FMON_CLK_LAST_COUNT_PLL_I1" }, + { 0x44, "REFERENCE_WINDOW_WIDTH_PLL_I1" }, + { 0x48, "FMON_CLK_LAST_COUNT_PLL_R1" }, + { 0x4c, "REFERENCE_WINDOW_WIDTH_PLL_R1" }, + { 0x50, "FMON_CLK_LAST_COUNT_PLL_P1" }, + { 0x54, "REFERENCE_WINDOW_WIDTH_PLL_P1" }, + { 0x58, "FMON_CLK_LAST_COUNT_REF_100_INST0" }, + { 0x5c, "REFERENCE_WINDOW_WIDTH_REF_100_INST0" }, + { 0x60, "FMON_CLK_LAST_COUNT_REF_100_INST1" }, + { 0x64, "REFERENCE_WINDOW_WIDTH_REF_100_INST1" }, + { 0x68, "FMON_CLK_LAST_COUNT_REF_156" }, + { 0x6c, "REFERENCE_WINDOW_WIDTH_REF_156" }, +}; + static struct mlxbf_pmc_context *pmc; /* UUID used to probe ATF service. */ @@ -1041,6 +1072,9 @@ static const struct mlxbf_pmc_events *mlxbf_pmc_event_list(const char *blk, } else if (strstr(blk, "llt")) { events = mlxbf_pmc_llt_events; *size = ARRAY_SIZE(mlxbf_pmc_llt_events); + } else if (strstr(blk, "clock_measure")) { + events = mlxbf_pmc_clock_events; + *size = ARRAY_SIZE(mlxbf_pmc_clock_events); } else { events = NULL; *size = 0; @@ -1474,14 +1508,15 @@ static int mlxbf_pmc_read_event(unsigned int blk_num, u32 cnt_num, bool is_l3, /* Method to read a register */ static int mlxbf_pmc_read_reg(unsigned int blk_num, u32 offset, u64 *result) { - u32 ecc_out; + u32 reg; - if (strstr(pmc->block_name[blk_num], "ecc")) { + if ((strstr(pmc->block_name[blk_num], "ecc")) || + (strstr(pmc->block_name[blk_num], "clock_measure"))) { if (mlxbf_pmc_readl(pmc->block[blk_num].mmio_base + offset, - &ecc_out)) + ®)) return -EFAULT; - *result = ecc_out; + *result = reg; return 0; } @@ -1495,6 +1530,9 @@ static int mlxbf_pmc_read_reg(unsigned int blk_num, u32 offset, u64 *result) /* Method to write to a register */ static int mlxbf_pmc_write_reg(unsigned int blk_num, u32 offset, u64 data) { + if (strstr(pmc->block_name[blk_num], "clock_measure")) + return -EINVAL; + if (strstr(pmc->block_name[blk_num], "ecc")) { return mlxbf_pmc_write(pmc->block[blk_num].mmio_base + offset, MLXBF_PMC_WRITE_REG_32, data);