Message ID | 20230731041013.2950307-3-quic_bjorande@quicinc.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> 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 <rfc822;dengxinlin2429@gmail.com> + 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 <rfc822;linux-kernel@vger.kernel.org>); 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 <quic_bjorande@quicinc.com> To: Bjorn Andersson <andersson@kernel.org>, Konrad Dybcio <konrad.dybcio@linaro.org>, Chris Lew <quic_clew@quicinc.com> CC: Alex Elder <elder@kernel.org>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Mathieu Poirier <mathieu.poirier@linaro.org>, <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <linux-arm-msm@vger.kernel.org>, <linux-remoteproc@vger.kernel.org> 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 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772911901145884438 X-GMAIL-MSGID: 1772911901145884438 |
Series |
soc: qcom: aoss: Introduce debugfs interface and cleanup things
|
|
Commit Message
Bjorn Andersson
July 31, 2023, 4:10 a.m. UTC
From: Chris Lew <clew@codeaurora.org> 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 <clew@codeaurora.org> [bjorn: Dropped debugfs guards, improve error codes, rewrote commit message] Signed-off-by: Bjorn Andersson <quic_bjorande@quicinc.com> --- drivers/soc/qcom/qcom_aoss.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
Comments
On 31.07.2023 06:10, Bjorn Andersson wrote: > From: Chris Lew <clew@codeaurora.org> No QUIC email? [...] > +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) >=? Otherwise the last char may be overwritten by the NULL termination couple lines below > + 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; > +} Konrad
On Sun, Jul 30, 2023 at 09:10:11PM -0700, Bjorn Andersson wrote: > From: Chris Lew <clew@codeaurora.org> > > 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. This sort of sending arbitrary binary blob commands is not liked, since it allow user space closed source drivers. At minimum, please provide a file per command, with the kernel marshalling parameters into the binary format, and decoding any returned values. Andrew
On Sun, Jul 30, 2023 at 09:10:11PM -0700, Bjorn Andersson wrote: > From: Chris Lew <clew@codeaurora.org> > > 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 <clew@codeaurora.org> > [bjorn: Dropped debugfs guards, improve error codes, rewrote commit message] > Signed-off-by: Bjorn Andersson <quic_bjorande@quicinc.com> > --- > 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 <linux/clk-provider.h> > +#include <linux/debugfs.h> > #include <linux/interrupt.h> > #include <linux/io.h> > #include <linux/mailbox_client.h> > @@ -82,6 +83,7 @@ struct qmp { > > struct clk_hw qdss_clk; > struct qmp_cooling_device *cooling_devs; > + struct dentry *debugfs_file; Hi Bjorn, Please consider adding debugfs_file to the kernel doc for struct qmp. > }; > > static void qmp_kick(struct qmp *qmp) ...
On Mon, Jul 31, 2023 at 10:21:31AM +0200, Andrew Lunn wrote: > On Sun, Jul 30, 2023 at 09:10:11PM -0700, Bjorn Andersson wrote: > > From: Chris Lew <clew@codeaurora.org> > > > > 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. > > This sort of sending arbitrary binary blob commands is not liked, > since it allow user space closed source drivers. At minimum, please > provide a file per command, with the kernel marshalling parameters > into the binary format, and decoding any returned values. > Thanks for your input Andrew, that is a valid concern. The interface is in debugfs and as such wouldn't be suitable for closed source drivers, as in the majority of our shipping software debugfs isn't enabled. Regards, Bjorn
On Mon, Jul 31, 2023 at 10:15:34AM +0200, Konrad Dybcio wrote: > On 31.07.2023 06:10, Bjorn Andersson wrote: > > From: Chris Lew <clew@codeaurora.org> > No QUIC email? > That's the author and s-o-b address of the patch. mailmap will help you if you want to reach him. > [...] > > > > +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) > >=? Otherwise the last char may be overwritten by the NULL termination > couple lines below > My mind had a '\0' accounted for in len as well, but you're right. Thanks, Bjorn
On Sun, Jul 30, 2023 at 09:10:11PM -0700, Bjorn Andersson wrote: > From: Chris Lew <clew@codeaurora.org> > > 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 <clew@codeaurora.org> > [bjorn: Dropped debugfs guards, improve error codes, rewrote commit message] > Signed-off-by: Bjorn Andersson <quic_bjorande@quicinc.com> Thanks Bjorn and Chris for enabling this interface. It will be very useful. We use this interface in downstream kernel during throughput/suspend issues debug. I have tested your series with v6.4 on SM8550 and it works as expected. Thanks, Pavan
On Mon, Jul 31, 2023 at 08:39:38AM -0700, Bjorn Andersson wrote: > On Mon, Jul 31, 2023 at 10:21:31AM +0200, Andrew Lunn wrote: > > On Sun, Jul 30, 2023 at 09:10:11PM -0700, Bjorn Andersson wrote: > > > From: Chris Lew <clew@codeaurora.org> > > > > > > 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. > > > > This sort of sending arbitrary binary blob commands is not liked, > > since it allow user space closed source drivers. At minimum, please > > provide a file per command, with the kernel marshalling parameters > > into the binary format, and decoding any returned values. > > > > Thanks for your input Andrew, that is a valid concern. > > The interface is in debugfs and as such wouldn't be suitable for closed > source drivers, as in the majority of our shipping software debugfs > isn't enabled. There only appears to be 3 commands, so it is now too much of a burden to do it properly, and not have a binary blob API. And most distros do have debugfs at least built and available, but maybe not mounted. Andrew
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 <linux/clk-provider.h> +#include <linux/debugfs.h> #include <linux/interrupt.h> #include <linux/io.h> #include <linux/mailbox_client.h> @@ -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);