From patchwork Mon Aug 5 13:47:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 170558 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp4321688ile; Mon, 5 Aug 2019 06:50:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqxJhfn1Ba0MFHe2DIqV3Pns16mmIRdUETEeLQ1vhTuhOTMeJKZDJ/gokCvUqax1cLBOrtv7 X-Received: by 2002:a63:ff66:: with SMTP id s38mr138615811pgk.363.1565013025898; Mon, 05 Aug 2019 06:50:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565013025; cv=none; d=google.com; s=arc-20160816; b=ZzrypRiJ0S4ceB5fJUTQyO7whcFAlKu0i0ewApqh3KSeAtnTRqZhgwj640Kk64f0Xh dhLC9sjmlZQ5tb6DWidhmKYMFdqkD7uQFihA7Khmiwr9Es9+sch1TB0knl4oqIqorl31 jdu3J0iuAduUV9pnp9Pu+x7dNm3JB4xyyokLp+ooHLlo1ICIUhuHwopqP+G01+mhwAC7 y/Qtu2hIrIu38TqqyqGl3m8YT0LBxY8naUeFCzNSUpOzj8wtDRY+vnbmi5I8vjOJCLjp 3DWTN1IB5yUVZkzDTFlBFD9c+c/cM9BzS+hPHyY3sz3USgcq0gFcAyD1xPgjw9D946ew uAhg== 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=yF3aYqPdIJX7xaic3NPB5yDngyGicLF4NjYTFabGAhw=; b=JXli24/tr00CwarPzWqyk5VaKArUC4mOFxwMDxrcV0lQbHeyhKvlGSu2v8HUqGnl84 S96XE55/Q/E/2RFbT8aoW35NEn4cdoT+fQyFV7L7k/TXJxDCzAO+6DEZj/UNcQq9Sd1F X9/6Jb72IMTZSMNBF4sOPeUcOBpYonLGF7s9ArHAJkvFHp5ODJyzZ9FOlYpdatEmCyGz nY57LPhH0fg3+yDrOhJ4tKEtLaEVcCpK5bGr/M8oV5WKXtfjNgulT+s91YhBd5A2mx9P rbAa1Ce/XcVgaDVnhHFYw0440J6/w76ypuWdqWutgTP6fwmkSM5KbgVU0sJfeYwFbxbU EbSg== 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 73si43449528pfa.123.2019.08.05.06.50.25; Mon, 05 Aug 2019 06:50:25 -0700 (PDT) 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 S1729614AbfHENuY (ORCPT + 29 others); Mon, 5 Aug 2019 09:50:24 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:3761 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728904AbfHENuW (ORCPT ); Mon, 5 Aug 2019 09:50:22 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 194B87F39B89CBF6CE54; Mon, 5 Aug 2019 21:50:19 +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:12 +0800 From: John Garry To: , CC: , , , John Garry Subject: [PATCH 01/15] scsi: hisi_sas: Make max IPTT count equal for all hw revisions Date: Mon, 5 Aug 2019 21:47:58 +0800 Message-ID: <1565012892-75940-2-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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There is a small optimisation to be had by making the max IPTT the same for all hw revisions, that being we can drop the check for read and write pointer being the same in the get free slot function. Change v1 hw to have max IPTT of 4096 - same as v2 and v3 hw - and drop hisi_sas_hw.max_command_entries. Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas.h | 6 ++++-- drivers/scsi/hisi_sas/hisi_sas_main.c | 30 +++++++++++--------------- drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 3 --- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 1 - drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 7 ++---- 5 files changed, 19 insertions(+), 28 deletions(-) -- 2.17.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h index 42a02cc47a60..1fa3e53e857d 100644 --- a/drivers/scsi/hisi_sas/hisi_sas.h +++ b/drivers/scsi/hisi_sas/hisi_sas.h @@ -31,7 +31,10 @@ #define HISI_SAS_MAX_DEVICES HISI_SAS_MAX_ITCT_ENTRIES #define HISI_SAS_RESET_BIT 0 #define HISI_SAS_REJECT_CMD_BIT 1 -#define HISI_SAS_RESERVED_IPTT_CNT 96 +#define HISI_SAS_MAX_COMMANDS (HISI_SAS_QUEUE_SLOTS) +#define HISI_SAS_RESERVED_IPTT 96 +#define HISI_SAS_UNRESERVED_IPTT \ + (HISI_SAS_MAX_COMMANDS - HISI_SAS_RESERVED_IPTT) #define HISI_SAS_STATUS_BUF_SZ (sizeof(struct hisi_sas_status_buffer)) #define HISI_SAS_COMMAND_TABLE_SZ (sizeof(union hisi_sas_command_table)) @@ -292,7 +295,6 @@ struct hisi_sas_hw { int delay_ms, int timeout_ms); void (*snapshot_prepare)(struct hisi_hba *hisi_hba); void (*snapshot_restore)(struct hisi_hba *hisi_hba); - int max_command_entries; int complete_hdr_size; struct scsi_host_template *sht; diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index cb746cfc2fa8..94c7c2b48b17 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -180,8 +180,8 @@ static void hisi_sas_slot_index_free(struct hisi_hba *hisi_hba, int slot_idx) { unsigned long flags; - if (hisi_hba->hw->slot_index_alloc || (slot_idx >= - hisi_hba->hw->max_command_entries - HISI_SAS_RESERVED_IPTT_CNT)) { + if (hisi_hba->hw->slot_index_alloc || + slot_idx >= HISI_SAS_UNRESERVED_IPTT) { spin_lock_irqsave(&hisi_hba->lock, flags); hisi_sas_slot_index_clear(hisi_hba, slot_idx); spin_unlock_irqrestore(&hisi_hba->lock, flags); @@ -211,8 +211,7 @@ static int hisi_sas_slot_index_alloc(struct hisi_hba *hisi_hba, if (index >= hisi_hba->slot_index_count) { index = find_next_zero_bit(bitmap, hisi_hba->slot_index_count, - hisi_hba->hw->max_command_entries - - HISI_SAS_RESERVED_IPTT_CNT); + HISI_SAS_UNRESERVED_IPTT); if (index >= hisi_hba->slot_index_count) { spin_unlock_irqrestore(&hisi_hba->lock, flags); return -SAS_QUEUE_FULL; @@ -2291,7 +2290,7 @@ static struct sas_domain_function_template hisi_sas_transport_ops = { void hisi_sas_init_mem(struct hisi_hba *hisi_hba) { - int i, s, j, max_command_entries = hisi_hba->hw->max_command_entries; + int i, s, j, max_command_entries = HISI_SAS_MAX_COMMANDS; struct hisi_sas_breakpoint *sata_breakpoint = hisi_hba->sata_breakpoint; for (i = 0; i < hisi_hba->queue_count; i++) { @@ -2328,7 +2327,7 @@ EXPORT_SYMBOL_GPL(hisi_sas_init_mem); int hisi_sas_alloc(struct hisi_hba *hisi_hba) { struct device *dev = hisi_hba->dev; - int i, j, s, max_command_entries = hisi_hba->hw->max_command_entries; + int i, j, s, max_command_entries = HISI_SAS_MAX_COMMANDS; int max_command_entries_ru, sz_slot_buf_ru; int blk_cnt, slots_per_blk; @@ -2458,8 +2457,7 @@ int hisi_sas_alloc(struct hisi_hba *hisi_hba) hisi_sas_init_mem(hisi_hba); hisi_sas_slot_index_init(hisi_hba); - hisi_hba->last_slot_index = hisi_hba->hw->max_command_entries - - HISI_SAS_RESERVED_IPTT_CNT; + hisi_hba->last_slot_index = HISI_SAS_UNRESERVED_IPTT; hisi_hba->wq = create_singlethread_workqueue(dev_name(dev)); if (!hisi_hba->wq) { @@ -2672,13 +2670,11 @@ int hisi_sas_probe(struct platform_device *pdev, shost->max_channel = 1; shost->max_cmd_len = 16; if (hisi_hba->hw->slot_index_alloc) { - shost->can_queue = hisi_hba->hw->max_command_entries; - shost->cmd_per_lun = hisi_hba->hw->max_command_entries; + shost->can_queue = HISI_SAS_MAX_COMMANDS; + shost->cmd_per_lun = HISI_SAS_MAX_COMMANDS; } else { - shost->can_queue = hisi_hba->hw->max_command_entries - - HISI_SAS_RESERVED_IPTT_CNT; - shost->cmd_per_lun = hisi_hba->hw->max_command_entries - - HISI_SAS_RESERVED_IPTT_CNT; + shost->can_queue = HISI_SAS_UNRESERVED_IPTT; + shost->cmd_per_lun = HISI_SAS_UNRESERVED_IPTT; } sha->sas_ha_name = DRV_NAME; @@ -2794,7 +2790,7 @@ static void hisi_sas_debugfs_snapshot_itct_reg(struct hisi_hba *hisi_hba) static void hisi_sas_debugfs_snapshot_iost_reg(struct hisi_hba *hisi_hba) { - int max_command_entries = hisi_hba->hw->max_command_entries; + int max_command_entries = HISI_SAS_MAX_COMMANDS; void *databuf = hisi_hba->debugfs_iost; struct hisi_sas_iost *iost; int i; @@ -3008,7 +3004,7 @@ static int hisi_sas_debugfs_iost_show(struct seq_file *s, void *p) { struct hisi_hba *hisi_hba = s->private; struct hisi_sas_iost *debugfs_iost = hisi_hba->debugfs_iost; - int i, ret, max_command_entries = hisi_hba->hw->max_command_entries; + int i, ret, max_command_entries = HISI_SAS_MAX_COMMANDS; __le64 *iost = &debugfs_iost->qw0; for (i = 0; i < max_command_entries; i++, debugfs_iost++) { @@ -3177,7 +3173,7 @@ EXPORT_SYMBOL_GPL(hisi_sas_debugfs_work_handler); void hisi_sas_debugfs_init(struct hisi_hba *hisi_hba) { - int max_command_entries = hisi_hba->hw->max_command_entries; + int max_command_entries = HISI_SAS_MAX_COMMANDS; struct device *dev = hisi_hba->dev; int p, i, c, d; size_t sz; diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c index 3912216e8a4f..afdbaccbbc5e 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c @@ -401,8 +401,6 @@ enum { TRANS_RX_SMP_RESP_TIMEOUT_ERR, /* 0x31a */ }; -#define HISI_SAS_COMMAND_ENTRIES_V1_HW 8192 - #define HISI_SAS_PHY_MAX_INT_NR (HISI_SAS_PHY_INT_NR * HISI_SAS_MAX_PHYS) #define HISI_SAS_CQ_MAX_INT_NR (HISI_SAS_MAX_QUEUES) #define HISI_SAS_FATAL_INT_NR (2) @@ -1830,7 +1828,6 @@ static const struct hisi_sas_hw hisi_sas_v1_hw = { .phy_set_linkrate = phy_set_linkrate_v1_hw, .phy_get_max_linkrate = phy_get_max_linkrate_v1_hw, .get_wideport_bitmap = get_wideport_bitmap_v1_hw, - .max_command_entries = HISI_SAS_COMMAND_ENTRIES_V1_HW, .complete_hdr_size = sizeof(struct hisi_sas_complete_v1_hdr), .sht = &sht_v1_hw, }; diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c index e9b15d45f98f..fc98bd9e5588 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c @@ -3616,7 +3616,6 @@ static const struct hisi_sas_hw hisi_sas_v2_hw = { .get_events = phy_get_events_v2_hw, .phy_set_linkrate = phy_set_linkrate_v2_hw, .phy_get_max_linkrate = phy_get_max_linkrate_v2_hw, - .max_command_entries = HISI_SAS_COMMAND_ENTRIES_V2_HW, .complete_hdr_size = sizeof(struct hisi_sas_complete_v2_hdr), .soft_reset = soft_reset_v2_hw, .get_phys_state = get_phys_state_v2_hw, diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index 5f0f6df11adf..0171cdb4da81 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -2935,7 +2935,6 @@ static struct scsi_host_template sht_v3_hw = { static const struct hisi_sas_hw hisi_sas_v3_hw = { .hw_init = hisi_sas_v3_init, .setup_itct = setup_itct_v3_hw, - .max_command_entries = HISI_SAS_COMMAND_ENTRIES_V3_HW, .get_wideport_bitmap = get_wideport_bitmap_v3_hw, .complete_hdr_size = sizeof(struct hisi_sas_complete_v3_hdr), .clear_itct = clear_itct_v3_hw, @@ -3076,10 +3075,8 @@ hisi_sas_v3_probe(struct pci_dev *pdev, const struct pci_device_id *id) shost->max_lun = ~0; shost->max_channel = 1; shost->max_cmd_len = 16; - shost->can_queue = hisi_hba->hw->max_command_entries - - HISI_SAS_RESERVED_IPTT_CNT; - shost->cmd_per_lun = hisi_hba->hw->max_command_entries - - HISI_SAS_RESERVED_IPTT_CNT; + shost->can_queue = HISI_SAS_UNRESERVED_IPTT; + shost->cmd_per_lun = HISI_SAS_UNRESERVED_IPTT; sha->sas_ha_name = DRV_NAME; sha->dev = dev; From patchwork Mon Aug 5 13:47:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 170572 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp4340750ile; Mon, 5 Aug 2019 07:06:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqxWyax5MDp3pq4bQmQrWn608k63N6prEhpE/UeUQwO6nDE+xceFEK85pT0ha6jrRJWS2nMY X-Received: by 2002:a17:90a:c68c:: with SMTP id n12mr18374110pjt.33.1565013983438; Mon, 05 Aug 2019 07:06:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565013983; cv=none; d=google.com; s=arc-20160816; b=O2N/A/1cQe3efwGT9a8WanloU2tV5R5coiQ2VpYqKY91s4O8RYiLPe/zKkxfeuRSZR 5frPyvaYrFzyCJtT48OjaX3Gd9Y/ufiG7pM4iDbM6fXGWyTuwwG68E0rcn6XZ7nrggdU pITELflIZMjF31rArs5EXLxO96hjBaN07toTVwBoRdjPh1OQHWrCptzQXqUJlrd2Zu/T Fri6QvkOhuwtFgbsdwo65uX6SCE3KDIHMgSx0sOgHvnWZHOgPTYo1TCPdLM/p48Hpctx Q4/QBxpFEETAEZRC/i6Jvieig+f10HRSN3LEWwxMPt5p30MY6BOh/L2xbw1UeOsR6d3p bGiQ== 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=GmiASFCLFTeI/3Dm9MN9pq45fR4Da4gRKXGe1L4vozw=; b=Y4/RX8fo4Xl8l/LYZfQ78cK/hfYz6wOPUUtZIb74Rex6JY/1w5mJz4vl62iGToe70M CjFghMVOZ07uCEgl5zz2cllGI9A564BXhCw6h/N+zPLK378viVd+n+TsJncW0TNnpO4m BrrfwVbC00GsBe5OJ8FzPl+gAMJykvWQ9CwnSKitaUWTrlMMH/Ya4r9p0C8x/g7mDpt7 fAj0uKZFBJIDeUkA3LiryPXTPOYQTJjYPdAEQCSbntk7asUGA56cIatN6I0ITCDV5cV/ tlJoOcOa305PzWmxi9cwWHPhOPQy2heOkOhLuYWym14KSTMiNGWqAyJLUGvSE9dEGQN1 jXuw== 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 d7si39875799plr.18.2019.08.05.07.06.23; Mon, 05 Aug 2019 07:06:23 -0700 (PDT) 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 S1729306AbfHEOGR (ORCPT + 29 others); Mon, 5 Aug 2019 10:06:17 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:50508 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728894AbfHEOGQ (ORCPT ); Mon, 5 Aug 2019 10:06:16 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id DF29D6B9D0210462AC61; Mon, 5 Aug 2019 21:50:18 +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:12 +0800 From: John Garry To: , CC: , , , John Garry Subject: [PATCH 02/15] scsi: hisi_sas: Drop hisi_sas_hw.get_free_slot Date: Mon, 5 Aug 2019 21:47:59 +0800 Message-ID: <1565012892-75940-3-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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In commit 1273d65f29045 ("scsi: hisi_sas: change queue depth from 512 to 4096"), the depth of each queue is the same as the max IPTT in the system. As such, as long as we have an IPTT allocated, we will have enough space on any delivery queue. All .get_free_slot functions were checking for space on the queue by reading the DQ read pointer. Drop this, and also raise the code into common code, as there is nothing hw specific remaining. Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas.h | 1 - drivers/scsi/hisi_sas/hisi_sas_main.c | 27 ++++++--------------- drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 32 ------------------------- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 26 -------------------- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 33 -------------------------- 5 files changed, 7 insertions(+), 112 deletions(-) -- 2.17.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h index 1fa3e53e857d..c1b56b482a23 100644 --- a/drivers/scsi/hisi_sas/hisi_sas.h +++ b/drivers/scsi/hisi_sas/hisi_sas.h @@ -260,7 +260,6 @@ struct hisi_sas_hw { struct domain_device *device); struct hisi_sas_device *(*alloc_dev)(struct domain_device *device); void (*sl_notify_ssp)(struct hisi_hba *hisi_hba, int phy_no); - int (*get_free_slot)(struct hisi_hba *hisi_hba, struct hisi_sas_dq *dq); void (*start_delivery)(struct hisi_sas_dq *dq); void (*prep_ssp)(struct hisi_hba *hisi_hba, struct hisi_sas_slot *slot); diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 94c7c2b48b17..54bbab7151c7 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -519,13 +519,8 @@ static int hisi_sas_task_prep(struct sas_task *task, slot = &hisi_hba->slot_info[slot_idx]; spin_lock_irqsave(&dq->lock, flags); - wr_q_index = hisi_hba->hw->get_free_slot(hisi_hba, dq); - if (wr_q_index < 0) { - spin_unlock_irqrestore(&dq->lock, flags); - rc = -EAGAIN; - goto err_out_tag; - } - + wr_q_index = dq->wr_point; + dq->wr_point = (dq->wr_point + 1) % HISI_SAS_QUEUE_SLOTS; list_add_tail(&slot->delivery, &dq->list); spin_unlock_irqrestore(&dq->lock, flags); spin_lock_irqsave(&sas_dev->lock, flags); @@ -579,8 +574,6 @@ static int hisi_sas_task_prep(struct sas_task *task, return 0; -err_out_tag: - hisi_sas_slot_index_free(hisi_hba, slot_idx); err_out_dif_dma_unmap: if (!sas_protocol_ata(task->task_proto)) hisi_sas_dif_dma_unmap(hisi_hba, task, n_elem_dif); @@ -1963,7 +1956,7 @@ hisi_sas_internal_abort_task_exec(struct hisi_hba *hisi_hba, int device_id, struct asd_sas_port *sas_port = device->port; struct hisi_sas_cmd_hdr *cmd_hdr_base; int dlvry_queue_slot, dlvry_queue, n_elem = 0, rc, slot_idx; - unsigned long flags, flags_dq = 0; + unsigned long flags; int wr_q_index; if (unlikely(test_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags))) @@ -1982,15 +1975,11 @@ hisi_sas_internal_abort_task_exec(struct hisi_hba *hisi_hba, int device_id, slot_idx = rc; slot = &hisi_hba->slot_info[slot_idx]; - spin_lock_irqsave(&dq->lock, flags_dq); - wr_q_index = hisi_hba->hw->get_free_slot(hisi_hba, dq); - if (wr_q_index < 0) { - spin_unlock_irqrestore(&dq->lock, flags_dq); - rc = -EAGAIN; - goto err_out_tag; - } + spin_lock_irqsave(&dq->lock, flags); + wr_q_index = dq->wr_point; + dq->wr_point = (dq->wr_point + 1) % HISI_SAS_QUEUE_SLOTS; list_add_tail(&slot->delivery, &dq->list); - spin_unlock_irqrestore(&dq->lock, flags_dq); + spin_unlock_irqrestore(&dq->lock, flags); spin_lock_irqsave(&sas_dev->lock, flags); list_add_tail(&slot->entry, &sas_dev->list); spin_unlock_irqrestore(&sas_dev->lock, flags); @@ -2027,8 +2016,6 @@ hisi_sas_internal_abort_task_exec(struct hisi_hba *hisi_hba, int device_id, return 0; -err_out_tag: - hisi_sas_slot_index_free(hisi_hba, slot_idx); err_out: dev_err(dev, "internal abort task prep: failed[%d]!\n", rc); diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c index afdbaccbbc5e..b13cbc64d2a9 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c @@ -416,13 +416,6 @@ static u32 hisi_sas_read32(struct hisi_hba *hisi_hba, u32 off) return readl(regs); } -static u32 hisi_sas_read32_relaxed(struct hisi_hba *hisi_hba, u32 off) -{ - void __iomem *regs = hisi_hba->regs + off; - - return readl_relaxed(regs); -} - static void hisi_sas_write32(struct hisi_hba *hisi_hba, u32 off, u32 val) { @@ -864,30 +857,6 @@ static int get_wideport_bitmap_v1_hw(struct hisi_hba *hisi_hba, int port_id) return bitmap; } -/* - * The callpath to this function and upto writing the write - * queue pointer should be safe from interruption. - */ -static int -get_free_slot_v1_hw(struct hisi_hba *hisi_hba, struct hisi_sas_dq *dq) -{ - struct device *dev = hisi_hba->dev; - int queue = dq->id; - u32 r, w; - - w = dq->wr_point; - r = hisi_sas_read32_relaxed(hisi_hba, - DLVRY_Q_0_RD_PTR + (queue * 0x14)); - if (r == (w+1) % HISI_SAS_QUEUE_SLOTS) { - dev_warn(dev, "could not find free slot\n"); - return -EAGAIN; - } - - dq->wr_point = (dq->wr_point + 1) % HISI_SAS_QUEUE_SLOTS; - - return w; -} - /* DQ lock must be taken here */ static void start_delivery_v1_hw(struct hisi_sas_dq *dq) { @@ -1818,7 +1787,6 @@ static const struct hisi_sas_hw hisi_sas_v1_hw = { .clear_itct = clear_itct_v1_hw, .prep_smp = prep_smp_v1_hw, .prep_ssp = prep_ssp_v1_hw, - .get_free_slot = get_free_slot_v1_hw, .start_delivery = start_delivery_v1_hw, .slot_complete = slot_complete_v1_hw, .phys_init = phys_init_v1_hw, diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c index fc98bd9e5588..de33e31cd88a 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c @@ -1637,31 +1637,6 @@ static int get_wideport_bitmap_v2_hw(struct hisi_hba *hisi_hba, int port_id) return bitmap; } -/* - * The callpath to this function and upto writing the write - * queue pointer should be safe from interruption. - */ -static int -get_free_slot_v2_hw(struct hisi_hba *hisi_hba, struct hisi_sas_dq *dq) -{ - struct device *dev = hisi_hba->dev; - int queue = dq->id; - u32 r, w; - - w = dq->wr_point; - r = hisi_sas_read32_relaxed(hisi_hba, - DLVRY_Q_0_RD_PTR + (queue * 0x14)); - if (r == (w+1) % HISI_SAS_QUEUE_SLOTS) { - dev_warn(dev, "full queue=%d r=%d w=%d\n", - queue, r, w); - return -EAGAIN; - } - - dq->wr_point = (dq->wr_point + 1) % HISI_SAS_QUEUE_SLOTS; - - return w; -} - /* DQ lock must be taken here */ static void start_delivery_v2_hw(struct hisi_sas_dq *dq) { @@ -3606,7 +3581,6 @@ static const struct hisi_sas_hw hisi_sas_v2_hw = { .prep_ssp = prep_ssp_v2_hw, .prep_stp = prep_ata_v2_hw, .prep_abort = prep_abort_v2_hw, - .get_free_slot = get_free_slot_v2_hw, .start_delivery = start_delivery_v2_hw, .slot_complete = slot_complete_v2_hw, .phys_init = phys_init_v2_hw, diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index 0171cdb4da81..b99abc788487 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -499,13 +499,6 @@ static u32 hisi_sas_read32(struct hisi_hba *hisi_hba, u32 off) return readl(regs); } -static u32 hisi_sas_read32_relaxed(struct hisi_hba *hisi_hba, u32 off) -{ - void __iomem *regs = hisi_hba->regs + off; - - return readl_relaxed(regs); -} - static void hisi_sas_write32(struct hisi_hba *hisi_hba, u32 off, u32 val) { void __iomem *regs = hisi_hba->regs + off; @@ -1006,31 +999,6 @@ static int get_wideport_bitmap_v3_hw(struct hisi_hba *hisi_hba, int port_id) return bitmap; } -/** - * The callpath to this function and upto writing the write - * queue pointer should be safe from interruption. - */ -static int -get_free_slot_v3_hw(struct hisi_hba *hisi_hba, struct hisi_sas_dq *dq) -{ - struct device *dev = hisi_hba->dev; - int queue = dq->id; - u32 r, w; - - w = dq->wr_point; - r = hisi_sas_read32_relaxed(hisi_hba, - DLVRY_Q_0_RD_PTR + (queue * 0x14)); - if (r == (w+1) % HISI_SAS_QUEUE_SLOTS) { - dev_warn(dev, "full queue=%d r=%d w=%d\n", - queue, r, w); - return -EAGAIN; - } - - dq->wr_point = (dq->wr_point + 1) % HISI_SAS_QUEUE_SLOTS; - - return w; -} - static void start_delivery_v3_hw(struct hisi_sas_dq *dq) { struct hisi_hba *hisi_hba = dq->hisi_hba; @@ -2943,7 +2911,6 @@ static const struct hisi_sas_hw hisi_sas_v3_hw = { .prep_smp = prep_smp_v3_hw, .prep_stp = prep_ata_v3_hw, .prep_abort = prep_abort_v3_hw, - .get_free_slot = get_free_slot_v3_hw, .start_delivery = start_delivery_v3_hw, .slot_complete = slot_complete_v3_hw, .phys_init = phys_init_v3_hw, From patchwork Mon Aug 5 13:48:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 170557 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp4321633ile; Mon, 5 Aug 2019 06:50:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqw9NmGurwoJ7L/2HUb2+bsQzEtxooeL1VLygZUYZpGRENBl1+aAbEynofw1XsYtaBIN+Ga5 X-Received: by 2002:a17:902:900a:: with SMTP id a10mr30798901plp.281.1565013023244; Mon, 05 Aug 2019 06:50:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565013023; cv=none; d=google.com; s=arc-20160816; b=hqSVAJ1ove0Tt0UilGJfmidFinuZXF9lSma1ZahJdxtWGa0ZZ8mP1LlDXH2f5gOMQf l+Uc4ylFKMNtGw3HLc55tt8VKQL3QlDZDFsdgYApioef/XUhBKcDFNqmeZPWqEn4uG0c GsTaaWcxVcSSQJoJp6oCWmUpFORwTJ00c9R+HWjnqTiEfKWrjXyRC0j0E1EYDUXHFjbt /8TKQ1tUHYq1TVIkI5QLkMy2CzYLwg3ui0J2GkKrGRzMagSg8SxvD+iUThUbeuhs62/l KEpYJLNS5cr0xX8h3+E7bRI/xtBtfQImMNfJu26TeDDfH2kunyKlRLw8DfgFGyXcc74g UsuQ== 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=pEC+W9BeJiyhXVI2L8hUCtId7n90aXzDdj5JQbUJ5Lg=; b=q2VJPSMi5ULDIwxUdMhAkQ7T/V3XG4BkJpZ8cl3FjXUq3gej+hUPA5+j0x4lkcvZ4Z AgcplbJa5y9R3ZJq1NS2YtRgt+mfYydABkwwil4eWAVgmCwolnUQZ4TPm9WBzfQ3+mAZ 3UNqwqdn4xhPu1EfQY2BhW7b4ho72TvT1NMATzwTvbdd9c7zVLzceyOzojgFf+lFxure sy+vkYutSzAZEI0AcFi7OUxDm0cswPn3YbqK5/zfYMW8/keRXyIvBljupUEEuo1ZK235 XN1WV2PSt4eah5fspY3O3O6fF74AbSEHO6DY5O+INZ5EDjNk/FM/pV02fAecMlyVhGNe IFfg== 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 73si43449528pfa.123.2019.08.05.06.50.22; Mon, 05 Aug 2019 06:50:23 -0700 (PDT) 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 S1729403AbfHENuV (ORCPT + 29 others); Mon, 5 Aug 2019 09:50:21 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:34658 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728815AbfHENuU (ORCPT ); Mon, 5 Aug 2019 09:50:20 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id E507AC09D589F8D79A86; Mon, 5 Aug 2019 21:50:18 +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:12 +0800 From: John Garry To: , CC: , , , Luo Jiaxing , John Garry Subject: [PATCH 03/15] scsi: hisi_sas: Fix pointer usage error in show debugfs IOST/ITCT Date: Mon, 5 Aug 2019 21:48:00 +0800 Message-ID: <1565012892-75940-4-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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Luo Jiaxing Fix how the pointer is set in hisi_sas_debugfs_iost_show() and hisi_sas_debugfs_itct_show(). Signed-off-by: Luo Jiaxing 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 54bbab7151c7..325ec4306794 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -2992,9 +2992,10 @@ static int hisi_sas_debugfs_iost_show(struct seq_file *s, void *p) struct hisi_hba *hisi_hba = s->private; struct hisi_sas_iost *debugfs_iost = hisi_hba->debugfs_iost; int i, ret, max_command_entries = HISI_SAS_MAX_COMMANDS; - __le64 *iost = &debugfs_iost->qw0; for (i = 0; i < max_command_entries; i++, debugfs_iost++) { + __le64 *iost = &debugfs_iost->qw0; + ret = hisi_sas_show_row_64(s, i, sizeof(*debugfs_iost), iost); if (ret) @@ -3022,9 +3023,10 @@ static int hisi_sas_debugfs_itct_show(struct seq_file *s, void *p) int i, ret; struct hisi_hba *hisi_hba = s->private; struct hisi_sas_itct *debugfs_itct = hisi_hba->debugfs_itct; - __le64 *itct = &debugfs_itct->qw0; for (i = 0; i < HISI_SAS_MAX_ITCT_ENTRIES; i++, debugfs_itct++) { + __le64 *itct = &debugfs_itct->qw0; + ret = hisi_sas_show_row_64(s, i, sizeof(*debugfs_itct), itct); if (ret) From patchwork Mon Aug 5 13:48:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 170570 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp4340624ile; Mon, 5 Aug 2019 07:06:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqzIPvkakStYX6oXn/B2M2dWJ7U2yEMVmMe2kYO2ioWa7+5jZi3ij2mbwAbk7AjNbeIQk/3X X-Received: by 2002:a62:3c3:: with SMTP id 186mr73189425pfd.21.1565013977901; Mon, 05 Aug 2019 07:06:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565013977; cv=none; d=google.com; s=arc-20160816; b=N0WFWp3CBtLaoYKc5BZHBj8yomBmky+PJojPH/xo2kmw2MRdv6NgGddE7nSTEoHWyZ /xAmYyD7cmLu6PZC7x/NOydmtJjxYLzCzHCG9Pcip67k+eDffWnKYO2ffCxoDzrcccJw Fenu4QiysKdfIggmQji+C5v8gtW4waUX3bjq3Frm2bgT5e6OVVU6hbCXViA0jn1KviFw S6f6gpYT/lH9bnh0G7AexEKpb5+IjnRdY6aV6SHNtlQ0/dMYb5a8WlKvxbpjICTZHEOv M9e0l5Q4BIK9m5i+D95QfHo2oZL3mzx4A73jQ3YgTczGJWQFSotm8VaFc+q4euXGMC00 0JHQ== 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=gFevK7/os4jj7c5hs7z2z1GpZgGZs5SVW8//I2ZUshk=; b=duCz8O8yU3c3g2BjVo17qko/P+brRdxNKwjXF0i9XjKNJ/Gx9o6DrICh5e1OF3VoDs rq0PehFk2zqUXC9DGgLPx9EEKqCeNoKF2Is4goNRB/pgyqMymE2/EopYbErjL9yFzyx1 j/cY5NYG9Ty3WBRduUSifAwZlmjxLRbPw9CqUF1rKpo/IKZWVZJDyEP8S3rYs6v3cZJP cF8w+LAssCuQC54svS/FXpaWAqRUE7a/qWl9jEX9SKvExVTjf2aKPbJUOgYUZu6Nv4Ut wyg6hE4ivg5CNhcro+sJH2U9h7yARpGLUOFcpxhaN3EqlK8lFdEKd537KazNBepqSzcf ammg== 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 d7si39875799plr.18.2019.08.05.07.06.17; Mon, 05 Aug 2019 07:06:17 -0700 (PDT) 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 S1729208AbfHEOGQ (ORCPT + 29 others); Mon, 5 Aug 2019 10:06:16 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:50538 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728975AbfHEOGQ (ORCPT ); Mon, 5 Aug 2019 10:06:16 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id E946B22149A80DF7A813; Mon, 5 Aug 2019 21:50:18 +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:12 +0800 From: John Garry To: , CC: , , , Luo Jiaxing , John Garry Subject: [PATCH 04/15] scsi: hisi_sas: Snapshot HW cache of IOST and ITCT at debugfs Date: Mon, 5 Aug 2019 21:48:01 +0800 Message-ID: <1565012892-75940-5-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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Luo Jiaxing The value of IOST/ITCT is update to cache first, and then synchronize to DDR periodically. So the value in IOST/ITCT cache is the latest data and it's important for debug. So, the HW cache of IOST and ITCT should be snapshot at debugfs. Signed-off-by: Luo Jiaxing Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas.h | 17 ++++ drivers/scsi/hisi_sas/hisi_sas_main.c | 114 ++++++++++++++++++++++++- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 32 +++++++ 3 files changed, 161 insertions(+), 2 deletions(-) -- 2.17.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h index c1b56b482a23..5a2fbbbed53e 100644 --- a/drivers/scsi/hisi_sas/hisi_sas.h +++ b/drivers/scsi/hisi_sas/hisi_sas.h @@ -36,6 +36,9 @@ #define HISI_SAS_UNRESERVED_IPTT \ (HISI_SAS_MAX_COMMANDS - HISI_SAS_RESERVED_IPTT) +#define HISI_SAS_IOST_ITCT_CACHE_NUM 64 +#define HISI_SAS_IOST_ITCT_CACHE_DW_SZ 10 + #define HISI_SAS_STATUS_BUF_SZ (sizeof(struct hisi_sas_status_buffer)) #define HISI_SAS_COMMAND_TABLE_SZ (sizeof(union hisi_sas_command_table)) @@ -252,6 +255,15 @@ struct hisi_sas_debugfs_reg { }; }; +struct hisi_sas_iost_itct_cache { + u32 data[HISI_SAS_IOST_ITCT_CACHE_DW_SZ]; +}; + +enum hisi_sas_debugfs_cache_type { + HISI_SAS_ITCT_CACHE, + HISI_SAS_IOST_CACHE, +}; + struct hisi_sas_hw { int (*hw_init)(struct hisi_hba *hisi_hba); void (*setup_itct)(struct hisi_hba *hisi_hba, @@ -294,6 +306,9 @@ struct hisi_sas_hw { int delay_ms, int timeout_ms); void (*snapshot_prepare)(struct hisi_hba *hisi_hba); void (*snapshot_restore)(struct hisi_hba *hisi_hba); + void (*read_iost_itct_cache)(struct hisi_hba *hisi_hba, + enum hisi_sas_debugfs_cache_type type, + u32 *cache); int complete_hdr_size; struct scsi_host_template *sht; @@ -379,6 +394,8 @@ struct hisi_hba { struct hisi_sas_cmd_hdr *debugfs_cmd_hdr[HISI_SAS_MAX_QUEUES]; struct hisi_sas_iost *debugfs_iost; struct hisi_sas_itct *debugfs_itct; + u64 *debugfs_iost_cache; + u64 *debugfs_itct_cache; struct dentry *debugfs_dir; struct dentry *debugfs_dump_dentry; diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 325ec4306794..240b6faaf25f 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -2763,10 +2763,14 @@ static void hisi_sas_debugfs_snapshot_global_reg(struct hisi_hba *hisi_hba) static void hisi_sas_debugfs_snapshot_itct_reg(struct hisi_hba *hisi_hba) { + void *cachebuf = hisi_hba->debugfs_itct_cache; void *databuf = hisi_hba->debugfs_itct; struct hisi_sas_itct *itct; int i; + hisi_hba->hw->read_iost_itct_cache(hisi_hba, HISI_SAS_ITCT_CACHE, + cachebuf); + itct = hisi_hba->itct; for (i = 0; i < HISI_SAS_MAX_ITCT_ENTRIES; i++, itct++) { @@ -2778,10 +2782,14 @@ static void hisi_sas_debugfs_snapshot_itct_reg(struct hisi_hba *hisi_hba) static void hisi_sas_debugfs_snapshot_iost_reg(struct hisi_hba *hisi_hba) { int max_command_entries = HISI_SAS_MAX_COMMANDS; + void *cachebuf = hisi_hba->debugfs_iost_cache; void *databuf = hisi_hba->debugfs_iost; struct hisi_sas_iost *iost; int i; + hisi_hba->hw->read_iost_itct_cache(hisi_hba, HISI_SAS_IOST_CACHE, + cachebuf); + iost = hisi_hba->iost; for (i = 0; i < max_command_entries; i++, iost++) { @@ -3018,6 +3026,46 @@ static const struct file_operations hisi_sas_debugfs_iost_fops = { .owner = THIS_MODULE, }; +static int hisi_sas_debugfs_iost_cache_show(struct seq_file *s, void *p) +{ + struct hisi_hba *hisi_hba = s->private; + struct hisi_sas_iost_itct_cache *iost_cache = + (struct hisi_sas_iost_itct_cache *)hisi_hba->debugfs_iost_cache; + u32 cache_size = HISI_SAS_IOST_ITCT_CACHE_DW_SZ * 4; + int i, tab_idx; + __le64 *iost; + + for (i = 0; i < HISI_SAS_IOST_ITCT_CACHE_NUM; i++, iost_cache++) { + /* + * Data struct of IOST cache: + * Data[1]: BIT0~15: Table index + * Bit16: Valid mask + * Data[2]~[9]: IOST table + */ + tab_idx = (iost_cache->data[1] & 0xffff); + iost = (__le64 *)iost_cache; + + hisi_sas_show_row_64(s, tab_idx, cache_size, iost); + } + + return 0; +} + +static int hisi_sas_debugfs_iost_cache_open(struct inode *inode, + struct file *filp) +{ + return single_open(filp, hisi_sas_debugfs_iost_cache_show, + inode->i_private); +} + +static const struct file_operations hisi_sas_debugfs_iost_cache_fops = { + .open = hisi_sas_debugfs_iost_cache_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, + .owner = THIS_MODULE, +}; + static int hisi_sas_debugfs_itct_show(struct seq_file *s, void *p) { int i, ret; @@ -3049,6 +3097,46 @@ static const struct file_operations hisi_sas_debugfs_itct_fops = { .owner = THIS_MODULE, }; +static int hisi_sas_debugfs_itct_cache_show(struct seq_file *s, void *p) +{ + struct hisi_hba *hisi_hba = s->private; + struct hisi_sas_iost_itct_cache *itct_cache = + (struct hisi_sas_iost_itct_cache *)hisi_hba->debugfs_itct_cache; + u32 cache_size = HISI_SAS_IOST_ITCT_CACHE_DW_SZ * 4; + int i, tab_idx; + __le64 *itct; + + for (i = 0; i < HISI_SAS_IOST_ITCT_CACHE_NUM; i++, itct_cache++) { + /* + * Data struct of ITCT cache: + * Data[1]: BIT0~15: Table index + * Bit16: Valid mask + * Data[2]~[9]: ITCT table + */ + tab_idx = itct_cache->data[1] & 0xffff; + itct = (__le64 *)itct_cache; + + hisi_sas_show_row_64(s, tab_idx, cache_size, itct); + } + + return 0; +} + +static int hisi_sas_debugfs_itct_cache_open(struct inode *inode, + struct file *filp) +{ + return single_open(filp, hisi_sas_debugfs_itct_cache_show, + inode->i_private); +} + +static const struct file_operations hisi_sas_debugfs_itct_cache_fops = { + .open = hisi_sas_debugfs_itct_cache_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, + .owner = THIS_MODULE, +}; + static void hisi_sas_debugfs_create_files(struct hisi_hba *hisi_hba) { struct dentry *dump_dentry; @@ -3095,9 +3183,15 @@ static void hisi_sas_debugfs_create_files(struct hisi_hba *hisi_hba) debugfs_create_file("iost", 0400, dump_dentry, hisi_hba, &hisi_sas_debugfs_iost_fops); + debugfs_create_file("iost_cache", 0400, dump_dentry, hisi_hba, + &hisi_sas_debugfs_iost_cache_fops); + debugfs_create_file("itct", 0400, dump_dentry, hisi_hba, &hisi_sas_debugfs_itct_fops); + debugfs_create_file("itct_cache", 0400, dump_dentry, hisi_hba, + &hisi_sas_debugfs_itct_cache_fops); + return; } @@ -3212,14 +3306,26 @@ void hisi_sas_debugfs_init(struct hisi_hba *hisi_hba) goto fail_iost_dq; } - /* Alloc buffer for iost */ sz = max_command_entries * sizeof(struct hisi_sas_iost); hisi_hba->debugfs_iost = devm_kmalloc(dev, sz, GFP_KERNEL); if (!hisi_hba->debugfs_iost) goto fail_iost_dq; - /* Alloc buffer for itct */ + sz = HISI_SAS_IOST_ITCT_CACHE_NUM * + sizeof(struct hisi_sas_iost_itct_cache); + + hisi_hba->debugfs_iost_cache = devm_kmalloc(dev, sz, GFP_KERNEL); + if (!hisi_hba->debugfs_iost_cache) + goto fail_iost_cache; + + sz = HISI_SAS_IOST_ITCT_CACHE_NUM * + sizeof(struct hisi_sas_iost_itct_cache); + + hisi_hba->debugfs_itct_cache = devm_kmalloc(dev, sz, GFP_KERNEL); + if (!hisi_hba->debugfs_itct_cache) + goto fail_itct_cache; + /* New memory allocation must be locate before itct */ sz = HISI_SAS_MAX_ITCT_ENTRIES * sizeof(struct hisi_sas_itct); @@ -3229,6 +3335,10 @@ void hisi_sas_debugfs_init(struct hisi_hba *hisi_hba) return; fail_itct: + devm_kfree(dev, hisi_hba->debugfs_iost_cache); +fail_itct_cache: + devm_kfree(dev, hisi_hba->debugfs_iost_cache); +fail_iost_cache: devm_kfree(dev, hisi_hba->debugfs_iost); fail_iost_dq: for (i = 0; i < d; i++) diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index b99abc788487..c8ca6ead639b 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -71,6 +71,7 @@ #define HGC_DQE_ECC_MB_ADDR_OFF 16 #define HGC_DQE_ECC_MB_ADDR_MSK (0xfff << HGC_DQE_ECC_MB_ADDR_OFF) #define CHNL_INT_STATUS 0x148 +#define TAB_DFX 0x14c #define HGC_ITCT_ECC_ADDR 0x150 #define HGC_ITCT_ECC_1B_ADDR_OFF 0 #define HGC_ITCT_ECC_1B_ADDR_MSK (0x3ff << \ @@ -83,6 +84,7 @@ #define AXI_ERR_INFO_MSK (0xff << AXI_ERR_INFO_OFF) #define FIFO_ERR_INFO_OFF 8 #define FIFO_ERR_INFO_MSK (0xff << FIFO_ERR_INFO_OFF) +#define TAB_RD_TYPE 0x15c #define INT_COAL_EN 0x19c #define OQ_INT_COAL_TIME 0x1a0 #define OQ_INT_COAL_CNT 0x1a4 @@ -2877,6 +2879,35 @@ static void debugfs_snapshot_restore_v3_hw(struct hisi_hba *hisi_hba) clear_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags); } +static void read_iost_itct_cache_v3_hw(struct hisi_hba *hisi_hba, + enum hisi_sas_debugfs_cache_type type, + u32 *cache) +{ + u32 cache_dw_size = HISI_SAS_IOST_ITCT_CACHE_DW_SZ * + HISI_SAS_IOST_ITCT_CACHE_NUM; + u32 *buf = cache; + u32 i, val; + + hisi_sas_write32(hisi_hba, TAB_RD_TYPE, type); + + for (i = 0; i < HISI_SAS_IOST_ITCT_CACHE_DW_SZ; i++) { + val = hisi_sas_read32(hisi_hba, TAB_DFX); + if (val == 0xffffffff) + break; + } + + if (val != 0xffffffff) { + pr_err("Issue occur when reading IOST/ITCT cache!\n"); + return; + } + + memset(buf, 0, cache_dw_size * 4); + buf[0] = val; + + for (i = 1; i < cache_dw_size; i++) + buf[i] = hisi_sas_read32(hisi_hba, TAB_DFX); +} + static struct scsi_host_template sht_v3_hw = { .name = DRV_NAME, .module = THIS_MODULE, @@ -2929,6 +2960,7 @@ static const struct hisi_sas_hw hisi_sas_v3_hw = { .debugfs_reg_port = &debugfs_port_reg, .snapshot_prepare = debugfs_snapshot_prepare_v3_hw, .snapshot_restore = debugfs_snapshot_restore_v3_hw, + .read_iost_itct_cache = read_iost_itct_cache_v3_hw, }; static struct Scsi_Host * From patchwork Mon Aug 5 13:48:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 170563 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp4321798ile; Mon, 5 Aug 2019 06:50:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqzDzUSYiS7L3Okq2d5Ng2uDSM+1+ET65o9Bh2wZoQa0Y9R77BJCeHBflQIkZJUnipsPQ0HJ X-Received: by 2002:a17:90a:ac11:: with SMTP id o17mr18429231pjq.134.1565013030411; 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=JpW2up2+CH0QL9NFKjCzqf1TRxZkHGa+NZmW9AC8IeDMfCy/jsfpWUHSx3d/mmdb3l P+p/4OHBLyL0P/vze1aGhFzfLnOxrqRYqcQwzG8vXFbzDbCIgoO5Dby0sochmuNPN9x2 vhJYd/sSLXtRlLhwb1rYhQ5qu8HIP9OOkrrTR7aHETcY50qN7z8so9fq8Jcq2TaQ+Ck2 a3VuXetiyy1YP+YwXzT8KimNZC/Biy5nQH1Qd4JmSovjHMO//w4Hm3NXM1BhAo7joGcr H3gcKili292Bp0P2PyW6nQnTCbXU6ZaXe0POlxlAA072WqOcw051zf/WlxVsOwk9onNA nGpA== 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=Ip+UFGw0MvONvr9x+QeSW/eStwmsXBl4CPxId9yykkg=; b=MAe7UHuWIPXEHZkhcWm5MKeQPqJQ0oeOCwt39HldUVR2Zc0ffTmTZwWV7j2I8FfAMf XAIG2Y2WLXpZ7PPNV8QHAvwoqOgQjUGFXypTmbpaUbtgWuypjzfvKpqVjDnuRLOV0c57 uDMgDPzTA+ONpqnB+8//L/1SyZq3ko4ngCUy0MTGZ9ukmfroE5CkK7GAevFlkOdlaQv7 TEqdurS9qLnmmPUk7W8Z15FWBlUE3wAJSuUohibKgWJlTFQK9W/cqoYabmJnoP3PrigJ VNN/td5X5F+xKsHZfpzEQPPeXWqnQXMmjOHZRtt8NqrYELZ8oqnkRl2vtv71Zvzcv/Us sMdA== 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 k13si45940146pfa.17.2019.08.05.06.50.30; Mon, 05 Aug 2019 06:50:30 -0700 (PDT) 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 S1730005AbfHENu3 (ORCPT + 29 others); Mon, 5 Aug 2019 09:50:29 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:44494 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729623AbfHENu1 (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 11B0426FC82EBB493845; 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: , , , Luo Jiaxing , John Garry Subject: [PATCH 05/15] scsi: hisi_sas: Snapshot AXI and RAS register at debugfs Date: Mon, 5 Aug 2019 21:48:02 +0800 Message-ID: <1565012892-75940-6-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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Luo Jiaxing The AXI and RAS register values should also should be snapshot at debugfs. Signed-off-by: Luo Jiaxing Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas.h | 12 ++- drivers/scsi/hisi_sas/hisi_sas_main.c | 132 ++++++++++++++++++++++--- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 36 ++++++- 3 files changed, 162 insertions(+), 18 deletions(-) -- 2.17.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h index 5a2fbbbed53e..fd998d07ffcd 100644 --- a/drivers/scsi/hisi_sas/hisi_sas.h +++ b/drivers/scsi/hisi_sas/hisi_sas.h @@ -259,6 +259,13 @@ struct hisi_sas_iost_itct_cache { u32 data[HISI_SAS_IOST_ITCT_CACHE_DW_SZ]; }; +enum hisi_sas_debugfs_reg_array_member { + DEBUGFS_GLOBAL = 0, + DEBUGFS_AXI, + DEBUGFS_RAS, + DEBUGFS_REGS_NUM +}; + enum hisi_sas_debugfs_cache_type { HISI_SAS_ITCT_CACHE, HISI_SAS_IOST_CACHE, @@ -312,7 +319,7 @@ struct hisi_sas_hw { int complete_hdr_size; struct scsi_host_template *sht; - const struct hisi_sas_debugfs_reg *debugfs_reg_global; + const struct hisi_sas_debugfs_reg *debugfs_reg_array[DEBUGFS_REGS_NUM]; const struct hisi_sas_debugfs_reg *debugfs_reg_port; }; @@ -388,7 +395,8 @@ struct hisi_hba { unsigned int *reply_map; /* debugfs memories */ - u32 *debugfs_global_reg; + /* Put Global AXI and RAS Register into register array */ + u32 *debugfs_regs[DEBUGFS_REGS_NUM]; u32 *debugfs_port_reg[HISI_SAS_MAX_PHYS]; void *debugfs_complete_hdr[HISI_SAS_MAX_QUEUES]; struct hisi_sas_cmd_hdr *debugfs_cmd_hdr[HISI_SAS_MAX_QUEUES]; diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 240b6faaf25f..04b3b0040059 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -2752,15 +2752,42 @@ static void hisi_sas_debugfs_snapshot_port_reg(struct hisi_hba *hisi_hba) static void hisi_sas_debugfs_snapshot_global_reg(struct hisi_hba *hisi_hba) { - u32 *databuf = (u32 *)hisi_hba->debugfs_global_reg; + u32 *databuf = hisi_hba->debugfs_regs[DEBUGFS_GLOBAL]; + const struct hisi_sas_hw *hw = hisi_hba->hw; const struct hisi_sas_debugfs_reg *global = - hisi_hba->hw->debugfs_reg_global; + hw->debugfs_reg_array[DEBUGFS_GLOBAL]; int i; for (i = 0; i < global->count; i++, databuf++) *databuf = global->read_global_reg(hisi_hba, 4 * i); } +static void hisi_sas_debugfs_snapshot_axi_reg(struct hisi_hba *hisi_hba) +{ + u32 *databuf = hisi_hba->debugfs_regs[DEBUGFS_AXI]; + const struct hisi_sas_hw *hw = hisi_hba->hw; + const struct hisi_sas_debugfs_reg *axi = + hw->debugfs_reg_array[DEBUGFS_AXI]; + int i; + + for (i = 0; i < axi->count; i++, databuf++) + *databuf = axi->read_global_reg(hisi_hba, + 4 * i + axi->base_off); +} + +static void hisi_sas_debugfs_snapshot_ras_reg(struct hisi_hba *hisi_hba) +{ + u32 *databuf = hisi_hba->debugfs_regs[DEBUGFS_RAS]; + const struct hisi_sas_hw *hw = hisi_hba->hw; + const struct hisi_sas_debugfs_reg *ras = + hw->debugfs_reg_array[DEBUGFS_RAS]; + int i; + + for (i = 0; i < ras->count; i++, databuf++) + *databuf = ras->read_global_reg(hisi_hba, + 4 * i + ras->base_off); +} + static void hisi_sas_debugfs_snapshot_itct_reg(struct hisi_hba *hisi_hba) { void *cachebuf = hisi_hba->debugfs_itct_cache; @@ -2836,9 +2863,9 @@ static int hisi_sas_debugfs_global_show(struct seq_file *s, void *p) { struct hisi_hba *hisi_hba = s->private; const struct hisi_sas_hw *hw = hisi_hba->hw; - const struct hisi_sas_debugfs_reg *reg_global = hw->debugfs_reg_global; + const void *reg_global = hw->debugfs_reg_array[DEBUGFS_GLOBAL]; - hisi_sas_debugfs_print_reg(hisi_hba->debugfs_global_reg, + hisi_sas_debugfs_print_reg(hisi_hba->debugfs_regs[DEBUGFS_GLOBAL], reg_global, s); return 0; @@ -2858,6 +2885,58 @@ static const struct file_operations hisi_sas_debugfs_global_fops = { .owner = THIS_MODULE, }; +static int hisi_sas_debugfs_axi_show(struct seq_file *s, void *p) +{ + struct hisi_hba *hisi_hba = s->private; + const struct hisi_sas_hw *hw = hisi_hba->hw; + const void *reg_axi = hw->debugfs_reg_array[DEBUGFS_AXI]; + + hisi_sas_debugfs_print_reg(hisi_hba->debugfs_regs[DEBUGFS_AXI], + reg_axi, s); + + return 0; +} + +static int hisi_sas_debugfs_axi_open(struct inode *inode, struct file *filp) +{ + return single_open(filp, hisi_sas_debugfs_axi_show, + inode->i_private); +} + +static const struct file_operations hisi_sas_debugfs_axi_fops = { + .open = hisi_sas_debugfs_axi_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, + .owner = THIS_MODULE, +}; + +static int hisi_sas_debugfs_ras_show(struct seq_file *s, void *p) +{ + struct hisi_hba *hisi_hba = s->private; + const struct hisi_sas_hw *hw = hisi_hba->hw; + const void *reg_ras = hw->debugfs_reg_array[DEBUGFS_RAS]; + + hisi_sas_debugfs_print_reg(hisi_hba->debugfs_regs[DEBUGFS_RAS], + reg_ras, s); + + return 0; +} + +static int hisi_sas_debugfs_ras_open(struct inode *inode, struct file *filp) +{ + return single_open(filp, hisi_sas_debugfs_ras_show, + inode->i_private); +} + +static const struct file_operations hisi_sas_debugfs_ras_fops = { + .open = hisi_sas_debugfs_ras_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, + .owner = THIS_MODULE, +}; + static int hisi_sas_debugfs_port_show(struct seq_file *s, void *p) { struct hisi_sas_phy *phy = s->private; @@ -3192,6 +3271,12 @@ static void hisi_sas_debugfs_create_files(struct hisi_hba *hisi_hba) debugfs_create_file("itct_cache", 0400, dump_dentry, hisi_hba, &hisi_sas_debugfs_itct_cache_fops); + debugfs_create_file("axi", 0400, dump_dentry, hisi_hba, + &hisi_sas_debugfs_axi_fops); + + debugfs_create_file("ras", 0400, dump_dentry, hisi_hba, + &hisi_sas_debugfs_ras_fops); + return; } @@ -3201,6 +3286,8 @@ static void hisi_sas_debugfs_snapshot_regs(struct hisi_hba *hisi_hba) hisi_sas_debugfs_snapshot_global_reg(hisi_hba); hisi_sas_debugfs_snapshot_port_reg(hisi_hba); + hisi_sas_debugfs_snapshot_axi_reg(hisi_hba); + hisi_sas_debugfs_snapshot_ras_reg(hisi_hba); hisi_sas_debugfs_snapshot_cq_reg(hisi_hba); hisi_sas_debugfs_snapshot_dq_reg(hisi_hba); hisi_sas_debugfs_snapshot_itct_reg(hisi_hba); @@ -3257,6 +3344,7 @@ EXPORT_SYMBOL_GPL(hisi_sas_debugfs_work_handler); void hisi_sas_debugfs_init(struct hisi_hba *hisi_hba) { int max_command_entries = HISI_SAS_MAX_COMMANDS; + const struct hisi_sas_hw *hw = hisi_hba->hw; struct device *dev = hisi_hba->dev; int p, i, c, d; size_t sz; @@ -3268,16 +3356,14 @@ void hisi_sas_debugfs_init(struct hisi_hba *hisi_hba) hisi_hba, &hisi_sas_debugfs_trigger_dump_fops); - /* Alloc buffer for global */ - sz = hisi_hba->hw->debugfs_reg_global->count * 4; - hisi_hba->debugfs_global_reg = - devm_kmalloc(dev, sz, GFP_KERNEL); + sz = hw->debugfs_reg_array[DEBUGFS_GLOBAL]->count * 4; + hisi_hba->debugfs_regs[DEBUGFS_GLOBAL] = + devm_kmalloc(dev, sz, GFP_KERNEL); - if (!hisi_hba->debugfs_global_reg) + if (!hisi_hba->debugfs_regs[DEBUGFS_GLOBAL]) goto fail_global; - /* Alloc buffer for port */ - sz = hisi_hba->hw->debugfs_reg_port->count * 4; + sz = hw->debugfs_reg_port->count * 4; for (p = 0; p < hisi_hba->n_phy; p++) { hisi_hba->debugfs_port_reg[p] = devm_kmalloc(dev, sz, GFP_KERNEL); @@ -3286,8 +3372,21 @@ void hisi_sas_debugfs_init(struct hisi_hba *hisi_hba) goto fail_port; } - /* Alloc buffer for cq */ - sz = hisi_hba->hw->complete_hdr_size * HISI_SAS_QUEUE_SLOTS; + sz = hw->debugfs_reg_array[DEBUGFS_AXI]->count * 4; + hisi_hba->debugfs_regs[DEBUGFS_AXI] = + devm_kmalloc(dev, sz, GFP_KERNEL); + + if (!hisi_hba->debugfs_regs[DEBUGFS_AXI]) + goto fail_axi; + + sz = hw->debugfs_reg_array[DEBUGFS_RAS]->count * 4; + hisi_hba->debugfs_regs[DEBUGFS_RAS] = + devm_kmalloc(dev, sz, GFP_KERNEL); + + if (!hisi_hba->debugfs_regs[DEBUGFS_RAS]) + goto fail_ras; + + sz = hw->complete_hdr_size * HISI_SAS_QUEUE_SLOTS; for (c = 0; c < hisi_hba->queue_count; c++) { hisi_hba->debugfs_complete_hdr[c] = devm_kmalloc(dev, sz, GFP_KERNEL); @@ -3296,7 +3395,6 @@ void hisi_sas_debugfs_init(struct hisi_hba *hisi_hba) goto fail_cq; } - /* Alloc buffer for dq */ sz = sizeof(struct hisi_sas_cmd_hdr) * HISI_SAS_QUEUE_SLOTS; for (d = 0; d < hisi_hba->queue_count; d++) { hisi_hba->debugfs_cmd_hdr[d] = @@ -3346,10 +3444,14 @@ void hisi_sas_debugfs_init(struct hisi_hba *hisi_hba) fail_cq: for (i = 0; i < c; i++) devm_kfree(dev, hisi_hba->debugfs_complete_hdr[i]); + devm_kfree(dev, hisi_hba->debugfs_regs[DEBUGFS_RAS]); +fail_ras: + devm_kfree(dev, hisi_hba->debugfs_regs[DEBUGFS_AXI]); +fail_axi: fail_port: for (i = 0; i < p; i++) devm_kfree(dev, hisi_hba->debugfs_port_reg[i]); - devm_kfree(dev, hisi_hba->debugfs_global_reg); + devm_kfree(dev, hisi_hba->debugfs_regs[DEBUGFS_GLOBAL]); fail_global: debugfs_remove_recursive(hisi_hba->debugfs_dir); dev_dbg(dev, "failed to init debugfs!\n"); diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index c8ca6ead639b..072a39d5c4ad 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -2857,6 +2857,38 @@ static const struct hisi_sas_debugfs_reg debugfs_global_reg = { .read_global_reg = hisi_sas_read32, }; +static const struct hisi_sas_debugfs_reg_lu debugfs_axi_reg_lu[] = { + HISI_SAS_DEBUGFS_REG(AM_CFG_MAX_TRANS), + HISI_SAS_DEBUGFS_REG(AM_CFG_SINGLE_PORT_MAX_TRANS), + HISI_SAS_DEBUGFS_REG(AXI_CFG), + HISI_SAS_DEBUGFS_REG(AM_ROB_ECC_ERR_ADDR), + {} +}; + +static const struct hisi_sas_debugfs_reg debugfs_axi_reg = { + .lu = debugfs_axi_reg_lu, + .count = 0x61, + .base_off = AXI_MASTER_CFG_BASE, + .read_global_reg = hisi_sas_read32, +}; + +static const struct hisi_sas_debugfs_reg_lu debugfs_ras_reg_lu[] = { + HISI_SAS_DEBUGFS_REG(SAS_RAS_INTR1), + HISI_SAS_DEBUGFS_REG(SAS_RAS_INTR0_MASK), + HISI_SAS_DEBUGFS_REG(SAS_RAS_INTR1_MASK), + HISI_SAS_DEBUGFS_REG(CFG_SAS_RAS_INTR_MASK), + HISI_SAS_DEBUGFS_REG(SAS_RAS_INTR2), + HISI_SAS_DEBUGFS_REG(SAS_RAS_INTR2_MASK), + {} +}; + +static const struct hisi_sas_debugfs_reg debugfs_ras_reg = { + .lu = debugfs_ras_reg_lu, + .count = 0x10, + .base_off = RAS_BASE, + .read_global_reg = hisi_sas_read32, +}; + static void debugfs_snapshot_prepare_v3_hw(struct hisi_hba *hisi_hba) { struct device *dev = hisi_hba->dev; @@ -2956,7 +2988,9 @@ static const struct hisi_sas_hw hisi_sas_v3_hw = { .get_events = phy_get_events_v3_hw, .write_gpio = write_gpio_v3_hw, .wait_cmds_complete_timeout = wait_cmds_complete_timeout_v3_hw, - .debugfs_reg_global = &debugfs_global_reg, + .debugfs_reg_array[DEBUGFS_GLOBAL] = &debugfs_global_reg, + .debugfs_reg_array[DEBUGFS_AXI] = &debugfs_axi_reg, + .debugfs_reg_array[DEBUGFS_RAS] = &debugfs_ras_reg, .debugfs_reg_port = &debugfs_port_reg, .snapshot_prepare = debugfs_snapshot_prepare_v3_hw, .snapshot_restore = debugfs_snapshot_restore_v3_hw, From patchwork Mon Aug 5 13:48:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 170569 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp4322773ile; Mon, 5 Aug 2019 06:51:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqy51YsB3i4EI+UtU2MuaVbGhbcJIA4ISMEAD83W2GVbzY03TrrrB+nkMnuGzyI9AsGZpJiH X-Received: by 2002:aa7:9514:: with SMTP id b20mr74886544pfp.223.1565013086466; Mon, 05 Aug 2019 06:51:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565013086; cv=none; d=google.com; s=arc-20160816; b=WVd8BTnETAD6n74sJmO3NTE7lBV+SyRlvyuD0lgisItJQatuQ8PufF0CAPVGL5bTUB 9zElj34UJMD1LgVCB7c8oTbMXBusTr3W1eZjuR8exK/U/WWALLTO8ESZh931lBHHHYqk +x5SpU99VMedH9pClUTBwPgYtqo9ftGfL8SeIBkxWrev3I296pqbuAEEpXlpHfL6PSWK /COeR8f/DEQ4IVyfeeESlt9yfJuxsyqmwVwvZ0Fk05cm1wi9gk+Dnwz/Pajr4JOpF99g VkUhKCslKucycTxFcFhYSbvEOgUSTwU66M4Ig/A8sVAs5WV6ID7fM1MH49xe1jcOt+1o tR9w== 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=KwEy6xoV6bjbhye/nwPcz3PCTH+vHkKCoyQ8e4uYDik=; b=l890S48lbL00H4SP8OlO+z6hbePUq6GYwiveCoLM4gCgE8YCEGlDMl8SWdGLIDSmz+ pzHU+hlsA2104csv5rfYV6icRTeS87esZ/3LTXtp5/se3Ygpj1O4Qfeqx2vasYOCEmmL psemRsZEUIKqSs1PCboPKNgnMJHdv+KKjJa540qZBOOKqh+gET6wfx8ugr3myiRMpLRM gXUHHKJ2mZnPgOFuAhDnLBHpYCNbixCvflwUVFOoP3TiyRgvde9d9ymsKtvgHFBoIWuM 3f7uy4aVXhDKFl3s5rRD+PwiPufDNsBLmaEgBkxmKcSOO1zDhPKkoXQmtN080HHirDCb W1iw== 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 6si40509487plb.345.2019.08.05.06.51.26; Mon, 05 Aug 2019 06:51:26 -0700 (PDT) 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 S1730816AbfHENvZ (ORCPT + 29 others); Mon, 5 Aug 2019 09:51:25 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:44502 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728690AbfHENu0 (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 0D823BC74230D4495B06; 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: , , , Luo Jiaxing , John Garry Subject: [PATCH 06/15] scsi: hisi_sas: Fix out of bound at debug_I_T_nexus_reset() Date: Mon, 5 Aug 2019 21:48:03 +0800 Message-ID: <1565012892-75940-7-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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Luo Jiaxing Fix a possible out-of-bounds access in hisi_sas_debug_I_T_nexus_reset(). Signed-off-by: Luo Jiaxing Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_main.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 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 04b3b0040059..02ad91c01a44 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -1762,13 +1762,14 @@ static int hisi_sas_debug_I_T_nexus_reset(struct domain_device *device) struct hisi_sas_device *sas_dev = device->lldd_dev; struct hisi_hba *hisi_hba = dev_to_hisi_hba(device); struct sas_ha_struct *sas_ha = &hisi_hba->sha; - struct asd_sas_phy *sas_phy = sas_ha->sas_phy[local_phy->number]; - struct hisi_sas_phy *phy = container_of(sas_phy, - struct hisi_sas_phy, sas_phy); DECLARE_COMPLETION_ONSTACK(phyreset); int rc, reset_type; if (scsi_is_sas_phy_local(local_phy)) { + struct asd_sas_phy *sas_phy = + sas_ha->sas_phy[local_phy->number]; + struct hisi_sas_phy *phy = + container_of(sas_phy, struct hisi_sas_phy, sas_phy); phy->in_reset = 1; phy->reset_completion = &phyreset; } @@ -1780,6 +1781,10 @@ static int hisi_sas_debug_I_T_nexus_reset(struct domain_device *device) sas_put_local_phy(local_phy); if (scsi_is_sas_phy_local(local_phy)) { + struct asd_sas_phy *sas_phy = + sas_ha->sas_phy[local_phy->number]; + struct hisi_sas_phy *phy = + container_of(sas_phy, struct hisi_sas_phy, sas_phy); int ret = wait_for_completion_timeout(&phyreset, 2 * HZ); unsigned long flags; From patchwork Mon Aug 5 13:48:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 170565 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp4322341ile; Mon, 5 Aug 2019 06:51:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqxs9oQNXQaFJImgim14oWDIAGYRNshSvmhlnD0tkShf/upR3BZ4crjhJhbvFMaHy9cdAx5G X-Received: by 2002:a63:1908:: with SMTP id z8mr133071170pgl.433.1565013061508; Mon, 05 Aug 2019 06:51:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565013061; cv=none; d=google.com; s=arc-20160816; b=C0+ruvS7xIf7zJ/B7yrzs9zk9VQU0ccUt0w01s9/e5AdWcfdeZ42qLwM8k6sXkmoKo 2FhwBtRIriu7T8JObixnA44G+8oiw+8DigA7f1NtjOkDIFiaUdvjTVsDbUUVzksZW7pi BVej/k706XwitK41zIcehe/y4b7ysjgeovn/mArdST3l5szux3KLX0NoqJ7k/xpgFOvz DuZhk6QmZhb8jM9ENeRzcRhhyp+Rnnm6mk3i6ZCtoYz3s5ORN68ibMnMq93w31Tw8yA6 q8+alf6iIz2pmT/lh6LoadKkqbQxQEIGl6J98PEALpdoUN9h5CHs5CuiKIKru/UB6aTV GHUw== 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=iZOtmVuwlHPlSKStIXUu40QoqGkKausQhAEUd227JOY=; b=wS8jVlpoW1DFOAjvNtl54fdFRIcXtxztqxSS/AqoB/bp6KH24nyJFk0QiNGKMmZhmj /Wq82ipCYCTYwbjdlnnrmInzGDDXDjuG5ImuYrD/XWpLkiSs0W7sDN42jssZmn+hjl+t JAj/1fFdo0L+W1xGq/YU3wNc/B2N9D4Qz2fY/3Xhr1Et2XlxVn2RWcKB5kFyKwc13Wbm HzzGfdt46CoHCexuAcOiddvjOLYkWV+DKn8bBNWUhH+QVRGxmNLnpg/LKPa0iOKFfxQC 0KapEEIw21o5lbPTgh15nB5vJyz1FQda7qmOy1BBs3IHi9rMA8WNgCSp3ZrUevE6mtyk MPdQ== 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 c16si4316279plo.420.2019.08.05.06.51.00; Mon, 05 Aug 2019 06:51:01 -0700 (PDT) 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 S1730563AbfHENu7 (ORCPT + 29 others); Mon, 5 Aug 2019 09:50:59 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:44548 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729755AbfHENu2 (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 1C38CF8B2C0E5EB75829; 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:14 +0800 From: John Garry To: , CC: , , , Xiang Chen , "John Garry" Subject: [PATCH 11/15] scsi: hisi_sas: Drop free_irq() when devm_request_irq() failed Date: Mon, 5 Aug 2019 21:48:08 +0800 Message-ID: <1565012892-75940-12-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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xiang Chen It will free irq automatically if devm_request_irq() failed, so drop free_irq() if devm_request_irq() failed. Signed-off-by: Xiang Chen Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 34 ++++++-------------------- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 21 +++------------- 2 files changed, 11 insertions(+), 44 deletions(-) -- 2.17.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c index 9955b4fbdd0d..a3f8c51b3500 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c @@ -3304,8 +3304,8 @@ static int interrupt_init_v2_hw(struct hisi_hba *hisi_hba) { struct platform_device *pdev = hisi_hba->platform_dev; struct device *dev = &pdev->dev; - int irq, rc, irq_map[128]; - int i, phy_no, fatal_no, queue_no, k; + int irq, rc = 0, irq_map[128]; + int i, phy_no, fatal_no, queue_no; for (i = 0; i < 128; i++) irq_map[i] = platform_get_irq(pdev, i); @@ -3318,7 +3318,7 @@ static int interrupt_init_v2_hw(struct hisi_hba *hisi_hba) dev_err(dev, "irq init: could not request phy interrupt %d, rc=%d\n", irq, rc); rc = -ENOENT; - goto free_phy_int_irqs; + goto err_out; } } @@ -3332,7 +3332,7 @@ static int interrupt_init_v2_hw(struct hisi_hba *hisi_hba) dev_err(dev, "irq init: could not request sata interrupt %d, rc=%d\n", irq, rc); rc = -ENOENT; - goto free_sata_int_irqs; + goto err_out; } } @@ -3344,7 +3344,7 @@ static int interrupt_init_v2_hw(struct hisi_hba *hisi_hba) dev_err(dev, "irq init: could not request fatal interrupt %d, rc=%d\n", irq, rc); rc = -ENOENT; - goto free_fatal_int_irqs; + goto err_out; } } @@ -3359,34 +3359,14 @@ static int interrupt_init_v2_hw(struct hisi_hba *hisi_hba) dev_err(dev, "irq init: could not request cq interrupt %d, rc=%d\n", irq, rc); rc = -ENOENT; - goto free_cq_int_irqs; + goto err_out; } tasklet_init(t, cq_tasklet_v2_hw, (unsigned long)cq); } hisi_hba->cq_nvecs = hisi_hba->queue_count; - return 0; - -free_cq_int_irqs: - for (k = 0; k < queue_no; k++) { - struct hisi_sas_cq *cq = &hisi_hba->cq[k]; - - free_irq(irq_map[k + 96], cq); - tasklet_kill(&cq->tasklet); - } -free_fatal_int_irqs: - for (k = 0; k < fatal_no; k++) - free_irq(irq_map[k + 81], hisi_hba); -free_sata_int_irqs: - for (k = 0; k < phy_no; k++) { - struct hisi_sas_phy *phy = &hisi_hba->phy[k]; - - free_irq(irq_map[k + 72], phy); - } -free_phy_int_irqs: - for (k = 0; k < i; k++) - free_irq(irq_map[k + 1], hisi_hba); +err_out: return rc; } diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index 95a298d4e211..3cc53e5b92f2 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -2351,8 +2351,7 @@ static int interrupt_init_v3_hw(struct hisi_hba *hisi_hba) { struct device *dev = hisi_hba->dev; struct pci_dev *pdev = hisi_hba->pci_dev; - int vectors, rc; - int i, k; + int vectors, rc, i; int max_msi = HISI_SAS_MSI_COUNT_V3_HW, min_msi; if (auto_affine_msi_experimental) { @@ -2400,7 +2399,7 @@ static int interrupt_init_v3_hw(struct hisi_hba *hisi_hba) if (rc) { dev_err(dev, "could not request chnl interrupt, rc=%d\n", rc); rc = -ENOENT; - goto free_phy_irq; + goto free_irq_vectors; } rc = devm_request_irq(dev, pci_irq_vector(pdev, 11), @@ -2409,7 +2408,7 @@ static int interrupt_init_v3_hw(struct hisi_hba *hisi_hba) if (rc) { dev_err(dev, "could not request fatal interrupt, rc=%d\n", rc); rc = -ENOENT; - goto free_chnl_interrupt; + goto free_irq_vectors; } /* Init tasklets for cq only */ @@ -2426,7 +2425,7 @@ static int interrupt_init_v3_hw(struct hisi_hba *hisi_hba) dev_err(dev, "could not request cq%d interrupt, rc=%d\n", i, rc); rc = -ENOENT; - goto free_cq_irqs; + goto free_irq_vectors; } tasklet_init(t, cq_tasklet_v3_hw, (unsigned long)cq); @@ -2434,18 +2433,6 @@ static int interrupt_init_v3_hw(struct hisi_hba *hisi_hba) return 0; -free_cq_irqs: - for (k = 0; k < i; k++) { - struct hisi_sas_cq *cq = &hisi_hba->cq[k]; - int nr = hisi_sas_intr_conv ? 16 : 16 + k; - - free_irq(pci_irq_vector(pdev, nr), cq); - } - free_irq(pci_irq_vector(pdev, 11), hisi_hba); -free_chnl_interrupt: - free_irq(pci_irq_vector(pdev, 2), hisi_hba); -free_phy_irq: - free_irq(pci_irq_vector(pdev, 1), hisi_hba); free_irq_vectors: pci_free_irq_vectors(pdev); return rc; From patchwork Mon Aug 5 13:48:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 170566 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp4322405ile; Mon, 5 Aug 2019 06:51:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqxxJQ/LWZuNT2Vc8AyGv3vQ8lSVedczB+9TultvCjxHeocXDGurQw7pYLOG/07oLN4ArGBY X-Received: by 2002:a63:7106:: with SMTP id m6mr4852197pgc.2.1565013065738; Mon, 05 Aug 2019 06:51:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565013065; cv=none; d=google.com; s=arc-20160816; b=NxWhiE/WXyzpSSgNUNsRoXYGU5DyWTXudWzGZqqNeQD0tp3ZE0+pA0J4kW4RtzMCqs xw1IzNqsEj1bpTh94j+SiorxhNZBBYdE2WqmxTZn2J5aiVc1SXoTLsaAMybkH4yQ7XPu +/5MPJbGlK8tYacR7I/ECX8vbIWtM8l0J2t5t9qdAZqFo9Sw8k/zUrhLHL4oskXDOIBL d7Tf1z+oLCIWL7osxQfthzNIYoiF7xgeQelY5o3I1wJItbkEm2NL22VWnjZw3tRODmCL cOEcADWQ6Oh83ZNkIHWYoLe5Q6DUI8cXgNAuKMuGVEcCz6Yl3oTxN7ZF14tf3mduWKnV EwFw== 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=XuW7xkl4yp7UuyS7aIm97L43OaMebV7bL1NQ5TaenJY=; b=Wl45xJByOkOejOvj+toetdBFvpirqwun10DA4WprIMQtIl+XymFBihsORWQIU6NWh+ 6rYeGr06NHsBZvDisT9VYwvjcCGTtGvmepFpbO9KiC5XCLvzbYYcWSKW9y25XMlr5wZS OMRY2448GexCmbKobSfQxEbh/rUQLpWHw/SCbzhYnUYTWyfTVs0ZEh2Tl/Hq7/oWe0sz 29oxhgzTTtBGb/V/ZfhdZ9XhQTXLU20ltN6/SfiSaibLPNsfNL7fRG4sCIB00fmAvAGI PdHEdb/6CbMFZF2aLtVsHAk8Jw8kla37EyM/SaPQDWEzFcmcH6uCDzh1N8Iw+yqf0XYy RMwQ== 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 e10si10826154pgt.431.2019.08.05.06.51.05; Mon, 05 Aug 2019 06:51:05 -0700 (PDT) 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 S1730609AbfHENvE (ORCPT + 29 others); Mon, 5 Aug 2019 09:51:04 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:44546 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729747AbfHENu1 (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 174B5C4A8622A0199C17; 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:14 +0800 From: John Garry To: , CC: , , , Luo Jiaxing , John Garry Subject: [PATCH 12/15] scsi: hisi_sas: Modify return type of debugfs functions Date: Mon, 5 Aug 2019 21:48:09 +0800 Message-ID: <1565012892-75940-13-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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Luo Jiaxing For functions which always return 0, which is never checked, make to return void. Signed-off-by: Luo Jiaxing Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_main.c | 51 ++++++++++----------------- 1 file changed, 18 insertions(+), 33 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 a2255701b50b..be15280343d1 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -2956,8 +2956,8 @@ static const struct file_operations hisi_sas_debugfs_port_fops = { .owner = THIS_MODULE, }; -static int hisi_sas_show_row_64(struct seq_file *s, int index, - int sz, __le64 *ptr) +static void hisi_sas_show_row_64(struct seq_file *s, int index, + int sz, __le64 *ptr) { int i; @@ -2970,12 +2970,10 @@ static int hisi_sas_show_row_64(struct seq_file *s, int index, } seq_puts(s, "\n"); - - return 0; } -static int hisi_sas_show_row_32(struct seq_file *s, int index, - int sz, __le32 *ptr) +static void hisi_sas_show_row_32(struct seq_file *s, int index, + int sz, __le32 *ptr) { int i; @@ -2987,11 +2985,9 @@ static int hisi_sas_show_row_32(struct seq_file *s, int index, seq_puts(s, "\n\t"); } seq_puts(s, "\n"); - - return 0; } -static int hisi_sas_cq_show_slot(struct seq_file *s, int slot, void *cq_ptr) +static void hisi_sas_cq_show_slot(struct seq_file *s, int slot, void *cq_ptr) { struct hisi_sas_cq *cq = cq_ptr; struct hisi_hba *hisi_hba = cq->hisi_hba; @@ -2999,20 +2995,18 @@ static int hisi_sas_cq_show_slot(struct seq_file *s, int slot, void *cq_ptr) __le32 *complete_hdr = complete_queue + (hisi_hba->hw->complete_hdr_size * slot); - return hisi_sas_show_row_32(s, slot, - hisi_hba->hw->complete_hdr_size, - complete_hdr); + hisi_sas_show_row_32(s, slot, + hisi_hba->hw->complete_hdr_size, + complete_hdr); } static int hisi_sas_debugfs_cq_show(struct seq_file *s, void *p) { struct hisi_sas_cq *cq = s->private; - int slot, ret; + int slot; for (slot = 0; slot < HISI_SAS_QUEUE_SLOTS; slot++) { - ret = hisi_sas_cq_show_slot(s, slot, cq); - if (ret) - return ret; + hisi_sas_cq_show_slot(s, slot, cq); } return 0; } @@ -3030,7 +3024,7 @@ static const struct file_operations hisi_sas_debugfs_cq_fops = { .owner = THIS_MODULE, }; -static int hisi_sas_dq_show_slot(struct seq_file *s, int slot, void *dq_ptr) +static void hisi_sas_dq_show_slot(struct seq_file *s, int slot, void *dq_ptr) { struct hisi_sas_dq *dq = dq_ptr; struct hisi_hba *hisi_hba = dq->hisi_hba; @@ -3038,18 +3032,15 @@ static int hisi_sas_dq_show_slot(struct seq_file *s, int slot, void *dq_ptr) __le32 *cmd_hdr = cmd_queue + sizeof(struct hisi_sas_cmd_hdr) * slot; - return hisi_sas_show_row_32(s, slot, sizeof(struct hisi_sas_cmd_hdr), - cmd_hdr); + hisi_sas_show_row_32(s, slot, sizeof(struct hisi_sas_cmd_hdr), cmd_hdr); } static int hisi_sas_debugfs_dq_show(struct seq_file *s, void *p) { - int slot, ret; + int slot; for (slot = 0; slot < HISI_SAS_QUEUE_SLOTS; slot++) { - ret = hisi_sas_dq_show_slot(s, slot, s->private); - if (ret) - return ret; + hisi_sas_dq_show_slot(s, slot, s->private); } return 0; } @@ -3071,15 +3062,12 @@ static int hisi_sas_debugfs_iost_show(struct seq_file *s, void *p) { struct hisi_hba *hisi_hba = s->private; struct hisi_sas_iost *debugfs_iost = hisi_hba->debugfs_iost; - int i, ret, max_command_entries = HISI_SAS_MAX_COMMANDS; + int i, max_command_entries = HISI_SAS_MAX_COMMANDS; for (i = 0; i < max_command_entries; i++, debugfs_iost++) { __le64 *iost = &debugfs_iost->qw0; - ret = hisi_sas_show_row_64(s, i, sizeof(*debugfs_iost), - iost); - if (ret) - return ret; + hisi_sas_show_row_64(s, i, sizeof(*debugfs_iost), iost); } return 0; @@ -3140,17 +3128,14 @@ static const struct file_operations hisi_sas_debugfs_iost_cache_fops = { static int hisi_sas_debugfs_itct_show(struct seq_file *s, void *p) { - int i, ret; + int i; struct hisi_hba *hisi_hba = s->private; struct hisi_sas_itct *debugfs_itct = hisi_hba->debugfs_itct; for (i = 0; i < HISI_SAS_MAX_ITCT_ENTRIES; i++, debugfs_itct++) { __le64 *itct = &debugfs_itct->qw0; - ret = hisi_sas_show_row_64(s, i, sizeof(*debugfs_itct), - itct); - if (ret) - return ret; + hisi_sas_show_row_64(s, i, sizeof(*debugfs_itct), itct); } return 0; From patchwork Mon Aug 5 13:48:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 170562 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp4322023ile; Mon, 5 Aug 2019 06:50:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqy3LgVN7OEeiqwt0LNkX7tWcEgfGbA/k+jNL3DUpVj5IkVS2my/mwFA7VUBVm3fN66Om70E X-Received: by 2002:a17:90a:ba93:: with SMTP id t19mr17873402pjr.139.1565013046065; Mon, 05 Aug 2019 06:50:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565013046; cv=none; d=google.com; s=arc-20160816; b=widK2Y2pioUaOtB5AqBmlyRtunyG27QomJEzy6IhSSXinH8pm+iUwbonCVZdDeVyfi tscGxcuCKcl4HbLzZHapZcPgx6tH7DSBAt+fSg/xCU015jdbfuRH66FexyEpPFkNTX+O 1mTZHIEhix82N4RsYk69wjGqmIerCLphgu/nDaRY2maNYvEGpOPAHZjhYchOMdrLyDtS /5/N8nTmADnSvtqcDyEpKcIWgSZ0FEzle7Lqd+DO4+pmZDtzVMxFB0FIyPfmgKMYndoA 0k64z7qK0ZHMxy4G2Di97hvJxjlKayRdnLGLt9ejFqnK4RARJwnisU+iKUx8AF/RRHnt C4MA== 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=Mo2Moca2a+xjLm7uGS2qnxtUGBoZxjU8yfj6fsZRkq0=; b=hE0oyvFaguR6CGESOEyADmj4TAFWMU4FA4o7PG9OvE8ZTnqTEgJe5qrmjBZK0Ng9Cy lLgNcqDQpmRmBNpz5EliCXBEeh9fzQ8i6LD2nuqHgC60yzI0VsvQxymtwqNr5iH+YpSJ KDwqi07WkUpG5IiICQ/gnTfgroOeT1vU1kPxkdBTe1wBBkkd1wim6qcq0gBQyAHPshHb uhskyJum4rpttJhgaFZdc/1xPGBxpubhdk2mlkYpNWgo6kIzcho+yVjQ2nHg4mKRe2v3 jdZHWYjbLhba7WX3jSRZaQiRnlT/hBPFXOqlf6f27Ed97yqyKqkCxPb98nNtlfo8CDLC XscA== 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 y6si44357502pfl.288.2019.08.05.06.50.45; Mon, 05 Aug 2019 06:50:46 -0700 (PDT) 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 S1730422AbfHENuo (ORCPT + 29 others); Mon, 5 Aug 2019 09:50:44 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:44552 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729854AbfHENu2 (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 24FF616D94FDECA0FE1E; 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:15 +0800 From: John Garry To: , CC: , , , Xiang Chen , "John Garry" Subject: [PATCH 13/15] scsi: hisi_sas: Remove some unnecessary code Date: Mon, 5 Aug 2019 21:48:10 +0800 Message-ID: <1565012892-75940-14-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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xiang Chen Remove some unnecessary code, including: - Explicit zeroing of memory allocated for dmam_alloc_coherent() - Some duplicated code - Some redundant masking Signed-off-by: Xiang Chen Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_main.c | 5 ++--- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 5 +---- 2 files changed, 3 insertions(+), 7 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 be15280343d1..e1c52811f4c7 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -2358,7 +2358,7 @@ 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_ZERO); + GFP_KERNEL); if (!hisi_hba->itct) goto err_out; @@ -2385,7 +2385,7 @@ int hisi_sas_alloc(struct hisi_hba *hisi_hba) void *buf; buf = dmam_alloc_coherent(dev, s, &buf_dma, - GFP_KERNEL | __GFP_ZERO); + GFP_KERNEL); if (!buf) goto err_out; @@ -2434,7 +2434,6 @@ int hisi_sas_alloc(struct hisi_hba *hisi_hba) GFP_KERNEL); if (!hisi_hba->sata_breakpoint) goto err_out; - hisi_sas_init_mem(hisi_hba); hisi_sas_slot_index_init(hisi_hba); hisi_hba->last_slot_index = HISI_SAS_UNRESERVED_IPTT; diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index 3cc53e5b92f2..db8c7e4b1954 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -1914,7 +1914,7 @@ static void fatal_ecc_int_v3_hw(struct hisi_hba *hisi_hba) u32 irq_value, irq_msk; irq_msk = hisi_sas_read32(hisi_hba, SAS_ECC_INTR_MSK); - hisi_sas_write32(hisi_hba, SAS_ECC_INTR_MSK, irq_msk | 0xffffffff); + hisi_sas_write32(hisi_hba, SAS_ECC_INTR_MSK, 0xffffffff); irq_value = hisi_sas_read32(hisi_hba, SAS_ECC_INTR); if (irq_value) @@ -3008,8 +3008,6 @@ hisi_sas_shost_alloc_pci(struct pci_dev *pdev) else hisi_hba->prot_mask = prot_mask; - timer_setup(&hisi_hba->timer, NULL, 0); - if (hisi_sas_get_fw_info(hisi_hba) < 0) goto err_out; @@ -3099,7 +3097,6 @@ hisi_sas_v3_probe(struct pci_dev *pdev, const struct pci_device_id *id) sha->lldd_module = THIS_MODULE; sha->sas_addr = &hisi_hba->sas_addr[0]; sha->num_phys = hisi_hba->n_phy; - sha->core.shost = hisi_hba->shost; for (i = 0; i < hisi_hba->n_phy; i++) { sha->sas_phy[i] = &hisi_hba->phy[i].sas_phy; From patchwork Mon Aug 5 13:48:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 170561 Delivered-To: patch@linaro.org Received: by 2002:a92:861b:0:0:0:0:0 with SMTP id g27csp4083401ild; Mon, 5 Aug 2019 06:50:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqyMLBfi6e8PKKmhiip1bIKzfNMWQ9mA5CZ8tUM8fDcjSZp01yVNeXd/B+a/URSWHzf+tpTn X-Received: by 2002:a62:5c47:: with SMTP id q68mr74509020pfb.205.1565013036329; Mon, 05 Aug 2019 06:50:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565013036; cv=none; d=google.com; s=arc-20160816; b=jZX24MyN0OV4F0Wu31x0eTsJovo2yQxR6wWWhhJtY+D2vakVvnR1G8H1i2oB3j6z81 Ttd0b9KmHWqo3g7/uo24gqZbojE7Zf2l10YkoehqEkfOKpA5O36ylHwPklVaJA8krokm boXT9PDVqdaoSJaKWatyl/2z05FHWPG7+39tipeaaokpw02vM8qWTb8SAe2gLXIbPPTE YaSR1Z54ZPlbLKZAy17b3GoHVyKVQrocnSBSGFSXiobQb0bdiOpR9+pCMjFoitkqP+87 Part/dgo2XBTS8U4e/4fWabCeiF46ED+USMml95BY06aV01poRC5FZn40DA88uxruKEH NB7g== 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=gcyueqBwK8hUof3bhu6TQ8IkfAmT7X16DdbQdtBFnM0=; b=OfiiTPSVs/eOSivV2JMZip7iDwfqhX84fiOp89N6BKjRlv948W70t9t8pMiwYsWtes JvHVGV3Ehpp1mxjOEK18TXjIJ4HvwRIT+ppzV/zJv8qZ8ZS98LDXleP1Aav7vP8vp5sx gj7S027cX90K9O0KcmZQ/717+xGNuV5NafVjOPzwTZ1OERAtL0RfkH/BV7Pt2zgwhd3O i+SwfrkpTY/acJOolvussPNfBzO9WMw/5FVsuOFAoJ6HEHdi4G7cK2RruZln+4+BXdZo iqBF2EyDCqRmWJ7LtqtDP/dye8KsaX7iuavKV4o+pk4zz6BUt2KnPTB+ScFDZyDpqdE2 Db6g== 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 k13si45940146pfa.17.2019.08.05.06.50.36; Mon, 05 Aug 2019 06:50:36 -0700 (PDT) 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 S1730251AbfHENue (ORCPT + 29 others); Mon, 5 Aug 2019 09:50:34 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:44558 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729873AbfHENua (ORCPT ); Mon, 5 Aug 2019 09:50:30 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 2E4722D86713B22B4ABD; 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:15 +0800 From: John Garry To: , CC: , , , Xiang Chen , "John Garry" Subject: [PATCH 14/15] scsi: hisi_sas: replace "%p" with "%pK" Date: Mon, 5 Aug 2019 21:48:11 +0800 Message-ID: <1565012892-75940-15-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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xiang Chen The format specifier "%p" can leak kernel address, and use "%pK" instead. Signed-off-by: Xiang Chen Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_main.c | 2 +- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 6 +++--- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 6 +++--- 3 files changed, 7 insertions(+), 7 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 e1c52811f4c7..acb87b4f9622 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -2102,7 +2102,7 @@ _hisi_sas_internal_task_abort(struct hisi_hba *hisi_hba, } exit: - dev_dbg(dev, "internal task abort: task to dev %016llx task=%p resp: 0x%x sts 0x%x\n", + dev_dbg(dev, "internal task abort: task to dev %016llx task=%pK resp: 0x%x sts 0x%x\n", SAS_ADDR(device->sas_addr), task, task->task_status.resp, /* 0 is complete, -1 is undelivered */ task->task_status.stat); diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c index a3f8c51b3500..fba4fcad4735 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c @@ -2393,7 +2393,7 @@ slot_complete_v2_hw(struct hisi_hba *hisi_hba, struct hisi_sas_slot *slot) slot_err_v2_hw(hisi_hba, task, slot, 2); if (ts->stat != SAS_DATA_UNDERRUN) - dev_info(dev, "erroneous completion iptt=%d task=%p dev id=%d CQ hdr: 0x%x 0x%x 0x%x 0x%x Error info: 0x%x 0x%x 0x%x 0x%x\n", + dev_info(dev, "erroneous completion iptt=%d task=%pK dev id=%d CQ hdr: 0x%x 0x%x 0x%x 0x%x Error info: 0x%x 0x%x 0x%x 0x%x\n", slot->idx, task, sas_dev->device_id, complete_hdr->dw0, complete_hdr->dw1, complete_hdr->act, complete_hdr->dw3, @@ -2455,7 +2455,7 @@ slot_complete_v2_hw(struct hisi_hba *hisi_hba, struct hisi_sas_slot *slot) spin_lock_irqsave(&task->task_state_lock, flags); if (task->task_state_flags & SAS_TASK_STATE_ABORTED) { spin_unlock_irqrestore(&task->task_state_lock, flags); - dev_info(dev, "slot complete: task(%p) aborted\n", task); + dev_info(dev, "slot complete: task(%pK) aborted\n", task); return SAS_ABORTED_TASK; } task->task_state_flags |= SAS_TASK_STATE_DONE; @@ -2466,7 +2466,7 @@ slot_complete_v2_hw(struct hisi_hba *hisi_hba, struct hisi_sas_slot *slot) spin_lock_irqsave(&device->done_lock, flags); if (test_bit(SAS_HA_FROZEN, &ha->state)) { spin_unlock_irqrestore(&device->done_lock, flags); - dev_info(dev, "slot complete: task(%p) ignored\n", + dev_info(dev, "slot complete: task(%pK) ignored\n", task); return sts; } diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index db8c7e4b1954..2adb5c93bd81 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -2190,7 +2190,7 @@ slot_complete_v3_hw(struct hisi_hba *hisi_hba, struct hisi_sas_slot *slot) slot_err_v3_hw(hisi_hba, task, slot); if (ts->stat != SAS_DATA_UNDERRUN) - dev_info(dev, "erroneous completion iptt=%d task=%p dev id=%d CQ hdr: 0x%x 0x%x 0x%x 0x%x Error info: 0x%x 0x%x 0x%x 0x%x\n", + dev_info(dev, "erroneous completion iptt=%d task=%pK dev id=%d CQ hdr: 0x%x 0x%x 0x%x 0x%x Error info: 0x%x 0x%x 0x%x 0x%x\n", slot->idx, task, sas_dev->device_id, dw0, dw1, complete_hdr->act, dw3, error_info[0], error_info[1], @@ -2245,7 +2245,7 @@ slot_complete_v3_hw(struct hisi_hba *hisi_hba, struct hisi_sas_slot *slot) spin_lock_irqsave(&task->task_state_lock, flags); if (task->task_state_flags & SAS_TASK_STATE_ABORTED) { spin_unlock_irqrestore(&task->task_state_lock, flags); - dev_info(dev, "slot complete: task(%p) aborted\n", task); + dev_info(dev, "slot complete: task(%pK) aborted\n", task); return SAS_ABORTED_TASK; } task->task_state_flags |= SAS_TASK_STATE_DONE; @@ -2256,7 +2256,7 @@ slot_complete_v3_hw(struct hisi_hba *hisi_hba, struct hisi_sas_slot *slot) spin_lock_irqsave(&device->done_lock, flags); if (test_bit(SAS_HA_FROZEN, &ha->state)) { spin_unlock_irqrestore(&device->done_lock, flags); - dev_info(dev, "slot complete: task(%p) ignored\n ", + dev_info(dev, "slot complete: task(%pK) ignored\n ", task); return sts; } From patchwork Mon Aug 5 13:48:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 170568 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp4322611ile; Mon, 5 Aug 2019 06:51:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqyQ5N1vaY9OKjgIhhPW7zJnAsW/pwgrodReCIR1Rt8EYWcVruMLbTxi1bN5q+UBZpBsJ0Kr X-Received: by 2002:a65:504c:: with SMTP id k12mr138446395pgo.252.1565013077035; Mon, 05 Aug 2019 06:51:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565013077; cv=none; d=google.com; s=arc-20160816; b=NMPez+b4XJp56k4gRYTRLP8C+ldRayyne5k9HESRIme1F9dgpsECvSscXf5YMaS75v /16JypiRVSaspnWr0M7cg5hW/DYAKbj3maxtGkJUL+0PYq+gXkYdMxyPUF2UCeIDBhRM ugOU9RKQ0e3OECpF2YLVOaBiuiuntjtE25DouUdEan3+bzzkr1FKm2y/6fUHAXcUAuZ+ aRpMDUtY6yJxpnDCsdUePPetszWRTxaosItTLm1u15NgXGrhBA5hrPh9MA/eU4yVd096 44CwFKMMCmqNZ7VP7D6QqKOy02eVv9iJV+IWwmLc0qvWgqEL2uyWHmNDulV3gB7mQZ2A f2Yg== 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=4DfdfPcYI1f1BRFLqGo9O0dOPpkG7/tOAEw41Jv3D+o=; b=KJBzRuM6Dg9CwzLqjl3PrsMki3v/Jgsvaf/aBn8BYmt3ZomcDOmhDTcEgD8AMS4sBd eQytvBqGLuThsvXD9RpLXeREP8Rm2wJH5OU8JUb0AMuPpgHvdidMCFLzzApW6aq/Nvtd o07xTXlHTZjf7R99aqLM/p6bBP9ty5vGSCifJ8Vr6nJwlVYaiV4NsvC3ueTZIzn2PKiu /SWmkpQF+pP4iKR38VWqYVU/A/GtU39JqkK23JpN7v/abRlFExXK/b2js2wrDF3jUEu/ u1a59RMrJN4QUBwAQBYEGMyqTMWSV8R2RuasnzhQXcQOIKZXupF0Fn8qYtQsJ1h/icX5 bxRA== 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 q16si44409477pgv.140.2019.08.05.06.51.16; Mon, 05 Aug 2019 06:51:17 -0700 (PDT) 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 S1730685AbfHENvP (ORCPT + 29 others); Mon, 5 Aug 2019 09:51:15 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:44492 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729625AbfHENu1 (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 0636237F57F35AD326B3; 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:15 +0800 From: John Garry To: , CC: , , , Luo Jiaxing , John Garry Subject: [PATCH 15/15] scsi: hisi_sas: Consolidate internal abort calls in LU reset operation Date: Mon, 5 Aug 2019 21:48:12 +0800 Message-ID: <1565012892-75940-16-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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Luo Jiaxing In hisi_sas_lu_reset(), we call internal abort for SAS and SATA device codepaths -> consolidate into a single call. Signed-off-by: Luo Jiaxing Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_main.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 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 acb87b4f9622..d60eaaa4c5e8 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -1829,18 +1829,18 @@ static int hisi_sas_lu_reset(struct domain_device *device, u8 *lun) struct device *dev = hisi_hba->dev; int rc = TMF_RESP_FUNC_FAILED; + /* Clear internal IO and then lu reset */ + rc = hisi_sas_internal_task_abort(hisi_hba, device, + HISI_SAS_INT_ABT_DEV, 0); + if (rc < 0) { + dev_err(dev, "lu_reset: internal abort failed\n"); + goto out; + } + hisi_sas_dereg_device(hisi_hba, device); + if (dev_is_sata(device)) { struct sas_phy *phy; - /* Clear internal IO and then hardreset */ - rc = hisi_sas_internal_task_abort(hisi_hba, device, - HISI_SAS_INT_ABT_DEV, 0); - if (rc < 0) { - dev_err(dev, "lu_reset: internal abort failed\n"); - goto out; - } - hisi_sas_dereg_device(hisi_hba, device); - phy = sas_get_local_phy(device); rc = sas_phy_reset(phy, 1); @@ -1851,14 +1851,6 @@ static int hisi_sas_lu_reset(struct domain_device *device, u8 *lun) } else { struct hisi_sas_tmf_task tmf_task = { .tmf = TMF_LU_RESET }; - rc = hisi_sas_internal_task_abort(hisi_hba, device, - HISI_SAS_INT_ABT_DEV, 0); - if (rc < 0) { - dev_err(dev, "lu_reset: internal abort failed\n"); - goto out; - } - hisi_sas_dereg_device(hisi_hba, device); - rc = hisi_sas_debug_issue_ssp_tmf(device, lun, &tmf_task); if (rc == TMF_RESP_FUNC_COMPLETE) hisi_sas_release_task(hisi_hba, device);