From patchwork Wed Dec 19 15:56:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 154272 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp5092385ljp; Wed, 19 Dec 2018 07:56:03 -0800 (PST) X-Google-Smtp-Source: AFSGD/VqWRWCNKP8IcIo/DcIU5YA0OD1WK1SggCV70D4PbKVhzShWq+rjN5l3aBZV/Uld+B3fHvM X-Received: by 2002:a63:2507:: with SMTP id l7mr19018429pgl.22.1545234963422; Wed, 19 Dec 2018 07:56:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545234963; cv=none; d=google.com; s=arc-20160816; b=z2642NXnZHp7mj7l70kFH51G9+Hoh1iEeB0XWubBLN344iKcWR+3v0pB/gfuF+CaNs 3kh4++bAcVsxG36IWtXSUfKGteiIsKJhN9XU72RdA8GtXzRLvsyYh8YjDRSOV46q2uws 80y/P0j762EaVqyxVs3RqypEb4xx55OMUHrqx9jdQsMGl/U7jwcTSbrTYVniINP4TqaD nqOzZlJaN1SeNS3iJmjpK2TktivEDcHq/iHa7OQaEgb0/Ef6wXfJyZ8QtvGygnjOlfhP 1HgYEoQk2xFd5rDXhxhkuBtZAPACtNmHf0asKw4Nvn47+EyCh+15MKazeKvxxp/xmNL7 xLTw== 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=lvnr3xaZnwgkmPUWPL634ty35n8omx22PaNGUy7rTqg=; b=IhT9PYiZo0OjEbJa3VkJuHm3JWz3onEVH9ZmEL0UUIClWwJdPZahBe8LXBzlREn7S5 M3OMo22oVzz8/qi7lEn6H939Al/dJx3KiNmeMM5wzey2Ncs7xBHJqGZymZ86OGSflEWZ Uwco6ynYJb6HWnXYt129pPja6v9k/QN6G3SPcjJ4tgfki5ijEBZtZJoS49gJ36/4FxVl NHKSWyXRC+Ytr3bKXXzhByY+FlD4bvAx2sQ9NL2n1u4hwdJ+/cUHu510tKfDjC1CzOxJ /Mwx9eGRc5G6edOSewDoet35+kZgLK0nKZkrvM/P676OrHJ0jYWCa5M7v7GvkzQCsXwE IeYw== 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 p16si15627065plr.31.2018.12.19.07.56.02; Wed, 19 Dec 2018 07:56:03 -0800 (PST) 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 S1730432AbeLSP4B (ORCPT + 31 others); Wed, 19 Dec 2018 10:56:01 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:16161 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727982AbeLSPz6 (ORCPT ); Wed, 19 Dec 2018 10:55:58 -0500 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 16C9171D09B7B; Wed, 19 Dec 2018 23:55:51 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.408.0; Wed, 19 Dec 2018 23:55:43 +0800 From: John Garry To: , CC: , , , Luo Jiaxing , John Garry Subject: [PATCH 1/8] scsi: hisi_sas: Create root and device debugfs directories Date: Wed, 19 Dec 2018 23:56:39 +0800 Message-ID: <1545235006-151716-2-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1545235006-151716-1-git-send-email-john.garry@huawei.com> References: <1545235006-151716-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: Luo Jiaxing This patch creates root directory at hisi_sas_init() and generate device directory when we probe device driver. And we remove the root directory at hisi_sas_exit(), but recursively delete device directory when we remove device driver. Signed-off-by: Luo Jiaxing Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas.h | 9 +++++++++ drivers/scsi/hisi_sas/hisi_sas_main.c | 27 +++++++++++++++++++++++++++ drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 5 +++++ 3 files changed, 41 insertions(+) -- 1.9.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h index af29194..3ad8746 100644 --- a/drivers/scsi/hisi_sas/hisi_sas.h +++ b/drivers/scsi/hisi_sas/hisi_sas.h @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -332,6 +333,8 @@ struct hisi_hba { u32 phy_state; u32 intr_coal_ticks; /* Time of interrupt coalesce in us */ u32 intr_coal_count; /* Interrupt count to coalesce */ + + struct dentry *debugfs_dir; }; /* Generic HW DMA host memory structures */ @@ -461,6 +464,10 @@ struct hisi_sas_slot_buf_table { }; extern struct scsi_transport_template *hisi_sas_stt; + +extern bool hisi_sas_debugfs_enable; +extern struct dentry *hisi_sas_debugfs_dir; + extern void hisi_sas_stop_phys(struct hisi_hba *hisi_hba); extern int hisi_sas_alloc(struct hisi_hba *hisi_hba, struct Scsi_Host *shost); extern void hisi_sas_free(struct hisi_hba *hisi_hba); @@ -493,4 +500,6 @@ extern bool hisi_sas_notify_phy_event(struct hisi_sas_phy *phy, extern u8 hisi_sas_get_prog_phy_linkrate_mask(enum sas_linkrate max); extern void hisi_sas_controller_reset_prepare(struct hisi_hba *hisi_hba); extern void hisi_sas_controller_reset_done(struct hisi_hba *hisi_hba); +extern void hisi_sas_debugfs_init(struct hisi_hba *hisi_hba); +extern void hisi_sas_debugfs_exit(struct hisi_hba *hisi_hba); #endif diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index eed7fc5..919cd3b 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -2457,6 +2457,23 @@ int hisi_sas_probe(struct platform_device *pdev, } EXPORT_SYMBOL_GPL(hisi_sas_probe); +struct dentry *hisi_sas_debugfs_dir; + +void hisi_sas_debugfs_init(struct hisi_hba *hisi_hba) +{ + struct device *dev = hisi_hba->dev; + + hisi_hba->debugfs_dir = debugfs_create_dir(dev_name(dev), + hisi_sas_debugfs_dir); +} +EXPORT_SYMBOL_GPL(hisi_sas_debugfs_init); + +void hisi_sas_debugfs_exit(struct hisi_hba *hisi_hba) +{ + debugfs_remove_recursive(hisi_hba->debugfs_dir); +} +EXPORT_SYMBOL_GPL(hisi_sas_debugfs_exit); + int hisi_sas_remove(struct platform_device *pdev) { struct sas_ha_struct *sha = platform_get_drvdata(pdev); @@ -2475,18 +2492,28 @@ int hisi_sas_remove(struct platform_device *pdev) } EXPORT_SYMBOL_GPL(hisi_sas_remove); +bool hisi_sas_debugfs_enable; +EXPORT_SYMBOL_GPL(hisi_sas_debugfs_enable); +module_param_named(debugfs_enable, hisi_sas_debugfs_enable, bool, 0444); +MODULE_PARM_DESC(hisi_sas_debugfs_enable, "Enable driver debugfs (default disabled)"); + static __init int hisi_sas_init(void) { hisi_sas_stt = sas_domain_attach_transport(&hisi_sas_transport_ops); if (!hisi_sas_stt) return -ENOMEM; + if (hisi_sas_debugfs_enable) + hisi_sas_debugfs_dir = debugfs_create_dir("hisi_sas", NULL); + return 0; } static __exit void hisi_sas_exit(void) { sas_release_transport(hisi_sas_stt); + + debugfs_remove(hisi_sas_debugfs_dir); } module_init(hisi_sas_init); diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index add7616..d2e1c85 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -2509,6 +2509,9 @@ static ssize_t intr_coal_count_v3_hw_store(struct device *dev, sha->sas_port[i] = &hisi_hba->port[i].sas_port; } + if (hisi_sas_debugfs_enable) + hisi_sas_debugfs_init(hisi_hba); + rc = scsi_add_host(shost, dev); if (rc) goto err_out_ha; @@ -2567,6 +2570,8 @@ static void hisi_sas_v3_remove(struct pci_dev *pdev) struct hisi_hba *hisi_hba = sha->lldd_ha; struct Scsi_Host *shost = sha->core.shost; + hisi_sas_debugfs_exit(hisi_hba); + if (timer_pending(&hisi_hba->timer)) del_timer(&hisi_hba->timer);