Received: by 2002:ab2:5d18:0:b0:1ef:7a0f:c32d with SMTP id j24csp61351lqk; Sat, 9 Mar 2024 00:11:44 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWSQAPN9iNZM5CONoDfRMpECU7gREE2diwp7NhBD2vCraBSW7nlyuJ25HZ3StX1hV8BhjE41eVGakX7LMPrNHzqPrEZuuPal1dFdTea7Q== X-Google-Smtp-Source: AGHT+IF1p5MemG03ILt7ND78ft2j2p0IPkBl/x1z249hDf7yg0IIPsg/jXuJUJXotWTI9bjXDVqT X-Received: by 2002:a05:6214:7f0:b0:690:b99a:22b2 with SMTP id bp16-20020a05621407f000b00690b99a22b2mr1237902qvb.44.1709971903884; Sat, 09 Mar 2024 00:11:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709971903; cv=pass; d=google.com; s=arc-20160816; b=z5H6epFxYgAx6ZeIUWtvar6OiMwNRQyiFXqzoVms/iDgguHOV1DM0XPDnl5rGUtZrD n7VJh7aDzMRVGHpcQJ9iNfOL2O0AGhl+MoI7GT8E1nwsRivXCrIYwlmh8cTqsORb/gzf t3qeh9+k0q3WJVCE64IlVFIr+4oo2+wfOquoTvbSj4sraivoMmoEeUDhD5iW0RAGXjIf Lw3NXuRadX73+tQsXB6tISDBzZ++tycNp2k6RrM/aeYg2NxgpI4XHNkVWRk0Li7Mu1oC zdIQlf1RzwiL2F0RyywSCkbjN0hSpxmTSmIqzHOmnvlW3Wl5jO2pRvEofARZEXZyGBfi cCiA== 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=8A3V1L7ibAKd6VNulokVlQ/qmH5zKRpQ0wYUTkXEBV0=; fh=M/KanMlWJ9O2I0hMJPl483UULCHuHOYUPdaxVvdB79E=; b=TP2icR7iTPKMGJU+CKBf+lEK06qSnYlX+++E0j4hR3aqbwywUla6ZicD+GJdRVyeBo eAq5sCv4JJIw8IhNxJaSNrwEQFkp74dyGfEpQhNKWzQK85CSQ+bq9P1TC2IBzfJzpCdY Dpx8pvpnqfj8FhM3/iJ7Z8pJXeTLlvdmAq4aNR4GxPdjFdaNQV48D2fwoXn6z+ly/NjZ 7w83gV+uNLaOX73GgPd0eA5JAiWAxQRQmgh1y7lUuuxJTU2QrIAh0CngdBlhXjqqgARq m1UabXL2bxKwHHvBWNYco/NzA0RsDxrBRwhiHUwK8r0MrN9bJLOD41719/bmiuh8rHDu tNSw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@wdc.com header.s=dkim.wdc.com header.b=FifV0NRB; 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-97802-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-97802-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wdc.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id on12-20020a056214448c00b0068fa7211a44si1254872qvb.3.2024.03.09.00.11.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Mar 2024 00:11:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-97802-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@wdc.com header.s=dkim.wdc.com header.b=FifV0NRB; 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-97802-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-97802-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 8E5721C20C46 for ; Sat, 9 Mar 2024 08:11:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D364D381C5; Sat, 9 Mar 2024 08:11:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="FifV0NRB" Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) (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 ECA9D374F1; Sat, 9 Mar 2024 08:11:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=216.71.154.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709971881; cv=none; b=kAm4uju4Zwad+oaToZNZXINTDprNNMPGj5+SpU+XtdDDCOOcdQTwyQdUaWMoaQeYz+8VIfgWy4sSEMks3gQjeT9FSXKnlJVZCWjy7vBapqOT3h+SSe5gWg8cyIR1kdwtzvMLrkmqeza/He6a/umPTWuOQscTemzcURtkRXBQ8vU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709971881; c=relaxed/simple; bh=6JXRE9xbaYXSjjEh7IsdvBn1gHR+jrWYYNpXb7YHIck=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HsX0KKSRMecdIJMnNpEZ7kPJA77iZg7ylNMPIROPuAhfreu+8l41CizviY0icBhyEzrUYE+Ihc494rSFz/6cdy+Fv6vxm4hC+I9e+EyOASz2kOEJTPLh/tuaL11SBC/ukxAvU8gHpb2u22N6vttX5UyKua42s+uYdzEKv5aDxdI= 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=FifV0NRB; arc=none smtp.client-ip=216.71.154.45 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=1709971878; x=1741507878; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6JXRE9xbaYXSjjEh7IsdvBn1gHR+jrWYYNpXb7YHIck=; b=FifV0NRB8rzjVisE/KjDM0afLHpOQelhcoyqh5X5OOxxeB4HHwVSeggB Ex7cjQlFrFftaImUztNMurbSk6GCTjzU+8Cjuj/dgmHdkJPey2rHNEz3T CZyIgsf4sbzczTcMzSeVm6bxOxgfsIQiS72OWpJqJ4JMvHyEyi+qqTayh 5wwhKKN1gkWSIp5qhgNopseew34/cGuzdG+LOROndwVCCPsO2dbDoIlQh zIvTGGJZFOjwoGds4LoTlH1K7eaf0mTnPEXIoy5puybUuMNZp52UrgXiR tvsPB+cy+oVNurCBw4Cu9/bLDQ9aVdsWHQ8n35dC4eNT/jtch43LNv6XZ Q==; X-CSE-ConnectionGUID: I35hU2XKT8S/38c6/6JT5g== X-CSE-MsgGUID: EGagtkWMQ82YHnaASo2wUA== X-IronPort-AV: E=Sophos;i="6.07,112,1708358400"; d="scan'208";a="11183736" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 09 Mar 2024 16:11:18 +0800 IronPort-SDR: RyDHBkH088TWClGZpulTfTM208VBnFBtIB92fDWfHwlH/RZZNMd8zndXmD95N+3LIsbmHC6ds7 lfSSlFim1GIA== Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 08 Mar 2024 23:14:44 -0800 IronPort-SDR: s5T08JdhM9MormO4Sj/Sfs1ijBeJa+KLDOaw2WzQUou5ELBWClVkVKrpkHOqdgsxS531iettHi NBnmFuSFkUWg== WDCIronportException: Internal Received: from 87h6l33.ad.shared (HELO BXYGM33.ad.shared) ([10.225.32.8]) by uls-op-cesaip01.wdc.com with ESMTP; 09 Mar 2024 00:11:17 -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 v3 2/4] scsi: ufs: Re-use exec_dev_cmd Date: Sat, 9 Mar 2024 10:11:00 +0200 Message-ID: <20240309081104.5006-3-avri.altman@wdc.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240309081104.5006-1-avri.altman@wdc.com> References: <20240309081104.5006-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 the actual command issue from exec_dev_cmd so it can be used elsewhere. While at it, remove a redundant "lrbp->cmd = NULL" assignment. Also, the device management commands that are originated from the ufs-bsg code path, are being traced now, which wasn't the case before. Signed-off-by: Avri Altman --- drivers/ufs/core/ufshcd.c | 53 ++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 983b7b8e3c7c..3f62ad7b4062 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -3286,6 +3286,25 @@ static void ufshcd_dev_man_unlock(struct ufs_hba *hba) ufshcd_release(hba); } +static int ufshcd_issue_dev_cmd(struct ufs_hba *hba, struct ufshcd_lrb *lrbp, + const u32 tag, int timeout) +{ + DECLARE_COMPLETION_ONSTACK(wait); + int err; + + hba->dev_cmd.complete = &wait; + + ufshcd_add_query_upiu_trace(hba, UFS_QUERY_SEND, lrbp->ucd_req_ptr); + + ufshcd_send_command(hba, tag, hba->dev_cmd_queue); + err = ufshcd_wait_for_dev_cmd(hba, lrbp, timeout); + + ufshcd_add_query_upiu_trace(hba, err ? UFS_QUERY_ERR : UFS_QUERY_COMP, + (struct utp_upiu_req *)lrbp->ucd_rsp_ptr); + + return err; +} + /** * ufshcd_exec_dev_cmd - API for sending device management requests * @hba: UFS hba @@ -3300,31 +3319,18 @@ static void ufshcd_dev_man_unlock(struct ufs_hba *hba) static int ufshcd_exec_dev_cmd(struct ufs_hba *hba, enum dev_cmd_type cmd_type, int timeout) { - DECLARE_COMPLETION_ONSTACK(wait); const u32 tag = hba->reserved_slot; - struct ufshcd_lrb *lrbp; + struct ufshcd_lrb *lrbp = &hba->lrb[tag]; int err; /* Protects use of hba->reserved_slot. */ lockdep_assert_held(&hba->dev_cmd.lock); - lrbp = &hba->lrb[tag]; - lrbp->cmd = NULL; err = ufshcd_compose_dev_cmd(hba, lrbp, cmd_type, tag); if (unlikely(err)) - goto out; - - hba->dev_cmd.complete = &wait; - - ufshcd_add_query_upiu_trace(hba, UFS_QUERY_SEND, lrbp->ucd_req_ptr); - - ufshcd_send_command(hba, tag, hba->dev_cmd_queue); - err = ufshcd_wait_for_dev_cmd(hba, lrbp, timeout); - ufshcd_add_query_upiu_trace(hba, err ? UFS_QUERY_ERR : UFS_QUERY_COMP, - (struct utp_upiu_req *)lrbp->ucd_rsp_ptr); + return err; -out: - return err; + return ufshcd_issue_dev_cmd(hba, lrbp, tag, timeout); } /** @@ -7206,7 +7212,6 @@ static int ufshcd_issue_devman_upiu_cmd(struct ufs_hba *hba, enum dev_cmd_type cmd_type, enum query_opcode desc_op) { - DECLARE_COMPLETION_ONSTACK(wait); const u32 tag = hba->reserved_slot; struct ufshcd_lrb *lrbp; int err = 0; @@ -7246,17 +7251,12 @@ static int ufshcd_issue_devman_upiu_cmd(struct ufs_hba *hba, memset(lrbp->ucd_rsp_ptr, 0, sizeof(struct utp_upiu_rsp)); - hba->dev_cmd.complete = &wait; - - ufshcd_add_query_upiu_trace(hba, UFS_QUERY_SEND, lrbp->ucd_req_ptr); - - ufshcd_send_command(hba, tag, hba->dev_cmd_queue); /* * ignore the returning value here - ufshcd_check_query_response is * bound to fail since dev_cmd.query and dev_cmd.type were left empty. * read the response directly ignoring all errors. */ - ufshcd_wait_for_dev_cmd(hba, lrbp, QUERY_REQ_TIMEOUT); + ufshcd_issue_dev_cmd(hba, lrbp, tag, QUERY_REQ_TIMEOUT); /* just copy the upiu response as it is */ memcpy(rsp_upiu, lrbp->ucd_rsp_ptr, sizeof(*rsp_upiu)); @@ -7371,7 +7371,6 @@ int ufshcd_advanced_rpmb_req_handler(struct ufs_hba *hba, struct utp_upiu_req *r struct ufs_ehs *rsp_ehs, int sg_cnt, struct scatterlist *sg_list, enum dma_data_direction dir) { - DECLARE_COMPLETION_ONSTACK(wait); const u32 tag = hba->reserved_slot; struct ufshcd_lrb *lrbp; int err = 0; @@ -7418,11 +7417,7 @@ int ufshcd_advanced_rpmb_req_handler(struct ufs_hba *hba, struct utp_upiu_req *r memset(lrbp->ucd_rsp_ptr, 0, sizeof(struct utp_upiu_rsp)); - hba->dev_cmd.complete = &wait; - - ufshcd_send_command(hba, tag, hba->dev_cmd_queue); - - err = ufshcd_wait_for_dev_cmd(hba, lrbp, ADVANCED_RPMB_REQ_TIMEOUT); + err = ufshcd_issue_dev_cmd(hba, lrbp, tag, ADVANCED_RPMB_REQ_TIMEOUT); if (!err) { /* Just copy the upiu response as it is */ -- 2.42.0