From nobody Sat Feb 7 07:25:35 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) (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 77214347FF6; Wed, 22 Oct 2025 13:35:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761140159; cv=none; b=LrBJhNK3qiz4DperQjbSqlxpF9Iio4JkMRX0IkFY63N6r2kM2GXux/iSef/HavB/tBNQ98wzhVfvDZ+ZwU/xzitqbaMZgx43za/3icPxHo832XTUCxHa2I8/J5KaV4Zz5pwx4jpadhoAOw4JNyQ0R4Vxb4Zg63TX3mkXp72HykQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761140159; c=relaxed/simple; bh=EmpF6b0WmnNp0mwUO4CDpZ5esZ0cLfkjpTyG6Yghz5o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=U3BsSOGfMrWYdo9c2EzL4Ub1skOfT7Ubk9VHclwcLHIwzwcAHrgjgHRNWmzD5n6ZYHb4Z082lHSQ6v7Vp9WATAeVxILA4RxsesCx7rIy2tpvxRdTBuQwgL9fFDkPdt/tET7Dp7Q4wwrS0EC0WNWhAgg5y8d9psVatQdCG/Vl4Zs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=FUWTVaXH; arc=none smtp.client-ip=192.198.163.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass 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="FUWTVaXH" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1761140157; x=1792676157; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=EmpF6b0WmnNp0mwUO4CDpZ5esZ0cLfkjpTyG6Yghz5o=; b=FUWTVaXHHm9anLu9TCyDYWmxePWnhrhJRe1gIXoymgtoTgiqsdEwfpeL H3xLWDKRG8zzF/3LZhqNFVO7QlEUXitGGEq361eCIboSA7YsAdLwmvCqL XgNLJS/+b8b+erWgRIkH4e813XkqTPK7O5yAhMdYFf1Buxn1a4LSchhF6 iMg9FT3cD5O9abyBOuD4jro0AyizhWra9YV2UdBa2dKC2AXAkRSX6V023 f47Qcz5e4LbpsgARv/PKMVsLuunv0zbYABmS4iAaeoBsUe1yWYhIWFL5J vmStoNN1F1ec5itsTdZwJeCIvV6/BslBSfbMdbsZ5A+lbpfykQqqSpRCw A==; X-CSE-ConnectionGUID: Mgncv70GTxKtrgTA9C/Y1Q== X-CSE-MsgGUID: cfIFpMgvS4WnMWJ4PwRakw== X-IronPort-AV: E=McAfee;i="6800,10657,11586"; a="67152658" X-IronPort-AV: E=Sophos;i="6.19,247,1754982000"; d="scan'208";a="67152658" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2025 06:35:56 -0700 X-CSE-ConnectionGUID: 01BFCYMtRpeNxnwdyj8gHg== X-CSE-MsgGUID: Um+07uRyRZmfKkxVOh4lDQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,247,1754982000"; d="scan'208";a="188281691" Received: from ijarvine-mobl1.ger.corp.intel.com (HELO localhost) ([10.245.244.82]) by fmviesa005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2025 06:35:49 -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 , "Michael J . Ruhl" , Andi Shyti , linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH v3 10/11] drm/amdgpu: Use pci_rebar_get_max_size() Date: Wed, 22 Oct 2025 16:33:30 +0300 Message-Id: <20251022133331.4357-11-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251022133331.4357-1-ilpo.jarvinen@linux.intel.com> References: <20251022133331.4357-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 to simplify code in amdgpu_device_resize_fb_bar(). Signed-off-by: Ilpo J=C3=A4rvinen Reviewed-by: Christian K=C3=B6nig --- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/a= md/amdgpu/amdgpu_device.c index a77000c2e0bb..f2c4f6996c23 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -1673,9 +1673,9 @@ int amdgpu_device_resize_fb_bar(struct amdgpu_device = *adev) int rbar_size =3D pci_rebar_bytes_to_size(adev->gmc.real_vram_size); struct pci_bus *root; struct resource *res; + int max_size, r; unsigned int i; u16 cmd; - int r; =20 if (!IS_ENABLED(CONFIG_PHYS_ADDR_T_64BIT)) return 0; @@ -1721,8 +1721,10 @@ int amdgpu_device_resize_fb_bar(struct amdgpu_device= *adev) return 0; =20 /* Limit the BAR size to what is available */ - rbar_size =3D min(fls(pci_rebar_get_possible_sizes(adev->pdev, 0)) - 1, - rbar_size); + max_size =3D pci_rebar_get_max_size(adev->pdev, 0); + if (max_size < 0) + return 0; + rbar_size =3D min(max_size, rbar_size); =20 /* Disable memory decoding while we change the BAR addresses and size */ pci_read_config_word(adev->pdev, PCI_COMMAND, &cmd); --=20 2.39.5