From patchwork Fri Jan 25 14:22:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 156597 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp417998jaa; Fri, 25 Jan 2019 06:22:43 -0800 (PST) X-Google-Smtp-Source: ALg8bN5Sh2eCLWilHc01Z4FGr7MVBXZpUvqBUGJ8f2y4A2ZovKfhKPPbQA9hHJOEQaAheeEfuUb2 X-Received: by 2002:a63:d655:: with SMTP id d21mr10194079pgj.280.1548426163118; Fri, 25 Jan 2019 06:22:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548426163; cv=none; d=google.com; s=arc-20160816; b=u8Dv6pGqBOmrlWHvwP2PBQR7kghxq1d423stMVbIcGYkDo9hStziVbZH/Px9Av+lRH o6MJaIBus7BZytptCY138m11C/7SXd54OSWsI4AceRDhdth63Xe5HhvKLN31VKFtojl3 owIudazu22/pn+91GIawDYQ4FGTOXpxijGIEOpC4Tl1Z0yGHDVSZWcTP7CFhZQ+XPeLJ WX+6xgR40+nPAXgMg3XKnBOMnM4rKpkOA26j9j5FuW4a9Moo7vK87NPo1YTIFZi6Brx+ bFheSc7pg+8vY7cFJdLk+pBaMQS67ZTN4nmovtwqbvMG5zTQNOr3bsPKai/gr5G3vJ1o 7Ztg== 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=+ejnYQ8PZxP+ICIGRpQs+zbcrnCI9JwF40qSI+yn5jA=; b=clWI+24qrxrnaufiGO4gEoNgzB4YKVvt0uvwuTxth8SKcM0I1rwLpw63EWbSU8BoiQ 1lC1syOHYJwZIUWdo1+Zk7q6ica+5CPZX/LmzFoTmo65xqXhybEemPDOzRR7UadYIF3p sGVqGcVYP0NXKtWhBfMuTXmRTSlaTqKPnFIih/rjkBsJqG6PndUDJRHnm+uRvgLO0c3u ViOd/+rISZyXvvgGIphpLf5cK2FSP8rjcBR2K4r3+4DPrv81Il0E4VKElt5cSgICCkys fM1sF9iRBbxZcsbp2R5pABWTl7hTZm+ARgVUuXjTh5JlQi7ZOWGOaSKoMTLXGaPNmcDQ 3x1A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 p26si20283653pfj.244.2019.01.25.06.22.42; Fri, 25 Jan 2019 06:22:43 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729180AbfAYOWl (ORCPT + 31 others); Fri, 25 Jan 2019 09:22:41 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:56364 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728641AbfAYOWH (ORCPT ); Fri, 25 Jan 2019 09:22:07 -0500 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 471E79C91A481FA10234; Fri, 25 Jan 2019 22:22:04 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.408.0; Fri, 25 Jan 2019 22:21:53 +0800 From: John Garry To: , CC: , , , John Garry Subject: [PATCH 11/13] scsi: hisi_sas: Some misc tidy-up Date: Fri, 25 Jan 2019 22:22:37 +0800 Message-ID: <1548426159-225679-12-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1548426159-225679-1-git-send-email-john.garry@huawei.com> References: <1548426159-225679-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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Sparse detected some problems in the driver, so tidy them up. Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_main.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) -- 1.9.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 89f1bc5..e48b627 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -2075,14 +2075,18 @@ void hisi_sas_kill_tasklets(struct hisi_hba *hisi_hba) void hisi_sas_init_mem(struct hisi_hba *hisi_hba) { - int i, s, max_command_entries = hisi_hba->hw->max_command_entries; + int i, s, j, max_command_entries = hisi_hba->hw->max_command_entries; + struct hisi_sas_breakpoint *sata_breakpoint = hisi_hba->sata_breakpoint; for (i = 0; i < hisi_hba->queue_count; i++) { struct hisi_sas_cq *cq = &hisi_hba->cq[i]; struct hisi_sas_dq *dq = &hisi_hba->dq[i]; + struct hisi_sas_cmd_hdr *cmd_hdr = hisi_hba->cmd_hdr[i]; + + s = sizeof(struct hisi_sas_cmd_hdr); + for (j = 0; j < HISI_SAS_QUEUE_SLOTS; j++) + memset(&cmd_hdr[j], 0, s); - s = sizeof(struct hisi_sas_cmd_hdr) * HISI_SAS_QUEUE_SLOTS; - memset(hisi_hba->cmd_hdr[i], 0, s); dq->wr_point = 0; s = hisi_hba->hw->complete_hdr_size * HISI_SAS_QUEUE_SLOTS; @@ -2099,8 +2103,9 @@ void hisi_sas_init_mem(struct hisi_hba *hisi_hba) s = max_command_entries * sizeof(struct hisi_sas_breakpoint); memset(hisi_hba->breakpoint, 0, s); - s = HISI_SAS_MAX_ITCT_ENTRIES * sizeof(struct hisi_sas_sata_breakpoint); - memset(hisi_hba->sata_breakpoint, 0, s); + s = sizeof(struct hisi_sas_sata_breakpoint); + for (j = 0; j < HISI_SAS_MAX_ITCT_ENTRIES; j++) + memset(&sata_breakpoint[j], 0, s); } EXPORT_SYMBOL_GPL(hisi_sas_init_mem); @@ -2157,10 +2162,9 @@ int hisi_sas_alloc(struct hisi_hba *hisi_hba) s = HISI_SAS_MAX_ITCT_ENTRIES * sizeof(struct hisi_sas_itct); hisi_hba->itct = dmam_alloc_coherent(dev, s, &hisi_hba->itct_dma, - GFP_KERNEL); + GFP_KERNEL | __GFP_ZERO); if (!hisi_hba->itct) goto err_out; - memset(hisi_hba->itct, 0, s); hisi_hba->slot_info = devm_kcalloc(dev, max_command_entries, sizeof(struct hisi_sas_slot), @@ -2505,10 +2509,17 @@ static void hisi_sas_debugfs_snapshot_dq_reg(struct hisi_hba *hisi_hba) int queue_entry_size = sizeof(struct hisi_sas_cmd_hdr); int i; - for (i = 0; i < hisi_hba->queue_count; i++) - memcpy(hisi_hba->debugfs_cmd_hdr[i], - hisi_hba->cmd_hdr[i], - HISI_SAS_QUEUE_SLOTS * queue_entry_size); + for (i = 0; i < hisi_hba->queue_count; i++) { + struct hisi_sas_cmd_hdr *debugfs_cmd_hdr, *cmd_hdr; + int j; + + debugfs_cmd_hdr = hisi_hba->debugfs_cmd_hdr[i]; + cmd_hdr = hisi_hba->cmd_hdr[i]; + + for (j = 0; j < HISI_SAS_QUEUE_SLOTS; j++) + memcpy(&debugfs_cmd_hdr[j], &cmd_hdr[j], + queue_entry_size); + } } static void hisi_sas_debugfs_snapshot_port_reg(struct hisi_hba *hisi_hba)