Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp9990167rwp; Thu, 20 Jul 2023 12:51:02 -0700 (PDT) X-Google-Smtp-Source: APBJJlEg5j9WjJ0Mw96Vg0R2WL+nKli7N4frPh/617RhXG+dfTNCQoRmEITfeleoIiv09x5qsYb7 X-Received: by 2002:a17:907:3d8a:b0:994:fec:e1b7 with SMTP id he10-20020a1709073d8a00b009940fece1b7mr6616725ejc.0.1689882662521; Thu, 20 Jul 2023 12:51:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689882662; cv=none; d=google.com; s=arc-20160816; b=hPv6vCfSGkyrXLdISTOhiuisP40mt8FlP03K0JwOHUiIQsL/RI27anlAeQYgq2Jfac coZet0d4LjCQPLcmGL+yXz+j5BZUE76Vcc4nDL8GaZhmb2O6URPu+P18OMo5ilmQGzlG Hx3a+0U+L2IvRzpM/DJk/FqNijD/t7uDeg99/dmVEZLKPqWk7Sy5X217I4ezp+DijgOK ug0t4ISlA9fr0u+uE0fD5QG1+TzxdHFQtrfamn8aeaKmE9LAXSnokpwLcc7Tjy3UPD0a ntCoJqZH7jrd1KzBRLofBOplZqUokzWR4Xz2bBB3sAXXPxuOcnbUggMjr7bVpDwUMfS4 d/+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=BgoWEOSu5VAgz/EY6ImELAyLlVmK6s8QoLF1e2UUL94=; fh=8EJrCEsKIDWZTs0BumawpsDWI0ijgrCvtvlDWDGP7ZA=; b=aWeKErT9zyWG47TJPD7/gKZrPjwZbWSLLY82m0yeAd8M+OLbXIGGuvijgfzxak2Sea FG8EkqVp8b/gOIMCiI9JHXpezA3t46zr4bIBRR+uQnbizsz6TPN+2iWT14E7io8J0oY8 ioVZrSCMu9yQp8P+dMGCvXzFGzBCQymKb7t9GqbeLMLrLmUAut3O3a3YmqAgmSv5zSeJ 3sczM1Pka5OeAuAYYRW3F3q9qG6eGGLuEytsfBY9RmKmKU7v4m6MndfV15le8L61EBF3 9Tp1OTeUi3nSNNGhBoAi4XL2vO10tb1p/ctC8l2hvI4ILVOIaYXCcrKhrPtcwlTsDswh qgyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=J7KGdhPl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o1-20020a170906288100b00965a6d6b536si1130147ejd.335.2023.07.20.12.50.38; Thu, 20 Jul 2023 12:51:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=J7KGdhPl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229614AbjGTSrz (ORCPT + 99 others); Thu, 20 Jul 2023 14:47:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbjGTSry (ORCPT ); Thu, 20 Jul 2023 14:47:54 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C620BE4C; Thu, 20 Jul 2023 11:47:53 -0700 (PDT) Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36KFxHWX013040; Thu, 20 Jul 2023 18:47:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=qcppdkim1; bh=BgoWEOSu5VAgz/EY6ImELAyLlVmK6s8QoLF1e2UUL94=; b=J7KGdhPl9mk54l1P9aWxZ47QQ2LqjM5QBU8yH93R2eAdlkSwRWBlEY5CvvBqDDGeSEEM M45qFK+y6ZSIYa6/mg3ESjmtFcKUkFN/a8+CnOLDwalzN3JaMZLW3eTi/TcX5z3aQQY9 aVZuxzoe/6YMSdMVsMMCWX3WgbZt6eKbFv0XPlhivTZusbhQCvSOyurmV4siRTfPRTfr wXV3cYV/mwmlmqSqwZEzXv+7lEuLZPPWi0FswZ7HjwdmFfqi8Jai+nbFe60V1ykBIkkk AfXKe4yS0uZJApMhmYQfMGERz14+ii+mnAQVmmKmRYaRHPfHwve1IGIpG91xnqu8YR+5 Dg== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3rxup4j2tu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Jul 2023 18:47:23 +0000 Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 36KIlMwP012076 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Jul 2023 18:47:22 GMT Received: from hu-bjorande-lv.qualcomm.com (10.49.16.6) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Thu, 20 Jul 2023 11:47:22 -0700 Date: Thu, 20 Jul 2023 11:47:21 -0700 From: Bjorn Andersson To: Chengfeng Ye CC: , , , , , , , Subject: Re: [PATCH v2] mfd: qcom-pm8xxx: Fix potential deadlock on &chip->pm_irq_lock Message-ID: <20230720184721.GC2667611@hu-bjorande-lv.qualcomm.com> References: <20230720071330.50382-1-dg573847474@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20230720071330.50382-1-dg573847474@gmail.com> X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01c.na.qualcomm.com (10.47.97.35) To nalasex01c.na.qualcomm.com (10.47.97.35) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: CrBcRF-os3zqeV5lUjvHtyZplfxJ9FBz X-Proofpoint-ORIG-GUID: CrBcRF-os3zqeV5lUjvHtyZplfxJ9FBz X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-20_10,2023-07-20_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 spamscore=0 adultscore=0 mlxlogscore=641 lowpriorityscore=0 suspectscore=0 priorityscore=1501 clxscore=1011 bulkscore=0 mlxscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307200158 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,T_SCC_BODY_TEXT_LINE 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: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 20, 2023 at 07:13:30AM +0000, Chengfeng Ye wrote: > As &chip->pm_irq_lock is acquired by pm8xxx_irq_handler() under irq > context, other process context code should disable irq before acquiring > the lock. > > Since .irq_set_type and .irq_get_irqchip_state callbacks are generally > executed from process context without irq disabled by default, the same > lock acquision should disable irq. > > Possible deadlock scenario > pm8xxx_irq_set_type() > -> pm8xxx_config_irq() > -> spin_lock(&chip->pm_irq_lock) > > -> pm8xxx_irq_handler() > -> pm8xxx_irq_master_handler() > -> pm8xxx_irq_block_handler() > -> pm8xxx_read_block_irq() > -> spin_lock(&chip->pm_irq_lock) (deadlock here) > > This flaw was found using an experimental static analysis tool we are > developing for irq-related deadlock. > > Fix the potential deadlock by spin_lock_irqsave(). > > Signed-off-by: Chengfeng Ye Reviewed-by: Bjorn Andersson Regards, Bjorn