From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 662401E633C for ; Sun, 25 May 2025 08:56:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748163374; cv=none; b=jYAcuCiYnl2gCgyODNDUd3M1TB5iNDuFcBMyPYKm5VnV7UbBAdQh51oX1uN+CXdQ8KrtA0bOmeFffsLNFaWCwPNQwFWULme9S2E3U3kvOaaiQTUuSs3sH3DwOzZMPmSZlD8P8z6ZSzKoo5Op32+zWfajxHI24goI1ByzZsIhvpo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748163374; c=relaxed/simple; bh=AVtU54nc25opv8K+2tymcPJdIsSp8GMt9cZa3TIf5Xw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QGwlj9if4/N5t9E7ooFvWG+l9apUbLZdnvxT/RstuXUUEcLQ9v7DBaQwfFY2RJJXfsv8c0VhdMEH/8kibiFmBTS9mlTlnSi+hOhJVe61A4iCDmKTHicqLjmNfo50a+RD5ar4e3axbuoRuDyVUdjJD4cBPeaxMk3SPY02U9gx1WM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=MjkCu8CT; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="MjkCu8CT" Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 54P6eDIY023240 for ; Sun, 25 May 2025 08:56:12 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= JkOp7j3zXSAkYXiIHN6jRO+1RgVkkoDu+mIC7by/Wuk=; b=MjkCu8CTGBoEs2Ia laFNUmxpzwI6BGeIifZ0o+yQi2RT/PV4hl6JVa/Va+rgzyJnWjC+7J4kUPokK8lh A6eZHGx5Vu5MKJqzwAtssljHrXBEJJjqrAuY3/KTGtPpyvEJgtoPFoESYKVMufdb PkXjWVEY8rIFAQwjdFSkG9UsGp5Y1bxKBLJEpwLAeAQmZh87Vy/dD4rvSjdM3PFQ IiHJvj7+LYV9VdW1V6Zuxqj4+YeObTe6uzgsWAayJ7VntiJwWCVkQNUFebP8F5Ty AedmrH1WTxVHh3e14hxQ+aGwOR9ZrgVFegVHhoqJuRAXfBhEOTrfVDyl/X4MHqsA xIWMVg== Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 46u52usv6d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Sun, 25 May 2025 08:56:12 +0000 (GMT) Received: by mail-pl1-f200.google.com with SMTP id d9443c01a7336-2344f88f9easo1204065ad.3 for ; Sun, 25 May 2025 01:56:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748163371; x=1748768171; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JkOp7j3zXSAkYXiIHN6jRO+1RgVkkoDu+mIC7by/Wuk=; b=PkJFu/rPvX7dmJB7iHZuTAIm1uL8bTK+BEAXXMYVeIi3u64ImpjCb0lRSFX7W8SBrJ l2kpeuJ4Yn40ChGeyyhdkdlNirxB3N/gVA4FaDqYG/NK49CCZ26kPQ1HqfD0Gw8O4RGA uj6UZmEjO1C2wAjVH6vAdfVF012v6ooDA8KdGHJEY45L4au3KxO0r1hKqS+47pCwCDo4 cxkbJtou7VTjtB9IT8Q1k3S3wNK/SP1AgOcjDYKD4c7uPklTRkDAR9e/+I2W3n8ylE71 8JYXUee4SE5WN1YTe0cXQcgAkJUKcr1IkjvZqF2Gd1MC17CN22BMFJnIB2ZY15q8zaLm UcCw== X-Forwarded-Encrypted: i=1; AJvYcCVtIJPY/wK/r2XJKAJRenGV5fVM8StnepoMhMeMDUhPTIG+4RSuHYI0oDmLlM0EzvjRKXtzHo80Pw3U@vger.kernel.org X-Gm-Message-State: AOJu0YwAh50wVAqSKNd5rFiyeCf/f90/aZydq2HwwYvNOHoHQ1RyWApz NKBlYn6Zr3k94reUr+fNVJS1Kauj+ECwBSjO593jpoO04r3CXdeNbbjPEG5YR2HGGCpugeHrBwX p+/tb4W2f5wjg++PhBuNW0nsGfMpxDXQ9b2G0zPCPK3WHKIOh6Xw/MZIEGlD3rkYM X-Gm-Gg: ASbGncs9KgV32UGb7A70sXByFX+Y7fKDYykifzkJCVtL5OCSv5qcwSxoepLaqQLD9kM P2OW3CS7X3TtKMjAZtSqAadsUg7ajEOPowQSbPwW96WFsxRLHUt+x0a+QMev4ZycKAFdfKvBW0X L1D0kWafWGk0Ww54r8qi2XDweF0Zf9805TyJAJR4iYGjPqhdrNDKcIleOJx+gQVi51hpF3aKEn5 c6vMcGrxCaGqqmECBPrQny6FAhxQtoIKSWmWDNiQW0BiI2MnVBdHdcEdrhyZY53yRFA6GXB9MnP f0VyN/Wn3bct8Eu9oexhi1zHdg== X-Received: by 2002:a17:902:cf4b:b0:224:584:6eef with SMTP id d9443c01a7336-23414fb5404mr86308945ad.41.1748163371224; Sun, 25 May 2025 01:56:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHqKEWMFK6USrz4We9Zy7uWd2Rz+ButRLFAqNJb1eOogDF7vmSPsDwTFWhh8Rhw0hDm6BUntA== X-Received: by 2002:a17:902:cf4b:b0:224:584:6eef with SMTP id d9443c01a7336-23414fb5404mr86308765ad.41.1748163370834; Sun, 25 May 2025 01:56:10 -0700 (PDT) Received: from [10.213.103.17] ([202.46.23.25]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2340531be85sm29609805ad.104.2025.05.25.01.56.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 May 2025 01:56:10 -0700 (PDT) From: Maulik Shah Date: Sun, 25 May 2025 14:25:58 +0530 Subject: [PATCH v3 2/3] soc: qcom: qcom_stats: Add QMP support for syncing ddr stats Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20250525-ddr_stats_-v3-2-49a3c1e42db7@oss.qualcomm.com> References: <20250525-ddr_stats_-v3-0-49a3c1e42db7@oss.qualcomm.com> In-Reply-To: <20250525-ddr_stats_-v3-0-49a3c1e42db7@oss.qualcomm.com> To: Bjorn Andersson , Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Marijn Suijten , Doug Anderson , Maulik Shah X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1748163360; l=2878; i=maulik.shah@oss.qualcomm.com; s=20240109; h=from:subject:message-id; bh=AVtU54nc25opv8K+2tymcPJdIsSp8GMt9cZa3TIf5Xw=; b=3c7v81qedwuXioo4vYTXsR3wF4NVJMeZRwj26wnGGbr7w9rxRDIyNbC+T/fUJzrH9ez9Ncm6P lMySkzEof6YAKl0XB7NmY3PiYG1WPyYjh7H7uhBIRf0BrrLC+q19DzV X-Developer-Key: i=maulik.shah@oss.qualcomm.com; a=ed25519; pk=bd9h5FIIliUddIk8p3BlQWBlzKEQ/YW5V+fe759hTWQ= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTI1MDA4MSBTYWx0ZWRfXwkAg1mSR+d2K xA8N7bruEcm4RkVDrdAGQduzwYXxC07105cxDakkKPsDT9ukOCCyiPDYWY/3u9yBMo+z3ulxnxs PKdESrReVbYWAo15KXzVgzFoLEmMBsLCQ+BBGC3Quc8TtNIdBU+3n41P9UjQyByCfjlTJ4xLuDN Jh4SAJfDi426e/Vqn5W8Wa5baHPSTKMci54Mx1RKnk2nTNmnDZuxmYo7fJ2QSE8Duw8MdmP8vlg Yr96lwUHVwxVBf4kzWJ36HlhoGL1p9Nirhlk8/fR0At1bTVIqLLu5Jts7cZaVljFfvYWJ+/1xGW /ov9S6geDEIUue74X1nsSrLvQnesA+yfHK0DaLyHfzbSRgMQZeRsnsxHZsZ+Mbk1BsFYjcEiQq5 D1zVnJ+UU8HCHOM4UgsDucg8wGt1oREUylX7vQVV5maoP0qGpNDV7WZBRlFttzjG491jCwMr X-Authority-Analysis: v=2.4 cv=f/5IBPyM c=1 sm=1 tr=0 ts=6832db2c cx=c_pps a=IZJwPbhc+fLeJZngyXXI0A==:117 a=ZePRamnt/+rB5gQjfz0u9A==:17 a=IkcTkHD0fZMA:10 a=dt9VzEwgFbYA:10 a=EUspDBNiAAAA:8 a=BT90xxDHZu-g9S-RVkkA:9 a=QEXdDO2ut3YA:10 a=uG9DUKGECoFWVXl0Dc02:22 X-Proofpoint-ORIG-GUID: ruFd0ySOoE1mCHnYd3R8yoAsNehDy-GW X-Proofpoint-GUID: ruFd0ySOoE1mCHnYd3R8yoAsNehDy-GW X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.0.736,FMLib:17.12.80.40 definitions=2025-05-25_03,2025-05-22_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 adultscore=0 impostorscore=0 suspectscore=0 mlxlogscore=999 spamscore=0 clxscore=1015 phishscore=0 bulkscore=0 lowpriorityscore=0 priorityscore=1501 malwarescore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505160000 definitions=main-2505250081 Recent SoCs (SM8450 onwards) require QMP command to be sent before reading ddr stats. The duration field of ddr stats will get populated only if QMP command is sent. Add support to send ddr stats freqsync QMP command. Signed-off-by: Maulik Shah --- drivers/soc/qcom/qcom_stats.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/drivers/soc/qcom/qcom_stats.c b/drivers/soc/qcom/qcom_stats.c index 33fd2a1574464768bd07289e743fbb79ba415e84..7795f0bd18c63adeee93da2b9e07ab4944c1662d 100644 --- a/drivers/soc/qcom/qcom_stats.c +++ b/drivers/soc/qcom/qcom_stats.c @@ -13,6 +13,7 @@ #include #include +#include #include #include @@ -37,6 +38,8 @@ #define DDR_STATS_TYPE(data) FIELD_GET(GENMASK(15, 8), data) #define DDR_STATS_FREQ(data) FIELD_GET(GENMASK(31, 16), data) +static struct qmp *qcom_stats_qmp; + struct subsystem_data { const char *name; u32 smem_item; @@ -188,12 +191,28 @@ static int qcom_ddr_stats_show(struct seq_file *s, void *d) struct ddr_stats_entry data[DDR_STATS_MAX_NUM_MODES]; void __iomem *reg = (void __iomem *)s->private; u32 entry_count; - int i; + int i, ret; entry_count = readl_relaxed(reg + DDR_STATS_NUM_MODES_ADDR); if (entry_count > DDR_STATS_MAX_NUM_MODES) return -EINVAL; + if (qcom_stats_qmp) { + /* + * Recent SoCs (SM8450 onwards) do not have duration field + * populated from boot up onwards for both DDR LPM Stats + * and DDR Frequency Stats. + * + * Send QMP message to Always on processor which will + * populate duration field into MSG RAM area. + * + * Sent every time to read latest data. + */ + ret = qmp_send(qcom_stats_qmp, "{class: ddr, action: freqsync}"); + if (ret) + return ret; + } + reg += DDR_STATS_ENTRY_START_ADDR; memcpy_fromio(data, reg, sizeof(struct ddr_stats_entry) * entry_count); @@ -310,6 +329,19 @@ static int qcom_stats_probe(struct platform_device *pdev) qcom_create_subsystem_stat_files(root, config); qcom_create_soc_sleep_stat_files(root, reg, d, config); qcom_create_ddr_stat_files(root, reg, config); + /* + * QMP is used for DDR stats syncing to MSG RAM for recent SoCs (SM8450 onwards). + * The prior SoCs do not need QMP handle as the required stats are already present + * in MSG RAM, provided the DDR_STATS_MAGIC_KEY matches. + */ + qcom_stats_qmp = qmp_get(&pdev->dev); + if (IS_ERR(qcom_stats_qmp)) { + if (PTR_ERR(qcom_stats_qmp) == -EPROBE_DEFER) + return -EPROBE_DEFER; + + /* We assume any other error means it's not defined/needed */ + qcom_stats_qmp = NULL; + } platform_set_drvdata(pdev, root); -- 2.34.1