Re: [PATCH v3 2/2] iommu/amd: Add basic debugfs infrastructure for AMD IOMMU

From: Mehta, Sohil
Date: Wed Apr 18 2018 - 03:27:36 EST


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.

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);