From patchwork Mon Sep 18 16:20:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 725164 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7B53C46CA1 for ; Mon, 18 Sep 2023 16:27:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230081AbjIRQ16 (ORCPT ); Mon, 18 Sep 2023 12:27:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229982AbjIRQ1g (ORCPT ); Mon, 18 Sep 2023 12:27:36 -0400 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA206216C5 for ; Mon, 18 Sep 2023 09:21:47 -0700 (PDT) Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-1bf55a81eeaso33933745ad.0 for ; Mon, 18 Sep 2023 09:21:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695054076; x=1695658876; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HC1c+srrjijA9jfgQkIRw/emAtgfwjLgM9wA0nVlBAo=; b=L3lB9l46EJQWPyU9uCyAZ4VhJ0GEgJZHPP89G13sZ7si5oym5GhYs/KrUyWedK5wM/ mghcUxxnjVn6D+fhjR+nxGOYM2pHo7bJAXzcLd7Nuu6UiKo63BWDXv1i+okr/qPkq/MC zWx6iax2iEIDCvJonmMfrr19Z5lePcfsZyspsf4iIaH90NkWH4r5Im1Hrfx2+yAANJHj OecMKesPufUj5C3xZRyWjDkFm1zjlxe7nXyjqOEoEmlFpwfvZkQNoLr1YnEFTS8tzkyx TXKuoRdIL4DA3i2NkHpQcxVjz1M19qaOQID3GK6POISCHAkDhdHiK2clC323qcKmKUTV 6mpg== X-Gm-Message-State: AOJu0YwUogZo1JnLoruD+/lnfozdH5oKy2OQvRuc5fWMI3wKU2qgRKV7 owf4iTiyIOUVXdpR3a8FJ0M= X-Google-Smtp-Source: AGHT+IHA4U1qTUfeeVMynnYgVNGhp6pYTwN2F3wjv9PwEjhWCy2SlrTYqMgjYwy3fTN5t5cXArw5Ig== X-Received: by 2002:a17:902:f689:b0:1c3:e5bf:a9ec with SMTP id l9-20020a170902f68900b001c3e5bfa9ecmr9061164plg.51.1695054075831; Mon, 18 Sep 2023 09:21:15 -0700 (PDT) Received: from bvanassche-linux.mtv.corp.google.com ([2620:15c:211:201:33e7:1437:5d00:8e3b]) by smtp.gmail.com with ESMTPSA id z14-20020a170902d54e00b001bd28b9c3ddsm8489414plf.299.2023.09.18.09.21.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 09:21:15 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , "James E.J. Bottomley" , Stanley Chu , Can Guo , Manivannan Sadhasivam , Asutosh Das , Bean Huo , "Bao D. Nguyen" , Arthur Simchaev Subject: [PATCH 1/4] scsi: ufs: Return in case of an invalid tag Date: Mon, 18 Sep 2023 09:20:12 -0700 Message-ID: <20230918162058.1562033-2-bvanassche@acm.org> X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog In-Reply-To: <20230918162058.1562033-1-bvanassche@acm.org> References: <20230918162058.1562033-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org If a tag is invalid, instead of only issuing a kernel warning, also return. This patch suppresses Coverity warnings about left shifts with a negative right hand operand. Signed-off-by: Bart Van Assche --- drivers/ufs/core/ufshcd.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index dc1285351336..5fccec3c1091 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -2822,7 +2822,8 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) int err = 0; struct ufs_hw_queue *hwq = NULL; - WARN_ONCE(tag < 0 || tag >= hba->nutrs, "Invalid tag %d\n", tag); + if (WARN_ONCE(tag < 0 || tag >= hba->nutrs, "Invalid tag %d\n", tag)) + return 0; switch (hba->ufshcd_state) { case UFSHCD_STATE_OPERATIONAL: @@ -6923,8 +6924,11 @@ static int __ufshcd_issue_tm_cmd(struct ufs_hba *hba, spin_lock_irqsave(host->host_lock, flags); task_tag = req->tag; - WARN_ONCE(task_tag < 0 || task_tag >= hba->nutmrs, "Invalid tag %d\n", - task_tag); + if (WARN_ONCE(task_tag < 0 || task_tag >= hba->nutmrs, + "Invalid tag %d\n", task_tag)) { + err = -EINVAL; + goto unlock; + } hba->tmf_rqs[req->tag] = req; treq->upiu_req.req_header.task_tag = task_tag; @@ -6963,6 +6967,7 @@ static int __ufshcd_issue_tm_cmd(struct ufs_hba *hba, spin_lock_irqsave(hba->host->host_lock, flags); hba->tmf_rqs[req->tag] = NULL; __clear_bit(task_tag, &hba->outstanding_tasks); +unlock: spin_unlock_irqrestore(hba->host->host_lock, flags); ufshcd_release(hba); @@ -7485,7 +7490,7 @@ int ufshcd_try_to_abort_task(struct ufs_hba *hba, int tag) * ufshcd_abort - scsi host template eh_abort_handler callback * @cmd: SCSI command pointer * - * Return: SUCCESS or FAILED. + * Return: SUCCESS, FAILED or FAST_IO_FAIL. */ static int ufshcd_abort(struct scsi_cmnd *cmd) { @@ -7498,7 +7503,8 @@ static int ufshcd_abort(struct scsi_cmnd *cmd) bool outstanding; u32 reg; - WARN_ONCE(tag < 0, "Invalid tag %d\n", tag); + if (WARN_ONCE(tag < 0, "Invalid tag %d\n", tag)) + return FAST_IO_FAIL; ufshcd_hold(hba); From patchwork Mon Sep 18 16:20:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 724363 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81B38C46CA1 for ; Mon, 18 Sep 2023 16:28:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229995AbjIRQ2N (ORCPT ); Mon, 18 Sep 2023 12:28:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229918AbjIRQ1t (ORCPT ); Mon, 18 Sep 2023 12:27:49 -0400 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AC6F21EB0 for ; Mon, 18 Sep 2023 09:22:05 -0700 (PDT) Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-1c3bd829b86so34075455ad.0 for ; Mon, 18 Sep 2023 09:22:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695054091; x=1695658891; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DxhRYQyu6qLWzaGH/ogzDEcSbv33IcCjbAZcuyI4vOA=; b=CSkZ7Tlvxk8EkI+DS9oYjHpf52ZN//oasPhhy/+/APUYiYvlH6YHX+ON1aQPhF6GSk DDi2YXptloqr2xIxkxN8rJLKT383ZW0WK091btzo3RiWiBJ+BRb9NpCe9PwlElsgTGka //XHJ7zytQyCpMV8hNJ0NP2cMS/Grq99wAWanZTQyPY1HBCxq3gRMZdZK/H8IcRcPcXL Klv5SxC68Qn57HJJiiQBNy5Kh1FCjZ+alDxMjHZpln0VFrk88UyqauT5ZD+yVYWLCWgM BxAIAcznyJKMhR/N09BaSm6VB4PG5+Ugzht0Qro3r/B3jp+iVogbx7AJ065npV20nbdy xb5w== X-Gm-Message-State: AOJu0YxBZZU6IpzSL+zG0ZrVE/3XtNaddETdTLDdgWcq6+Kl1s8Z7O8E 6rIRCIw32YuVeo2H2ZHX7u4= X-Google-Smtp-Source: AGHT+IGZmWtcgFBwW4BoYgrS7yq1L7CtuMir503EO4Fsuf8mT8/xge80k6uGRBNq7+QI13AYEyL9fg== X-Received: by 2002:a17:903:2643:b0:1bf:703d:cc6b with SMTP id je3-20020a170903264300b001bf703dcc6bmr6884009plb.10.1695054091292; Mon, 18 Sep 2023 09:21:31 -0700 (PDT) Received: from bvanassche-linux.mtv.corp.google.com ([2620:15c:211:201:33e7:1437:5d00:8e3b]) by smtp.gmail.com with ESMTPSA id z14-20020a170902d54e00b001bd28b9c3ddsm8489414plf.299.2023.09.18.09.21.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 09:21:30 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Alim Akhtar , "James E.J. Bottomley" , Krzysztof Kozlowski , Stanley Chu , Can Guo , Manivannan Sadhasivam , Asutosh Das , Bean Huo , "Bao D. Nguyen" , Arthur Simchaev , Po-Wen Kao , Eric Biggers , Keoseong Park Subject: [PATCH 2/4] scsi: ufs: Move the 4K alignment code into the Exynos driver Date: Mon, 18 Sep 2023 09:20:13 -0700 Message-ID: <20230918162058.1562033-3-bvanassche@acm.org> X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog In-Reply-To: <20230918162058.1562033-1-bvanassche@acm.org> References: <20230918162058.1562033-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The DMA alignment for the Exynos controller follows directly from the PRDT segment size configured in ufs-exynos.c. Hence, move the DMA alignment code into the Exynos driver source code. Cc: Alim Akhtar Signed-off-by: Bart Van Assche --- drivers/ufs/core/ufshcd.c | 6 ++++-- drivers/ufs/host/ufs-exynos.c | 9 +++++++-- include/ufs/ufshcd.h | 7 ++----- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 5fccec3c1091..100729981738 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -5098,8 +5098,7 @@ static int ufshcd_slave_configure(struct scsi_device *sdev) struct request_queue *q = sdev->request_queue; blk_queue_update_dma_pad(q, PRDT_DATA_BYTE_COUNT_PAD - 1); - if (hba->quirks & UFSHCD_QUIRK_4KB_DMA_ALIGNMENT) - blk_queue_update_dma_alignment(q, SZ_4K - 1); + /* * Block runtime-pm until all consumers are added. * Refer ufshcd_setup_links(). @@ -5115,6 +5114,9 @@ static int ufshcd_slave_configure(struct scsi_device *sdev) */ sdev->silence_suspend = 1; + if (hba->vops && hba->vops->config_scsi_dev) + hba->vops->config_scsi_dev(sdev); + ufshcd_crypto_register(hba, q); return 0; diff --git a/drivers/ufs/host/ufs-exynos.c b/drivers/ufs/host/ufs-exynos.c index 3396e0388512..e5d145a2676e 100644 --- a/drivers/ufs/host/ufs-exynos.c +++ b/drivers/ufs/host/ufs-exynos.c @@ -1511,6 +1511,11 @@ static int fsd_ufs_pre_link(struct exynos_ufs *ufs) return 0; } +static void exynos_ufs_config_scsi_dev(struct scsi_device *sdev) +{ + blk_queue_update_dma_alignment(sdev->request_queue, SZ_4K - 1); +} + static int fsd_ufs_post_link(struct exynos_ufs *ufs) { int i; @@ -1579,6 +1584,7 @@ static const struct ufs_hba_variant_ops ufs_hba_exynos_ops = { .hibern8_notify = exynos_ufs_hibern8_notify, .suspend = exynos_ufs_suspend, .resume = exynos_ufs_resume, + .config_scsi_dev = exynos_ufs_config_scsi_dev, }; static struct ufs_hba_variant_ops ufs_hba_exynosauto_vh_ops = { @@ -1680,8 +1686,7 @@ static const struct exynos_ufs_drv_data exynos_ufs_drvs = { UFSHCI_QUIRK_SKIP_RESET_INTR_AGGR | UFSHCD_QUIRK_BROKEN_OCS_FATAL_ERROR | UFSHCI_QUIRK_SKIP_MANUAL_WB_FLUSH_CTRL | - UFSHCD_QUIRK_SKIP_DEF_UNIPRO_TIMEOUT_SETTING | - UFSHCD_QUIRK_4KB_DMA_ALIGNMENT, + UFSHCD_QUIRK_SKIP_DEF_UNIPRO_TIMEOUT_SETTING, .opts = EXYNOS_UFS_OPT_HAS_APB_CLK_CTRL | EXYNOS_UFS_OPT_BROKEN_AUTO_CLK_CTRL | EXYNOS_UFS_OPT_BROKEN_RX_SEL_IDX | diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h index 7d07b256e906..e0d6590d163d 100644 --- a/include/ufs/ufshcd.h +++ b/include/ufs/ufshcd.h @@ -28,6 +28,7 @@ #define UFSHCD "ufshcd" +struct scsi_device; struct ufs_hba; enum dev_cmd_type { @@ -371,6 +372,7 @@ struct ufs_hba_variant_ops { int (*get_outstanding_cqs)(struct ufs_hba *hba, unsigned long *ocqs); int (*config_esi)(struct ufs_hba *hba); + void (*config_scsi_dev)(struct scsi_device *sdev); }; /* clock gating state */ @@ -596,11 +598,6 @@ enum ufshcd_quirks { */ UFSHCD_QUIRK_SKIP_DEF_UNIPRO_TIMEOUT_SETTING = 1 << 13, - /* - * Align DMA SG entries on a 4 KiB boundary. - */ - UFSHCD_QUIRK_4KB_DMA_ALIGNMENT = 1 << 14, - /* * This quirk needs to be enabled if the host controller does not * support UIC command From patchwork Mon Sep 18 16:20:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 724364 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2CAACD37B0 for ; Mon, 18 Sep 2023 16:26:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229905AbjIRQ0t (ORCPT ); Mon, 18 Sep 2023 12:26:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230074AbjIRQ0T (ORCPT ); Mon, 18 Sep 2023 12:26:19 -0400 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4181C23CDE for ; Mon, 18 Sep 2023 09:22:14 -0700 (PDT) Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-1c3d8fb23d9so36559185ad.0 for ; Mon, 18 Sep 2023 09:22:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695054100; x=1695658900; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JzlqkJgudxivYIXs+IzQPdAZD4igib+RglO/avRHMBM=; b=cs6fHObstPwRC8WlBAs6XhgLYhRR3YqTa+f7My0TFnenxJ9tNWVmJtgMiJQGgXYc0r JPl6ircR45nUaiIfYGs6n5U7wXYevvuej0fHzT893ORplEacCteyOqwchRvXB1GPOxdR 4MaquY7VDz6WRbyPqOxkNQEZLGMwE5qDMUdpwPpySLpJ9C/mtCnKHeuMh63am2lrH7pN fcMR7DRBzFY5L423Ygimg/vRXPcYnAtRxyaSO8h9KoLuK2R3wC0qySrRXLlSsG87zQKl nRyObFu1qg6AKNGdDNq41CneB5Ofn6ZnEyNC9S9xh1E9K7nlNf55iJORb4wld910NYA/ FP6g== X-Gm-Message-State: AOJu0YzIFj5Gh1kLtfe9p5z7mdkXvyvlDixezk3MbNCVbldOQ5Hmekx+ 150SZAlkRccjcjatuPH5oYI= X-Google-Smtp-Source: AGHT+IG8DRZWuIiIjDmDqQ2lyTzrXqVie076wcPl/1FkVjfPrnZaZiSpfPLnDSN6SAbI59ZngwuTUA== X-Received: by 2002:a17:902:d491:b0:1c3:e3b1:98df with SMTP id c17-20020a170902d49100b001c3e3b198dfmr10136949plg.52.1695054099719; Mon, 18 Sep 2023 09:21:39 -0700 (PDT) Received: from bvanassche-linux.mtv.corp.google.com ([2620:15c:211:201:33e7:1437:5d00:8e3b]) by smtp.gmail.com with ESMTPSA id z14-20020a170902d54e00b001bd28b9c3ddsm8489414plf.299.2023.09.18.09.21.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 09:21:39 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , "James E.J. Bottomley" , Stanley Chu , Can Guo , Manivannan Sadhasivam , Asutosh Das , Bean Huo , "Bao D. Nguyen" , Arthur Simchaev Subject: [PATCH 3/4] scsi: ufs: Simplify ufshcd_comp_scsi_upiu() Date: Mon, 18 Sep 2023 09:20:14 -0700 Message-ID: <20230918162058.1562033-4-bvanassche@acm.org> X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog In-Reply-To: <20230918162058.1562033-1-bvanassche@acm.org> References: <20230918162058.1562033-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org ufshcd_comp_scsi_upiu() has one caller and that caller ensures that lrbp->cmd != NULL. Hence leave out the lrbp->cmd check from ufshcd_comp_scsi_upiu(). Signed-off-by: Bart Van Assche --- drivers/ufs/core/ufshcd.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 100729981738..c69bf532c4ab 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -2714,27 +2714,19 @@ static int ufshcd_compose_devman_upiu(struct ufs_hba *hba, * for SCSI Purposes * @hba: per adapter instance * @lrbp: pointer to local reference block - * - * Return: 0 upon success; < 0 upon failure. */ -static int ufshcd_comp_scsi_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) +static void ufshcd_comp_scsi_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) { u8 upiu_flags; - int ret = 0; if (hba->ufs_version <= ufshci_version(1, 1)) lrbp->command_type = UTP_CMD_TYPE_SCSI; else lrbp->command_type = UTP_CMD_TYPE_UFS_STORAGE; - if (likely(lrbp->cmd)) { - ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags, lrbp->cmd->sc_data_direction, 0); - ufshcd_prepare_utp_scsi_cmd_upiu(lrbp, upiu_flags); - } else { - ret = -EINVAL; - } - - return ret; + ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags, + lrbp->cmd->sc_data_direction, 0); + ufshcd_prepare_utp_scsi_cmd_upiu(lrbp, upiu_flags); } /** From patchwork Mon Sep 18 16:20:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 725165 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56D9FCD13DE for ; Mon, 18 Sep 2023 16:26:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229704AbjIRQ0b (ORCPT ); Mon, 18 Sep 2023 12:26:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229998AbjIRQ0S (ORCPT ); Mon, 18 Sep 2023 12:26:18 -0400 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C63DB24457 for ; Mon, 18 Sep 2023 09:22:22 -0700 (PDT) Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-1c46b30a1ceso14839285ad.3 for ; Mon, 18 Sep 2023 09:22:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695054115; x=1695658915; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2TqlPkjwyXKr2IgdDGn6gtkPnsspM7borbVflhN6PYE=; b=AkKuf2qKAnWC7/MUMINu5aBQ1n8wEArtNc0Lp+2/eYzHvflKvFpeqAOlPvUYd1y1kw QaeXRGOLDOKH/RiQpT31dg+igXNmc6Z7mKZTSyMMG1Mv2gW++ec4HXnUSpwQIraJdFuu faT+6FctkTjZXf6fvNb/kIZ7Gk/QLqfoGyxwEkw3ZLgQfXFGweilvh01bQL4o/bJacR/ 7rxt/HzUHiKklCjZpNY23Xn6HIwvKot8vT6kKCzcRvUF/VoxS2V4tJ49mnq49DQ6PE7Q bFsYA3T8qt++KUTJACHvhbkDCs8VMr/PtsgekGlVDyFZC1qLbU+OeG6NEc4Fbe6imsRr mqzw== X-Gm-Message-State: AOJu0Yx4yDs0F5R11RQwNlS9I8TvVSWLw0Y6ranQ0slci8mOfCfHKIQh 5oCsqp6fme3/N7bOKi1yMAE= X-Google-Smtp-Source: AGHT+IGykO8rgz3pzEAG9rNGtSQWPl96pMDMWwiFml4LSfIh6Z0qIXNKJRes0ANNk8hDjTqlX18PDA== X-Received: by 2002:a17:902:d2d2:b0:1c4:bc8:4b64 with SMTP id n18-20020a170902d2d200b001c40bc84b64mr10464851plc.5.1695054114622; Mon, 18 Sep 2023 09:21:54 -0700 (PDT) Received: from bvanassche-linux.mtv.corp.google.com ([2620:15c:211:201:33e7:1437:5d00:8e3b]) by smtp.gmail.com with ESMTPSA id z14-20020a170902d54e00b001bd28b9c3ddsm8489414plf.299.2023.09.18.09.21.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 09:21:54 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , "James E.J. Bottomley" , Stanley Chu , Can Guo , Manivannan Sadhasivam , Asutosh Das , Bean Huo , "Bao D. Nguyen" , Arthur Simchaev , Avri Altman Subject: [PATCH 4/4] scsi: ufs: Set the Command Priority (CP) flag for RT requests Date: Mon, 18 Sep 2023 09:20:15 -0700 Message-ID: <20230918162058.1562033-5-bvanassche@acm.org> X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog In-Reply-To: <20230918162058.1562033-1-bvanassche@acm.org> References: <20230918162058.1562033-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Make the UFS device execute realtime (RT) requests before other requests. This will be used in Android to reduce the I/O latency of the foreground app. Signed-off-by: Bart Van Assche --- drivers/ufs/core/ufshcd.c | 4 ++++ include/ufs/ufs.h | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index c69bf532c4ab..54c3811d5534 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -2717,6 +2717,8 @@ static int ufshcd_compose_devman_upiu(struct ufs_hba *hba, */ static void ufshcd_comp_scsi_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) { + struct request *rq = scsi_cmd_to_rq(lrbp->cmd); + unsigned int ioprio_class = IOPRIO_PRIO_CLASS(req_get_ioprio(rq)); u8 upiu_flags; if (hba->ufs_version <= ufshci_version(1, 1)) @@ -2726,6 +2728,8 @@ static void ufshcd_comp_scsi_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags, lrbp->cmd->sc_data_direction, 0); + if (ioprio_class == IOPRIO_CLASS_RT) + upiu_flags |= UPIU_CMD_FLAGS_CP; ufshcd_prepare_utp_scsi_cmd_upiu(lrbp, upiu_flags); } diff --git a/include/ufs/ufs.h b/include/ufs/ufs.h index 0cced88f4531..e77ab1786856 100644 --- a/include/ufs/ufs.h +++ b/include/ufs/ufs.h @@ -98,9 +98,10 @@ enum upiu_response_transaction { UPIU_TRANSACTION_REJECT_UPIU = 0x3F, }; -/* UPIU Read/Write flags */ +/* UPIU Read/Write flags. See also table "UPIU Flags" in the UFS standard. */ enum { UPIU_CMD_FLAGS_NONE = 0x00, + UPIU_CMD_FLAGS_CP = 0x04, UPIU_CMD_FLAGS_WRITE = 0x20, UPIU_CMD_FLAGS_READ = 0x40, };