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 */