From patchwork Tue Oct 25 10:32:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 10704 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp917658wru; Tue, 25 Oct 2022 03:15:12 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6Rm97jUVtTLYp/JRe7Lgskjl0TC1SmhRuX8KCV9vpY3L3Yk2O09AK/XrNMO/zsM4Yww4SY X-Received: by 2002:a17:90b:d88:b0:211:4d8:1c93 with SMTP id bg8-20020a17090b0d8800b0021104d81c93mr33506225pjb.41.1666692912394; Tue, 25 Oct 2022 03:15:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666692912; cv=none; d=google.com; s=arc-20160816; b=pE0i0yqIVlpjwiqyJo7DKvNuGdpQZm9oBabl75Xpe/WiYvWLKJJFyTsj1/qfFpcKD/ ZYa+dJSXExYycskRFhuUkveWqLjXXMCZU+EpXin8imL53vVK4yBqwPY1lk0V7AFGt/dR SVlrfh4MiQHJ2RMyf25kZLD1icDiAatlAPuua4yN2qjCuwzJE7IYzXZ5BDzXVH6gTLqb 20Ea01PuXHumIjRjZgmkATJYCuyfqkaPE1m1z8y6uatyBkBaN/qezhjK7pgQHdEWKlYd xfNF5L9AyohRIBqkffP5cN+jtHtenf16HSGnqouSZP7zUBCZ5WGJzbiZ6V730bOacGsP JOIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=xU0JCWPH/TTft2uUmja1ZRjUeg1A15rMzEr8btk0QYU=; b=n/ZarARb9UZZOOdeI0UqGNvAZx2yMsIckbKhBcVqGh4NtlvbJnhHz6buhoea1TAfhB uju4mE1R4VgBWdQSy3pO12aZbgtJiVB2Lxv5/BmvNHFEkZUXsyxDdLNv62Y2It94YOF8 1P/gvzU6g4Tb3lJi/y+Q+eLdV+NWQU0ZzaIBMEpKVeWxpI68nMO0C+2u88uEBrsf1xF2 Zfhd1uu9h02tHzt2z6PfSP3vB3hB8a0mGvfEGSAHjrlq8RG/nJNupb6qP/K3+2ACk9Wk dQfTaaPFVtHUc1imePu2ZtpS4mAjeKkm8gsPRwOMPPciOAfQR6M8bgdKg4smgevMMCxv gXyg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e34-20020a635462000000b0042ff6b15129si2412591pgm.2.2022.10.25.03.14.58; Tue, 25 Oct 2022 03:15:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232357AbiJYKLw (ORCPT + 99 others); Tue, 25 Oct 2022 06:11:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230361AbiJYKKq (ORCPT ); Tue, 25 Oct 2022 06:10:46 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6018F12741E; Tue, 25 Oct 2022 03:03:39 -0700 (PDT) Received: from fraeml702-chm.china.huawei.com (unknown [172.18.147.226]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4MxS9L6lMFz67MQZ; Tue, 25 Oct 2022 18:00:06 +0800 (CST) Received: from lhrpeml500003.china.huawei.com (7.191.162.67) by fraeml702-chm.china.huawei.com (10.206.15.51) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2375.31; Tue, 25 Oct 2022 12:03:37 +0200 Received: from localhost.localdomain (10.69.192.58) by lhrpeml500003.china.huawei.com (7.191.162.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 25 Oct 2022 11:03:33 +0100 From: John Garry To: , , , , , , , CC: , , , , , , , John Garry Subject: [PATCH RFC v3 6/7] scsi: mvsas: Remove internal tag handling Date: Tue, 25 Oct 2022 18:32:55 +0800 Message-ID: <1666693976-181094-7-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1666693976-181094-1-git-send-email-john.garry@huawei.com> References: <1666693976-181094-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.58] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To lhrpeml500003.china.huawei.com (7.191.162.67) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747654187342231934?= X-GMAIL-MSGID: =?utf-8?q?1747654187342231934?= Now that any sas_task which we're sent has a request associated, delete internal tag management. Signed-off-by: John Garry --- drivers/scsi/mvsas/mv_init.c | 11 -------- drivers/scsi/mvsas/mv_sas.c | 55 ++---------------------------------- drivers/scsi/mvsas/mv_sas.h | 1 - 3 files changed, 2 insertions(+), 65 deletions(-) diff --git a/drivers/scsi/mvsas/mv_init.c b/drivers/scsi/mvsas/mv_init.c index e1b6cc196cef..9cb8d5b315db 100644 --- a/drivers/scsi/mvsas/mv_init.c +++ b/drivers/scsi/mvsas/mv_init.c @@ -147,7 +147,6 @@ static void mvs_free(struct mvs_info *mvi) scsi_host_put(mvi->shost); list_for_each_entry(mwq, &mvi->wq_list, entry) cancel_delayed_work(&mwq->work_q); - kfree(mvi->rsvd_tags); kfree(mvi); } @@ -371,10 +370,6 @@ static struct mvs_info *mvs_pci_alloc(struct pci_dev *pdev, mvi->sas = sha; mvi->shost = shost; - mvi->rsvd_tags = bitmap_zalloc(MVS_RSVD_SLOTS, GFP_KERNEL); - if (!mvi->rsvd_tags) - goto err_out; - if (MVS_CHIP_DISP->chip_ioremap(mvi)) goto err_out; if (!mvs_alloc(mvi, shost)) @@ -473,12 +468,6 @@ static void mvs_post_sas_ha_init(struct Scsi_Host *shost, else can_queue = MVS_CHIP_SLOT_SZ; - /* - * Carve out MVS_RSVD_SLOTS slots internally until every sas_task we're sent - * has a request associated. - */ - can_queue -= MVS_RSVD_SLOTS; - shost->sg_tablesize = min_t(u16, SG_ALL, MVS_MAX_SG); shost->can_queue = can_queue; mvi->shost->cmd_per_lun = MVS_QUEUE_SIZE; diff --git a/drivers/scsi/mvsas/mv_sas.c b/drivers/scsi/mvsas/mv_sas.c index 9978c424214c..3c92fc48680d 100644 --- a/drivers/scsi/mvsas/mv_sas.c +++ b/drivers/scsi/mvsas/mv_sas.c @@ -20,40 +20,6 @@ static int mvs_find_tag(struct mvs_info *mvi, struct sas_task *task, u32 *tag) return 0; } -static void mvs_tag_clear(struct mvs_info *mvi, u32 tag) -{ - void *bitmap = mvi->rsvd_tags; - clear_bit(tag, bitmap); -} - -static void mvs_tag_free(struct mvs_info *mvi, u32 tag) -{ - if (tag >= MVS_RSVD_SLOTS) - return; - - mvs_tag_clear(mvi, tag); -} - -static void mvs_tag_set(struct mvs_info *mvi, unsigned int tag) -{ - void *bitmap = mvi->rsvd_tags; - set_bit(tag, bitmap); -} - -static int mvs_tag_alloc(struct mvs_info *mvi, u32 *tag_out) -{ - unsigned int index, tag; - void *bitmap = mvi->rsvd_tags; - - index = find_first_zero_bit(bitmap, MVS_RSVD_SLOTS); - tag = index; - if (tag >= MVS_RSVD_SLOTS) - return -SAS_QUEUE_FULL; - mvs_tag_set(mvi, tag); - *tag_out = tag; - return 0; -} - static struct mvs_info *mvs_find_dev_mvi(struct domain_device *dev) { unsigned long i = 0, j = 0, hi = 0; @@ -765,13 +731,7 @@ static int mvs_task_prep(struct sas_task *task, struct mvs_info *mvi, int is_tmf } rq = sas_task_find_rq(task); - if (rq) { - tag = rq->tag + MVS_RSVD_SLOTS; - } else { - rc = mvs_tag_alloc(mvi, &tag); - if (rc) - goto err_out; - } + tag = rq->tag; slot = &mvi->slot_info[tag]; @@ -782,7 +742,7 @@ static int mvs_task_prep(struct sas_task *task, struct mvs_info *mvi, int is_tmf slot->buf = dma_pool_zalloc(mvi->dma_pool, GFP_ATOMIC, &slot->buf_dma); if (!slot->buf) { rc = -ENOMEM; - goto err_out_tag; + goto err_out; } tei.task = task; @@ -826,8 +786,6 @@ static int mvs_task_prep(struct sas_task *task, struct mvs_info *mvi, int is_tmf err_out_slot_buf: dma_pool_free(mvi->dma_pool, slot->buf, slot->buf_dma); -err_out_tag: - mvs_tag_free(mvi, tag); err_out: dev_printk(KERN_ERR, mvi->dev, "mvsas prep failed[%d]!\n", rc); @@ -863,12 +821,6 @@ int mvs_queue_command(struct sas_task *task, gfp_t gfp_flags) return rc; } -static void mvs_slot_free(struct mvs_info *mvi, u32 rx_desc) -{ - u32 slot_idx = rx_desc & RXQ_SLOT_MASK; - mvs_tag_free(mvi, slot_idx); -} - static void mvs_slot_task_free(struct mvs_info *mvi, struct sas_task *task, struct mvs_slot_info *slot, u32 slot_idx) { @@ -906,7 +858,6 @@ static void mvs_slot_task_free(struct mvs_info *mvi, struct sas_task *task, slot->task = NULL; slot->port = NULL; slot->slot_tag = 0xFFFFFFFF; - mvs_slot_free(mvi, slot_idx); } static void mvs_update_wideport(struct mvs_info *mvi, int phy_no) @@ -1913,8 +1864,6 @@ int mvs_int_rx(struct mvs_info *mvi, bool self_clear) } else if (rx_desc & RXQ_ERR) { if (!(rx_desc & RXQ_DONE)) mvs_slot_complete(mvi, rx_desc, 0); - } else if (rx_desc & RXQ_SLOT_RESET) { - mvs_slot_free(mvi, rx_desc); } } diff --git a/drivers/scsi/mvsas/mv_sas.h b/drivers/scsi/mvsas/mv_sas.h index 68df771e2975..bc3b5711fc07 100644 --- a/drivers/scsi/mvsas/mv_sas.h +++ b/drivers/scsi/mvsas/mv_sas.h @@ -370,7 +370,6 @@ struct mvs_info { u32 chip_id; const struct mvs_chip_info *chip; - unsigned long *rsvd_tags; /* further per-slot information */ struct mvs_phy phy[MVS_MAX_PHYS]; struct mvs_port port[MVS_MAX_PHYS];