From patchwork Mon Sep 24 15:06:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 147364 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp836520lji; Mon, 24 Sep 2018 08:09:51 -0700 (PDT) X-Google-Smtp-Source: ACcGV62HPHGvkDtQ8PMBmRvtgV2jdGrzGKPmLrnCpdDNyRT/lKQQB6eEAO14PfzgX+BjFUJvkrs6 X-Received: by 2002:a63:3207:: with SMTP id y7-v6mr9973661pgy.101.1537801790902; Mon, 24 Sep 2018 08:09:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537801790; cv=none; d=google.com; s=arc-20160816; b=rt/LUoluuB9DDIcqY2fcl/n9bDH2NKEgk0Qhb81JlkoDgutv0/GDNG64h2+zha0sS5 HkxCze7EGUwXzpnntOvB2BX4aabnFRvn6QOnl9eb4676emJWmuFB5uFGIqRPJO+uCyLs iRoaHnisY7iYlaAKuLEAc8OBAYYrT3uAOdl3KXq+7ACp6LRwlyqykbxitqoICNc6cfu/ Gjx+wd5gwd40WHgZTvk+UzpItTbp1FUAzWf4mPd8QH+el0XtCaUSA0qnMsxD/bb3pKNK Prer1lNDR+OnECS1bhtawWLsuf9wP513EXN2mZgskWTdqjEc9/tjNyLHTzAcazJ/27Gj Ia8w== 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=pSHZ/+suklDIb4G0cpNo3EIK2ARAKPMi4Hf7CpEvhNM=; b=iWU3aan2bgsrliKD1Xngq/QHFAuEaq/H7l8wRMChDbGAC2lqec2deaeeFWsDgwPbsM Qp6JmFAfvRuD9yuUg7b4s7hB+FJsAIdi00ky1bHtN665QfqN7N9xn6Ad5H/YQiLQKpDi JDzXnSEBgXMalEsrNYLwajADrIGifC2o6yhEy2mjLlTegjuQ5W2OBWZW2Wfncpdt9of9 nQaF1mvl/V7ZiqdduK55y+5cQvKmJUPBXwfcMCHGi3GCAyhXEDRq8RjQA1L5++yp0C45 ILWSPrfyDQ7sbjxL5Hco4T94k+rt48fKS6lqRJnIvv8Sl7OT0CF6PkiddXSbDNbJvn4C WjCQ== 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 e10-v6si36469377pfc.51.2018.09.24.08.09.50; Mon, 24 Sep 2018 08:09:50 -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 S2387514AbeIXVMZ (ORCPT + 32 others); Mon, 24 Sep 2018 17:12:25 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:12686 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1733045AbeIXVMX (ORCPT ); Mon, 24 Sep 2018 17:12:23 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 0BB3C9241E8AE; Mon, 24 Sep 2018 23:09:39 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.399.0; Mon, 24 Sep 2018 23:09:31 +0800 From: John Garry To: , CC: , , , Luo Jiaxing , "John Garry" Subject: [PATCH 1/7] scsi: hisi_sas: Feed back linkrate(max/min) when re-attached Date: Mon, 24 Sep 2018 23:06:28 +0800 Message-ID: <1537801594-207139-2-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1537801594-207139-1-git-send-email-john.garry@huawei.com> References: <1537801594-207139-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 At directly attached situation, if the user modifies the sysfs interface of maximum_linkrate and minimum_linkrate to renegotiate the linkrate between SAS controller and target, the value of both files mentioned above should have change to user setting after renegotiate is over, but it remain unchanged. To fix this bug, maximum_linkrate and minimum_linkrate will be directly fed back to relevant sas_phy structure. Signed-off-by: Luo Jiaxing Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_main.c | 3 +++ 1 file changed, 3 insertions(+) -- 1.9.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index a4e2e6a..ba6fb535 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -904,6 +904,9 @@ static void hisi_sas_phy_set_linkrate(struct hisi_hba *hisi_hba, int phy_no, _r.maximum_linkrate = max; _r.minimum_linkrate = min; + sas_phy->phy->maximum_linkrate = max; + sas_phy->phy->minimum_linkrate = min; + hisi_hba->hw->phy_disable(hisi_hba, phy_no); msleep(100); hisi_hba->hw->phy_set_linkrate(hisi_hba, phy_no, &_r); From patchwork Mon Sep 24 15:06:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 147369 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp837467lji; Mon, 24 Sep 2018 08:10:34 -0700 (PDT) X-Google-Smtp-Source: ACcGV62krK9pnke1hbeR40fhH8WBbFX5PMKMqqC67OItpOK75ULCqtxXs3LgztFmGWxrkuLiaOEK X-Received: by 2002:a63:754a:: with SMTP id f10-v6mr5410859pgn.137.1537801834059; Mon, 24 Sep 2018 08:10:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537801834; cv=none; d=google.com; s=arc-20160816; b=F5OG9GvoQPjA5BJz40fVjV8vP2+N7qS1Xg8EtP8nlrRt/ngsrIdmxiqW+XZVFJUnv1 FrL1HYtYSF/AQqG/WzZOHzZZQW8CITDHtUIGRH+k7t2jPnSBwJBjIE1q9JvPkHVORAoG V5J1/7tV7MlwSjNxnwj+UL9rI/IoA+nKu39oimTNmCGmZwMKSDTD8hetfVEaII7dqjpZ N4DWJPaHP4ZiVYifjpEKY5NN8CSOjpEhCXMKytzbNURHAX+fPYmdatrg6xpuuxcn4mXu aAXs+vD2llhptC1dNvjwIULSRPlqecKcgQxJ93/WRiWkwlCW/jCE1GRdjbocDz0zxkqO I/fA== 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=rDND0EYXc3506dmUd7e4GcfD1mJJKzY5uvi74BffhZY=; b=RXo4Q5ohf4LMM8+FPYCO5PLhXBWXuBGtYrz+eo1+Etl3gsO47gqJPXn6wBbHHEwFtg 5iWkNC+2dY2C3XfCeXq3MP4PaFUgsrr5T5/9Dv0PZDv3X4DQ4NCUEqyDBQWZELG4xLug izabAnT0VwNQDEvu4MgAbegiq3KVgoqNEuhDr9azVNZaXiacMD2stG+oUNLXu+DRGoQ1 EaytsmlmsboaV/CGplIVUiKqku2HLrDa8QXoON2Ub1NeTAp2C5u3J6PDSiM+U3isoHLJ ltZYiNPKx4egNLOi6nNAvVUl+ZSAgar5wwbCv2KqLwUEDlRDMdI+z+Jre9bIO7tMCYVT QZgw== 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 2-v6si14444588pgg.421.2018.09.24.08.10.33; Mon, 24 Sep 2018 08:10:34 -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 S1732251AbeIXVNI (ORCPT + 32 others); Mon, 24 Sep 2018 17:13:08 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:40826 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729844AbeIXVMU (ORCPT ); Mon, 24 Sep 2018 17:12:20 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 30373646D9320; Mon, 24 Sep 2018 23:09:40 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.399.0; Mon, 24 Sep 2018 23:09:31 +0800 From: John Garry To: , CC: , , , Luo Jiaxing , "John Garry" Subject: [PATCH 2/7] scsi: hisi_sas: Move evaluation of hisi_hba in hisi_sas_task_prep() Date: Mon, 24 Sep 2018 23:06:29 +0800 Message-ID: <1537801594-207139-3-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1537801594-207139-1-git-send-email-john.garry@huawei.com> References: <1537801594-207139-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 evaluating hisi_hba, the sas_port may be NULL, so for safety relocate the the check to value possible NULL deference. Signed-off-by: Luo Jiaxing Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) -- 1.9.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index ba6fb535..3b95a7a 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -287,13 +287,13 @@ static int hisi_sas_task_prep(struct sas_task *task, int *pass) { struct domain_device *device = task->dev; - struct hisi_hba *hisi_hba = dev_to_hisi_hba(device); + struct hisi_hba *hisi_hba; struct hisi_sas_device *sas_dev = device->lldd_dev; struct hisi_sas_port *port; struct hisi_sas_slot *slot; struct hisi_sas_cmd_hdr *cmd_hdr_base; struct asd_sas_port *sas_port = device->port; - struct device *dev = hisi_hba->dev; + struct device *dev; int dlvry_queue_slot, dlvry_queue, rc, slot_idx; int n_elem = 0, n_elem_req = 0, n_elem_resp = 0; struct hisi_sas_dq *dq; @@ -314,6 +314,9 @@ static int hisi_sas_task_prep(struct sas_task *task, return -ECOMM; } + hisi_hba = dev_to_hisi_hba(device); + dev = hisi_hba->dev; + if (DEV_IS_GONE(sas_dev)) { if (sas_dev) dev_info(dev, "task prep: device %d not ready\n", From patchwork Mon Sep 24 15:06:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 147363 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp836480lji; Mon, 24 Sep 2018 08:09:48 -0700 (PDT) X-Google-Smtp-Source: ACcGV61OiJJuuTSQAX6P51Kh9m0dyfN8wo+RUBANiOZ01YsG4e2HQ6I4TrrptjEpQgPyZzNcZlMX X-Received: by 2002:a65:5286:: with SMTP id y6-v6mr9732071pgp.65.1537801788599; Mon, 24 Sep 2018 08:09:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537801788; cv=none; d=google.com; s=arc-20160816; b=QZnkU7CCKDaiJL2AbEh5KiYpWDcon/IWKah78ZcH5/HGyi3SkVGeFduZltNsjWVjFg MhqA/glLy2aKijs/tRXgWcqXCZqKiWzJz9J9ZVAmFFP3qhb6L+SDlwlWHzhLEk0JKnPp XT3R4pO56akBcedUE4gSagEwciqcUM0cP+a9G3xwf8LCWFOXfNssmH+YCHwEOdiBtKG8 AFd0o26B1NdaiSBdt8upJv6sF14YCJCZehvi7XdBD7x1AS7pP5T/S11V+UaRG+6QECOz yG4jLUdXx+slo+iiQweo4H7piIE++YuLpMXS6/R0snoYqUALu5/PFzNBYoKzUopl7QGW 7Nsg== 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=epDZfF+3KKsNbrGsYTYY4mpF73PYsSyGNmZOAmN034w=; b=ZIexBlNglEXatxM5Ywx0ooz04+UvhKEZb+Y+l9fHUC06kHOZrPjoQ/EiYNbse6j59w PHAgNGxgoW97G6deuUae0aakeBDtvmddzTT1MLbL6O7/ov8ohufbJir8UnkmdCCPidti GLUDnT7+itIfvDAqN/5hQur0l9HPrIzhcX3Fv8KdC7AlRv9lvG6lRtlrkOhVn4WjYhI6 Ni1/dtiiQsghDi2K9T/BA5sDLZxr2uaNvM/7kJ7wacVW0N83IgIZci1ebiaMBIqAZrIF rteW1FFnQA8DBO9oaOz1qy35N2FeJN6ZwuLw48oXZSJESXkT4T8wqP9ZggR40bvfnCaa PTBQ== 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 b3-v6si2062831plx.106.2018.09.24.08.09.48; Mon, 24 Sep 2018 08:09:48 -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 S1733277AbeIXVMX (ORCPT + 32 others); Mon, 24 Sep 2018 17:12:23 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:12681 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728512AbeIXVMV (ORCPT ); Mon, 24 Sep 2018 17:12:21 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 0711468DEFC99; Mon, 24 Sep 2018 23:09:39 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.399.0; Mon, 24 Sep 2018 23:09:31 +0800 From: John Garry To: , CC: , , , Xiang Chen , "John Garry" Subject: [PATCH 3/7] scsi: hisi_sas: Fix the race between IO completion and timeout for SMP/internal IO Date: Mon, 24 Sep 2018 23:06:30 +0800 Message-ID: <1537801594-207139-4-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1537801594-207139-1-git-send-email-john.garry@huawei.com> References: <1537801594-207139-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 If SMP/internal IO times out, we will possibly free the task immediately. However if the IO actually completes at the same time, the IO completion may refer to task which have been freed. So to solve the issue, flush the tasklet to finish IO completion before free'ing slot/task. Signed-off-by: Xiang Chen Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_main.c | 55 +++++++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 9 deletions(-) -- 1.9.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 3b95a7a..416f2c0 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -956,8 +956,7 @@ static int hisi_sas_control_phy(struct asd_sas_phy *sas_phy, enum phy_func func, static void hisi_sas_task_done(struct sas_task *task) { - if (!del_timer(&task->slow_task->timer)) - return; + del_timer(&task->slow_task->timer); complete(&task->slow_task->completion); } @@ -966,13 +965,17 @@ static void hisi_sas_tmf_timedout(struct timer_list *t) struct sas_task_slow *slow = from_timer(slow, t, timer); struct sas_task *task = slow->task; unsigned long flags; + bool is_completed = true; spin_lock_irqsave(&task->task_state_lock, flags); - if (!(task->task_state_flags & SAS_TASK_STATE_DONE)) + if (!(task->task_state_flags & SAS_TASK_STATE_DONE)) { task->task_state_flags |= SAS_TASK_STATE_ABORTED; + is_completed = false; + } spin_unlock_irqrestore(&task->task_state_lock, flags); - complete(&task->slow_task->completion); + if (!is_completed) + complete(&task->slow_task->completion); } #define TASK_TIMEOUT 20 @@ -1023,10 +1026,18 @@ static int hisi_sas_exec_internal_tmf_task(struct domain_device *device, if ((task->task_state_flags & SAS_TASK_STATE_ABORTED)) { if (!(task->task_state_flags & SAS_TASK_STATE_DONE)) { struct hisi_sas_slot *slot = task->lldd_task; + struct hisi_sas_cq *cq = + &hisi_hba->cq[slot->dlvry_queue]; dev_err(dev, "abort tmf: TMF task timeout and not done\n"); - if (slot) + if (slot) { + /* + * flush tasklet to avoid free'ing task + * before using task in IO completion + */ + tasklet_kill(&cq->tasklet); slot->task = NULL; + } goto ex_err; } else @@ -1402,6 +1413,17 @@ static int hisi_sas_abort_task(struct sas_task *task) spin_lock_irqsave(&task->task_state_lock, flags); if (task->task_state_flags & SAS_TASK_STATE_DONE) { + struct hisi_sas_slot *slot = task->lldd_task; + struct hisi_sas_cq *cq; + + if (slot) { + /* + * flush tasklet to avoid free'ing task + * before using task in IO completion + */ + cq = &hisi_hba->cq[slot->dlvry_queue]; + tasklet_kill(&cq->tasklet); + } spin_unlock_irqrestore(&task->task_state_lock, flags); rc = TMF_RESP_FUNC_COMPLETE; goto out; @@ -1457,12 +1479,19 @@ static int hisi_sas_abort_task(struct sas_task *task) /* SMP */ struct hisi_sas_slot *slot = task->lldd_task; u32 tag = slot->idx; + struct hisi_sas_cq *cq = &hisi_hba->cq[slot->dlvry_queue]; rc = hisi_sas_internal_task_abort(hisi_hba, device, HISI_SAS_INT_ABT_CMD, tag); if (((rc < 0) || (rc == TMF_RESP_FUNC_FAILED)) && - task->lldd_task) - hisi_sas_do_release_task(hisi_hba, task, slot); + task->lldd_task) { + /* + * flush tasklet to avoid free'ing task + * before using task in IO completion + */ + tasklet_kill(&cq->tasklet); + slot->task = NULL; + } } out: @@ -1828,9 +1857,17 @@ static int hisi_sas_query_task(struct sas_task *task) if ((task->task_state_flags & SAS_TASK_STATE_ABORTED)) { if (!(task->task_state_flags & SAS_TASK_STATE_DONE)) { struct hisi_sas_slot *slot = task->lldd_task; - - if (slot) + struct hisi_sas_cq *cq = + &hisi_hba->cq[slot->dlvry_queue]; + + if (slot) { + /* + * flush tasklet to avoid free'ing task + * before using task in IO completion + */ + tasklet_kill(&cq->tasklet); slot->task = NULL; + } dev_err(dev, "internal task abort: timeout and not done.\n"); res = -EIO; goto exit; From patchwork Mon Sep 24 15:06:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 147368 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp837238lji; Mon, 24 Sep 2018 08:10:23 -0700 (PDT) X-Google-Smtp-Source: ACcGV63EajjW0WLQfMGfFZoj20yeNYxUhH2ZTilUdJC8/WZ+qFEhb61fA6Byqy8lklWiLxKh3yi4 X-Received: by 2002:a17:902:d909:: with SMTP id c9-v6mr10583398plz.165.1537801823407; Mon, 24 Sep 2018 08:10:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537801823; cv=none; d=google.com; s=arc-20160816; b=e1Y5K5OU8dmMiavSOUdHglJf9nZctPTt5Naceb1QMemF0p0+lLIuQtEWUSL0IEN0mR W3DFSfkUkzCID/7r8lNI+s2XlGKKruljI9os+QQ5hYCT5vxicRIt0oWZATnTMpFWeMn1 u/En94ZJTbEENllwiyO5EqnPPsJL03BcceCAMT1M7d3eDcDip8+ssEJyPc5SAM3Ll1gt G3SJJJgud059bz8Ojut7jxTCVAMNECerVxjpI2p3aG5eLsdlHoJSD5M6pDBQtGrUGitF T0s18NAv2Cbaw6HzIBogff48RGKZ3ElsFgxoKJgg6ouEVSdY3Amc4Btm5NPA6rDfARjX tVEQ== 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=AAoLJDLYmEJiHC89PIX6elwnrCVX/nK+UpJFljJCzsw=; b=IiGOOqyPd+VOFqwBl+vbrdfYy+TNLFymQRux6W2YbFek3SkS9u4pQwNlXV7XXMzaf3 rC2EB5k619tzcVmqGy1deMAmpJgN4nYawPyyxtfyUXcJUsJ4+gxO/9K5udFq3c3nJzRl ORWINORApC2fJLCsd2HnHGac7HMFV9nsokQw9LnHcysUC23RpDe0zWALSiCgfwGLut+n kfWmE8EV79OzZf4yZ3hjqP2rTTLhAE8Z1l25yanKtOHQGeEilLyhq3Z47iDqE7HqLxnG c2OOLB3dqd/UecWSzujfH9wd88PwjJU6Qrtz5G8REqZT7bTx054VmdCmrjQ5Pnu8aAbB zM4Q== 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 b5-v6si36893127pfa.116.2018.09.24.08.10.22; Mon, 24 Sep 2018 08:10: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 S1731010AbeIXVM6 (ORCPT + 32 others); Mon, 24 Sep 2018 17:12:58 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:12684 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729737AbeIXVMV (ORCPT ); Mon, 24 Sep 2018 17:12:21 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id F103E63A0974B; Mon, 24 Sep 2018 23:09:38 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.399.0; Mon, 24 Sep 2018 23:09:32 +0800 From: John Garry To: , CC: , , , Xiang Chen , "John Garry" Subject: [PATCH 4/7] scsi: hisi_sas: Free slot later in slot_complete_vx_hw() Date: Mon, 24 Sep 2018 23:06:31 +0800 Message-ID: <1537801594-207139-5-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1537801594-207139-1-git-send-email-john.garry@huawei.com> References: <1537801594-207139-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 If an SSP/SMP IO times out, it may be actually in reality be simultaneously processing completion of the slot in slot_complete_vx_hw(). Then if the slot is freed in slot_complete_vx_hw() (this IPTT is freed and it may be re-used by other slot), and we may abort the wrong slot in hisi_sas_abort_task(). So to solve the issue, free the slot after the check of SAS_TASK_STATE_ABORTED in slot_complete_vx_hw(). Signed-off-by: Xiang Chen Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 2 +- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) -- 1.9.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c index 9c5c5a6..67134b4 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c @@ -2483,7 +2483,6 @@ static void slot_err_v2_hw(struct hisi_hba *hisi_hba, } out: - hisi_sas_slot_task_free(hisi_hba, task, slot); sts = ts->stat; spin_lock_irqsave(&task->task_state_lock, flags); if (task->task_state_flags & SAS_TASK_STATE_ABORTED) { @@ -2493,6 +2492,7 @@ static void slot_err_v2_hw(struct hisi_hba *hisi_hba, } task->task_state_flags |= SAS_TASK_STATE_DONE; spin_unlock_irqrestore(&task->task_state_lock, flags); + hisi_sas_slot_task_free(hisi_hba, task, slot); if (!is_internal && (task->task_proto != SAS_PROTOCOL_SMP)) { spin_lock_irqsave(&device->done_lock, flags); diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index 08b503e2..3995ff6 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -1751,7 +1751,6 @@ static irqreturn_t fatal_axi_int_v3_hw(int irq_no, void *p) } out: - hisi_sas_slot_task_free(hisi_hba, task, slot); sts = ts->stat; spin_lock_irqsave(&task->task_state_lock, flags); if (task->task_state_flags & SAS_TASK_STATE_ABORTED) { @@ -1761,6 +1760,7 @@ static irqreturn_t fatal_axi_int_v3_hw(int irq_no, void *p) } task->task_state_flags |= SAS_TASK_STATE_DONE; spin_unlock_irqrestore(&task->task_state_lock, flags); + hisi_sas_slot_task_free(hisi_hba, task, slot); if (!is_internal && (task->task_proto != SAS_PROTOCOL_SMP)) { spin_lock_irqsave(&device->done_lock, flags); From patchwork Mon Sep 24 15:06:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 147366 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp836903lji; Mon, 24 Sep 2018 08:10:10 -0700 (PDT) X-Google-Smtp-Source: ACcGV62T3qOAIY2KMR2C+iafkAYz2LdQbux4bYe8QVMRH6kpp1i4CrZ4LyjDxYPZWU9s/9DvcPB5 X-Received: by 2002:a63:9c3:: with SMTP id 186-v6mr10093589pgj.249.1537801810040; Mon, 24 Sep 2018 08:10:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537801810; cv=none; d=google.com; s=arc-20160816; b=KOQqu7tj1EX1BkZ686tJKqu6n6lxSUPmb3YgC5lXCN8lqj+HWhhlmzbitjIOw7Wwnq yVHssuI+wn9EVMRX7AJI+6UsMrRoCjCiLDtcpcc8N4zkuueC9sYeixUsIjzEDPEhds6J 7Mg9gpDWTYdqtmq63pGyXVH9fU72LEIZf9GIKEAP4x/U6le2sEGaYlFDioKgYoqUb6Qb 64IGC46BG6ZoGCgqN7JmVGDctqN35x3dOYIM7Qjka6eaggVCSB19V0fpv3P/7Y9mYraY valPjS6sqCjhYnX1UyTAoAmEFuHB1wRs9e92kce+9baY0CUk5swv/wlyBF9OwHKcfQwQ b75g== 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=6YHnhH3QIQ9XAZXarwMGIfeos4EeYQZSwy73VC1XgU8=; b=pFFcgDe4cUFksMMXoe6Swpb3AES+JUnJcxSo8oMIpAkWB5q4TyUn0PiKU8VDaSI09c v6T+9WeoeQ3PiqSydyHuaduFG452+MiMwa61EQhxKQf4flE8l2OvliKJop/eFvR52Vit wT7AIke6bEYF42eTxlq9WaBJvdcvr1OxBFNpWl5c36G2JRsXEp7tKsS0JENMxDqWJqb2 nuRMZrSXNietGOpYt30ft+iCcdqkjcu1TSr4ZX7YAJ6qU9G1BJIKKuLLSiNCy+1nYsXV CKwMX91Cn8TH0o07ogy9VrySGTGL4tRcWXHCp4snM+95ENOpZHTG01GS4nq/qx/KonEt ZiiQ== 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 n3-v6si35810479pld.146.2018.09.24.08.10.09; Mon, 24 Sep 2018 08:10:10 -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 S1733047AbeIXVMX (ORCPT + 32 others); Mon, 24 Sep 2018 17:12:23 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:12685 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729701AbeIXVMV (ORCPT ); Mon, 24 Sep 2018 17:12:21 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 0154B5F7B7FA1; Mon, 24 Sep 2018 23:09:39 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.399.0; Mon, 24 Sep 2018 23:09:32 +0800 From: John Garry To: , CC: , , , Xiang Chen , "John Garry" Subject: [PATCH 6/7] scsi: hisi_sas: Use block layer tag instead for IPTT Date: Mon, 24 Sep 2018 23:06:33 +0800 Message-ID: <1537801594-207139-7-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1537801594-207139-1-git-send-email-john.garry@huawei.com> References: <1537801594-207139-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 Currently we use the IPTT defined in LLDD to identify IOs. Actually for IOs which are from the block layer, they have tags to identify them. So for those IOs, use tag of the block layer directly, and for IOs which is not from the block layer (such as internal IOs from libsas/LLDD), reserve 96 IPTTs for them. Signed-off-by: Xiang Chen Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas.h | 3 +- drivers/scsi/hisi_sas/hisi_sas_main.c | 89 ++++++++++++++++++++++------------ drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 1 - drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 9 ++-- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 8 +-- 5 files changed, 70 insertions(+), 40 deletions(-) -- 1.9.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h index 6c7d2e2..0ddb53c 100644 --- a/drivers/scsi/hisi_sas/hisi_sas.h +++ b/drivers/scsi/hisi_sas/hisi_sas.h @@ -34,6 +34,7 @@ #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_STATUS_BUF_SZ (sizeof(struct hisi_sas_status_buffer)) #define HISI_SAS_COMMAND_TABLE_SZ (sizeof(union hisi_sas_command_table)) @@ -217,7 +218,7 @@ struct hisi_sas_hw { int (*hw_init)(struct hisi_hba *hisi_hba); void (*setup_itct)(struct hisi_hba *hisi_hba, struct hisi_sas_device *device); - int (*slot_index_alloc)(struct hisi_hba *hisi_hba, int *slot_idx, + int (*slot_index_alloc)(struct hisi_hba *hisi_hba, struct domain_device *device); struct hisi_sas_device *(*alloc_dev)(struct domain_device *device); void (*sl_notify)(struct hisi_hba *hisi_hba, int phy_no); diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 416f2c0..8fcd1ab 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -183,7 +183,14 @@ static void hisi_sas_slot_index_clear(struct hisi_hba *hisi_hba, int slot_idx) static void hisi_sas_slot_index_free(struct hisi_hba *hisi_hba, int slot_idx) { - hisi_sas_slot_index_clear(hisi_hba, 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)) { + spin_lock_irqsave(&hisi_hba->lock, flags); + hisi_sas_slot_index_clear(hisi_hba, slot_idx); + spin_unlock_irqrestore(&hisi_hba->lock, flags); + } } static void hisi_sas_slot_index_set(struct hisi_hba *hisi_hba, int slot_idx) @@ -193,24 +200,34 @@ static void hisi_sas_slot_index_set(struct hisi_hba *hisi_hba, int slot_idx) set_bit(slot_idx, bitmap); } -static int hisi_sas_slot_index_alloc(struct hisi_hba *hisi_hba, int *slot_idx) +static int hisi_sas_slot_index_alloc(struct hisi_hba *hisi_hba, + struct scsi_cmnd *scsi_cmnd) { - unsigned int index; + int index; void *bitmap = hisi_hba->slot_index_tags; + unsigned long flags; + if (scsi_cmnd) + return scsi_cmnd->request->tag; + + spin_lock_irqsave(&hisi_hba->lock, flags); index = find_next_zero_bit(bitmap, hisi_hba->slot_index_count, - hisi_hba->last_slot_index + 1); + hisi_hba->last_slot_index + 1); if (index >= hisi_hba->slot_index_count) { - index = find_next_zero_bit(bitmap, hisi_hba->slot_index_count, - 0); - 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); + if (index >= hisi_hba->slot_index_count) { + spin_unlock_irqrestore(&hisi_hba->lock, flags); return -SAS_QUEUE_FULL; + } } hisi_sas_slot_index_set(hisi_hba, index); - *slot_idx = index; hisi_hba->last_slot_index = index; + spin_unlock_irqrestore(&hisi_hba->lock, flags); - return 0; + return index; } static void hisi_sas_slot_index_init(struct hisi_hba *hisi_hba) @@ -249,9 +266,7 @@ void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba, struct sas_task *task, memset(slot, 0, offsetof(struct hisi_sas_slot, buf)); - spin_lock_irqsave(&hisi_hba->lock, flags); hisi_sas_slot_index_free(hisi_hba, slot->idx); - spin_unlock_irqrestore(&hisi_hba->lock, flags); } EXPORT_SYMBOL_GPL(hisi_sas_slot_task_free); @@ -384,16 +399,27 @@ static int hisi_sas_task_prep(struct sas_task *task, goto err_out_dma_unmap; } - spin_lock_irqsave(&hisi_hba->lock, flags); if (hisi_hba->hw->slot_index_alloc) - rc = hisi_hba->hw->slot_index_alloc(hisi_hba, &slot_idx, - device); - else - rc = hisi_sas_slot_index_alloc(hisi_hba, &slot_idx); - spin_unlock_irqrestore(&hisi_hba->lock, flags); - if (rc) + rc = hisi_hba->hw->slot_index_alloc(hisi_hba, device); + else { + struct scsi_cmnd *scsi_cmnd = NULL; + + if (task->uldd_task) { + struct ata_queued_cmd *qc; + + if (dev_is_sata(device)) { + qc = task->uldd_task; + scsi_cmnd = qc->scsicmd; + } else { + scsi_cmnd = task->uldd_task; + } + } + rc = hisi_sas_slot_index_alloc(hisi_hba, scsi_cmnd); + } + if (rc < 0) goto err_out_dma_unmap; + slot_idx = rc; slot = &hisi_hba->slot_info[slot_idx]; spin_lock_irqsave(&dq->lock, flags); @@ -454,9 +480,7 @@ static int hisi_sas_task_prep(struct sas_task *task, return 0; err_out_tag: - spin_lock_irqsave(&hisi_hba->lock, flags); hisi_sas_slot_index_free(hisi_hba, slot_idx); - spin_unlock_irqrestore(&hisi_hba->lock, flags); err_out_dma_unmap: if (!sas_protocol_ata(task->task_proto)) { if (task->num_scatter) { @@ -1740,14 +1764,11 @@ static int hisi_sas_query_task(struct sas_task *task) port = to_hisi_sas_port(sas_port); /* simply get a slot and send abort command */ - spin_lock_irqsave(&hisi_hba->lock, flags); - rc = hisi_sas_slot_index_alloc(hisi_hba, &slot_idx); - if (rc) { - spin_unlock_irqrestore(&hisi_hba->lock, flags); + rc = hisi_sas_slot_index_alloc(hisi_hba, NULL); + if (rc < 0) goto err_out; - } - spin_unlock_irqrestore(&hisi_hba->lock, flags); + slot_idx = rc; slot = &hisi_hba->slot_info[slot_idx]; spin_lock_irqsave(&dq->lock, flags_dq); @@ -1783,7 +1804,6 @@ static int hisi_sas_query_task(struct sas_task *task) spin_lock_irqsave(&task->task_state_lock, flags); task->task_state_flags |= SAS_TASK_AT_INITIATOR; spin_unlock_irqrestore(&task->task_state_lock, flags); - WRITE_ONCE(slot->ready, 1); /* send abort command to the chip */ spin_lock_irqsave(&dq->lock, flags); @@ -1794,9 +1814,7 @@ static int hisi_sas_query_task(struct sas_task *task) return 0; err_out_tag: - spin_lock_irqsave(&hisi_hba->lock, flags); hisi_sas_slot_index_free(hisi_hba, slot_idx); - spin_unlock_irqrestore(&hisi_hba->lock, flags); err_out: dev_err(dev, "internal abort task prep: failed[%d]!\n", rc); @@ -2163,6 +2181,8 @@ int hisi_sas_alloc(struct hisi_hba *hisi_hba, struct Scsi_Host *shost) 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->wq = create_singlethread_workqueue(dev_name(dev)); if (!hisi_hba->wq) { @@ -2366,8 +2386,15 @@ int hisi_sas_probe(struct platform_device *pdev, shost->max_channel = 1; shost->max_cmd_len = 16; shost->sg_tablesize = min_t(u16, SG_ALL, HISI_SAS_SGE_PAGE_CNT); - shost->can_queue = hisi_hba->hw->max_command_entries; - shost->cmd_per_lun = hisi_hba->hw->max_command_entries; + 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; + } 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; + } sha->sas_ha_name = DRV_NAME; sha->dev = hisi_hba->dev; diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c index 8f60f0e..f0e457e 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c @@ -1809,7 +1809,6 @@ static int hisi_sas_v1_init(struct hisi_hba *hisi_hba) .scan_start = hisi_sas_scan_start, .change_queue_depth = sas_change_queue_depth, .bios_param = sas_bios_param, - .can_queue = 1, .this_id = -1, .sg_tablesize = SG_ALL, .max_sectors = SCSI_DEFAULT_MAX_SECTORS, diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c index 67134b4..70d6b28 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c @@ -770,7 +770,7 @@ static u32 hisi_sas_phy_read32(struct hisi_hba *hisi_hba, /* This function needs to be protected from pre-emption. */ static int -slot_index_alloc_quirk_v2_hw(struct hisi_hba *hisi_hba, int *slot_idx, +slot_index_alloc_quirk_v2_hw(struct hisi_hba *hisi_hba, struct domain_device *device) { int sata_dev = dev_is_sata(device); @@ -778,6 +778,7 @@ static u32 hisi_sas_phy_read32(struct hisi_hba *hisi_hba, struct hisi_sas_device *sas_dev = device->lldd_dev; int sata_idx = sas_dev->sata_idx; int start, end; + unsigned long flags; if (!sata_dev) { /* @@ -801,6 +802,7 @@ static u32 hisi_sas_phy_read32(struct hisi_hba *hisi_hba, end = 64 * (sata_idx + 2); } + spin_lock_irqsave(&hisi_hba->lock, flags); while (1) { start = find_next_zero_bit(bitmap, hisi_hba->slot_index_count, start); @@ -815,8 +817,8 @@ static u32 hisi_sas_phy_read32(struct hisi_hba *hisi_hba, } set_bit(start, bitmap); - *slot_idx = start; - return 0; + spin_unlock_irqrestore(&hisi_hba->lock, flags); + return start; } static bool sata_index_alloc_v2_hw(struct hisi_hba *hisi_hba, int *idx) @@ -3560,7 +3562,6 @@ static void wait_cmds_complete_timeout_v2_hw(struct hisi_hba *hisi_hba, .scan_start = hisi_sas_scan_start, .change_queue_depth = sas_change_queue_depth, .bios_param = sas_bios_param, - .can_queue = 1, .this_id = -1, .sg_tablesize = SG_ALL, .max_sectors = SCSI_DEFAULT_MAX_SECTORS, diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index 34c8f30..f30c4e4 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -2098,7 +2098,6 @@ static void wait_cmds_complete_timeout_v3_hw(struct hisi_hba *hisi_hba, .scan_start = hisi_sas_scan_start, .change_queue_depth = sas_change_queue_depth, .bios_param = sas_bios_param, - .can_queue = 1, .this_id = -1, .sg_tablesize = SG_ALL, .max_sectors = SCSI_DEFAULT_MAX_SECTORS, @@ -2108,6 +2107,7 @@ static void wait_cmds_complete_timeout_v3_hw(struct hisi_hba *hisi_hba, .target_destroy = sas_target_destroy, .ioctl = sas_ioctl, .shost_attrs = host_attrs, + .tag_alloc_policy = BLK_TAG_ALLOC_RR, }; static const struct hisi_sas_hw hisi_sas_v3_hw = { @@ -2245,8 +2245,10 @@ static void wait_cmds_complete_timeout_v3_hw(struct hisi_hba *hisi_hba, shost->max_channel = 1; shost->max_cmd_len = 16; shost->sg_tablesize = min_t(u16, SG_ALL, HISI_SAS_SGE_PAGE_CNT); - shost->can_queue = hisi_hba->hw->max_command_entries; - shost->cmd_per_lun = hisi_hba->hw->max_command_entries; + 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; sha->sas_ha_name = DRV_NAME; sha->dev = dev; From patchwork Mon Sep 24 15:06:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 147365 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp836687lji; Mon, 24 Sep 2018 08:09:59 -0700 (PDT) X-Google-Smtp-Source: ACcGV60QhKrUu0dIg9IXO56ivqYR/xzHdTR9s+tuY2sOaBwQd2mgy28s3BDLGWdQWL2BBNHOj5po X-Received: by 2002:a17:902:b189:: with SMTP id s9-v6mr11131785plr.188.1537801799157; Mon, 24 Sep 2018 08:09:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537801799; cv=none; d=google.com; s=arc-20160816; b=XyhhstuqVWMGcAiVxtQuxqqEfsPhmDrOX4PVsbmdYPO44eh0+PfweR/m4XtM6Oc6dT GmnQQtpC5jSBL7qIF7SZN/Cl935D448uHiJr3qNZnWChDsHK9oowC6aay7BYSeXOCdUk ERXGxrLY89SMSqVwx9f6LmIAuScb6zB2n+OUI5uV0X2EhkyuOiiJGIEadMkcGJaT2+zy NSaAvNKKlauqO/RwV2p2s9pMml7LK8Yq/iU3ArAj4RKx0SorGeIvmQhZCTykhglB4nxT q9MX688pwUzi/TjZouv02kHHzqd8KerHOhJVrq3cemdT/GMsvb+MnzQoICew+ppGXZKl 6hTg== 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=SyzWL9sN5uZxIizhdMp3h6PbHJsATfZ6VywgtfQ1uPo=; b=tuTOt2mwt8DqEuXcHuUZef6u3F0M2n6vlxdqNeZIKfa1iIqTSxRULKEZgvtJUVnEMN qXFYyrYCkdJ8KfqCwXnPS2+YlV0vArV643tEft7l4h82afz3CNFziNQcYeNs9D3UHS2s XtfSzLHHAZlU7Adu6LvqYAZ1keBGzD6FHcyoIF05H95geGFfZLUetkgZ/0Qg8hjtG38F dDBwN7x7jAqKTQFy+nrrys0g4Vhjm837rYIM+yWqqyGuf1+GgSJwpe3BoiUl8kI0mCMG YJrjqzdhKecDdpwVQ/dPKtQhGWtMqKCQ15untMfYA2wd0dKdlXNp/Cv3fh6vRb2X7XiQ YDeQ== 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 i21-v6si34379770pgg.513.2018.09.24.08.09.58; Mon, 24 Sep 2018 08:09:59 -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 S2387526AbeIXVMd (ORCPT + 32 others); Mon, 24 Sep 2018 17:12:33 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:12683 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729102AbeIXVMd (ORCPT ); Mon, 24 Sep 2018 17:12:33 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id E7E5B6DFF0AA5; Mon, 24 Sep 2018 23:09:38 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.399.0; Mon, 24 Sep 2018 23:09:33 +0800 From: John Garry To: , CC: , , , Xiang Chen , "John Garry" Subject: [PATCH 7/7] scsi: hisi_sas: Update v3 hw AIP_LIMIT and CFG_AGING_TIME register values Date: Mon, 24 Sep 2018 23:06:34 +0800 Message-ID: <1537801594-207139-8-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1537801594-207139-1-git-send-email-john.garry@huawei.com> References: <1537801594-207139-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 Update registers as follows: - Default value of AIP timer is 1ms, and it is easy for some expanders to cause IO error. Change the value to max value 65ms to avoid IO error for those expanders. - A CQ completion will be reported by HW when 4 CQs have occurred or the aging timer expires, whichever happens first. Sor serial IO scenario, it will still wait 8us for every IO before it is reported. So in the situation, the performance is poor. So to improve it, change the limit time to the least value. For other scenario, it does little affect to the performance. Signed-off-by: Xiang Chen Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 3 +++ 1 file changed, 3 insertions(+) -- 1.9.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index f30c4e4..bd4ce38 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -127,6 +127,7 @@ #define PHY_CTRL_RESET_OFF 0 #define PHY_CTRL_RESET_MSK (0x1 << PHY_CTRL_RESET_OFF) #define SL_CFG (PORT_BASE + 0x84) +#define AIP_LIMIT (PORT_BASE + 0x90) #define SL_CONTROL (PORT_BASE + 0x94) #define SL_CONTROL_NOTIFY_EN_OFF 0 #define SL_CONTROL_NOTIFY_EN_MSK (0x1 << SL_CONTROL_NOTIFY_EN_OFF) @@ -431,6 +432,7 @@ static void init_reg_v3_hw(struct hisi_hba *hisi_hba) (u32)((1ULL << hisi_hba->queue_count) - 1)); hisi_sas_write32(hisi_hba, CFG_MAX_TAG, 0xfff0400); hisi_sas_write32(hisi_hba, HGC_SAS_TXFAIL_RETRY_CTRL, 0x108); + hisi_sas_write32(hisi_hba, CFG_AGING_TIME, 0x1); hisi_sas_write32(hisi_hba, INT_COAL_EN, 0x1); hisi_sas_write32(hisi_hba, OQ_INT_COAL_TIME, 0x1); hisi_sas_write32(hisi_hba, OQ_INT_COAL_CNT, 0x1); @@ -495,6 +497,7 @@ static void init_reg_v3_hw(struct hisi_hba *hisi_hba) /* used for 12G negotiate */ hisi_sas_phy_write32(hisi_hba, i, COARSETUNE_TIME, 0x1e); + hisi_sas_phy_write32(hisi_hba, i, AIP_LIMIT, 0x2ffff); } for (i = 0; i < hisi_hba->queue_count; i++) {