From patchwork Tue Nov 14 05:27:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qiang Yu X-Patchwork-Id: 164735 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp1660004vqg; Mon, 13 Nov 2023 21:29:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IFwBLVSVeiEuh9d2/yVgV+pLOqgmQA6eSlL0S4aym4/9FE7Box2vLL4jJdndWBK8QJp0q7M X-Received: by 2002:a25:3290:0:b0:d9b:dae4:63fa with SMTP id y138-20020a253290000000b00d9bdae463famr7621599yby.34.1699939788712; Mon, 13 Nov 2023 21:29:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699939788; cv=none; d=google.com; s=arc-20160816; b=aUne/KfIViBk4wheEystKmh3qDl8ycqTFA1XIj1virHe6aNY4QGUnoHzGVjd8gZkEZ 6tCPji4wTnmbUTDdk/Rhb/mGp1OnrrkuWb0Nrh68ofuLVcgWlj4rDe6hsffD80WwM7pd iKkQqXLWQCBBrkJ/+WqIHUaUyQr87LNRdT3HQZUGW9nguY4SamqjcdHTITh2f8gKtfmA Bx/hmNh/G4ivHgXd0iSCj5RZpkujiSKsCnhEcH6051dhrc6cUOS2n6lpnLK4lOzc6xJz 6USZuoHuZCR/ABd7xbYiohARfjL+FJW8R2DM5eruF7Yx+BuSlfXT/08nF4waPM6HahwE Hg0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=vi+ivIzdj5lz69ubLpbSMW3Cjsd+LFLFD/vSlhgdYaY=; fh=7y8XBjHEOFaIi1bWwlOqynzp3kMu6S1xEU1Lbig9USo=; b=AjXbuuzTf1JjKib3h8mZn/KcVA1vCAWR4F112O/nVVKXDgT57BN3Jbm5JlOwpTNNFk 60irvmXTqIodLfLeoDaQZlhR4zqdl49VOycbbtqvfUGfhs65o6BX7jrhm9Mm+oRNA01h hp6MgzQhJsrGIsiGDf5jTi/E/L6mopGgcZYLNj6doMy7hAbipB2voQL4U3B5bgvcUEyh QR2lmvkk2zyR76hp/ylreXv5F4Pt5YOl+plLPLdFoybpzrMu0PQpuCaRAxqqU3BNGCsA l2fscRPwgLUvwzkofibfDLOtqEEk89BmUSUhVe5t75KHbYsuBLYrdcLiyEbroRkj6Zle 5lqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Fi2OqVch; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id bd33-20020a056a0027a100b006c382648737si7321022pfb.115.2023.11.13.21.29.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 21:29:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Fi2OqVch; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 5017180ADEE7; Mon, 13 Nov 2023 21:29:42 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232220AbjKNF2y (ORCPT + 30 others); Tue, 14 Nov 2023 00:28:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232386AbjKNF22 (ORCPT ); Tue, 14 Nov 2023 00:28:28 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F4D4171A; Mon, 13 Nov 2023 21:28:20 -0800 (PST) Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AE52Ocf022800; Tue, 14 Nov 2023 05:27:46 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; s=qcppdkim1; bh=vi+ivIzdj5lz69ubLpbSMW3Cjsd+LFLFD/vSlhgdYaY=; b=Fi2OqVchCBJXH82l59S/tB4JYgK6UMkuBOoXjtKzO5+oBstJ5P23AR99cpz3S0jhu/WX uuhGNcLIRdp3LTMpSHa47nBLWUEQ0it9VaP4y1iETjONZRmNG6DLxJ5y7qAmMIg/fx6Y atqyHcCS0nqvzPFzrz83AauQI/OKvH36yLYjEZ37aFM3R3IlvlWGuFOzbCHTA08Mk79f Chn4paNRIjjxaMdbJD926KkFL3i0MPaUxG4gRscog3IwjBVLQqV/ok6KNPUQl5wEZd9Y l5j49fP/66jbBmrFPBL4YWVzYcgyIl9zsQS7gtDFO90NsF13Yk1CtYmrSnBsIDjZ1YJT xw== Received: from aptaippmta01.qualcomm.com (tpe-colo-wan-fw-bordernet.qualcomm.com [103.229.16.4]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3uc048086y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Nov 2023 05:27:45 +0000 Received: from pps.filterd (APTAIPPMTA01.qualcomm.com [127.0.0.1]) by APTAIPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 3AE5Rhme008880; Tue, 14 Nov 2023 05:27:43 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APTAIPPMTA01.qualcomm.com (PPS) with ESMTP id 3ua2pkg46a-1; Tue, 14 Nov 2023 05:27:43 +0000 Received: from APTAIPPMTA01.qualcomm.com (APTAIPPMTA01.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3AE5RhkH008869; Tue, 14 Nov 2023 05:27:43 GMT Received: from cbsp-sh-gv.qualcomm.com (CBSP-SH-gv.ap.qualcomm.com [10.231.249.68]) by APTAIPPMTA01.qualcomm.com (PPS) with ESMTP id 3AE5RgJC008868; Tue, 14 Nov 2023 05:27:43 +0000 Received: by cbsp-sh-gv.qualcomm.com (Postfix, from userid 4098150) id 33BE5549D; Tue, 14 Nov 2023 13:27:42 +0800 (CST) From: Qiang Yu To: mani@kernel.org, quic_jhugo@quicinc.com Cc: mhi@lists.linux.dev, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, quic_cang@quicinc.com, quic_mrana@quicinc.com, Bhaumik Bhatt , stable@vger.kernel.org, Qiang Yu Subject: [PATCH v4 1/4] bus: mhi: host: Add spinlock to protect WP access when queueing TREs Date: Tue, 14 Nov 2023 13:27:38 +0800 Message-Id: <1699939661-7385-2-git-send-email-quic_qianyu@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1699939661-7385-1-git-send-email-quic_qianyu@quicinc.com> References: <1699939661-7385-1-git-send-email-quic_qianyu@quicinc.com> X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: fEW3KgFGSHMfIq2igPBxNogHINopilhk X-Proofpoint-GUID: fEW3KgFGSHMfIq2igPBxNogHINopilhk X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-14_04,2023-11-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 priorityscore=1501 adultscore=0 malwarescore=0 bulkscore=0 phishscore=0 mlxlogscore=357 clxscore=1015 spamscore=0 lowpriorityscore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311140040 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Mon, 13 Nov 2023 21:29:42 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782516063923220773 X-GMAIL-MSGID: 1782516063923220773 From: Bhaumik Bhatt Protect WP accesses such that multiple threads queueing buffers for incoming data do not race. Cc: Fixes: 189ff97cca53 ("bus: mhi: core: Add support for data transfer") Signed-off-by: Bhaumik Bhatt Signed-off-by: Qiang Yu Reviewed-by: Manivannan Sadhasivam --- drivers/bus/mhi/host/main.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/bus/mhi/host/main.c b/drivers/bus/mhi/host/main.c index dcf627b..6c6d253 100644 --- a/drivers/bus/mhi/host/main.c +++ b/drivers/bus/mhi/host/main.c @@ -1204,6 +1204,9 @@ int mhi_gen_tre(struct mhi_controller *mhi_cntrl, struct mhi_chan *mhi_chan, int eot, eob, chain, bei; int ret; + /* Protect accesses for reading and incrementing WP */ + write_lock_bh(&mhi_chan->lock); + buf_ring = &mhi_chan->buf_ring; tre_ring = &mhi_chan->tre_ring; @@ -1221,8 +1224,10 @@ int mhi_gen_tre(struct mhi_controller *mhi_cntrl, struct mhi_chan *mhi_chan, if (!info->pre_mapped) { ret = mhi_cntrl->map_single(mhi_cntrl, buf_info); - if (ret) + if (ret) { + write_unlock_bh(&mhi_chan->lock); return ret; + } } eob = !!(flags & MHI_EOB); @@ -1239,6 +1244,8 @@ int mhi_gen_tre(struct mhi_controller *mhi_cntrl, struct mhi_chan *mhi_chan, mhi_add_ring_element(mhi_cntrl, tre_ring); mhi_add_ring_element(mhi_cntrl, buf_ring); + write_unlock_bh(&mhi_chan->lock); + return 0; } From patchwork Tue Nov 14 05:27:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qiang Yu X-Patchwork-Id: 164732 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp1659518vqg; Mon, 13 Nov 2023 21:28:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IEC1lYQJqA6WrvCPuGLc23lVGm1ZIsA3sjJBc0OAPYBjRoGQoZUR/VnycP1XxRqW4DvhFW5 X-Received: by 2002:a17:902:ce86:b0:1cc:13d0:d515 with SMTP id f6-20020a170902ce8600b001cc13d0d515mr1536218plg.20.1699939681070; Mon, 13 Nov 2023 21:28:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699939681; cv=none; d=google.com; s=arc-20160816; b=WyI9cpouzzG6knY4b8k0qQjlhNHJdFQznt/t5FWQAOQZOfhE/GyrMj3Zx7hVHJcEDh +yf5MMSOPXAmYIndNvUNObTvyaQ3EfUPGzyW+Jem2WHC0PDk+dL1KY3HDXo0wfpuQjKx w9cKM3D/SASTJSsOFhZ0Jw/yXSSnlHBI3FN+hEqzVNsLkSwUCPRS6gkpsMK3Gn1xabwI M96RLyt5XrNhP9OEwLG1ap8QwZEMbLrdr8LBb/RuFtkVKfR7+GpQaPjDlRx3bOLxqPg5 tbubaNoXikBjfFsX5kksrTnOM+XiBtAOfc36txjmwoWN9bwKKqZpd9Oav0qYXwnoq2pi /W4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=gjSpJlCj1oF1CZ9LtqHzM/lbY5LGb8Li7c87y0f6jLs=; fh=f4KQnOf4DL3FZ4rINpxCCB681RH9plJXTbAzdkN1cKE=; b=1D72aE5jW4iPJ2jLXJbOsJ9WNO4Dtjcc/hPQnqQrHGanLB9naHT+uUtfnXl4vSVGRv 9s8yEAFNdaWY+Atx8JqBGGclDw+vgelrpUhYJDvUvPXGhJDNkjSkVYiZAWDxyVdelvR3 M8zImIsvLruMxf393/pgLXeu4KXy6FeIjbKf15U+clP/unD6P42S48xxYs5DVPpqzBx+ MLTJ0dANpGn2Bm1Yw8JGKSOIEumhb+N9WxlLVtiFcsYQ+Dmrfc+ZYDkT1s3bnya7qCkx wSiyFpHVmWj+LS1jGRxaOqScvuqhvHszoYtAk0ZpA9fP7twEvYc+3/ATM+Ya36wP5rgf FWyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=XJr6xibi; 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 b3-20020a170902d30300b001c9c9251e05si6917833plc.476.2023.11.13.21.28.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 21:28:01 -0800 (PST) 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=XJr6xibi; 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 355CE801F763; Mon, 13 Nov 2023 21:28:00 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232149AbjKNF14 (ORCPT + 30 others); Tue, 14 Nov 2023 00:27:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232132AbjKNF1y (ORCPT ); Tue, 14 Nov 2023 00:27:54 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CC59D43; Mon, 13 Nov 2023 21:27:51 -0800 (PST) Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AE3m1iD030862; Tue, 14 Nov 2023 05:27:46 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; s=qcppdkim1; bh=gjSpJlCj1oF1CZ9LtqHzM/lbY5LGb8Li7c87y0f6jLs=; b=XJr6xibiL98Okx2TNRQ1ePC2HWqyw8LYOkgLITbS9ss2PZotikAEePOmG4JtuX/wHbYU SirDNn/Fgg/5U7FbHtuAisVOwkgn4FT6GfeT8X13z2FF4Xs0QRZtnZoYl85buVe5BsFs Tiy+zgEVvynweCGj3rlN9r0bBzDiope04gTKfv8Bv0TJL33dxTKVQUFz8Dc51M+8AtH7 ImVfJYQbvRx/AuKVw6i08+Con6tbircquc3JGH0mlyVOXfE5spaTAMRiUeTPW6xcuTmS mkrT7MlY0Z3C0by1jTl7BR+cJbJSKxXbAoyDudA5Kbz9Auu7dqu6OwJtpyyvRRUBaJG5 xQ== Received: from aptaippmta01.qualcomm.com (tpe-colo-wan-fw-bordernet.qualcomm.com [103.229.16.4]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3ubw6hgh9g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Nov 2023 05:27:45 +0000 Received: from pps.filterd (APTAIPPMTA01.qualcomm.com [127.0.0.1]) by APTAIPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 3AE5RhfP008882; Tue, 14 Nov 2023 05:27:43 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APTAIPPMTA01.qualcomm.com (PPS) with ESMTP id 3ua2pkg46b-1; Tue, 14 Nov 2023 05:27:43 +0000 Received: from APTAIPPMTA01.qualcomm.com (APTAIPPMTA01.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3AE5RhqW008870; Tue, 14 Nov 2023 05:27:43 GMT Received: from cbsp-sh-gv.qualcomm.com (CBSP-SH-gv.ap.qualcomm.com [10.231.249.68]) by APTAIPPMTA01.qualcomm.com (PPS) with ESMTP id 3AE5RghX008867; Tue, 14 Nov 2023 05:27:43 +0000 Received: by cbsp-sh-gv.qualcomm.com (Postfix, from userid 4098150) id 7B7FB549E; Tue, 14 Nov 2023 13:27:42 +0800 (CST) From: Qiang Yu To: mani@kernel.org, quic_jhugo@quicinc.com Cc: mhi@lists.linux.dev, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, quic_cang@quicinc.com, quic_mrana@quicinc.com, Qiang Yu Subject: [PATCH v4 2/4] bus: mhi: host: Drop chan lock before queuing buffers Date: Tue, 14 Nov 2023 13:27:39 +0800 Message-Id: <1699939661-7385-3-git-send-email-quic_qianyu@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1699939661-7385-1-git-send-email-quic_qianyu@quicinc.com> References: <1699939661-7385-1-git-send-email-quic_qianyu@quicinc.com> X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: phkTVK4-io4NL16x9IpI8k0sr56GKQ96 X-Proofpoint-GUID: phkTVK4-io4NL16x9IpI8k0sr56GKQ96 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-14_04,2023-11-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 mlxlogscore=597 priorityscore=1501 phishscore=0 malwarescore=0 impostorscore=0 lowpriorityscore=0 mlxscore=0 spamscore=0 suspectscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311140040 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 13 Nov 2023 21:28:00 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782515950767010330 X-GMAIL-MSGID: 1782515950767010330 Ensure read and write locks for the channel are not taken in succession by dropping the read lock from parse_xfer_event() such that a callback given to client can potentially queue buffers and acquire the write lock in that process. Any queueing of buffers should be done without channel read lock acquired as it can result in multiple locks and a soft lockup. Signed-off-by: Qiang Yu --- drivers/bus/mhi/host/main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/bus/mhi/host/main.c b/drivers/bus/mhi/host/main.c index 6c6d253..c4215b0 100644 --- a/drivers/bus/mhi/host/main.c +++ b/drivers/bus/mhi/host/main.c @@ -642,6 +642,8 @@ static int parse_xfer_event(struct mhi_controller *mhi_cntrl, mhi_del_ring_element(mhi_cntrl, tre_ring); local_rp = tre_ring->rp; + read_unlock_bh(&mhi_chan->lock); + /* notify client */ mhi_chan->xfer_cb(mhi_chan->mhi_dev, &result); @@ -667,6 +669,8 @@ static int parse_xfer_event(struct mhi_controller *mhi_cntrl, kfree(buf_info->cb_buf); } } + + read_lock_bh(&mhi_chan->lock); } break; } /* CC_EOT */ From patchwork Tue Nov 14 05:27:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qiang Yu X-Patchwork-Id: 164733 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp1659535vqg; Mon, 13 Nov 2023 21:28:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IFLr7ljwMO0pIEbZS8faodx0RIEbY8EqofQ+ZY4C2LbxQ2svH3VnhsGRRCaSkRmciMiiqk9 X-Received: by 2002:a17:902:7449:b0:1ca:28f3:5690 with SMTP id e9-20020a170902744900b001ca28f35690mr1300139plt.46.1699939682833; Mon, 13 Nov 2023 21:28:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699939682; cv=none; d=google.com; s=arc-20160816; b=B1TR/Z8sYnFTPmpcCD7QwpVnPcqA66pDJKcjTHBNWoulMaNfL9NsdnkzKtNjy26WFU GhFSEP1Hoht6sRsYrqiv7janHjsThYi0weeZUXydVU5SWTJiOPz4zQShw7SAGVMT0sKI 0kvg+jmxY+iFR2oqmyiejphNHF/aQT0u0dXh6as+DfSxp7v6emWtGmyUHqT90YwvTdsd cAaaTRvz3Ary3Gka4nFNwa/wZjKR6uCdWXYAVFVuS2Vo1x/ah8TSJuYa4NwPA8Ey7ACr 1le98UEpQwTmd/JnOWJpx7+vefKHW/ZZOiLWmcWanI/NwZUlapc5vdkhdsdNQqY3rJtp tl+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=jTLZDpaFyQh9b5vaid9uc2WLgM+TzHPWUCAJsFMDBm4=; fh=f4KQnOf4DL3FZ4rINpxCCB681RH9plJXTbAzdkN1cKE=; b=UE1S0s6Hl5m6cuSU6GqDXOW1Wm1jSFP7zkT/Bx1diScvjLXGqYzMPnHe9LRa4DuOoG cl97SGKhRaofG+6IeW9T16FDiSh/WfZamvCDDZol5VZOi8HSKZ/yNBCxqILVXMAzvUCe C82E3eoBICwUNVfAj1AwBY4IxSTv68kVtOhHsBv1qlGfs+tiEnnUszGnoPOskxcHuPAf Q/OyGaTHNxrFDYHE77RbRk5DLNAJSM3AHrFa8uUHF8LhaI6BIj28vIB+yxxeHh7pWKRH oWxvZ1Yi8lmGB91yK/tyKeVb5dcnrxWjsb+XiWLQ7TaqxX9gXB+fJzczKCL6ViKDhh6z ehwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=JZGrAbsb; 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 w13-20020a170902d3cd00b001c9faf1439esi7038729plb.288.2023.11.13.21.28.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 21:28:02 -0800 (PST) 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=JZGrAbsb; 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 E6402801F76C; Mon, 13 Nov 2023 21:28:01 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232180AbjKNF16 (ORCPT + 30 others); Tue, 14 Nov 2023 00:27:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232143AbjKNF1y (ORCPT ); Tue, 14 Nov 2023 00:27:54 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CC3294; Mon, 13 Nov 2023 21:27:51 -0800 (PST) Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AE0iuP0029557; Tue, 14 Nov 2023 05:27:46 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; s=qcppdkim1; bh=jTLZDpaFyQh9b5vaid9uc2WLgM+TzHPWUCAJsFMDBm4=; b=JZGrAbsbxsDqnciuqge93EdYnRzwEI2/XuAru47je3UG5pb4PK8/kJZvuUGII+70yVx1 ayPCXSaQTMK+GdTT62NEDd8khIGddbUIQpOd6EnjNS8JWUnT0BAvaPSDJ0pn3JU3QzBg KgdolXYXtcCpfcgkJxLxAK2rnPfAZnaQ/3S3d7Al4rqjQTcauxM3CBZLXio0j8qwkNPL Wa+71AtCBYTYqu9v/2iqcbvKbLv0FyuOC45puN07RNi5r5EXxby2bsriNz01rmImeVku WQHx8Na9c80iVWjhPNH1a9ZnCrCuSVQKd+QjLEOFx7Zvx2FObm5iwpGdzXMR5VKzHKpU Gw== Received: from aptaippmta02.qualcomm.com (tpe-colo-wan-fw-bordernet.qualcomm.com [103.229.16.4]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3ubwwn0f6j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Nov 2023 05:27:45 +0000 Received: from pps.filterd (APTAIPPMTA02.qualcomm.com [127.0.0.1]) by APTAIPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 3AE5RiV7032655; Tue, 14 Nov 2023 05:27:44 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APTAIPPMTA02.qualcomm.com (PPS) with ESMTP id 3ua2pkqrhb-1; Tue, 14 Nov 2023 05:27:44 +0000 Received: from APTAIPPMTA02.qualcomm.com (APTAIPPMTA02.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3AE5RhHZ032649; Tue, 14 Nov 2023 05:27:43 GMT Received: from cbsp-sh-gv.qualcomm.com (CBSP-SH-gv.ap.qualcomm.com [10.231.249.68]) by APTAIPPMTA02.qualcomm.com (PPS) with ESMTP id 3AE5RhqJ032648; Tue, 14 Nov 2023 05:27:43 +0000 Received: by cbsp-sh-gv.qualcomm.com (Postfix, from userid 4098150) id EF28F549F; Tue, 14 Nov 2023 13:27:42 +0800 (CST) From: Qiang Yu To: mani@kernel.org, quic_jhugo@quicinc.com Cc: mhi@lists.linux.dev, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, quic_cang@quicinc.com, quic_mrana@quicinc.com, Qiang Yu Subject: [PATCH v4 3/4] bus: mhi: host: Avoid processing buffer and event of a disable channel Date: Tue, 14 Nov 2023 13:27:40 +0800 Message-Id: <1699939661-7385-4-git-send-email-quic_qianyu@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1699939661-7385-1-git-send-email-quic_qianyu@quicinc.com> References: <1699939661-7385-1-git-send-email-quic_qianyu@quicinc.com> X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: DSMKcA27HlYvV0yI3DG-uozObHTD5tmn X-Proofpoint-ORIG-GUID: DSMKcA27HlYvV0yI3DG-uozObHTD5tmn X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-14_04,2023-11-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 bulkscore=0 adultscore=0 phishscore=0 mlxlogscore=687 suspectscore=0 mlxscore=0 clxscore=1015 impostorscore=0 malwarescore=0 lowpriorityscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311140040 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 13 Nov 2023 21:28:02 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782515952502095732 X-GMAIL-MSGID: 1782515952502095732 MHI channel state is protected by mhi_chan->lock. Hence, after core drops mhi_chan->lock during processing xfer event, it can not prevent channel state being changed if client closes channel or driver is removed at this time. So let's check mhi channel state after getting chan->lock again to avoid queuing buffer to a disabled channel in xfer callback and stop processing event of the disabled channel. Signed-off-by: Qiang Yu --- drivers/bus/mhi/host/main.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/bus/mhi/host/main.c b/drivers/bus/mhi/host/main.c index c4215b0..33f27e2 100644 --- a/drivers/bus/mhi/host/main.c +++ b/drivers/bus/mhi/host/main.c @@ -671,6 +671,8 @@ static int parse_xfer_event(struct mhi_controller *mhi_cntrl, } read_lock_bh(&mhi_chan->lock); + if (mhi_chan->ch_state != MHI_CH_STATE_ENABLED) + goto end_process_tx_event; } break; } /* CC_EOT */ @@ -1210,6 +1212,10 @@ int mhi_gen_tre(struct mhi_controller *mhi_cntrl, struct mhi_chan *mhi_chan, /* Protect accesses for reading and incrementing WP */ write_lock_bh(&mhi_chan->lock); + if (mhi_chan->ch_state != MHI_CH_STATE_ENABLED) { + write_unlock_bh(&mhi_chan->lock); + return -EINVAL; + } buf_ring = &mhi_chan->buf_ring; tre_ring = &mhi_chan->tre_ring; From patchwork Tue Nov 14 05:27:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qiang Yu X-Patchwork-Id: 164734 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp1659572vqg; Mon, 13 Nov 2023 21:28:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IHwlY2Onz2xL2pvHgdBlY9wIZeEM+jjXFGvnh3cXD7QxzWHvjYn1Tuq7aRuuNh5hUbQbMLb X-Received: by 2002:aa7:9a84:0:b0:6b3:aded:7e9a with SMTP id x4-20020aa79a84000000b006b3aded7e9amr6385037pfi.27.1699939691058; Mon, 13 Nov 2023 21:28:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699939691; cv=none; d=google.com; s=arc-20160816; b=xaay25xOy6L/3A0SlgvIHsWTPHkoyfj0ws6kj5JLjWnwMUXN0eWGA4sitgrLvFe7gk AIbVEX/2o+xaAap6kgMdyaaRgF2NMYGHtHx9XLcxNxgJ5n9MdFbCRsbO81MAN27JY17V X3t9MVu1FWtCLVjMurWMx86asNUV0etOUeLrZ2rtpPCDiU26cfbAiam7RrLnz9DCsLGl qRQ1sUxa2XrIO2nLlt1pzkIkUhO9BDc+FQlP56bdWcEpHIr3GAU+v03Shp4NHc/mj1VD 3RuPvBQ+AAaTlTy3H4qfLPFOI21IAr0lJJCXYKeRKMCR2MN3M+YmYyapHjtBFqIEPOIf Qkow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=M14X2TIO0VOPewrWHxCvQHTCeE0nDEhcUaaK/cjKzUI=; fh=bKmA2tW4XJgfdE5WSHQKuyGLkQmORF+gsrf1gZ0+NT4=; b=tzyybi0bDXjtV43VwM90qwzSjt24vksJjVxtkBBi8QlEa4a4H2NyG4+aPSeiMGyJrH siR8zQhgRJwCv+Z+hv/skGnCjh0LY9Q6L9ktK6Nw8g4SdhkId71HcDuRRpWwsn5PUQV+ F5btbUFmIC0tzJrP6oAjaCZsfjpVWeoKyiLkzyNNvjB5GgZSF0hYkOL8yKJYCJckLBEg nmNaA7zFuDMzpOdznQx4O1DIB48MmXmnP91ZVEdgjabnc64Oeo/rx3Fxu1jsscTJVahE AtyCfVRGWowDbf1E3gDgpMRivhIL9K8uwRx8GRx75hd/ZQrb6fd0Yd3YJtGjriXDzTqo faUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=MB8BseUg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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. [23.128.96.37]) by mx.google.com with ESMTPS id v8-20020a056a00148800b006bbe72a826asi7754797pfu.180.2023.11.13.21.28.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 21:28:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=MB8BseUg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 3587B801E85F; Mon, 13 Nov 2023 21:28:10 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232133AbjKNF2B (ORCPT + 30 others); Tue, 14 Nov 2023 00:28:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232146AbjKNF1y (ORCPT ); Tue, 14 Nov 2023 00:27:54 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4C4CD44; Mon, 13 Nov 2023 21:27:51 -0800 (PST) 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 3AE5JJG1024871; Tue, 14 Nov 2023 05:27:46 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; s=qcppdkim1; bh=M14X2TIO0VOPewrWHxCvQHTCeE0nDEhcUaaK/cjKzUI=; b=MB8BseUgUKctfOfO4L5a/Ekb1ciWi6ntuu+16P1x9kzikUjuhse7nspTACy4PYjhXcBe bSx3gKolC8kSE92T+t9kuB0ap11Kt0Wm1gVbWaCAkqsd/kic/4WDlBsy77QchquuYjui 1dy4pD0Y5Le0QMGUzm1h9DjjHHbVqWQKjjx+Tp3ufDTKWUhnvBT6AifpdmhuFM5bs/ew wzYI+4Wq1ouXL8zUJnuLJiDU26U1mcS6u4+mTnGwuenSWBL1vV2MBrYniSpID+mJB3BF R+aqZgQHOcnSXFEHisC9ntGDI3QUiXiv/qgkfzIHbfig2FtuPEKCruf5lUYxgIq/gjnI ww== Received: from aptaippmta01.qualcomm.com (tpe-colo-wan-fw-bordernet.qualcomm.com [103.229.16.4]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3ubmtv9t1e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Nov 2023 05:27:46 +0000 Received: from pps.filterd (APTAIPPMTA01.qualcomm.com [127.0.0.1]) by APTAIPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 3AE5RiYo009304; Tue, 14 Nov 2023 05:27:44 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APTAIPPMTA01.qualcomm.com (PPS) with ESMTP id 3ua2pkg46k-1; Tue, 14 Nov 2023 05:27:44 +0000 Received: from APTAIPPMTA01.qualcomm.com (APTAIPPMTA01.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3AE5RhqY008870; Tue, 14 Nov 2023 05:27:44 GMT Received: from cbsp-sh-gv.qualcomm.com (CBSP-SH-gv.ap.qualcomm.com [10.231.249.68]) by APTAIPPMTA01.qualcomm.com (PPS) with ESMTP id 3AE5Ri8D009291; Tue, 14 Nov 2023 05:27:44 +0000 Received: by cbsp-sh-gv.qualcomm.com (Postfix, from userid 4098150) id 5D9D8549C; Tue, 14 Nov 2023 13:27:43 +0800 (CST) From: Qiang Yu To: mani@kernel.org, quic_jhugo@quicinc.com Cc: mhi@lists.linux.dev, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, quic_cang@quicinc.com, quic_mrana@quicinc.com, Hemant Kumar , Lazarus Motha , Qiang Yu Subject: [PATCH v4 4/4] bus: mhi: host: Take irqsave lock after TRE is generated Date: Tue, 14 Nov 2023 13:27:41 +0800 Message-Id: <1699939661-7385-5-git-send-email-quic_qianyu@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1699939661-7385-1-git-send-email-quic_qianyu@quicinc.com> References: <1699939661-7385-1-git-send-email-quic_qianyu@quicinc.com> X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: NKMBcniiEGzTMSEhMBZL9Ieu3OX2vfTy X-Proofpoint-GUID: NKMBcniiEGzTMSEhMBZL9Ieu3OX2vfTy X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-14_04,2023-11-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 bulkscore=0 lowpriorityscore=0 mlxscore=0 clxscore=1015 spamscore=0 mlxlogscore=640 phishscore=0 adultscore=0 malwarescore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311140040 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 13 Nov 2023 21:28:10 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782515961706265830 X-GMAIL-MSGID: 1782515961706265830 From: Hemant Kumar If CONFIG_TRACE_IRQFLAGS is enabled, irq will be enabled once __local_bh_ enable_ip is called as part of write_unlock_bh. Hence, let's take irqsave lock after TRE is generated to avoid running write_unlock_bh when irqsave lock is held. Signed-off-by: Hemant Kumar Signed-off-by: Lazarus Motha Signed-off-by: Qiang Yu --- drivers/bus/mhi/host/main.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/bus/mhi/host/main.c b/drivers/bus/mhi/host/main.c index 33f27e2..d7abd0b 100644 --- a/drivers/bus/mhi/host/main.c +++ b/drivers/bus/mhi/host/main.c @@ -1128,17 +1128,15 @@ static int mhi_queue(struct mhi_device *mhi_dev, struct mhi_buf_info *buf_info, if (unlikely(MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state))) return -EIO; - read_lock_irqsave(&mhi_cntrl->pm_lock, flags); - ret = mhi_is_ring_full(mhi_cntrl, tre_ring); - if (unlikely(ret)) { - ret = -EAGAIN; - goto exit_unlock; - } + if (unlikely(ret)) + return -EAGAIN; ret = mhi_gen_tre(mhi_cntrl, mhi_chan, buf_info, mflags); if (unlikely(ret)) - goto exit_unlock; + return ret; + + read_lock_irqsave(&mhi_cntrl->pm_lock, flags); /* Packet is queued, take a usage ref to exit M3 if necessary * for host->device buffer, balanced put is done on buffer completion @@ -1158,7 +1156,6 @@ static int mhi_queue(struct mhi_device *mhi_dev, struct mhi_buf_info *buf_info, if (dir == DMA_FROM_DEVICE) mhi_cntrl->runtime_put(mhi_cntrl); -exit_unlock: read_unlock_irqrestore(&mhi_cntrl->pm_lock, flags); return ret;