From patchwork Thu Oct 24 14:21:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 177524 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2265896ill; Thu, 24 Oct 2019 07:25:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqyBg75+P2rsTn7hU0oDoavMM4kNJmq5x9SOtXR6+WzRluIlg+QWuavKEqK6NL4q1B9TcBxU X-Received: by 2002:a17:906:2550:: with SMTP id j16mr12352989ejb.239.1571927113962; Thu, 24 Oct 2019 07:25:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571927113; cv=none; d=google.com; s=arc-20160816; b=h0flYxPEoP3QorCTy3HTTWNQ3CTxnWMriAdI8vsGOJzV83td51cokdPKv2vIhscjvw ww5XJPTMevjFsZlbaBjSQgBHwofFgthzXR2bZAVwvInuRbQfDSJqlmVCmywVXmDym4FJ v9nKeCRIzj8O0ZFTFfgiKtBOaOx/mH4iZ/VAfFl6T1fGlSEpac3My0pLS9r2kuCh50MP dWATKEh/u7U6W4Ovz5cTeX0qJgZ12lh+EG3iuVsOD1Twex18ncpLzM90yLGzTK0F1mzG XgGt3b5kKfF4B/sQ/HcAsVW4l8uYPx2CgjVJ/+VkHkKNUhesZWVnElmvST/OrO4ktAgD 0hrw== 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=dthpy2cdcdaJydXm3i2mbXcxDOdRZHYgtIYzbd2yNic=; b=L3k6smWXee7jTRYt87OguDhqZUKZW7WTfu7xi3gLCfYrc+9DwYUdZ7GQebqee8rS0h /wnTBYyG829iDvTkDdpGLv6KHpKCHcr0t1FRf8m1QFH/pDQpl2iBqx39GX5tYRR7cu9n rD9rFeeAmYpS4S/rW/hez0xhgb9lwQZhhODiLpfRzm6JrBikpErrWyuiCNZvpnd84Xt9 pF/t1Bw+RjT9f9FqIh2AYF1kM1d48zKF+PN/9WkY431e7FCE33Vl+L8Y4F9JSPnxvea/ Bw+i3WODY0+reHT5liZG9CIZZApsoEzy3BPTRs46/W4FfzPR7Cs4o16OIq70DcKzzmy4 R9Zw== 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 l22si14480470ejr.149.2019.10.24.07.25.13; Thu, 24 Oct 2019 07:25:13 -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 S2502827AbfJXOZJ (ORCPT + 26 others); Thu, 24 Oct 2019 10:25:09 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:32834 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732393AbfJXOYy (ORCPT ); Thu, 24 Oct 2019 10:24:54 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 46566FB19A85F1FDF07C; Thu, 24 Oct 2019 22:24:50 +0800 (CST) Received: from localhost.localdomain (10.69.192.58) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.439.0; Thu, 24 Oct 2019 22:24:41 +0800 From: John Garry To: , CC: , , , , , "John Garry" Subject: [PATCH 4/6] scsi: hisi_sas: Add slot_index_alloc_v3_hw() and slot_index_free_v3_hw() Date: Thu, 24 Oct 2019 22:21:19 +0800 Message-ID: <1571926881-75524-5-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1571926881-75524-1-git-send-email-john.garry@huawei.com> References: <1571926881-75524-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.58] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We will want to make these non-generic in future. Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 27 ++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) -- 2.17.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index a46717efb870..497bbf6964f6 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -563,6 +563,31 @@ static int bitmaps_alloc_v3_hw(struct hisi_hba *hisi_hba) GFP_KERNEL, dev_to_node(hisi_hba->dev)); } +static int slot_index_alloc_v3_hw(struct hisi_hba *hisi_hba, + struct domain_device *device, + struct scsi_cmnd *scmd) +{ + struct sbitmap *slot_index_tags = &hisi_hba->slot_index_tags; + int index; + + if (scmd) + return scmd->request->tag; + + index = sbitmap_get(slot_index_tags, 0, false); + if (index == -1) + return index; + return index + HISI_SAS_UNRESERVED_IPTT; +} + +static void slot_index_free_v3_hw(struct hisi_hba *hisi_hba, int slot_idx) +{ + struct sbitmap *slot_index_tags = &hisi_hba->slot_index_tags; + + if (slot_idx >= HISI_SAS_UNRESERVED_IPTT) + sbitmap_clear_bit(slot_index_tags, + slot_idx - HISI_SAS_UNRESERVED_IPTT); +} + static void init_reg_v3_hw(struct hisi_hba *hisi_hba) { int i; @@ -3090,6 +3115,8 @@ static struct scsi_host_template sht_v3_hw = { static const struct hisi_sas_hw hisi_sas_v3_hw = { .hw_init = hisi_sas_v3_init, .setup_itct = setup_itct_v3_hw, + .slot_index_alloc = slot_index_alloc_v3_hw, + .slot_index_free = slot_index_free_v3_hw, .bitmaps_alloc = bitmaps_alloc_v3_hw, .get_wideport_bitmap = get_wideport_bitmap_v3_hw, .complete_hdr_size = sizeof(struct hisi_sas_complete_v3_hdr),