Message ID | 1695973360-14369-3-git-send-email-quic_ekangupt@quicinc.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp4211376vqu; Fri, 29 Sep 2023 10:58:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFLM6aNxk95NY7zk3aDG47/QLumgABI3PanwOaWYQNegwWrZ56xcyz0nlUHtGYp2he7AhiT X-Received: by 2002:a05:6a20:549c:b0:14c:d494:77d1 with SMTP id i28-20020a056a20549c00b0014cd49477d1mr5609322pzk.10.1696010302350; Fri, 29 Sep 2023 10:58:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696010302; cv=none; d=google.com; s=arc-20160816; b=zoCiVXoYqZ86MLJujHLxFNEh7zGKa7IuQ6xTZgCS45NDlILAUJNP/NvpEaP+aOD3gz AYALAdHirEJwvEbdWz8FhIH0t9jB9THWba560UA63hGE1+Bi7azqdlBMjeffQb/J7LJX IxfHtvynifqPaS2VnZozT6Itd3gL+DkZhVGKtZmzaV4j3sVnwBJou3srfRQLuE6IPu9n Apsb5QT71a9YcYJSmmbX3O+P2AZCY7rmhVep32WrdRPoROS7ef0gayIbvf1qzQauETZJ sh5mjKUeNQINhVBq6H56jfKQ67veu0zwXcbxxGK3dDL16HQptI2nVOkPMonlII7L59ux SwHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=JnvGPfam0j++dYMYQFm6Fq6OnF+GhvPcHneOtNp3o/Q=; fh=A6NNGgejDd0F81I6I/9zWdWOtBqD0woImsi6PTqxbkw=; b=soPqxKnO2jTvSEZp/GFqk1ciGwFeTVwOqpTQfYo4WPguSe8MCsVGj/i8T0kHEVuPGg R5vID6inaIqkyHojYC+sI539deh7kJYN8rkBTyAFcrqjkp1uc62fF+8ckNItNVPQOYVm 2ACUgg5SPfPc0KVcAxGK6OVmDcx7MvzesxwW3glFnqem3SCE9aUJkYIAu3fAFK2yiJid NkcfdGSuNmyd62HQOJ60tkto5bD6Ge2OScZXHcC9o3Gah0g1UNAZf7lhAys4MLtQWsu3 P7OT0J3YBp7SxdgNoE/KDWQGkSZa3bE1IiJegK+tZf/90v53rydRgKNuwmPWQwne1Eu1 ma0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=JlSyg4hX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id n12-20020a170902d2cc00b001b829a32f2dsi23212444plc.457.2023.09.29.10.58.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 10:58:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=JlSyg4hX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id BA66480FA869; Fri, 29 Sep 2023 00:43:22 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232779AbjI2HnF (ORCPT <rfc822;pwkd43@gmail.com> + 20 others); Fri, 29 Sep 2023 03:43:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232772AbjI2HnB (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 29 Sep 2023 03:43:01 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32F351B3; Fri, 29 Sep 2023 00:42:59 -0700 (PDT) Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38T7FrGp025017; Fri, 29 Sep 2023 07:42:55 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=JnvGPfam0j++dYMYQFm6Fq6OnF+GhvPcHneOtNp3o/Q=; b=JlSyg4hXf7vy2PgbI0GhKucm6zvBiHeXWf1+ugmXkWEzDwqnaTV0ypxZoHfw7jtJLshi xgkCUBzgfyB/O8xZz0YI4mHulG7LfaJzfg0531BQnBRmICqjtXGThcv1TkTBzQy1llv7 R/qPtrG7cl6/SFSJQ0rlyKafKDxDU9cpLCxu7DNvQ0Kb+wAp4QrTwmfCsKFYQb6sm6/Y xMbZKUfyiVrT546shTtFIy5n6VZaGrB3YuLTS11v0txa9/9f682fEdQR76oN6liC+jJz K8M+oewHhlRGLnXLq8ks584KK8nrISac0UuB3X44wMOwQsT+fB8pQxcQWPtmoV/4IzEv lA== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3td5se2bvw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 29 Sep 2023 07:42:55 +0000 Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 38T7gsk2021131 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 29 Sep 2023 07:42:54 GMT Received: from ekangupt-linux.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.1118.36; Fri, 29 Sep 2023 00:42:50 -0700 From: Ekansh Gupta <quic_ekangupt@quicinc.com> To: <srinivas.kandagatla@linaro.org>, <linux-arm-msm@vger.kernel.org> CC: Ekansh Gupta <quic_ekangupt@quicinc.com>, <ekangupt@qti.qualcomm.com>, <gregkh@linuxfoundation.org>, <linux-kernel@vger.kernel.org>, <fastrpc.upstream@qti.qualcomm.com>, stable <stable@kernel.org> Subject: [PATCH v1 2/3] misc: fastrpc: Free DMA handles for RPC calls with no arguments Date: Fri, 29 Sep 2023 13:12:39 +0530 Message-ID: <1695973360-14369-3-git-send-email-quic_ekangupt@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1695973360-14369-1-git-send-email-quic_ekangupt@quicinc.com> References: <1695973360-14369-1-git-send-email-quic_ekangupt@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain 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: 5-oN3xOW69dh9HyhGz1AHXbsTnSK5KGY X-Proofpoint-GUID: 5-oN3xOW69dh9HyhGz1AHXbsTnSK5KGY X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-09-29_05,2023-09-28_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 spamscore=0 suspectscore=0 impostorscore=0 malwarescore=0 priorityscore=1501 clxscore=1015 bulkscore=0 mlxlogscore=999 adultscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2309290064 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 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 29 Sep 2023 00:43:22 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778395698855674687 X-GMAIL-MSGID: 1778395698855674687 |
Series |
Add fixes for FastRPC driver
|
|
Commit Message
Ekansh Gupta
Sept. 29, 2023, 7:42 a.m. UTC
The FDs for DMA handles to be freed is updated in fdlist by DSP over
a remote call. This holds true even for remote calls with no
arguments. To handle this, get_args and put_args are needed to
be called for remote calls with no arguments also as fdlist
is allocated in get_args and FDs updated in fdlist is freed
in put_args.
Fixes: 8f6c1d8c4f0c ("misc: fastrpc: Add fdlist implementation")
Cc: stable <stable@kernel.org>
Signed-off-by: Ekansh Gupta <quic_ekangupt@quicinc.com>
---
drivers/misc/fastrpc.c | 23 ++++++++++-------------
1 file changed, 10 insertions(+), 13 deletions(-)
Comments
On 29/09/2023 08:42, Ekansh Gupta wrote: > The FDs for DMA handles to be freed is updated in fdlist by DSP over > a remote call. This holds true even for remote calls with no > arguments. To handle this, get_args and put_args are needed to > be called for remote calls with no arguments also as fdlist > is allocated in get_args and FDs updated in fdlist is freed > in put_args. > > Fixes: 8f6c1d8c4f0c ("misc: fastrpc: Add fdlist implementation") > Cc: stable <stable@kernel.org> > Signed-off-by: Ekansh Gupta <quic_ekangupt@quicinc.com> > --- > drivers/misc/fastrpc.c | 23 ++++++++++------------- > 1 file changed, 10 insertions(+), 13 deletions(-) > > diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c > index fb92197..a52701c 100644 > --- a/drivers/misc/fastrpc.c > +++ b/drivers/misc/fastrpc.c > @@ -1091,6 +1091,7 @@ static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx, > } > } > > + /* Clean up fdlist which is updated by DSP */ > for (i = 0; i < FASTRPC_MAX_FDLIST; i++) { > if (!fdlist[i]) > break; > @@ -1157,11 +1158,9 @@ static int fastrpc_internal_invoke(struct fastrpc_user *fl, u32 kernel, > if (IS_ERR(ctx)) > return PTR_ERR(ctx); > <--- > - if (ctx->nscalars) { > - err = fastrpc_get_args(kernel, ctx); > - if (err) > - goto bail; > - } > + err = fastrpc_get_args(kernel, ctx); > + if (err) > + goto bail; --> I dont see any point of the above change as fastrpc_internal_invoke will be called from kernel with nscalars always set. do you see a path that does not set this? --srini > > /* make sure that all CPU memory writes are seen by DSP */ > dma_wmb(); > @@ -1185,14 +1184,12 @@ static int fastrpc_internal_invoke(struct fastrpc_user *fl, u32 kernel, > if (err) > goto bail; > > - if (ctx->nscalars) { > - /* make sure that all memory writes by DSP are seen by CPU */ > - dma_rmb(); > - /* populate all the output buffers with results */ > - err = fastrpc_put_args(ctx, kernel); > - if (err) > - goto bail; > - } > + /* make sure that all memory writes by DSP are seen by CPU */ > + dma_rmb(); > + /* populate all the output buffers with results */ > + err = fastrpc_put_args(ctx, kernel); > + if (err) > + goto bail; > > bail: > if (err != -ERESTARTSYS && err != -ETIMEDOUT) {
On 10/2/2023 3:00 PM, Srinivas Kandagatla wrote: > > > On 29/09/2023 08:42, Ekansh Gupta wrote: >> The FDs for DMA handles to be freed is updated in fdlist by DSP over >> a remote call. This holds true even for remote calls with no >> arguments. To handle this, get_args and put_args are needed to >> be called for remote calls with no arguments also as fdlist >> is allocated in get_args and FDs updated in fdlist is freed >> in put_args. >> >> Fixes: 8f6c1d8c4f0c ("misc: fastrpc: Add fdlist implementation") >> Cc: stable <stable@kernel.org> >> Signed-off-by: Ekansh Gupta <quic_ekangupt@quicinc.com> >> --- >> drivers/misc/fastrpc.c | 23 ++++++++++------------- >> 1 file changed, 10 insertions(+), 13 deletions(-) >> >> diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c >> index fb92197..a52701c 100644 >> --- a/drivers/misc/fastrpc.c >> +++ b/drivers/misc/fastrpc.c >> @@ -1091,6 +1091,7 @@ static int fastrpc_put_args(struct >> fastrpc_invoke_ctx *ctx, >> } >> } >> + /* Clean up fdlist which is updated by DSP */ >> for (i = 0; i < FASTRPC_MAX_FDLIST; i++) { >> if (!fdlist[i]) >> break; >> @@ -1157,11 +1158,9 @@ static int fastrpc_internal_invoke(struct >> fastrpc_user *fl, u32 kernel, >> if (IS_ERR(ctx)) >> return PTR_ERR(ctx); > <--- >> - if (ctx->nscalars) { >> - err = fastrpc_get_args(kernel, ctx); >> - if (err) >> - goto bail; >> - } >> + err = fastrpc_get_args(kernel, ctx); >> + if (err) >> + goto bail; > --> > I dont see any point of the above change as fastrpc_internal_invoke will > be called from kernel with nscalars always set. > > do you see a path that does not set this? > The context specific rpra buffer is allocated as part of fastrpc_get_args and there is a possibility that the DSP intends to update fdlist for a call with 0 nscalars. In that scenario, the driver needs to ensure that the rpra is allocated which will carry the fdlist. The same can be extended to crc and dsp perf memory(to be added, patches shared for missing features) for remote calls with 0 nscalars. Thanks for taking your time to review the patches Srini, please let me know if you have more queries. -ekansh > --srini >> /* make sure that all CPU memory writes are seen by DSP */ >> dma_wmb(); >> @@ -1185,14 +1184,12 @@ static int fastrpc_internal_invoke(struct >> fastrpc_user *fl, u32 kernel, >> if (err) >> goto bail; >> - if (ctx->nscalars) { >> - /* make sure that all memory writes by DSP are seen by CPU */ >> - dma_rmb(); >> - /* populate all the output buffers with results */ >> - err = fastrpc_put_args(ctx, kernel); >> - if (err) >> - goto bail; >> - } >> + /* make sure that all memory writes by DSP are seen by CPU */ >> + dma_rmb(); >> + /* populate all the output buffers with results */ >> + err = fastrpc_put_args(ctx, kernel); >> + if (err) >> + goto bail; >> bail: >> if (err != -ERESTARTSYS && err != -ETIMEDOUT) {
On 03/10/2023 12:07, Ekansh Gupta wrote: > > > On 10/2/2023 3:00 PM, Srinivas Kandagatla wrote: >> >> >> On 29/09/2023 08:42, Ekansh Gupta wrote: >>> The FDs for DMA handles to be freed is updated in fdlist by DSP over >>> a remote call. This holds true even for remote calls with no >>> arguments. To handle this, get_args and put_args are needed to >>> be called for remote calls with no arguments also as fdlist >>> is allocated in get_args and FDs updated in fdlist is freed >>> in put_args. >>> >>> Fixes: 8f6c1d8c4f0c ("misc: fastrpc: Add fdlist implementation") >>> Cc: stable <stable@kernel.org> >>> Signed-off-by: Ekansh Gupta <quic_ekangupt@quicinc.com> >>> --- >>> drivers/misc/fastrpc.c | 23 ++++++++++------------- >>> 1 file changed, 10 insertions(+), 13 deletions(-) >>> >>> diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c >>> index fb92197..a52701c 100644 >>> --- a/drivers/misc/fastrpc.c >>> +++ b/drivers/misc/fastrpc.c >>> @@ -1091,6 +1091,7 @@ static int fastrpc_put_args(struct >>> fastrpc_invoke_ctx *ctx, >>> } >>> } >>> + /* Clean up fdlist which is updated by DSP */ >>> for (i = 0; i < FASTRPC_MAX_FDLIST; i++) { >>> if (!fdlist[i]) >>> break; >>> @@ -1157,11 +1158,9 @@ static int fastrpc_internal_invoke(struct >>> fastrpc_user *fl, u32 kernel, >>> if (IS_ERR(ctx)) >>> return PTR_ERR(ctx); >> <--- >>> - if (ctx->nscalars) { >>> - err = fastrpc_get_args(kernel, ctx); >>> - if (err) >>> - goto bail; >>> - } >>> + err = fastrpc_get_args(kernel, ctx); >>> + if (err) >>> + goto bail; >> --> >> I dont see any point of the above change as fastrpc_internal_invoke >> will be called from kernel with nscalars always set. >> >> do you see a path that does not set this? >> > The context specific rpra buffer is allocated as part of > fastrpc_get_args and there is a possibility that the DSP intends to > update fdlist for a call with 0 nscalars. In that scenario, the driver > needs to ensure that the rpra is allocated which will carry the fdlist. > The same can be extended to crc and dsp perf memory(to be added, patches > shared for missing features) for remote calls with 0 nscalars. > Yes, we need this to setup remote args. thanks srini > Thanks for taking your time to review the patches Srini, please let me > know if you have more queries. > > -ekansh >> --srini >>> /* make sure that all CPU memory writes are seen by DSP */ >>> dma_wmb(); >>> @@ -1185,14 +1184,12 @@ static int fastrpc_internal_invoke(struct >>> fastrpc_user *fl, u32 kernel, >>> if (err) >>> goto bail; >>> - if (ctx->nscalars) { >>> - /* make sure that all memory writes by DSP are seen by CPU */ >>> - dma_rmb(); >>> - /* populate all the output buffers with results */ >>> - err = fastrpc_put_args(ctx, kernel); >>> - if (err) >>> - goto bail; >>> - } >>> + /* make sure that all memory writes by DSP are seen by CPU */ >>> + dma_rmb(); >>> + /* populate all the output buffers with results */ >>> + err = fastrpc_put_args(ctx, kernel); >>> + if (err) >>> + goto bail; >>> bail: >>> if (err != -ERESTARTSYS && err != -ETIMEDOUT) {
diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index fb92197..a52701c 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -1091,6 +1091,7 @@ static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx, } } + /* Clean up fdlist which is updated by DSP */ for (i = 0; i < FASTRPC_MAX_FDLIST; i++) { if (!fdlist[i]) break; @@ -1157,11 +1158,9 @@ static int fastrpc_internal_invoke(struct fastrpc_user *fl, u32 kernel, if (IS_ERR(ctx)) return PTR_ERR(ctx); - if (ctx->nscalars) { - err = fastrpc_get_args(kernel, ctx); - if (err) - goto bail; - } + err = fastrpc_get_args(kernel, ctx); + if (err) + goto bail; /* make sure that all CPU memory writes are seen by DSP */ dma_wmb(); @@ -1185,14 +1184,12 @@ static int fastrpc_internal_invoke(struct fastrpc_user *fl, u32 kernel, if (err) goto bail; - if (ctx->nscalars) { - /* make sure that all memory writes by DSP are seen by CPU */ - dma_rmb(); - /* populate all the output buffers with results */ - err = fastrpc_put_args(ctx, kernel); - if (err) - goto bail; - } + /* make sure that all memory writes by DSP are seen by CPU */ + dma_rmb(); + /* populate all the output buffers with results */ + err = fastrpc_put_args(ctx, kernel); + if (err) + goto bail; bail: if (err != -ERESTARTSYS && err != -ETIMEDOUT) {