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 EA49D2D949D; Mon, 11 Aug 2025 20:11:06 +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=1754943068; cv=none; b=clV2vPMZdZdN/Bqz08bTUBjDjOGRep3RzsvNciocPkBDBERMbWbczbjYU5+TFt4frACj6wHpTeiwrhxKw97WtmGHTNx9GMZQtMRNIM+md/JZK4L6VCOdGc993Ed04auT0od/kK90jkTCojoEPxLahfDlvibJvWlQVFvz8ZDIbbs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754943068; c=relaxed/simple; bh=4bxsvPVBqqKAawMBDHV9HnWDID49t/gFbfxmnJ51P3U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Tz/6r65K3XiN57uIjYdmjm/Q1gSzMu8yJMs3HLzqSRUrzlmmz+2Y5QA4TAK8lcQ7XcMTlqNpJDgfdxEqVlOd3KkL9meZghKcLVbXQpuivTkhDs+9pIRL3tvk/F5ufySeDIi2QfcemqQusQSWmy/mBqQMIHzcCfAnil8Uul/UJhA= 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=uGGlFE3R; 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="uGGlFE3R" Received: from localhost (localhost [127.0.0.1]) by 004.mia.mailroute.net (Postfix) with ESMTP id 4c15P626Zvzm0ySq; Mon, 11 Aug 2025 20:11:06 +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=1754943064; x=1757535065; bh=BwbF9 3iRKJX5gmvSTUmwE22gNq0uCPfHdCkUrkFvWCQ=; b=uGGlFE3RAZgq7jB08SRN4 JFk4Ns/YFxicPcS6PYvBQrF2IaUnYxNTsnO22rYTIJ9Clr8duDNY0qBzAUfpZk3q eDMw39um15bgOfxf0P15cn61ycesjiT+XdRFz1ujTqL2/1VZYbUWIPurcGYT0nLe OOEKVrz/sZIbbXhKXryUnr93fTLbaxuS9bAUZ/lo5rR75BwREfsGgKEts62eUa0b uk+j5Q6xhg/BoreG16C5I6Oe6MFOaUsaiU0xpbor/xeSZqDUAaOfpreDTTpsEaOy M4y99nfO9YDvt0L9PcnqNuK5Zt66GKbPs2lHgb9SxSt9ZLpT/VlGm77iUnjGQRM2 A== 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 uRWS80KUNUpE; Mon, 11 Aug 2025 20:11:04 +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 4c15Nw5fNFzm0yVQ; Mon, 11 Aug 2025 20:10:55 +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 v23 16/16] ufs: core: Inform the block layer about write ordering Date: Mon, 11 Aug 2025 13:08:51 -0700 Message-ID: <20250811200851.626402-17-bvanassche@acm.org> X-Mailer: git-send-email 2.51.0.rc0.155.g4a0f42376b-goog In-Reply-To: <20250811200851.626402-1-bvanassche@acm.org> References: <20250811200851.626402-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 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 96ad57c3144b..28ef6188b806 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -5317,6 +5317,13 @@ 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. + */ + if (hba->mcq_enabled) + lim->features |=3D BLK_FEAT_ORDERED_HWQ; + lim->dma_pad_mask =3D PRDT_DATA_BYTE_COUNT_PAD - 1; =20 /*