Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp1266488rdb; Fri, 19 Jan 2024 13:33:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IEUVFOfz6I/ERYpD1hQFQcxxCKKC8Fjc2O7mdpdephFBBSSCxdss5SoNhMZ6YpIx3kqUNC+ X-Received: by 2002:ac8:5804:0:b0:42a:134d:8b10 with SMTP id g4-20020ac85804000000b0042a134d8b10mr533187qtg.48.1705700008346; Fri, 19 Jan 2024 13:33:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705700008; cv=pass; d=google.com; s=arc-20160816; b=L7HYpmBM/CK6xDK9BbSBcfg3OUFnuqlO22MIudkJcc+8S4zrVEwD7rKevpPxqWAspK HsenOKSMBInjdqIExC6aDFCupQF5MG7NiLzdgFd9ceCKRkMFcsY826egb1uXazKstYUq dNowfo57I5VViZeB8/fAyHGJ6p8QdyG5dzvJQVVWc9JSBXsHWAiOHRa2w7KNcB6QEkdp aU0gyVnoTHhZANtaA8IiDdUCA+GwNMyQoGTnLAa10JzfKkPXZiB9jtU1hZk2IKS9DuKr Idze0wIXeVhJzL2m9M7QpLhDz2m+q7gW56wfgnMq+LsVfK8J8FpSPKg3cGsa/5GhS9KL 36Lw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=lzrWPZR5+3QYuqMx3/O+fwKFrZi0Xwysmh/7OAXDcYM=; fh=Qi64G6cLPuD/nlQsRA+ywKLyHDOkzdA2OKK3e8Qx3x4=; b=Sg/nwdqhaaZBobRpn8Q8CR5YlvgzjMPyKPUwig2KbW+DZ0uHGai8KDp96a91CO0Boy 0E3Vy61MNIMj4LZ3ICq9rAvLQCm0qHIRLU7WrMIA6JNRGWc9ebKxtu/8TuLF7N0Nk/3r py/OUdVWNsbDJxHT6q7jY2h3+FKuPQ7rtN387hzzHlbBb/72PlO1qxweGptr89TPRrHS Z7K0H6aA5Xe6d1BIydtDltDh9dZTvw23nT5U/tjpEeFB0uvFSiz6gs5W9X+R35NHYMO5 51rU6J5Nel5mzyDPPqJ4h0jTTJJzjD5CdY/+1ywuAiHCmbccXgjv2e62sfO4ZIdp0dqi waig== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fbSo464k; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-31581-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-31581-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id l13-20020a05622a050d00b0042a293557a1si185002qtx.0.2024.01.19.13.33.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jan 2024 13:33:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-31581-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fbSo464k; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-31581-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-31581-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 0EF4F1C21EDF for ; Fri, 19 Jan 2024 21:33:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DAA5C58227; Fri, 19 Jan 2024 21:33:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="fbSo464k" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 616CC58100 for ; Fri, 19 Jan 2024 21:33:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705699996; cv=none; b=UF6HQh6wfGEKLGB+da6tRICR3mRO32dJoPw6mo1pcBWGQRKhYcVz3ImpCcgAYVuE/+OdbOT9qEsXdl6p6LY9x12JCPVyyOA6Wae1TgewMDNghDgnKjsRNN95sPSBeFSN9WXQeDpv9cJrFRPn8q9yUp7C33CLwK4C5W5wjluHt74= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705699996; c=relaxed/simple; bh=EkTj7yDGwdkzAs8tBNlRMDUvXzIDCIPdlE7L2nKM844=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=F7EwyoFEoRPB+oWXcJo4f6890kNFP1b8zfJIzvDVRH0FiM0j57oyrW3w+YWmCSmCfWcW/w1zkDNisX/73HPZi36Inf1PXkwvSFvrV93ZeuvKDIgRloR5hofXjdmJaAIzbwfBGGN16SDbisf3lLpPWJwpzcf6W11iz75aVM5wUKc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=fbSo464k; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705699994; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=lzrWPZR5+3QYuqMx3/O+fwKFrZi0Xwysmh/7OAXDcYM=; b=fbSo464k7XvSr96aYW4EOzeJ7XIXlJ4i5DcpvJhnVjvHtD+jxNUXuB3zbABa96Vm4K08mE V79LK4qRjvkT2Ose2rTXDUc0mjqXbNLazAkSsSrxI2nupCpXIr0ptFIl2L8YoyfdQsvQHy L1fIv/BmblvR01IKGPLVFqHbzOeMN68= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-398-uajpGbASMFqstPpvxjAzAw-1; Fri, 19 Jan 2024 16:33:12 -0500 X-MC-Unique: uajpGbASMFqstPpvxjAzAw-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-6855c0719a8so275266d6.1 for ; Fri, 19 Jan 2024 13:33:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705699992; x=1706304792; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=lzrWPZR5+3QYuqMx3/O+fwKFrZi0Xwysmh/7OAXDcYM=; b=txmUSgnzwupHYKcnzMSpnMu17DGTDFdM44QfMMe7/1xj5/Dl5mTvU0LtNNwZEUWwoJ n6LCmyImUFqVSxBZDMsDMgHFRo8JJ7nv2fZEFdoY8RAYG5oZ8IttcoSVjwMEraqyUPwi lZRLWoI8MG7DZlMVyITX0Gfj75w6JwuizV6cpnX6QJ8ZMUAT5l/4dD2Pcb84SgIy2bai Q5aLbAXqA0Lq9xdm/nHFY6ivU7T882YYORjAsxlB5bXkMWvj/wO84lFyVowPWfGEh3kS C/52K/wociFe4LyepM1x83qihOBHeBP+IN1V6KRSgSAfoiMjAo+WpUH/KozqDxtIhrvW w7gA== X-Gm-Message-State: AOJu0YxxQRR9RGYgzZnu7mJgKp2XpJ8qubAK+DHeO9R9Off4Bo8GjBXW HDEj+p694S9l5uQqY9CCn69802bzI/yQ36qc6lHuLGPAYmnxEkCsK5LaozCpNqVAV6kCxUH2MaC 4qgeL0hJohlPfbSQ2D7377s7HzcGrPPLCVhE+RBJOBf77Vw/cEYTRzmcnM+WWtw== X-Received: by 2002:a05:6214:2686:b0:680:c880:6646 with SMTP id gm6-20020a056214268600b00680c8806646mr668649qvb.22.1705699992321; Fri, 19 Jan 2024 13:33:12 -0800 (PST) X-Received: by 2002:a05:6214:2686:b0:680:c880:6646 with SMTP id gm6-20020a056214268600b00680c8806646mr668638qvb.22.1705699992064; Fri, 19 Jan 2024 13:33:12 -0800 (PST) Received: from localhost (pool-71-184-142-128.bstnma.fios.verizon.net. [71.184.142.128]) by smtp.gmail.com with ESMTPSA id di8-20020ad458e8000000b006818a1e269csm39021qvb.102.2024.01.19.13.33.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jan 2024 13:33:11 -0800 (PST) Date: Fri, 19 Jan 2024 16:33:10 -0500 From: Eric Chanudet To: Andrew Halaney Cc: Bjorn Andersson , Konrad Dybcio , Manivannan Sadhasivam , "James E.J. Bottomley" , "Martin K. Petersen" , linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: Re: Re: [PATCH] scsi: ufs: qcom: avoid re-init quirk when gears match Message-ID: References: <20240119185537.3091366-11-echanude@redhat.com> <3xnedre2d32rkad6n2ln4rrah7sgg6epxnzsdm54uab3zrutnz@fww7wb5mvykj> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Fri, Jan 19, 2024 at 02:33:32PM -0600, Andrew Halaney wrote: > On Fri, Jan 19, 2024 at 02:07:15PM -0600, Andrew Halaney wrote: > > On Fri, Jan 19, 2024 at 01:55:47PM -0500, Eric Chanudet wrote: > > > On sa8775p-ride, probing the hba will go through the > > > UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCH path although the power info > > > are same during the second init. > > > > > > If the host is at least v4, ufs_qcom_get_hs_gear() picked the highest > > > supported gear when setting the host_params. After the negotiation, if > > > the host and device are on the same gear, it is the highest gear > > > supported between the two. Skip the re-init to save some time. > > > > > > Signed-off-by: Eric Chanudet > > > --- > > > > > > "trace_event=ufs:ufshcd_init" reports the time spent where the re-init > > > quirk is performed. On sa8775p-ride: > > > Baseline: > > > 0.355879: ufshcd_init: 1d84000.ufs: took 103377 usecs, dev_state: UFS_ACTIVE_PWR_MODE, link_state: UIC_LINK_ACTIVE_STATE, err 0 > > > With this patch: > > > 0.297676: ufshcd_init: 1d84000.ufs: took 43553 usecs, dev_state: UFS_ACTIVE_PWR_MODE, link_state: UIC_LINK_ACTIVE_STATE, err 0 > > > > > > drivers/ufs/host/ufs-qcom.c | 6 +++++- > > > 1 file changed, 5 insertions(+), 1 deletion(-) > > > > > > diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c > > > index 39eef470f8fa..f9f161340e78 100644 > > > --- a/drivers/ufs/host/ufs-qcom.c > > > +++ b/drivers/ufs/host/ufs-qcom.c > > > @@ -738,8 +738,12 @@ static int ufs_qcom_pwr_change_notify(struct ufs_hba *hba, > > > * the second init can program the optimal PHY settings. This allows one to start > > > * the first init with either the minimum or the maximum support gear. > > > */ > > > - if (hba->ufshcd_state == UFSHCD_STATE_RESET) > > > + if (hba->ufshcd_state == UFSHCD_STATE_RESET) { > > > + if (host->hw_ver.major >= 0x4 && > > > > Is this check really necessary? I *think* so. For example, if hw_ver < 4, ufs_qcom_set_phy_gear() has a comment saying "power up the PHY using minimum supported gear (UFS_HS_G2). Switching to max gear will be performed during reinit if supported." > > > > The initial phy_gear state is something like this (my phrasing of > > ufs_qcom_set_phy_gear()): > > > > if hw_ver < 4: > > # Comments about powering up with minimum gear (with no > > # reasoning in the comment afaict), and mentions switching > > # to higher gear in reinit quirk. This is opposite of the later > > # versions which start at the max and scale down > > phy_gear = UFS_HS_G2 IIUC, the device would not be able to negotiate a gear higher than the minimum set for the phy_gear on initialization. ufshcd_init_host_params() and ufs_qcom_get_hs_gear() both set the controller phy_gear); async_schedule(ufshcd_async_scan, hba) ... ufshcd_async_scan ufshcd_device_init ufshcd_probe_hba /* where the re-init quirk happens */ ufshcd_device_init ufshcd_vops_pwr_change_notify(PRE_CHANGE) So that would limit the device to G2? In this circumstances, the re-init would instead re-initialize to G3. > I guess what I'm saying is shouldn't the check be something like: > > if (dev_req_params->gear_tx == host->phy_gear) { > // Skip reinit since we started up in the agreed upon gear > hba->quirks &= ~UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCH; > } -- Eric Chanudet