From patchwork Mon Nov 18 08:40:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ekansh Gupta X-Patchwork-Id: 13878301 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9E544D43FEE for ; Mon, 18 Nov 2024 08:41:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 280E810E355; Mon, 18 Nov 2024 08:41:07 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=quicinc.com header.i=@quicinc.com header.b="Y5n9JnYC"; dkim-atps=neutral Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by gabe.freedesktop.org (Postfix) with ESMTPS id 419F410E355 for ; Mon, 18 Nov 2024 08:41:05 +0000 (UTC) Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4AI5RdJt020056; Mon, 18 Nov 2024 08:41:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= 51UUDPKPn/m2eeZSZmRJhQ1BqI3NkwvgTuCMl8Xh+Uw=; b=Y5n9JnYC6mdO7PwL 7M3F4ypocrUyxN7uf51cqvpwq3PNga93HkqlvHDZbwqO9YPNaTsbzAVgB6xB86kE u5J2zfjVyMUvIroMmim9qbd0kFNhjEO6DlSP9VROP/EjdLZp6kkb242YOoTANeTo MEw+ixzEpWaFJt69nmlNdLOsl8LiJGnqg+Hde0h0ByHLr3pIicRcWOLCfe5fcFUr S68LzcilWM06Yo8M0Tw1SM5bybCn2KwGHCdXb9yRAqgaQRIuum2PegqKGDSavjnX E0qqMG4nZXYqlx9V1IoeZ0U+giZkxI+aE+KnihfZZ22vKJ9Nh78xqXVHldvLbfLy sayikg== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 42xksqkx90-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 Nov 2024 08:41:01 +0000 (GMT) Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA01.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 4AI8f0og020710 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 Nov 2024 08:41:00 GMT Received: from hu-ekangupt-hyd.qualcomm.com (10.80.80.8) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Mon, 18 Nov 2024 00:40:57 -0800 From: Ekansh Gupta To: , CC: , , , , , Subject: [PATCH v1 1/4] misc: fastrpc: Move fastrpc driver to misc/fastrpc/ Date: Mon, 18 Nov 2024 14:10:43 +0530 Message-ID: <20241118084046.3201290-2-quic_ekangupt@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241118084046.3201290-1-quic_ekangupt@quicinc.com> References: <20241118084046.3201290-1-quic_ekangupt@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: jCR-s6R03MPdCxMHBD16fGzf29QOqzHz X-Proofpoint-ORIG-GUID: jCR-s6R03MPdCxMHBD16fGzf29QOqzHz X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxlogscore=976 impostorscore=0 adultscore=0 spamscore=0 bulkscore=0 lowpriorityscore=0 malwarescore=0 clxscore=1015 phishscore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2411180071 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Move fastrpc.c from misc/ to misc/fastrpc/. New C files are planned to be added for PD notifications and other missing features. Adding and maintaining new files from within fastrpc directory would be easy. Example of feature that is being planned to be introduced in a new C file: https://lore.kernel.org/all/20240606165939.12950-6-quic_ekangupt@quicinc.com/ Signed-off-by: Ekansh Gupta --- MAINTAINERS | 2 +- drivers/misc/Kconfig | 13 +------------ drivers/misc/Makefile | 2 +- drivers/misc/fastrpc/Kconfig | 16 ++++++++++++++++ drivers/misc/fastrpc/Makefile | 2 ++ drivers/misc/{ => fastrpc}/fastrpc.c | 0 6 files changed, 21 insertions(+), 14 deletions(-) create mode 100644 drivers/misc/fastrpc/Kconfig create mode 100644 drivers/misc/fastrpc/Makefile rename drivers/misc/{ => fastrpc}/fastrpc.c (100%) diff --git a/MAINTAINERS b/MAINTAINERS index b878ddc99f94..280f07d722b5 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -19036,7 +19036,7 @@ L: linux-arm-msm@vger.kernel.org L: dri-devel@lists.freedesktop.org S: Maintained F: Documentation/devicetree/bindings/misc/qcom,fastrpc.yaml -F: drivers/misc/fastrpc.c +F: drivers/misc/fastrpc/ F: include/uapi/misc/fastrpc.h QUALCOMM HEXAGON ARCHITECTURE diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index 3fe7e2a9bd29..fd02acc3f444 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -286,18 +286,6 @@ config QCOM_COINCELL to maintain PMIC register and RTC state in the absence of external power. -config QCOM_FASTRPC - tristate "Qualcomm FastRPC" - depends on ARCH_QCOM || COMPILE_TEST - depends on RPMSG - select DMA_SHARED_BUFFER - select QCOM_SCM - help - Provides a communication mechanism that allows for clients to - make remote method invocations across processor boundary to - applications DSP processor. Say M if you want to enable this - module. - config SGI_GRU tristate "SGI GRU driver" depends on X86_UV && SMP @@ -628,4 +616,5 @@ source "drivers/misc/uacce/Kconfig" source "drivers/misc/pvpanic/Kconfig" source "drivers/misc/mchp_pci1xxxx/Kconfig" source "drivers/misc/keba/Kconfig" +source "drivers/misc/fastrpc/Kconfig" endmenu diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index a9f94525e181..efbf69c3b47c 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -17,7 +17,6 @@ obj-$(CONFIG_TIFM_7XX1) += tifm_7xx1.o obj-$(CONFIG_PHANTOM) += phantom.o obj-$(CONFIG_RPMB) += rpmb-core.o obj-$(CONFIG_QCOM_COINCELL) += qcom-coincell.o -obj-$(CONFIG_QCOM_FASTRPC) += fastrpc.o obj-$(CONFIG_SENSORS_BH1770) += bh1770glc.o obj-$(CONFIG_SENSORS_APDS990X) += apds990x.o obj-$(CONFIG_ENCLOSURE_SERVICES) += enclosure.o @@ -72,3 +71,4 @@ obj-$(CONFIG_TPS6594_PFSM) += tps6594-pfsm.o obj-$(CONFIG_NSM) += nsm.o obj-$(CONFIG_MARVELL_CN10K_DPI) += mrvl_cn10k_dpi.o obj-y += keba/ +obj-y += fastrpc/ diff --git a/drivers/misc/fastrpc/Kconfig b/drivers/misc/fastrpc/Kconfig new file mode 100644 index 000000000000..7179a44eda84 --- /dev/null +++ b/drivers/misc/fastrpc/Kconfig @@ -0,0 +1,16 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Qualcomm FastRPC devices +# + +config QCOM_FASTRPC + tristate "Qualcomm FastRPC" + depends on ARCH_QCOM || COMPILE_TEST + depends on RPMSG + select DMA_SHARED_BUFFER + select QCOM_SCM + help + Provides a communication mechanism that facilitate high-speed + Remote Procedure Call (RPC) mechanisms between the host CPU and + offload processors Qualcomm Digital Signal Processors (DSPs). + Say M if you want to enable this module. \ No newline at end of file diff --git a/drivers/misc/fastrpc/Makefile b/drivers/misc/fastrpc/Makefile new file mode 100644 index 000000000000..77fd2b763b6b --- /dev/null +++ b/drivers/misc/fastrpc/Makefile @@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0 +obj-$(CONFIG_QCOM_FASTRPC) += fastrpc.o diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc/fastrpc.c similarity index 100% rename from drivers/misc/fastrpc.c rename to drivers/misc/fastrpc/fastrpc.c From patchwork Mon Nov 18 08:40:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ekansh Gupta X-Patchwork-Id: 13878302 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E0D0BD43FEF for ; Mon, 18 Nov 2024 08:41:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3CBE510E448; Mon, 18 Nov 2024 08:41:10 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=quicinc.com header.i=@quicinc.com header.b="e8LTFzhW"; dkim-atps=neutral Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9575010E448 for ; Mon, 18 Nov 2024 08:41:08 +0000 (UTC) Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4AI5RjBM029054; Mon, 18 Nov 2024 08:41:04 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= i7TS+CMWl1Z1e95N/mX5sBAqoXbfzgbHRIPFgYRsp9E=; b=e8LTFzhWgw+9phsf Vce99oE9JUqlggya9Op7g86R4UBp+N/mXQl8BMNs+lH7UStfP88GP/83PYvKPwYJ g+XHnwQ5hiHgfvzgQRfamvnLkpPNjZAs8kA5j/BooEiBs3A84hmKc5/31Wnvk4kB 4pYd+TQCJXPWzjptzvq2zSGM0GJGfclFhC7Sc7KsjLMSci3sLkti8JDLztj+bMgU /ET8W2eN70538tx9NfQXB9SHFQFjEZ63EBbftTWTlW6d5FPQUQOEL4jc2tetf03A L6h3+Q+zA5za086gt2MCIfvzTVKz4ya4CHXNKwKJ/ZSMfsnxAiIA3YfgzN+403RV gmb9OQ== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 42xmp7bvqd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 Nov 2024 08:41:04 +0000 (GMT) Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA01.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 4AI8f39h020897 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 Nov 2024 08:41:03 GMT Received: from hu-ekangupt-hyd.qualcomm.com (10.80.80.8) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Mon, 18 Nov 2024 00:41:00 -0800 From: Ekansh Gupta To: , CC: , , , , , Subject: [PATCH v1 2/4] misc: fastrpc: Rename fastrpc.c to fastrpc_main.c Date: Mon, 18 Nov 2024 14:10:44 +0530 Message-ID: <20241118084046.3201290-3-quic_ekangupt@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241118084046.3201290-1-quic_ekangupt@quicinc.com> References: <20241118084046.3201290-1-quic_ekangupt@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: pjYBEE0cZRrv9SakxYTWBRGpyV5JaFaS X-Proofpoint-GUID: pjYBEE0cZRrv9SakxYTWBRGpyV5JaFaS X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 priorityscore=1501 suspectscore=0 adultscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 lowpriorityscore=0 impostorscore=0 mlxscore=0 malwarescore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2411180071 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Rename the main fastrpc source file to accomodate new files to be compiled in the same kernel object. Signed-off-by: Ekansh Gupta --- drivers/misc/fastrpc/Makefile | 1 + drivers/misc/fastrpc/{fastrpc.c => fastrpc_main.c} | 0 2 files changed, 1 insertion(+) rename drivers/misc/fastrpc/{fastrpc.c => fastrpc_main.c} (100%) diff --git a/drivers/misc/fastrpc/Makefile b/drivers/misc/fastrpc/Makefile index 77fd2b763b6b..020d30789a80 100644 --- a/drivers/misc/fastrpc/Makefile +++ b/drivers/misc/fastrpc/Makefile @@ -1,2 +1,3 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_QCOM_FASTRPC) += fastrpc.o +fastrpc-objs := fastrpc_main.o \ No newline at end of file diff --git a/drivers/misc/fastrpc/fastrpc.c b/drivers/misc/fastrpc/fastrpc_main.c similarity index 100% rename from drivers/misc/fastrpc/fastrpc.c rename to drivers/misc/fastrpc/fastrpc_main.c From patchwork Mon Nov 18 08:40:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ekansh Gupta X-Patchwork-Id: 13878303 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9767CD43FEE for ; Mon, 18 Nov 2024 08:41:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 06B9510E449; Mon, 18 Nov 2024 08:41:12 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=quicinc.com header.i=@quicinc.com header.b="B38gGp0y"; dkim-atps=neutral Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by gabe.freedesktop.org (Postfix) with ESMTPS id E257610E449 for ; Mon, 18 Nov 2024 08:41:10 +0000 (UTC) Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4AI5Rvo9009987; Mon, 18 Nov 2024 08:41:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= 0m0swi7dMzuPkzfVzknuzLvpMu3d39mlj69ZvYRt3o8=; b=B38gGp0yjl0JWeNu rNwgj1iPDZdgyazOIx90j8s8PKQN2yTR4B6vwxqMVUlagYVS7KJ406+15rsH9zaa Yp6VfRZANdYyO2lChn65l4qoKU1ikAS0dOUX3g7xw0NyVB4+vkBHyPRvvwlR04/1 Nxh5R5Gh6hR5rkBB32eLiQeiCV5YZ0fc/fXVWXk5Gi2YduNvxC+qDRR13EqLKkB3 rRWAJQRbf3cZHOnAir+1/aDxBoSKHIjs5IX6n38DPNjoBSdOyXl/KkoWNtcwGgH5 gtdgKn31julLRbS0botZsHpuvzIIvvUQY6UWm9py++2zelVrFBmVCtipwSRap/0+ UUaJvw== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 42xkrm3vvh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 Nov 2024 08:41:07 +0000 (GMT) Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA03.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 4AI8f6Re008054 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 Nov 2024 08:41:06 GMT Received: from hu-ekangupt-hyd.qualcomm.com (10.80.80.8) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Mon, 18 Nov 2024 00:41:03 -0800 From: Ekansh Gupta To: , CC: , , , , , Subject: [PATCH v1 3/4] misc: fastrpc: Introduce fastrpc_shared.h header Date: Mon, 18 Nov 2024 14:10:45 +0530 Message-ID: <20241118084046.3201290-4-quic_ekangupt@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241118084046.3201290-1-quic_ekangupt@quicinc.com> References: <20241118084046.3201290-1-quic_ekangupt@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: R12A47gJJ4yPqdq5m7fPXXjqFyvyuBih X-Proofpoint-ORIG-GUID: R12A47gJJ4yPqdq5m7fPXXjqFyvyuBih X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 phishscore=0 spamscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 impostorscore=0 clxscore=1015 bulkscore=0 priorityscore=1501 lowpriorityscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2411180071 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Move fastrpc structures and MACRO definitions to a new header file. These definitions are consumed by other upcoming features like debugfs, PDR support etc. Signed-off-by: Ekansh Gupta --- drivers/misc/fastrpc/fastrpc_main.c | 136 +--------------------- drivers/misc/fastrpc/fastrpc_shared.h | 155 ++++++++++++++++++++++++++ 2 files changed, 156 insertions(+), 135 deletions(-) create mode 100644 drivers/misc/fastrpc/fastrpc_shared.h diff --git a/drivers/misc/fastrpc/fastrpc_main.c b/drivers/misc/fastrpc/fastrpc_main.c index 74181b8c386b..3163b4159de7 100644 --- a/drivers/misc/fastrpc/fastrpc_main.c +++ b/drivers/misc/fastrpc/fastrpc_main.c @@ -22,6 +22,7 @@ #include #include #include +#include "fastrpc_shared.h" #define ADSP_DOMAIN_ID (0) #define MDSP_DOMAIN_ID (1) @@ -29,8 +30,6 @@ #define CDSP_DOMAIN_ID (3) #define CDSP1_DOMAIN_ID (4) #define FASTRPC_DEV_MAX 5 /* adsp, mdsp, slpi, cdsp, cdsp1 */ -#define FASTRPC_MAX_SESSIONS 14 -#define FASTRPC_MAX_VMIDS 16 #define FASTRPC_ALIGN 128 #define FASTRPC_MAX_FDLIST 16 #define FASTRPC_MAX_CRCLIST 64 @@ -55,9 +54,6 @@ #define ADSP_MMAP_ADD_PAGES_LLC 0x3000, #define DSP_UNSUPPORTED_API (0x80000414) -/* MAX NUMBER of DSP ATTRIBUTES SUPPORTED */ -#define FASTRPC_MAX_DSP_ATTRIBUTES (256) -#define FASTRPC_MAX_DSP_ATTRIBUTES_LEN (sizeof(u32) * FASTRPC_MAX_DSP_ATTRIBUTES) /* Retrives number of input buffers from the scalars parameter */ #define REMOTE_SCALARS_INBUFS(sc) (((sc) >> 16) & 0x0ff) @@ -118,22 +114,6 @@ struct fastrpc_invoke_buf { u32 pgidx; /* index to start of contiguous region */ }; -struct fastrpc_remote_dmahandle { - s32 fd; /* dma handle fd */ - u32 offset; /* dma handle offset */ - u32 len; /* dma handle length */ -}; - -struct fastrpc_remote_buf { - u64 pv; /* buffer pointer */ - u64 len; /* length of buffer */ -}; - -union fastrpc_remote_arg { - struct fastrpc_remote_buf buf; - struct fastrpc_remote_dmahandle dma; -}; - struct fastrpc_mmap_rsp_msg { u64 vaddr; }; @@ -168,16 +148,6 @@ struct fastrpc_mem_unmap_req_msg { u64 len; }; -struct fastrpc_msg { - int pid; /* process group id */ - int tid; /* thread id */ - u64 ctx; /* invoke caller context */ - u32 handle; /* handle to invoke */ - u32 sc; /* scalars structure describing the data */ - u64 addr; /* physical address */ - u64 size; /* size of contiguous region */ -}; - struct fastrpc_invoke_rsp { u64 ctx; /* invoke caller context */ int retval; /* invoke return value */ @@ -192,122 +162,18 @@ struct fastrpc_buf_overlap { u64 offset; }; -struct fastrpc_buf { - struct fastrpc_user *fl; - struct dma_buf *dmabuf; - struct device *dev; - void *virt; - u64 phys; - u64 size; - /* Lock for dma buf attachments */ - struct mutex lock; - struct list_head attachments; - /* mmap support */ - struct list_head node; /* list of user requested mmaps */ - uintptr_t raddr; -}; - struct fastrpc_dma_buf_attachment { struct device *dev; struct sg_table sgt; struct list_head node; }; -struct fastrpc_map { - struct list_head node; - struct fastrpc_user *fl; - int fd; - struct dma_buf *buf; - struct sg_table *table; - struct dma_buf_attachment *attach; - u64 phys; - u64 size; - void *va; - u64 len; - u64 raddr; - u32 attr; - struct kref refcount; -}; - -struct fastrpc_invoke_ctx { - int nscalars; - int nbufs; - int retval; - int pid; - int tgid; - u32 sc; - u32 *crc; - u64 ctxid; - u64 msg_sz; - struct kref refcount; - struct list_head node; /* list of ctxs */ - struct completion work; - struct work_struct put_work; - struct fastrpc_msg msg; - struct fastrpc_user *fl; - union fastrpc_remote_arg *rpra; - struct fastrpc_map **maps; - struct fastrpc_buf *buf; - struct fastrpc_invoke_args *args; - struct fastrpc_buf_overlap *olaps; - struct fastrpc_channel_ctx *cctx; -}; - -struct fastrpc_session_ctx { - struct device *dev; - int sid; - bool used; - bool valid; -}; - -struct fastrpc_channel_ctx { - int domain_id; - int sesscount; - int vmcount; - struct qcom_scm_vmperm vmperms[FASTRPC_MAX_VMIDS]; - struct rpmsg_device *rpdev; - struct fastrpc_session_ctx session[FASTRPC_MAX_SESSIONS]; - spinlock_t lock; - struct idr ctx_idr; - struct list_head users; - struct kref refcount; - /* Flag if dsp attributes are cached */ - bool valid_attributes; - u32 dsp_attributes[FASTRPC_MAX_DSP_ATTRIBUTES]; - struct fastrpc_device *secure_fdevice; - struct fastrpc_device *fdevice; - struct fastrpc_buf *remote_heap; - struct list_head invoke_interrupted_mmaps; - bool secure; - bool unsigned_support; - u64 dma_mask; -}; - struct fastrpc_device { struct fastrpc_channel_ctx *cctx; struct miscdevice miscdev; bool secure; }; -struct fastrpc_user { - struct list_head user; - struct list_head maps; - struct list_head pending; - struct list_head mmaps; - - struct fastrpc_channel_ctx *cctx; - struct fastrpc_session_ctx *sctx; - struct fastrpc_buf *init_mem; - - int tgid; - int pd; - bool is_secure_dev; - /* Lock for lists */ - spinlock_t lock; - /* lock for allocations */ - struct mutex mutex; -}; - static void fastrpc_free_map(struct kref *ref) { struct fastrpc_map *map; diff --git a/drivers/misc/fastrpc/fastrpc_shared.h b/drivers/misc/fastrpc/fastrpc_shared.h new file mode 100644 index 000000000000..8f1f1320a4c2 --- /dev/null +++ b/drivers/misc/fastrpc/fastrpc_shared.h @@ -0,0 +1,155 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +// Copyright (c) 2024 Qualcomm Innovation Center. +#ifndef FASTRPC_SHARED_H +#define FASTRPC_SHARED_H + +#include +#include +#include +#include +#include +#include + +#define FASTRPC_MAX_SESSIONS 14 +#define FASTRPC_MAX_VMIDS 16 +/* MAX NUMBER of DSP ATTRIBUTES SUPPORTED */ +#define FASTRPC_MAX_DSP_ATTRIBUTES (256) +#define FASTRPC_MAX_DSP_ATTRIBUTES_LEN (sizeof(u32) * FASTRPC_MAX_DSP_ATTRIBUTES) + +struct fastrpc_remote_dmahandle { + s32 fd; /* dma handle fd */ + u32 offset; /* dma handle offset */ + u32 len; /* dma handle length */ +}; + +struct fastrpc_remote_buf { + u64 pv; /* buffer pointer */ + u64 len; /* length of buffer */ +}; + +union fastrpc_remote_arg { + struct fastrpc_remote_buf buf; + struct fastrpc_remote_dmahandle dma; +}; + +struct fastrpc_buf { + struct fastrpc_user *fl; + struct dma_buf *dmabuf; + struct device *dev; + void *virt; + u64 phys; + u64 size; + /* Lock for dma buf attachments */ + struct mutex lock; + struct list_head attachments; + /* mmap support */ + struct list_head node; /* list of user requested mmaps */ + uintptr_t raddr; +}; + +struct fastrpc_map { + struct list_head node; + struct fastrpc_user *fl; + int fd; + struct dma_buf *buf; + struct sg_table *table; + struct dma_buf_attachment *attach; + u64 phys; + u64 size; + void *va; + u64 len; + u64 raddr; + u32 attr; + struct kref refcount; +}; + +struct fastrpc_msg { + int pid; /* process group id */ + int tid; /* thread id */ + u64 ctx; /* invoke caller context */ + u32 handle; /* handle to invoke */ + u32 sc; /* scalars structure describing the data */ + u64 addr; /* physical address */ + u64 size; /* size of contiguous region */ +}; + +struct fastrpc_invoke_ctx { + int nscalars; + int nbufs; + int retval; + int pid; + int tgid; + u32 sc; + u32 *crc; + u64 ctxid; + u64 msg_sz; + struct kref refcount; + struct list_head node; /* list of ctxs */ + struct completion work; + struct work_struct put_work; + struct fastrpc_msg msg; + struct fastrpc_user *fl; + union fastrpc_remote_arg *rpra; + struct fastrpc_map **maps; + struct fastrpc_buf *buf; + struct fastrpc_invoke_args *args; + struct fastrpc_buf_overlap *olaps; + struct fastrpc_channel_ctx *cctx; +}; + +struct fastrpc_session_ctx { + struct device *dev; + int sid; + bool used; + bool valid; +}; + +struct fastrpc_channel_ctx { + int domain_id; + int sesscount; + int vmcount; + struct qcom_scm_vmperm vmperms[FASTRPC_MAX_VMIDS]; + struct rpmsg_device *rpdev; + struct fastrpc_session_ctx session[FASTRPC_MAX_SESSIONS]; + spinlock_t lock; + struct idr ctx_idr; + struct list_head users; + struct kref refcount; + /* Flag if dsp attributes are cached */ + bool valid_attributes; + u32 dsp_attributes[FASTRPC_MAX_DSP_ATTRIBUTES]; + struct fastrpc_device *secure_fdevice; + struct fastrpc_device *fdevice; + struct fastrpc_buf *remote_heap; + struct list_head invoke_interrupted_mmaps; +#ifdef CONFIG_DEBUG_FS + struct dentry *debugfs_dir; +#endif + bool secure; + bool unsigned_support; + u64 dma_mask; +}; + +struct fastrpc_user { + struct list_head user; + struct list_head maps; + struct list_head pending; + struct list_head mmaps; + + struct fastrpc_channel_ctx *cctx; + struct fastrpc_session_ctx *sctx; + struct fastrpc_buf *init_mem; +#ifdef CONFIG_DEBUG_FS + struct dentry *debugfs_file; +#endif + + int tgid; + int pd; + bool is_secure_dev; + /* Lock for lists */ + spinlock_t lock; + /* lock for allocations */ + struct mutex mutex; +}; + +#endif /* FASTRPC_SHARED_H */ From patchwork Mon Nov 18 08:40:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ekansh Gupta X-Patchwork-Id: 13878304 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D8373D43FEE for ; Mon, 18 Nov 2024 08:41:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5E24710E447; Mon, 18 Nov 2024 08:41:15 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=quicinc.com header.i=@quicinc.com header.b="Zb1tv4x7"; dkim-atps=neutral Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by gabe.freedesktop.org (Postfix) with ESMTPS id C49A410E457 for ; Mon, 18 Nov 2024 08:41:13 +0000 (UTC) Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4AI5Rlxc029827; Mon, 18 Nov 2024 08:41:10 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= xy5PIP3I7fbqbc+XP6ixF3R71g+nuJKoFcx8cA/dNAE=; b=Zb1tv4x7nC6E630U LfHn3SvX/3tVFpcOeMrOS54xoMpZSMTwMAzV98S17gp5/pekQrINTKD3cgxU4vdG 9fuMAIfpL3Jv4/p2liWoJILQnzRQhPMtfPbJ8OQv8b/fryBqLhLnx1dTq7q3SkCP EYmd0wt5rqFgGI3G81RSZRBykjHJjSpO8DLAfG55rNgAPBUB0Ysyqzgg/tQbTHgf gOGFASsLE/p+SiYO/9rY3WW9cHzst9a4SzYnNF6O+tSYwF2p4angkmfDnT2QFlN7 50YPgtNbB/UF7sxkME+Ep6AbC5SB+oPW4NI8V2N6rbM90N1c72hN9QoBO4nm9Nqp oe63Kg== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 42xkv3bvg3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 Nov 2024 08:41:10 +0000 (GMT) Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA02.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 4AI8f9ki015416 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 Nov 2024 08:41:09 GMT Received: from hu-ekangupt-hyd.qualcomm.com (10.80.80.8) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Mon, 18 Nov 2024 00:41:06 -0800 From: Ekansh Gupta To: , CC: , , , , , Subject: [PATCH v1 4/4] misc: fastrpc: Add debugfs support for fastrpc Date: Mon, 18 Nov 2024 14:10:46 +0530 Message-ID: <20241118084046.3201290-5-quic_ekangupt@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241118084046.3201290-1-quic_ekangupt@quicinc.com> References: <20241118084046.3201290-1-quic_ekangupt@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: G5kKoCpMDsdr67yZAxIdkZ0su9jWNC0E X-Proofpoint-GUID: G5kKoCpMDsdr67yZAxIdkZ0su9jWNC0E X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 bulkscore=0 impostorscore=0 spamscore=0 lowpriorityscore=0 phishscore=0 malwarescore=0 clxscore=1015 mlxscore=0 suspectscore=0 priorityscore=1501 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2411180071 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add changes to support debugfs. The fastrpc directory will be created which will carry debugfs files for all fastrpc processes. The information of fastrpc user and channel contexts are getting captured as part of this change. Signed-off-by: Ekansh Gupta --- drivers/misc/fastrpc/Makefile | 3 +- drivers/misc/fastrpc/fastrpc_debug.c | 156 +++++++++++++++++++++++++++ drivers/misc/fastrpc/fastrpc_debug.h | 31 ++++++ drivers/misc/fastrpc/fastrpc_main.c | 18 +++- 4 files changed, 205 insertions(+), 3 deletions(-) create mode 100644 drivers/misc/fastrpc/fastrpc_debug.c create mode 100644 drivers/misc/fastrpc/fastrpc_debug.h diff --git a/drivers/misc/fastrpc/Makefile b/drivers/misc/fastrpc/Makefile index 020d30789a80..4ff6b64166ae 100644 --- a/drivers/misc/fastrpc/Makefile +++ b/drivers/misc/fastrpc/Makefile @@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_QCOM_FASTRPC) += fastrpc.o -fastrpc-objs := fastrpc_main.o \ No newline at end of file +fastrpc-objs := fastrpc_main.o \ + fastrpc_debug.o diff --git a/drivers/misc/fastrpc/fastrpc_debug.c b/drivers/misc/fastrpc/fastrpc_debug.c new file mode 100644 index 000000000000..cdb4fc6845a8 --- /dev/null +++ b/drivers/misc/fastrpc/fastrpc_debug.c @@ -0,0 +1,156 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (c) 2024 Qualcomm Innovation Center. + +#include +#include +#include "fastrpc_shared.h" +#include "fastrpc_debug.h" + +#ifdef CONFIG_DEBUG_FS + +static void print_buf_info(struct seq_file *s_file, struct fastrpc_buf *buf) +{ + seq_printf(s_file, "\n %s %2s 0x%p", "virt", ":", buf->virt); + seq_printf(s_file, "\n %s %2s 0x%llx", "phys", ":", buf->phys); + seq_printf(s_file, "\n %s %2s 0x%lx", "raddr", ":", buf->raddr); + seq_printf(s_file, "\n %s %2s 0x%llx", "size", ":", buf->size); +} + +static void print_ctx_info(struct seq_file *s_file, struct fastrpc_invoke_ctx *ctx) +{ + seq_printf(s_file, "\n %s %7s %d", "nscalars", ":", ctx->nscalars); + seq_printf(s_file, "\n %s %10s %d", "nbufs", ":", ctx->nbufs); + seq_printf(s_file, "\n %s %10s %d", "retval", ":", ctx->retval); + seq_printf(s_file, "\n %s %12s %p", "crc", ":", ctx->crc); + seq_printf(s_file, "\n %s %12s %d", "pid", ":", ctx->pid); + seq_printf(s_file, "\n %s %11s %d", "tgid", ":", ctx->tgid); + seq_printf(s_file, "\n %s %13s 0x%x", "sc", ":", ctx->sc); + seq_printf(s_file, "\n %s %10s %llu", "ctxid", ":", ctx->ctxid); + seq_printf(s_file, "\n %s %9s %llu", "msg_sz", ":", ctx->msg_sz); +} + +static void print_sctx_info(struct seq_file *s_file, struct fastrpc_session_ctx *sctx) +{ + seq_printf(s_file, "%s %13s %d\n", "sid", ":", sctx->sid); + seq_printf(s_file, "%s %12s %d\n", "used", ":", sctx->used); + seq_printf(s_file, "%s %11s %d\n", "valid", ":", sctx->valid); +} + +static void print_cctx_info(struct seq_file *s_file, struct fastrpc_channel_ctx *cctx) +{ + seq_printf(s_file, "%s %8s %d\n", "domain_id", ":", cctx->domain_id); + seq_printf(s_file, "%s %8s %d\n", "sesscount", ":", cctx->sesscount); + seq_printf(s_file, "%s %10s %d\n", "vmcount", ":", cctx->vmcount); + seq_printf(s_file, "%s %s %d\n", "valid_attributes", ":", cctx->valid_attributes); + seq_printf(s_file, "%s %11s %d\n", "secure", ":", cctx->secure); + seq_printf(s_file, "%s %s %d\n", "unsigned_support", ":", cctx->unsigned_support); +} + +static void print_map_info(struct seq_file *s_file, struct fastrpc_map *map) +{ + seq_printf(s_file, "%s %4s %d\n", "fd", ":", map->fd); + seq_printf(s_file, "%s %s 0x%llx\n", "phys", ":", map->phys); + seq_printf(s_file, "%s %s 0x%llx\n", "size", ":", map->size); + seq_printf(s_file, "%s %4s 0x%p\n", "va", ":", map->va); + seq_printf(s_file, "%s %3s 0x%llx\n", "len", ":", map->len); + seq_printf(s_file, "%s %2s 0x%llx\n", "raddr", ":", map->raddr); + seq_printf(s_file, "%s %2s 0x%x\n", "attr", ":", map->attr); +} + +static int fastrpc_debugfs_show(struct seq_file *s_file, void *data) +{ + struct fastrpc_user *fl = s_file->private; + struct fastrpc_map *map; + struct fastrpc_channel_ctx *cctx; + struct fastrpc_session_ctx *sctx = NULL; + struct fastrpc_invoke_ctx *ctx, *m; + struct fastrpc_buf *buf; + + if (fl != NULL) { + seq_printf(s_file, "%s %12s %d\n", "tgid", ":", fl->tgid); + seq_printf(s_file, "%s %3s %d\n", "is_secure_dev", ":", fl->is_secure_dev); + seq_printf(s_file, "%s %9s %d\n", "pd_type", ":", fl->pd); + + if (fl->cctx) { + seq_puts(s_file, "\n=============== Channel Context ===============\n"); + cctx = fl->cctx; + print_cctx_info(s_file, cctx); + } + if (fl->sctx) { + seq_puts(s_file, "\n=============== Session Context ===============\n"); + sctx = fl->sctx; + print_sctx_info(s_file, sctx); + } + spin_lock(&fl->lock); + if (fl->init_mem) { + seq_puts(s_file, "\n=============== Init Mem ===============\n"); + buf = fl->init_mem; + print_buf_info(s_file, buf); + } + spin_unlock(&fl->lock); + seq_puts(s_file, "\n=============== User space maps ===============\n"); + spin_lock(&fl->lock); + list_for_each_entry(map, &fl->maps, node) { + if (map) + print_map_info(s_file, map); + } + seq_puts(s_file, "\n=============== Kernel allocated buffers ===============\n"); + list_for_each_entry(map, &fl->mmaps, node) { + if (map) + print_map_info(s_file, map); + } + seq_puts(s_file, "\n=============== Pending contexts ===============\n"); + list_for_each_entry_safe(ctx, m, &fl->pending, node) { + if (ctx) + print_ctx_info(s_file, ctx); + } + spin_unlock(&fl->lock); + } + return 0; +} + +DEFINE_SHOW_ATTRIBUTE(fastrpc_debugfs); + +void fastrpc_create_user_debugfs(struct fastrpc_user *fl) +{ + char cur_comm[TASK_COMM_LEN]; + int domain_id, size; + char *debugfs_buf; + struct dentry *debugfs_dir = fl->cctx->debugfs_dir; + + memcpy(cur_comm, current->comm, TASK_COMM_LEN); + cur_comm[TASK_COMM_LEN-1] = '\0'; + if (debugfs_dir != NULL) { + domain_id = fl->cctx->domain_id; + size = snprintf(NULL, 0, "%.10s_%d_%d_%d", cur_comm, + current->pid, fl->tgid, domain_id) + 1; + debugfs_buf = kzalloc(size, GFP_KERNEL); + if (debugfs_buf == NULL) + return; + /* + * Use HLOS process name, HLOS PID, fastrpc user TGID, + * domain_id in debugfs filename to create unique file name + */ + snprintf(debugfs_buf, size, "%.10s_%d_%d_%d", + cur_comm, current->pid, fl->tgid, domain_id); + fl->debugfs_file = debugfs_create_file(debugfs_buf, 0644, + debugfs_dir, fl, &fastrpc_debugfs_fops); + kfree(debugfs_buf); + } +} + +void fastrpc_remove_user_debugfs(struct fastrpc_user *fl) +{ + debugfs_remove(fl->debugfs_file); +} + +struct dentry *fastrpc_create_debugfs_dir(const char *name) +{ + return debugfs_create_dir(name, NULL); +} + +void fastrpc_remove_debugfs_dir(struct dentry *cctx_debugfs) +{ + debugfs_remove_recursive(cctx_debugfs); +} +#endif diff --git a/drivers/misc/fastrpc/fastrpc_debug.h b/drivers/misc/fastrpc/fastrpc_debug.h new file mode 100644 index 000000000000..916a5c668308 --- /dev/null +++ b/drivers/misc/fastrpc/fastrpc_debug.h @@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +// Copyright (c) 2024 Qualcomm Innovation Center. +#ifndef FASTRPC_DEBUG_H +#define FASTRPC_DEBUG_H + +#include +#include "fastrpc_shared.h" +#include "fastrpc_debug.h" + +#define DEBUGFS_DIRLEN 16 +#ifdef CONFIG_DEBUG_FS +void fastrpc_create_user_debugfs(struct fastrpc_user *fl); +void fastrpc_remove_user_debugfs(struct fastrpc_user *fl); +struct dentry *fastrpc_create_debugfs_dir(const char *name); +void fastrpc_remove_debugfs_dir(struct dentry *cctx_debugfs); +#else +static inline void fastrpc_create_user_debugfs(struct fastrpc_user *fl) +{ +} +static inline void fastrpc_remove_user_debugfs(struct fastrpc_user *fl) +{ +} +static inline struct dentry *fastrpc_create_debugfs_dir(const char *name) +{ + return NULL; +} +static inline void fastrpc_remove_debugfs_dir(struct dentry *cctx_debugfs) +{ +} +#endif /* CONFIG_DEBUG_FS */ +#endif /* FASTRPC_DEBUG_H */ diff --git a/drivers/misc/fastrpc/fastrpc_main.c b/drivers/misc/fastrpc/fastrpc_main.c index 3163b4159de7..f758af1d2f8e 100644 --- a/drivers/misc/fastrpc/fastrpc_main.c +++ b/drivers/misc/fastrpc/fastrpc_main.c @@ -23,6 +23,7 @@ #include #include #include "fastrpc_shared.h" +#include "fastrpc_debug.h" #define ADSP_DOMAIN_ID (0) #define MDSP_DOMAIN_ID (1) @@ -1185,6 +1186,7 @@ static int fastrpc_init_create_static_process(struct fastrpc_user *fl, sc, args); if (err) goto err_invoke; + fastrpc_create_user_debugfs(fl); kfree(args); kfree(name); @@ -1318,6 +1320,7 @@ static int fastrpc_init_create_process(struct fastrpc_user *fl, sc, args); if (err) goto err_invoke; + fastrpc_create_user_debugfs(fl); kfree(args); @@ -1412,6 +1415,7 @@ static int fastrpc_device_release(struct inode *inode, struct file *file) } fastrpc_session_free(cctx, fl->sctx); + fastrpc_remove_user_debugfs(fl); fastrpc_channel_ctx_put(cctx); mutex_destroy(&fl->mutex); @@ -1513,7 +1517,7 @@ static int fastrpc_dmabuf_alloc(struct fastrpc_user *fl, char __user *argp) static int fastrpc_init_attach(struct fastrpc_user *fl, int pd) { struct fastrpc_invoke_args args[1]; - int tgid = fl->tgid; + int err, tgid = fl->tgid; u32 sc; args[0].ptr = (u64)(uintptr_t) &tgid; @@ -1522,8 +1526,13 @@ static int fastrpc_init_attach(struct fastrpc_user *fl, int pd) sc = FASTRPC_SCALARS(FASTRPC_RMID_INIT_ATTACH, 1, 0); fl->pd = pd; - return fastrpc_internal_invoke(fl, true, FASTRPC_INIT_HANDLE, + err = fastrpc_internal_invoke(fl, true, FASTRPC_INIT_HANDLE, sc, &args[0]); + if (err) + return err; + fastrpc_create_user_debugfs(fl); + + return 0; } static int fastrpc_invoke(struct fastrpc_user *fl, char __user *argp) @@ -2125,6 +2134,7 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev) struct fastrpc_channel_ctx *data; int i, err, domain_id = -1, vmcount; const char *domain; + char dir_name[DEBUGFS_DIRLEN]; bool secure_dsp; struct device_node *rmem_node; struct reserved_mem *rmem; @@ -2228,6 +2238,8 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev) idr_init(&data->ctx_idr); data->domain_id = domain_id; data->rpdev = rpdev; + snprintf(dir_name, sizeof(dir_name), "%s_%s", "fastrpc", domain); + data->debugfs_dir = fastrpc_create_debugfs_dir(dir_name); err = of_platform_populate(rdev->of_node, NULL, NULL, rdev); if (err) @@ -2284,6 +2296,8 @@ static void fastrpc_rpmsg_remove(struct rpmsg_device *rpdev) if (cctx->remote_heap) fastrpc_buf_free(cctx->remote_heap); + fastrpc_remove_debugfs_dir(cctx->debugfs_dir); + of_platform_depopulate(&rpdev->dev); fastrpc_channel_ctx_put(cctx);