From patchwork Mon Sep 3 10:33:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avri Altman X-Patchwork-Id: 10585747 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 B30DE16B1 for ; Mon, 3 Sep 2018 10:34:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A2AC928417 for ; Mon, 3 Sep 2018 10:34:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9671029580; Mon, 3 Sep 2018 10:34:39 +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 3795D28417 for ; Mon, 3 Sep 2018 10:34:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726160AbeICOyL (ORCPT ); Mon, 3 Sep 2018 10:54:11 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:12524 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726153AbeICOyL (ORCPT ); Mon, 3 Sep 2018 10:54:11 -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=1535970878; x=1567506878; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=nSsH9LIq/OUFlw5q2Ou2KZ1ZKZ3a2EcKy2577WwjVmY=; b=nZXgbdJos4oHKZIHpcKrE+bz0+kHuGZZxP/k4l29WB5nX7Vur8pu4Zow 0vh1P/pAQyKg0CEK5S+pBOC/W0iNBATy6qZPMqAkG+TWZ06AZRMkNF0ds A2OKnz5SY6zKOGTj2VeryKJHS+Hrjmb69xm5UKKPqkjKs0nIvCUC3+0a1 y17SrBvc6uBdX0eWQPIIUd1BBaLADy82n7c/Y4GEBPNYoHPt7eKE6Hs9C AXXnoN7e0Goomw3B9anpf7n3wbReWiNN4Qx92GIIe8FyGD9qiMZLgteGq iVmom5fmFr8T/qJO46f8b64SM5NTKalr4F0924ixVIag4UgABvC1St6AF Q==; X-IronPort-AV: E=Sophos;i="5.53,324,1531756800"; d="scan'208";a="89873743" 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; 03 Sep 2018 18:34:25 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP; 03 Sep 2018 03:21:16 -0700 Received: from kfae422988.sdcorp.global.sandisk.com ([10.0.231.37]) by uls-op-cesaip02.wdc.com with ESMTP; 03 Sep 2018 03:34:22 -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 v3 3/7] scsi: ufs: Add fill task management request Date: Mon, 3 Sep 2018 13:33:12 +0300 Message-Id: <1535970796-25582-4-git-send-email-avri.altman@wdc.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1535970796-25582-1-git-send-email-avri.altman@wdc.com> References: <1535970796-25582-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 preparation to re-use ufshcd_issue_tm_cmd code. Signed-off-by: Avri Altman Signed-off-by: Christoph Hellwig --- drivers/scsi/ufs/ufshcd.c | 50 +++++++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index ed37914..d18832a 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -5598,6 +5598,32 @@ static int ufshcd_clear_tm_cmd(struct ufs_hba *hba, int tag) return err; } +static void ufshcd_fill_tm_req(struct utp_task_req_desc *task_req_descp, + int lun_id, int task_id, u8 tm_function, + int task_tag) +{ + struct utp_upiu_task_req *task_req_upiup; + + /* Configure task request descriptor */ + task_req_descp->header.dword_0 = cpu_to_le32(UTP_REQ_DESC_INT_CMD); + task_req_descp->header.dword_2 = + cpu_to_le32(OCS_INVALID_COMMAND_STATUS); + + task_req_upiup = + (struct utp_upiu_task_req *)task_req_descp->task_req_upiu; + task_req_upiup->header.dword_0 = + UPIU_HEADER_DWORD(UPIU_TRANSACTION_TASK_REQ, 0, lun_id, + task_tag); + task_req_upiup->header.dword_1 = UPIU_HEADER_DWORD(0, tm_function, 0, + 0); + /* + * The host shall provide the same value for LUN field in the basic + * header and for Input Parameter. + */ + task_req_upiup->input_param1 = cpu_to_be32(lun_id); + task_req_upiup->input_param2 = cpu_to_be32(task_id); +} + /** * ufshcd_issue_tm_cmd - issues task management commands to controller * @hba: per adapter instance @@ -5612,7 +5638,6 @@ static int ufshcd_issue_tm_cmd(struct ufs_hba *hba, int lun_id, int task_id, u8 tm_function, u8 *tm_response) { struct utp_task_req_desc *task_req_descp; - struct utp_upiu_task_req *task_req_upiup; struct Scsi_Host *host; unsigned long flags; int free_slot; @@ -5632,27 +5657,10 @@ static int ufshcd_issue_tm_cmd(struct ufs_hba *hba, int lun_id, int task_id, spin_lock_irqsave(host->host_lock, flags); task_req_descp = hba->utmrdl_base_addr; task_req_descp += free_slot; - - /* Configure task request descriptor */ - task_req_descp->header.dword_0 = cpu_to_le32(UTP_REQ_DESC_INT_CMD); - task_req_descp->header.dword_2 = - cpu_to_le32(OCS_INVALID_COMMAND_STATUS); - - /* Configure task request UPIU */ - task_req_upiup = - (struct utp_upiu_task_req *) task_req_descp->task_req_upiu; task_tag = hba->nutrs + free_slot; - task_req_upiup->header.dword_0 = - UPIU_HEADER_DWORD(UPIU_TRANSACTION_TASK_REQ, 0, - lun_id, task_tag); - task_req_upiup->header.dword_1 = - UPIU_HEADER_DWORD(0, tm_function, 0, 0); - /* - * The host shall provide the same value for LUN field in the basic - * header and for Input Parameter. - */ - task_req_upiup->input_param1 = cpu_to_be32(lun_id); - task_req_upiup->input_param2 = cpu_to_be32(task_id); + + ufshcd_fill_tm_req(task_req_descp, lun_id, task_id, tm_function, + task_tag); ufshcd_vops_setup_task_mgmt(hba, free_slot, tm_function);