From patchwork Thu Apr 3 21:18:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 878126 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 683BB1E3DF4 for ; Thu, 3 Apr 2025 21:24:26 +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=1743715468; cv=none; b=KOvCZIpf6Sg1q52xOlzvJOBeMoDxhGMEYjs8eDg1Ho8amNpwPQb3FwlP574+nsNmYLCQnyEFb9veeros7lvBOc2oHmTk/0UXOyfGUOoqNyxtYLuLGV58vI4qJZ6n2YrcrPfYmokgRrilZELCP+4Hl+2T64yJzsXBBij/PTxPaiA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743715468; c=relaxed/simple; bh=+RxQEQmVfKMACMiyIKRidyDQHU9bwGpPa9mMnRLaV98=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hc1/N/fqGbI65qvkC7dzVLUA/LJ2UY76IwlaVbwYeCutvEbaY5xXLE5OajORiu2S8/yyFwE3NW7TfX9kLFoaP9Pz8IyF+QYj3gBF1btvUGg9EejYzQUprjf+OTz4NSngV4/GkIUZdIjshhwuZ2K0pnOjy4wWX0jezroAoa0PvKY= 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=NbOT0GHT; 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="NbOT0GHT" Received: from localhost (localhost [127.0.0.1]) by 004.mia.mailroute.net (Postfix) with ESMTP id 4ZTF9j4lXTzm0yTm; Thu, 3 Apr 2025 21:24:25 +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=1743715463; x=1746307464; bh=EsIjn RP1RlEFwQs2OjKNrJ99ezPgM7ADtqMEOoQetYo=; b=NbOT0GHTFYryFdHw+FmFL dNO7LImgVQvvAOA4ADKLmwZsDzrii0hraEF4bJqqsC/RaKGCy/uons11UK4vbiwu QYHyk3ZglTbgZ3kQ2mCliMemojhqs7dZ+n+jD/g8ul6j3fzE3EplxDv/oMF4mKVR PlRzIBwF2xNWCygyklmt/NIQ8r0fA0AA+twrYlPfX24EaMHKxVFC9DTHWTH3nslh v+LnmtP0d3ChmwrS6sc+HQrqnDFCpQoc1xqUmqI5fJCvPLj62XouC7jWCbf4EzJA oH4XGOhiIzzJfv2kraxu9+dKZm/MCEBYI7uUIq4GplWrmHVcjXA6GOXUJz62i+L2 Q== 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 bt3_HBEbMKLO; Thu, 3 Apr 2025 21:24:23 +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 4ZTF9X0TkFzm272S; Thu, 3 Apr 2025 21:24:15 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , "James E.J. Bottomley" , Peter Wang , Avri Altman , Manivannan Sadhasivam , "Bao D. Nguyen" , Eric Biggers , Can Guo , Minwoo Im Subject: [PATCH 24/24] scsi: ufs: core: Remove the ufshcd_lrb task_tag member Date: Thu, 3 Apr 2025 14:18:08 -0700 Message-ID: <20250403211937.2225615-25-bvanassche@acm.org> X-Mailer: git-send-email 2.49.0.504.g3bcea36a83-goog In-Reply-To: <20250403211937.2225615-1-bvanassche@acm.org> References: <20250403211937.2225615-1-bvanassche@acm.org> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Remove the ufshcd_lrb task_tag member and use scsi_cmd_to_rq(cmd)->tag instead. Use rq->tag instead of lrbp->task_tag. Signed-off-by: Bart Van Assche --- drivers/ufs/core/ufshcd.c | 66 +++++++++++++++++++-------------------- include/ufs/ufshcd.h | 1 - 2 files changed, 33 insertions(+), 34 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 1b8be737e470..b7769eb190f7 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -551,7 +551,7 @@ static void ufshcd_print_tr(struct ufs_hba *hba, struct scsi_cmnd *cmd, bool pr_prdt) { struct ufshcd_lrb *lrbp = scsi_cmd_priv(cmd); - const int tag = lrbp->task_tag; + const int tag = scsi_cmd_to_rq(cmd)->tag; int prdt_length; dev_err(hba->dev, "UPIU[%d] - issue time %lld us\n", @@ -2312,6 +2312,7 @@ static inline void ufshcd_send_command(struct ufs_hba *hba, struct ufs_hw_queue *hwq) { struct ufshcd_lrb *lrbp = scsi_cmd_priv(cmd); + const int tag = scsi_cmd_to_rq(cmd)->tag; unsigned long flags; lrbp->issue_time_stamp = ktime_get(); @@ -2338,11 +2339,10 @@ static inline void ufshcd_send_command(struct ufs_hba *hba, } else { spin_lock_irqsave(&hba->outstanding_lock, flags); if (hba->vops && hba->vops->setup_xfer_req) - hba->vops->setup_xfer_req(hba, lrbp->task_tag, + hba->vops->setup_xfer_req(hba, tag, ufshcd_is_scsi_cmd(cmd)); - __set_bit(lrbp->task_tag, &hba->outstanding_reqs); - ufshcd_writel(hba, 1 << lrbp->task_tag, - REG_UTP_TRANSFER_REQ_DOOR_BELL); + __set_bit(tag, &hba->outstanding_reqs); + ufshcd_writel(hba, 1 << tag, REG_UTP_TRANSFER_REQ_DOOR_BELL); spin_unlock_irqrestore(&hba->outstanding_lock, flags); } } @@ -2760,6 +2760,7 @@ static void ufshcd_prepare_utp_scsi_cmd_upiu(struct scsi_cmnd *cmd, u8 upiu_flags) { struct ufshcd_lrb *lrbp = scsi_cmd_priv(cmd); + const int tag = scsi_cmd_to_rq(cmd)->tag; struct utp_upiu_req *ucd_req_ptr = lrbp->ucd_req_ptr; unsigned short cdb_len; @@ -2767,11 +2768,11 @@ static void ufshcd_prepare_utp_scsi_cmd_upiu(struct scsi_cmnd *cmd, .transaction_code = UPIU_TRANSACTION_COMMAND, .flags = upiu_flags, .lun = lrbp->lun, - .task_tag = lrbp->task_tag, + .task_tag = tag, .command_set_type = UPIU_COMMAND_SET_TYPE_SCSI, }; - WARN_ON_ONCE(ucd_req_ptr->header.task_tag != lrbp->task_tag); + WARN_ON_ONCE(ucd_req_ptr->header.task_tag != tag); ucd_req_ptr->sc.exp_data_transfer_len = cpu_to_be32(cmd->sdb.length); @@ -2791,6 +2792,8 @@ static void ufshcd_prepare_utp_query_req_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp, u8 upiu_flags) { struct utp_upiu_req *ucd_req_ptr = lrbp->ucd_req_ptr; + struct scsi_cmnd *cmd = (struct scsi_cmnd *)lrbp - 1; + const int tag = scsi_cmd_to_rq(cmd)->tag; struct ufs_query *query = &hba->dev_cmd.query; u16 len = be16_to_cpu(query->request.upiu_req.length); @@ -2799,7 +2802,7 @@ static void ufshcd_prepare_utp_query_req_upiu(struct ufs_hba *hba, .transaction_code = UPIU_TRANSACTION_QUERY_REQ, .flags = upiu_flags, .lun = lrbp->lun, - .task_tag = lrbp->task_tag, + .task_tag = tag, .query_function = query->request.query_func, /* Data segment length only need for WRITE_DESC */ .data_segment_length = @@ -2823,12 +2826,14 @@ static void ufshcd_prepare_utp_query_req_upiu(struct ufs_hba *hba, static inline void ufshcd_prepare_utp_nop_upiu(struct ufshcd_lrb *lrbp) { struct utp_upiu_req *ucd_req_ptr = lrbp->ucd_req_ptr; + struct scsi_cmnd *cmd = (struct scsi_cmnd *)lrbp - 1; + const int tag = scsi_cmd_to_rq(cmd)->tag; memset(ucd_req_ptr, 0, sizeof(struct utp_upiu_req)); ucd_req_ptr->header = (struct utp_upiu_header){ .transaction_code = UPIU_TRANSACTION_NOP_OUT, - .task_tag = lrbp->task_tag, + .task_tag = tag, }; memset(lrbp->ucd_rsp_ptr, 0, sizeof(struct utp_upiu_rsp)); @@ -2864,7 +2869,7 @@ static int ufshcd_compose_devman_upiu(struct ufs_hba *hba, * ufshcd_comp_scsi_upiu - UFS Protocol Information Unit(UPIU) * for SCSI Purposes * @hba: per adapter instance - * @lrbp: pointer to local reference block + * @cmd: SCSI command */ static void ufshcd_comp_scsi_upiu(struct ufs_hba *hba, struct scsi_cmnd *cmd) { @@ -2912,7 +2917,6 @@ static void __ufshcd_setup_cmd(struct ufs_hba *hba, struct scsi_cmnd *cmd, memset(lrbp->ucd_req_ptr, 0, sizeof(*lrbp->ucd_req_ptr)); - lrbp->task_tag = tag; lrbp->lun = lun; ufshcd_prepare_lrbp_crypto(cmd ? scsi_cmd_to_rq(cmd) : NULL, lrbp); } @@ -3203,6 +3207,8 @@ ufshcd_dev_cmd_completion(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) static int ufshcd_wait_for_dev_cmd(struct ufs_hba *hba, struct ufshcd_lrb *lrbp, int max_timeout) { + struct scsi_cmnd *cmd = (struct scsi_cmnd *)lrbp - 1; + const int tag = scsi_cmd_to_rq(cmd)->tag; unsigned long time_left = msecs_to_jiffies(max_timeout); unsigned long flags; bool pending; @@ -3219,18 +3225,18 @@ static int ufshcd_wait_for_dev_cmd(struct ufs_hba *hba, } else { err = -ETIMEDOUT; dev_dbg(hba->dev, "%s: dev_cmd request timedout, tag %d\n", - __func__, lrbp->task_tag); + __func__, tag); /* MCQ mode */ if (hba->mcq_enabled) { /* successfully cleared the command, retry if needed */ - if (ufshcd_clear_cmd(hba, lrbp->task_tag) == 0) + if (ufshcd_clear_cmd(hba, tag) == 0) err = -EAGAIN; return err; } /* SDB mode */ - if (ufshcd_clear_cmd(hba, lrbp->task_tag) == 0) { + if (ufshcd_clear_cmd(hba, tag) == 0) { /* successfully cleared the command, retry if needed */ err = -EAGAIN; /* @@ -3239,11 +3245,9 @@ static int ufshcd_wait_for_dev_cmd(struct ufs_hba *hba, * variable. */ spin_lock_irqsave(&hba->outstanding_lock, flags); - pending = test_bit(lrbp->task_tag, - &hba->outstanding_reqs); + pending = test_bit(tag, &hba->outstanding_reqs); if (pending) - __clear_bit(lrbp->task_tag, - &hba->outstanding_reqs); + __clear_bit(tag, &hba->outstanding_reqs); spin_unlock_irqrestore(&hba->outstanding_lock, flags); if (!pending) { @@ -3256,11 +3260,10 @@ static int ufshcd_wait_for_dev_cmd(struct ufs_hba *hba, } } else { dev_err(hba->dev, "%s: failed to clear tag %d\n", - __func__, lrbp->task_tag); + __func__, tag); spin_lock_irqsave(&hba->outstanding_lock, flags); - pending = test_bit(lrbp->task_tag, - &hba->outstanding_reqs); + pending = test_bit(tag, &hba->outstanding_reqs); spin_unlock_irqrestore(&hba->outstanding_lock, flags); if (!pending) { @@ -5384,6 +5387,7 @@ static inline int ufshcd_transfer_rsp_status(struct ufs_hba *hba, struct cq_entry *cqe) { struct ufshcd_lrb *lrbp = scsi_cmd_priv(cmd); + const int tag = scsi_cmd_to_rq(cmd)->tag; int result = 0; int scsi_status; enum utp_ocs ocs; @@ -5455,10 +5459,8 @@ static inline int ufshcd_transfer_rsp_status(struct ufs_hba *hba, case OCS_ABORTED: case OCS_INVALID_COMMAND_STATUS: result |= DID_REQUEUE << 16; - dev_warn(hba->dev, - "OCS %s from controller for tag %d\n", - (ocs == OCS_ABORTED ? "aborted" : "invalid"), - lrbp->task_tag); + dev_warn(hba->dev, "OCS %s from controller for tag %d\n", + ocs == OCS_ABORTED ? "aborted" : "invalid", tag); break; case OCS_INVALID_CMD_TABLE_ATTR: case OCS_INVALID_PRDT_ATTR: @@ -5471,9 +5473,8 @@ static inline int ufshcd_transfer_rsp_status(struct ufs_hba *hba, case OCS_GENERAL_CRYPTO_ERROR: default: result |= DID_ERROR << 16; - dev_err(hba->dev, - "OCS error from controller = %x for tag %d\n", - ocs, lrbp->task_tag); + dev_err(hba->dev, "OCS error from controller = %x for tag %d\n", + ocs, tag); ufshcd_print_evt_hist(hba); ufshcd_print_host_state(hba); break; @@ -7540,8 +7541,8 @@ int ufshcd_try_to_abort_task(struct ufs_hba *hba, int tag) u8 resp = 0xF; for (poll_cnt = 100; poll_cnt; poll_cnt--) { - err = ufshcd_issue_tm_cmd(hba, lrbp->lun, lrbp->task_tag, - UFS_QUERY_TASK, &resp); + err = ufshcd_issue_tm_cmd(hba, lrbp->lun, tag, UFS_QUERY_TASK, + &resp); if (!err && resp == UPIU_TASK_MANAGEMENT_FUNC_SUCCEEDED) { /* cmd pending in the device */ dev_err(hba->dev, "%s: cmd pending in the device. tag = %d\n", @@ -7574,8 +7575,7 @@ int ufshcd_try_to_abort_task(struct ufs_hba *hba, int tag) if (!poll_cnt) return -EBUSY; - err = ufshcd_issue_tm_cmd(hba, lrbp->lun, lrbp->task_tag, - UFS_ABORT_TASK, &resp); + err = ufshcd_issue_tm_cmd(hba, lrbp->lun, tag, UFS_ABORT_TASK, &resp); if (err || resp != UPIU_TASK_MANAGEMENT_FUNC_COMPL) { if (!err) { err = resp; /* service response error */ @@ -7685,7 +7685,7 @@ static int ufshcd_abort(struct scsi_cmnd *cmd) goto release; } - err = ufshcd_try_to_abort_task(hba, lrbp->task_tag); + err = ufshcd_try_to_abort_task(hba, tag); if (err) { dev_err(hba->dev, "%s: failed with err %d\n", __func__, err); ufshcd_set_req_abort_skip(hba, hba->outstanding_reqs); diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h index 3e7ee781b841..0e61d89e83ce 100644 --- a/include/ufs/ufshcd.h +++ b/include/ufs/ufshcd.h @@ -188,7 +188,6 @@ struct ufshcd_lrb { int scsi_status; int command_type; - int task_tag; u8 lun; /* UPIU LUN id field is only 8-bit wide */ bool intr_cmd; ktime_t issue_time_stamp;