From: "Christian König" <christian.koenig@amd.com>
To: Ben Widawsky <ben@bwidawsk.net>
Cc: DRI Development <dri-devel@lists.freedesktop.org>,
Ben Widawsky <benjamin.widawsky@intel.com>
Subject: Re: [PATCH 3/6] drm/radeon: Use new drm debugfs file helper
Date: Thu, 23 Jan 2014 11:57:41 +0100 [thread overview]
Message-ID: <52E0F5A5.4090408@amd.com> (raw)
In-Reply-To: <20140123032042.GA2588@bwidawsk.net>
Am 23.01.2014 04:20, schrieb Ben Widawsky:
> On Wed, Jan 22, 2014 at 11:11:10AM +0100, Christian König wrote:
>> Am 21.01.2014 21:33, schrieb Ben Widawsky:
>>> The debugfs helper duplicates the functionality used by Armada, so let's
>>> just use that.
>>>
>>> WARNING: only compile tested
>>>
>>> Cc: Christian König <christian.koenig@amd.com>
>>> Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
>>> ---
>>> drivers/gpu/drm/radeon/radeon.h | 5 -----
>>> drivers/gpu/drm/radeon/radeon_ttm.c | 43 ++++++++++++++++++++++---------------
>>> 2 files changed, 26 insertions(+), 22 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
>>> index c5519ca..ceec468 100644
>>> --- a/drivers/gpu/drm/radeon/radeon.h
>>> +++ b/drivers/gpu/drm/radeon/radeon.h
>>> @@ -418,11 +418,6 @@ struct radeon_mman {
>>> struct ttm_bo_device bdev;
>>> bool mem_global_referenced;
>>> bool initialized;
>>> -
>>> -#if defined(CONFIG_DEBUG_FS)
>>> - struct dentry *vram;
>>> - struct dentry *gtt;
>>> -#endif
>>> };
>>> /* bo virtual address in a specific vm */
>>> diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
>>> index 77f5b0c..cf7caf2 100644
>>> --- a/drivers/gpu/drm/radeon/radeon_ttm.c
>>> +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
>>> @@ -971,27 +971,34 @@ static const struct file_operations radeon_ttm_gtt_fops = {
>>> .llseek = default_llseek
>>> };
>>> +static const struct radeon_debugfs_files {
>>> + const char *name;
>>> + const struct file_operations *fops;
>>> +} radeon_debugfs_files[] = {
>>> + {"radeon_vram", &radeon_ttm_vram_fops},
>>> + {"radeon_gtt", &radeon_ttm_gtt_fops},
>>> +};
>>> #endif
>>> static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
>>> {
>>> #if defined(CONFIG_DEBUG_FS)
>>> unsigned count;
>>> + int i, ret;
>>> struct drm_minor *minor = rdev->ddev->primary;
>>> - struct dentry *ent, *root = minor->debugfs_root;
>>> -
>>> - ent = debugfs_create_file("radeon_vram", S_IFREG | S_IRUGO, root,
>>> - rdev, &radeon_ttm_vram_fops);
>>> - if (IS_ERR(ent))
>>> - return PTR_ERR(ent);
>>> - rdev->mman.vram = ent;
>>> -
>>> - ent = debugfs_create_file("radeon_gtt", S_IFREG | S_IRUGO, root,
>>> - rdev, &radeon_ttm_gtt_fops);
>>> - if (IS_ERR(ent))
>>> - return PTR_ERR(ent);
>>> - rdev->mman.gtt = ent;
>>> + struct dentry *root = minor->debugfs_root;
>>> +
>>> + for (i = 0; i < ARRAY_SIZE(radeon_debugfs_files); i++) {
>>> + ret = drm_debugfs_create_file(root, minor,
>>> + radeon_debugfs_files[i].name,
>>> + radeon_debugfs_files[i].fops,
>>> + S_IFREG | S_IWUSR);
>>> + if (ret) {
>>> + radeon_ttm_debugfs_fini(rdev);
>>> + return ret;
>>> + }
>>> + }
>>> count = ARRAY_SIZE(radeon_ttm_debugfs_list);
>>> @@ -1010,11 +1017,13 @@ static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
>>> static void radeon_ttm_debugfs_fini(struct radeon_device *rdev)
>>> {
>>> #if defined(CONFIG_DEBUG_FS)
>>> + int i;
>>> - debugfs_remove(rdev->mman.vram);
>>> - rdev->mman.vram = NULL;
>>> + for (i = 0; i < ARRAY_SIZE(radeon_debugfs_files); i++) {
>>> + struct drm_info_list *info_list =
>>> + (struct drm_info_list *)&radeon_debugfs_files[i];
>>> - debugfs_remove(rdev->mman.gtt);
>>> - rdev->mman.gtt = NULL;
>>> + drm_debugfs_remove_files(info_list, 1, rdev->ddev->primary);
>> This won't work correctly because info_ent doesn't contain this pointer but
>> a pointer to the fops instead.
> You are correct. It should have been &radeon_debugfs_files[i].fops.
>
>> Additional to that the fops might not be unique (you can use the same
>> fops for different files) so they are probably not such a good choice
>> as the key.
> This is correct, and I elaborate a bit on this in a later patch (or
> earlier, I forget). Essentially we have exactly one usage (afaict) of a
> caller that wants a fops != key. I didn't want to create the interface
> around this possibility, but rather let other extend it when it becomes
> more common.
>
> However, if this is requested/required, what I would do is provide a
> void *key argument, where a NULL value will result in using fops.
>
>
>> On the other hand why do the drm layer want to do this bookkeeping of
>> all the created files in the first place? We could just use
>> debugfs_remove_recursive instead and don't need to mess with this at
>> all.
>>
>> Regards, Christian.
>>
> The answer to the question predates me. I think having the helpers for
> the common case, where you only want a show() function is handy. The
> decision to split off and continue to shoehorn newer, more featured
> debugfs files (as you have done in Radeon with these two, and as we have
> done in i915 all over) was not one I made, nor one I really care to fix.
>
> So assuming I fix the bug, what do you want to me do?
If you want to clean it up then clean it up completely.
The helper to add a debugfs file with only a show function should
probably be a general debugfs feature instead of being part of DRM.
So as long as nobody can come up with a good reason why DRM does this
housekeeping of all created debugfs file I would say use
debugfs_remove_recursive instead and kill the complete drm debugfs helpers.
Christian.
>
>>> + } #endif }
>>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2014-01-23 10:57 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-14 14:14 [PATCH 1/2] drm: share drm_add_fake_info_node Ben Widawsky
2014-01-14 23:25 ` [Intel-gfx] " Daniel Vetter
2014-01-14 23:40 ` Russell King - ARM Linux
2014-01-15 8:39 ` [Intel-gfx] " Daniel Vetter
2014-01-15 8:45 ` Daniel Vetter
2014-01-15 20:08 ` Ben Widawsky
2014-01-15 23:42 ` [Intel-gfx] " Daniel Vetter
2014-01-21 19:05 ` Ben Widawsky
2014-01-21 20:33 ` [PATCH 1/6] drm: Create a debugfs file creation helper Ben Widawsky
2014-01-21 20:33 ` [PATCH 2/6] drm/armada: Use new drm debugfs file helper Ben Widawsky
2014-01-21 20:33 ` [PATCH 3/6] drm/radeon: " Ben Widawsky
2014-01-22 10:11 ` Christian König
2014-01-23 3:20 ` Ben Widawsky
2014-01-23 10:57 ` Christian König [this message]
2014-01-21 20:33 ` [PATCH 4/6] drm/i915: " Ben Widawsky
2014-01-21 20:33 ` [PATCH 5/6] drm/i915: Move forcewake debugfs setup also Ben Widawsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52E0F5A5.4090408@amd.com \
--to=christian.koenig@amd.com \
--cc=ben@bwidawsk.net \
--cc=benjamin.widawsky@intel.com \
--cc=dri-devel@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox