Re: [Nouveau] [PATCH] drm/nouveau/mmu: Fix a typo

2022-06-21 Thread Joe Perches
On Wed, 2022-06-22 at 09:52 +0800, Zhang Jiaming wrote:
> There is a typo in comments. Change 'neeed' to 'need'.
[]
> diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c 
> b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c
[]
> @@ -280,7 +280,7 @@ nvkm_vmm_unref_ptes(struct nvkm_vmm_iter *it, bool pfn, 
> u32 ptei, u32 ptes)
>   if (desc->type == SPT && (pgt->refs[0] || pgt->refs[1]))
>   nvkm_vmm_unref_sptes(it, pgt, desc, ptei, ptes);
>  
> - /* PT no longer neeed?  Destroy it. */
> + /* PT no longer need?  Destroy it. */

needed



Re: [Nouveau] [PATCH] drm/nouveau/Kconfig: Drop duplicate "select ACPI_VIDEO"

2022-06-21 Thread Lyude Paul
Reviewed-by: Lyude Paul 

Also, you have my permission to push this to drm-misc-next.

On Mon, 2022-06-20 at 11:46 +0200, Hans de Goede wrote:
> Before this change nouveau's Kconfig section had 2 "select ACPI_VIDEO"
> statements:
> 
> select ACPI_VIDEO if ACPI && X86 && BACKLIGHT_CLASS_DEVICE && INPUT
> select ACPI_VIDEO if ACPI && X86
> 
> Drop the one with the extra conditions, if the conditions for that
> one are true then the second statement will always select ACPI_VIDEO
> already.
> 
> Signed-off-by: Hans de Goede 
> ---
>  drivers/gpu/drm/nouveau/Kconfig | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/nouveau/Kconfig
> b/drivers/gpu/drm/nouveau/Kconfig
> index 34760164c271..03d12caf9e26 100644
> --- a/drivers/gpu/drm/nouveau/Kconfig
> +++ b/drivers/gpu/drm/nouveau/Kconfig
> @@ -11,7 +11,6 @@ config DRM_NOUVEAU
> select DRM_TTM
> select DRM_TTM_HELPER
> select BACKLIGHT_CLASS_DEVICE if DRM_NOUVEAU_BACKLIGHT
> -   select ACPI_VIDEO if ACPI && X86 && BACKLIGHT_CLASS_DEVICE && INPUT
> select X86_PLATFORM_DEVICES if ACPI && X86
> select ACPI_WMI if ACPI && X86
> select MXM_WMI if ACPI && X86

-- 
Cheers,
 Lyude Paul (she/her)
 Software Engineer at Red Hat



Re: [Nouveau] [PATCH] drm/nouveau/mmu: drop unexpected word "the" in the comments

2022-06-21 Thread Lyude Paul
Reviewed-by: Lyude Paul 

Will push to the appropriate branch in a moment

On Tue, 2022-06-21 at 21:39 +0800, Jiang Jian wrote:
> there is an unexpected word "the" in the comments that need to be dropped
> 
> file: drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c
> line: 1051
>  * have the the deepest nesting of page tables.
> changed to
>  * have the deepest nesting of page tables.
> 
> Signed-off-by: Jiang Jian 
> ---
>  drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c
> b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c
> index ca74775834dd..ae793f400ba1 100644
> --- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c
> +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c
> @@ -1048,7 +1048,7 @@ nvkm_vmm_ctor(const struct nvkm_vmm_func *func, struct
> nvkm_mmu *mmu,
> __mutex_init(>mutex, ">mutex", key ? key : &_key);
>  
> /* Locate the smallest page size supported by the backend, it will
> -    * have the the deepest nesting of page tables.
> +    * have the deepest nesting of page tables.
>  */
> while (page[1].shift)
> page++;

-- 
Cheers,
 Lyude Paul (she/her)
 Software Engineer at Red Hat



Re: [Nouveau] [PATCH 01/14] ACPI: video: Add a native function parameter to acpi_video_get_backlight_type()

2022-06-21 Thread Hans de Goede
Hi,

On 5/19/22 11:02, Jani Nikula wrote:
> On Wed, 18 May 2022, Hans de Goede  wrote:
>> Hi,
>>
>> On 5/18/22 10:55, Jani Nikula wrote:
>>> On Tue, 17 May 2022, Hans de Goede  wrote:
 ATM on x86 laptops where we want userspace to use the acpi_video backlight
 device we often register both the GPU's native backlight device and
 acpi_video's firmware acpi_video# backlight device. This relies on
 userspace preferring firmware type backlight devices over native ones, but
 registering 2 backlight devices for a single display really is undesirable.

 On x86 laptops where the native GPU backlight device should be used,
 the registering of other backlight devices is avoided by their drivers
 using acpi_video_get_backlight_type() and only registering their backlight
 if the return value matches their type.

 acpi_video_get_backlight_type() uses
 backlight_device_get_by_type(BACKLIGHT_RAW) to determine if a native
 driver is available and will never return native if this returns
 false. This means that the GPU's native backlight registering code
 cannot just call acpi_video_get_backlight_type() to determine if it
 should register its backlight, since acpi_video_get_backlight_type() will
 never return native until the native backlight has already registered.

 To fix this add a native function parameter to
 acpi_video_get_backlight_type(), which when set to true will make
 acpi_video_get_backlight_type() behave as if a native backlight has
 already been registered.
> 
> Regarding the question below, this is the part that throws me off.
> 

 Note that all current callers are updated to pass false for the new
 parameter, so this change in itself causes no functional changes.
>>>
>>>
 diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c
 index becc198e4c22..0a06f0edd298 100644
 --- a/drivers/acpi/video_detect.c
 +++ b/drivers/acpi/video_detect.c
 @@ -17,12 +17,14 @@
   * Otherwise vendor specific drivers like thinkpad_acpi, asus-laptop,
   * sony_acpi,... can take care about backlight brightness.
   *
 - * Backlight drivers can use acpi_video_get_backlight_type() to determine
 - * which driver should handle the backlight.
 + * Backlight drivers can use acpi_video_get_backlight_type() to determine 
 which
 + * driver should handle the backlight. RAW/GPU-driver backlight drivers 
 must
 + * pass true for the native function argument, other drivers must pass 
 false.
   *
   * If CONFIG_ACPI_VIDEO is neither set as "compiled in" (y) nor as a 
 module (m)
   * this file will not be compiled and acpi_video_get_backlight_type() will
 - * always return acpi_backlight_vendor.
 + * return acpi_backlight_native when its native argument is true and
 + * acpi_backlight_vendor when it is false.
   */
>>>
>>> Frankly, I think the boolean native parameter here, and at the call
>>> sites, is confusing, and the slightly different explanations in the
>>> commit message and comment here aren't helping.
>>
>> Can you elaborate the "slightly different explanations in the
>> commit message and comment" part a bit (so that I can fix this) ?
>>
>>> I suggest adding a separate function that the native backlight drivers
>>> should use. I think it's more obvious all around, and easier to document
>>> too.
>>
>> Code wise I think this would mean renaming the original and
>> then adding 2 wrappers, but that is fine with me. I've no real
>> preference either way and I'm happy with adding a new variant of
>> acpi_video_get_backlight_type() for the native backlight drivers
>> any suggestion for a name ?
> 
> Alternatively, do the native backlight drivers have any need for the
> actual backlight type information from acpi? They only need to be able
> to ask if they should register themselves, right?
> 
> I understand this sounds like bikeshedding, but I'm trying to avoid
> duplicating the conditions in the drivers where a single predicate
> function call could be sufficient, and the complexity could be hidden in
> acpi.
> 
>   if (!acpi_video_backlight_use_native())
>   return;

acpi_video_backlight_use_native() sounds good, I like I will change
this for v2. This also removes churn in all the other
acpi_video_get_backlight_type() callers.

> Perhaps all the drivers/platform/x86/* backlight drivers could use:
> 
>   if (acpi_video_backlight_use_vendor())
>   ...

Hmm, as part of the ractoring there also will be new apple_gmux
and nvidia_wmi_ec types. I'm not sure about adding seperate functions
for all of those vs get_type() != foo. I like get_type != foo because
it makes clear that there will also be another caller somewhere
where get_type == foo and that that one will rbe the one which
actually gets to register its backlight.

> You can still use the native parameter etc. internally, but just hide
> the