Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp15073690ybl; Tue, 31 Dec 2019 00:36:11 -0800 (PST) X-Google-Smtp-Source: APXvYqxvm0AfpOiwvG8uH9uvNlALNus6CyJqmNOpxBCfCsFp0IfsC0mrNA6AAhhrGYEPEIt/ioUH X-Received: by 2002:a05:6830:1b7b:: with SMTP id d27mr82280761ote.78.1577781371240; Tue, 31 Dec 2019 00:36:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577781371; cv=none; d=google.com; s=arc-20160816; b=KciWMMgQWwbCZWL2IJHnMQpHjnHmMnbxP4v+tGc1Q2jIk/dPWdrGSBdQu37CMn8G24 YmJJliFEHelIAwPlHMRHF1Qul1p309I9khB1kRLnW4pMV1aVN05CYiVo6rFJOQVI+o9l FZtJriGLn/KKL2lMmB1Bx1jgKTwO0GOsILu3JB7vWvAt9HCGGJWrsEQdN5UdjV3ACJHs zT9Bj90XWEgXEL2FSgbTJ8EGGdOTuNpJEaC4UyzDU23KD1JGx3zp4JJjaUxvls5vlknn FDfdcSYrdNi3PGnTV30+kbxp8zC2psQ1ulvq6vFX8yeDnCpTu4q7MMqbr2Sjl/I16o8h XkNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature; bh=/MyzgTAoW84poPoGQNDvx4+/Q3RCJgT0vSrB6UE39Ec=; b=XFtH6+OfIdC02bB4f6NKEYi+ZFmIGSWpMrUJKArgon8XXtR/Jo7sQfvxFt58fSuLxn W4mE8GadM/CNqc8iVDERLTJFGzU3pFU8ruxwcrJXXDj0rO4/kAlpjLhS+R+ez3zXeYMD SiUz4QOc+hrYKxYm/AZhjaPpWh0vyX6R8Y+5rHlR7X/vTytAwUwdK9FU0nWBudi94y5M WudAl94iSceysHuJQz82hvC4BezXyNTPpcNYvbARmAbGC3q4rzRkP8qRz41VZ7YxOwAI uWADS2NEebCKv1gXqFZUsJJe9n1FG2OhqeIhGnFY9XicgN7FNMyfKIqU2TVZSrEIwDYG Wdrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=EaskGOhh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l6si24515784oti.249.2019.12.31.00.35.59; Tue, 31 Dec 2019 00:36:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=EaskGOhh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726359AbfLaIfP (ORCPT + 99 others); Tue, 31 Dec 2019 03:35:15 -0500 Received: from mail26.static.mailgun.info ([104.130.122.26]:46330 "EHLO mail26.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725793AbfLaIfN (ORCPT ); Tue, 31 Dec 2019 03:35:13 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1577781312; h=Message-ID: References: In-Reply-To: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=/MyzgTAoW84poPoGQNDvx4+/Q3RCJgT0vSrB6UE39Ec=; b=EaskGOhhGl9zE+i3m4via1P21uHkBLczEZnKZgfHlsUfwz5z1AZB9vQTAd7nZORmhI4GiTqh HiAI1NWY9NXPSxWT62gJ4Fj5eAceWUi9oor0oNz78NBT1F/SUTjvAcoD+EuQaaqJ5tLhr6DK CiRp6o6MAa3DYhBGfbsx3DT0tyk= X-Mailgun-Sending-Ip: 104.130.122.26 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by mxa.mailgun.org with ESMTP id 5e0b083d.7fe0130850a0-smtp-out-n03; Tue, 31 Dec 2019 08:35:09 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id ADB6CC447A4; Tue, 31 Dec 2019 08:35:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: cang) by smtp.codeaurora.org (Postfix) with ESMTPSA id A3C10C433CB; Tue, 31 Dec 2019 08:35:06 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 31 Dec 2019 16:35:06 +0800 From: Can Guo To: Stanley Chu Cc: linux-scsi-owner@vger.kernel.org, linux-scsi@vger.kernel.org, martin.petersen@oracle.com, subhashj@codeaurora.org, jejb@linux.ibm.com, chun-hung.wu@mediatek.com, kuohong.wang@mediatek.com, linux-kernel@vger.kernel.org, stable@vger.kernel.org, avri.altman@wdc.com, linux-mediatek@lists.infradead.org, peter.wang@mediatek.com, alim.akhtar@samsung.com, andy.teng@mediatek.com, matthias.bgg@gmail.com, beanhuo@micron.com, pedrom.sousa@synopsys.com, bvanassche@acm.org, linux-arm-kernel@lists.infradead.org, asutoshd@codeaurora.org Subject: Re: [PATCH v1 1/2] scsi: ufs: set device as default active power mode during initialization only In-Reply-To: <1577778290.13164.45.camel@mtkswgap22> References: <1577693546-7598-1-git-send-email-stanley.chu@mediatek.com> <1577693546-7598-2-git-send-email-stanley.chu@mediatek.com> <1577754469.13164.5.camel@mtkswgap22> <836772092daffd8283a97d633e59fc34@codeaurora.org> <1577766179.13164.24.camel@mtkswgap22> <1577778290.13164.45.camel@mtkswgap22> Message-ID: <44393ed9ff3ba9878bae838307e7eec0@codeaurora.org> X-Sender: cang@codeaurora.org User-Agent: Roundcube Webmail/1.3.9 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019-12-31 15:44, Stanley Chu wrote: > Hi Can, > > On Tue, 2019-12-31 at 12:22 +0800, Stanley Chu wrote: >> Hi Can, >> >> >> > Hi Stanley, >> > >> > I see skipping ufshcd_set_ufs_dev_active() in ufshcd_probe_hba() >> > if it is called from ufshcd_resume() path is the purpose here. >> > >> > If so, then ufshcd_set_dev_pwr_mode() would be called, meaning >> > SSU command will be sent. Why is this SSU command needed to be >> > sent after a full host reset and restore? Is ufshcd_probe_hba() >> > not enough to make UFS device fully functional? >> >> After resume (for both runtime resume and system resume), device power >> mode shall be back to "Active" to service incoming requests. >> >> I see two cases need device power mode transition during resume flow >> 1. Device Power Mode = Sleep >> 2. Device Power Mode = PowerDown >> >> For 1, ufshcd_probe_hba() is not invoked during resume flow, >> hba->curr_dev_pwr_mode = SLEEP, thus ufshcd_resume() can invoke >> ufshcd_set_dev_pwr_mode() to change device power mode. >> >> For 2, ufshcd_probe_hba() is invoked during resume flow, before this >> fix, hba->curr_dev_pwr_mode will be set to ACTIVE (note that only this >> flag is set as ACTIVE, but device may be still in PowerDown state if >> device power is not fully shutdown or device HW reset is not executed >> before resume), in the end, ufshcd_resume() will not invoke >> ufshcd_set_dev_pwr_mode() to send SSU command to make device change >> back >> to Active power mode. >> >> But if device is fully reset before resume (not by current mainstream >> driver), device can be already in "Active" power mode after power on >> again during resume flow. In this case, it is OK to set >> hba->curr_dev_pwr_mode as ACTIVE in ufshcd_probe_hba() and SSU command >> is not necessary. >> >> Thanks, >> Stanley > > I think currently the assumption in ufshcd_probe_hba() that "device > shall be already in Active power mode" makes sense because many device > commands will be sent to device in ufshcd_probe_hba() but device is not > promised to handle those commands in PowerDown power mode according to > UFS spec. > > So, maybe always ensuring device being Active power mode before leaving > ufshcd_probe_hba() is more reasonable. If so, I will drop this patch > first. > > Thanks so much for your reviews. > > Happy new year! > > Thanks, > Stanley Hi Stanley, I missed this mail before I hit send. In current code, as per my understanding, UFS device's power state should be Active after ufshcd_link_startup() returns. If I am wrong, please feel free to correct me. Due to you are almost trying to revert commit 7caf489b99a42a, I am just wondering if you encounter failure/error caused by it. Happy new year to you too! Thanks, Can Guo