From nobody Thu Oct 2 17:00:07 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (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 B45AF2F28E6; Mon, 15 Sep 2025 09:16:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757927779; cv=none; b=Wm9UXi5qUgUELfIL7Lq7IJ7kMmhz3wQ+bRB2ikoejKH7G4vuocqBnfVOCS0r7xo1FhU0mMPfukqFWOQIuSl5brYwBQnyxiv0e411KvfYO4PRdmSHlnavQZzKE7dRsjvItwFjsTn1LgbtpomnRZe2GMMwrMX2HqtXw3nTBMM1eWs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757927779; c=relaxed/simple; bh=3QZLcU1sOaofImxypEEkFSCCp9uLAxUQQn/lot3lAiI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=cmvsDh+z97Yr2mrxgyBXOZ+Lonov/vozP+uJUq8QRLbfF1I2ZmL2IP6SDN+jKt93NouQCuuDSxDBA5PmkmexohorSVe0/bRuEoNkZ4LUSj6oJm682KMv0zyl/wM4bPeH7QY4xV/+93So/VSLyEStv2Q48tf7bOYL5stDnuq+eLw= 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=VRyVghQ+; arc=none smtp.client-ip=192.198.163.18 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="VRyVghQ+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1757927777; x=1789463777; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3QZLcU1sOaofImxypEEkFSCCp9uLAxUQQn/lot3lAiI=; b=VRyVghQ+80Kqj/hpiWLvT8n3EdwU0xnbGFdnIqxadP4UaEu4KwRW3XXk rcNkZAqFykRVeRQQ0uWCBm+qEyW2WmFXpLQ8c3HPohxYe/WLTQ+ImJwDW Hy7/gN+Is3f0JwMvQQwpVwrbLx0rUA5JUO20PntiIoi9yJp77hkmwDDXT NnDfdo85yVBxybHPzIONjfIpG2dQsVPujtrPhBwWNlYSnkdcvG/06GoMo taUxVzljLVGbJmRcWGUTIREVtJg46mPPDbHk2uQvdfzYD9luA7m2RDQoA p2B5SyvqBKQA+RBZRDgX3Qc8ZnpXxEljgySrqLu9dY/bvubjyW5u8wclH g==; X-CSE-ConnectionGUID: euWm/HMORYiH7nBrL3JQyw== X-CSE-MsgGUID: G5J2omOeRbifx2X2COT3Wg== X-IronPort-AV: E=McAfee;i="6800,10657,11553"; a="59401376" X-IronPort-AV: E=Sophos;i="6.18,265,1751266800"; d="scan'208";a="59401376" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2025 02:16:17 -0700 X-CSE-ConnectionGUID: Qd5TG6JaS9iw3UGWoNdylA== X-CSE-MsgGUID: VTXSdWOPQ4G7D6CGu0QLYQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.18,265,1751266800"; d="scan'208";a="175364122" Received: from ijarvine-mobl1.ger.corp.intel.com (HELO localhost) ([10.245.245.39]) by fmviesa010-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2025 02:16:09 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: linux-pci@vger.kernel.org, Bjorn Helgaas , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , =?UTF-8?q?Christian=20K=C3=B6nig?= , =?UTF-8?q?Micha=C5=82=20Winiarski?= , Alex Deucher , amd-gfx@lists.freedesktop.org, David Airlie , dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org, Jani Nikula , Joonas Lahtinen , Lucas De Marchi , Rodrigo Vivi , Simona Vetter , Tvrtko Ursulin , ?UTF-8?q?Thomas=20Hellstr=C3=B6m?= , "Michael J . Ruhl" , linux-kernel@vger.kernel.org Cc: linux-doc@vger.kernel.org, =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH v2 09/11] drm/xe/vram: Use pci_rebar_get_max_size() Date: Mon, 15 Sep 2025 12:13:56 +0300 Message-Id: <20250915091358.9203-10-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250915091358.9203-1-ilpo.jarvinen@linux.intel.com> References: <20250915091358.9203-1-ilpo.jarvinen@linux.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="utf-8" Content-Transfer-Encoding: quoted-printable Use pci_rebar_get_max_size() from PCI core in resize_vram_bar() to simplify code. Signed-off-by: Ilpo J=C3=A4rvinen Acked-by: Christian K=C3=B6nig Acked-by: Rodrigo Vivi --- drivers/gpu/drm/xe/xe_vram.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_vram.c b/drivers/gpu/drm/xe/xe_vram.c index d4fbd7f74255..ca02744fb369 100644 --- a/drivers/gpu/drm/xe/xe_vram.c +++ b/drivers/gpu/drm/xe/xe_vram.c @@ -54,16 +54,11 @@ static void resize_vram_bar(struct xe_device *xe) resource_size_t current_size; resource_size_t rebar_size; struct resource *root_res; - u32 bar_size_mask; + int max_size, i; u32 pci_cmd; - int i; =20 /* gather some relevant info */ current_size =3D pci_resource_len(pdev, LMEM_BAR); - bar_size_mask =3D pci_rebar_get_possible_sizes(pdev, LMEM_BAR); - - if (!bar_size_mask) - return; =20 if (force_vram_bar_size < 0) return; @@ -77,7 +72,8 @@ static void resize_vram_bar(struct xe_device *xe) drm_info(&xe->drm, "Requested size: %lluMiB is not supported by rebar sizes: 0x%x. Leavi= ng default: %lluMiB\n", (u64)pci_rebar_size_to_bytes(rebar_size) >> 20, - bar_size_mask, (u64)current_size >> 20); + pci_rebar_get_possible_sizes(pdev, LMEM_BAR), + (u64)current_size >> 20); return; } =20 @@ -85,7 +81,10 @@ static void resize_vram_bar(struct xe_device *xe) if (rebar_size =3D=3D current_size) return; } else { - rebar_size =3D pci_rebar_size_to_bytes(__fls(bar_size_mask)); + max_size =3D pci_rebar_get_max_size(pdev, LMEM_BAR); + if (max_size < 0) + return; + rebar_size =3D pci_rebar_size_to_bytes(max_size); =20 /* only resize if larger than current */ if (rebar_size <=3D current_size) --=20 2.39.5