Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp842106imw; Thu, 14 Jul 2022 11:49:44 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tXSITbpRJEM04Hfq+E8GoA2Ufh0p5tZYpPW4eJbfO7GvClHI+xF/FUoVfXCL9AeTfjL2Wv X-Received: by 2002:a17:907:8a0e:b0:72b:9ca3:507 with SMTP id sc14-20020a1709078a0e00b0072b9ca30507mr9812616ejc.477.1657824584736; Thu, 14 Jul 2022 11:49:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657824584; cv=none; d=google.com; s=arc-20160816; b=vc/lUzgIQJm8BEIHNnj3vMCSyE9+l4Wj7l6nfftD4G3NeIHtopNTfpS70ZQWjuJ9C1 tegJ0HPKZXRjRUK8OqsAoU96RlNZ4IPpFs/bDhUiNSdz58fzcNEcEve2lhLcAkW/n/NO xFJ+8aVCj4DWp2c1IfhJ13hhXZjiZneAAot+A/D8X4sPxAermgWol1YUpnSqk3GWirZp UheH77/CR9dZl1QTYrdL3230i7EKXRQBfHE8HpfQNsgzhgV+MqsidvEV07UCySN3erBF gntkKyt/L2ipmHAlatQ8JmTmpPcTOY4pW3qTS/yURHt0I33AbQNY/P8NFBzkJEOx2u9G QUaQ== 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=dKNGISQAmg6J6Qrhse02HOetlF5K9au513ccq9mpDYQ=; b=ln0miwsbbvW+hZHUToDzReKFlnc7xmzHCHAq1ggiyQ7jQq7wvpx2pLEbNzH8CUYdlx BL/wW87onP1jRnKErmIpsoXwbGXla4NZI1BcSydXAP/ylP3RfMSmMa/QC1mwkUpEDDOk aZKd6gDZhrCLaEJaWibjBMOW07W12WU3Vg0CMeMWwDvfwEIlvr9tpHCKdsWLhIth4OQI lJ91Y2huklp11G54dLUzhzSkVFuMKnqWlPIadw7dI+Sdig8sEaJscoR0D3vZmfgfxgY5 iWEzwR8ntCFNFPChoNSClYk15Doz/AWve47udt177N5sk3PGaixiwS9jQqZMiczjNiFU 89Rg== 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 g14-20020a056402090e00b00439fe0779f0si1802222edz.469.2022.07.14.11.49.20; Thu, 14 Jul 2022 11:49:44 -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 S240715AbiGNSaK (ORCPT + 99 others); Thu, 14 Jul 2022 14:30:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240710AbiGNSaB (ORCPT ); Thu, 14 Jul 2022 14:30:01 -0400 Received: from sinmsgout02.his.huawei.com (sinmsgout02.his.huawei.com [119.8.177.37]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 582CF6B262; Thu, 14 Jul 2022 11:29:58 -0700 (PDT) Received: from fraeml714-chm.china.huawei.com (unknown [172.18.156.149]) by sinmsgout02.his.huawei.com (SkyGuard) with ESMTP id 4LkNL13Y76z9v7Hs; Fri, 15 Jul 2022 02:28:57 +0800 (CST) Received: from lhreml724-chm.china.huawei.com (10.201.108.75) by fraeml714-chm.china.huawei.com (10.206.15.33) 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:46 +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:44 +0100 From: John Garry To: , CC: , , , Xiang Chen , John Garry Subject: [PATCH 3/5] scsi: hisi_sas: Relocate DMA unmap of SMP task Date: Fri, 15 Jul 2022 02:23:20 +0800 Message-ID: <1657823002-139010-4-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 Currently SMP tasks are DMA unmapped only when cq of SMP IO is returned normally. If the cq of SMP IO is returned with exception actually SMP tas is never unmapped. Relocate DMA unmap of SMP task to fix the issue. Signed-off-by: Xiang Chen Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_main.c | 6 +++++- drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 2 -- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 2 -- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 2 -- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index bd62e441f947..33af5b8dede2 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -219,11 +219,15 @@ void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba, struct sas_task *task, task->lldd_task = NULL; if (!sas_protocol_ata(task->task_proto)) { - if (slot->n_elem) + if (slot->n_elem) { if (task->task_proto & SAS_PROTOCOL_SSP) dma_unmap_sg(dev, task->scatter, task->num_scatter, task->data_dir); + else + dma_unmap_sg(dev, &task->smp_task.smp_req, + 1, DMA_TO_DEVICE); + } if (slot->n_elem_dif) { struct sas_ssp_task *ssp_task = &task->ssp_task; struct scsi_cmnd *scsi_cmnd = ssp_task->cmd; diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c index 4582791def32..349546bacb2b 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c @@ -1282,8 +1282,6 @@ static void slot_complete_v1_hw(struct hisi_hba *hisi_hba, ts->stat = SAS_SAM_STAT_GOOD; - dma_unmap_sg(dev, &task->smp_task.smp_req, 1, - DMA_TO_DEVICE); memcpy(to + sg_resp->offset, hisi_sas_status_buf_addr_mem(slot) + sizeof(struct hisi_sas_err_record), diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c index 18297ab5a32b..70e401fd432a 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c @@ -2428,8 +2428,6 @@ static void slot_complete_v2_hw(struct hisi_hba *hisi_hba, ts->stat = SAS_SAM_STAT_GOOD; - dma_unmap_sg(dev, &task->smp_task.smp_req, 1, - DMA_TO_DEVICE); memcpy(to + sg_resp->offset, hisi_sas_status_buf_addr_mem(slot) + sizeof(struct hisi_sas_err_record), diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index 76c4173e277d..4d3eb53a8209 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -2311,8 +2311,6 @@ static void slot_complete_v3_hw(struct hisi_hba *hisi_hba, ts->stat = SAS_SAM_STAT_GOOD; - dma_unmap_sg(dev, &task->smp_task.smp_req, 1, - DMA_TO_DEVICE); memcpy(to + sg_resp->offset, hisi_sas_status_buf_addr_mem(slot) + sizeof(struct hisi_sas_err_record), -- 2.35.3