From patchwork Mon May 21 10:09:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 136448 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp121799lji; Mon, 21 May 2018 03:14:28 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpxa6HKINvlzazdF2RMhpN8Lyl5aEu0iseR5FGp8M3+Vl2BQ7C29B8EXX4/3FkMQQ53eYi1 X-Received: by 2002:a17:902:2804:: with SMTP id e4-v6mr19680674plb.153.1526897668493; Mon, 21 May 2018 03:14:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526897668; cv=none; d=google.com; s=arc-20160816; b=0XzC8qBm6gV/rhWs6tdY9Q8IMbt2e9wvkjT4J+hdti0zVxs8FW0QDH+KD/jdz7+qmj 5yyUk6xX5dn/hv+9UUbrOcIy8TQZLnMGRFVD1C7rpPClqLXOIFrWgvy2gwq/gzQlBsEl 7Z56+9vGQgLni1pbaSsUnqADDlJdmUms79xBgoVxDYJejmtJusk/kfHJhF2uvWcCsD8W Aqabgguq1AaTz+HjXTvpzpgFiQ/2k/dpvA9d2ttbGZbcZn37yc0n5DmajQGjNK2HKD5U UK5nZuRm9m89sRY1um2L4en//jMxNc2mdbgDYx6tIYzwdY3rDshHDfsKbybre5+ocSDx dvUA== 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=R+sLDUSn8hXc/MgrFOjeNEg5JkK7SJgyLoIqiayTsug=; b=gil+gzqsp16ntS+kPnBmpX2+vEUWHts8TGly7arV+2neLwwMDmFgk1jdqcBk/m9ibn Rp1uLSXLGXGHugghFMLC/g75yrPyjz5PKHlN2oLEjZ497OdkLNr/EZcqRBRqCOy4oSxK BLRHiajXnhP52IaXP3/LjxM3VkHMJNAOSYtVgLUIol7Xwr0DGYozoU/WvyNseaHqrd9i UV5QkvFfu9sOuACyZrJv5PW2QYlmpKKSRScAYGvw6XYEqPr2O27RWB6hfU5Ncojq0ddS GWUPU1RA/P/Rzxh/SGscHVp+PB3Y7XWZH6/GvErVjVX/Kwvyn86WrjdWNW6jv3Idxr3/ BtGw== 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 c4-v6si7665566pga.522.2018.05.21.03.14.28; Mon, 21 May 2018 03:14:28 -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 S1752838AbeEUKOZ (ORCPT + 29 others); Mon, 21 May 2018 06:14:25 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:55756 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752257AbeEUKLl (ORCPT ); Mon, 21 May 2018 06:11:41 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 70E60EFD871A4; Mon, 21 May 2018 18:11:35 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.382.0; Mon, 21 May 2018 18:11:28 +0800 From: John Garry To: , CC: , , , Xiang Chen , "John Garry" Subject: [PATCH 03/13] scsi: hisi_sas: Change common allocation mode of device id Date: Mon, 21 May 2018 18:09:15 +0800 Message-ID: <1526897365-228549-4-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1526897365-228549-1-git-send-email-john.garry@huawei.com> References: <1526897365-228549-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 To reduce possibility of hitting unknown SoC bugs and aid debugging and test, change allocation mode of device id from last used device id instead of lowest available index. Signed-off-by: Xiang Chen Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas.h | 1 + drivers/scsi/hisi_sas/hisi_sas_main.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) -- 1.9.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h index 3c88400..b4717bd 100644 --- a/drivers/scsi/hisi_sas/hisi_sas.h +++ b/drivers/scsi/hisi_sas/hisi_sas.h @@ -275,6 +275,7 @@ struct hisi_hba { int slot_index_count; int last_slot_index; + int last_dev_id; unsigned long *slot_index_tags; unsigned long reject_stp_links_msk; diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 1d300a2..04a3eb4 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -596,10 +596,12 @@ static struct hisi_sas_device *hisi_sas_alloc_dev(struct domain_device *device) struct hisi_hba *hisi_hba = dev_to_hisi_hba(device); struct hisi_sas_device *sas_dev = NULL; unsigned long flags; + int last = hisi_hba->last_dev_id; + int first = (hisi_hba->last_dev_id + 1) % HISI_SAS_MAX_DEVICES; int i; spin_lock_irqsave(&hisi_hba->lock, flags); - for (i = 0; i < HISI_SAS_MAX_DEVICES; i++) { + for (i = first; i != last; i %= HISI_SAS_MAX_DEVICES) { if (hisi_hba->devices[i].dev_type == SAS_PHY_UNUSED) { int queue = i % hisi_hba->queue_count; struct hisi_sas_dq *dq = &hisi_hba->dq[queue]; @@ -614,7 +616,9 @@ static struct hisi_sas_device *hisi_sas_alloc_dev(struct domain_device *device) INIT_LIST_HEAD(&hisi_hba->devices[i].list); break; } + i++; } + hisi_hba->last_dev_id = i; spin_unlock_irqrestore(&hisi_hba->lock, flags); return sas_dev;