Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3579188pxb; Mon, 24 Jan 2022 12:41:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJxi2/ncHFUvfE0+m7XLGvkm2t0WfrZsuk9Fp3k4FZUQW0q5SC7udCqjiyUJ6uz0pf0+QCOz X-Received: by 2002:a17:903:31d5:b0:14b:53b7:cbd3 with SMTP id v21-20020a17090331d500b0014b53b7cbd3mr5664008ple.29.1643056898503; Mon, 24 Jan 2022 12:41:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643056898; cv=none; d=google.com; s=arc-20160816; b=Va9ZwY16XGeEVadouGK7Tjz/9W8LrkUzUru7Upx5/c8v6n72t6S+Y+4X38A5RqXgKf 8coBi1yVsNajnL5w03N4XfzKxJ6y0pNPfcXqTsNu3uVq62C6LXCf6+oHJjpcNmgMMmeq AwIk56O3pWn/ErVzbQQ3EjxG/+pEu/8Q+8YAoPcLAJFe/1DwXKxbNDqJ25BMFFOWOldT LWJL8CxWB+RGSNb0Sij9toTJGqAKzgJTc2XpbP7KonhWI89wBv+6uUJVNtEoJqfDBeJ9 gyTLn/1hULHLdA0/maMTuQxK/xxPo5RoC0uTf0KxNLGjuQ1EomoAUI++CksFyQNijByW AKrw== 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=j3Iv+RELUKMbWdXVRAu3WlBeVP2Iedm0UzVEMg3IK3c=; b=kKLrC1Mok3zDiyzol1HXxLb4RGhND9smfamQ+NRmGFJlamvMfu/BFXhXoeSnqTBhjo Dx1BGEb6GvqTPqR2zwP0xa5CBbTmX/+maX4CEIFScJ8bDns+Yl3kvbRoCkrMNAA8SSxa B3/LQtn8QvZebH0XtqmcZ9vUg9jUXSX6og+/AZbUvcZkJKldVSIygOdtOu7GKMw5zrRE EneGvam2rxs1TlYV4PEWa3O2BNRR/q/RWImzpSKASTXdgZPbi+IN3dAbZloS0XJoNCE4 uGcXbcnL+PXFgiQe/yRIlDqLMW4mpnxnJFIgMLL4olRBjtTJMrfQBNmh9MXcU4qeQ8Ve Xr5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aHx3LxLW; 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 d131si1345408pgc.595.2022.01.24.12.41.23; Mon, 24 Jan 2022 12:41:38 -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=aHx3LxLW; 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 S1358455AbiAXTzQ (ORCPT + 99 others); Mon, 24 Jan 2022 14:55:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353078AbiAXTlC (ORCPT ); Mon, 24 Jan 2022 14:41:02 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45DA1C07A971; Mon, 24 Jan 2022 11:20:31 -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 ams.source.kernel.org (Postfix) with ESMTPS id 0464BB8119D; Mon, 24 Jan 2022 19:20:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3C211C340E5; Mon, 24 Jan 2022 19:20:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643052028; bh=9KzqLyWNPtNjyKUaNk7Wi21QeiU1/TQnVwSNi8tWifw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aHx3LxLW0ZrOT4uJ6kDdkihNbFMjIdTjaX5WzzbnhFEmH7RcSVzziC9XDhM33yTM0 aRJtrAMrhG9z1i74ZeWpvGcM3wIhfxLzR0XCZ7FHgzOnbm5W63q5e4gLjzAsazdJPP EsyYdC02cE9QpaMrbuohc2m1G6pun/7LAfrsd9MM= 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 4.19 164/239] drm/amdgpu: fixup bad vram size on gmc v8 Date: Mon, 24 Jan 2022 19:43:22 +0100 Message-Id: <20220124183948.311273742@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183943.102762895@linuxfoundation.org> References: <20220124183943.102762895@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 1a744f964b301..358004a4650b6 100644 --- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c @@ -520,10 +520,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 */ @@ -567,8 +567,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