Received: by 2002:a05:6a10:83d0:0:0:0:0 with SMTP id o16csp39970pxh; Thu, 7 Apr 2022 13:19:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyDHb4ikySa2qPI6CGwZG30TAEaVbBH/uPy3aZwT6jCCIk9SGJKE6LVx3YpjMpED4eVF1n9 X-Received: by 2002:a17:90a:b903:b0:1ca:be37:1d41 with SMTP id p3-20020a17090ab90300b001cabe371d41mr17976319pjr.9.1649362765011; Thu, 07 Apr 2022 13:19:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649362765; cv=none; d=google.com; s=arc-20160816; b=jI4R3sYWHdzMrW8Zb4buFIY9Q3Enlpv2SN0q88Xo2WzOygaY6RNyQ6Yuy5y9N5tH5v souRwT0yiN93S17dVZ0GlIGT6MMrOtB1yXVAwIoXqhFjMYP0lPB05Wjb4H+kKEmyZVFT w/MkQDLaunFi1nmsXAPrDihkqARKN4FXD3CJRKDNri1kYM5qeCY5+d55UJ900VS+lF41 vgcWumNNooiE263R8S0X6M1zVllouS/ufRRcSwZfLypymeGKPHGvhmnSrFCsuqlAxs9w Db7tmNs9dI98HMhrjoEKdpMW2442+hXuengktppw4kfygmB7Iw+b3rtt6JujqdCS1hqW RAZQ== 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=ilRZ4ek+6KKKYFW419BEN9rdb9L/EYrhdFBp0/hmrUo=; b=UfTD8EKspqJ/G6xvZ8zFAreTblaDeKJ45k/MTz8MYUKk6AYVU8RIZOfhQ5ib3wbGg+ m4IRjPGVO9ZiBLpFkwUXy+M2yFd1D1AEBN303XG/tvh7lnV3ht2WwkK+FrIVze0MebDG oF7l+cdTmGcUMqNuBEtZ+JYTsaB1BGcUyqLXuNcF5S5RQdvTDTyeLcLyD2Grj274XNjU DqvfFkhsFqeEhWbHV03iyP5pQ+5fqWH/s7RIDThGrILX4kkO3c+kxT9d6sm+QRQiuXgx RsSZ9yPPaZADRCuyeA2SNJl+L0nOXqBWnDXi2Fs9Ck5De8YIGog2ZcdCJsaHA66dSlLy QiGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HwJDof5Y; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id k20-20020a17090aaa1400b001ca8fbc8944si2720463pjq.123.2022.04.07.13.19.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 13:19:25 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HwJDof5Y; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 647D4319A05; Thu, 7 Apr 2022 12:37:56 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235285AbiDGOEc (ORCPT + 99 others); Thu, 7 Apr 2022 10:04:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343816AbiDGOC3 (ORCPT ); Thu, 7 Apr 2022 10:02:29 -0400 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45AD64EDF5 for ; Thu, 7 Apr 2022 07:00:28 -0700 (PDT) Received: by mail-pj1-x1032.google.com with SMTP id gt4so5685717pjb.4 for ; Thu, 07 Apr 2022 07:00:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ilRZ4ek+6KKKYFW419BEN9rdb9L/EYrhdFBp0/hmrUo=; b=HwJDof5YSaWRbe0KrDpNtb2vyys012Tla6FVJeqfBFkpIwiK/lgZkwibLPvftaGvE3 IvtDVbmOleQx7jby+JKRyynJN01kNpGQ46O0q9i3QVBPC6iDtnR97XRqyJfkr3AG5bcY AL7zygZ3cCJJTxhuGpho8lWd0glBno8gn1gydMS0jAyWTNBNkc2OFXmvnzMCVKlyddOO +nT83uVha6jRW+cPUwhC9sPv6kJb15hdfq61d8jFmQzlbYsdhgbpOKg44Y8vrhIGueGu GQV9SsJGVrMNdraRFniUYWANhsD96yuvw8oQ4DLKk73Hpf2A1tU+bB2eS0dJygOTXMMt sltQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ilRZ4ek+6KKKYFW419BEN9rdb9L/EYrhdFBp0/hmrUo=; b=fZ4uAtabIZ3oJLVbd88IRc9UhzgtQ3JqaVq1C2dYB1jQxvjHbHKPyvo8YrLSevZpRp jFHuYcL+MKE/80zmgsgNhGFS6tzHGrcF4xWCgAUDQhXCVXNHD8uM0IJiUwTaubY8VF4j FLHMCUYhzwEBwWVxwnpzetpCr5HUYhARmFsfbwEWdaUpITQ87tFhJVpRXu8woIUoYVjB pFiF8a50Vu+1BvNPILLg4/6yHgbyjaDk7gqBbsQcJv2hPRj3z8tQcTGSJlJETOoXS+UR TLpf1TebvdYd9FvnoBt00QiF9ZbqWLuqP77ifldebyJbYjVO4ieVEYHArhOMI5wQpDpB TXTw== X-Gm-Message-State: AOAM532najeQNG8wr60trDrmhQ/JhsKCVKs39Ffrsi+EN5vNLP/z8MxU T1YOXPeB5x0D3nyDVcexbZ2r X-Received: by 2002:a17:90b:164f:b0:1c7:8d20:ff6d with SMTP id il15-20020a17090b164f00b001c78d20ff6dmr16240981pjb.64.1649340027203; Thu, 07 Apr 2022 07:00:27 -0700 (PDT) Received: from thinkpad ([59.92.99.101]) by smtp.gmail.com with ESMTPSA id mn18-20020a17090b189200b001cac1781bb4sm9269222pjb.35.2022.04.07.07.00.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 07:00:26 -0700 (PDT) Date: Thu, 7 Apr 2022 19:30:21 +0530 From: Manivannan Sadhasivam To: Bhaumik Vasav Bhatt Cc: mhi@lists.linux.dev, quic_hemantk@quicinc.com, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, loic.poulain@linaro.org, stable@vger.kernel.org Subject: Re: [PATCH v2] bus: mhi: host: pci_generic: Add missing poweroff() PM callback Message-ID: <20220407140021.GA118957@thinkpad> References: <20220405125907.5644-1-manivannan.sadhasivam@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED 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-kernel@vger.kernel.org On Tue, Apr 05, 2022 at 01:23:22PM -0700, Bhaumik Vasav Bhatt wrote: > > 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. > These two cannot run in parallel because the power down will only happen if the MHI_PCI_DEV_STARTED bit is set in mhi_pdev->status and that's the last step of recovery. But the real issue I found is, if the recovery didn't finish during powerdown() stage, then the function will just return and the device might be powered on later. So to avoid this scenario, we should have the flush_workqueue() in freeze. I'll submit a different patch for that. Thanks, Mani > > .restore = mhi_pci_restore, > > #endif > > };