Message ID | 20200305235941.1716-1-andi.shyti@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | drm/i915/gt: allow setting generic data pointer | expand |
On 3/5/20 3:59 PM, Andi Shyti wrote: > When registering debugfs files the intel gt debugfs library > forces a 'struct *gt' private data on the caller. > > There might be different needs, therefore make it generic by > adding one more argument to the "debugfs_register_files()" > function which gets the generic void private data as argument. > > Still keep it simple by defining a wrapper where struct *gt is > the chosen private data to be stored. > > I take the chance to rename the functions by using "intel_gt_" as > prefix instead of "debugfs_". > > Signed-off-by: Andi Shyti <andi.shyti@intel.com> > --- > drivers/gpu/drm/i915/gt/debugfs_engines.c | 2 +- > drivers/gpu/drm/i915/gt/debugfs_gt.c | 9 ++++----- > drivers/gpu/drm/i915/gt/debugfs_gt.h | 10 ++++++---- > drivers/gpu/drm/i915/gt/debugfs_gt_pm.c | 2 +- > 4 files changed, 12 insertions(+), 11 deletions(-) > > diff --git a/drivers/gpu/drm/i915/gt/debugfs_engines.c b/drivers/gpu/drm/i915/gt/debugfs_engines.c > index 6a5e9ab20b94..3434df10d58c 100644 > --- a/drivers/gpu/drm/i915/gt/debugfs_engines.c > +++ b/drivers/gpu/drm/i915/gt/debugfs_engines.c > @@ -32,5 +32,5 @@ void debugfs_engines_register(struct intel_gt *gt, struct dentry *root) > { "engines", &engines_fops }, > }; > > - debugfs_gt_register_files(gt, root, files, ARRAY_SIZE(files)); > + intel_gt_debugfs_register_file(gt, root, files, ARRAY_SIZE(files)); > } > diff --git a/drivers/gpu/drm/i915/gt/debugfs_gt.c b/drivers/gpu/drm/i915/gt/debugfs_gt.c > index 75255aaacaed..9112a8585caf 100644 > --- a/drivers/gpu/drm/i915/gt/debugfs_gt.c > +++ b/drivers/gpu/drm/i915/gt/debugfs_gt.c > @@ -26,15 +26,14 @@ void debugfs_gt_register(struct intel_gt *gt) > debugfs_gt_pm_register(gt, root); > } > > -void debugfs_gt_register_files(struct intel_gt *gt, > - struct dentry *root, > - const struct debugfs_gt_file *files, > - unsigned long count) > +void __intel_gt_debugfs_register_files(struct intel_gt *gt, struct dentry *root, > + const struct debugfs_gt_file *files, > + unsigned long count, void *data) > { > while (count--) { > if (!files->eval || files->eval(gt)) IMO the files->eval() function should also use the provided data instead of intel_gt. This will also allow us to drop the intel_gt parameter in this function, which in turn means we can use this function directly from all the levels. Daniele > debugfs_create_file(files->name, > - 0444, root, gt, > + 0444, root, data, > files->fops); > > files++; > diff --git a/drivers/gpu/drm/i915/gt/debugfs_gt.h b/drivers/gpu/drm/i915/gt/debugfs_gt.h > index 4ea0f06cda8f..1c01d70a2a44 100644 > --- a/drivers/gpu/drm/i915/gt/debugfs_gt.h > +++ b/drivers/gpu/drm/i915/gt/debugfs_gt.h > @@ -31,9 +31,11 @@ struct debugfs_gt_file { > bool (*eval)(const struct intel_gt *gt); > }; > > -void debugfs_gt_register_files(struct intel_gt *gt, > - struct dentry *root, > - const struct debugfs_gt_file *files, > - unsigned long count); > +void __intel_gt_debugfs_register_files(struct intel_gt *gt, struct dentry *root, > + const struct debugfs_gt_file *files, > + unsigned long count, void *data); > + > +#define intel_gt_debugfs_register_file(_g, _r, _f, _c) \ > + __intel_gt_debugfs_register_files(_g, _r, _f, _c, _g) > > #endif /* DEBUGFS_GT_H */ > diff --git a/drivers/gpu/drm/i915/gt/debugfs_gt_pm.c b/drivers/gpu/drm/i915/gt/debugfs_gt_pm.c > index 059c9e5c002e..a8d2391a207a 100644 > --- a/drivers/gpu/drm/i915/gt/debugfs_gt_pm.c > +++ b/drivers/gpu/drm/i915/gt/debugfs_gt_pm.c > @@ -597,5 +597,5 @@ void debugfs_gt_pm_register(struct intel_gt *gt, struct dentry *root) > { "rps_boost", &rps_boost_fops, rps_eval }, > }; > > - debugfs_gt_register_files(gt, root, files, ARRAY_SIZE(files)); > + intel_gt_debugfs_register_file(gt, root, files, ARRAY_SIZE(files)); > } >
Hi Daniele, > > diff --git a/drivers/gpu/drm/i915/gt/debugfs_gt.c b/drivers/gpu/drm/i915/gt/debugfs_gt.c > > index 75255aaacaed..9112a8585caf 100644 > > --- a/drivers/gpu/drm/i915/gt/debugfs_gt.c > > +++ b/drivers/gpu/drm/i915/gt/debugfs_gt.c > > @@ -26,15 +26,14 @@ void debugfs_gt_register(struct intel_gt *gt) > > debugfs_gt_pm_register(gt, root); > > } > > -void debugfs_gt_register_files(struct intel_gt *gt, > > - struct dentry *root, > > - const struct debugfs_gt_file *files, > > - unsigned long count) > > +void __intel_gt_debugfs_register_files(struct intel_gt *gt, struct dentry *root, > > + const struct debugfs_gt_file *files, > > + unsigned long count, void *data) > > { > > while (count--) { > > if (!files->eval || files->eval(gt)) > > IMO the files->eval() function should also use the provided data instead of > intel_gt. This will also allow us to drop the intel_gt parameter in this > function, which in turn means we can use this function directly from all the > levels. do you mean something like this: - bool (*eval)(const struct intel_gt *gt); + bool (*eval)(void *data); ? I am missing the use case, though, what is it that cannot be reached by the gt so that it needs to be more generic? Do you want to use it at i915 level? Thanks for the review, Andi
On 3/5/20 5:15 PM, Andi Shyti wrote: > Hi Daniele, > >>> diff --git a/drivers/gpu/drm/i915/gt/debugfs_gt.c b/drivers/gpu/drm/i915/gt/debugfs_gt.c >>> index 75255aaacaed..9112a8585caf 100644 >>> --- a/drivers/gpu/drm/i915/gt/debugfs_gt.c >>> +++ b/drivers/gpu/drm/i915/gt/debugfs_gt.c >>> @@ -26,15 +26,14 @@ void debugfs_gt_register(struct intel_gt *gt) >>> debugfs_gt_pm_register(gt, root); >>> } >>> -void debugfs_gt_register_files(struct intel_gt *gt, >>> - struct dentry *root, >>> - const struct debugfs_gt_file *files, >>> - unsigned long count) >>> +void __intel_gt_debugfs_register_files(struct intel_gt *gt, struct dentry *root, >>> + const struct debugfs_gt_file *files, >>> + unsigned long count, void *data) >>> { >>> while (count--) { >>> if (!files->eval || files->eval(gt)) >> >> IMO the files->eval() function should also use the provided data instead of >> intel_gt. This will also allow us to drop the intel_gt parameter in this >> function, which in turn means we can use this function directly from all the >> levels. > > do you mean something like this: > > - bool (*eval)(const struct intel_gt *gt); > + bool (*eval)(void *data); > > ? yes > > I am missing the use case, though, what is it that cannot be > reached by the gt so that it needs to be more generic? It's not a problem of reaching it from gt but the other way around, I don't want the caller to have to retrieve a gt variable it don't needs just to pass it to this function and then go back to the actual required data from gt inside of the eval function. Anything you need for your evaluation should be reachable from the struct used as data for the debugfs. To make a concrete example, I want to avoid an unneeded guc_to_gt inside intel_guc_debugfs_register that would also require a matched guc = >->uc.guc inside the eval function, passing guc (i.e. the data) straight in the eval is cleaner IMO. Daniele > > Do you want to use it at i915 level? > > Thanks for the review, > Andi >
Hi Daniele, > > > > diff --git a/drivers/gpu/drm/i915/gt/debugfs_gt.c b/drivers/gpu/drm/i915/gt/debugfs_gt.c > > > > index 75255aaacaed..9112a8585caf 100644 > > > > --- a/drivers/gpu/drm/i915/gt/debugfs_gt.c > > > > +++ b/drivers/gpu/drm/i915/gt/debugfs_gt.c > > > > @@ -26,15 +26,14 @@ void debugfs_gt_register(struct intel_gt *gt) > > > > debugfs_gt_pm_register(gt, root); > > > > } > > > > -void debugfs_gt_register_files(struct intel_gt *gt, > > > > - struct dentry *root, > > > > - const struct debugfs_gt_file *files, > > > > - unsigned long count) > > > > +void __intel_gt_debugfs_register_files(struct intel_gt *gt, struct dentry *root, > > > > + const struct debugfs_gt_file *files, > > > > + unsigned long count, void *data) > > > > { > > > > while (count--) { > > > > if (!files->eval || files->eval(gt)) > > > > > > IMO the files->eval() function should also use the provided data instead of > > > intel_gt. This will also allow us to drop the intel_gt parameter in this > > > function, which in turn means we can use this function directly from all the > > > levels. > > > > do you mean something like this: > > > > - bool (*eval)(const struct intel_gt *gt); > > + bool (*eval)(void *data); > > > > ? > > yes > > > > > I am missing the use case, though, what is it that cannot be > > reached by the gt so that it needs to be more generic? > > It's not a problem of reaching it from gt but the other way around, I don't > want the caller to have to retrieve a gt variable it don't needs just to > pass it to this function and then go back to the actual required data from > gt inside of the eval function. Anything you need for your evaluation should > be reachable from the struct used as data for the debugfs. > To make a concrete example, I want to avoid an unneeded guc_to_gt inside > intel_guc_debugfs_register that would also require a matched guc = > >->uc.guc inside the eval function, passing guc (i.e. the data) straight > in the eval is cleaner IMO. Thanks for the feedback, makes sense. Andi
diff --git a/drivers/gpu/drm/i915/gt/debugfs_engines.c b/drivers/gpu/drm/i915/gt/debugfs_engines.c index 6a5e9ab20b94..3434df10d58c 100644 --- a/drivers/gpu/drm/i915/gt/debugfs_engines.c +++ b/drivers/gpu/drm/i915/gt/debugfs_engines.c @@ -32,5 +32,5 @@ void debugfs_engines_register(struct intel_gt *gt, struct dentry *root) { "engines", &engines_fops }, }; - debugfs_gt_register_files(gt, root, files, ARRAY_SIZE(files)); + intel_gt_debugfs_register_file(gt, root, files, ARRAY_SIZE(files)); } diff --git a/drivers/gpu/drm/i915/gt/debugfs_gt.c b/drivers/gpu/drm/i915/gt/debugfs_gt.c index 75255aaacaed..9112a8585caf 100644 --- a/drivers/gpu/drm/i915/gt/debugfs_gt.c +++ b/drivers/gpu/drm/i915/gt/debugfs_gt.c @@ -26,15 +26,14 @@ void debugfs_gt_register(struct intel_gt *gt) debugfs_gt_pm_register(gt, root); } -void debugfs_gt_register_files(struct intel_gt *gt, - struct dentry *root, - const struct debugfs_gt_file *files, - unsigned long count) +void __intel_gt_debugfs_register_files(struct intel_gt *gt, struct dentry *root, + const struct debugfs_gt_file *files, + unsigned long count, void *data) { while (count--) { if (!files->eval || files->eval(gt)) debugfs_create_file(files->name, - 0444, root, gt, + 0444, root, data, files->fops); files++; diff --git a/drivers/gpu/drm/i915/gt/debugfs_gt.h b/drivers/gpu/drm/i915/gt/debugfs_gt.h index 4ea0f06cda8f..1c01d70a2a44 100644 --- a/drivers/gpu/drm/i915/gt/debugfs_gt.h +++ b/drivers/gpu/drm/i915/gt/debugfs_gt.h @@ -31,9 +31,11 @@ struct debugfs_gt_file { bool (*eval)(const struct intel_gt *gt); }; -void debugfs_gt_register_files(struct intel_gt *gt, - struct dentry *root, - const struct debugfs_gt_file *files, - unsigned long count); +void __intel_gt_debugfs_register_files(struct intel_gt *gt, struct dentry *root, + const struct debugfs_gt_file *files, + unsigned long count, void *data); + +#define intel_gt_debugfs_register_file(_g, _r, _f, _c) \ + __intel_gt_debugfs_register_files(_g, _r, _f, _c, _g) #endif /* DEBUGFS_GT_H */ diff --git a/drivers/gpu/drm/i915/gt/debugfs_gt_pm.c b/drivers/gpu/drm/i915/gt/debugfs_gt_pm.c index 059c9e5c002e..a8d2391a207a 100644 --- a/drivers/gpu/drm/i915/gt/debugfs_gt_pm.c +++ b/drivers/gpu/drm/i915/gt/debugfs_gt_pm.c @@ -597,5 +597,5 @@ void debugfs_gt_pm_register(struct intel_gt *gt, struct dentry *root) { "rps_boost", &rps_boost_fops, rps_eval }, }; - debugfs_gt_register_files(gt, root, files, ARRAY_SIZE(files)); + intel_gt_debugfs_register_file(gt, root, files, ARRAY_SIZE(files)); }
When registering debugfs files the intel gt debugfs library forces a 'struct *gt' private data on the caller. There might be different needs, therefore make it generic by adding one more argument to the "debugfs_register_files()" function which gets the generic void private data as argument. Still keep it simple by defining a wrapper where struct *gt is the chosen private data to be stored. I take the chance to rename the functions by using "intel_gt_" as prefix instead of "debugfs_". Signed-off-by: Andi Shyti <andi.shyti@intel.com> --- drivers/gpu/drm/i915/gt/debugfs_engines.c | 2 +- drivers/gpu/drm/i915/gt/debugfs_gt.c | 9 ++++----- drivers/gpu/drm/i915/gt/debugfs_gt.h | 10 ++++++---- drivers/gpu/drm/i915/gt/debugfs_gt_pm.c | 2 +- 4 files changed, 12 insertions(+), 11 deletions(-)