Received: by 10.192.165.156 with SMTP id m28csp974179imm; Wed, 18 Apr 2018 01:33:09 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+php0qcFXioU4xmR3I4mczg6j/bxkZ07Zs7tNuBlX2KknSzqVj1g09ygglw+g4JPAG79zI X-Received: by 2002:a17:902:2826:: with SMTP id e35-v6mr1215990plb.348.1524040389265; Wed, 18 Apr 2018 01:33:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524040389; cv=none; d=google.com; s=arc-20160816; b=tVbciR5SS9HoJViJjaz+qExvywyCyajFXwY+IB95McXRyKtvbJ2ZudF9dth/nLSSB5 MsVLKkegCQnkbv3p7WBqGnrl3gsyUoAelgivh6Qb/S7ommF3FiH1I9zvmbw0vmOsWrfE cqt9+2p2zb87N2TPSOSGid713MB/CIYjeIHNr4ylvsODcQ/YTNAatGwONhXvI6pB9qUY OkW/AlIpmlYRRmruPz9+FLVJX0Mw6TP66u7dM8V4GvaKEc/KHo90MFYh9tTLOLGcZgkM eDfOmv8WU9blgXwNuAbs31v+AxHgZiQQtCrp+JmzrzdQLyG+UAb5lFMpFB4Wy2KE9y9d jBWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-id:content-language:accept-language:in-reply-to:references :message-id:date:thread-index:thread-topic:subject:cc:to:from :arc-authentication-results; bh=f9vWxZRErhmWaKc79y7hS38Kbv5X9t80tsWNu+Okf+w=; b=SPCbaWAkTqkGxD12lMTbHOkT29vqE5I5s+ecksIqJz4/tIQNbXiRCZKjk/9IkmlNBU ORO+c04JoQGXdddUfQkcnLQ4uYNDwctmlaArPuzs8PzFI+9cMQxY+maDpk6CrAxzXrIV GkyRI6cS/iSt1MPs25rWBcG4or/cCsUa/ufW+7si6qK6zD6I6oZrNGd4J/J7mqcD/GHd tWjLt+nslJoMN5LRZvZBVLgWNS6KvXyWndzg8/8dVRVPsZcZs4Q2w6vDjvKhgIZtqmwZ 4OQP278CQr+mjxJNAAk7uoY0t5PPW/1cUynsjCbd4XilWcVZ6Y0Grv4hgMQebULsyTni pLDg== 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 x1si663490pgp.89.2018.04.18.01.32.55; Wed, 18 Apr 2018 01:33:09 -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 S1753643AbeDRIbs convert rfc822-to-8bit (ORCPT + 99 others); Wed, 18 Apr 2018 04:31:48 -0400 Received: from mx01.hxt-semitech.com.96.203.223.in-addr.arpa ([223.203.96.7]:39373 "EHLO barracuda.hxt-semitech.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1753178AbeDRIbr (ORCPT ); Wed, 18 Apr 2018 04:31:47 -0400 X-ASG-Debug-ID: 1524040303-093b7e10b3b9fa0001-xx1T2L Received: from HXTBJIDCEMVIW01.hxtcorp.net (localhost [10.128.0.14]) by barracuda.hxt-semitech.com with ESMTP id agAmHAhlraDTT3rm (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 18 Apr 2018 16:31:43 +0800 (CST) X-Barracuda-Envelope-From: shunyong.yang@hxt-semitech.com Received: from HXTBJIDCEMVIW01.hxtcorp.net (10.128.0.14) by HXTBJIDCEMVIW01.hxtcorp.net (10.128.0.14) with Microsoft SMTP Server (TLS) id 15.0.847.32; Wed, 18 Apr 2018 16:31:48 +0800 Received: from HXTBJIDCEMVIW01.hxtcorp.net ([fe80::f451:a443:c0b5:87d1]) by HXTBJIDCEMVIW01.hxtcorp.net ([fe80::f451:a443:c0b5:87d1%12]) with mapi id 15.00.0847.030; Wed, 18 Apr 2018 16:31:36 +0800 From: "Yang, Shunyong" To: "sohil.mehta@intel.com" , "gary.hook@amd.com" , "iommu@lists.linux-foundation.org" , "ghook@amd.com" CC: "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v3 2/2] iommu/amd: Add basic debugfs infrastructure for AMD IOMMU Thread-Topic: [PATCH v3 2/2] iommu/amd: Add basic debugfs infrastructure for AMD IOMMU X-ASG-Orig-Subj: Re: [PATCH v3 2/2] iommu/amd: Add basic debugfs infrastructure for AMD IOMMU Thread-Index: AQHT1tpRJAZW59A4ZEqPfHlYD/OogKQFmZcAgAAR5AA= Date: Wed, 18 Apr 2018 08:31:36 +0000 Message-ID: <1524040290.4031.25.camel@hxt-semitech.com> References: <152302042701.47565.17954813724758433858.stgit@sosxen2.amd.com> <152302067362.47565.628887796165116844.stgit@sosxen2.amd.com> <1523664612.2747.13.camel@intel.com> <1524031122.4031.5.camel@hxt-semitech.com> <1524036520.2747.31.camel@intel.com> In-Reply-To: <1524036520.2747.31.camel@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.64.6.80] Content-Type: text/plain; charset="iso-8859-15" Content-ID: <1C2E6DF8FCA0C8448B44B1E023EB6DEE@hxt-semitech.com> Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-Barracuda-Connect: localhost[10.128.0.14] X-Barracuda-Start-Time: 1524040303 X-Barracuda-Encrypted: ECDHE-RSA-AES256-SHA X-Barracuda-URL: https://192.168.50.101:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at hxt-semitech.com X-Barracuda-BRTS-Status: 1 X-Barracuda-Bayes: INNOCENT GLOBAL 0.5345 1.0000 0.7500 X-Barracuda-Spam-Score: 0.75 X-Barracuda-Spam-Status: No, SCORE=0.75 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=9.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.50013 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Sohil On Wed, 2018-04-18 at 07:27 +0000, Mehta, Sohil wrote: > On Wed, 2018-04-18 at 05:58 +0000, Yang, Shunyong wrote: > > > > Hi, Gary and Sohil, > > > > On Tue, 2018-04-17 at 13:38 -0400, Hook, Gary wrote: > > > > > > On 4/13/2018 8:08 PM, Mehta, Sohil wrote: > > > > > > > > ? > > > > On Fri, 2018-04-06 at 08:17 -0500, Gary R Hook wrote: > > > > > > > > > > ? > > > > > ?? > > > > > + > > > > > +void amd_iommu_debugfs_setup(struct amd_iommu *iommu) > > > > > +{ > > > > > +?char name[MAX_NAME_LEN + 1]; > > > > > +?struct dentry *d_top; > > > > > + > > > > > +?if (!debugfs_initialized()) > > > > Probably not needed. > > > Right. > > When will this check is needed? > > IMO, this function is to check debugfs ready status before we want > > to > > use debugfs. I just want to understand when we should use > > debugfs_initialized(); > > > You are right debugfs_initialized() can be used to check if debugfs > is > ready. However in this case we can also rely on debugfs_create_dir() > which is called in iommu_debufs_setup(). > > debugfs_create_dir() says: > > ?* If debugfs is not enabled in the kernel, the value -%ENODEV will > be > ?* returned. It seems "If debugfs is not enabled in the kernel" means?CONFIG_DEBUG_FS is not configured. Following is the code of no such config. ? static inline struct dentry *debugfs_create_dir(const char *name, struct dentry *parent) ? { return ERR_PTR(-ENODEV); ? } Looking into the code,?debugfs_initialized() return the value of debugfs_registered. debugfs_registered is set to true after debugfs_init() has been called. However, debugfs_create_dir() doesn't call debugfs_initialized() or check debugfs_registered value. So, there is tiny different of checking status by debugfs_create_dir() and debugfs_initialized().?Although it can achieve functionality here. Maybe the original design is to call?debugfs_initialized() before calling?debugfs_create_xxx()? Thanks. Shunyong. > > Sohil > > > > > Thanks. > > Shunyong. > > > > > > > > ? > > > > > > > > ? > > > > ? > > > > > > > > > > ? > > > > > +?????????return; > > > > > + > > > > > +?mutex_lock(&amd_iommu_debugfs_lock); > > > > > +?if (!amd_iommu_debugfs) { > > > > > +?????????d_top = iommu_debugfs_setup(); > > > > > +?????????if (d_top) > > > > > +?????????????????amd_iommu_debugfs = > > > > > debugfs_create_dir("amd", d_top); > > > > > +?} > > > > > +?mutex_unlock(&amd_iommu_debugfs_lock);