Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3674777pxb; Mon, 24 Jan 2022 15:04:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJx8/Zv+rePOoMCNxyQf+ItLGeU+xHq6NnsQw7UtNkeseXxWoyIXOoQBm6ANc8hJAPfIMd7p X-Received: by 2002:a17:90a:8c87:: with SMTP id b7mr465184pjo.179.1643065460972; Mon, 24 Jan 2022 15:04:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643065460; cv=none; d=google.com; s=arc-20160816; b=rNOmZ29LHtBfBz23I1SLslFOZf0W8V182rbefrpU/ZArbG9jsG34Xhle/C/PEnrUDh LRmfNcMFAReyTGr2LuTFQt7Hbw66APq0WQEqVLEx/0Zw4mttgum73PUvZ21f2aAhyA+I XPUeRoGSCQaBvVn5M+XLSVPDV2iOs/Mc4F6Bp2vUba3SAXiS++CYcOQEJqUCiQpYCG3k hA2cR0N0+mM/syXdh/N6qdf3IluOpn33hHQqD98MR7dz2rWwK1YbS9kGHoSrEiDB8Qm3 0yKRIQtz/Nwpnm7YsQ6LPkrsScOjMhcgMUqciJUwfVZ5vPfkOFhIvax8cQDC+MoXYyWE UreA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=IUDkltpMosYJm2ozICSVnugNxro2DzyvA/ZnHoS4J9c=; b=kKosois86yz1iytTLp8vuUmqcWideCCuPZ7ZdzmMyzJk975lHsa69p1uyH2vLQHpvY PakJ9dxSAVVhQdFOPd+BM2TkgTh5e21O9T7ZwyxukPPNWtlb7YUFl3tK/g1yxUPo7H4Y okmk99KPr1NGW2kfsRv4TAnEow0i/Kw7YaKSWvfTo2NPvJlPb5aWTcUTpm14j0/fstHq 02jGmHlfJpElkZmO3KSg1swr+vTpS+bT7JBueEKfnzzqZpD7VNIz/5VjBjJ/r5Xcuvob Lg04DJGWHAcqW7s02z8yOFDAQ2HMrVbTExCd5CbHMCkKlxCgixqvb5Q9rHhYGl4jhM2M Nf9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JX93oeIA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x207si2339868pfc.69.2022.01.24.15.04.09; Mon, 24 Jan 2022 15:04:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JX93oeIA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1841260AbiAXW6J (ORCPT + 99 others); Mon, 24 Jan 2022 17:58:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380508AbiAXV7X (ORCPT ); Mon, 24 Jan 2022 16:59:23 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CA32C0C091E; Mon, 24 Jan 2022 12:39:37 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8984861382; Mon, 24 Jan 2022 20:39:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A00BC340E5; Mon, 24 Jan 2022 20:39:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643056776; bh=Evjdvma7DpXHpludweJifTmE2JUT8KCAToNGDJW3x2k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JX93oeIA3KGi+MKJj1QbTUCRC6n0w4DMTy8fDeu1eBrKnX013jn7KDuvV1Cv5U0Ih OZKaf9pUACHm+/25cAaFQvYwvQD3RC1EaPkQUvfAG3BGY3jJXO6T6Rso3Vgxhry9vS b4wjRfphWCWSS/hypNYk2yEoHmfTGkTihHF2lgHs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zongmin Zhou , Alex Deucher , Sasha Levin Subject: [PATCH 5.15 596/846] drm/amdgpu: fixup bad vram size on gmc v8 Date: Mon, 24 Jan 2022 19:41:53 +0100 Message-Id: <20220124184121.596789227@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zongmin Zhou [ Upstream commit 11544d77e3974924c5a9c8a8320b996a3e9b2f8b ] Some boards(like RX550) seem to have garbage in the upper 16 bits of the vram size register. Check for this and clamp the size properly. Fixes boards reporting bogus amounts of vram. after add this patch,the maximum GPU VRAM size is 64GB, otherwise only 64GB vram size will be used. Signed-off-by: Zongmin Zhou Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c index 492ebed2915be..63b890f1e8afb 100644 --- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c @@ -515,10 +515,10 @@ static void gmc_v8_0_mc_program(struct amdgpu_device *adev) static int gmc_v8_0_mc_init(struct amdgpu_device *adev) { int r; + u32 tmp; adev->gmc.vram_width = amdgpu_atombios_get_vram_width(adev); if (!adev->gmc.vram_width) { - u32 tmp; int chansize, numchan; /* Get VRAM informations */ @@ -562,8 +562,15 @@ static int gmc_v8_0_mc_init(struct amdgpu_device *adev) adev->gmc.vram_width = numchan * chansize; } /* size in MB on si */ - adev->gmc.mc_vram_size = RREG32(mmCONFIG_MEMSIZE) * 1024ULL * 1024ULL; - adev->gmc.real_vram_size = RREG32(mmCONFIG_MEMSIZE) * 1024ULL * 1024ULL; + tmp = RREG32(mmCONFIG_MEMSIZE); + /* some boards may have garbage in the upper 16 bits */ + if (tmp & 0xffff0000) { + DRM_INFO("Probable bad vram size: 0x%08x\n", tmp); + if (tmp & 0xffff) + tmp &= 0xffff; + } + adev->gmc.mc_vram_size = tmp * 1024ULL * 1024ULL; + adev->gmc.real_vram_size = adev->gmc.mc_vram_size; if (!(adev->flags & AMD_IS_APU)) { r = amdgpu_device_resize_fb_bar(adev); -- 2.34.1