Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp978065pxb; Wed, 6 Apr 2022 05:53:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxLwtoSFINfC65s8MQ+bC6VjRBSp2MqQ5zx4K1S7M8WBFDJL32+eeQLWkV4nshT+WrzG8fY X-Received: by 2002:a17:90b:1d02:b0:1c7:1802:c00e with SMTP id on2-20020a17090b1d0200b001c71802c00emr9754551pjb.99.1649249599104; Wed, 06 Apr 2022 05:53:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649249599; cv=none; d=google.com; s=arc-20160816; b=xPxeFMVCoSsPC4ctLk+O9UFutl670WoosWaVL1h+SWx4nmSk4aqP1gimR6SdLKoz9f CS4AmaVPDIFumjrBB8QT5Kd9/jmZbFDdSef7bH6KfpuGhcvOIm/4KX+sBXRr8kXerrpi dAX3ao+BxXGF+PwQ6cN1fR2BEO9HddrPzfc3pqfQHix0JJLlwHvhZ569pIAHzl6aS0Fb Ht5zHMgrJEaiNt91uqU06IH9TjZ5mOf2hFsQ6DMjfKa59JZLi+hyfGygnDE6fjdcNJad z54QbaOrYs5sKQIbEaDBwlxQc79Q+2i7DvYRfuA7nCd7+BrOFNosNd5GwlQ+6gh3sWQE ps2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=+7AtI8Svdw+YyS90Bb5N100rWVe2spjtKW5TxoNJUo0=; b=089wNloRpI4lUKkywN4/zXd56dDK5DX3sqF/kcNShQDTS7nAA1n7z28b369Q+CEw9D CcKl3WqBr8E1jnnUJhAqS8P1n8H8KoTdpvG3rcW6XC7a5lmMaCYn1T4I6442yerx5zXv xSXOB/kEdr9V6S/W1nIu8kkT3ggMcsM1FZ4Y8w1pZv6E35LQaNlDxqSf6Nucg8PR7eTD ZRS/lgrytBQLvzt5+kYo1yn8oTiAYZ8iRxtDq3S2/EUhNh4dTQHE4EFrJXD+/b0kEcdc VfilFtF9BSA7XyoxuO9ROIBfglF4TXUSaTUSAoTe4eCu64slQCE3BOGXS423xPnt0lXZ EnqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=f8PILEMa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id 142-20020a621894000000b004fa3a8e008fsi14560649pfy.326.2022.04.06.05.53.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 05:53:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=f8PILEMa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9B85F4E7D88; Wed, 6 Apr 2022 02:54:50 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1848662AbiDFCZF (ORCPT + 99 others); Tue, 5 Apr 2022 22:25:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352510AbiDEUt3 (ORCPT ); Tue, 5 Apr 2022 16:49:29 -0400 Received: from alexa-out-sd-01.qualcomm.com (alexa-out-sd-01.qualcomm.com [199.106.114.38]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B40A42AC4; Tue, 5 Apr 2022 13:23:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1649190216; x=1680726216; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=+7AtI8Svdw+YyS90Bb5N100rWVe2spjtKW5TxoNJUo0=; b=f8PILEMau1vB44h12kQZMho1IshiPyRNzOt+amq9svlQ1Ao+n8jcdHRA yKx3WmD8QIBBX5naiwVV2featY2FuC3oH2Hqu+YaB51B1bqsJdcRPvapS tvS5TgIQA+JZ7iOf1CbANi5fFomrID/sC8R9sB3lLgmX7P5X3WHzrbJd6 E=; Received: from unknown (HELO ironmsg01-sd.qualcomm.com) ([10.53.140.141]) by alexa-out-sd-01.qualcomm.com with ESMTP; 05 Apr 2022 13:23:24 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg01-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Apr 2022 13:23:24 -0700 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Tue, 5 Apr 2022 13:23:23 -0700 Received: from [10.110.86.177] (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.22; Tue, 5 Apr 2022 13:23:22 -0700 Message-ID: Date: Tue, 5 Apr 2022 13:23:22 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.0 Subject: Re: [PATCH v2] bus: mhi: host: pci_generic: Add missing poweroff() PM callback Content-Language: en-US To: Manivannan Sadhasivam , CC: , , , , References: <20220405125907.5644-1-manivannan.sadhasivam@linaro.org> From: Bhaumik Vasav Bhatt In-Reply-To: <20220405125907.5644-1-manivannan.sadhasivam@linaro.org> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01a.na.qualcomm.com (10.47.209.196) X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE 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 On 4/5/2022 5:59 AM, Manivannan Sadhasivam wrote: > During hibernation process, once thaw() stage completes, the MHI endpoint > devices will be in M0 state post recovery. After that, the devices will be > powered down so that the system can enter the target sleep state. During > this stage, the PCI core will put the devices in D3hot. But this transition > is allowed by the MHI spec. The devices can only enter D3hot when it is in > M3 state. > > So for fixing this issue, let's add the poweroff() callback that will get > executed before putting the system in target sleep state during > hibernation. This callback will power down the device properly so that it > could be restored during restore() or thaw() stage. > > Cc: stable@vger.kernel.org > Fixes: 5f0c2ee1fe8d ("bus: mhi: pci-generic: Fix hibernation") > Reported-by: Hemant Kumar > Suggested-by: Hemant Kumar > Signed-off-by: Manivannan Sadhasivam > --- > > Changes in v2: > > * Hemant suggested to use restore function for poweroff() callback as we can > make sure that the device gets powered down properly. > > drivers/bus/mhi/host/pci_generic.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/bus/mhi/host/pci_generic.c b/drivers/bus/mhi/host/pci_generic.c > index 9527b7d63840..ef85dbfb3216 100644 > --- a/drivers/bus/mhi/host/pci_generic.c > +++ b/drivers/bus/mhi/host/pci_generic.c > @@ -1085,6 +1085,7 @@ static const struct dev_pm_ops mhi_pci_pm_ops = { > .resume = mhi_pci_resume, > .freeze = mhi_pci_freeze, > .thaw = mhi_pci_restore, > + .poweroff = mhi_pci_freeze, It is possible that .thaw() queues recovery work and recovery work is still running while .poweroff() is called. I would suggest adding a flush_work() in freeze such that we don't try to power off while we're also trying to power on MHI from recovery work. > .restore = mhi_pci_restore, > #endif > };