Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 30AD8E9B262 for ; Tue, 24 Feb 2026 13:12:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 90BFF10E580; Tue, 24 Feb 2026 13:12:21 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="JO8xmZlw"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3839110E580 for ; Tue, 24 Feb 2026 13:12:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1771938740; x=1803474740; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=UBqfpuoHiHO12Q6XzOi0hlOWzhBh1VVhircJp5oD0zY=; b=JO8xmZlwLN8/blqzufXXqKmayJfcxbmblmi3PiUYakzLLcSCnttJO4Lv A8DC1ItZwyceMdmauC7fVP3vgDrSq4LMNrPcuUWvwQXKA9FpznNqB6u51 S3rKsGGl/BQk4JacOrUadSeKG/lFQXc5KajWnafe2DDcitlXQn56t2nrs Ut7Y4zuVLigr3HzWTUrp5yhi0HuTCg/PBWOEMA+Lrx6bivVPRWee/77i8 iG4CpeOV5beiE/hl6bbVVrUj+M49Ux0nTDkKVptP3rTJAPjg4syq4yjod jkQHrRxkshaoPyol91xW6zlIxuxdztPYxy4DZo2gtIno6VuXRvvVqIcfC w==; X-CSE-ConnectionGUID: 5ooL+tELQ56NgUQ7Lxtbiw== X-CSE-MsgGUID: 1VChQcTaTjuehGqMXiHPQA== X-IronPort-AV: E=McAfee;i="6800,10657,11710"; a="72862841" X-IronPort-AV: E=Sophos;i="6.21,308,1763452800"; d="scan'208";a="72862841" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Feb 2026 05:12:20 -0800 X-CSE-ConnectionGUID: QUCI7yJ1RpCc5Hff2hmmvg== X-CSE-MsgGUID: AvrppeMxSXSpSWelIKC1lA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,308,1763452800"; d="scan'208";a="253626735" Received: from abityuts-desk.ger.corp.intel.com (HELO [10.245.244.193]) ([10.245.244.193]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Feb 2026 05:12:18 -0800 Message-ID: <791538fb-56e5-4ca5-9484-1180cc928a70@linux.intel.com> Date: Tue, 24 Feb 2026 14:12:15 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] drm/pagemap_util: Ensure proper cache lock management on free To: Jonathan Cavitt , dri-devel@lists.freedesktop.org Cc: saurabhg.gupta@intel.com, alex.zuo@intel.com, thomas.hellstrom@linux.intel.com, matthew.brost@intel.com References: <20260220190943.66961-2-jonathan.cavitt@intel.com> Content-Language: en-US From: Maarten Lankhorst In-Reply-To: <20260220190943.66961-2-jonathan.cavitt@intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Den 2026-02-20 kl. 20:09, skrev Jonathan Cavitt: > Static analysis issue: > > Though probably unnecessary given the cache is being freed at this step, > for the sake of consistency, ensure that the cache lock is always > unlocked after drm_pagemap_cache_fini. > > Fixes: 77f14f2f2d73f ("drm/pagemap: Add a drm_pagemap cache and shrinker") > Signed-off-by: Jonathan Cavitt > Cc: Thomas Hellstrom > Cc: Matthew Brost > Cc: Maarten Lankhorst > --- > drivers/gpu/drm/drm_pagemap_util.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/gpu/drm/drm_pagemap_util.c b/drivers/gpu/drm/drm_pagemap_util.c > index c6ae3357c7fb..79e07b3658ed 100644 > --- a/drivers/gpu/drm/drm_pagemap_util.c > +++ b/drivers/gpu/drm/drm_pagemap_util.c > @@ -65,18 +65,18 @@ static void drm_pagemap_cache_fini(void *arg) > drm_dbg(cache->shrinker->drm, "Destroying dpagemap cache.\n"); > spin_lock(&cache->lock); > dpagemap = cache->dpagemap; > - if (!dpagemap) { > - spin_unlock(&cache->lock); > + if (!dpagemap) > goto out; > - } > > if (drm_pagemap_shrinker_cancel(dpagemap)) { > cache->dpagemap = NULL; > spin_unlock(&cache->lock); > drm_pagemap_destroy(dpagemap, false); > + } else { > +out: > + spin_unlock(&cache->lock); > } > > -out: > mutex_destroy(&cache->lookup_mutex); > kfree(cache); > } I think this flow without goto is slightly more readable: spin_lock(&cache->lock); dpagemap = cache->dpagemap; cache->dpagemap = NULL; if (dpagemap && !drm_pagemap_shrinker_cancel(dpagemap)) dpagemap = NULL; spin_unlock(&cache->lock); if (dpagemap) drm_pagemap_destroy(dpagemap, false); mutex_destroy(&cache->lookup_mutex); kfree(cache); } Although since we are freeing, it doesn't matter if cache->dpagemap stays assigned, so perhaps the cache->dpagemap = NULL assignment can be removed too. Kind regards, ~Maarten Lankhorst