Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp698072lqs; Tue, 5 Mar 2024 13:46:49 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXrNTmxLwYbQ3knyPhXTFrDv1aFs8sGzBgMNWP5DijeDal3H+/XJq9DZNl/SVxjtHadgEz4tzg2fYdrgBz8ra/rcYTnwuJJPXatcul8xg== X-Google-Smtp-Source: AGHT+IFKKYiIXYMNJYrJuqUV2y7rg3/isz2pcaVZ920+iUmV3S4NZ9KyBj5fTxQZpfItyUNZebrs X-Received: by 2002:a05:6e02:1a22:b0:365:ac7:30b8 with SMTP id g2-20020a056e021a2200b003650ac730b8mr16260989ile.29.1709675209135; Tue, 05 Mar 2024 13:46:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709675209; cv=pass; d=google.com; s=arc-20160816; b=juzqfMYfVoQLpTJ9L4ZJiQERBJBpb2D+NsS/NirOxhGZVllimCNLWlgZYwrRKNhKp5 Vdgb+zD8W9lLNisjTXrILWFjwegbcqqalcuPPaxgkp4uZuOqSCNRBV0L76JLGn8HSf+z +t36X9dnMPACaEpN5ipEcXym0Itkt4q4zz0ELCU97aiwsDHQEHRES4ujs0rXH9OqNE85 A0VniUovj9S7c1CAnxeHB0faN0j0Y+PEYloZZSPCsjYK9jqhf8lxE+XTTBxcHCT4AvnM BRP6BrrIePNhNvyEAsEQgnLLQk+ZLKmRYPmRyJVojAxiOZ2Ag2FdBz0zoiabeQn/AUdT JUFQ== 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:references:in-reply-to:message-id :date:subject:cc:to:from:wdcironportexception:ironport-sdr :ironport-sdr:dkim-signature; bh=zeTbQa0L1oDfqvnY519nkd/FmgLV4O55kdMvqmRiFn0=; fh=lbnuh9Va1UwcnWxZPbjQjN30xhVZh+Gs5sSzMLG81NY=; b=WOpKX5hkg62G2nc5jerS7HFBzD6vwExf44nJ4O2A3ajELxFqvwVonMnDfJtmDn1ljp rAr9iv7tWshseBNRdgQuQt0mqmiwn93n4nQhwb5BfPhdyH3dewWbJ76g+/uIR48Qm1RA lc1t4+t70C4mysHRPoU8fBt9650kJkIkLVAe1SElMsTCPdQQ0EobQwTX4lQxKL3zLkCd U7z6hawQJNRgv709dt79P7teTDeiA57VZWufWuYLu8dZFL2yYM63rMo1q4uF4KT7CcS8 6FXTCKHHFpFMLoTSqoI5l6dRgSOVA55TMFoPZhpupOfFj36o0XFCO4kCkJLbgc/44HFl iqGQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@wdc.com header.s=dkim.wdc.com header.b=nBRothHD; 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-92988-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-92988-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wdc.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 15-20020a63124f000000b005dcae4c1ff8si10295232pgs.131.2024.03.05.13.46.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 13:46:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-92988-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@wdc.com header.s=dkim.wdc.com header.b=nBRothHD; 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-92988-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-92988-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 06A40B2BBE8 for ; Tue, 5 Mar 2024 21:02:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CCA9712D206; Tue, 5 Mar 2024 21:01:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="nBRothHD" Received: from esa4.hgst.iphmx.com (esa4.hgst.iphmx.com [216.71.154.42]) (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 2B13F128817; Tue, 5 Mar 2024 21:01:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=216.71.154.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709672494; cv=none; b=P/Yp33yl2q4VT4zo7tDSYJeciurrMmkvprtWuzRFM2sg2hd6eqJRiukthL3ad6/cIx+HyIMzaAY1Kdz39K6gVYcyP+WEsoR4Hg6nTXVS+uLA9sLmwBuv48xzoxzM/FQABrytOmLxq+TuS2hJixoTwx82N3XTVS+GjSS99BLVsc8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709672494; c=relaxed/simple; bh=/P84ODUHYbGsYYgXUeXdf6QOlpEWyHv+gD90llRzItY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=l0v1IJ7Plli/3cIXA5U7MjZYKpccIwCwpp5Ha7hiqBLdenhKrL9a8Ylf3erdMuU8uMVYjCw8euTVTJiI5PAthXzhSk9fO+k3Eyvksbd8Z42hEVpNKxclThH4Ljkh24uCWvXbhKbxQVq0yCnqRwC0YzcOSWAN467zqWcp2kDFJ9M= 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=nBRothHD; arc=none smtp.client-ip=216.71.154.42 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=1709672492; x=1741208492; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/P84ODUHYbGsYYgXUeXdf6QOlpEWyHv+gD90llRzItY=; b=nBRothHD3ZrnaBDZgSapBdSvlU3N45bpjIlK4nT+CMTGqWO2DDd6Nelh gnKmtwzLEwMIoQfEhbghJMhp9xEmXsaITYK+i3Urq1lpAyCiHc2N5wYfw 82oqEe0lZxN9dab5Vmh1aLcqX/GFSypslOF03KmnIfL4hyRSICj9yiknv 6CPtF/LKuQnki82+tWgPsY8LSBvOt/KTvxD8hlxkJz0HinT+ubvfrtlti pO/nE0GrO92wxwEBFJ+YmrojinXsrN1VjV5HMHkf0f1ZytbMevWT4hLYB h20ukYmokqHUKhP4O8VWuRPc6ZsW2tFzlbDD4Hd/jAW6vjd352FnzEJOQ A==; X-CSE-ConnectionGUID: OTGbBJByQX6LfY7+1NEmkQ== X-CSE-MsgGUID: NdPADZwQQ1SOro07xyav2Q== X-IronPort-AV: E=Sophos;i="6.06,206,1705334400"; d="scan'208";a="10423325" 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; 06 Mar 2024 05:01:30 +0800 IronPort-SDR: dGlA6gGgWuCI7l69K8d1mtYIufSHy8dIbSPK5DOv8P7RntsEd2vvP4EfjiFX5OZllWlWS/bBFb Xiru63z7GcHQ== Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 05 Mar 2024 12:10:40 -0800 IronPort-SDR: gNX+rEGkrn/kOQ89Qga37f+D+SkgseS5wSxKjBs90yqq8MhiyrIhFoEq3OaFOM5h9WwmGiXaDP qGjEOVzqaK3Q== WDCIronportException: Internal Received: from 87h6l33.ad.shared (HELO BXYGM33.ad.shared) ([10.225.32.8]) by uls-op-cesaip01.wdc.com with ESMTP; 05 Mar 2024 13:01:28 -0800 From: Avri Altman To: "James E . J . Bottomley" , "Martin K . Petersen" Cc: Bart Van Assche , Bean Huo , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Avri Altman Subject: [PATCH v2 3/4] scsi: ufs: Re-use compose_dev_cmd Date: Tue, 5 Mar 2024 23:00:48 +0200 Message-ID: <20240305210051.10847-4-avri.altman@wdc.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240305210051.10847-1-avri.altman@wdc.com> References: <20240305210051.10847-1-avri.altman@wdc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Move out some of the dev_cmd initializations so it can be used elsewhere. Signed-off-by: Avri Altman --- drivers/ufs/core/ufshcd.c | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 3f62ad7b4062..c9c2b7f99758 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -3061,15 +3061,21 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) return err; } -static int ufshcd_compose_dev_cmd(struct ufs_hba *hba, - struct ufshcd_lrb *lrbp, enum dev_cmd_type cmd_type, int tag) +static void ufshcd_setup_dev_cmd(struct ufs_hba *hba, struct ufshcd_lrb *lrbp, + enum dev_cmd_type cmd_type, u8 lun, int tag) { lrbp->cmd = NULL; lrbp->task_tag = tag; - lrbp->lun = 0; /* device management cmd is not specific to any LUN */ + lrbp->lun = lun; lrbp->intr_cmd = true; /* No interrupt aggregation */ ufshcd_prepare_lrbp_crypto(NULL, lrbp); hba->dev_cmd.type = cmd_type; +} + +static int ufshcd_compose_dev_cmd(struct ufs_hba *hba, + struct ufshcd_lrb *lrbp, enum dev_cmd_type cmd_type, int tag) +{ + ufshcd_setup_dev_cmd(hba, lrbp, cmd_type, 0, tag); return ufshcd_compose_devman_upiu(hba, lrbp); } @@ -7213,20 +7219,14 @@ static int ufshcd_issue_devman_upiu_cmd(struct ufs_hba *hba, enum query_opcode desc_op) { const u32 tag = hba->reserved_slot; - struct ufshcd_lrb *lrbp; + struct ufshcd_lrb *lrbp = &hba->lrb[tag]; int err = 0; u8 upiu_flags; /* Protects use of hba->reserved_slot. */ lockdep_assert_held(&hba->dev_cmd.lock); - lrbp = &hba->lrb[tag]; - lrbp->cmd = NULL; - lrbp->task_tag = tag; - lrbp->lun = 0; - lrbp->intr_cmd = true; - ufshcd_prepare_lrbp_crypto(NULL, lrbp); - hba->dev_cmd.type = cmd_type; + ufshcd_setup_dev_cmd(hba, lrbp, cmd_type, 0, tag); if (hba->ufs_version <= ufshci_version(1, 1)) lrbp->command_type = UTP_CMD_TYPE_DEV_MANAGE; @@ -7372,7 +7372,7 @@ int ufshcd_advanced_rpmb_req_handler(struct ufs_hba *hba, struct utp_upiu_req *r enum dma_data_direction dir) { const u32 tag = hba->reserved_slot; - struct ufshcd_lrb *lrbp; + struct ufshcd_lrb *lrbp = &hba->lrb[tag]; int err = 0; int result; u8 upiu_flags; @@ -7382,14 +7382,7 @@ int ufshcd_advanced_rpmb_req_handler(struct ufs_hba *hba, struct utp_upiu_req *r /* Protects use of hba->reserved_slot. */ ufshcd_dev_man_lock(hba); - lrbp = &hba->lrb[tag]; - lrbp->cmd = NULL; - lrbp->task_tag = tag; - lrbp->lun = UFS_UPIU_RPMB_WLUN; - - lrbp->intr_cmd = true; - ufshcd_prepare_lrbp_crypto(NULL, lrbp); - hba->dev_cmd.type = DEV_CMD_TYPE_RPMB; + ufshcd_setup_dev_cmd(hba, lrbp, DEV_CMD_TYPE_RPMB, UFS_UPIU_RPMB_WLUN, tag); /* Advanced RPMB starts from UFS 4.0, so its command type is UTP_CMD_TYPE_UFS_STORAGE */ lrbp->command_type = UTP_CMD_TYPE_UFS_STORAGE; -- 2.42.0