aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ntb/ntb_transport.c
diff options
context:
space:
mode:
authorJon Mason <jon.mason@intel.com>2013-07-30 18:58:49 -0400
committerJon Mason <jon.mason@intel.com>2013-09-03 14:14:54 -0400
commit1517a3f21a1dd321f16bcf44204bddff9d21abd0 (patch)
tree45b8eb39ea33fae5f66af89376f5029e45d09127 /drivers/ntb/ntb_transport.c
parentb6750cfe0710a14fd147ba27fddbecae8ba88c77 (diff)
NTB: Correct debugfs to work with more than 1 NTB Device
Debugfs was setup in NTB to only have a single debugfs directory. This resulted in the leaking of debugfs directories and files when multiple NTB devices were present, due to each device stomping on the variables containing the previous device's values (thus preventing them from being freed on cleanup). Correct this by creating a secondary directory of the PCI BDF for each device present, and nesting the previously existing information in those directories. Signed-off-by: Jon Mason <jon.mason@intel.com>
Diffstat (limited to 'drivers/ntb/ntb_transport.c')
-rw-r--r--drivers/ntb/ntb_transport.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c
index f8d7081ee301..c3089151aa49 100644
--- a/drivers/ntb/ntb_transport.c
+++ b/drivers/ntb/ntb_transport.c
@@ -157,7 +157,6 @@ struct ntb_transport {
157 bool transport_link; 157 bool transport_link;
158 struct delayed_work link_work; 158 struct delayed_work link_work;
159 struct work_struct link_cleanup; 159 struct work_struct link_cleanup;
160 struct dentry *debugfs_dir;
161}; 160};
162 161
163enum { 162enum {
@@ -824,12 +823,12 @@ static void ntb_transport_init_queue(struct ntb_transport *nt,
824 qp->tx_max_frame = min(transport_mtu, tx_size / 2); 823 qp->tx_max_frame = min(transport_mtu, tx_size / 2);
825 qp->tx_max_entry = tx_size / qp->tx_max_frame; 824 qp->tx_max_entry = tx_size / qp->tx_max_frame;
826 825
827 if (nt->debugfs_dir) { 826 if (ntb_query_debugfs(nt->ndev)) {
828 char debugfs_name[4]; 827 char debugfs_name[4];
829 828
830 snprintf(debugfs_name, 4, "qp%d", qp_num); 829 snprintf(debugfs_name, 4, "qp%d", qp_num);
831 qp->debugfs_dir = debugfs_create_dir(debugfs_name, 830 qp->debugfs_dir = debugfs_create_dir(debugfs_name,
832 nt->debugfs_dir); 831 ntb_query_debugfs(nt->ndev));
833 832
834 qp->debugfs_stats = debugfs_create_file("stats", S_IRUSR, 833 qp->debugfs_stats = debugfs_create_file("stats", S_IRUSR,
835 qp->debugfs_dir, qp, 834 qp->debugfs_dir, qp,
@@ -857,11 +856,6 @@ int ntb_transport_init(struct pci_dev *pdev)
857 if (!nt) 856 if (!nt)
858 return -ENOMEM; 857 return -ENOMEM;
859 858
860 if (debugfs_initialized())
861 nt->debugfs_dir = debugfs_create_dir(KBUILD_MODNAME, NULL);
862 else
863 nt->debugfs_dir = NULL;
864
865 nt->ndev = ntb_register_transport(pdev, nt); 859 nt->ndev = ntb_register_transport(pdev, nt);
866 if (!nt->ndev) { 860 if (!nt->ndev) {
867 rc = -EIO; 861 rc = -EIO;
@@ -907,7 +901,6 @@ err2:
907err1: 901err1:
908 ntb_unregister_transport(nt->ndev); 902 ntb_unregister_transport(nt->ndev);
909err: 903err:
910 debugfs_remove_recursive(nt->debugfs_dir);
911 kfree(nt); 904 kfree(nt);
912 return rc; 905 return rc;
913} 906}
@@ -921,16 +914,16 @@ void ntb_transport_free(void *transport)
921 nt->transport_link = NTB_LINK_DOWN; 914 nt->transport_link = NTB_LINK_DOWN;
922 915
923 /* verify that all the qp's are freed */ 916 /* verify that all the qp's are freed */
924 for (i = 0; i < nt->max_qps; i++) 917 for (i = 0; i < nt->max_qps; i++) {
925 if (!test_bit(i, &nt->qp_bitmap)) 918 if (!test_bit(i, &nt->qp_bitmap))
926 ntb_transport_free_queue(&nt->qps[i]); 919 ntb_transport_free_queue(&nt->qps[i]);
920 debugfs_remove_recursive(nt->qps[i].debugfs_dir);
921 }
927 922
928 ntb_bus_remove(nt); 923 ntb_bus_remove(nt);
929 924
930 cancel_delayed_work_sync(&nt->link_work); 925 cancel_delayed_work_sync(&nt->link_work);
931 926
932 debugfs_remove_recursive(nt->debugfs_dir);
933
934 ntb_unregister_event_callback(nt->ndev); 927 ntb_unregister_event_callback(nt->ndev);
935 928
936 pdev = ntb_query_pdev(nt->ndev); 929 pdev = ntb_query_pdev(nt->ndev);