Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp1450663lqb; Sun, 26 May 2024 01:17:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVW56cw6I9sw5fnwstjjerjOw9vuB8OethfTXNMesOa35Gqi34stW20qWuSRg9qdpWa99J6SC+RmlrdmW6vA49B+PyuwFLZ2X3EQONqEQ== X-Google-Smtp-Source: AGHT+IHF5rNMZS57DkE8yPnvcyTA4Ybx4bIMIHnAKyw5ErzdR4UcuwfsxVBD0f2OOBPYSHwwLMqU X-Received: by 2002:a05:6358:80a1:b0:192:b048:2942 with SMTP id e5c5f4694b2df-197e5666013mr770695455d.30.1716711427954; Sun, 26 May 2024 01:17:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716711427; cv=pass; d=google.com; s=arc-20160816; b=NH9A0HUma9o4E7BfQVHUOdVZ2j8cCLKC+7U+NyjfOxHmXMkGDC1brudLTdgFWiLYgH kmxa1eO4u1CnORkws/RDKNCHnVifCAElpRuadWoa6h60RpfmgcUirRe1xN5SVevd5KYT IUCEdkSEAfuf26ln08/fT/pVcsGSMVr0SfBcT6ebb4mWpYaN+Y/3QJn1FoMNPQB/f5eC 0cnG+mJ9iLxu3JvpbCNebnDTEoNVkSU0MB0hU3qd33sbwtV805jTtV99IQ9J0vPWo7L/ rRln2Y4SUrDv3xNPKS8dIX+qKbDhvH48XWhPFiL0ihN598gtdtdyvqDvi2+ZfR9siTNg i8AA== 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=dWsBc8HodqJwUyY8q5fuDv/dLeQzJzGWVCSN8uSsXho=; fh=X0Lb6G6jJE8+QeYtFGxv2g5f8eI/IotqH0fFq08ifqY=; b=AR39Da4YB+u/4nE76Y8zWhvyWQxj803NnipfqFFjrERbp0bTqCkt9x02UC52IJqF+O rA6rGiv0fbq+8bPzNxwFsA+yCGk4gM4LGUTUwWPIcZMMxjAOGAJMCdhvuQD+58UGM/mf VrGHMTZoeO/XS1Ese0jDRlRVCVFugYO92kXlc5F2ZAdDHvPy6x+kh70rTeUXa2u6pYUP wm6Gh7nox4HQ/MO7AMz+l39ZpvW9ymfa5p8jZ+gfb71GlVp9jjMXgBArvkD7ZuNXstUk h/PnNADM03HNqIH/UMz7eDY0aLwhgxli5kjd6RHuh9LaHK7jkJ0ELa8CEuojcpmuxldr vDsg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@wdc.com header.s=dkim.wdc.com header.b=Q1yboHmL; 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-189605-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-189605-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wdc.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-68227890295si4311907a12.275.2024.05.26.01.17.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 May 2024 01:17:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-189605-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@wdc.com header.s=dkim.wdc.com header.b=Q1yboHmL; 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-189605-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-189605-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 994B328145A for ; Sun, 26 May 2024 08:17:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AD11C8F4E; Sun, 26 May 2024 08:16:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="Q1yboHmL" Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) (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 D3E488BEE; Sun, 26 May 2024 08:16:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=216.71.154.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716711418; cv=none; b=reAm+Rbr4wLO49lPpv9n1jBmNmZXyYjADg6NRD6ysAx7VldvJ7LtUbghVMjl2iDc22mdA/1Jr3cJGXviQNgyhVTbpAwrlNjCiOpSM8eazECRW1T0QzK2Kh9JzMUGxobdIGvq64VnGe/7q/stUX15jRJ9espS0f5P7ARMkg/+SRo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716711418; c=relaxed/simple; bh=wPjkuqy7/TUpStWC5aJK0tThAfQUMWuS92Pd6h5bFhw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=UFls5fAYjWdrg8PiV7txZ51s/iFkqpOS0eTqHRsdN9vPHv6e45Gd16ChHH6zooLWQz1pO/pS/9n1X15iRyHO6fdK2U9njJyPKuLXKZ8sMdlLwZHqRVy1pFTFDDdxlwS7P343egcT5AAH+uVkGTPZpG0BTy/HCsiAtxS4dz+Qw5U= 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=Q1yboHmL; arc=none smtp.client-ip=216.71.154.45 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=1716711416; x=1748247416; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=wPjkuqy7/TUpStWC5aJK0tThAfQUMWuS92Pd6h5bFhw=; b=Q1yboHmLzqX5C+5ThqfA/qCfiElV2Vq0bslxqSPQ7BTchO5eXvJ8Dud+ Tlb5mOXfKyZ/QtH3Z+aiGkgWCFHjPPMAhcz11j3YnYb+oycYKDeLxsMlK e5b5U4KVuGs82xXPeuGpMhPCb/47DSIoio+Sx35ZNxGKfmfsxcydTKG14 jESAuBDJ08vss/GwL/hNSk0RzC0Rmi5G1w5qdWMrZklwikX4PbXy4zF7w RCPEkDUhM2tIj/UTLxqoj628yPQxuRjvQfXbQJML6dyuxp4TiKswhDTSz PlfCUK03Swu2oHAg88xy1EdPLJkgl6rKkpBlFkiq1WRz+PKgupWqcY9LL w==; X-CSE-ConnectionGUID: MNofxBkFQ/unrkNmKI04zA== X-CSE-MsgGUID: SA+y0A8VTdOe7seORAbdQw== X-IronPort-AV: E=Sophos;i="6.08,190,1712592000"; d="scan'208";a="17270699" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 26 May 2024 16:16:49 +0800 IronPort-SDR: 6652e3a5_FmK3oc4I5P2r9a80TXUjnofXB3YBpeYX5wkDncMsZfznXFT 0U5GMImndRQhi2gwlCDBPSGFf48qXBzcWZ0Xygw== Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 26 May 2024 00:24:22 -0700 WDCIronportException: Internal Received: from bxygm33.ad.shared ([10.45.31.229]) by uls-op-cesaip02.wdc.com with ESMTP; 26 May 2024 01:16:47 -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 v6 0/3] scsi: ufs: Allow RTT negotiation Date: Sun, 26 May 2024 11:16:33 +0300 Message-ID: <20240526081636.2064-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. 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 | 68 +++++++++++++++++++++- drivers/ufs/core/ufshcd-priv.h | 24 ++++++++ drivers/ufs/core/ufshcd.c | 42 +++++++++++++ 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 + 9 files changed, 152 insertions(+), 7 deletions(-) -- 2.34.1