Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2832920pxv; Mon, 12 Jul 2021 03:04:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx52G2ndBC9MoY+MldI/HTyOSCOTS5MHGiW6HPdwyocKs6fpse2zcB5bvgbYaKlHWZIfSSG X-Received: by 2002:a5d:914a:: with SMTP id y10mr39915069ioq.140.1626084270748; Mon, 12 Jul 2021 03:04:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626084270; cv=none; d=google.com; s=arc-20160816; b=nFnIAeLZy1TglFJwx38Ih4BDXpXPOPxqTDrtoGbhJlhCUHkqwyBiqZZtgc7coHvHN5 BqB7mOb8Mm1W73gBcWEuHDggt1hTfFMw8AJpv8yhZqhgtQOC6oIHDLD4BzHAqM3ChDbg 5yfGRqk5Iud9BcND+30R8E+soLmLQSZJa6EzZ8JxP3YzFWaU2+euknqQmFBa4KC42gAZ Y127J2bQSxZ7SwQTJlUX+FlA5yTeJm9JNBILq6YLTcBAjs2L9i6P/HO2mlRRrcxpLNHD voiHnq8eRkd/1fz12PivGA6fzxWsZdmRcPFw2Hi/2h30jMfT8gK56OHnjlm7tn4P5uy1 5eEw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=xBdiy8hoIvmPQ0S0pBNlI378emnoMVAgVmCZBVAaGCc=; b=zU8ACwdlsR3lvYreRQiKiwn5G0qM+pwhebLGS7BKhLH61+HuY7YIv1wvzRUbW8n9Em 19pZ9Mg/kKmj3RRtpgj3wuAilvXWqdrDam10XZC/AXl710hdIKQjKz7Mj8hUPLto67Ag +36JHoAxWlRxEjuumt4nMomhj1CS1gsIfWP2ewebW/6LuCi2JlWN/7V5ALe/qPBLg6Z4 7AyoMvirna+3u5Q56qP4jzYmzXftuwwiiwMai4Mwt99waHmeh3DosawJjLFUQbFl8QKT JB5SezbB0tV/0Fg4QplDDPJnL/msMSwFB+xK4lVUoMFKbE/85UVCc2711uqsjLu3pnXm z+WQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GISSykWT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d198si17168721jac.70.2021.07.12.03.04.16; Mon, 12 Jul 2021 03:04:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GISSykWT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345155AbhGLHZB (ORCPT + 99 others); Mon, 12 Jul 2021 03:25:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:56792 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239720AbhGLG6S (ORCPT ); Mon, 12 Jul 2021 02:58:18 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 39C4F61221; Mon, 12 Jul 2021 06:55:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626072923; bh=J0nygtlwOBdS5jsxPSDFu4f3APcnLSibPSpRauofCA8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GISSykWTkK5hzQXck3PTymiQ/JLBZt7RF0HpA34mNKuSxMiiqLjjbZvejzuvR1Q0j vXJuxdd7KQcPd7xm+sHwyFikRH5eJ3iZ2wkDroBrlk96IzqKXJIXXMghKURn5SAKyt m6BVQW3SLuM5ZT84HZcficcoM3bV4Tah/Oi+9A3E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Baochen Qiang , Hemant Kumar , Manivannan Sadhasivam Subject: [PATCH 5.12 066/700] bus: mhi: Wait for M2 state during system resume Date: Mon, 12 Jul 2021 08:02:29 +0200 Message-Id: <20210712060934.044256474@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060924.797321836@linuxfoundation.org> References: <20210712060924.797321836@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Baochen Qiang commit 02b49cd1174527e611768fc2ce0f75a74dfec7ae upstream. During system resume, MHI host triggers M3->M0 transition and then waits for target device to enter M0 state. Once done, the device queues a state change event into ctrl event ring and notifies MHI host by raising an interrupt, where a tasklet is scheduled to process this event. In most cases, the tasklet is served timely and wait operation succeeds. However, there are cases where CPU is busy and cannot serve this tasklet for some time. Once delay goes long enough, the device moves itself to M1 state and also interrupts MHI host after inserting a new state change event to ctrl ring. Later when CPU finally has time to process the ring, there will be two events: 1. For M3->M0 event, which is the first event to be processed queued first. The tasklet handler serves the event, updates device state to M0 and wakes up the task. 2. For M0->M1 event, which is processed later, the tasklet handler triggers M1->M2 transition and updates device state to M2 directly, then wakes up the MHI host (if it is still sleeping on this wait queue). Note that although MHI host has been woken up while processing the first event, it may still has no chance to run before the second event is processed. In other words, MHI host has to keep waiting till timeout causing the M0 state to be missed. kernel log here: ... Apr 15 01:45:14 test-NUC8i7HVK kernel: [ 4247.911251] mhi 0000:06:00.0: Entered with PM state: M3, MHI state: M3 Apr 15 01:45:14 test-NUC8i7HVK kernel: [ 4247.917762] mhi 0000:06:00.0: State change event to state: M0 Apr 15 01:45:14 test-NUC8i7HVK kernel: [ 4247.917767] mhi 0000:06:00.0: State change event to state: M1 Apr 15 01:45:14 test-NUC8i7HVK kernel: [ 4338.788231] mhi 0000:06:00.0: Did not enter M0 state, MHI state: M2, PM state: M2 ... Fix this issue by simply adding M2 as a valid state for resume. Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-01720.1-QCAHSPSWPL_V1_V2_SILICONZ_LITE-1 Cc: stable@vger.kernel.org Fixes: 0c6b20a1d720 ("bus: mhi: core: Add support for MHI suspend and resume") Signed-off-by: Baochen Qiang Reviewed-by: Hemant Kumar Reviewed-by: Manivannan Sadhasivam Link: https://lore.kernel.org/r/20210524040312.14409-1-bqiang@codeaurora.org [mani: slightly massaged the commit message] Signed-off-by: Manivannan Sadhasivam Link: https://lore.kernel.org/r/20210621161616.77524-4-manivannan.sadhasivam@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/bus/mhi/core/pm.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/bus/mhi/core/pm.c +++ b/drivers/bus/mhi/core/pm.c @@ -911,6 +911,7 @@ int mhi_pm_resume(struct mhi_controller ret = wait_event_timeout(mhi_cntrl->state_event, mhi_cntrl->dev_state == MHI_STATE_M0 || + mhi_cntrl->dev_state == MHI_STATE_M2 || MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state), msecs_to_jiffies(mhi_cntrl->timeout_ms));