Received: by 2002:a05:7412:3290:b0:fa:6e18:a558 with SMTP id ev16csp826721rdb; Fri, 26 Jan 2024 11:55:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IGNrMcfnzQhDEpu2qkN1dqAhj0VPyzAmTW00uPQ5SSEs9Potw3UKVnp0h1v6O67ss/FXu2r X-Received: by 2002:a05:6214:19cf:b0:681:68dc:58eb with SMTP id j15-20020a05621419cf00b0068168dc58ebmr439130qvc.88.1706298910568; Fri, 26 Jan 2024 11:55:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706298910; cv=pass; d=google.com; s=arc-20160816; b=FP86UifR8zHJwyXSTV1i0T4OO0RGzNLeHcuAs1h4TJ2hP8lQbwIb+ugZO2vUZ5pLm7 7iyVkcuFYdaraVAcvoXZeovH3Cmj1g5BczTPBrQUSvfWB9W72yLydIlvuL704q9z+/eS For6SjfarDgJ4wrFyrK5CV5rYYmX/zH/NKGbb654MibJ3k5JaKPEWiENk1Xjps9fAKMU cDaL9/KlbfVqZbwIYmi3MqreH08svHTvR85nUltkYlYzqTZ5hwWpknNg9hSWNFjrSo6C cS4Z3jtBKT6S07mkQ5vYYoSpt2sG/YjLDvehLpYSt5y9igbYnqMuM0tbTjZtqTr0mhNU PtMA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=JGo0GIM0JPQhV0kSzWpW8QacPsz1Bsu9GxpTQJuvl58=; fh=5o3iYJoYsAP3d9cTxMOhR+E3jpeSW51IjIfKFfAuiwA=; b=RAeXHup1nTY3BqRzju5Wzw/yx5zR0fi8J3I3yU5SmALL/Ai6DJK+yVhJrK//Owte82 nOfzRM1P/SeEQw+7Y07K/u8yR3gp2j99e0XHmpZuTP4or3/ghIJMpq4nE3L6u/RW2rGg rrxWrw/3uufT1Q/djbTDWtWzn/e8V4jw2gOqJyMEek+RtGuxGZ6ommXyNwW/qBrWou6U gz5csoxgDMnhnxNFjzhl9R8hT6YiI+qqTTf7DQIAukAA5KaM1eiMkSnagf3XWmwlWvFX QjFDlJ2XETpJEJ20jBJD1TiMkWrWf8jqCmLmNWyKAoJ3wGJbuRF1n33Ebdt+qLV9mQmZ e9aA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nQKmbnMh; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-40222-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40222-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id gu1-20020a056214260100b006819867ed39si2017951qvb.388.2024.01.26.11.55.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 11:55:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-40222-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nQKmbnMh; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-40222-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40222-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 7C1131C228FB for ; Fri, 26 Jan 2024 14:45:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8C99D1D537; Fri, 26 Jan 2024 14:45:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="nQKmbnMh" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) (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 0C2571CFBB for ; Fri, 26 Jan 2024 14:44:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.14 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706280300; cv=none; b=MU7JlGaE9h6ZhZ2iLuKTqHB0avdmPbx02AhE3LnvpcVQTg/ovUGVqf9Cdn7NbXox3HYg6W/MGO3fOXfDtJyjBqf/3Zmm64kZH+e9Ini+lEeOrSzvqJcV5d6XF6eG/xgQ0jX3fU7Plh1xz2UnXF4coMsGu7cBAuY1xxS2QgRBgWo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706280300; c=relaxed/simple; bh=bym/ajJOjcQl8LKnRUAO/z1T8s/laBYaWYjbSMZv0tE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ETb59M4Cw176o3dQvvZaXmZPTNX2JR6uRMlCGy4kr6U0rBqgulBu9zLLKais/ZwCrKs8Sl7QSUnSLO5a1VcUEAn2/nKOtVjOxobFw8rRT/eLmTs8or4iHXh2npCdosilZXztuNHhu7Tn/55PPrNQh+BA8Hjg2rTz+wrCY8xGzjA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=nQKmbnMh; arc=none smtp.client-ip=198.175.65.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706280299; x=1737816299; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=bym/ajJOjcQl8LKnRUAO/z1T8s/laBYaWYjbSMZv0tE=; b=nQKmbnMhRtA1aq2I7/9AyObPl03r8xvWETYYcABh72eR9oOvJQ6P4Ndk FqpD7ody29G2dAGuBM6X/S2Xh5/7JcYxKQBZ35Xm+vKIdg5AzSFlPEzgC 5XeKoFQ/EKBLW2VT0JSjVJK2J2V+lAh/fz4PiUV5aqmJ9bAVgkEzOA0uu OkDavpDnJeZKtM50MBhiwFbMkxEJYi5F/AfHG8Nb3zpRHhrNLMnnFfjHh XZufoliYz8gI1VSwb40Iyvlvo/LM/NdxAkJS4R0SEUXDM2Pw0UhU7jOVQ hv8iHsTF4nJZj/f5KsfoivaMqNsJjImtKAovpZ1/VxSbej545orywFciY g==; X-IronPort-AV: E=McAfee;i="6600,9927,10964"; a="2371526" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="2371526" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2024 06:44:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10964"; a="821159831" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="821159831" Received: from stinkpipe.fi.intel.com (HELO stinkbox) ([10.237.72.74]) by orsmga001.jf.intel.com with SMTP; 26 Jan 2024 06:44:54 -0800 Received: by stinkbox (sSMTP sendmail emulation); Fri, 26 Jan 2024 16:44:53 +0200 Date: Fri, 26 Jan 2024 16:44:53 +0200 From: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= To: wangxiaoming321 Cc: lucas.demarchi@intel.com, ogabbay@kernel.org, thomas.hellstrom@linux.intel.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, daniel@ffwll.ch, intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] drm/xe/display: Fix memleak in display initialization Message-ID: References: <20240125063633.989944-1-xiaoming.wang@intel.com> <20240126143433.997078-1-xiaoming.wang@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240126143433.997078-1-xiaoming.wang@intel.com> X-Patchwork-Hint: comment On Fri, Jan 26, 2024 at 10:34:33PM +0800, wangxiaoming321 wrote: > intel_power_domains_init has been called twice in xe_device_probe: > xe_device_probe -> xe_display_init_nommio -> intel_power_domains_init(xe) > xe_device_probe -> xe_display_init_noirq -> intel_display_driver_probe_noirq > -> intel_power_domains_init(i915) Why are you calling it twice? > > It needs add a flag to avoid power_domains->power_wells double malloc. > > unreferenced object 0xffff88811150ee00 (size 512): > comm "systemd-udevd", pid 506, jiffies 4294674198 (age 3605.560s) > hex dump (first 32 bytes): > 10 b4 9d a0 ff ff ff ff ff ff ff ff ff ff ff ff ................ > ff ff ff ff ff ff ff ff 00 00 00 00 00 00 00 00 ................ > backtrace: > [] __kmem_cache_alloc_node+0x1c1/0x2b0 > [] __kmalloc+0x52/0x150 > [] __set_power_wells+0xc3/0x360 [xe] > [] xe_display_init_nommio+0x4c/0x70 [xe] > [] xe_device_probe+0x3c/0x5a0 [xe] > [] xe_pci_probe+0x33f/0x5a0 [xe] > [] local_pci_probe+0x47/0xa0 > [] pci_device_probe+0xc3/0x1f0 > [] really_probe+0x1a2/0x410 > [] __driver_probe_device+0x78/0x160 > [] driver_probe_device+0x1e/0x90 > [] __driver_attach+0xda/0x1d0 > [] bus_for_each_dev+0x7c/0xd0 > [] bus_add_driver+0x119/0x220 > [] driver_register+0x60/0x120 > [] 0xffffffffa05e50a0 > > Signed-off-by: wangxiaoming321 > --- > drivers/gpu/drm/i915/display/intel_display_power.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/drivers/gpu/drm/i915/display/intel_display_power.c b/drivers/gpu/drm/i915/display/intel_display_power.c > index bf9685acf75a..3b48a1cb7c54 100644 > --- a/drivers/gpu/drm/i915/display/intel_display_power.c > +++ b/drivers/gpu/drm/i915/display/intel_display_power.c > @@ -36,6 +36,8 @@ > for_each_power_well_reverse(__dev_priv, __power_well) \ > for_each_if(test_bit((__domain), (__power_well)->domains.bits)) > > +static int intel_power_domains_init_flag = 0; > + > const char * > intel_display_power_domain_str(enum intel_display_power_domain domain) > { > @@ -1016,6 +1018,11 @@ int intel_power_domains_init(struct drm_i915_private *dev_priv) > { > struct i915_power_domains *power_domains = &dev_priv->display.power.domains; > > + if(intel_power_domains_init_flag == 1) > + return 0; > + > + intel_power_domains_init_flag++; Consider what happens when you have multiple Intel GPUs in the system... > + > dev_priv->display.params.disable_power_well = > sanitize_disable_power_well_option(dev_priv, > dev_priv->display.params.disable_power_well); > @@ -1041,6 +1048,7 @@ int intel_power_domains_init(struct drm_i915_private *dev_priv) > */ > void intel_power_domains_cleanup(struct drm_i915_private *dev_priv) > { > + intel_power_domains_init_flag = 0; > intel_display_power_map_cleanup(&dev_priv->display.power.domains); > } > > -- > 2.25.1 -- Ville Syrj?l? Intel