From patchwork Mon Apr 10 15:58:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeffrey Hugo X-Patchwork-Id: 81549 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1997187vqo; Mon, 10 Apr 2023 09:10:04 -0700 (PDT) X-Google-Smtp-Source: AKy350bXmGO9oDNy0gidLWj0bWk0PjhBQKQL0qsBMODnIqUOsozloJMKv2QGIy4YHmMVHxQCBzjj X-Received: by 2002:a17:907:3f81:b0:93b:62f:82a3 with SMTP id hr1-20020a1709073f8100b0093b062f82a3mr10302551ejc.6.1681143004677; Mon, 10 Apr 2023 09:10:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681143004; cv=none; d=google.com; s=arc-20160816; b=tGhPlPdJzFvKZ5NlJE67YExq4y9LeJQOzteFFlyP+xJlJJaZQ8iO1+5I/oKZIPLUSI 0EHCwi1pO4Ev43SAKMHQ98z+GWwJVu8hnBduGZ2g9RuOjyRED6KmcGN+Nb0JGFrcnGTY /VgUksi5y96l5gQ7URoNI8NgAT9UoRqMoL23hRXBxxI8N/uXNoIJk4cHNvVp4M1wMHV8 Qan0C6BK+LL8DBI/t5dEVyMxDFHfF6cUcGMyM6BN4tCGpIlQmDm9v/Of3D1I6iMNNRZD HZzivmwC8OzLUTbvKuQxlYqiQQ/Sjup4QXfK9vcMVxARpU+KNLUOa25AkbrgE3EzYNVD BLwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=mmcyLRiBJx9gAHhptPzkuDIDBuac3B3MBef4hnojS2M=; b=mTiQ/JuPrXN7VZ9dV+MgY7CE6Ftxuq5DFQzn0RzZlJ6Yq9xCae9Xw09VzOxS5HFUed 0+sbu4n8WyieXmxIVhhcRfPKIy0yinW1ZjMDOomKrVe2lyf4XvxoseH3FQ6FbtrAeC3a YJiJ+1LCuwncf+sJGKwJO/ZD3lmsh6gWLf6l23m/uKj/BvS3Pu64F2QPQ3SdQNA3Cmis 2/Ndm0c6CqpCQ0FEJxQQkuetI8Ei5VwAis1bZWrcjo7KEi8o9/X3hXSh8Ig/a8uXb5RG q73CeEd6Bi5b1FcGSQ4FjBSvVrXVYxk9+IPsJV8bEgV3PIACYN6KCJDTzTOjZzeqgBwm RN/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=WhihGZkG; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m15-20020a17090607cf00b0094a6863fddfsi4063960ejc.430.2023.04.10.09.09.39; Mon, 10 Apr 2023 09:10:04 -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=WhihGZkG; 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 S230196AbjDJP7P (ORCPT + 99 others); Mon, 10 Apr 2023 11:59:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230141AbjDJP7E (ORCPT ); Mon, 10 Apr 2023 11:59:04 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57910B0; Mon, 10 Apr 2023 08:58:47 -0700 (PDT) Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33AAMUiO024759; Mon, 10 Apr 2023 15:58:37 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 : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=mmcyLRiBJx9gAHhptPzkuDIDBuac3B3MBef4hnojS2M=; b=WhihGZkGRgs5ztarMq+wh4Wo2nvZV84EB3c0t6m5YsR5xAtmW4FsogpDcVUfY8P5as0x E18UHmKWrs1MeE4v6jeKpo1/jKRX27Q8PjfvIae5K7L+Q3VOdL5VG+0H1UjpC4a+bY5V Zv3swp/FK827evhJtdgnxDHGU2GUxV2GKWuhUm2/jSGhEr56vnACACa+kp2MG3OvbaRN KjMnarNQAODo6EM+hEOywUUgZO0BvQ1Ln3aOfK6dg2IP1+A9IEGuFXbYQoUCytnHsCqP l4N39n4KMggSGrS02banNVBy1BJ/vUbeCqGWQTVKKkDYoi1N4j+DNbHoB+hNgEzbe6xa lA== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3pu0c33bf6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 10 Apr 2023 15:58:37 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 33AFwaHm015262 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 10 Apr 2023 15:58:36 GMT Received: from jhugo-lnx.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.42; Mon, 10 Apr 2023 08:58:36 -0700 From: Jeffrey Hugo To: CC: , , , Jeffrey Hugo , Subject: [PATCH v2 1/2] bus: mhi: host: Remove duplicate ee check for syserr Date: Mon, 10 Apr 2023 09:58:11 -0600 Message-ID: <1681142292-27571-2-git-send-email-quic_jhugo@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1681142292-27571-1-git-send-email-quic_jhugo@quicinc.com> References: <1681142292-27571-1-git-send-email-quic_jhugo@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: 6ESPAp2ed3QSNIlH3WOqeug9W06acyNm X-Proofpoint-ORIG-GUID: 6ESPAp2ed3QSNIlH3WOqeug9W06acyNm X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-10_11,2023-04-06_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 priorityscore=1501 bulkscore=0 lowpriorityscore=0 phishscore=0 mlxscore=0 suspectscore=0 clxscore=1015 spamscore=0 malwarescore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304100135 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762806207025517299?= X-GMAIL-MSGID: =?utf-8?q?1762806207025517299?= If we detect a system error via intvec, we only process the syserr if the current ee is different than the last observed ee. The reason for this check is to prevent bhie from running multiple times, but with the single queue handling syserr, that is not possible. The check can cause an issue with device recovery. If PBL loads a bad SBL via BHI, but that SBL hangs before notifying the host of an ee change, then issuing soc_reset to crash the device and retry (after supplying a fixed SBL) will not recover the device as the host will observe a PBL->PBL transition and not process the syserr. The device will be stuck until either the driver is reloaded, or the host is rebooted. Instead, remove the check so that we can attempt to recover the device. Fixes: ef2126c4e2ea ("bus: mhi: core: Process execution environment changes serially") Cc: stable@vger.kernel.org Signed-off-by: Jeffrey Hugo Reviewed-by: Carl Vanderlip Reviewed-by: Manivannan Sadhasivam --- drivers/bus/mhi/host/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/bus/mhi/host/main.c b/drivers/bus/mhi/host/main.c index 4fa0969..3a08518 100644 --- a/drivers/bus/mhi/host/main.c +++ b/drivers/bus/mhi/host/main.c @@ -503,7 +503,7 @@ irqreturn_t mhi_intvec_threaded_handler(int irq_number, void *priv) } write_unlock_irq(&mhi_cntrl->pm_lock); - if (pm_state != MHI_PM_SYS_ERR_DETECT || ee == mhi_cntrl->ee) + if (pm_state != MHI_PM_SYS_ERR_DETECT) goto exit_intvec; switch (ee) { From patchwork Mon Apr 10 15:58:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeffrey Hugo X-Patchwork-Id: 81544 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1988758vqo; Mon, 10 Apr 2023 08:59:58 -0700 (PDT) X-Google-Smtp-Source: AKy350Y+e8tZb4+u+PCB/0d68Yso6InL8sIW2ciJ7MwK2J/ojCotcivQnB7sbK5vTmVHdmYebUqe X-Received: by 2002:a05:6a20:4992:b0:e3:86d1:55e8 with SMTP id fs18-20020a056a20499200b000e386d155e8mr11266783pzb.53.1681142398479; Mon, 10 Apr 2023 08:59:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681142398; cv=none; d=google.com; s=arc-20160816; b=N1VEnA75RvGjiAZnOKcwfTHjbL1DHESMmQIQUA9yBLfgiG7PZigJwQe3F0tVppPlOo 2fIqKZEuc9ro7sgJKogyf9TyB2e8Yfb/S1LFPNj5aHF5sS+Oj7paWLWctdYU8ng4/dW+ I/E7wOzF1HIIm7Sr4Sa0xZ3evNHDxEnYil2x/jR1I5UfElnkrDVt6EJCC5mehvT3leJ6 Sd95x0l5qIzCDVRf5lzXOySrLulY3uY2lMUwPFJE51w0po/xkvFU7qlFhdt2vcI461LC Z9PH8h6Wp8WcemLM12xzp5ulcrH6FFOjHpAXu1tNZdLhdFRUFFda6/88PAa9iR4OZX+6 H9mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=szHzoq7tKGJqYuNdYwz346FzwL2/2yEwJcW7cR8g3iQ=; b=JBbphQjK+GhBx7aIXwvhe5gt+g7AbELXUg/PkLdHKWlyyqJUOBgitrCHj+Qr2z1fsU LmZx6UIFR5AMkOlvMsOURHdAY1WOSHXjuPImdh/AX37pf/6pPu10qQdb8qRo7ixIM3sX ml6qp5Jh+Ae8p8MikY6fxjVRxqIBAKat72F5PiCIvkjCq7iSMb9YwTT3wtRP6vqlCR6V 2ExO01VWbn2bQHWeZ0EVkUti8GKra18nn4EBdFF8x76BkooRTFyVWShQXu4NguDaXsja 6a3jqTQm7quaLZ5AeCjIMFZOkazLSXcoDmMwzyISKsreVo8kamTyYDEJuL6l2GMzUvns NWuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=I8AlcvLn; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f2-20020aa79682000000b006385c1cac93si2461564pfk.280.2023.04.10.08.59.45; Mon, 10 Apr 2023 08:59:58 -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=I8AlcvLn; 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 S230169AbjDJP7J (ORCPT + 99 others); Mon, 10 Apr 2023 11:59:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230135AbjDJP7A (ORCPT ); Mon, 10 Apr 2023 11:59:00 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB40C12F; Mon, 10 Apr 2023 08:58:43 -0700 (PDT) Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33AFTKoQ015004; Mon, 10 Apr 2023 15:58:40 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 : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=szHzoq7tKGJqYuNdYwz346FzwL2/2yEwJcW7cR8g3iQ=; b=I8AlcvLnM8kdJnnzhAeXwGbl2D+R/BCyEUfLU5hBUxnXY5DRnFPaoxTxeH+tDNC5ix5k 4X/PRft4whmxiLDUiL574Ksmbr37iB6sGC4ggI2i5N7M6QT4G/S4iLLe2d4JWqVocgdz nA1MhGj0ZGHwHILmj4KFX6lH1Gm6zZhuIHxndyv+svE9JsvWLM2ISacUI/zypjruD3cx pBcO5xKQSuxbXyth5sCflcuWHtCrLvtVGRCS9eXb5asXWQHUfg+sltmeGFu+8cv0mrhp 0GBwc434cAPeZDX6SsV/3ACMs3OAm6QZJpui/2SSz+/B0igae/llybGnBeRrJ7LElWdD nA== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3pvgmermy1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 10 Apr 2023 15:58:40 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 33AFwdAR015864 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 10 Apr 2023 15:58:39 GMT Received: from jhugo-lnx.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.42; Mon, 10 Apr 2023 08:58:38 -0700 From: Jeffrey Hugo To: CC: , , , Jeffrey Hugo , Subject: [PATCH v2 2/2] bus: mhi: host: Use mhi_tryset_pm_state() for setting fw error state Date: Mon, 10 Apr 2023 09:58:12 -0600 Message-ID: <1681142292-27571-3-git-send-email-quic_jhugo@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1681142292-27571-1-git-send-email-quic_jhugo@quicinc.com> References: <1681142292-27571-1-git-send-email-quic_jhugo@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: 6qFdGaaplweUuw7U9x42DW_mRYauH-ES X-Proofpoint-ORIG-GUID: 6qFdGaaplweUuw7U9x42DW_mRYauH-ES X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-10_11,2023-04-06_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 spamscore=0 phishscore=0 priorityscore=1501 mlxlogscore=816 impostorscore=0 adultscore=0 mlxscore=0 malwarescore=0 clxscore=1015 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304100135 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762805571543968713?= X-GMAIL-MSGID: =?utf-8?q?1762805571543968713?= If firmware loading fails, the controller's pm_state is updated to MHI_PM_FW_DL_ERR unconditionally. This can corrupt the pm_state as the update is not done under the proper lock, and also does not validate the state transition. The firmware loading can fail due to a detected syserr, but if MHI_PM_FW_DL_ERR is unconditionally set as the pm_state, the handling of the syserr can break when it attempts to transition from syserr detect, to syserr process. By grabbing the lock, we ensure we don't race with some other pm_state update. By using mhi_try_set_pm_state(), we check that the transition to MHI_PM_FW_DL_ERR is valid via the state machine logic. If it is not valid, then some other transition is occurring like syserr processing, and we assume that will resolve the firmware loading error. Fixes: 12e050c77be0 ("bus: mhi: core: Move to an error state on any firmware load failure") Cc: stable@vger.kernel.org Signed-off-by: Jeffrey Hugo Reviewed-by: Carl Vanderlip Reviewed-by: Manivannan Sadhasivam --- drivers/bus/mhi/host/boot.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/bus/mhi/host/boot.c b/drivers/bus/mhi/host/boot.c index 1c69fee..d2a19b07 100644 --- a/drivers/bus/mhi/host/boot.c +++ b/drivers/bus/mhi/host/boot.c @@ -391,6 +391,7 @@ void mhi_fw_load_handler(struct mhi_controller *mhi_cntrl) { const struct firmware *firmware = NULL; struct device *dev = &mhi_cntrl->mhi_dev->dev; + enum mhi_pm_state new_state; const char *fw_name; void *buf; dma_addr_t dma_addr; @@ -508,14 +509,18 @@ void mhi_fw_load_handler(struct mhi_controller *mhi_cntrl) } error_fw_load: - mhi_cntrl->pm_state = MHI_PM_FW_DL_ERR; - wake_up_all(&mhi_cntrl->state_event); + write_lock_irq(&mhi_cntrl->pm_lock); + new_state = mhi_tryset_pm_state(mhi_cntrl, MHI_PM_FW_DL_ERR); + write_unlock_irq(&mhi_cntrl->pm_lock); + if (new_state == MHI_PM_FW_DL_ERR) + wake_up_all(&mhi_cntrl->state_event); } int mhi_download_amss_image(struct mhi_controller *mhi_cntrl) { struct image_info *image_info = mhi_cntrl->fbc_image; struct device *dev = &mhi_cntrl->mhi_dev->dev; + enum mhi_pm_state new_state; int ret; if (!image_info) @@ -526,8 +531,11 @@ int mhi_download_amss_image(struct mhi_controller *mhi_cntrl) &image_info->mhi_buf[image_info->entries - 1]); if (ret) { dev_err(dev, "MHI did not load AMSS, ret:%d\n", ret); - mhi_cntrl->pm_state = MHI_PM_FW_DL_ERR; - wake_up_all(&mhi_cntrl->state_event); + write_lock_irq(&mhi_cntrl->pm_lock); + new_state = mhi_tryset_pm_state(mhi_cntrl, MHI_PM_FW_DL_ERR); + write_unlock_irq(&mhi_cntrl->pm_lock); + if (new_state == MHI_PM_FW_DL_ERR) + wake_up_all(&mhi_cntrl->state_event); } return ret;