From patchwork Mon Aug 5 13:48:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 170560 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp4321799ile; Mon, 5 Aug 2019 06:50:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqzvdpQHNWkWrMmt3Q8e993h24w212VbSNXwNbzCyRbhIrl0Z++961AxWjfEaHa1JOIcQD7M X-Received: by 2002:a62:5c47:: with SMTP id q68mr74508672pfb.205.1565013030928; Mon, 05 Aug 2019 06:50:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565013030; cv=none; d=google.com; s=arc-20160816; b=ecdfBotMF6IwCrxoxYNwi+ySDhtJ66iVHU7+YvERQ7fijIsUWZzqYnv8wUWPIdRUOi YMwPuTS6UVCas2CCFbNkei+8IWc8udg+qtjgRaJRt2G6qlaOhi/IVvYci6JE6hlsuzCc g829I/zNZocxlOfIXF1seTunFTEGFD4LG97zgFjt+SQoZS1okrIIqRB5HxIbeXBBVEyL TjOZpBlNXfYsBa90UogLoEOL1ss7CPtcHl+upGwcq8ukBBxRc4L8B8QWp75xivNKaaFf Y9bZs9nXECk9ZHqhBYAQMWz1MxM0E+KfkVCzgrB4ViNg1SxkrLyJzaCssJD10Ff82PYA MQ7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=OC5qDc0uyAGVNHCgSwkPbX2DW80VzAN8gD9YkaekSAQ=; b=g6/wrDB8ticmNrmGz5ci1WBB61JollRWSPckSC7t0r1WxKIelbtFpW7Og1LD9qKqQa 7zUS0ljaOffb4IoxWGuI6pZmTsHufL2EH9hx8S+6yf+nf8eo+iE6qdUjnEgtlVw5oIma zxc4TmQxPJjBJyuPWnNcCOXrS19jWYqQBMtCjvPTDusQ/PCEIOyBPCch+Hs8/AH6QMpU Pram8si1CpiPD2Ncw9ITho3xM5WRn3hKgxfwKmwE7SFmXZq8drYzYI1k6fh6XGbUl5zE NhA27eWTDopvtZiQmtIGnbw1GUfW0loQ5TZlS9phfkamXTAa431zq3fcXKWPi8ec+0M5 RoSg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k13si45940146pfa.17.2019.08.05.06.50.30 for ; Mon, 05 Aug 2019 06:50:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730043AbfHENu3 (ORCPT ); Mon, 5 Aug 2019 09:50:29 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:44560 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729866AbfHENu2 (ORCPT ); Mon, 5 Aug 2019 09:50:28 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 29691A460A766AD89F5A; Mon, 5 Aug 2019 21:50:24 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.439.0; Mon, 5 Aug 2019 21:50:13 +0800 From: John Garry To: , CC: , , , Xiang Chen , "John Garry" Subject: [PATCH 07/15] scsi: hisi_sas: Don't bother clearing status buffer IU in task prep Date: Mon, 5 Aug 2019 21:48:04 +0800 Message-ID: <1565012892-75940-8-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1565012892-75940-1-git-send-email-john.garry@huawei.com> References: <1565012892-75940-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.212.75] X-CFilter-Loop: Reflected Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Xiang Chen For struct hisi_sas_status_buffer, it contains struct hisi_sas_err_record and iu[1024]. The struct iu[1024] will be filled fully by the response of disks, so it is not need to initialize them to 0, but for the struct hisi_sas_err_record, SAS controller only fill some fields of hisi_sas_err_record according to hw designer, so it should be initialised to 0. After the change, cpu utilization percentage of memset() is changed from 1.7% to 0.12%. Signed-off-by: Xiang Chen Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) -- 2.17.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 02ad91c01a44..7efa8dfa0cc1 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -545,7 +545,8 @@ static int hisi_sas_task_prep(struct sas_task *task, memset(slot->cmd_hdr, 0, sizeof(struct hisi_sas_cmd_hdr)); memset(hisi_sas_cmd_hdr_addr_mem(slot), 0, HISI_SAS_COMMAND_TABLE_SZ); - memset(hisi_sas_status_buf_addr_mem(slot), 0, HISI_SAS_STATUS_BUF_SZ); + memset(hisi_sas_status_buf_addr_mem(slot), 0, + sizeof(struct hisi_sas_err_record)); switch (task->task_proto) { case SAS_PROTOCOL_SMP: @@ -2005,7 +2006,8 @@ hisi_sas_internal_abort_task_exec(struct hisi_hba *hisi_hba, int device_id, memset(slot->cmd_hdr, 0, sizeof(struct hisi_sas_cmd_hdr)); memset(hisi_sas_cmd_hdr_addr_mem(slot), 0, HISI_SAS_COMMAND_TABLE_SZ); - memset(hisi_sas_status_buf_addr_mem(slot), 0, HISI_SAS_STATUS_BUF_SZ); + memset(hisi_sas_status_buf_addr_mem(slot), 0, + sizeof(struct hisi_sas_err_record)); hisi_sas_task_prep_abort(hisi_hba, slot, device_id, abort_flag, task_tag); From patchwork Mon Aug 5 13:48:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 170564 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp4322238ile; Mon, 5 Aug 2019 06:50:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqwQNpV6HTW+1WMOP8F6zcoetZh4iHFLwSnvedl3l0+aVpt4huIFmVoGu0ko861oNfOqaPEb X-Received: by 2002:a63:e44b:: with SMTP id i11mr87706406pgk.297.1565013058346; Mon, 05 Aug 2019 06:50:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565013058; cv=none; d=google.com; s=arc-20160816; b=odChpGLa5eKxci6Td6FfuZcOMnH3xL/bjjhSQQ3RIiSuilJ0uYvDKPjrRpmPqUz66p FUsVJ4td+e7RHLRmHySMceTnN7UWSTi8s8I+qGTZtKTajz81XiwFxZaeqwJyQd6GGS8H +nLW+oXo8D/88S1A4ntDuIH2aOpicIsaUfNerBqPXnoz9mHOjxTtMAGnN4fmYdq053qC u6pz0zWH0fBcHUpcUHbpDprSlp6EIzLKXNkvJo940zTvqVY589yOORoXbiGI/PK2fwgK CS5kDxMaK4W+/aV45dDCeSucZtUIhO1ePf+Q+1grMa7DPXM3p0nta/emo+ZuMfGUQxME 8xfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=24rgm9wkBJ1hTkpySSYQ8RP+bcQ2HAxtlkZmN9O48sA=; b=deKFauroV0TaXl6FPv+rt5ZuJO4/fJRoG5wTXg8nR8BfRXv4mCNhiUYxKJxEOldyBR XaFJ5+zywWgiG6m0zrhmbEVRapygMjZ5kcG/sqS13pPefZjMFlxhH27P+rE1xBHhq6bI U3Rh4Qze0nEMd2UW5e/kc/EjztZW3PtKlztVFGffc7pS2/dwjdk9tQ1WXjIU2uNW3tWS LA1yQI+V7ywdzh4ErMQ+T1OBR6AUO0sYvkg1RDtT3X1QCI0Ev6eC3gMf/ckEus5d1cYb P4F4wwS8dYqFMb4Mg5r+ArhnYITxoE6uPl+2RO591Z17Pprbioiq3ButkFtJABLz1car 2YoQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y6si44357502pfl.288.2019.08.05.06.50.57 for ; Mon, 05 Aug 2019 06:50:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729825AbfHENuk (ORCPT ); Mon, 5 Aug 2019 09:50:40 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:44550 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729845AbfHENu2 (ORCPT ); Mon, 5 Aug 2019 09:50:28 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 20F3588411166E615543; Mon, 5 Aug 2019 21:50:24 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.439.0; Mon, 5 Aug 2019 21:50:13 +0800 From: John Garry To: , CC: , , , Xiang Chen , "John Garry" Subject: [PATCH 08/15] scsi: hisi_sas: Make slot buf minimum allocation of PAGE_SIZE Date: Mon, 5 Aug 2019 21:48:05 +0800 Message-ID: <1565012892-75940-9-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1565012892-75940-1-git-send-email-john.garry@huawei.com> References: <1565012892-75940-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.212.75] X-CFilter-Loop: Reflected Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Xiang Chen For a system with PAGE_SIZE of 16K or 64K, the size every time we want to alloc may be small like 4K, but for function dmam_alloc_coherent(), the least size it allocates is PAGE_SIZE, so it will waste much memory for the situation. To solve the issue, limit the minimum allocation size of slot buf to PAGE_SIZE. Signed-off-by: Xiang Chen Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.17.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 7efa8dfa0cc1..39ae69e42d26 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -2389,7 +2389,7 @@ int hisi_sas_alloc(struct hisi_hba *hisi_hba) else sz_slot_buf_ru = sizeof(struct hisi_sas_slot_buf_table); sz_slot_buf_ru = roundup(sz_slot_buf_ru, 64); - s = lcm(max_command_entries_ru, sz_slot_buf_ru); + s = max(lcm(max_command_entries_ru, sz_slot_buf_ru), PAGE_SIZE); blk_cnt = (max_command_entries_ru * sz_slot_buf_ru) / s; slots_per_blk = s / sz_slot_buf_ru; From patchwork Mon Aug 5 13:48:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 170559 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp4321724ile; Mon, 5 Aug 2019 06:50:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqzQ1BjxAk4qY+xHwbPPrmZr6X2MqYTaxMkO1Az+55h+CdiN1MvHcZ8tjP6UCfPFXbpMXd7T X-Received: by 2002:a63:89c2:: with SMTP id v185mr30714645pgd.241.1565013027466; Mon, 05 Aug 2019 06:50:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565013027; cv=none; d=google.com; s=arc-20160816; b=t7CbLZbUXNdLCmbJiY7wAhidACk3YERKQP67ZGEtuwQby2N9BIWnB1W4XybU6k3+iH 0uPvzhVEa4rXe8EXhtpkLtKJPOWmhn2JirJ6ObEfTQZoVx6tvp5poaAsVVM1f4m1VbR7 9+H+2YwlFCKx4fvvyhsxIhM33GtG4CgHsHPD9zymq31yNihOuA1XWuN+3Sm+tvRJ79ks mBSb9qefjMdVm89S4a6mIM0pEKxpiIfTzDcmHqYpIzie5G7zRc8Wy/eBXiyEnGWSNlmd s6xnlOrhZrBKE2GlHjyIpXTSz3/usM1ArppJvFGa+5Mg0J04irwZX2pqUhV7MiP0+Dyh WN7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=1PYYX1O/wb1DpEa93ssxN9NVo7CQosl76BE5NjFNMlM=; b=meMoP6gVFqEtXGzpJO5TO6X9/PSVJbnvWhlT5qf9RdLvHQCB5GiKV8gA9tm47pG6lf 43JxeXitri4KdEwqqzWBtZWC0doOQbvSXjROLf85Q+KNagfoawne333XgtWeoRP5q04m 3HLHYJh6IKQYFuCL152RUj0EhGasgFg1vuu4XnO1oKoZy8gJCzLVao/F+FfV2rOjhWK4 UVCoF+ANt4ScRsnCjdVZTvC+MyOIErZR/rbuuuU29Eltj430+vaGJf/DRV7NNeTr9/3p 68aiMsD9i9VTWhZb9Rg4gSr5fXHaGiRaDYZqXo+rdtqyShRTsu3LiJT3VUm2x7AkIERW 6EiQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 73si43449528pfa.123.2019.08.05.06.50.27 for ; Mon, 05 Aug 2019 06:50:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729691AbfHENu0 (ORCPT ); Mon, 5 Aug 2019 09:50:26 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:44500 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728904AbfHENu0 (ORCPT ); Mon, 5 Aug 2019 09:50:26 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id EB6D2E454038141DF8AB; Mon, 5 Aug 2019 21:50:23 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.439.0; Mon, 5 Aug 2019 21:50:14 +0800 From: John Garry To: , CC: , , , John Garry Subject: [PATCH 09/15] scsi: hisi_sas: Drop kmap_atomic() in SMP command completion Date: Mon, 5 Aug 2019 21:48:06 +0800 Message-ID: <1565012892-75940-10-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1565012892-75940-1-git-send-email-john.garry@huawei.com> References: <1565012892-75940-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.212.75] X-CFilter-Loop: Reflected Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The call to kmap_atomic() in the SMP command completion code is unnecessary, since kmap() is only really concerned with highmem, which is not relevant on arm64. The controller only finds itself in arm64 systems. Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 4 +--- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 4 +--- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 4 +--- 3 files changed, 3 insertions(+), 9 deletions(-) -- 2.17.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c index b13cbc64d2a9..015bf00a20e6 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c @@ -1275,11 +1275,10 @@ static int slot_complete_v1_hw(struct hisi_hba *hisi_hba, } case SAS_PROTOCOL_SMP: { - void *to; struct scatterlist *sg_resp = &task->smp_task.smp_resp; + void *to = page_address(sg_page(sg_resp)); ts->stat = SAM_STAT_GOOD; - to = kmap_atomic(sg_page(sg_resp)); dma_unmap_sg(dev, &task->smp_task.smp_resp, 1, DMA_FROM_DEVICE); @@ -1289,7 +1288,6 @@ static int slot_complete_v1_hw(struct hisi_hba *hisi_hba, hisi_sas_status_buf_addr_mem(slot) + sizeof(struct hisi_sas_err_record), sg_dma_len(sg_resp)); - kunmap_atomic(to); break; } case SAS_PROTOCOL_SATA: diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c index de33e31cd88a..c3cf3b77c655 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c @@ -2419,10 +2419,9 @@ slot_complete_v2_hw(struct hisi_hba *hisi_hba, struct hisi_sas_slot *slot) case SAS_PROTOCOL_SMP: { struct scatterlist *sg_resp = &task->smp_task.smp_resp; - void *to; + void *to = page_address(sg_page(sg_resp)); ts->stat = SAM_STAT_GOOD; - to = kmap_atomic(sg_page(sg_resp)); dma_unmap_sg(dev, &task->smp_task.smp_resp, 1, DMA_FROM_DEVICE); @@ -2432,7 +2431,6 @@ slot_complete_v2_hw(struct hisi_hba *hisi_hba, struct hisi_sas_slot *slot) hisi_sas_status_buf_addr_mem(slot) + sizeof(struct hisi_sas_err_record), sg_dma_len(sg_resp)); - kunmap_atomic(to); break; } case SAS_PROTOCOL_SATA: diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index 072a39d5c4ad..fcb2ef5f24b9 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -2211,10 +2211,9 @@ slot_complete_v3_hw(struct hisi_hba *hisi_hba, struct hisi_sas_slot *slot) } case SAS_PROTOCOL_SMP: { struct scatterlist *sg_resp = &task->smp_task.smp_resp; - void *to; + void *to = page_address(sg_page(sg_resp)); ts->stat = SAM_STAT_GOOD; - to = kmap_atomic(sg_page(sg_resp)); dma_unmap_sg(dev, &task->smp_task.smp_resp, 1, DMA_FROM_DEVICE); @@ -2224,7 +2223,6 @@ slot_complete_v3_hw(struct hisi_hba *hisi_hba, struct hisi_sas_slot *slot) hisi_sas_status_buf_addr_mem(slot) + sizeof(struct hisi_sas_err_record), sg_dma_len(sg_resp)); - kunmap_atomic(to); break; } case SAS_PROTOCOL_SATA: From patchwork Mon Aug 5 13:48:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 170567 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp4322458ile; Mon, 5 Aug 2019 06:51:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqx3z9HAQDiHwvZchC/1x0AVBlGM8O4/7OhfxVo9IZ7mWZLblgWsSIIlxVtZTEtXlKfCyldt X-Received: by 2002:a63:c054:: with SMTP id z20mr12936680pgi.373.1565013068627; Mon, 05 Aug 2019 06:51:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565013068; cv=none; d=google.com; s=arc-20160816; b=nI7QOS2tDugLbxPdW2Aac4ntev7cQogCkExms/OJjUm8CCsmr/TAfCodwJNGL0oRcO xY2oRhuUdlIzGyqsNeKuQ5UgT0wyCU1hzm93tV7JkfMixAgn7K63Z8DdVrD8OTwMo+pg K6sljRq7NJ2iwHPl+2UoV9afZC9GdufK/YO2RsGDZ3RejZautypn4gadZDTAIpHTtBTb rv1Vu0fNRO4jM1NVdcbz2KnNbd9tNqygwfYoiHZ2VpBwbnOxWVgXatq2RGvDz6+iO2+n 6W5piVD74XS0yOvaEaUf9FilAjHiyWIVDMzFn0D3I8YWONDAKdOhmdfi71HLJNUQeJEw Mb3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=1CyrCh9cYh//4wvbLKxNYRpezauymX6DKhhnogaMss8=; b=XPkpFEcZEGOAC3UyKj+/Xk3CeuWZHWcb3wALzIxu4KdvLcNK6MtLgde3S4e4rXBemX u4345+DdzLxn1HusoMWdidu9RludE9bCkO4oWge+5EdH7DXO7mx04RwtLxHiIo6BXkcN /ScELomLn+cKZtcZthHUZ8ndzE1Mx0ENbbqdXHDPuU+I1zFBID4yqCzIDTRZKkJDuphK OpGrfmRAlqnoi/+V/8iRzndaU1VTkJb0xMhR/jTCU6xaVakX9yzmk6q8L9B2EW0XzL1d shf8fihHUfwYPZqwMY3T5FXnQWeGxeJ6dOcJtYDwMFT3KK9ZsVDZkeQTHkvUUl9LVW+j IrkQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e10si10826154pgt.431.2019.08.05.06.51.08 for ; Mon, 05 Aug 2019 06:51:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730014AbfHENvI (ORCPT ); Mon, 5 Aug 2019 09:51:08 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:44496 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729627AbfHENu1 (ORCPT ); Mon, 5 Aug 2019 09:50:27 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 003B8DA2237DC82E83EC; Mon, 5 Aug 2019 21:50:23 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.439.0; Mon, 5 Aug 2019 21:50:14 +0800 From: John Garry To: , CC: , , , John Garry Subject: [PATCH 10/15] scsi: hisi_sas: Drop SMP resp frame DMA mapping Date: Mon, 5 Aug 2019 21:48:07 +0800 Message-ID: <1565012892-75940-11-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1565012892-75940-1-git-send-email-john.garry@huawei.com> References: <1565012892-75940-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.212.75] X-CFilter-Loop: Reflected Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The SMP frame response is written to the command table and not the SMP response pointer from libsas, so don't bother DMA mapping (and unmapping) the SMP response from libsas. Suggested-by: Xiang Chen Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_main.c | 28 +++++++------------------- drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 4 +--- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 4 +--- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 4 +--- 4 files changed, 10 insertions(+), 30 deletions(-) -- 2.17.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 39ae69e42d26..a2255701b50b 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -300,7 +300,7 @@ 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, int n_elem_resp) + int n_elem_req) { struct device *dev = hisi_hba->dev; @@ -314,16 +314,13 @@ static void hisi_sas_dma_unmap(struct hisi_hba *hisi_hba, if (n_elem_req) dma_unmap_sg(dev, &task->smp_task.smp_req, 1, DMA_TO_DEVICE); - if (n_elem_resp) - dma_unmap_sg(dev, &task->smp_task.smp_resp, - 1, DMA_FROM_DEVICE); } } } static int hisi_sas_dma_map(struct hisi_hba *hisi_hba, struct sas_task *task, int *n_elem, - int *n_elem_req, int *n_elem_resp) + int *n_elem_req) { struct device *dev = hisi_hba->dev; int rc; @@ -331,7 +328,7 @@ static int hisi_sas_dma_map(struct hisi_hba *hisi_hba, if (sas_protocol_ata(task->task_proto)) { *n_elem = task->num_scatter; } else { - unsigned int req_len, resp_len; + unsigned int req_len; if (task->num_scatter) { *n_elem = dma_map_sg(dev, task->scatter, @@ -352,17 +349,6 @@ static int hisi_sas_dma_map(struct hisi_hba *hisi_hba, rc = -EINVAL; goto err_out_dma_unmap; } - *n_elem_resp = dma_map_sg(dev, &task->smp_task.smp_resp, - 1, DMA_FROM_DEVICE); - if (!*n_elem_resp) { - rc = -ENOMEM; - goto err_out_dma_unmap; - } - resp_len = sg_dma_len(&task->smp_task.smp_resp); - if (resp_len & 0x3) { - rc = -EINVAL; - goto err_out_dma_unmap; - } } } @@ -377,7 +363,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, *n_elem_resp); + *n_elem_req); prep_out: return rc; } @@ -449,7 +435,7 @@ static int hisi_sas_task_prep(struct sas_task *task, struct asd_sas_port *sas_port = device->port; struct device *dev = hisi_hba->dev; int dlvry_queue_slot, dlvry_queue, rc, slot_idx; - int n_elem = 0, n_elem_dif = 0, n_elem_req = 0, n_elem_resp = 0; + int n_elem = 0, n_elem_dif = 0, n_elem_req = 0; struct hisi_sas_dq *dq; unsigned long flags; int wr_q_index; @@ -485,7 +471,7 @@ static int hisi_sas_task_prep(struct sas_task *task, } rc = hisi_sas_dma_map(hisi_hba, task, &n_elem, - &n_elem_req, &n_elem_resp); + &n_elem_req); if (rc < 0) goto prep_out; @@ -580,7 +566,7 @@ static int hisi_sas_task_prep(struct sas_task *task, 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, n_elem_resp); + n_elem_req); prep_out: dev_err(dev, "task prep: failed[%d]!\n", rc); return rc; diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c index 015bf00a20e6..16974421cb31 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c @@ -1280,14 +1280,12 @@ static int slot_complete_v1_hw(struct hisi_hba *hisi_hba, ts->stat = SAM_STAT_GOOD; - dma_unmap_sg(dev, &task->smp_task.smp_resp, 1, - DMA_FROM_DEVICE); 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), - sg_dma_len(sg_resp)); + sg_resp->length); break; } case SAS_PROTOCOL_SATA: diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c index c3cf3b77c655..9955b4fbdd0d 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c @@ -2423,14 +2423,12 @@ slot_complete_v2_hw(struct hisi_hba *hisi_hba, struct hisi_sas_slot *slot) ts->stat = SAM_STAT_GOOD; - dma_unmap_sg(dev, &task->smp_task.smp_resp, 1, - DMA_FROM_DEVICE); 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), - sg_dma_len(sg_resp)); + sg_resp->length); break; } case SAS_PROTOCOL_SATA: diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index fcb2ef5f24b9..95a298d4e211 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -2215,14 +2215,12 @@ slot_complete_v3_hw(struct hisi_hba *hisi_hba, struct hisi_sas_slot *slot) ts->stat = SAM_STAT_GOOD; - dma_unmap_sg(dev, &task->smp_task.smp_resp, 1, - DMA_FROM_DEVICE); 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), - sg_dma_len(sg_resp)); + sg_resp->length); break; } case SAS_PROTOCOL_SATA: