Message ID | 20240402155534.1788466-1-jani.nikula@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | drm/i915/display: fix display param dup for NULL char * params | expand |
On Tue, Apr 02, 2024 at 06:55:34PM +0300, Jani Nikula wrote: >The display param duplication deviates from the original param >duplication in that it converts NULL params to to allocated empty >strings. This works for the vbt_firmware parameter, but not for >dmc_firmware_path, the user of which interprets NULL and the empty >string as distinct values. Specifically, the empty dmc_firmware_path >leads to DMC and PM being disabled. > >Just remove the NULL check and pass it to kstrdup(), which safely >returns NULL for NULL input. > >Fixes: 8015bee0bfec ("drm/i915/display: Add framework to add parameters specific to display") >Fixes: 0d82a0d6f556 ("drm/i915/display: move dmc_firmware_path to display params") >Cc: Jouni Högander <jouni.hogander@intel.com> >Cc: Luca Coelho <luciano.coelho@intel.com> >Cc: <stable@vger.kernel.org> # v6.8+ >Signed-off-by: Jani Nikula <jani.nikula@intel.com> Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com> ... but what's the purpose of the duplication? How one is supposed to use the dmc_firmware with e.g. LNL + BMG? Setting it later via debugfs doesn´t change the behavior. AFAIR this was done to support multiple devices, but I don't think it achieves its purpose or I'm missing something. By leaving a param writable and not duplicate it at all, we are at least be allowed to: 1) disable autoprobe 2) load module 3) bind do LNL 4) set dmc_firmware param 5) bind to BMG Yeah, it's manual and not intuitive, but should only be used by developers with targeted debug. How would we do something like that with the current code? I know that for params via sysfs, it's impossible to get them back to NULL, so I think we should make sure NULL and empty is handled the same way. Getting it back to empty is hard enough but at least possible (see https://lore.kernel.org/igt-dev/20240228223134.3908035-4-lucas.demarchi@intel.com/), but I think this is not the case for debugfs. Lucas De Marchi
On Tue, 02 Apr 2024, Lucas De Marchi <lucas.demarchi@intel.com> wrote: > On Tue, Apr 02, 2024 at 06:55:34PM +0300, Jani Nikula wrote: >>The display param duplication deviates from the original param >>duplication in that it converts NULL params to to allocated empty >>strings. This works for the vbt_firmware parameter, but not for >>dmc_firmware_path, the user of which interprets NULL and the empty >>string as distinct values. Specifically, the empty dmc_firmware_path >>leads to DMC and PM being disabled. >> >>Just remove the NULL check and pass it to kstrdup(), which safely >>returns NULL for NULL input. >> >>Fixes: 8015bee0bfec ("drm/i915/display: Add framework to add parameters specific to display") >>Fixes: 0d82a0d6f556 ("drm/i915/display: move dmc_firmware_path to display params") >>Cc: Jouni Högander <jouni.hogander@intel.com> >>Cc: Luca Coelho <luciano.coelho@intel.com> >>Cc: <stable@vger.kernel.org> # v6.8+ >>Signed-off-by: Jani Nikula <jani.nikula@intel.com> > > Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com> Thanks! > ... but what's the purpose of the duplication? How one is supposed to > use the dmc_firmware with e.g. LNL + BMG? Setting it later via debugfs > doesn´t change the behavior. AFAIR this was done to support multiple > devices, but I don't think it achieves its purpose or I'm missing > something. > > By leaving a param writable and not duplicate it at all, we are at > least be allowed to: > > 1) disable autoprobe > 2) load module > 3) bind do LNL > 4) set dmc_firmware param > 5) bind to BMG > > Yeah, it's manual and not intuitive, but should only be used by > developers with targeted debug. How would we do something like that > with the current code? > > I know that for params via sysfs, it's impossible to get them back to > NULL, so I think we should make sure NULL and empty is handled the same > way. Getting it back to empty is hard enough but at least possible (see > https://lore.kernel.org/igt-dev/20240228223134.3908035-4-lucas.demarchi@intel.com/), > but I think this is not the case for debugfs. There are a lot of angles to this. :) First of all, I think when we do copy the params, they should be preserved as they were, instead of changed. This patch fixes this part, and the bug that currently disables DMC altogether. We do copies for a few reasons. From module params to device params, and from device params to error capture. I agree that making a distinction between an unset parameter and a parameter set to NULL is probably a mistake, because as you mention it's not feasible to go back to NULL. In this case, NULL means default and "" means disabled. No way to go back to default. For params that only make sense at probe, we should perhaps leave the module parameter writable, and the device parameter read only. Even in this case, the duplication is a feature and makes sense: you can modify the module parameter, but it only makes a difference to devices bound after the change. For devices already bound, you can look up the value that was used from debugfs. BR, Jani.
On Tue, 02 Apr 2024, Jani Nikula <jani.nikula@intel.com> wrote: > The display param duplication deviates from the original param > duplication in that it converts NULL params to to allocated empty > strings. This works for the vbt_firmware parameter, but not for > dmc_firmware_path, the user of which interprets NULL and the empty > string as distinct values. Specifically, the empty dmc_firmware_path > leads to DMC and PM being disabled. > > Just remove the NULL check and pass it to kstrdup(), which safely > returns NULL for NULL input. Turns out this fails miserably as well. The debugfs for display params oopses for NULL value while the i915 core debugfs doesn't. I obviously didn't realize how the param handling was subtly different between the two. Since the quick fix didn't cut it, I've opted to revert 0d82a0d6f556 ("drm/i915/display: move dmc_firmware_path to display params") with Rodrigo's and Lucas' acks. Back to the drawing board. We probably want to first address the issue with NULL and "" being distinct values for firmware path params and the fact that you can't set them back to NULL via debugfs or module param sysfs. BR, Jani. > Fixes: 8015bee0bfec ("drm/i915/display: Add framework to add parameters specific to display") > Fixes: 0d82a0d6f556 ("drm/i915/display: move dmc_firmware_path to display params") > Cc: Jouni Högander <jouni.hogander@intel.com> > Cc: Luca Coelho <luciano.coelho@intel.com> > Cc: <stable@vger.kernel.org> # v6.8+ > Signed-off-by: Jani Nikula <jani.nikula@intel.com> > --- > drivers/gpu/drm/i915/display/intel_display_params.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/i915/display/intel_display_params.c b/drivers/gpu/drm/i915/display/intel_display_params.c > index c8e3d6892e23..49c6b42077dc 100644 > --- a/drivers/gpu/drm/i915/display/intel_display_params.c > +++ b/drivers/gpu/drm/i915/display/intel_display_params.c > @@ -176,9 +176,9 @@ void intel_display_params_dump(struct drm_i915_private *i915, struct drm_printer > #undef PRINT > } > > -__maybe_unused static void _param_dup_charp(char **valp) > +static void _param_dup_charp(char **valp) > { > - *valp = kstrdup(*valp ? *valp : "", GFP_ATOMIC); > + *valp = kstrdup(*valp, GFP_ATOMIC); > } > > __maybe_unused static void _param_nop(void *valp)
diff --git a/drivers/gpu/drm/i915/display/intel_display_params.c b/drivers/gpu/drm/i915/display/intel_display_params.c index c8e3d6892e23..49c6b42077dc 100644 --- a/drivers/gpu/drm/i915/display/intel_display_params.c +++ b/drivers/gpu/drm/i915/display/intel_display_params.c @@ -176,9 +176,9 @@ void intel_display_params_dump(struct drm_i915_private *i915, struct drm_printer #undef PRINT } -__maybe_unused static void _param_dup_charp(char **valp) +static void _param_dup_charp(char **valp) { - *valp = kstrdup(*valp ? *valp : "", GFP_ATOMIC); + *valp = kstrdup(*valp, GFP_ATOMIC); } __maybe_unused static void _param_nop(void *valp)
The display param duplication deviates from the original param duplication in that it converts NULL params to to allocated empty strings. This works for the vbt_firmware parameter, but not for dmc_firmware_path, the user of which interprets NULL and the empty string as distinct values. Specifically, the empty dmc_firmware_path leads to DMC and PM being disabled. Just remove the NULL check and pass it to kstrdup(), which safely returns NULL for NULL input. Fixes: 8015bee0bfec ("drm/i915/display: Add framework to add parameters specific to display") Fixes: 0d82a0d6f556 ("drm/i915/display: move dmc_firmware_path to display params") Cc: Jouni Högander <jouni.hogander@intel.com> Cc: Luca Coelho <luciano.coelho@intel.com> Cc: <stable@vger.kernel.org> # v6.8+ Signed-off-by: Jani Nikula <jani.nikula@intel.com> --- drivers/gpu/drm/i915/display/intel_display_params.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)