Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3389752pxb; Mon, 17 Jan 2022 19:23:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJz8snelaW0M/RN7D7Hx6n/IQMnDC4ErJJe4e11rjqXTRR5gh2Wvh9a99/3tB6M/D0Wm287o X-Received: by 2002:a05:6a00:1c5a:b0:4bf:31c9:ec04 with SMTP id s26-20020a056a001c5a00b004bf31c9ec04mr24087268pfw.81.1642476230514; Mon, 17 Jan 2022 19:23:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642476230; cv=none; d=google.com; s=arc-20160816; b=f9ko44zSKJ5ijzvJnYdVH4VjsHjwo7RFG2teEK/rtYm2GtT46bgD1YbVIJp8I9ExCG Uilgau4VVjM0oYaaJXbjsCx1+SNdEmLiuYJevwCRS2lKwbBVbODHFPqE3W7RbQBoPwam MzC5PJOVsywtTJgYe1qnMbc2zUw1PaHr6A4dhZYRtaI0Ssbjy85HeL3lwRzWadPmgSRo ejWt0fpLDknP89+EqYJu8Ib1pTYmBsqDGgYszGV2MSO2JupbhUa3WaW6xAeLZMTKBRDg FvwFxDFnbL92S9jdsjwPPhJigGH3nVcnpuYEuiKzh0qGcXxufaYdtL0vmLJxxnKceF3R GY9g== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=IUDkltpMosYJm2ozICSVnugNxro2DzyvA/ZnHoS4J9c=; b=k5wLPTadzJeVOsAhomrmKjn+nub9J9r+mg315WkxwXTjYPgLwCnLrvuEA/rIwXRKz+ KLiIadojNrrG2Nx+I4LYnoKkONA6gFgAiIlPUls8ex6WtrzlakRHxW5Kqfi9moCRI3da fDeQ1ZASaIZ2YKqgoEQ9gPqWqPc06WvEl6TL0s5asHrGIG+OsJm+tBmfRbNKBlos5fB9 cYaNfVLH1GzM9gHvw66KvTqrRG/Cs4uZ5aAO1KnI9XyDKz+DzcY7juf1WRSjby0wTCYj woJV+coakDJL7NBLTgLZoTHXLoOUtwiAGerFJuMHEzCB2p6ZJ6PRnS+9r1NmaDvisqtR /7Uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eerbGhrl; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h4si5906017plk.581.2022.01.17.19.23.39; Mon, 17 Jan 2022 19:23:50 -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=@kernel.org header.s=k20201202 header.b=eerbGhrl; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343920AbiARCdz (ORCPT + 99 others); Mon, 17 Jan 2022 21:33:55 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:42354 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344290AbiARC3k (ORCPT ); Mon, 17 Jan 2022 21:29:40 -0500 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 CD70AB8123A; Tue, 18 Jan 2022 02:29:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F189FC36AE3; Tue, 18 Jan 2022 02:29:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1642472977; bh=Evjdvma7DpXHpludweJifTmE2JUT8KCAToNGDJW3x2k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eerbGhrlNLP1/Tud2Kbz0yribI4ym6EHqKcbPOTVKvZmz8NCkLshL108ayIw1FxFh gbnvQwlmNATRb5IpfyKLQLeheRJUKRQlrst6QL7O1rafv/BOFjrJjX1nIbmtE5x21L /EW+Veb8Ogt7H6FIBKQv9/tK1QU75lEo2vr/dJ0IGckEjbJ1bVoXdc2FAoVVbufdFq nWlWmZa3cN5JUbWsshVtyBmTfyAb2d2wvpgtgNNlQbb0cNppSQ+dstoyI0jiLaqDPZ leOHpDXW6qUcrnJdGgr7Uzham9iOzf/mfktw/nvNyMGqPW0LGNizVdui2Dq1L24tZM zf09f3xmBT65Q== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Zongmin Zhou , Alex Deucher , Sasha Levin , christian.koenig@amd.com, Xinhui.Pan@amd.com, airlied@linux.ie, daniel@ffwll.ch, Felix.Kuehling@amd.com, evan.quan@amd.com, nirmoy.das@amd.com, andrey.grodzovsky@amd.com, Oak.Zeng@amd.com, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 5.16 186/217] drm/amdgpu: fixup bad vram size on gmc v8 Date: Mon, 17 Jan 2022 21:19:09 -0500 Message-Id: <20220118021940.1942199-186-sashal@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220118021940.1942199-1-sashal@kernel.org> References: <20220118021940.1942199-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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