Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp1335218lqb; Thu, 30 May 2024 07:26:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV/qdS8ujwLCSlnhx1XHkKGVdo/GX0jr5YyQcDJGFQmNYv6jCJ6n+p/laOMU2Oghfi7hDX+0PQF2jZR61tf0ukzFJcHB2Aryc76MvSm2Q== X-Google-Smtp-Source: AGHT+IGX1Z1zMyVbtmCNW0EWJRVmah2MHIycoexviw3cxG9lnmQosYb/uUX3qGuOK2zBD2/00q9I X-Received: by 2002:a17:902:f684:b0:1f6:1c1f:f31f with SMTP id d9443c01a7336-1f61c1ff69emr19623035ad.64.1717079183529; Thu, 30 May 2024 07:26:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717079183; cv=pass; d=google.com; s=arc-20160816; b=b3xVtWQUoc1tGpU1csCb1oQV8SDUuDNoa0HUF6vrZoPc67RRNF/eNpg5YXeeI5MunC gfXul8SoMlSBxWTX48rNb0BPgX7Zoan2MA/n7U9kZMMhC5fV5OzfKysqYQy6lvUO39AD jGYE3ATTzg39F+wvU2FQasfpSWvwhbTq96JqDmSNiN3zqIgYX3HdZAKtKdW1fKX1Wedj HCe/13O91k6nWJ8l9hJ49pOQ/2fBcYw/DCrQYSUKqaREEzs/Mn2qOuPSY6bo8XF22SaS VZRmfgAIpKjZGSfM+4Bsa9hL8bHj+amlyXeWdR9V8pCun2Is/D7LUGTH/X9Fh3AV48ja JBLA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:wdcironportexception:ironport-sdr:dkim-signature; bh=hHDSGWi4YPA2KG7qhYiU+0VFBnNrUPmb/AMt0AcIgJs=; fh=X0Lb6G6jJE8+QeYtFGxv2g5f8eI/IotqH0fFq08ifqY=; b=TTxBIt0JtHUZDiQk1f3bkq4CBTL/L2niTZE9dOBBRVTWGk/aUh32vcJpHKa0Trqp5S OI82YkM+e8F7CkaVlcZeuTp1kmMdUyKJmVylLgfv77dpnRXgmIpcETle1tUxyW34ROgH fnyEutHQE4ln6azguMOeyxcGVi37DvFzWS0GQZ2cZXleAIe/3Iqp159j3+0p2b5vBYl4 TIgSYFAANBmhKWQGKKMP+3ysHfljapFCvyMlVebzaFIm4Kbo/TWf3mdUa3YlJT/R2kNi i0AzTQs+1+S+j80mZg1LmW++unkD2qvXVGDfBMSxH3xilXQT/s9aovwhcmL5Bj0GmWz9 PGUQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@wdc.com header.s=dkim.wdc.com header.b=DXUjjBvd; arc=pass (i=1 spf=pass spfdomain=wdc.com dkim=pass dkdomain=wdc.com dmarc=pass fromdomain=wdc.com); spf=pass (google.com: domain of linux-kernel+bounces-195514-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-195514-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wdc.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f44c7d05f6si119793695ad.179.2024.05.30.07.26.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 07:26:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-195514-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@wdc.com header.s=dkim.wdc.com header.b=DXUjjBvd; arc=pass (i=1 spf=pass spfdomain=wdc.com dkim=pass dkdomain=wdc.com dmarc=pass fromdomain=wdc.com); spf=pass (google.com: domain of linux-kernel+bounces-195514-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-195514-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wdc.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 39EE8B225D3 for ; Thu, 30 May 2024 14:26:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BEEBB17C206; Thu, 30 May 2024 14:25:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="DXUjjBvd" Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.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 F0BE4186E59; Thu, 30 May 2024 14:25:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=68.232.143.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717079124; cv=none; b=krUw0QsJNtvvBiHQLAZzX0TbkTvUmCOeeDHlzjialw1zRMYGbsYr32ZfpxhgEPrT9yYnH6rlEWtD/9KhFVqm4jG9Jzz6a+LVI5GC3Gin9kPzJ8ozae4MSJ9TFBGdMlv3q9mRHdg19iorikH2dy7+pOzHSmf2LPPqe1CKz7Q7AK4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717079124; c=relaxed/simple; bh=lI93q7XNVx+d7jqN8ZADdFt2wY3bkSBhba8PZ5lEbdI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Td7qpvRCmwLlXpm62o37fnnzZB7bIfPjoeW34HbVPMGRvpPOGHaHXRIL+E5IlFKW52PvF1LNuEXWqe1IphO93CRYG3Zd3G1YtV0MeVciBWj0Ek3t7bZLnBqTWN4vUrtSYa/k2+NSobfGWKfZm/DNDsvSyB3b97FN9BuEsjSekVU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com; spf=pass smtp.mailfrom=wdc.com; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b=DXUjjBvd; arc=none smtp.client-ip=68.232.143.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1717079121; x=1748615121; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=lI93q7XNVx+d7jqN8ZADdFt2wY3bkSBhba8PZ5lEbdI=; b=DXUjjBvdx2VKd4TZe0eaiJIZ6klx/Bd7DG0yDRV9YEajAQQThiONQgrt xh/LgSeD/1p/iWqUiMzYXeBpVIVYQxjArUPvdhrY7vWKMekqABoXby6BH Ve8dfJcyXQtpiBJe+BxuNXN7+5FO8llEpGjD4gm9j46d2zl4MUegDWiwc S561hNHZH3lXfmaLFkHfGcEUeC8h1Jkc3nN5LaNt4QN/D0TdWbrAs+xhP uM7MEY/CiLaWUwGvgmI6C6Vitwp2UhSazF7nzJ1NFwXV2RgtIbjMjxDaG SQKIbMmH8tLBvpzFbrwtlxx8ocL+4B61+Ps/0ACX0CjqdpjM9BvNzW/kF A==; X-CSE-ConnectionGUID: Dugq8QkmTZC5jZwOoUtRuA== X-CSE-MsgGUID: 8xoCSTJQRLiRzgrFQztK+Q== X-IronPort-AV: E=Sophos;i="6.08,201,1712592000"; d="scan'208";a="17740314" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 30 May 2024 22:25:15 +0800 IronPort-SDR: 66587ea5_3Z2Kl8XGDs9fQ2b9UQTG94faoSRyLE4vBTSyLxh9pkgCGEV HYiR1EVbTE5eq0qxvAR9gyG2yEoFGm4zAjAxupQ== Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 30 May 2024 06:27:02 -0700 WDCIronportException: Internal Received: from bxygm33.ad.shared ([10.45.31.229]) by uls-op-cesaip01.wdc.com with ESMTP; 30 May 2024 07:25:14 -0700 From: Avri Altman To: "Martin K . Petersen" Cc: Bart Van Assche , Bean Huo , Peter Wang , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Avri Altman Subject: [PATCH v7 0/3] scsi: ufs: Allow RTT negotiation Date: Thu, 30 May 2024 17:25:06 +0300 Message-ID: <20240530142510.734-1-avri.altman@wdc.com> X-Mailer: git-send-email 2.42.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The rtt-upiu packets precede any data-out upiu packets, thus synchronizing the data input to the device: this mostly applies to write operations, but there are other operations that requires rtt as well. There are several rules binding this rtt - data-out dialog, specifically There can be at most outstanding bMaxNumOfRTT such packets. This might have an effect on write performance (sequential write in particular), as each data-out upiu must wait for its rtt sibling. UFSHCI expects bMaxNumOfRTT to be min(bDeviceRTTCap, NORTT). However, as of today, there does not appear to be no-one who sets it: not the host controller nor the driver. It wasn't an issue up to now: bMaxNumOfRTT is set to 2 after manufacturing, and wasn't limiting the write performance. UFS4.0, and specifically gear 5 changes this, and requires the device to be more attentive. This doesn't come free - the device has to allocate more resources to that end, but the sequential write performance improvement is significant. Early measurements shows 25% gain when moving from rtt 2 to 9. Therefore, set bMaxNumOfRTT to be min(bDeviceRTTCap, NORTT) as UFSHCI expects. v6 -> v7: Some more comments to patches 2 & 3 (Bart) v5 -> v6: Use blk_mq_freeze_queue to drain the queues (Bart) Replace the rtt_set() vop by a max_num_rtt constant (Cristoph/Bart) v4 -> v5: Quiesce the queues before writing bMaxNumOfRTT (Bart) Make bDeviceRTTCap available in ufshcd_device_params_init() (Bart) v3 -> v4: Allow bMaxNumOfRTT to be configured via sysfs (Bart) v2 -> v3: Allow platform vendors to take precedence having their own rtt negotiation mechanism (Peter) v1 -> v2: bMaxNumOfRTT is a Persistent attribute - do not override if it was written (Bean) Avri Altman (3): scsi: ufs: Allow RTT negotiation scsi: ufs: Maximum RTT supported by the host driver scsi: ufs: sysfs: Make max_number_of_rtt read-write Documentation/ABI/testing/sysfs-driver-ufs | 14 +++-- drivers/ufs/core/ufs-sysfs.c | 73 +++++++++++++++++++++- drivers/ufs/core/ufshcd.c | 41 ++++++++++++ drivers/ufs/host/ufs-mediatek.c | 1 + drivers/ufs/host/ufs-mediatek.h | 3 + include/ufs/ufs.h | 2 + include/ufs/ufshcd.h | 4 ++ include/ufs/ufshci.h | 1 + 8 files changed, 132 insertions(+), 7 deletions(-) -- 2.34.1