From patchwork Wed Nov 29 06:57:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sibi Sankar X-Patchwork-Id: 171117 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a5a7:0:b0:403:3b70:6f57 with SMTP id d7csp162265vqn; Tue, 28 Nov 2023 22:58:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IHUxnb3xB9nwcNwKTclGBuvo/9QqNPxySLQw9mlG97zOjaBNlmmZDCwQmJRx+KdcRuGLJyl X-Received: by 2002:a9d:654d:0:b0:6d8:4d56:59cc with SMTP id q13-20020a9d654d000000b006d84d5659ccmr1737944otl.21.1701241115461; Tue, 28 Nov 2023 22:58:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701241115; cv=none; d=google.com; s=arc-20160816; b=gXKJoSrPDXNxjBK3Lai2DQNOmVNSaglNkmDbZHgVbXCoOUKrSggWgQRfnrq+UUVLfQ wQTZ5KmH7LCD3QUhZejb68V+3QTUaalM3J6nD3w4z5AJEH/zGkqZhDz9+/+xSeAyz+iK 3hISo8NIbTwaMpPRdphwinR+L702Y3oSDco0RF5OUyWE6hSsEANpGRUa8sAMyQTHZlY9 otFTmjjAJvanMrMQ3GjbWWqKtkRExRJ/wJGRW0INirdSX8iaiYETcl0FGSOl00b1hftb YgPQzNoGz+l9B7jWr0xDOpuV3prHIciDekvGvCxoyv0lZPF27IMVuLzLdq3TFzeVLfBq Aejw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=edLm9Ox96tmdmTQ7v//ClBc2NVL4CfyEXE85fW+2XjY=; fh=pfakrco4cTbVcMrPdGBTJE5nivepstmgBuFe4CJ65wE=; b=dDW8z142d+mN3vc/J4TcqrP8TOr5aEKTIAyPye086AIavflrP+m4RBz0N60TbZf7X2 oKPWt5D0CzVRUo9+VS3OVNoMRJj5ez+i458TCL5B5k4A37C86zy5vLSZSuNXjnE5oX/D xi1H2prPV71Dr+nKjA3O2W0n2cf7FdUY07YmsCOOzdysvLDJYr53uv3PDi+TSryXYIJW qcXc+gGfLU1n5y4Ur6pTIRxmepG3p+7vkhMQvD45xfbyw65eIGGyJtNVjcLw7CyUIFTZ NcWhw/1fZx99ufFguh5cjrhp9ZYHvpYW12xieeyyhC2xO0eLZxQP80Tg2rMS8ixgWDpC bjMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=OsEUTNsQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id a23-20020a630b57000000b005b929886d2bsi1140285pgl.138.2023.11.28.22.58.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 22:58:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=OsEUTNsQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 2EE2280A64FB; Tue, 28 Nov 2023 22:58:31 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232972AbjK2G6W (ORCPT + 99 others); Wed, 29 Nov 2023 01:58:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233130AbjK2G6S (ORCPT ); Wed, 29 Nov 2023 01:58:18 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A83681735; Tue, 28 Nov 2023 22:58:24 -0800 (PST) Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AT4q8BM009098; Wed, 29 Nov 2023 06:58:14 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=edLm9Ox96tmdmTQ7v//ClBc2NVL4CfyEXE85fW+2XjY=; b=OsEUTNsQ1X/aVlIBxYwqEGtREKpnXucZDcQ2nnu5fXRIpnihFc0Zbv53cieZAcxNiKY1 ch6wFRgbiFYq1wOICB7QQo6VNtQeI/B0mnBwYE1geHYkNDrn3xSzIwooINUGyE756x22 pUrXGL8gG//w9ZfJP8DqjtDrFlaylMgygcaki50JpXkF/gQE2mO9TbGxMS/AWo8RJQKp 5PBPFd04KLj3rZgIgVyLzPyJB1MN9icMbt3gdpvDWEBkVszNDMhFZY1w7dNQPMq3VjMw LBxEZbwhRM744Pkqy1q0mSf+vPQS5C+QyzX7ddf+CD8oVuJFOzn4fNEAueW1v28+T0eZ lw== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3unje1a2h2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Nov 2023 06:58:13 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3AT6wDaa020862 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Nov 2023 06:58:13 GMT Received: from blr-ubuntu-253.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Tue, 28 Nov 2023 22:58:10 -0800 From: Sibi Sankar To: , CC: , , , , , , Sibi Sankar Subject: [PATCH 1/3] firmware: arm_scmi: Fix null pointer dereference during fastchannel init Date: Wed, 29 Nov 2023 12:27:46 +0530 Message-ID: <20231129065748.19871-2-quic_sibis@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20231129065748.19871-1-quic_sibis@quicinc.com> References: <20231129065748.19871-1-quic_sibis@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: jSzMxAy31XFdUcrRMgglGV8GLxPqBZFx X-Proofpoint-ORIG-GUID: jSzMxAy31XFdUcrRMgglGV8GLxPqBZFx X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-29_03,2023-11-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 spamscore=0 phishscore=0 adultscore=0 priorityscore=1501 bulkscore=0 clxscore=1015 mlxscore=0 mlxlogscore=999 suspectscore=0 malwarescore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311290049 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,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 fry.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 (fry.vger.email [0.0.0.0]); Tue, 28 Nov 2023 22:58:31 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783880603554846446 X-GMAIL-MSGID: 1783880603554846446 The scmi_perf_domain_lookup requires the protocol handle to have the private data set, which is yet to happen during the fastchannel init scenario. This results in a null pointer dereference. Fix this by using the pre-populated perf_dom_info to pass on the required information instead. Call trace: scmi_perf_protocol_init+0x434/0x678 scmi_get_protocol_instance+0x168/0x29c scmi_devres_protocol_instance_get+0x50/0xa0 scmi_devm_protocol_get+0x20/0x50 scmi_cpufreq_probe+0x34/0xd4 scmi_dev_probe+0x28/0x3c really_probe+0x148/0x2ac __driver_probe_device+0x78/0x12c driver_probe_device+0x40/0x160 __device_attach_driver+0xb8/0x134 bus_for_each_drv+0x80/0xdc __device_attach+0xa8/0x1b0 device_initial_probe+0x14/0x20 bus_probe_device+0xa8/0xac device_add+0x5cc/0x778 device_register+0x20/0x30 __scmi_device_create.part.0+0xec/0x1cc scmi_device_create+0x180/0x1c4 scmi_create_protocol_devices+0x4c/0xb0 scmi_probe+0x660/0x738 platform_probe+0x68/0xdc really_probe+0x148/0x2ac __driver_probe_device+0x78/0x12c driver_probe_device+0x40/0x160 __device_attach_driver+0xb8/0x134 bus_for_each_drv+0x80/0xdc __device_attach+0xa8/0x1b0 device_initial_probe+0x14/0x20 bus_probe_device+0xa8/0xac deferred_probe_work_func+0x88/0xc0 process_one_work+0x13c/0x264 worker_thread+0x32c/0x438 kthread+0x118/0x11c ret_from_fork+0x10/0x20 Fixes: 619bc6e034f3 ("firmware: arm_scmi: Populate fastchannel info only if set operations are allowed") Signed-off-by: Sibi Sankar --- drivers/firmware/arm_scmi/perf.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/drivers/firmware/arm_scmi/perf.c b/drivers/firmware/arm_scmi/perf.c index d1323c5d9c27..a648521e04a3 100644 --- a/drivers/firmware/arm_scmi/perf.c +++ b/drivers/firmware/arm_scmi/perf.c @@ -759,40 +759,35 @@ static int scmi_perf_level_limits_notify(const struct scmi_protocol_handle *ph, } static void scmi_perf_domain_init_fc(const struct scmi_protocol_handle *ph, - u32 domain, struct scmi_fc_info **p_fc) + struct perf_dom_info *dom) { struct scmi_fc_info *fc; - struct perf_dom_info *dom; - - dom = scmi_perf_domain_lookup(ph, domain); - if (IS_ERR(dom)) - return; fc = devm_kcalloc(ph->dev, PERF_FC_MAX, sizeof(*fc), GFP_KERNEL); if (!fc) return; ph->hops->fastchannel_init(ph, PERF_DESCRIBE_FASTCHANNEL, - PERF_LEVEL_GET, 4, domain, + PERF_LEVEL_GET, 4, dom->id, &fc[PERF_FC_LEVEL].get_addr, NULL); ph->hops->fastchannel_init(ph, PERF_DESCRIBE_FASTCHANNEL, - PERF_LIMITS_GET, 8, domain, + PERF_LIMITS_GET, 8, dom->id, &fc[PERF_FC_LIMIT].get_addr, NULL); if (dom->info.set_perf) ph->hops->fastchannel_init(ph, PERF_DESCRIBE_FASTCHANNEL, - PERF_LEVEL_SET, 4, domain, + PERF_LEVEL_SET, 4, dom->id, &fc[PERF_FC_LEVEL].set_addr, &fc[PERF_FC_LEVEL].set_db); if (dom->set_limits) ph->hops->fastchannel_init(ph, PERF_DESCRIBE_FASTCHANNEL, - PERF_LIMITS_SET, 8, domain, + PERF_LIMITS_SET, 8, dom->id, &fc[PERF_FC_LIMIT].set_addr, &fc[PERF_FC_LIMIT].set_db); - *p_fc = fc; + dom->fc_info = fc; } static int scmi_dvfs_device_opps_add(const struct scmi_protocol_handle *ph, @@ -1102,7 +1097,7 @@ static int scmi_perf_protocol_init(const struct scmi_protocol_handle *ph) scmi_perf_describe_levels_get(ph, dom, version); if (dom->perf_fastchannels) - scmi_perf_domain_init_fc(ph, dom->id, &dom->fc_info); + scmi_perf_domain_init_fc(ph, dom); } ret = devm_add_action_or_reset(ph->dev, scmi_perf_xa_destroy, pinfo); From patchwork Wed Nov 29 06:57:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sibi Sankar X-Patchwork-Id: 171116 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a5a7:0:b0:403:3b70:6f57 with SMTP id d7csp162263vqn; Tue, 28 Nov 2023 22:58:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IFYo9epFKD0XARLWnSkFCilakFRAkYQWf2Q2rBnwkIzjx8v8rMqa/XhEDQNRerLi7U85Sk1 X-Received: by 2002:a05:6a00:2e08:b0:6be:5367:2131 with SMTP id fc8-20020a056a002e0800b006be53672131mr18037046pfb.24.1701241115014; Tue, 28 Nov 2023 22:58:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701241114; cv=none; d=google.com; s=arc-20160816; b=N7byayGXVtHHfMYqL5u77asn5UAj24w1YrTT1yRLlPKOe39hAWD5FUyYsx/YuGU0RI Ah01s76oeTbELil32C8bp/i5H2KylrEFm8a+NnMRV99phRTDvIplSD4V841QnkTwFgBs tTnCjbQDRo3Tc7T6q7ZhDCKVCSV/5zhx8OXuZK0LiDH90iQDs8AtDs3Xn83yUWT8EuTI Tnkp9HyInOBzl9CvqkV5U5p24SRiKJwyBIg/UDZYEIqsjo+EsSQpqiawbfRqO/Uu7VoC IQZ1xK3D9gNxDgu4TffxZWgBnhBLTZUYLyf0+CjzIPhH7HCIt4PUPG7lDO9lvB26aQh0 ep9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=qGDZyLkSoHtcMnsZPlA3sOSXl2/82Oeo64ZLTh+FD5o=; fh=pfakrco4cTbVcMrPdGBTJE5nivepstmgBuFe4CJ65wE=; b=sKbjPOYOrBu3lgAbxDApaw2sjZds1+c+EKFnThc+0Ox7+70TavCkJWvpEtO7c8Dfh4 pCi+EBdMQgdRs8UA6fsqE/PrifLLG7Gna5imAoyIO69qM+rwL2YxiqFFWkmezpeq+oiJ asaniJCD7g1pyRZ8MTqLb+cWRRbHUDayxk7Fn+2tGFp1BYAaYqCLdCgTGWQpjiS0ii3r AIGtRiWJQ1aT8jFCmBwsqaZ6I1cSzNXiwEDc+o/iSPV6ZTht83RRmAkWwvMLQRliYbXg 9XkU5+rM7QDb3hOk3av/TTI5ffcG/rixu/wB6I4qtXXffJInLJ5KD9pGoxRe6r7HlSnK eWrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=EmjoSRZG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id 37-20020a630f65000000b005b8ea4a4ab6si14082175pgp.623.2023.11.28.22.58.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 22:58:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=EmjoSRZG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id D4F918051A3E; Tue, 28 Nov 2023 22:58:29 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233148AbjK2G6T (ORCPT + 99 others); Wed, 29 Nov 2023 01:58:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229532AbjK2G6Q (ORCPT ); Wed, 29 Nov 2023 01:58:16 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8B7319AB; Tue, 28 Nov 2023 22:58:22 -0800 (PST) Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AT4DS6n009415; Wed, 29 Nov 2023 06:58:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=qGDZyLkSoHtcMnsZPlA3sOSXl2/82Oeo64ZLTh+FD5o=; b=EmjoSRZG3kb8A6fRCw1WqHZ0g/Dt9pmOJx1O3jZXfQQNdQuTqwCua0D5qOlFYRhMUhY8 j0mGvzZt+gJbnfZiAvedTy1y0NaMrSv70+fHR/8+9WikaWlA3wXhMBP09N0IqXaaL7vy Vq1GvEeOqNtKGRdID7yfq9dYHzOuxnwYlfBFFKKwIzJx/DKyZGpwp1WwuRIGQAKA7TZG PihhZENtuLhVWHySJ+RYr6FRmQe5n/vsgOwtv2vouLOF2H6siHR56NBPmRs6fRIwiJyI 8XGFt5oqOfQLRZN1TV+beY016u/IuEYmWGp9GgPyrU6NxyfXScycibBgJx+Uy+1weG0G aw== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3unjdtj37b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Nov 2023 06:58:17 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3AT6wG1T027258 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Nov 2023 06:58:16 GMT Received: from blr-ubuntu-253.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Tue, 28 Nov 2023 22:58:13 -0800 From: Sibi Sankar To: , CC: , , , , , , Sibi Sankar Subject: [PATCH 2/3] firmware: arm_scmi: Fix freq/power truncation in the perf protocol Date: Wed, 29 Nov 2023 12:27:47 +0530 Message-ID: <20231129065748.19871-3-quic_sibis@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20231129065748.19871-1-quic_sibis@quicinc.com> References: <20231129065748.19871-1-quic_sibis@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: Ai59dcvVBLIw8QsbmAkP_tBPyjQWr3r4 X-Proofpoint-ORIG-GUID: Ai59dcvVBLIw8QsbmAkP_tBPyjQWr3r4 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-29_03,2023-11-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 lowpriorityscore=0 suspectscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 impostorscore=0 priorityscore=1501 clxscore=1015 malwarescore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311290049 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,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 fry.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 (fry.vger.email [0.0.0.0]); Tue, 28 Nov 2023 22:58:30 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783880603504946995 X-GMAIL-MSGID: 1783880603504946995 Fix frequency and power truncation seen in the performance protocol by casting it with the correct type. Fixes: a9e3fbfaa0ff ("firmware: arm_scmi: add initial support for performance protocol") Signed-off-by: Sibi Sankar --- drivers/firmware/arm_scmi/perf.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/firmware/arm_scmi/perf.c b/drivers/firmware/arm_scmi/perf.c index a648521e04a3..3344ce3a2026 100644 --- a/drivers/firmware/arm_scmi/perf.c +++ b/drivers/firmware/arm_scmi/perf.c @@ -804,9 +804,9 @@ static int scmi_dvfs_device_opps_add(const struct scmi_protocol_handle *ph, for (idx = 0; idx < dom->opp_count; idx++) { if (!dom->level_indexing_mode) - freq = dom->opp[idx].perf * dom->mult_factor; + freq = (unsigned long)dom->opp[idx].perf * dom->mult_factor; else - freq = dom->opp[idx].indicative_freq * 1000; + freq = (unsigned long)dom->opp[idx].indicative_freq * 1000; data.level = dom->opp[idx].perf; data.freq = freq; @@ -879,7 +879,7 @@ static int scmi_dvfs_freq_get(const struct scmi_protocol_handle *ph, u32 domain, return ret; if (!dom->level_indexing_mode) { - *freq = level * dom->mult_factor; + *freq = (unsigned long)level * dom->mult_factor; } else { struct scmi_opp *opp; @@ -887,7 +887,7 @@ static int scmi_dvfs_freq_get(const struct scmi_protocol_handle *ph, u32 domain, if (!opp) return -EIO; - *freq = opp->indicative_freq * 1000; + *freq = (unsigned long)opp->indicative_freq * 1000; } return ret; @@ -908,9 +908,9 @@ static int scmi_dvfs_est_power_get(const struct scmi_protocol_handle *ph, for (opp = dom->opp, idx = 0; idx < dom->opp_count; idx++, opp++) { if (!dom->level_indexing_mode) - opp_freq = opp->perf * dom->mult_factor; + opp_freq = (unsigned long)opp->perf * dom->mult_factor; else - opp_freq = opp->indicative_freq * 1000; + opp_freq = (unsigned long)opp->indicative_freq * 1000; if (opp_freq < *freq) continue; From patchwork Wed Nov 29 06:57:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sibi Sankar X-Patchwork-Id: 171118 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a5a7:0:b0:403:3b70:6f57 with SMTP id d7csp162287vqn; Tue, 28 Nov 2023 22:58:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IHbamv5sCXbbkCGxtPNvPVrZbI0y2qSuhWw3pmIXOOTCtTRYqp8P8H2l0bUX9cc75vC+4jm X-Received: by 2002:a05:6a00:3989:b0:693:3d55:2bb3 with SMTP id fi9-20020a056a00398900b006933d552bb3mr18448436pfb.26.1701241121185; Tue, 28 Nov 2023 22:58:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701241121; cv=none; d=google.com; s=arc-20160816; b=GmCR2LRTzTe4ztmFEUorklo5Ppg/MqR0PvelVKUuV0NbR5ltVqIL/M07z2FHZdOgUV SSOAdGDmZRYaS/FC/hYR3thCTXhUsA23gRmQgOk93RUoWt24pJENfDEvgaHKsARzyHw8 zPjnF1SReLYQqfALNTY99InsGoT2qR2BuZ63wIIoBIHMKD/6ip1g1pGmf0W02Z0PZudm amtQBVC/ZWgpomRcEgn1uojgp2QSCymzwDJK9tkkiZ1OCbOac05ovAhG3r3P/L33h5jJ Pz7HUek45LXL/dkjw4rQdHsD8qq7PJjoyy8+8RzSctjnhZj2S5v+mH1mxScGpzJuppOO EclA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=LsICOZfGK90sPM4D4fqzedjtuDu0jx2XyVM/Kw8raRE=; fh=pfakrco4cTbVcMrPdGBTJE5nivepstmgBuFe4CJ65wE=; b=gjNQ+9zSvYDT2ltMLa54RfVLj72naXBCDEqE9/TS6saAEQXi0E2RR+i+7MVfIec9FN enbxyIUAC1cmdcuCGRk3CwFF/5j2/JZu1LPnSTD8fsjlAkFmJzMRtwczz9bjwP4R2ruY gYO4gkQnFC4+2Hwj1pFMHhODyTjUa19LcBJKUJ/5ctbD/yZKqUPj6Pt6Ge3xLLPTGnL8 RcX/Baqmi+prC1S4khwbYRgzVPHzfRJJpEHKrmjs9TxNDFIkV+4TJbhdy6DEAO/gQUM0 +dEvaWj4J+i4ZjQ2qvCLDVcvKIjXa2c6aRgEpRipp57rJ0W7IQAcCJBWV2kWoSJLa+LE emBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="jZBN/Jzj"; 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=quicinc.com Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id d10-20020a65424a000000b005c278210f82si13644216pgq.544.2023.11.28.22.58.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 22:58:41 -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=@quicinc.com header.s=qcppdkim1 header.b="jZBN/Jzj"; 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=quicinc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 3969E8326580; Tue, 28 Nov 2023 22:58:35 -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 S233691AbjK2G6Y (ORCPT + 99 others); Wed, 29 Nov 2023 01:58:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231393AbjK2G6T (ORCPT ); Wed, 29 Nov 2023 01:58:19 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA90119A6; Tue, 28 Nov 2023 22:58:25 -0800 (PST) Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3ASNSLx9025752; Wed, 29 Nov 2023 06:58:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=LsICOZfGK90sPM4D4fqzedjtuDu0jx2XyVM/Kw8raRE=; b=jZBN/JzjtUulhYeuqNV//7MAOyI6Ur5aSWpcUDlbMnJEbWHlBKXryeZgqd7JNwkPoKfN EvWsNbfC5S3QJdIE4tY4iF6no/jGK6/fbnidZF3aH3ufn27Xrjwr7jk79L49UUCbH7fy No+l8fjgTXZQiPm/T/kQHQImIdWExSwqj4YxrrhBzzKeoeoKqeE0tD2+L+1GUB/mtkrK 1iFFHNe0fs90XwITRZubX+gM2QG7W5jI5uBukKImpHfICLDHNTwS6+7pc7URv6kLnIoO aMbDpp3tj1mHTR9shw/ml9JhhtE6PJdrMOnliXyXjOredhAcwaSRvDUg0TzJybmh9I5b UA== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3unnpese8c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Nov 2023 06:58:21 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3AT6wKsR020954 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Nov 2023 06:58:20 GMT Received: from blr-ubuntu-253.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Tue, 28 Nov 2023 22:58:16 -0800 From: Sibi Sankar To: , CC: , , , , , , Sibi Sankar Subject: [PATCH 3/3] firmware: arm_scmi: Increase the maximum opp count Date: Wed, 29 Nov 2023 12:27:48 +0530 Message-ID: <20231129065748.19871-4-quic_sibis@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20231129065748.19871-1-quic_sibis@quicinc.com> References: <20231129065748.19871-1-quic_sibis@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: AR6n_PD1s-LLN0Fb8fWTsRCyat1A1kzT X-Proofpoint-ORIG-GUID: AR6n_PD1s-LLN0Fb8fWTsRCyat1A1kzT X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-29_03,2023-11-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 impostorscore=0 mlxscore=0 phishscore=0 mlxlogscore=793 priorityscore=1501 adultscore=0 clxscore=1015 bulkscore=0 malwarescore=0 suspectscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311290049 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,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]); Tue, 28 Nov 2023 22:58:35 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783880609644370449 X-GMAIL-MSGID: 1783880609644370449 The number of opps on certain variants of the X1E80100 SoC are greater than current maximum, so increase the MAX_OPP count to the next log level to accommodate that. Signed-off-by: Sibi Sankar --- drivers/firmware/arm_scmi/perf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/firmware/arm_scmi/perf.c b/drivers/firmware/arm_scmi/perf.c index 3344ce3a2026..edf34a3c4d6a 100644 --- a/drivers/firmware/arm_scmi/perf.c +++ b/drivers/firmware/arm_scmi/perf.c @@ -24,7 +24,7 @@ #include "protocols.h" #include "notify.h" -#define MAX_OPPS 16 +#define MAX_OPPS 24 enum scmi_performance_protocol_cmd { PERF_DOMAIN_ATTRIBUTES = 0x3,