Re: [PATCH v2 1/6] drm/i915/gem: fix bitwise and logical AND mixup

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

 



On Mon, 30 Sep 2024, Matthew Auld <matthew.auld@xxxxxxxxx> wrote:
> On 30/09/2024 14:54, Jani Nikula wrote:
>> On Fri, 27 Sep 2024, Jani Nikula <jani.nikula@xxxxxxxxx> wrote:
>>> On Thu, 26 Sep 2024, Rodrigo Vivi <rodrigo.vivi@xxxxxxxxx> wrote:
>>>> On Wed, Sep 18, 2024 at 08:35:43PM +0300, Jani Nikula wrote:
>>>>> CONFIG_DRM_I915_USERFAULT_AUTOSUSPEND is an int, defaulting to 250. When
>>>>> the wakeref is non-zero, it's either -1 or a dynamically allocated
>>>>> pointer, depending on CONFIG_DRM_I915_DEBUG_RUNTIME_PM. It's likely that
>>>>> the code works by coincidence with the bitwise AND, but with
>>>>> CONFIG_DRM_I915_DEBUG_RUNTIME_PM=y, there's the off chance that the
>>>>> condition evaluates to false, and intel_wakeref_auto() doesn't get
>>>>> called. Switch to the intended logical AND.
>>>>>
>>>>> v2: Use != to avoid clang -Wconstant-logical-operand (Nathan)
>>>>
>>>> oh, this is ugly!
>>>>
>>>> Wouldn't it be better then to use IS_ENABLED() macro?
>>>
>>> It's an int config option, not a bool. (Yes, the name is misleading.)
>>>
>>> IS_ENABLED(CONFIG_DRM_I915_USERFAULT_AUTOSUSPEND) would be the same as
>>> CONFIG_DRM_I915_USERFAULT_AUTOSUSPEND == 1.
>>>
>>> We're actually checking if the int value != 0, so IMO the patch at hand
>>> is fine.
>> 
>> Ping, r-b on this one too?
>
> r-b still holds for v2, fwiw.

Thanks for the reviews, pushed the lot to drm-intel-next.

BR,
Jani.

>
>> 
>> BR,
>> Jani.
>> 
>>>
>>> BR,
>>> Jani.
>>>
>>>
>>>>
>>>>>
>>>>> Fixes: ad74457a6b5a ("drm/i915/dgfx: Release mmap on rpm suspend")
>>>>> Cc: Matthew Auld <matthew.auld@xxxxxxxxx>
>>>>> Cc: Rodrigo Vivi <rodrigo.vivi@xxxxxxxxx>
>>>>> Cc: Anshuman Gupta <anshuman.gupta@xxxxxxxxx>
>>>>> Cc: Andi Shyti <andi.shyti@xxxxxxxxxxxxxxx>
>>>>> Cc: Nathan Chancellor <nathan@xxxxxxxxxx>
>>>>> Cc: <stable@xxxxxxxxxxxxxxx> # v6.1+
>>>>> Reviewed-by: Matthew Auld <matthew.auld@xxxxxxxxx> # v1
>>>>> Reviewed-by: Andi Shyti <andi.shyti@xxxxxxxxxxxxxxx> # v1
>>>>> Signed-off-by: Jani Nikula <jani.nikula@xxxxxxxxx>
>>>>> ---
>>>>>   drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 2 +-
>>>>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>>>>
>>>>> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
>>>>> index 5c72462d1f57..b22e2019768f 100644
>>>>> --- a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
>>>>> +++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
>>>>> @@ -1131,7 +1131,7 @@ static vm_fault_t vm_fault_ttm(struct vm_fault *vmf)
>>>>>   		GEM_WARN_ON(!i915_ttm_cpu_maps_iomem(bo->resource));
>>>>>   	}
>>>>>   
>>>>> -	if (wakeref & CONFIG_DRM_I915_USERFAULT_AUTOSUSPEND)
>>>>> +	if (wakeref && CONFIG_DRM_I915_USERFAULT_AUTOSUSPEND != 0)
>>>>>   		intel_wakeref_auto(&to_i915(obj->base.dev)->runtime_pm.userfault_wakeref,
>>>>>   				   msecs_to_jiffies_timeout(CONFIG_DRM_I915_USERFAULT_AUTOSUSPEND));
>>>>>   
>>>>> -- 
>>>>> 2.39.2
>>>>>
>> 

-- 
Jani Nikula, Intel



[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux