From patchwork Sun Aug 5 11:39:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avri Altman X-Patchwork-Id: 10556123 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AFCD4157B for ; Sun, 5 Aug 2018 11:41:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9D24B2991F for ; Sun, 5 Aug 2018 11:41:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F36F2993B; Sun, 5 Aug 2018 11:41:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 257E62991F for ; Sun, 5 Aug 2018 11:41:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726180AbeHENpd (ORCPT ); Sun, 5 Aug 2018 09:45:33 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:4547 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726091AbeHENpc (ORCPT ); Sun, 5 Aug 2018 09:45:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1533469275; x=1565005275; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=KaEkKc7fCZERQBUQRMM1HKSJz0h6nEFOo7T73MJtbrU=; b=ZsffqbAEb9xfpvq5MCEFkBX2n1xsWqoaxmNrs3oLPukQwEOo/sKZHwdL e0cx0w2KDTLLSvU7CS252tFjcKxfh3wDERCD3ZG7u8j8N6tco7Ph/jMqd 505ZVkv1lQV78cbrbmQd6xzcW2eSMryly37/1RIDHDFHDmQyj8JEJMOkT cgjzQSsxyf5SvIHDZCPoXZHooE/SGBuIy3nx5WSDrWC1QSUN9jPFwxxti dqzVq/MSzDgHIZi4OFe8L1prfY0fMcBa4cAlp/6W0JJzmYjyhnO4Jpmoi puhpfyMrZaqyYoMdxpD5V+Y3DXB8nR/Dl5Jln9wvCO3ie+2NAw+u2fFE4 A==; X-IronPort-AV: E=Sophos;i="5.51,447,1526313600"; d="scan'208";a="86611446" 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; 05 Aug 2018 19:41:15 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP; 05 Aug 2018 04:29:33 -0700 Received: from kfae422988.sdcorp.global.sandisk.com ([10.0.231.37]) by uls-op-cesaip02.wdc.com with ESMTP; 05 Aug 2018 04:41:12 -0700 From: Avri Altman To: Christoph Hellwig , Johannes Thumshirn , Hannes Reinecke , Bart Van Assche , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org Cc: Stanislav Nijnikov , Avi Shchislowski , Alex Lemberg , Subhash Jadavani , Vinayak Holikatti , Avri Altman Subject: [PATCH v2 5/8] scsi: ufs: Allow ufshcd_issue_tm_cmd accept raw task upius Date: Sun, 5 Aug 2018 14:39:53 +0300 Message-Id: <1533469196-300-6-git-send-email-avri.altman@wdc.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1533469196-300-1-git-send-email-avri.altman@wdc.com> References: <1533469196-300-1-git-send-email-avri.altman@wdc.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Do that in order to re-use its code if the task request and response UPIUs are given externally. Signed-off-by: Avri Altman --- drivers/scsi/ufs/ufshcd.c | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 4206bab..2df87e0 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -5598,6 +5598,7 @@ static int ufshcd_clear_tm_cmd(struct ufs_hba *hba, int tag) } static void ufshcd_fill_tm_req(struct utp_task_req_desc *task_req_descp, + struct utp_upiu_task_req *raw_task_req_upiup, int lun_id, int task_id, u8 tm_function, int task_tag) { @@ -5608,6 +5609,13 @@ static void ufshcd_fill_tm_req(struct utp_task_req_desc *task_req_descp, task_req_descp->header.dword_2 = cpu_to_le32(OCS_INVALID_COMMAND_STATUS); + if (raw_task_req_upiup) { + raw_task_req_upiup->header.dword_0 |= cpu_to_be32(task_tag); + memcpy(task_req_descp->task_req_upiu, raw_task_req_upiup, + GENERAL_UPIU_REQUEST_SIZE); + return; + } + task_req_upiup = (struct utp_upiu_task_req *)task_req_descp->task_req_upiu; task_req_upiup->header.dword_0 = @@ -5633,8 +5641,11 @@ static void ufshcd_fill_tm_req(struct utp_task_req_desc *task_req_descp, * * Returns non-zero value on error, zero on success. */ -static int ufshcd_issue_tm_cmd(struct ufs_hba *hba, int lun_id, int task_id, - u8 tm_function, u8 *tm_response) +static int ufshcd_issue_tm_cmd(struct ufs_hba *hba, + struct utp_upiu_task_req *raw_task_req_upiup, + struct utp_upiu_task_req *raw_task_rsp_upiup, + int lun_id, int task_id, u8 tm_function, + u8 *tm_response) { struct utp_task_req_desc *task_req_descp; struct Scsi_Host *host; @@ -5658,8 +5669,8 @@ static int ufshcd_issue_tm_cmd(struct ufs_hba *hba, int lun_id, int task_id, task_req_descp += free_slot; task_tag = hba->nutrs + free_slot; - ufshcd_fill_tm_req(task_req_descp, lun_id, task_id, tm_function, - task_tag); + ufshcd_fill_tm_req(task_req_descp, raw_task_req_upiup, lun_id, task_id, + tm_function, task_tag); ufshcd_vops_setup_task_mgmt(hba, free_slot, tm_function); @@ -5691,6 +5702,10 @@ static int ufshcd_issue_tm_cmd(struct ufs_hba *hba, int lun_id, int task_id, err = -ETIMEDOUT; } else { err = ufshcd_task_req_compl(hba, free_slot, tm_response); + if (raw_task_rsp_upiup) + memcpy(raw_task_rsp_upiup, + task_req_descp->task_rsp_upiu, + GENERAL_UPIU_REQUEST_SIZE); ufshcd_add_tm_upiu_trace(hba, task_tag, "tm_complete"); } @@ -5725,7 +5740,8 @@ static int ufshcd_eh_device_reset_handler(struct scsi_cmnd *cmd) tag = cmd->request->tag; lrbp = &hba->lrb[tag]; - err = ufshcd_issue_tm_cmd(hba, lrbp->lun, 0, UFS_LOGICAL_RESET, &resp); + err = ufshcd_issue_tm_cmd(hba, NULL, NULL, lrbp->lun, 0, + UFS_LOGICAL_RESET, &resp); if (err || resp != UPIU_TASK_MANAGEMENT_FUNC_COMPL) { if (!err) err = resp; @@ -5855,8 +5871,9 @@ static int ufshcd_abort(struct scsi_cmnd *cmd) } 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, NULL, NULL, lrbp->lun, + lrbp->task_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", @@ -5894,8 +5911,8 @@ static int ufshcd_abort(struct scsi_cmnd *cmd) goto out; } - err = ufshcd_issue_tm_cmd(hba, lrbp->lun, lrbp->task_tag, - UFS_ABORT_TASK, &resp); + err = ufshcd_issue_tm_cmd(hba, NULL, NULL, lrbp->lun, lrbp->task_tag, + UFS_ABORT_TASK, &resp); if (err || resp != UPIU_TASK_MANAGEMENT_FUNC_COMPL) { if (!err) { err = resp; /* service response error */