From patchwork Mon Jul 31 04:10:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 128345 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp1812395vqg; Sun, 30 Jul 2023 22:37:10 -0700 (PDT) X-Google-Smtp-Source: APBJJlEhAnT1FaKK92PFh187s9IDzQ3tlMAErAdpzN/vdbsl9pSf7Qpq5aeqPXtav+bd8rprx2bP X-Received: by 2002:a17:902:ed8c:b0:1b8:28f6:20e6 with SMTP id e12-20020a170902ed8c00b001b828f620e6mr7756014plj.34.1690781830113; Sun, 30 Jul 2023 22:37:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690781830; cv=none; d=google.com; s=arc-20160816; b=YUDs7Dm7JWUaalROX6YdrGJUMUa7bf3ec0jNxv/qjzPHNNQ4Rfb25y1UGqUftaKPs3 kSRkzDOabed7+Fk7lsSi+JCMVir40z8Vr5deik6nyLraAidBAadX2zZIGyt6o1ojF4zi gTp7McZ7DcwZ3bp/TJWI16+BgEGBU48dlmCOkLt+C/K7Rl98Jdd1+I04AlVDKLdjbJVt awmoq6euZgMQXBofNs+mn+cx2nPzgBk6P1Jh/X7uLbXQFzDi102Su9JkYnYXIyXqRIFv SBMCvvpnrKAQw8KRrYnJrx0FM+5O4f+NsUglFoGTdKvgF7VRJ6zdRntr79pc8imBBVuI v6/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kgenKl9freS+5VlM47boO9w9nJXcjiucfx9ioDXfiDw=; fh=rCBE8/kXWBaCp7P5CIBGqD11Aa0ik5RvwLHhauCkNFk=; b=ydoXzkWY8CE32wnkVHPPi4ua6q37SKWid3iBMSIJUhnrumkwxneRi75jC7R/uBMLgp YFVYPW+yJu32CLfCe+Dm9P7xJZ9Msm8wEYMuTNIkv42ymvVD9G7x9M9ePpH+YTGYDozx EDI5Gk8BXGIGRLqnWp78i9FNZ8hbytdynjJap42DRwJuCdEt+IuPR77H0gY3uflcEuuN VIYKMwBXPXYNjB1l9pACbSaHrWb1u5bM4B0OQ7UHGjzT9NkNT2ROLseqYtkU8ERowIQ6 cDPwftDh1SU5mvbetPT54GoUTlBkKdYqskcAXKQBLL6eMlCMjaCxU9ju+UrzDovVVq1J cDwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=d8Y+Ctly; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kl5-20020a170903074500b001b895a2c09esi6496989plb.381.2023.07.30.22.36.52; Sun, 30 Jul 2023 22:37:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=d8Y+Ctly; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229900AbjGaEKk (ORCPT + 99 others); Mon, 31 Jul 2023 00:10:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229552AbjGaEKf (ORCPT ); Mon, 31 Jul 2023 00:10:35 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A1491B7; Sun, 30 Jul 2023 21:10:30 -0700 (PDT) Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36V3v45n026768; Mon, 31 Jul 2023 04:10: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-transfer-encoding : content-type; s=qcppdkim1; bh=kgenKl9freS+5VlM47boO9w9nJXcjiucfx9ioDXfiDw=; b=d8Y+CtlyeLzriVNs2Mo5nqqPt2mJgLzyrvldl4ES9Tg71YC8RGOuLFphngc4hvZ+wWZA ID0p3NU8SAZIudIMZpCnK0j65ZJonVd5vcchbtiyWJUEEGr6A1Y0/v0m9e/p9NpyiFWU xHKPY/9TQVI1UU7r8gyToMS/+0pYZjWLz49YEfVNy9iw8hvJa201wVfuWaT005IZOm0F PtSrC/up4Fnnk13wv2iK5AISUpxtqN1/Sa0PaES1sNHt9fdD5qGnfIC3PXUNk+quFv+2 GKl4eKp7+p1taqDdK+KARLTGSktJiUizk3wDp2eXt050dZB1AXudxqA599JDFp2xz3Qp Mw== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3s4ueujk8y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 31 Jul 2023 04:10:20 +0000 Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 36V4AJxV002499 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 31 Jul 2023 04:10:19 GMT Received: from hu-bjorande-lv.qualcomm.com (10.49.16.6) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Sun, 30 Jul 2023 21:10:19 -0700 From: Bjorn Andersson To: Bjorn Andersson , Konrad Dybcio , Chris Lew CC: Alex Elder , "David S. Miller" , Jakub Kicinski , Mathieu Poirier , , , , Subject: [PATCH 1/4] soc: qcom: aoss: Move length requirements from caller Date: Sun, 30 Jul 2023 21:10:10 -0700 Message-ID: <20230731041013.2950307-2-quic_bjorande@quicinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230731041013.2950307-1-quic_bjorande@quicinc.com> References: <20230731041013.2950307-1-quic_bjorande@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01c.na.qualcomm.com (10.47.97.35) To nalasex01c.na.qualcomm.com (10.47.97.35) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: PKrhk14bkJ_3GBV2QVUedKulTzMvNNU9 X-Proofpoint-ORIG-GUID: PKrhk14bkJ_3GBV2QVUedKulTzMvNNU9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-27_10,2023-07-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 bulkscore=0 phishscore=0 suspectscore=0 spamscore=0 lowpriorityscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 adultscore=0 impostorscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307310038 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772913248235661078 X-GMAIL-MSGID: 1772913248235661078 The existing implementation of qmp_send() requires the caller to provide a buffer which is of word-aligned. The underlying reason for this is that message ram only supports word accesses, but pushing this requirement onto the clients results in the same boiler plate code sprinkled in every call site. By using a temporary buffer in qmp_send() we can hide the underlying hardware limitations from the clients and allow them to pass their NUL-terminates C string directly. Signed-off-by: Bjorn Andersson --- drivers/net/ipa/ipa_power.c | 2 +- drivers/remoteproc/qcom_q6v5.c | 2 +- drivers/soc/qcom/qcom_aoss.c | 25 ++++++++++++------------- include/linux/soc/qcom/qcom_aoss.h | 4 ++-- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/drivers/net/ipa/ipa_power.c b/drivers/net/ipa/ipa_power.c index 921eecf3eff6..26181eeed975 100644 --- a/drivers/net/ipa/ipa_power.c +++ b/drivers/net/ipa/ipa_power.c @@ -332,7 +332,7 @@ void ipa_power_retention(struct ipa *ipa, bool enable) (void)snprintf(buf, sizeof(buf), fmt, enable ? '1' : '0'); - ret = qmp_send(power->qmp, buf, sizeof(buf)); + ret = qmp_send(power->qmp, buf); if (ret) dev_err(power->dev, "error %d sending QMP %sable request\n", ret, enable ? "en" : "dis"); diff --git a/drivers/remoteproc/qcom_q6v5.c b/drivers/remoteproc/qcom_q6v5.c index 192c7aa0e39e..8b41a73fa4d1 100644 --- a/drivers/remoteproc/qcom_q6v5.c +++ b/drivers/remoteproc/qcom_q6v5.c @@ -35,7 +35,7 @@ static int q6v5_load_state_toggle(struct qcom_q6v5 *q6v5, bool enable) WARN_ON(ret >= Q6V5_LOAD_STATE_MSG_LEN); - ret = qmp_send(q6v5->qmp, buf, sizeof(buf)); + ret = qmp_send(q6v5->qmp, buf); if (ret) dev_err(q6v5->dev, "failed to toggle load state\n"); diff --git a/drivers/soc/qcom/qcom_aoss.c b/drivers/soc/qcom/qcom_aoss.c index e376c32cc16e..5e74332515cf 100644 --- a/drivers/soc/qcom/qcom_aoss.c +++ b/drivers/soc/qcom/qcom_aoss.c @@ -206,36 +206,35 @@ static bool qmp_message_empty(struct qmp *qmp) * qmp_send() - send a message to the AOSS * @qmp: qmp context * @data: message to be sent - * @len: length of the message * * Transmit @data to AOSS and wait for the AOSS to acknowledge the message. - * @len must be a multiple of 4 and not longer than the mailbox size. Access is - * synchronized by this implementation. + * data must not be longer than the mailbox size. Access is synchronized by + * this implementation. * * Return: 0 on success, negative errno on failure */ -int qmp_send(struct qmp *qmp, const void *data, size_t len) +int qmp_send(struct qmp *qmp, const void *data) { long time_left; + char buf[QMP_MSG_LEN]; int ret; if (WARN_ON(IS_ERR_OR_NULL(qmp) || !data)) return -EINVAL; - if (WARN_ON(len + sizeof(u32) > qmp->size)) + if (WARN_ON(strlen(data) >= sizeof(buf))) return -EINVAL; - if (WARN_ON(len % sizeof(u32))) - return -EINVAL; + strscpy_pad(buf, data, sizeof(buf)); mutex_lock(&qmp->tx_lock); /* The message RAM only implements 32-bit accesses */ __iowrite32_copy(qmp->msgram + qmp->offset + sizeof(u32), - data, len / sizeof(u32)); - writel(len, qmp->msgram + qmp->offset); + buf, sizeof(buf) / sizeof(u32)); + writel(sizeof(buf), qmp->msgram + qmp->offset); - /* Read back len to confirm data written in message RAM */ + /* Read back length to confirm data written in message RAM */ readl(qmp->msgram + qmp->offset); qmp_kick(qmp); @@ -262,7 +261,7 @@ static int qmp_qdss_clk_prepare(struct clk_hw *hw) static const char buf[QMP_MSG_LEN] = "{class: clock, res: qdss, val: 1}"; struct qmp *qmp = container_of(hw, struct qmp, qdss_clk); - return qmp_send(qmp, buf, sizeof(buf)); + return qmp_send(qmp, buf); } static void qmp_qdss_clk_unprepare(struct clk_hw *hw) @@ -270,7 +269,7 @@ static void qmp_qdss_clk_unprepare(struct clk_hw *hw) static const char buf[QMP_MSG_LEN] = "{class: clock, res: qdss, val: 0}"; struct qmp *qmp = container_of(hw, struct qmp, qdss_clk); - qmp_send(qmp, buf, sizeof(buf)); + qmp_send(qmp, buf); } static const struct clk_ops qmp_qdss_clk_ops = { @@ -344,7 +343,7 @@ static int qmp_cdev_set_cur_state(struct thermal_cooling_device *cdev, qmp_cdev->name, cdev_state ? "on" : "off"); - ret = qmp_send(qmp_cdev->qmp, buf, sizeof(buf)); + ret = qmp_send(qmp_cdev->qmp, buf); if (!ret) qmp_cdev->state = cdev_state; diff --git a/include/linux/soc/qcom/qcom_aoss.h b/include/linux/soc/qcom/qcom_aoss.h index 3c2a82e606f8..7a71406b6050 100644 --- a/include/linux/soc/qcom/qcom_aoss.h +++ b/include/linux/soc/qcom/qcom_aoss.h @@ -13,13 +13,13 @@ struct qmp; #if IS_ENABLED(CONFIG_QCOM_AOSS_QMP) -int qmp_send(struct qmp *qmp, const void *data, size_t len); +int qmp_send(struct qmp *qmp, const void *data); struct qmp *qmp_get(struct device *dev); void qmp_put(struct qmp *qmp); #else -static inline int qmp_send(struct qmp *qmp, const void *data, size_t len) +static inline int qmp_send(struct qmp *qmp, const void *data) { return -ENODEV; } From patchwork Mon Jul 31 04:10:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 128340 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp1805887vqg; Sun, 30 Jul 2023 22:15:45 -0700 (PDT) X-Google-Smtp-Source: APBJJlGu/AdhNi54dCiwMg2EHulVfyxncfKFmhu1NYRhI8GBRJ5+K3EZGq6f8Kw21YAyVprEY7eM X-Received: by 2002:a17:90a:c797:b0:268:22bb:f0d0 with SMTP id gn23-20020a17090ac79700b0026822bbf0d0mr7974980pjb.7.1690780545079; Sun, 30 Jul 2023 22:15:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690780545; cv=none; d=google.com; s=arc-20160816; b=MTrTxWfyBn74NqYHEoThSbjFhRxqp/e/EPA+tpSsc53z4cBah8CT5Wi3osgif5//t9 tbdIKIdc/wABgD3LgskRTU4L6QWVZeGMgDmqgwMR64HwiMaDETidz9/+kr+EBSI0muys vd3xsvKsUHvD+MbsaXJiFUvnymBBRloUg9b/rvVg0Y6EZCxuFSuczo15S6dLL5Ex88Xm aJrO9rwlPY133GsvHHcze3vwuMac1pmCWw3TYsmsrlR8R5hZ/H6WMw7X7Zq5cGT4SvQW mFxJp5yKv6hTWGf5TOtWBTDXWSelJ3qpXfHIbuwcui+E4FLZcE8D29IFrQ5zqySuyF/1 72BA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=iPGu+a7vfT6bkQwP2to6KXLKlH2TykxH0AmqhSrw8I8=; fh=rCBE8/kXWBaCp7P5CIBGqD11Aa0ik5RvwLHhauCkNFk=; b=ODp4NliyYMeoLnNpEPuDnxdOlTdDKMUbgD2yW/vYp6NQyXnfDjqO39l/oc4V6aRIkJ AZsjerAhnGLJbUebUmyYbLBGeS5vuJgYAEdPgL6vSvhosXUx3yzz6OFWIgA0uJ7DCT+k LfOS1ylpQGr1PU43ZQFXg3oMfMJtaxD5KQa7GjS21kPZ92SaCPBMH42yzidZKHx2axAy 8Xd44ymSSShhKKWDaa5lb9jpXrCvZsUiJj60GQ6uWKhMQbhCUeOtGQYQMgpITi4SLvQU a00nT4s47OU5GKUANpNZ+9nL5zi83RmjuZXq8WdvYlYJX3iIVPccKsWQJJlxrgi1wN3M +BWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=jIvB004T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fz4-20020a17090b024400b00263638bb354si8368888pjb.93.2023.07.30.22.15.32; Sun, 30 Jul 2023 22:15:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=jIvB004T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229457AbjGaEKw (ORCPT + 99 others); Mon, 31 Jul 2023 00:10:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229889AbjGaEKi (ORCPT ); Mon, 31 Jul 2023 00:10:38 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D4B4E45; Sun, 30 Jul 2023 21:10:32 -0700 (PDT) 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 36V4ALdY003422; Mon, 31 Jul 2023 04:10: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-transfer-encoding : content-type; s=qcppdkim1; bh=iPGu+a7vfT6bkQwP2to6KXLKlH2TykxH0AmqhSrw8I8=; b=jIvB004Tk1bF8FxLKQcnbEr8TmonQJpfztHPo0y9rYRtJ5s7YlEEjRve73XSZRwO+4jk GThmgXnCf5pNWv0QefwMTddzZiPbyv4gwlj4yPqOf8b3x2oEkxUeGh4yuNEqyAFqPWBu WznyvIcd/ClsoNuKllG5sZ9hd1IAAzMSUHpEqbQlgJXtp8aM1Ril2ZcB5mF4LHSEYB5W yhrO8gHoNIzWBIG5KOE5kuo12TLEJw/j3/X49rdoqipKhueZq2q/t+MDlSHS1oRWgj3d 5XY7So4bV1Jx4QzeoHsJeXkct/UMgr9azIb5+iTmpCe5ewOkxUxdbw2lyUvVi8tKJb97 Ug== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3s4uh3aju8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 31 Jul 2023 04:10:21 +0000 Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 36V4AJlu031491 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 31 Jul 2023 04:10:19 GMT Received: from hu-bjorande-lv.qualcomm.com (10.49.16.6) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Sun, 30 Jul 2023 21:10:19 -0700 From: Bjorn Andersson To: Bjorn Andersson , Konrad Dybcio , Chris Lew CC: Alex Elder , "David S. Miller" , Jakub Kicinski , Mathieu Poirier , , , , Subject: [PATCH 2/4] soc: qcom: aoss: Add debugfs interface for sending messages Date: Sun, 30 Jul 2023 21:10:11 -0700 Message-ID: <20230731041013.2950307-3-quic_bjorande@quicinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230731041013.2950307-1-quic_bjorande@quicinc.com> References: <20230731041013.2950307-1-quic_bjorande@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01c.na.qualcomm.com (10.47.97.35) To nalasex01c.na.qualcomm.com (10.47.97.35) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: ZQ3AGRPXVoyKxIE4dpVoNMcWhIITraLf X-Proofpoint-GUID: ZQ3AGRPXVoyKxIE4dpVoNMcWhIITraLf X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-27_10,2023-07-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 mlxscore=0 lowpriorityscore=0 spamscore=0 priorityscore=1501 phishscore=0 malwarescore=0 mlxlogscore=999 clxscore=1015 suspectscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307310037 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772911901145884438 X-GMAIL-MSGID: 1772911901145884438 From: Chris Lew In addition to the normal runtime commands, the Always On Processor (AOP) provides a number of debug commands which can be used during system debugging for things such as preventing power collapse or placing floor votes for certain resources. Some of these are documented in the Robotics RB5 "Debug AOP ADB" linked below. Provide a debugfs interface for the developer/tester to send these commands to the AOP. Link: https://docs.qualcomm.com/bundle/publicresource/topics/80-88500-3/85_Debugging_AOP_ADB.html Signed-off-by: Chris Lew [bjorn: Dropped debugfs guards, improve error codes, rewrote commit message] Signed-off-by: Bjorn Andersson --- drivers/soc/qcom/qcom_aoss.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/drivers/soc/qcom/qcom_aoss.c b/drivers/soc/qcom/qcom_aoss.c index 5e74332515cf..4c5bb7034fff 100644 --- a/drivers/soc/qcom/qcom_aoss.c +++ b/drivers/soc/qcom/qcom_aoss.c @@ -3,6 +3,7 @@ * Copyright (c) 2019, Linaro Ltd */ #include +#include #include #include #include @@ -82,6 +83,7 @@ struct qmp { struct clk_hw qdss_clk; struct qmp_cooling_device *cooling_devs; + struct dentry *debugfs_file; }; static void qmp_kick(struct qmp *qmp) @@ -475,6 +477,32 @@ void qmp_put(struct qmp *qmp) } EXPORT_SYMBOL(qmp_put); +static ssize_t qmp_debugfs_write(struct file *file, const char __user *userstr, + size_t len, loff_t *pos) +{ + struct qmp *qmp = file->private_data; + char buf[QMP_MSG_LEN]; + int ret; + + if (!len || len > QMP_MSG_LEN) + return -EINVAL; + + if (copy_from_user(buf, userstr, len)) + return -EFAULT; + buf[len] = '\0'; + + ret = qmp_send(qmp, buf); + if (ret < 0) + return ret; + + return len; +} + +static const struct file_operations qmp_debugfs_fops = { + .open = simple_open, + .write = qmp_debugfs_write, +}; + static int qmp_probe(struct platform_device *pdev) { struct qmp *qmp; @@ -523,6 +551,9 @@ static int qmp_probe(struct platform_device *pdev) platform_set_drvdata(pdev, qmp); + qmp->debugfs_file = debugfs_create_file("aoss_send_message", 0220, NULL, + qmp, &qmp_debugfs_fops); + return 0; err_close_qmp: @@ -537,6 +568,8 @@ static int qmp_remove(struct platform_device *pdev) { struct qmp *qmp = platform_get_drvdata(pdev); + debugfs_remove(qmp->debugfs_file); + qmp_qdss_clk_remove(qmp); qmp_cooling_devices_remove(qmp); From patchwork Mon Jul 31 04:10:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 128342 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp1809256vqg; Sun, 30 Jul 2023 22:27:05 -0700 (PDT) X-Google-Smtp-Source: APBJJlEti1c+J0FzfQbULgpcIgoYGkld5kJqGDEpKvaB9Ccb/V5aQpcBJ6QY1v7WP8thLsI2Dn0G X-Received: by 2002:a17:906:51ca:b0:99b:49a6:952d with SMTP id v10-20020a17090651ca00b0099b49a6952dmr5848625ejk.65.1690781225366; Sun, 30 Jul 2023 22:27:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690781225; cv=none; d=google.com; s=arc-20160816; b=LMO8VpC0y9C6ID5oT7D3VbXXj9aPCinzJ+8xXKiJXWaT5HsSBrr0lTIXwT8peCRN8G mgoKEw3AIiD1IVHJe+HSIb2iY6/CWoc7R8LexnF5xzErt/B5spGIQwlWaPkHtHAHrQNf esmw5KnOQmtSGORSHUwVC/BfhZ7ch6IEgcFIc7X5TRPtSyTIX9C7sUB+1jskULLN8Bb9 N6XLJWbYr+2rhKecfAzgTYKbYgOm9QGZ1q0neq162QWgxDib2vlBfcA5X96FCuHP+uLa m36H6Pt/w3LvzT4fBA4TBwT3UihKIlqh5+lrExoVMxWfW2ae+m758yF9zeChecMLEsAX 3SZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gp9XD6CZd39XpaMXUChOFVUeON8Mza7FQOgDoLLrBuk=; fh=rCBE8/kXWBaCp7P5CIBGqD11Aa0ik5RvwLHhauCkNFk=; b=niGCYj3c6+7VRmj3LIZWwmquulbAt+hmd6qg2yYi8zOK7ClKVqmlPgdkWAWZ25za9H ncyVeGZXIRWJ0CCWwZxZ4A7JiC4Hw5gU9ccvsxGGnuy88ITvgW+HKfxl1PWHzEcOrxVc DmHKbOdH83PH1EukaUysiWLxkMWQ0snwouhqJcEuVhs7DPv7CsaNPCxOaw9vD2jLCd3E uzbGoeQFjH+vuMDTV4lAZw8EK6aSDxNkBPJB4OM+Pq96pbsBtbQv8HibyPSBHD+0tsBt mrIClxcpHjTvRsTeOUcj7Cwt7B4Jxy0Dt/vp6NeVlogNC4oCFkJMMi3uX1f2JckqAHMr NHsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=m+cfC8ou; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kk20-20020a170907767400b00987dc76f82fsi1924569ejc.285.2023.07.30.22.26.40; Sun, 30 Jul 2023 22:27:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=m+cfC8ou; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229921AbjGaEKs (ORCPT + 99 others); Mon, 31 Jul 2023 00:10:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229887AbjGaEKi (ORCPT ); Mon, 31 Jul 2023 00:10:38 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3D4E1BE; Sun, 30 Jul 2023 21:10:31 -0700 (PDT) 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 36V21xQt023385; Mon, 31 Jul 2023 04:10: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-transfer-encoding : content-type; s=qcppdkim1; bh=gp9XD6CZd39XpaMXUChOFVUeON8Mza7FQOgDoLLrBuk=; b=m+cfC8ouoS9AvGZ3TXRvTk/xLGt5Vtauu/X7P0PrCykQMaTADEHtCYuKmNPKWnNajGX2 9riFHsj0j0Qg3lrMTJFYQ1j/is7RIG5Nxbw5d841MXQGVzSNeX0fS9wJc4eJET3qTN24 y3I8T9Z/2aLCmMJNddcsjqa0LeCwIfATA1055yzBvooFbgNxyrmanMbPp7IulcIWc6MR kaHxOIf1AKEYQ6eHrstXXGmXOuSPiQD7wrWAA3RSa3B6R0kbKa72yz5/dJ6fxqVSblmi m69O8OoJrg6XtTyUK1yairlY4CcFjoW1aFtc+QJE31ptnScV7w60GUxvjXT21UKXBIQg jw== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3s4ug22k11-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 31 Jul 2023 04:10:21 +0000 Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 36V4AKav006152 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 31 Jul 2023 04:10:20 GMT Received: from hu-bjorande-lv.qualcomm.com (10.49.16.6) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Sun, 30 Jul 2023 21:10:19 -0700 From: Bjorn Andersson To: Bjorn Andersson , Konrad Dybcio , Chris Lew CC: Alex Elder , "David S. Miller" , Jakub Kicinski , Mathieu Poirier , , , , Subject: [PATCH 3/4] soc: qcom: aoss: Format string in qmp_send() Date: Sun, 30 Jul 2023 21:10:12 -0700 Message-ID: <20230731041013.2950307-4-quic_bjorande@quicinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230731041013.2950307-1-quic_bjorande@quicinc.com> References: <20230731041013.2950307-1-quic_bjorande@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01c.na.qualcomm.com (10.47.97.35) To nalasex01c.na.qualcomm.com (10.47.97.35) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: Nwq8Mjb-FgW-ItEpkpAUcI8Dv5ZyPl__ X-Proofpoint-ORIG-GUID: Nwq8Mjb-FgW-ItEpkpAUcI8Dv5ZyPl__ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-27_10,2023-07-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 spamscore=0 priorityscore=1501 malwarescore=0 impostorscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 clxscore=1015 mlxscore=0 suspectscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307310037 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772912613951034177 X-GMAIL-MSGID: 1772912613951034177 The majority of callers to qmp_send() composes the message dynamically using some form of sprintf(), resulting in unnecessary complication and stack usage. By changing the interface of qmp_send() to take a format string and arguments, the duplicated composition of the commands can be moved to a single location. Signed-off-by: Bjorn Andersson Reviewed-by: Konrad Dybcio --- drivers/soc/qcom/qcom_aoss.c | 22 ++++++++++++++-------- include/linux/soc/qcom/qcom_aoss.h | 4 ++-- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/soc/qcom/qcom_aoss.c b/drivers/soc/qcom/qcom_aoss.c index 4c5bb7034fff..b59c8681bcfe 100644 --- a/drivers/soc/qcom/qcom_aoss.c +++ b/drivers/soc/qcom/qcom_aoss.c @@ -207,27 +207,33 @@ static bool qmp_message_empty(struct qmp *qmp) /** * qmp_send() - send a message to the AOSS * @qmp: qmp context - * @data: message to be sent + * @fmt: format string for message to be sent + * @...: arguments for the format string * - * Transmit @data to AOSS and wait for the AOSS to acknowledge the message. + * Transmit message to AOSS and wait for the AOSS to acknowledge the message. * data must not be longer than the mailbox size. Access is synchronized by * this implementation. * * Return: 0 on success, negative errno on failure */ -int qmp_send(struct qmp *qmp, const void *data) +int qmp_send(struct qmp *qmp, const char *fmt, ...) { long time_left; + va_list args; char buf[QMP_MSG_LEN]; + int len; int ret; - if (WARN_ON(IS_ERR_OR_NULL(qmp) || !data)) + if (WARN_ON(IS_ERR_OR_NULL(qmp) || !fmt)) return -EINVAL; - if (WARN_ON(strlen(data) >= sizeof(buf))) - return -EINVAL; + memset(buf, 0, sizeof(buf)); + va_start(args, fmt); + len = vsnprintf(buf, sizeof(buf), fmt, args); + va_end(args); - strscpy_pad(buf, data, sizeof(buf)); + if (WARN_ON(len >= sizeof(buf))) + return -EINVAL; mutex_lock(&qmp->tx_lock); @@ -491,7 +497,7 @@ static ssize_t qmp_debugfs_write(struct file *file, const char __user *userstr, return -EFAULT; buf[len] = '\0'; - ret = qmp_send(qmp, buf); + ret = qmp_send(qmp, "%s", buf); if (ret < 0) return ret; diff --git a/include/linux/soc/qcom/qcom_aoss.h b/include/linux/soc/qcom/qcom_aoss.h index 7a71406b6050..7361ca028752 100644 --- a/include/linux/soc/qcom/qcom_aoss.h +++ b/include/linux/soc/qcom/qcom_aoss.h @@ -13,13 +13,13 @@ struct qmp; #if IS_ENABLED(CONFIG_QCOM_AOSS_QMP) -int qmp_send(struct qmp *qmp, const void *data); +int qmp_send(struct qmp *qmp, const char *fmt, ...); struct qmp *qmp_get(struct device *dev); void qmp_put(struct qmp *qmp); #else -static inline int qmp_send(struct qmp *qmp, const void *data) +static inline int qmp_send(struct qmp *qmp, const char *fmt, ...) { return -ENODEV; } From patchwork Mon Jul 31 04:10:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 128339 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp1800312vqg; Sun, 30 Jul 2023 21:59:53 -0700 (PDT) X-Google-Smtp-Source: APBJJlHp8yzgIZKXgwwKllzCbdsIm9uamR/Kl93/amm5EiDp8wZOkLxb0fN7l6oG5+yxabBvNrTo X-Received: by 2002:a05:622a:651:b0:403:9a69:a94a with SMTP id a17-20020a05622a065100b004039a69a94amr14259297qtb.40.1690779593101; Sun, 30 Jul 2023 21:59:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690779593; cv=none; d=google.com; s=arc-20160816; b=qBO7prGO8ZZwMq/oEZdL9oCMyxjmCtpluuLOU2g6idT4qTQ0nXPMjv1IC0M9K7zPVz ViUuBq7uu1o7uv6GMYHjmR+5D/fRV9PlCkSzpeDWkqt552w+/grHgwJkN+S67ac+mW9n pi6SPz16Fe6ahwu13pjvsO+xTNG+4nZusyvpw6EP3rj2CqO9VuKckMUJ4M7g2qan9OFX JcBkQxUwy25ggbejnZwui4m/TV8Ei7s2W6RHrA7Sfve10dRAJ36DIpvXip3uNKU/BFFM xiPFGF7ZoPQ5xPZo1ze6jfsevTuX6LOTF4TiSrFR00Q0jAkhqaTht5bPv5e0iso/TSe4 acKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gPvnt16QGA4ObIxg6yNEmot12urHMc4SMSDvzpuJp88=; fh=rCBE8/kXWBaCp7P5CIBGqD11Aa0ik5RvwLHhauCkNFk=; b=C9hGs+sdHvTpDPW5h3YcD68RHHJyW6cBzU51wgsVl1iLdU2LJogh8/XwwB//9syL7Y BFCjf9/NkHe/RYzwWRQdvhLunXg3ihoDsoUBFl30W2r7m4cp1FQ6lHWsZbBt/gjDZuwy PmqGzBJRmiTp44sVjpOglq1BmtGdbfihI4OfXQhrKpLLW4bYXNhEBt2BMKYNWt0utKKW MBbjTHakksyQ4/aLZLhT/7chb+mqtLvLmuU+YDLOsclYCdoVHSIIPly0O0VwAF/h/Xnu YZLiHRQkyZ2Lf//9ZUAqXhvEB+Pqs9X25jKPZt5COp0ykJ9eOp45/JPNJtFQUvWwbe1u Jmjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=RlLkPPOk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h11-20020a63574b000000b00545a181d157si4775668pgm.51.2023.07.30.21.59.40; Sun, 30 Jul 2023 21:59:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=RlLkPPOk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229911AbjGaEKn (ORCPT + 99 others); Mon, 31 Jul 2023 00:10:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229742AbjGaEKg (ORCPT ); Mon, 31 Jul 2023 00:10:36 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48AD3E43; Sun, 30 Jul 2023 21:10:32 -0700 (PDT) Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36V2mVwh019004; Mon, 31 Jul 2023 04:10: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-transfer-encoding : content-type; s=qcppdkim1; bh=gPvnt16QGA4ObIxg6yNEmot12urHMc4SMSDvzpuJp88=; b=RlLkPPOkE5u5Rw76QJjAmaE+bjsmWEzfXxz1oqz/Q2Ixelqy6P5gdoX+95bRWboGgKIz TB6TIPWVSz+Cy4FnNZidaQL2gHYAGBDL7J2nWo5Et/vAE47sNYVN471tMr1Y9ZGjgzvg Z2F7oYnp1gKwrHn4cy4KQQU5WvpDGK7Ghv4Btno6+Vpw5to6IZikvRLEieVIlZQV0OkC ks2J1dGpluLR+EBaAFJt96U8TaTD+RbkaXfQ1cctY1odiU4cSWHZZE1yZPBuo1Qiav9O Y3BibykIVP7nlHDGByK43P62j+kfZQ8LHDTB9P2kvZeDdN+V4IQdmfv4e4vjTxXKn918 Rg== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3s4ueujk90-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 31 Jul 2023 04:10:21 +0000 Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 36V4AKiS031498 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 31 Jul 2023 04:10:20 GMT Received: from hu-bjorande-lv.qualcomm.com (10.49.16.6) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Sun, 30 Jul 2023 21:10:20 -0700 From: Bjorn Andersson To: Bjorn Andersson , Konrad Dybcio , Chris Lew CC: Alex Elder , "David S. Miller" , Jakub Kicinski , Mathieu Poirier , , , , Subject: [PATCH 4/4] soc: qcom: aoss: Tidy up qmp_send() callers Date: Sun, 30 Jul 2023 21:10:13 -0700 Message-ID: <20230731041013.2950307-5-quic_bjorande@quicinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230731041013.2950307-1-quic_bjorande@quicinc.com> References: <20230731041013.2950307-1-quic_bjorande@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01c.na.qualcomm.com (10.47.97.35) To nalasex01c.na.qualcomm.com (10.47.97.35) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: 7zMnZAXaYh_3srMd2w-mcsIwO6_BuxRf X-Proofpoint-ORIG-GUID: 7zMnZAXaYh_3srMd2w-mcsIwO6_BuxRf X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-27_10,2023-07-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 bulkscore=0 phishscore=0 suspectscore=0 spamscore=0 lowpriorityscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 adultscore=0 impostorscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307310038 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772910902589198579 X-GMAIL-MSGID: 1772910902589198579 With qmp_send() handling variable length messages and string formatting he callers of qmp_send() can be cleaned up to not care about these things. Drop the QMP_MSG_LEN sized buffers and use the message formatting, as appropriate. Signed-off-by: Bjorn Andersson Reviewed-by: Konrad Dybcio --- drivers/net/ipa/ipa_power.c | 5 +---- drivers/remoteproc/qcom_q6v5.c | 8 +------- drivers/soc/qcom/qcom_aoss.c | 14 ++++---------- 3 files changed, 6 insertions(+), 21 deletions(-) diff --git a/drivers/net/ipa/ipa_power.c b/drivers/net/ipa/ipa_power.c index 26181eeed975..0eaa7a7f3343 100644 --- a/drivers/net/ipa/ipa_power.c +++ b/drivers/net/ipa/ipa_power.c @@ -324,15 +324,12 @@ void ipa_power_retention(struct ipa *ipa, bool enable) { static const char fmt[] = "{ class: bcm, res: ipa_pc, val: %c }"; struct ipa_power *power = ipa->power; - char buf[36]; /* Exactly enough for fmt[]; size a multiple of 4 */ int ret; if (!power->qmp) return; /* Not needed on this platform */ - (void)snprintf(buf, sizeof(buf), fmt, enable ? '1' : '0'); - - ret = qmp_send(power->qmp, buf); + ret = qmp_send(power->qmp, fmt, enable ? '1' : '0'); if (ret) dev_err(power->dev, "error %d sending QMP %sable request\n", ret, enable ? "en" : "dis"); diff --git a/drivers/remoteproc/qcom_q6v5.c b/drivers/remoteproc/qcom_q6v5.c index 8b41a73fa4d1..4ee5e67a9f03 100644 --- a/drivers/remoteproc/qcom_q6v5.c +++ b/drivers/remoteproc/qcom_q6v5.c @@ -23,19 +23,13 @@ static int q6v5_load_state_toggle(struct qcom_q6v5 *q6v5, bool enable) { - char buf[Q6V5_LOAD_STATE_MSG_LEN]; int ret; if (!q6v5->qmp) return 0; - ret = snprintf(buf, sizeof(buf), - "{class: image, res: load_state, name: %s, val: %s}", + ret = qmp_send(q6v5->qmp, "{class: image, res: load_state, name: %s, val: %s}", q6v5->load_state, enable ? "on" : "off"); - - WARN_ON(ret >= Q6V5_LOAD_STATE_MSG_LEN); - - ret = qmp_send(q6v5->qmp, buf); if (ret) dev_err(q6v5->dev, "failed to toggle load state\n"); diff --git a/drivers/soc/qcom/qcom_aoss.c b/drivers/soc/qcom/qcom_aoss.c index b59c8681bcfe..4a4e12c7439a 100644 --- a/drivers/soc/qcom/qcom_aoss.c +++ b/drivers/soc/qcom/qcom_aoss.c @@ -266,7 +266,7 @@ EXPORT_SYMBOL(qmp_send); static int qmp_qdss_clk_prepare(struct clk_hw *hw) { - static const char buf[QMP_MSG_LEN] = "{class: clock, res: qdss, val: 1}"; + static const char *buf = "{class: clock, res: qdss, val: 1}"; struct qmp *qmp = container_of(hw, struct qmp, qdss_clk); return qmp_send(qmp, buf); @@ -274,7 +274,7 @@ static int qmp_qdss_clk_prepare(struct clk_hw *hw) static void qmp_qdss_clk_unprepare(struct clk_hw *hw) { - static const char buf[QMP_MSG_LEN] = "{class: clock, res: qdss, val: 0}"; + static const char *buf = "{class: clock, res: qdss, val: 0}"; struct qmp *qmp = container_of(hw, struct qmp, qdss_clk); qmp_send(qmp, buf); @@ -336,7 +336,6 @@ static int qmp_cdev_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state) { struct qmp_cooling_device *qmp_cdev = cdev->devdata; - char buf[QMP_MSG_LEN] = {}; bool cdev_state; int ret; @@ -346,13 +345,8 @@ static int qmp_cdev_set_cur_state(struct thermal_cooling_device *cdev, if (qmp_cdev->state == state) return 0; - snprintf(buf, sizeof(buf), - "{class: volt_flr, event:zero_temp, res:%s, value:%s}", - qmp_cdev->name, - cdev_state ? "on" : "off"); - - ret = qmp_send(qmp_cdev->qmp, buf); - + ret = qmp_send(qmp_cdev->qmp, "{class: volt_flr, event:zero_temp, res:%s, value:%s}", + qmp_cdev->name, cdev_state ? "on" : "off"); if (!ret) qmp_cdev->state = cdev_state;