Re: [PATCH] drm/i915/display: fix display param dup for NULL char * params

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 02 Apr 2024, Lucas De Marchi <lucas.demarchi@xxxxxxxxx> 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@xxxxxxxxx>
>>Cc: Luca Coelho <luciano.coelho@xxxxxxxxx>
>>Cc: <stable@xxxxxxxxxxxxxxx> # v6.8+
>>Signed-off-by: Jani Nikula <jani.nikula@xxxxxxxxx>
>
> Reviewed-by: Lucas De Marchi <lucas.demarchi@xxxxxxxxx>

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@xxxxxxxxx/),
> 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.



-- 
Jani Nikula, Intel





[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux