Received: from 004.mia.mailroute.net (004.mia.mailroute.net [199.89.3.7]) (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 B22682EA750; Mon, 30 Jun 2025 22:31:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.3.7 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751322694; cv=none; b=drMndAN5Srci3wCCIhPkd1+ew5CvbRw/XGj3UExHiMPv5lBeHcqVt6fwV5UsdoTxpuGbxc0UEE+Y7pWOp13M8Gi9XVysH+XZgULz5wQm+/uwYPwuR1sm/D8URmmRLuYE+6PcFCJYTv1CoYmU44YILdogzUP9gghBfG98gl8cCV8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751322694; c=relaxed/simple; bh=CXMV6wfDaQSlWZQyF4hSEXvoxhfI57wDE1w3O8R1x3M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hzTpC47YJbIeAgQKv56IGY1OZ3fsPYnDQkmUxH1LrGY8KgASuAUulIcnV8VBf58dG4IplHooarPPKSg5NMQH9nKUGrH1RJSXZbhcLHyZz1NAPzk8OSgLKtT6YKxTrKI5Hkwcnov94UfmU0SUW90O2JN5syQFefKcfvhtYDPm8yE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org; spf=pass smtp.mailfrom=acm.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b=DWwvpdxe; arc=none smtp.client-ip=199.89.3.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=acm.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b="DWwvpdxe" Received: from localhost (localhost [127.0.0.1]) by 004.mia.mailroute.net (Postfix) with ESMTP id 4bWLVW67d5zm0c30; Mon, 30 Jun 2025 22:31:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acm.org; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:from:from :received:received; s=mr01; t=1751322689; x=1753914690; bh=CIeKg tusAl5YQmSP+f8DbV1x3/RtOLjWueDD7VaDP0I=; b=DWwvpdxetgrodJ6LfKEZz kwK6reMixG+BL+59P5AeVBy/tHuZSvBFvDq9B/lNDxS+G1W1UxU16YnfDes0qps8 YOvKHfm8SfSWAnQC8VtGpvo/hg2t2DJq42DREvjAnWikPf3jmlGuTMrFtSzqZ/JR IrgJFnTSwYjmQgVlQDzGdxFhZDngxkFm7dzuSCLh3kGyguWzoceO1I7Tfbw8eD8Y 4x3qnjbvD2Z1CbYH6CkNQ/L8iIt1+WhdSNqrsMgGFE6E+x7HLoQjd/iNYyNxKHwC QP2y9uUvYUq2hmLeUF27SVeCE+tFFSbKVP3FLJpVUtaCeJB5LD3hN6qA8q4/J7Ab g== X-Virus-Scanned: by MailRoute Received: from 004.mia.mailroute.net ([127.0.0.1]) by localhost (004.mia [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id hBgGAFdiZpja; Mon, 30 Jun 2025 22:31:29 +0000 (UTC) Received: from bvanassche.mtv.corp.google.com (unknown [104.135.204.82]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bvanassche@acm.org) by 004.mia.mailroute.net (Postfix) with ESMTPSA id 4bWLVM2qHdzm1Hbt; Mon, 30 Jun 2025 22:31:22 +0000 (UTC) From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org, Christoph Hellwig , Damien Le Moal , Bart Van Assche , Avri Altman , "Bao D. Nguyen" , Can Guo , "Martin K. Petersen" Subject: [PATCH v19 11/11] scsi: ufs: Inform the block layer about write ordering Date: Mon, 30 Jun 2025 15:30:03 -0700 Message-ID: <20250630223003.2642594-12-bvanassche@acm.org> X-Mailer: git-send-email 2.50.0.727.gbf7dc18ff4-goog In-Reply-To: <20250630223003.2642594-1-bvanassche@acm.org> References: <20250630223003.2642594-1-bvanassche@acm.org> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From the UFSHCI 4.0 specification, about the MCQ mode: "Command Submission 1. Host SW writes an Entry to SQ 2. Host SW updates SQ doorbell tail pointer Command Processing 3. After fetching the Entry, Host Controller updates SQ doorbell head pointer 4. Host controller sends COMMAND UPIU to UFS device" In other words, in MCQ mode, UFS controllers are required to forward commands to the UFS device in the order these commands have been received from the host. This patch improves performance as follows on a test setup with UFSHCI 4.0 controller: - When not using an I/O scheduler: 2.3x more IOPS for small writes. - With the mq-deadline scheduler: 2.0x more IOPS for small writes. Reviewed-by: Avri Altman Cc: Bao D. Nguyen Cc: Can Guo Cc: Martin K. Petersen Signed-off-by: Bart Van Assche --- drivers/ufs/core/ufshcd.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 50adfb8b335b..1f2fc47ca7b4 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -5281,6 +5281,12 @@ static int ufshcd_sdev_configure(struct scsi_devic= e *sdev, struct ufs_hba *hba =3D shost_priv(sdev->host); struct request_queue *q =3D sdev->request_queue; =20 + /* + * The write order is preserved per MCQ. Without MCQ, auto-hibernation + * may cause write reordering that results in unaligned write errors. + */ + lim->driver_preserves_write_order =3D hba->mcq_enabled; + lim->dma_pad_mask =3D PRDT_DATA_BYTE_COUNT_PAD - 1; =20 /*