Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1197927iog; Tue, 14 Jun 2022 00:52:52 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vXCEg5MSAhROdZdFsLf2xV4kqyyQDMmjoK+OmhPKNY1xhd6KVpIluTfJRQUFmLwUr9A9vY X-Received: by 2002:a17:902:f682:b0:164:3d5:74c1 with SMTP id l2-20020a170902f68200b0016403d574c1mr3234611plg.60.1655193172406; Tue, 14 Jun 2022 00:52:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655193172; cv=none; d=google.com; s=arc-20160816; b=vh4yt9DnJVrva3UdZGpq6Qf24Xf4kAD0r9VOYH8Z8ZWDhyWSNfWYuSdfAr7rnR/7I4 X1wEJhdsZITVPkmNTHewOCwWxhPrQguJr8ghM/0bAa1D+uQgP2+8Ed7ktZAC4Tbo5MTH FL6LZABxqIzqoOBbzsl5NSW2/EzqHgtRoMHecA//JA+U0eL/hJsssF7EEuMJ+x9F2Hr8 bXEbOS/uTWGCWoF8ynsjQ8y5HSk+/5GBEPvzP+xD/GkQJ1+FzhwiErjB+jCeJFo+O1+b UESzTNSdjJ3sBuaaA0U43aELx4hGWXTj4XCirk2JchWR1YciYdWf8hDIyb/2rTTITf24 lpMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=i4/PtIF7xNTaRzrdUbeRct9QcujJ85m4MgCl0Go37Ks=; b=zjia9AJFRiVl/bqpKXm1b8LPUkEllOB7cfgw6JGtFGsE3+ctcK8dfN8yGmBwu0rGKH Y9V3rpSzLQarhJh2R1ek2ZUJYOi8RMk2/C6MMMUhl5UkiqRhRTiW+wS90Ga1fFMHGQ8V VmlgKYvUslOZSJ6AC4hY/aoBJEqlcPWmMcNs2Av8opSFYs7pO6W87FptWaOrCil7QRPQ 9yqsnBAJ4P7hxz1l9zF87PcEaNq5YV5AUkvIrj3a1wwTZxAm09hTeCLHRADeTiOd1dUZ /F7m+RJwRoI5G+SOwZPgDrGQMlj7MmNKsf3hTOvTy1H6UR3mk6lkcynyVYqiH8SgkfGo Mx4w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u2-20020a170902e80200b00161ba2ffeb8si13663256plg.557.2022.06.14.00.52.38; Tue, 14 Jun 2022 00:52:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-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; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355292AbiFNHvh (ORCPT + 65 others); Tue, 14 Jun 2022 03:51:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352435AbiFNHuq (ORCPT ); Tue, 14 Jun 2022 03:50:46 -0400 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACCCC3EF06 for ; Tue, 14 Jun 2022 00:50:36 -0700 (PDT) X-UUID: 38d28a7ca6a44524b684f0d6f53acdc3-20220614 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.6,REQID:de3d928b-12ca-4eb4-b001-d22e46d88140,OB:0,LO B:0,IP:0,URL:5,TC:0,Content:-5,EDM:0,RT:0,SF:0,FILE:0,RULE:Release_Ham,ACT ION:release,TS:0 X-CID-META: VersionHash:b14ad71,CLOUDID:43b860c5-c67b-4a73-9b18-726dd8f2eb58,C OID:IGNORED,Recheck:0,SF:nil,TC:nil,Content:0,EDM:-3,IP:nil,URL:1,File:nil ,QS:nil,BEC:nil,COL:0 X-UUID: 38d28a7ca6a44524b684f0d6f53acdc3-20220614 Received: from mtkexhb02.mediatek.inc [(172.21.101.103)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1735940368; Tue, 14 Jun 2022 15:50:32 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.15; Tue, 14 Jun 2022 15:50:31 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.3 via Frontend Transport; Tue, 14 Jun 2022 15:50:31 +0800 From: Deren Wu To: Felix Fietkau , Lorenzo Bianconi CC: Sean Wang , Soul Huang , YN Chen , Leon Yen , "Eric-SY Chang" , Deren Wu , KM Lin , Robin Chiu , CH Yeh , Posh Sun , Eric Liang , Stella Chang , "Evelyn Tsai" , Ryder Lee , "Shayne Chen" , linux-wireless , linux-mediatek , Deren Wu Subject: [PATCH v2] mt76: mt7921s: fix possible sdio deadlock in command fail Date: Tue, 14 Jun 2022 15:50:24 +0800 Message-ID: X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 Content-Type: text/plain X-MTK: N X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,MAY_BE_FORGED, SPF_HELO_PASS,T_SCC_BODY_TEXT_LINE,T_SPF_TEMPERROR,UNPARSEABLE_RELAY 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-wireless@vger.kernel.org From: Deren Wu Move sdio_release_host() to final resource handing Fixes: b12deb5e86fa ("mt76: mt7921s: fix mt7921s_mcu_[fw|drv]_pmctrl") Reported-by: YN Chen Co-developed-by: Lorenzo Bianconi Signed-off-by: Lorenzo Bianconi Signed-off-by: Deren Wu --- v2: 1. Align the code with mt7921e 2. Add Lorenzo in co-developer --- drivers/net/wireless/mediatek/mt76/mt7921/sdio_mcu.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/sdio_mcu.c b/drivers/net/wireless/mediatek/mt76/mt7921/sdio_mcu.c index 54a5c712a3c3..c572a3107b8b 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/sdio_mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/sdio_mcu.c @@ -136,8 +136,8 @@ int mt7921s_mcu_fw_pmctrl(struct mt7921_dev *dev) struct sdio_func *func = dev->mt76.sdio.func; struct mt76_phy *mphy = &dev->mt76.phy; struct mt76_connac_pm *pm = &dev->pm; - int err = 0; u32 status; + int err; sdio_claim_host(func); @@ -148,7 +148,7 @@ int mt7921s_mcu_fw_pmctrl(struct mt7921_dev *dev) 2000, 1000000); if (err < 0) { dev_err(dev->mt76.dev, "mailbox ACK not cleared\n"); - goto err; + goto out; } } @@ -156,18 +156,18 @@ int mt7921s_mcu_fw_pmctrl(struct mt7921_dev *dev) err = readx_poll_timeout(mt76s_read_pcr, &dev->mt76, status, !(status & WHLPCR_IS_DRIVER_OWN), 2000, 1000000); +out: sdio_release_host(func); -err: if (err < 0) { dev_err(dev->mt76.dev, "firmware own failed\n"); clear_bit(MT76_STATE_PM, &mphy->state); - err = -EIO; + return -EIO; } pm->stats.last_doze_event = jiffies; pm->stats.awake_time += pm->stats.last_doze_event - pm->stats.last_wake_event; - return err; + return 0; } -- 2.18.0