Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp829761imw; Thu, 14 Jul 2022 11:32:48 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sBEDOw/zg2B7h1BuTwdTNjOI63g2hjBUT6Oq0Nv7SDDdM71IrBi+2lMQLtOhZvIio7+e4H X-Received: by 2002:a17:906:6a2a:b0:72c:e324:9844 with SMTP id qw42-20020a1709066a2a00b0072ce3249844mr8166039ejc.303.1657823567971; Thu, 14 Jul 2022 11:32:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657823567; cv=none; d=google.com; s=arc-20160816; b=qOyROyCakbuytWFXC8hs3bcEnukzhykR2pnodphymqVyi0rhOetrYXBYuQBYiPR7zJ 9k2KWeiZBOUAIJpCKNocddye1WWwecloz1P54tBJzd689h4TgEJnmxlNAnwNfSPSaMmI TS69bIsEGEf0ipXzmcZ2T/ajzA3sKKSRiL8pR4mA2ZguBzvxpf64hnDJHrhQVGWhq5wP XGORm9GeudttBTdtwOL9catyNc8q9N5h4tQ7TEuU7aJZuUqtcjB3ea4zG6MIaO3OKE+z qwNZYSPXLimP3pOMTgRKpnKlQ+u9OF2lIhmFtZhpFy452UGHFjx2GBCvcsmbGc88IHqB XY2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=0/7zqrxKNolGyKiMX9ExpdecRPmm08glxYm7oPmonsE=; b=n4ADrTBu/wNtDdB6Kz0XYy/9Vpi6Sjy4sZIkCMMeaUOW+WIBt2GulkjO4uWBJ/QfTh XHmn5dDRhzcuI98VlYliMY/+5zaZxDZDkmp0r/spTOKf4bbZ2QBBgRi6vBGzTHareUk3 OmfnMnHGYvlKEX3y+zTgyoStJsZEpBKRQgDQoBjMYAA6KGe0F8x6NyDoGz00ypEmQe05 KKRq/fk3RiffJDTDLeoNs+c3ivopVgdyTp9fKLUSk2GR/0wuN1zorR6Wy638hZ68haBn uWltP7gTAZ3JDq/is9Ih2fAiANfIvCwSv09B8a8dE9MksHlZWSDrK3sQHm2zCunDrrLR ibnw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ne35-20020a1709077ba300b006febfa8bf0asi3385186ejc.509.2022.07.14.11.32.22; Thu, 14 Jul 2022 11:32:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240690AbiGNS3z (ORCPT + 99 others); Thu, 14 Jul 2022 14:29:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240674AbiGNS3v (ORCPT ); Thu, 14 Jul 2022 14:29:51 -0400 Received: from sinmsgout03.his.huawei.com (sinmsgout03.his.huawei.com [119.8.177.38]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53B206A9F2; Thu, 14 Jul 2022 11:29:50 -0700 (PDT) Received: from fraeml734-chm.china.huawei.com (unknown [172.18.156.148]) by sinmsgout03.his.huawei.com (SkyGuard) with ESMTP id 4LkNKg6n9kz9v79V; Fri, 15 Jul 2022 02:28:39 +0800 (CST) Received: from lhreml724-chm.china.huawei.com (10.201.108.75) by fraeml734-chm.china.huawei.com (10.206.15.215) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 14 Jul 2022 20:29:44 +0200 Received: from localhost.localdomain (10.69.192.58) by lhreml724-chm.china.huawei.com (10.201.108.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 14 Jul 2022 19:29:41 +0100 From: John Garry To: , CC: , , , Xiang Chen , John Garry Subject: [PATCH 2/5] scsi: hisi_sas: Remove unnecessary variable to hold DMA map elements Date: Fri, 15 Jul 2022 02:23:19 +0800 Message-ID: <1657823002-139010-3-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1657823002-139010-1-git-send-email-john.garry@huawei.com> References: <1657823002-139010-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.58] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To lhreml724-chm.china.huawei.com (10.201.108.75) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xiang Chen Use slot->n_elem to store the return value of dma_map_sg() for SSP and SMP IOs, and remove unnecessary variable n_elem_req. Signed-off-by: Xiang Chen Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_main.c | 43 +++++++++++---------------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 764e859d0106..bd62e441f947 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -220,9 +220,10 @@ void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba, struct sas_task *task, if (!sas_protocol_ata(task->task_proto)) { if (slot->n_elem) - dma_unmap_sg(dev, task->scatter, - task->num_scatter, - task->data_dir); + if (task->task_proto & SAS_PROTOCOL_SSP) + dma_unmap_sg(dev, task->scatter, + task->num_scatter, + task->data_dir); if (slot->n_elem_dif) { struct sas_ssp_task *ssp_task = &task->ssp_task; struct scsi_cmnd *scsi_cmnd = ssp_task->cmd; @@ -269,28 +270,23 @@ static void hisi_sas_task_prep_abort(struct hisi_hba *hisi_hba, } static void hisi_sas_dma_unmap(struct hisi_hba *hisi_hba, - struct sas_task *task, int n_elem, - int n_elem_req) + struct sas_task *task, int n_elem) { struct device *dev = hisi_hba->dev; - if (!sas_protocol_ata(task->task_proto)) { + if (!sas_protocol_ata(task->task_proto) && n_elem) { if (task->num_scatter) { - if (n_elem) - dma_unmap_sg(dev, task->scatter, - task->num_scatter, - task->data_dir); + dma_unmap_sg(dev, task->scatter, task->num_scatter, + task->data_dir); } else if (task->task_proto & SAS_PROTOCOL_SMP) { - if (n_elem_req) - dma_unmap_sg(dev, &task->smp_task.smp_req, - 1, DMA_TO_DEVICE); + dma_unmap_sg(dev, &task->smp_task.smp_req, + 1, DMA_TO_DEVICE); } } } static int hisi_sas_dma_map(struct hisi_hba *hisi_hba, - struct sas_task *task, int *n_elem, - int *n_elem_req) + struct sas_task *task, int *n_elem) { struct device *dev = hisi_hba->dev; int rc; @@ -308,9 +304,9 @@ static int hisi_sas_dma_map(struct hisi_hba *hisi_hba, goto prep_out; } } else if (task->task_proto & SAS_PROTOCOL_SMP) { - *n_elem_req = dma_map_sg(dev, &task->smp_task.smp_req, - 1, DMA_TO_DEVICE); - if (!*n_elem_req) { + *n_elem = dma_map_sg(dev, &task->smp_task.smp_req, + 1, DMA_TO_DEVICE); + if (!*n_elem) { rc = -ENOMEM; goto prep_out; } @@ -332,8 +328,7 @@ static int hisi_sas_dma_map(struct hisi_hba *hisi_hba, err_out_dma_unmap: /* It would be better to call dma_unmap_sg() here, but it's messy */ - hisi_sas_dma_unmap(hisi_hba, task, *n_elem, - *n_elem_req); + hisi_sas_dma_unmap(hisi_hba, task, *n_elem); prep_out: return rc; } @@ -457,7 +452,7 @@ void hisi_sas_task_deliver(struct hisi_hba *hisi_hba, static int hisi_sas_queue_command(struct sas_task *task, gfp_t gfp_flags) { - int n_elem = 0, n_elem_dif = 0, n_elem_req = 0; + int n_elem = 0, n_elem_dif = 0; struct domain_device *device = task->dev; struct asd_sas_port *sas_port = device->port; struct hisi_sas_device *sas_dev = device->lldd_dev; @@ -568,8 +563,7 @@ static int hisi_sas_queue_command(struct sas_task *task, gfp_t gfp_flags) return -EINVAL; } - rc = hisi_sas_dma_map(hisi_hba, task, &n_elem, - &n_elem_req); + rc = hisi_sas_dma_map(hisi_hba, task, &n_elem); if (rc < 0) goto prep_out; @@ -605,8 +599,7 @@ static int hisi_sas_queue_command(struct sas_task *task, gfp_t gfp_flags) if (!sas_protocol_ata(task->task_proto)) hisi_sas_dif_dma_unmap(hisi_hba, task, n_elem_dif); err_out_dma_unmap: - hisi_sas_dma_unmap(hisi_hba, task, n_elem, - n_elem_req); + hisi_sas_dma_unmap(hisi_hba, task, n_elem); prep_out: dev_err(dev, "task exec: failed[%d]!\n", rc); return rc; -- 2.35.3