From patchwork Mon May 21 10:09:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 136440 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp119818lji; Mon, 21 May 2018 03:12:33 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr3DlROE+KAShc2YQpsYNchVFac+V5FvNYCctXJyzjYUlrEizWlj/KprFIklfmDjPb/xS1m X-Received: by 2002:a63:aa4c:: with SMTP id x12-v6mr14688800pgo.398.1526897553264; Mon, 21 May 2018 03:12:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526897553; cv=none; d=google.com; s=arc-20160816; b=GvfVa6vu8rLOvkHVnhiVt+KaKtscfhTFN71GkTq4jIiP6kvD4AsglBcoB5NP2uWxV2 bmHK7IdB6/jmUR2Jt9WCQ5TnqW8rCNrqqRkjUB5m/MWsHXOws1mBC+pp131Vz97cCnbO JTuLr0qpsjaYzGIWAByODToLsUFLapk7CfPlVn0ZxWQ/F/78qKYrTK+bpDK4XN0b2I04 /yM3MnPxZmxSyCOHDtxMzr+sKRlpmE8s4pLOaOMklRe4gKjFNth5YmuN1/cj9/GO/1Qp jLSGjcseezcNerbVgj67FHBA6Lvf2rZy/e63tIZ4PLoGROU3rM3whkzibzG8baTk4FbF 7QpA== 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=QyFoalzvdBZvMg4ZnKkzofwL+0j2jCAWMogmI0/iBPM=; b=zP/eqwVtKMixsXXU87IwsO3/XjhyHwKBTAkywhuIEOQdWcb7QOkfifZc46s27PrA2P 1shCDhpHup5Rw/WqVLrntGUhalaBhTTFPc6ZJqCn7a/naaDLNx48nCVx6qYPboFunNTT YitYvNUq2LAsGJVzCYUVzI976X8JENkLaVMsWBSdn9l9UsfgYmnIXnpvJILhsDQ7i69z cbXDyjMJqUfaXAt6CHpucJIwCvW2XTVWc3BE4Q0yZ7JgHoz3PTJnBy9bg65XfuWTL4sO 93+y1hoGsxlf5/BGbJYerLns1T+T2kvoxXfTDXYTq5yCqHYGRSUQM+Pngyj42g9dOPHm E5PQ== 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 e184-v6si11062156pgc.475.2018.05.21.03.12.33; Mon, 21 May 2018 03:12:33 -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 S1752671AbeEUKLp (ORCPT + 29 others); Mon, 21 May 2018 06:11:45 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:55747 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752256AbeEUKLj (ORCPT ); Mon, 21 May 2018 06:11:39 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 627F3EF1B8B3A; 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 02/13] scsi: hisi_sas: change slot index allocation mode Date: Mon, 21 May 2018 18:09:14 +0800 Message-ID: <1526897365-228549-3-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 Currently we find the lowest available empty bit in the IPTT bitmap to allocate the IPTT for a command. To reduce possibility of hitting unknown SoC bugs and also aid in the debugging of those same bugs, change the allocation mode. The next allocation method is to use the next free slot adjacent to the most recently allocated slot, in a round-robin fashion. 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 | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) -- 1.9.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h index 52fc709..3c88400 100644 --- a/drivers/scsi/hisi_sas/hisi_sas.h +++ b/drivers/scsi/hisi_sas/hisi_sas.h @@ -274,6 +274,7 @@ struct hisi_hba { struct workqueue_struct *wq; int slot_index_count; + int last_slot_index; 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 f822d6f..1d300a2 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -195,11 +195,18 @@ static int hisi_sas_slot_index_alloc(struct hisi_hba *hisi_hba, int *slot_idx) unsigned int index; void *bitmap = hisi_hba->slot_index_tags; - index = find_first_zero_bit(bitmap, hisi_hba->slot_index_count); - if (index >= hisi_hba->slot_index_count) - return -SAS_QUEUE_FULL; + index = find_next_zero_bit(bitmap, hisi_hba->slot_index_count, + 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) + return -SAS_QUEUE_FULL; + } hisi_sas_slot_index_set(hisi_hba, index); *slot_idx = index; + hisi_hba->last_slot_index = index; + return 0; }