From patchwork Wed Jul 18 14:14:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 142286 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp594534ljj; Wed, 18 Jul 2018 07:16:48 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdk47J3OyQCXMeSwBZb3zup0Nbm6h+/ZzkOMxpoG2VARxO4AhDHinmJ8nxgOomiiHuWZLm1 X-Received: by 2002:a63:6b03:: with SMTP id g3-v6mr6008891pgc.57.1531923408259; Wed, 18 Jul 2018 07:16:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531923408; cv=none; d=google.com; s=arc-20160816; b=EvaomahJ5JUDH6+SSRddbqg4Q8Vi4XUruesFHy/bB99ft1NPnAsqMxezwEqFrnysYh EPVIjCoYNTZC/Vid7aamyI5JW+4zECuhX6C7fsAZeylXh8ZTP1ZsV6hOZwiQ8PRORy5P dGBEwJnwgK5rQfBoIt6BMi03TH/rJC96m68l6UB/9mn6YAMm3H1y7fUpOfmabrTG5cRc 6oukZDTE5dhrTYAQ2kGT8U9FM964h7zS/FRrdSkPMyWLCnOexxmhzXsHeIMpwhMHPicq 2ComogsNr0xotrcaeoReZefbTPMophaE1Vg2LxXNZFEtrKEGYi156KTzb+X25KDaZau+ JyFA== 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:arc-authentication-results; bh=qJ9LBoC5qF2RHbn2b+C9GP2BAkoOmXUqW2nnpq6BkXA=; b=vZMxTY4Vhe/WvxPPHbbb9L+cHXx34R2s7U4axD3J+rQ7HjfCU0jyPI7snOkq6E3QQF qHTx9N0N0Hwxqu7JU0qHEJ13r5cTVrJRy3YLs92w3NZDzH7ucgDAllJS1AXrVeb8WaPh cdNtyZXBj9i5vCFMjs71QPNY/CGFz4pMv3Q5LNHPSIWEPgGjWheiPkSLDg+GaO2AeFy7 diXn7T1CSKmunLcFXyt3xGLwZGNzbmuBiLOUPFV6c6HEQWDxDRB0tKRSHICx9c+ycJej GDOroJnlmdkfiNhy2M6wd5GbbVRfZ/XYZYQNcILc6pp3VNuHTV5FHVRTcJ7fPUxP62jA uuCg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j61-v6si3351881plb.68.2018.07.18.07.16.48; Wed, 18 Jul 2018 07:16:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731493AbeGROyy (ORCPT + 1 other); Wed, 18 Jul 2018 10:54:54 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:9692 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731019AbeGROy2 (ORCPT ); Wed, 18 Jul 2018 10:54:28 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id C2C31FA207560; Wed, 18 Jul 2018 22:16:03 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.382.0; Wed, 18 Jul 2018 22:15:55 +0800 From: John Garry To: , CC: , , , John Garry Subject: [PATCH 1/9] scsi: hisi_sas: Drop hisi_sas_slot_abort() Date: Wed, 18 Jul 2018 22:14:25 +0800 Message-ID: <1531923273-193768-2-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1531923273-193768-1-git-send-email-john.garry@huawei.com> References: <1531923273-193768-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.212.75] X-CFilter-Loop: Reflected Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org For some time now we have not used hisi_sas_slot_abort() to handle erroring slots, apart from in archaic v1 hw. As such, remove this function and associated code. For v1 hw, move error handling to same scheme as other hw revisions, where we allow erroring commands to timeout. Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas.h | 1 - drivers/scsi/hisi_sas/hisi_sas_main.c | 35 ---------------------------------- drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 5 +---- 3 files changed, 1 insertion(+), 40 deletions(-) -- 1.9.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h index beda412..0ff9115 100644 --- a/drivers/scsi/hisi_sas/hisi_sas.h +++ b/drivers/scsi/hisi_sas/hisi_sas.h @@ -204,7 +204,6 @@ struct hisi_sas_slot { int ready; void *cmd_hdr; dma_addr_t cmd_hdr_dma; - struct work_struct abort_slot; struct timer_list internal_abort_timer; bool is_internal; struct hisi_sas_tmf_task *tmf; diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 781b2af..ed671af 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -281,40 +281,6 @@ static void hisi_sas_task_prep_abort(struct hisi_hba *hisi_hba, device_id, abort_flag, tag_to_abort); } -/* - * This function will issue an abort TMF regardless of whether the - * task is in the sdev or not. Then it will do the task complete - * cleanup and callbacks. - */ -static void hisi_sas_slot_abort(struct work_struct *work) -{ - struct hisi_sas_slot *abort_slot = - container_of(work, struct hisi_sas_slot, abort_slot); - struct sas_task *task = abort_slot->task; - struct hisi_hba *hisi_hba = dev_to_hisi_hba(task->dev); - struct scsi_cmnd *cmnd = task->uldd_task; - struct hisi_sas_tmf_task tmf_task; - struct scsi_lun lun; - struct device *dev = hisi_hba->dev; - int tag = abort_slot->idx; - - if (!(task->task_proto & SAS_PROTOCOL_SSP)) { - dev_err(dev, "cannot abort slot for non-ssp task\n"); - goto out; - } - - int_to_scsilun(cmnd->device->lun, &lun); - tmf_task.tmf = TMF_ABORT_TASK; - tmf_task.tag_of_task_to_be_managed = cpu_to_le16(tag); - - hisi_sas_debug_issue_ssp_tmf(task->dev, lun.scsi_lun, &tmf_task); -out: - /* Do cleanup for this task */ - hisi_sas_slot_task_free(hisi_hba, task, abort_slot); - if (task->task_done) - task->task_done(task); -} - static int hisi_sas_task_prep(struct sas_task *task, struct hisi_sas_dq **dq_pointer, bool is_tmf, struct hisi_sas_tmf_task *tmf, @@ -451,7 +417,6 @@ static int hisi_sas_task_prep(struct sas_task *task, slot->tmf = tmf; slot->is_internal = is_tmf; task->lldd_task = slot; - INIT_WORK(&slot->abort_slot, hisi_sas_slot_abort); memset(slot->cmd_hdr, 0, sizeof(struct hisi_sas_cmd_hdr)); memset(hisi_sas_cmd_hdr_addr_mem(slot), 0, HISI_SAS_COMMAND_TABLE_SZ); diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c index 3277442..7dc6874 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c @@ -1296,11 +1296,8 @@ static int slot_complete_v1_hw(struct hisi_hba *hisi_hba, !(cmplt_hdr_data & CMPLT_HDR_RSPNS_XFRD_MSK)) { slot_err_v1_hw(hisi_hba, task, slot); - if (unlikely(slot->abort)) { - queue_work(hisi_hba->wq, &slot->abort_slot); - /* immediately return and do not complete */ + if (unlikely(slot->abort)) return ts->stat; - } goto out; } From patchwork Wed Jul 18 14:14:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 142282 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp594042ljj; Wed, 18 Jul 2018 07:16:23 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfwwSReSxjmJm4RI9QKR420ta6Aej6W3OaoHYSbz3SFMYnyzeXmwGP5jIxk7tdskJytt6+D X-Received: by 2002:a63:cf10:: with SMTP id j16-v6mr6018614pgg.238.1531923383395; Wed, 18 Jul 2018 07:16:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531923383; cv=none; d=google.com; s=arc-20160816; b=BFbJm/jbAGu4uZvIUxG8FwJT7P69UMRQpJjYbn7epeQRFE5iZMBu6bnwEGOgCwV4zs 4MyiqkKDQv4cWf8V0j5iYCLOlR0cJyG80UQ+D8aG/lDiYazxSoQcqPsuR22Ad+QEmokB OECTfKHIAk0IPjKKzinK86bZie+Z5WMeLP+oDGcj3/ZptVEOg6+SURKg6ohX4IuxuBTQ sThj5YYeCC4REXY5vy+zONUDC0PvllfH4nCZkfereS1RORR3mMZ3VJyECS1Tawiia2pr YtCJv4BfH5zrB6ip2tPMZbkG68eCPG55oF0gQcSywrShUS6QcBRFymk5nbvYGSRSp4vX pzKA== 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:arc-authentication-results; bh=iH6gtWiY7FDlVLH8OlklQ44S6I7rFLCvn6TJJlsFodE=; b=HyGSwOHT4TXLfINOwO69fTFJUqidZZxog5u2uMSQcUH2mBuppRegAfZUnsySmGVo8L UEPIktbEBLWCIY4bRIoLu5/9yfEaW+c6kAFA4MM38jKgoyUHdlWAz6/0YWzt2XeGLH6O BYxcxAEgY2dBI77nNVRQzgepHLvmSMnpo7HH1lxGQJF73MvtaQzzeFF+Txmxjw911yVX yH+Q3nxJ1YAyIZ5n3f4LZPFf6/yuEO6fdomldv0kMyRaCTHVaEh/UOA3Vyo+KjFW3+qJ 1IZnb8LWKxF1YgkHAek8a74WyPLSxzpVh9/iWik2YVDggu4LN83j0emd77AjJ+9bt1Q+ uYOg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s11-v6si3182834plp.464.2018.07.18.07.16.23; Wed, 18 Jul 2018 07:16:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731282AbeGROy3 (ORCPT + 1 other); Wed, 18 Jul 2018 10:54:29 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:9696 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727083AbeGROy2 (ORCPT ); Wed, 18 Jul 2018 10:54:28 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 186C696AE85A1; Wed, 18 Jul 2018 22:16:04 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.382.0; Wed, 18 Jul 2018 22:15:58 +0800 From: John Garry To: , CC: , , , Xiaofei Tan , "John Garry" Subject: [PATCH 8/9] scsi: hisi_sas: add memory barrier in task delivery function Date: Wed, 18 Jul 2018 22:14:32 +0800 Message-ID: <1531923273-193768-9-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1531923273-193768-1-git-send-email-john.garry@huawei.com> References: <1531923273-193768-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.212.75] X-CFilter-Loop: Reflected Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Xiaofei Tan In task start delivery function, we need to add a memory barrier to prevent re-ordering of reading memory by hardware. Because the slot data is set in task prepare function and it could be running in another CPU. This patch adds an memory barrier after s->ready is read in the task start delivery function, and uses WRITE_ONCE() in the places where s->ready is set to ensure that the compiler does not re-order. Signed-off-by: Xiaofei Tan Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_main.c | 4 ++-- drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 15 ++++++++++----- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 15 ++++++++++----- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 15 ++++++++++----- 4 files changed, 32 insertions(+), 17 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 432a38a..a4e2e6a 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -446,7 +446,7 @@ static int hisi_sas_task_prep(struct sas_task *task, spin_unlock_irqrestore(&task->task_state_lock, flags); ++(*pass); - slot->ready = 1; + WRITE_ONCE(slot->ready, 1); return 0; @@ -1749,7 +1749,7 @@ static int hisi_sas_query_task(struct sas_task *task) task->task_state_flags |= SAS_TASK_AT_INITIATOR; spin_unlock_irqrestore(&task->task_state_lock, flags); - slot->ready = 1; + WRITE_ONCE(slot->ready, 1); /* send abort command to the chip */ spin_lock_irqsave(&dq->lock, flags); list_add_tail(&slot->entry, &sas_dev->list); diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c index 7dc6874..8f60f0e 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c @@ -903,23 +903,28 @@ static int get_wideport_bitmap_v1_hw(struct hisi_hba *hisi_hba, int port_id) static void start_delivery_v1_hw(struct hisi_sas_dq *dq) { struct hisi_hba *hisi_hba = dq->hisi_hba; - struct hisi_sas_slot *s, *s1; + struct hisi_sas_slot *s, *s1, *s2 = NULL; struct list_head *dq_list; int dlvry_queue = dq->id; - int wp, count = 0; + int wp; dq_list = &dq->list; list_for_each_entry_safe(s, s1, &dq->list, delivery) { if (!s->ready) break; - count++; - wp = (s->dlvry_queue_slot + 1) % HISI_SAS_QUEUE_SLOTS; + s2 = s; list_del(&s->delivery); } - if (!count) + if (!s2) return; + /* + * Ensure that memories for slots built on other CPUs is observed. + */ + smp_rmb(); + wp = (s2->dlvry_queue_slot + 1) % HISI_SAS_QUEUE_SLOTS; + hisi_sas_write32(hisi_hba, DLVRY_Q_0_WR_PTR + (dlvry_queue * 0x14), wp); } diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c index 159576e..5a3d6a7 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c @@ -1665,23 +1665,28 @@ static int get_wideport_bitmap_v2_hw(struct hisi_hba *hisi_hba, int port_id) static void start_delivery_v2_hw(struct hisi_sas_dq *dq) { struct hisi_hba *hisi_hba = dq->hisi_hba; - struct hisi_sas_slot *s, *s1; + struct hisi_sas_slot *s, *s1, *s2 = NULL; struct list_head *dq_list; int dlvry_queue = dq->id; - int wp, count = 0; + int wp; dq_list = &dq->list; list_for_each_entry_safe(s, s1, &dq->list, delivery) { if (!s->ready) break; - count++; - wp = (s->dlvry_queue_slot + 1) % HISI_SAS_QUEUE_SLOTS; + s2 = s; list_del(&s->delivery); } - if (!count) + if (!s2) return; + /* + * Ensure that memories for slots built on other CPUs is observed. + */ + smp_rmb(); + wp = (s2->dlvry_queue_slot + 1) % HISI_SAS_QUEUE_SLOTS; + hisi_sas_write32(hisi_hba, DLVRY_Q_0_WR_PTR + (dlvry_queue * 0x14), wp); } diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index 3d20fcf..70e2299 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -882,23 +882,28 @@ static int get_wideport_bitmap_v3_hw(struct hisi_hba *hisi_hba, int port_id) static void start_delivery_v3_hw(struct hisi_sas_dq *dq) { struct hisi_hba *hisi_hba = dq->hisi_hba; - struct hisi_sas_slot *s, *s1; + struct hisi_sas_slot *s, *s1, *s2 = NULL; struct list_head *dq_list; int dlvry_queue = dq->id; - int wp, count = 0; + int wp; dq_list = &dq->list; list_for_each_entry_safe(s, s1, &dq->list, delivery) { if (!s->ready) break; - count++; - wp = (s->dlvry_queue_slot + 1) % HISI_SAS_QUEUE_SLOTS; + s2 = s; list_del(&s->delivery); } - if (!count) + if (!s2) return; + /* + * Ensure that memories for slots built on other CPUs is observed. + */ + smp_rmb(); + wp = (s2->dlvry_queue_slot + 1) % HISI_SAS_QUEUE_SLOTS; + hisi_sas_write32(hisi_hba, DLVRY_Q_0_WR_PTR + (dlvry_queue * 0x14), wp); }