Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp3788682rdb; Sun, 10 Dec 2023 22:43:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IGH4NVnO7GBEmzjqGMNLAcw4uiaoI1WUAkbyxsB3nnM+w7OuechoAjNYTQ1QwL5v9yJyKZR X-Received: by 2002:a05:6359:5ea8:b0:16d:bbb3:69c6 with SMTP id px40-20020a0563595ea800b0016dbbb369c6mr2982940rwb.13.1702276995888; Sun, 10 Dec 2023 22:43:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702276995; cv=none; d=google.com; s=arc-20160816; b=W8Ekq8XGSsinuKEVjMrNbzyCO6bQE8BKvADblsRoFBKoJPCJWx4CG9yn/ksv28Woqw 8pHTVDpAuejxcNaNZDYN1o6l+2apq4HjRnqFjjUMsaZrNlwkg0FSze4KsNc9KY65I5So JwIO903xf+VumCewe5SMpdmhx+uNi05A71HL9ez47WaDcrF50rWOl/45e/MXZtcfV7a/ 5uaFw4eiD0BkX6u927ytAcKJw7eMwggTpzIhTet+iBB2RUuloXmx1inh+WB08yPWlPy2 MkowY1PJK87nwRbaZkign4a1miFs6eKg1onMDxePgtMDLCme46PQwzvvlQQCICTJl/Zm MbyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=gDmF3Z8bpvyT2isGQR96C4xl9uFFMECarS08e0Gntcs=; fh=f4KQnOf4DL3FZ4rINpxCCB681RH9plJXTbAzdkN1cKE=; b=OoMe2LI+HxZdTzg1CfXy0bY5PyKVsTWfaXo6dJYvlX/Rd+l/PsETq3LCvcoX2pD3fo f98RuAz1tqymIbrGmHVgEXpQpqlh9kqyozYet3esIOPljK4TpWDeJSwTc06oGyydeImm Y2Fd6fd+08DytTxPMWHg95EG5e6a18aW/N5Mp5DvDgsu1Rls9MAwoCSJJpawWyKY58T7 6kUzLVzBUD3+55+sJ3+INvz3OS8uRK/Rc8nykSxxzJiwfNVr9Bqf0+U5RzRtnTITe7KC wJe5lQvQNcdMtCgJUFEhVYEo/9zS3PkFWuOI5pJI874bdhkA6xe+mmOmoeZEBuOUH6Gk TDEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=meBN3Vtn; 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 Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id k12-20020a6568cc000000b0056f7f18bbfdsi5469784pgt.632.2023.12.10.22.43.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Dec 2023 22:43:15 -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=meBN3Vtn; 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 404638097882; Sun, 10 Dec 2023 22:43:14 -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 S233510AbjLKGnF (ORCPT + 99 others); Mon, 11 Dec 2023 01:43:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229570AbjLKGnD (ORCPT ); Mon, 11 Dec 2023 01:43:03 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 672E5B5; Sun, 10 Dec 2023 22:43:09 -0800 (PST) Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 3BB5kZCJ028438; 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; s=qcppdkim1; bh=gDmF3Z8bpvyT 2isGQR96C4xl9uFFMECarS08e0Gntcs=; b=meBN3VtnBit3X/I56N8Mulby2qUZ 60VL2VBdetWqFQsffLIArcxS9LWuIl/R1hkO5ZDQBhPYnOzORVlASlrn/03WaxcM m4p0b653azm1MffIPcHn6wTUrny1wCXmaFECl2aukrNpOVvZX4pK3mhagUT8nZq1 mzn+J/5QtGrYZz/4UovCYx5NUeb4PxderLl6Lknb4dOBZUsJQt8u+W91XOUt01t8 q5K9B8TBSxaYiYYhSNvEwL14Om27r35HS5CqXpvrFWp5pHF4kguwIqq13DzmpiWB J13v33o9YQgLgZeWdXuEbtngNsKsTR+EkXkuwK1Lg09vvS/fQ6kPqulqsA== 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 3uvney2gkg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Dec 2023 06:42:57 +0000 (GMT) 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 3BB6gtkt026134; Mon, 11 Dec 2023 06:42:55 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APTAIPPMTA02.qualcomm.com (PPS) with ESMTP id 3uvhak8ycp-1; Mon, 11 Dec 2023 06:42:55 +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 3BB6gtsb026128; 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 APTAIPPMTA02.qualcomm.com (PPS) with ESMTP id 3BB6gtG5026127; Mon, 11 Dec 2023 06:42:55 +0000 Received: by cbsp-sh-gv.qualcomm.com (Postfix, from userid 4098150) id 016C355E7; Mon, 11 Dec 2023 14:42:53 +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 0/2] bus: mhi: host: Add lock to avoid race when ringing channel DB Date: Mon, 11 Dec 2023 14:42:50 +0800 Message-Id: <1702276972-41296-1-git-send-email-quic_qianyu@quicinc.com> X-Mailer: git-send-email 2.7.4 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: SS15zwtudvQ1jNPVx9kJqxPv_KROnGsh X-Proofpoint-ORIG-GUID: SS15zwtudvQ1jNPVx9kJqxPv_KROnGsh 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 adultscore=0 bulkscore=0 impostorscore=0 mlxlogscore=536 mlxscore=0 phishscore=0 spamscore=0 malwarescore=0 lowpriorityscore=0 clxscore=1015 suspectscore=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:14 -0800 (PST) 1. We need a write lock in mhi_gen_tre otherwise there is race of the WP used for ringing channel DB between mhi_queue and M0 transition. 2. We can not invoke local_bh_enable() when irqs are disabled, so move read_lock_irqsave() under the mhi_gen_tre() since we add write_lock_bh() in mhi_gen_tre(). 3. Unlock xfer_cb to prevent potential lockup v1 -> v2: Added write_unlock_bh(&mhi_chan->lock) in mhi_gen_tre() before return because of error process. v2 -> v3: 1. split protecting WP and unlocking xfer_cb into two patches 2. Add a new patch to stop processing buffer and eventof a disabled or stopped channel. v3 -> v4: 1. Modify commit message 2. Add unlock operation before return error v4 -> v5: 1. Squash "protecting WP" and "Take irqsave lock" into one patch 2. Drop patch 3/4 of patch v4 Bhaumik Bhatt (1): bus: mhi: host: Add spinlock to protect WP access when queueing TREs Qiang Yu (1): bus: mhi: host: Drop chan lock before queuing buffers drivers/bus/mhi/host/main.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) -- 2.7.4