From patchwork Mon Dec 11 06:42:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qiang Yu X-Patchwork-Id: 176502 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp6866500vqy; Sun, 10 Dec 2023 22:43:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IEHtQChCejwsViu/6IAWJTRsbPXh6NpJDh8i7GUB2B2WzktrnW7OkNbBBNLpnfvnzlLqLQe X-Received: by 2002:a05:6a00:4643:b0:6cd:f18e:176 with SMTP id kp3-20020a056a00464300b006cdf18e0176mr4215067pfb.27.1702277020014; Sun, 10 Dec 2023 22:43:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702277019; cv=none; d=google.com; s=arc-20160816; b=u0NK93F76lKidnxS2Y9HjTq0yyS+0Xqm08LFvqs5kGfyY7Ja/1GUkRaapCYMGQW9ht /tKfFyJ7N871S0C3Y4dUUz4JIrGfJxQzyh35xBhEafkbnI0JVz1Y/I6WXj0ZbkmeIj4z ikQouzhzs6Y/bWrZOqWt400Q6Wf1i5xcNCqHrrxsdcWwHXu3fssTtD+00/Ir2vKc26X8 J+b/1oUo6IoDcjNXQkumvgP/dY5l0asGNCOu1Ofd81ekkkwZ8EhQLLVd8AATeKmczTd+ mBwmt7wAiNaIId8ZiECGbDTYPkq1qmZl2v8Y57bOBRfXqtpSmGhq7m+uCggE3ZlpKo6I WxDg== 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=RYnj6i8X3DA/tzosX99m5OYDnjepi+4YYvJGmfdTIn8=; fh=7y8XBjHEOFaIi1bWwlOqynzp3kMu6S1xEU1Lbig9USo=; b=JOdwAimhzK4mLmLMyagYKtsOHFT+9xEB7ZNS/DnQ9RxYZp4ROwHfIkQlVLRT/btEHf Z817PpxaMvCnb1ECzBc2cWTQfNz0gEgdmSRIxQ5iDsUaGPf0I6aBQFHLKppmEEeEC7YD R4UlxnapLyTjf5HKAgH4w5bybjcJMIY2V0QMyNXJe/ZuYnjsbkaYRfls0bEgqJO0rkwh Kr2UdpGngc8NK4GFMUVirkC26IWF6K0kSI7KKvfn4qmAsse2BED9ILgS0jejs7MnF06B evWRM2/WKiDNt971c73bCNcFAEEieu5LI8pcAympqnr6SIY/SMaSIM824SHdjVNw/1lp EnMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=PU8La6Y7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id d24-20020aa78e58000000b006cef630790esi623500pfr.90.2023.12.10.22.43.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Dec 2023 22:43:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=PU8La6Y7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id 87E5C80926BC; Sun, 10 Dec 2023 22:43:37 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233659AbjLKGn3 (ORCPT + 99 others); Mon, 11 Dec 2023 01:43:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233581AbjLKGnY (ORCPT ); Mon, 11 Dec 2023 01:43:24 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2C1710F; Sun, 10 Dec 2023 22:43:28 -0800 (PST) Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 3BB3U2Zx025349; Mon, 11 Dec 2023 06:42:58 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=RYnj6i8X3DA/tzosX99m5OYDnjepi+4YYvJGmfdTIn8=; b=PU 8La6Y76Q7tpokiFPcfRkWeeDJnToCq4H4rMZP9J7e37vd1Pu0DDOmgQbqYWrctoo o1u4ZwXnDKDRBgO1HSrH52d9jEiufgB9Z/SyDNYyMo/KAYEzaeEdm9O7gCiQUu6z r/ETt0nosDsO9068Hy5PAHCIUQBhb7uYlYMM6grcs8PzbRP3KaU2W2wtoqBIkvlE bc7UOTfhhiXLRQwX1EFTLz6Jw3osNYnEbcmeC6TzRp6p5v2m8Kxz9wHlMDQDBAUg 4ocR0pO+npoCA/qECe9jXIYxsr2aXgeDDCOF4VPIVgJ83w++T+kaLWWn4p0EiFlD Vd1Iux69RK7F2PLSYJXA== 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 3uvp30aeqq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Dec 2023 06:42:58 +0000 (GMT) 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 3BB6gt7r030880; Mon, 11 Dec 2023 06:42:55 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APTAIPPMTA01.qualcomm.com (PPS) with ESMTP id 3uvhak95cr-1; Mon, 11 Dec 2023 06:42:55 +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 3BB6gtSs030875; Mon, 11 Dec 2023 06:42:55 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 3BB6gtLP030873; Mon, 11 Dec 2023 06:42:55 +0000 Received: by cbsp-sh-gv.qualcomm.com (Postfix, from userid 4098150) id 892B955E8; Mon, 11 Dec 2023 14:42:54 +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 v5 1/2] bus: mhi: host: Add spinlock to protect WP access when queueing TREs Date: Mon, 11 Dec 2023 14:42:51 +0800 Message-Id: <1702276972-41296-2-git-send-email-quic_qianyu@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1702276972-41296-1-git-send-email-quic_qianyu@quicinc.com> References: <1702276972-41296-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: CYvXI6dEOR8xWN_a4aN6Zm7O1UJxWgP1 X-Proofpoint-GUID: CYvXI6dEOR8xWN_a4aN6Zm7O1UJxWgP1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-09_01,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 malwarescore=0 phishscore=0 mlxlogscore=504 lowpriorityscore=0 clxscore=1011 priorityscore=1501 bulkscore=0 adultscore=0 spamscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311290000 definitions=main-2312110054 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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Sun, 10 Dec 2023 22:43:37 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784966828526923550 X-GMAIL-MSGID: 1784966828526923550 From: Bhaumik Bhatt Protect WP accesses such that multiple threads queueing buffers for incoming data do not race. Meanwhile, 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. Cc: Fixes: 189ff97cca53 ("bus: mhi: core: Add support for data transfer") Signed-off-by: Bhaumik Bhatt Signed-off-by: Qiang Yu Reviewed-by: Jeffrey Hugo Tested-by: Jeffrey Hugo Reviewed-by: Manivannan Sadhasivam --- drivers/bus/mhi/host/main.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/bus/mhi/host/main.c b/drivers/bus/mhi/host/main.c index dcf627b..32021fe 100644 --- a/drivers/bus/mhi/host/main.c +++ b/drivers/bus/mhi/host/main.c @@ -1122,17 +1122,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 @@ -1152,7 +1150,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; @@ -1204,6 +1201,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 +1221,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 +1241,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 Mon Dec 11 06:42:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qiang Yu X-Patchwork-Id: 176501 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp6866414vqy; Sun, 10 Dec 2023 22:43:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IGVINTRORwiS9A05tXOjOpru1we/hBXekI1DQGNRQh8DkOMSLjONEEIGdH969RF6KrmVxBK X-Received: by 2002:a05:6a00:850a:b0:6ce:7be1:3cfd with SMTP id ha10-20020a056a00850a00b006ce7be13cfdmr3668631pfb.61.1702277001127; Sun, 10 Dec 2023 22:43:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702277001; cv=none; d=google.com; s=arc-20160816; b=b5APFQoRh2zEqiK7f9aCJif7taW+o66FLOzK4ZNkUKduF6Y98c92vzwVo22FWrFTeq eUUKuaSSPWtoqpGNONojciOutHKw7CPcko9ufMFMLRXkJrcLD1Rjq4AXj2FyhMelllQG eDw27O3P/PV26OZo+rf1aTNyKFblQW0o6vb9MOCeAgngf8PRDNjeOqGQt96ckRBllRZ5 KhNebCNbc7wwNJbNvAzPsWdMytTOP/p7pWtMO+44OXeiQTBrlCZz/dUBQZsmPgXYFcxW BrfkDkW3pwtU4JvilCIAsUrqW10zAnQp8buXAzGTjIozV1eJJDbm6/5/w9zWnwfcyGBE HkDg== 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=e1+zOy1qUA8HHZYc5Bz8jvBUDY2bNGJthqVjZfAWwWM=; fh=f4KQnOf4DL3FZ4rINpxCCB681RH9plJXTbAzdkN1cKE=; b=TmcCKgY0Qh/7AIVpR9f4WIdM2owSVpqcQ5FjEnHWD1u6zr4lxUmxDbxXxjTbn7W8q7 CIA76PmraP9wKLzp3VucbR+zXQFDtQKCmPQSZ4nMRzBHrGLyRrGiZHq7TuoLpQyqv6iD XMnIOZIwZUVViH0QXGT/psoDvLAT7a/1qU23SNcCPLmOYxLGK8FQQltDKOfR4zG9jWvw EKEKNdYJ/9hlEeydbmv71h5eqp7GJulyaOgKseEMWqLOuns4eQSdhy43XZJ8yNUazI4O YS7uP0uSnxCncV7qEU4av9mN2zlOULlHGiL+LsCsND0J3EeeBog6MIpei2qblkduqC5n rtHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=bD5hylfl; 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 gu11-20020a056a004e4b00b006ce823785a2si5528749pfb.134.2023.12.10.22.43.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Dec 2023 22:43:21 -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=bD5hylfl; 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 13F8F8098497; Sun, 10 Dec 2023 22:43:20 -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 S233548AbjLKGnH (ORCPT + 99 others); Mon, 11 Dec 2023 01:43:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233104AbjLKGnE (ORCPT ); Mon, 11 Dec 2023 01:43:04 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62248C3; Sun, 10 Dec 2023 22:43:10 -0800 (PST) Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 3BB5anrG008038; Mon, 11 Dec 2023 06:42:59 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=e1+zOy1qUA8HHZYc5Bz8jvBUDY2bNGJthqVjZfAWwWM=; b=bD 5hylflfZoXirBZeF7jkwfSwl0KoeG0YIy39hjF3Yzpr/g1tWmWUAOYns7+1UJRWJ Ji0AcX1dEfMCj8gmsIwfGs2hYTMM5W+leJIM8fnH3T0Lhz9lr8RBftmkL8yjwoBy IFqbl/xXh/MKp2GTtbU3HgNHhEKGT5OMRddJyoHvYh7rSQ2e133YTrcBLFIKXf8c /DdrbXoZDuX0ZIYOUoI1t3D+mreZjipKtjl5AANBE2hTt2J0RVrB59jjQoOi7Wty cQUXw27bS2Hn8zqJ1WIKtqCLfYRvWR4TiWW0Z15Tne2Kj9Gu27ghoN4tXbzwe07b SB2f4Q27end1v8wLS3MA== 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 3uvnyvadhq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Dec 2023 06:42:58 +0000 (GMT) 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 3BB6gt7s030880; Mon, 11 Dec 2023 06:42:56 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APTAIPPMTA01.qualcomm.com (PPS) with ESMTP id 3uvhak95cv-1; Mon, 11 Dec 2023 06:42:56 +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 3BB6gtSu030875; Mon, 11 Dec 2023 06:42:56 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 3BB6gt3O030883; Mon, 11 Dec 2023 06:42:56 +0000 Received: by cbsp-sh-gv.qualcomm.com (Postfix, from userid 4098150) id 3466B55E9; Mon, 11 Dec 2023 14:42:55 +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 v5 2/2] bus: mhi: host: Drop chan lock before queuing buffers Date: Mon, 11 Dec 2023 14:42:52 +0800 Message-Id: <1702276972-41296-3-git-send-email-quic_qianyu@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1702276972-41296-1-git-send-email-quic_qianyu@quicinc.com> References: <1702276972-41296-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: 8Df1Yo5-Hlz7hPdjP3ssHD4aAAr05k0g X-Proofpoint-ORIG-GUID: 8Df1Yo5-Hlz7hPdjP3ssHD4aAAr05k0g X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-09_02,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxlogscore=639 suspectscore=0 spamscore=0 bulkscore=0 clxscore=1015 phishscore=0 adultscore=0 mlxscore=0 lowpriorityscore=0 malwarescore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311290000 definitions=main-2312110054 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]); Sun, 10 Dec 2023 22:43:20 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784966808514846985 X-GMAIL-MSGID: 1784966808514846985 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 Reviewed-by: Jeffrey Hugo Tested-by: Jeffrey Hugo Reviewed-by: Manivannan Sadhasivam --- 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 32021fe..25f98d6 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 */