From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 09B2418C1F for ; Fri, 27 Sep 2024 08:38:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.7 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727426321; cv=none; b=rUx/FsBWHWjgdDcUKuJOVyH4Kdz48FDxN8RgIMfogti/f6eOnuFmcSF35pn8NIo8J0k3mRgJ0ZpckNcs0TwZ9CXbgvTgmqnao9SEmW2X040x+JSaG2rR+Ky/mf3Dbwo4Y7NlWDfQn4beU8yvRp1VJxEzrL8fH3xdS723kZuR7gI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727426321; c=relaxed/simple; bh=1me+ShLNnot4eBJYuxAtKeswmVdRy1w6WPYAdQlYdvw=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=eTFT/U0JhYROkm1ur98CbWHVmqJARW8xU6GvLHE/UaGXwajQ8mOItVNF4QtK/8qQcF39OGZus5LlFhdtgDDeO/GvdYMdrdzSy9jNra/ayJwJfLc7M/sRkwm2uoAvsqz8QNYEfDzT1Sz7RH/nFVaZtimt0Lih/ktbL4EW8gr08eA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=ekbwGMXp; arc=none smtp.client-ip=192.198.163.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ekbwGMXp" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1727426319; x=1758962319; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=1me+ShLNnot4eBJYuxAtKeswmVdRy1w6WPYAdQlYdvw=; b=ekbwGMXpAHjefBsxnALlHo/c+a/sBt0x03o/uCg9hfXmtIwGS01JZMMc K0NgHaMp62T6hjQFvObLvPJKbK2X8B4jlapqxYcK5/9sFhnJAms2SrCsh 3KhMpZ+tV+PcNBAy2lZ9QpebLLkHBVNDai8pxpjaJQcO11gi+8reals57 B6K412oBKQnqUxdfhKfx6xjZzQWhP4IVZBU236DZOpCZzQkhyow6xf5Rp xj/eKCUfn6JLzosRzT8OOrI3bZ3LGvcJt7CZlj2h6+RPJ/T2ZURjulr+O pPdAKQvImPaCfG6GIvwgD17guzfByfX+ozPBYgh5JP8tGmrpQvuZDozEC Q==; X-CSE-ConnectionGUID: lzc+tSFQT1qKSzZ9TJjRsQ== X-CSE-MsgGUID: Ak+ZFli9SGOV7VFQmPpwBg== X-IronPort-AV: E=McAfee;i="6700,10204,11207"; a="51977726" X-IronPort-AV: E=Sophos;i="6.11,158,1725346800"; d="scan'208";a="51977726" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2024 01:38:38 -0700 X-CSE-ConnectionGUID: 2OMKsGp8TuegWuQRugSBbA== X-CSE-MsgGUID: NOmt5vyNQRCN1UMHWDNTGg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,158,1725346800"; d="scan'208";a="77409637" Received: from bergbenj-mobl1.ger.corp.intel.com (HELO localhost) ([10.245.246.211]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2024 01:38:35 -0700 From: Jani Nikula To: Rodrigo Vivi Cc: intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org, Matthew Auld , Anshuman Gupta , Andi Shyti , Nathan Chancellor , stable@vger.kernel.org Subject: Re: [PATCH v2 1/6] drm/i915/gem: fix bitwise and logical AND mixup In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <643cc0a4d12f47fd8403d42581e83b1e9c4543c7.1726680898.git.jani.nikula@intel.com> Date: Fri, 27 Sep 2024 11:38:29 +0300 Message-ID: <87r095ze2i.fsf@intel.com> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain On Thu, 26 Sep 2024, Rodrigo Vivi 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. BR, Jani. > >> >> Fixes: ad74457a6b5a ("drm/i915/dgfx: Release mmap on rpm suspend") >> Cc: Matthew Auld >> Cc: Rodrigo Vivi >> Cc: Anshuman Gupta >> Cc: Andi Shyti >> Cc: Nathan Chancellor >> Cc: # v6.1+ >> Reviewed-by: Matthew Auld # v1 >> Reviewed-by: Andi Shyti # v1 >> Signed-off-by: Jani Nikula >> --- >> 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