Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp14033175pxu; Mon, 4 Jan 2021 11:00:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJzpAvZWGE02V+E0eQbafTu0+bcsvTlA8Sfr9aMyjpGEyr7K3FU2TT9LTaq52wob9SMItE8d X-Received: by 2002:a05:6402:1383:: with SMTP id b3mr70876005edv.100.1609786855608; Mon, 04 Jan 2021 11:00:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609786855; cv=none; d=google.com; s=arc-20160816; b=pkIziD2X2Ys8VoLUtFzEBB4c3VOoSJvPHxs2tAP49Jd+K3M9+x1GdxcoSjpQKngAER 3/N/mRYS/TwNiLnih7Z/Eok4QcQAy7Lj6Uzf+VXOQRAz1AbfNY0tsd4QvHW0xZYlQI3J IUUFDn7KXOeikITB5VFbCb1OTmu44huOCCYa3JHtT1p2bW9G8mIgoac0ZGWHdrp1qqGD WmCfrD+dUhtGV9EO70n8EHheBqlKJjzl85f/cCIesOJidpk2WgBwqdOJh8yltZvN7zEs 9aXMSOuoY7JBgRRmb7ofux6s1Hw0zulFSTTEnyMwQ5sJPbFRXeoHL/VDg/ZttRQSmhCL mJdQ== 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=uT5KCgk/jZMHf7cRAZ3Gk/Wa2EphxQ+0xFsMXQbfN0o=; b=MlBD2GVRArdbs8QcYZu/cIdafPeiUdUkCDVPP/wHgcQtK7yyw12msHyKLtwyEHXJy0 ygTMXa27HqzY2WWWYmcx+qDOo3agK/Wfqh22XCLUknqEUekHzN518XEYQEgJnKIsw6NO QFs1/FO22oTRCbkTAnrDlgjjIMADe7wJjrPbG23oIjHnx1cv3tDg3nt+qNDx5VzFGeML 6Y7WKyiHR4jxLb5CvslqONBDXQdgJUGZkFHJYFuNIiw98lZb5PO74ZwdRiNkq2oQs+2N gRqZsEretl4j5OZDWVzDYrRAcwbhV4fzBun03xRZ2oKyS+Qbr0L+wV0+HbHg1gSbTkxd NwgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bqRK3JFF; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o21si31902063edi.210.2021.01.04.11.00.32; Mon, 04 Jan 2021 11:00:55 -0800 (PST) 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=@linaro.org header.s=google header.b=bqRK3JFF; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726602AbhADS7o (ORCPT + 99 others); Mon, 4 Jan 2021 13:59:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726427AbhADS7o (ORCPT ); Mon, 4 Jan 2021 13:59:44 -0500 Received: from mail-ot1-x32b.google.com (mail-ot1-x32b.google.com [IPv6:2607:f8b0:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17B32C061793 for ; Mon, 4 Jan 2021 10:59:04 -0800 (PST) Received: by mail-ot1-x32b.google.com with SMTP id q25so26980552otn.10 for ; Mon, 04 Jan 2021 10:59:04 -0800 (PST) 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=uT5KCgk/jZMHf7cRAZ3Gk/Wa2EphxQ+0xFsMXQbfN0o=; b=bqRK3JFFGg93mU6uZPWaW5akXaVmSZlkgDvU5fw1iBZ9MPoMudZLGU9073yYQ2I/WZ cb16w/QoLwHW5ornVsNvPjULH3bA32uPjZoZjugiNiukbEVLt+GLEmHTE9+UE+tLhtvM AXMdawT4Yu4j3xMoZZQ85b6NjKCVhdBHlIAIQ9AhAm1LLKhJU7wxahlvbnL+qQMWpCC/ vDtbv36sm8UOZdgRztkXZmrxHRpqzojCcabpjbC/ifkhOQaclbEpTO++2yRuXHFf+hWT p/U/K/nanu5TYDYAmuVlgx0gf+gLYTjDPYlWcwlEmgpEW0Gt80Y/rHv/ONIIdl8vIi9p Seiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=uT5KCgk/jZMHf7cRAZ3Gk/Wa2EphxQ+0xFsMXQbfN0o=; b=IpJpItWfpR4UN6sqwmE0POd0JYZKFWRctqGLwJwCBiF+EMgc2pWq9L+qVxCzGMtmc1 FifH6VG4EF53VVmCQmm8+Nd24T6dqvf3mJJC0UuQEWuZVDRctW4jKz73ttythOYvFHjC b3dXw/ncoCfF5DDzTA0eIqFE6OM1wLYFo7J/2dc4qTBcx0yzdpVTQTDxEcAXXGRmYQvz fB/FAiU3yGmN5O7X0jLNrSCAnx2xXQOSdN33QgXsWhbCKbukRhIC2CPsQ54ALM8Phedh kPM0ln1h2leRIULpNNQ3a2orcUUH8ejH2MoFTXx3Y5btWOb0FMmqBvA9e0cAZVNx6UKw qrpw== X-Gm-Message-State: AOAM5310HzBX9Tx84Y6wMbuhuRMu+HD+xd3zW4BA6Y5VdT6yM1gGjWwE ubhSGnm2oCBj1LE69nqSQ7lVuQ== X-Received: by 2002:a05:6830:1e16:: with SMTP id s22mr51369315otr.110.1609786743465; Mon, 04 Jan 2021 10:59:03 -0800 (PST) Received: from builder.lan (104-57-184-186.lightspeed.austtx.sbcglobal.net. [104.57.184.186]) by smtp.gmail.com with ESMTPSA id g12sm13323496oos.8.2021.01.04.10.59.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Jan 2021 10:59:02 -0800 (PST) Date: Mon, 4 Jan 2021 12:59:00 -0600 From: Bjorn Andersson To: Can Guo Cc: Ziqi Chen , asutoshd@codeaurora.org, nguyenb@codeaurora.org, hongwus@codeaurora.org, rnayak@codeaurora.org, vinholikatti@gmail.com, jejb@linux.vnet.ibm.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, kernel-team@android.com, saravanak@google.com, salyzyn@google.com, kwmad.kim@samsung.com, stanley.chu@mediatek.com, Alim Akhtar , Avri Altman , "James E.J. Bottomley" , Andy Gross , Matthias Brugger , Bean Huo , Bart Van Assche , Adrian Hunter , Satya Tangirala , "moderated list:UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER..." , open list , "open list:ARM/QUALCOMM SUPPORT" , "moderated list:ARM/Mediatek SoC support" Subject: Re: [PATCH RFC v4 1/1] scsi: ufs: Fix ufs power down/on specs violation Message-ID: References: <1608644981-46267-1-git-send-email-ziqichen@codeaurora.org> <4c3035c418d0a0c4344be84fb1919314@codeaurora.org> <182321abfc98e0cfca071d1ec1255f6d@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <182321abfc98e0cfca071d1ec1255f6d@codeaurora.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 28 Dec 19:48 CST 2020, Can Guo wrote: > On 2020-12-29 09:18, Can Guo wrote: > > On 2020-12-29 01:55, Bjorn Andersson wrote: > > > On Tue 22 Dec 07:49 CST 2020, Ziqi Chen wrote: > > > > > > > As per specs, e.g, JESD220E chapter 7.2, while powering > > > > off/on the ufs device, RST_N signal and REF_CLK signal > > > > should be between VSS(Ground) and VCCQ/VCCQ2. > > > > > > > > To flexibly control device reset line, refactor the function > > > > ufschd_vops_device_reset(sturct ufs_hba *hba) to ufshcd_ > > > > vops_device_reset(sturct ufs_hba *hba, bool asserted). The > > > > new parameter "bool asserted" is used to separate device reset > > > > line pulling down from pulling up. > > > > > > > > Cc: Kiwoong Kim > > > > Cc: Stanley Chu > > > > Signed-off-by: Ziqi Chen > > > > --- > > > > drivers/scsi/ufs/ufs-mediatek.c | 32 > > > > ++++++++++++++++---------------- > > > > drivers/scsi/ufs/ufs-qcom.c | 24 +++++++++++++++--------- > > > > drivers/scsi/ufs/ufshcd.c | 36 > > > > +++++++++++++++++++++++++----------- > > > > drivers/scsi/ufs/ufshcd.h | 8 ++++---- > > > > 4 files changed, 60 insertions(+), 40 deletions(-) > > > > > > > > diff --git a/drivers/scsi/ufs/ufs-mediatek.c > > > > b/drivers/scsi/ufs/ufs-mediatek.c > > > > index 80618af..072f4db 100644 > > > > --- a/drivers/scsi/ufs/ufs-mediatek.c > > > > +++ b/drivers/scsi/ufs/ufs-mediatek.c > > > > @@ -841,27 +841,27 @@ static int > > > > ufs_mtk_link_startup_notify(struct ufs_hba *hba, > > > > return ret; > > > > } > > > > > > > > -static int ufs_mtk_device_reset(struct ufs_hba *hba) > > > > +static int ufs_mtk_device_reset(struct ufs_hba *hba, bool asserted) > > > > { > > > > struct arm_smccc_res res; > > > > > > > > - ufs_mtk_device_reset_ctrl(0, res); > > > > + if (asserted) { > > > > + ufs_mtk_device_reset_ctrl(0, res); > > > > > > > > - /* > > > > - * The reset signal is active low. UFS devices shall detect > > > > - * more than or equal to 1us of positive or negative RST_n > > > > - * pulse width. > > > > - * > > > > - * To be on safe side, keep the reset low for at least 10us. > > > > - */ > > > > - usleep_range(10, 15); > > > > - > > > > - ufs_mtk_device_reset_ctrl(1, res); > > > > - > > > > - /* Some devices may need time to respond to rst_n */ > > > > - usleep_range(10000, 15000); > > > > + /* > > > > + * The reset signal is active low. UFS devices shall detect > > > > + * more than or equal to 1us of positive or negative RST_n > > > > + * pulse width. > > > > + * > > > > + * To be on safe side, keep the reset low for at least 10us. > > > > + */ > > > > + usleep_range(10, 15); > > > > > > I see no point in allowing vendors to "tweak" the 1us->10us > > > adjustment. > > > The specification says 1us and we all agree that 10us gives us good > > > enough slack. I.e. this is common code. > > > > Hi Bjron, > > > > We tried, but Samsung fellows wanted 5us. We couldn't get a agreement > > on this delay in short term, so we chose to leave it in vops. > > > > > > > > > + } else { > > > > + ufs_mtk_device_reset_ctrl(1, res); > > > > > > > > - dev_info(hba->dev, "device reset done\n"); > > > > + /* Some devices may need time to respond to rst_n */ > > > > + usleep_range(10000, 15000); > > > > > > The comment in both the Qualcomm and Mediatek drivers claim that > > > this is > > > sleep relates to the UFS device (not host), so why should it be > > > different? > > > > > > What happens if I take the device that Mediatek see a need for a 10ms > > > delay and hook that up to a Qualcomm host? This really should go in > > > the > > > common code. > > > > > > > Agree, but Qualcomm host didn't have any problems with 10us yet, so if > > we put > > the 10ms delay to common code, Qualcomm host would suffer longer delay > > when > > device reset happens - both bootup and resume(xpm_lvl = 5/6) latency > > would > > be increased. > > > > Regards, > > Can Guo. > > > > Besides, currently this device reset vops is only registered by ufs-qcom.c > and ufs-mediatek.c, meaning any delays that we put in the common code are > not > necessary for those who do not have this vops registered, i.e ufs-exynos.c, > ufs-hisi.c. > Surely we can detect this in the common code and only sleep if the vops is implemented - and successfully deasserted the reset. Regards, Bjorn