From patchwork Tue Oct 24 15:51:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 116954 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp5912652qgn; Tue, 24 Oct 2017 08:05:35 -0700 (PDT) X-Google-Smtp-Source: ABhQp+T9PVRfD4e26v4ZwcVO93pC+T8ZC9gPGPnU6diZB3xzNHbLlUstbaMkm+1MUD3RYcOBvLiR X-Received: by 10.101.71.197 with SMTP id f5mr14705922pgs.266.1508857535848; Tue, 24 Oct 2017 08:05:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508857535; cv=none; d=google.com; s=arc-20160816; b=NleZWVAWi2Q+hA4aU9x1CIDSTsgPAZ4C4Jd9gbEp8QGfxzdDXwJ1y1zW208ZbumgYV YX01pRfoEgsJZH3e4XCjnfbgtYMHCz96KzmpITLaBnunZXF/1546uVz32MH6tzz52CT4 mm6gMb9qyKVWr2C8q7DAiPzzNH4IYRXAB5O2BkR72mYa7eeb+q5CWP5wpN9SsNgNoO7N siQ1ypCaUycIk8N1RQgx8NYg9b/Yuvd64N8m5Wga1/Wm9lo05Ebxn7xrAd3+ZWriNdv0 7A70IAZva7GU2Ud9TL9SssI0Thhp+M4xUZGO5LKqtOrlYF16y0ek4E13kA6RnpxYJo1r 4Xng== 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=zP1GPofjFAp1WAF8JbeMzRFQRQPocXQSvsCsTUcH8To=; b=MyGhP/JOoSmHO3ECXLYguIToIeRyTyxMy2+t03mHSksAiVVFfRflmFuJAXpps/w4Lk AXioaCKr2rHXi8drc3RLe6k5AULK9jG8WGpvq8eoRmz6qlQRLhApmqtEW1YtJ5vXgTmS hOGc4PqaezBL+MZ2fv3ycut+GrMUj9ABmGUjclmMKzHMTnch+bc6iZuzUX24quD7+7Zi fogvNwAHGjplS78BRY4/kFuKNb55IO+oouIt25tuFTyybVrlIDQYW/qC/dqUD4BFhIq3 RcxzM/B1TIkHTqX07AVkiNC9VmlhZUVqCGeYxzTtUueivIeU7MfYGcSIpF2H8Vmx1FiS N00A== 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 f26si344004pff.119.2017.10.24.08.05.35; Tue, 24 Oct 2017 08:05:35 -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 S932297AbdJXPFc (ORCPT + 27 others); Tue, 24 Oct 2017 11:05:32 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:50516 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751354AbdJXPF1 (ORCPT ); Tue, 24 Oct 2017 11:05:27 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 015D2E98343FF; Tue, 24 Oct 2017 23:05:23 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.361.1; Tue, 24 Oct 2017 23:05:16 +0800 From: John Garry To: , CC: , , , , Xiang Chen , John Garry Subject: [PATCH 04/19] scsi: hisi_sas: grab hisi_hba.lock when processing slots Date: Tue, 24 Oct 2017 23:51:34 +0800 Message-ID: <1508860309-212397-5-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1508860309-212397-1-git-send-email-john.garry@huawei.com> References: <1508860309-212397-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 When adding/removing slots from device list, we need to lock this operation with hisi_hba lock for safety. This patch adds missing instances of this. 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_v2_hw.c | 2 ++ drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) -- 1.9.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index e038bdf..254af67 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -401,7 +401,9 @@ static int hisi_sas_task_prep(struct sas_task *task, struct hisi_sas_dq goto err_out_buf; } + spin_lock_irqsave(&hisi_hba->lock, flags); list_add_tail(&slot->entry, &sas_dev->list); + spin_unlock_irqrestore(&hisi_hba->lock, flags); spin_lock_irqsave(&task->task_state_lock, flags); task->task_state_flags |= SAS_TASK_AT_INITIATOR; spin_unlock_irqrestore(&task->task_state_lock, flags); @@ -1387,8 +1389,9 @@ static int hisi_sas_query_task(struct sas_task *task) if (rc) goto err_out_buf; - + spin_lock_irqsave(&hisi_hba->lock, flags); list_add_tail(&slot->entry, &sas_dev->list); + spin_unlock_irqrestore(&hisi_hba->lock, flags); spin_lock_irqsave(&task->task_state_lock, flags); task->task_state_flags |= SAS_TASK_AT_INITIATOR; spin_unlock_irqrestore(&task->task_state_lock, flags); diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c index 73d12ff..3b2e5b5 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c @@ -2378,7 +2378,9 @@ static void slot_err_v2_hw(struct hisi_hba *hisi_hba, if (unlikely(aborted)) { ts->stat = SAS_ABORTED_TASK; + spin_lock_irqsave(&hisi_hba->lock, flags); hisi_sas_slot_task_free(hisi_hba, task, slot); + spin_unlock_irqrestore(&hisi_hba->lock, flags); return -1; } diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index d60501f..38eeba9 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -1400,7 +1400,9 @@ static irqreturn_t int_chnl_int_v3_hw(int irq_no, void *p) ts->resp = SAS_TASK_COMPLETE; if (unlikely(aborted)) { ts->stat = SAS_ABORTED_TASK; + spin_lock_irqsave(&hisi_hba->lock, flags); hisi_sas_slot_task_free(hisi_hba, task, slot); + spin_unlock_irqrestore(&hisi_hba->lock, flags); return -1; }