Message ID | 20240220090805.2886914-1-rohitner@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-72661-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp278175dyc; Tue, 20 Feb 2024 01:13:04 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW3AiT0JWIuwLhGWgqWEgQoPUui3W5Gu5GqDEsP/tW1SISKp4ptNGy+tJhq4zwtlUc6ZAoetMB8xT4MIPpwOCT0sSIqpg== X-Google-Smtp-Source: AGHT+IFN2aV3uVTfwZ3b2KlVLv/D/gzoUENdBwa+OBS261zyt4z8/L+CDGMfMYauoqfQ6dA15Y1I X-Received: by 2002:aa7:8b8f:0:b0:6e3:ad06:8153 with SMTP id r15-20020aa78b8f000000b006e3ad068153mr5818672pfd.28.1708420384091; Tue, 20 Feb 2024 01:13:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708420384; cv=pass; d=google.com; s=arc-20160816; b=w1dvOsdK2wlvyssptN7hL8iyK+wrgQ989lv5zn+W/3kOpOdtxCroWsjsBDJQMo6dL+ Ok1Eh2LI0+xXGFCVI6wPrzs6QOIL54cDwNx7luCkrF9e/8lAu9P0Lvfz/zp0FfzF+uyo +XIO2mABxaqLVqwItKKnN2O+N+rWB19iUxtKGQscSKSPTrxt4X343VCRooGPwQwMRF4G k8uMYyZ56WdcwpqS4l1zn6REms57jjlVXIP2Z8uhNXboEUa1j3Q8Lu51F5uKwxMroFFe o9LoHcKZhsqHTVVC2prweVAZj2gxNnpPd7P3nHUJgamx7agW9E5mwsys/UBObMys3xZx ydKg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:dkim-signature; bh=C5TIghhj81XJMhc6wHnIWYfJQESzheU3Zzvlzz3ZRZI=; fh=gUsX+KtCzqUeHHj6k8xuJ6CiNqlQDmM2TiLkzQ2/0cw=; b=1FfrgbgtXaNxDst1vtprEnXq9ybnhUHuEsdLxRKpxwcAX97u/wUNzWArFYcaQYkWt8 98B1o7ZZE0d/OM+g6LvjgER6ZY6TntAiqf4pH7YY9luYJH4QObc5ELz6JYu6m33aq5LO uSOxtb4m6V5M/oxI04wfIbJwUuYADg0SJEsHYtJXx3+tAF94wDtE7DDaKAQLQjJ+XKKh ATz1Lmvd41JMWAasU+UaSzZ1yk/fKDaiVP0L/QOHGt619WKR+yjzYBSLTEM6VY3l1HyY ghXdINDsylFwkQ1MATQIEzN+Y/tFM5wLnJcH9QG5jLwe38XJxZOSKPT818KJqVGyadkp tInQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=4vxtFVh8; arc=pass (i=1 spf=pass spfdomain=flex--rohitner.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-72661-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72661-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id k136-20020a62848e000000b006e2faf784e8si5473588pfd.15.2024.02.20.01.13.04 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 01:13:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-72661-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=4vxtFVh8; arc=pass (i=1 spf=pass spfdomain=flex--rohitner.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-72661-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72661-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 36CFC28A6DF for <ouuuleilei@gmail.com>; Tue, 20 Feb 2024 09:12:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E570E60ECB; Tue, 20 Feb 2024 09:09:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="4vxtFVh8" Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BFE955F49E for <linux-kernel@vger.kernel.org>; Tue, 20 Feb 2024 09:08:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708420141; cv=none; b=Lvq9WD3X90ihkmpjWQA0XfxHsCDCWshDMUblTHu0W7rYFDXT29AYjzaFtfb8qFllMaZvOL60axst7QgpcHj4WiJSsiu4qyaZ5rSY1p1UHGrsZTTgTobaT3ElpKdP/4/wH0bNCPaiQAgDa62iMrlM43q/V2z6/bq0vQcr3/nisKw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708420141; c=relaxed/simple; bh=mjn6EXTmSJZ+lGndYlrFuihk9Yh0VIx3guEcNtjlNRU=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=AtHEzxHNJpkuH+SDGXCSa7NOqQWsRYv0UsLDTvuf3x5+sleYGZAhpp4O5BNTmtoz8T6/nONbUPeDoM98f4W/Hgn+tN8gGJn/Z8maVuEQ6bUwtsuiHoYWY+bgnBPg2CSoXefTPWgWrFhh/0ushxWNfn2nqQZFX2Prjzr6QHp4HtM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--rohitner.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=4vxtFVh8; arc=none smtp.client-ip=209.85.128.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--rohitner.bounces.google.com Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-5efe82b835fso113336767b3.0 for <linux-kernel@vger.kernel.org>; Tue, 20 Feb 2024 01:08:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708420139; x=1709024939; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=C5TIghhj81XJMhc6wHnIWYfJQESzheU3Zzvlzz3ZRZI=; b=4vxtFVh8jPunlq+rWV7bLChCNXukLTnUydEE7dP0gV2nheoPUSexQGr40fAt2fqwUv HkVE5L4Nex9dh1YhLFgpJ4HB6gZcjA7TW8s5D+z+bFwRnW21+l7MjVld/fcnY3Vnf+M8 IZAVe6ziJIYPfYLE3+mVBnvB2SHoKHXR+kZDt3phDKTz1SECxZq+GSdixTaI3BdBj/Og YlM2p+nt7iysA8aFpslTPj8oA3+VNDJksnck56ojBMSzppBE5Uc3N1IWHMggKPM94pZS XJNk3Q+NM4rHHMpU+h28TCJwsnDW2pebdd/5zMGz3BfEYA6cHJ/PH6WcaaNl03tv9c3L +SGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708420139; x=1709024939; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=C5TIghhj81XJMhc6wHnIWYfJQESzheU3Zzvlzz3ZRZI=; b=Y1YK3FCx9YpLZhK+sOSzxw5mESox4qj7z/3u0H/AbLFruWrOD+xGis2U6fQKZA6R3a KDH2bAx8CvoQKLtykP3W6PO131Lzmq1yDOSokdQCVe/PdZky5kRSq0fpWmfPYhmfY/JF yUrZ6Nvf+hujici98+tybwwvziu7u2H6j5Gtgm5nWrSRpoGuef/I3V2MB4Cq66mzAS0G hHXUqI0z6hNxUWM8nn0RXX6Oipqqvcq8oyb7Hmml6bhmi3wgfaYkZmdSjH4czczC7waa xgmfDP2StFBGcxtw3UTKPGsLi7O/YlH80xqXJkhW1BrzpKbl12rqNT2Pb1su4A2ZWXvh w/vw== X-Forwarded-Encrypted: i=1; AJvYcCWrhn7aprzF156pl87SxG5iHhuNp5Ro/nYEakGKqYQv6Uy+kGKBOPUgjOKUlEXiBN2Wn8vRSGEVf5GfWgXGsi/Ul7Yj5Xkz26e/5zZ0 X-Gm-Message-State: AOJu0YwqITtWne6DpDABe1/Vc4v2ob6Eva9LFKSDuQts7GwLR6ymsZ+H XMB3U7VroPp4n0FvOjZjb0lsx7V08tpM+IGXJLZKX2YYBDBK+ZzIMG1v6Q7p9WgYerrBtK9YFB+ DXkyLrZcKlg== X-Received: from rohitner.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:413]) (user=rohitner job=sendgmr) by 2002:a05:6902:706:b0:dc6:fa35:b42 with SMTP id k6-20020a056902070600b00dc6fa350b42mr4323086ybt.2.1708420138874; Tue, 20 Feb 2024 01:08:58 -0800 (PST) Date: Tue, 20 Feb 2024 01:08:05 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> Mime-Version: 1.0 X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog Message-ID: <20240220090805.2886914-1-rohitner@google.com> Subject: [PATCH] scsi: ufs: core: Fix setup_xfer_req invocation From: Rohit Ner <rohitner@google.com> To: Can Guo <quic_cang@quicinc.com>, Bean Huo <beanhuo@micron.com>, Stanley Chu <stanley.chu@mediatek.com>, "Martin K. Petersen" <martin.petersen@oracle.com> Cc: Avri Altman <avri.altman@wdc.com>, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Rohit Ner <rohitner@google.com> Content-Type: text/plain; charset="UTF-8" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791408612750925881 X-GMAIL-MSGID: 1791408612750925881 |
Series |
scsi: ufs: core: Fix setup_xfer_req invocation
|
|
Commit Message
Rohit Ner
Feb. 20, 2024, 9:08 a.m. UTC
Allow variant callback to setup transfers without
restricting the transfers to use legacy doorbell
Signed-off-by: Rohit Ner <rohitner@google.com>
---
drivers/ufs/core/ufshcd.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
Comments
On 2/20/24 01:08, Rohit Ner wrote: > Allow variant callback to setup transfers without > restricting the transfers to use legacy doorbell > > Signed-off-by: Rohit Ner <rohitner@google.com> > --- > drivers/ufs/core/ufshcd.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c > index d77b25b79ae3..91e483dd3974 100644 > --- a/drivers/ufs/core/ufshcd.c > +++ b/drivers/ufs/core/ufshcd.c > @@ -2280,6 +2280,9 @@ void ufshcd_send_command(struct ufs_hba *hba, unsigned int task_tag, > ufshcd_clk_scaling_start_busy(hba); > if (unlikely(ufshcd_should_inform_monitor(hba, lrbp))) > ufshcd_start_monitor(hba, lrbp); > + if (hba->vops && hba->vops->setup_xfer_req) > + hba->vops->setup_xfer_req(hba, lrbp->task_tag, > + !!lrbp->cmd); > > if (is_mcq_enabled(hba)) { > int utrd_size = sizeof(struct utp_transfer_req_desc); > @@ -2293,9 +2296,6 @@ void ufshcd_send_command(struct ufs_hba *hba, unsigned int task_tag, > spin_unlock(&hwq->sq_lock); > } else { > spin_lock_irqsave(&hba->outstanding_lock, flags); > - if (hba->vops && hba->vops->setup_xfer_req) > - hba->vops->setup_xfer_req(hba, lrbp->task_tag, > - !!lrbp->cmd); > __set_bit(lrbp->task_tag, &hba->outstanding_reqs); > ufshcd_writel(hba, 1 << lrbp->task_tag, > REG_UTP_TRANSFER_REQ_DOOR_BELL); UFS controllers that are compliant with the JEDEC UFSHCI specification do not need the .setup_xfer_req() callback so I think a better motivation is needed to make this change. Thanks, Bart.
On 2/20/24 09:58, Rohit Ner wrote: > Do you propose to remove this callback altogether? This callback should > either support both transfer modes or none. The only UFSHCI controller I know of that needs this callback is the Exynos UFSHCI controller. As far as I know there are Exynos UFSHCI controllers that support UFSHCI 3.0 but UFSHCI 4.0 Exynos controllers are not yet available. Standard compliant controllers should not use the .setup_xfer_req() callback. As you may know invoking that callback means performing an indirect function call. Indirect function calls are slower than direct calls, especially if speculative execution vulnerability security mitigations are enabled. Bart.
Hi Bart, On 2/21/2024 1:21 AM, Bart Van Assche wrote: > On 2/20/24 01:08, Rohit Ner wrote: >> Allow variant callback to setup transfers without >> restricting the transfers to use legacy doorbell >> >> Signed-off-by: Rohit Ner <rohitner@google.com> >> --- >> drivers/ufs/core/ufshcd.c | 6 +++--- >> 1 file changed, 3 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c >> index d77b25b79ae3..91e483dd3974 100644 >> --- a/drivers/ufs/core/ufshcd.c >> +++ b/drivers/ufs/core/ufshcd.c >> @@ -2280,6 +2280,9 @@ void ufshcd_send_command(struct ufs_hba *hba, >> unsigned int task_tag, >> ufshcd_clk_scaling_start_busy(hba); >> if (unlikely(ufshcd_should_inform_monitor(hba, lrbp))) >> ufshcd_start_monitor(hba, lrbp); >> + if (hba->vops && hba->vops->setup_xfer_req) >> + hba->vops->setup_xfer_req(hba, lrbp->task_tag, >> + !!lrbp->cmd); >> if (is_mcq_enabled(hba)) { >> int utrd_size = sizeof(struct utp_transfer_req_desc); >> @@ -2293,9 +2296,6 @@ void ufshcd_send_command(struct ufs_hba *hba, >> unsigned int task_tag, >> spin_unlock(&hwq->sq_lock); >> } else { >> spin_lock_irqsave(&hba->outstanding_lock, flags); >> - if (hba->vops && hba->vops->setup_xfer_req) >> - hba->vops->setup_xfer_req(hba, lrbp->task_tag, >> - !!lrbp->cmd); >> __set_bit(lrbp->task_tag, &hba->outstanding_reqs); >> ufshcd_writel(hba, 1 << lrbp->task_tag, >> REG_UTP_TRANSFER_REQ_DOOR_BELL); > > UFS controllers that are compliant with the JEDEC UFSHCI specification do > not need the .setup_xfer_req() callback so I think a better motivation is > needed to make this change. I am going to push some BUG fixes for Qualcomm UFSHCI MCQ engine, one of which would count on a vops in ufshcd_send_command(). My original plan was to add a new vops.mcq_setup_xfer_req() to differentiate from the existing one used in legacy mode. But if Rohit moves the existing setup_xfer_req() up, I can use it instead of introducing the new one. Thanks, Can Guo. > > Thanks, > > Bart.
On 2/21/24 01:13, Can Guo wrote: > I am going to push some BUG fixes for Qualcomm UFSHCI MCQ engine, one of > which would count on a vops in ufshcd_send_command(). My original plan > was to add a new vops.mcq_setup_xfer_req() to differentiate from the > existing one used in legacy mode. But if Rohit moves the existing > .setup_xfer_req() up, I can use it instead of introducing the new one. Hi Can, If an if-statement can be avoided in the hot path by introducing a new callback pointer for MCQ code then I prefer the approach of introducing a new callback instead of moving the setup_xfer_req() call. Thanks, Bart.
On 2/22/2024 1:55 AM, Bart Van Assche wrote: > On 2/21/24 01:13, Can Guo wrote: >> I am going to push some BUG fixes for Qualcomm UFSHCI MCQ engine, one >> of which would count on a vops in ufshcd_send_command(). My original >> plan was to add a new vops.mcq_setup_xfer_req() to differentiate from >> the existing one used in legacy mode. But if Rohit moves the existing >> .setup_xfer_req() up, I can use it instead of introducing the new one. > > Hi Can, > > If an if-statement can be avoided in the hot path by introducing a new > callback pointer for MCQ code then I prefer the approach of introducing > a new callback instead of moving the setup_xfer_req() call. Hi Bart, The if-statement you are mentioning here, is it the if (hba->vops && hba->vops->setup_xfer_req) or if (is_mcq_enabled(hba))? Thanks, Can Guo. > > Thanks, > > Bart. >
On 2/21/24 18:05, Can Guo wrote:
> The if-statement you are mentioning here, is it the if (hba->vops && hba->vops->setup_xfer_req) or if (is_mcq_enabled(hba))?
Hi Can,
I was referring to the latter if-statement, at least if it would occur in the
code that you plan to post and that I haven't seen yet.
Thanks,
Bart.
On 2/21/24 01:13, Can Guo wrote: > I am going to push some BUG fixes for Qualcomm UFSHCI MCQ engine, one of > which would count on a vops in ufshcd_send_command(). My original plan > was to add a new vops.mcq_setup_xfer_req() to differentiate from the > existing one used in legacy mode. But if Rohit moves the existing > .setup_xfer_req() up, I can use it instead of introducing the new one. Hi Can, Can we stick to the current approach of moving the .setup_xfer_req() up, keeping in mind the following pros? 1. Avoid redundant callbacks for setting up transfers 2. Trim the duration for which hba->outstanding_lock is acquired unnecessarily Thanks, Rohit.
On 2/22/24 00:27, Rohit Ner wrote: > Can we stick to the current approach of moving the .setup_xfer_req() > up, keeping in mind the following pros? > 1. Avoid redundant callbacks for setting up transfers > 2. Trim the duration for which hba->outstanding_lock is acquired unnecessarily No, we can't. The Exynos implementation of the .setup_xfer_req() callback is not thread-safe and relies on serialization by the caller. This patch breaks the Exynos driver. A better title for this patch would be "Break the setup_xfer_req() invocation". Bart.
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index d77b25b79ae3..91e483dd3974 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -2280,6 +2280,9 @@ void ufshcd_send_command(struct ufs_hba *hba, unsigned int task_tag, ufshcd_clk_scaling_start_busy(hba); if (unlikely(ufshcd_should_inform_monitor(hba, lrbp))) ufshcd_start_monitor(hba, lrbp); + if (hba->vops && hba->vops->setup_xfer_req) + hba->vops->setup_xfer_req(hba, lrbp->task_tag, + !!lrbp->cmd); if (is_mcq_enabled(hba)) { int utrd_size = sizeof(struct utp_transfer_req_desc); @@ -2293,9 +2296,6 @@ void ufshcd_send_command(struct ufs_hba *hba, unsigned int task_tag, spin_unlock(&hwq->sq_lock); } else { spin_lock_irqsave(&hba->outstanding_lock, flags); - if (hba->vops && hba->vops->setup_xfer_req) - hba->vops->setup_xfer_req(hba, lrbp->task_tag, - !!lrbp->cmd); __set_bit(lrbp->task_tag, &hba->outstanding_reqs); ufshcd_writel(hba, 1 << lrbp->task_tag, REG_UTP_TRANSFER_REQ_DOOR_BELL);