Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3653219pxb; Mon, 24 Jan 2022 14:31:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJyzm2XBPcF7jzFsLNjVkHz8/WZiqLfpf8NM08N4y7aKhzdY0/u8eB88HWCcJ9ZLjAlgOw2k X-Received: by 2002:a17:902:7208:b0:14a:9df9:19a5 with SMTP id ba8-20020a170902720800b0014a9df919a5mr15787224plb.167.1643063462599; Mon, 24 Jan 2022 14:31:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643063462; cv=none; d=google.com; s=arc-20160816; b=zuzr6hOGsNhXegk+qEmQJ2X6N7nlsqHBOSthE9mCGdkKmDuTwfQGhqPsBA3pgt3L00 zEI3qXweun46h3/tD7n2CdaaLU1j6BslDIc8sSxh8jiUbCi6jODd/65EYFCYFPLhiEDb wyZEzfw32ljuDo7uAvNLMgVfUxk+ROSuJDgpKxZsQR0P5K1K+ytv1LL9qSsTwW7s3jSI NEXIx1zZjnF+xd/uFopo1c0OlDGJKUl4iSztFQ/eOTrg1rFSKNBlwqOKeMpMp4K+ZCYD nU/CXXInQ2yPpRuDo5Bb0fLCmp7klJ6EitszH3lKQyjT2v+gNd47GRrt8yCnMgii2TVm x5nw== 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=umMKoXDbuximLCim4AHF5ZV7rAF0eGyrkdj7udH7zsV9j5Ol/MafwGVi4MPfW9Xpuy zGCvkDSVufbsnMqqvscJK7Sga9fT/+U2zcTFS8R3AVCyqZHXv4VCaFq0+3OmcXIsF8sg I7pKg345o9EPEOg6GOQbos1jO84HB8SxjcHcFmBeo9jRQNkl7rqgzIk33DBgh/+Dwono VNdn++GGOvLf4m4PrSn895mo4Lfg0A5/BPQXISokva419cYqBWwgGfChMVQjtZDFbajE SYbswBsDaNIGEXWOc4MehtKkq8hJlExC9KTnSFTy5W59XQb15SNN/mQymrArOJBZWVlE AwNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XgvY4r24; 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 p19si13628497plq.558.2022.01.24.14.30.50; Mon, 24 Jan 2022 14:31:02 -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=XgvY4r24; 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 S1584604AbiAXWV3 (ORCPT + 99 others); Mon, 24 Jan 2022 17:21:29 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:40736 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1449381AbiAXV2U (ORCPT ); Mon, 24 Jan 2022 16:28:20 -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 29B3AB811FB; Mon, 24 Jan 2022 21:28:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5509BC340E4; Mon, 24 Jan 2022 21:28:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643059694; bh=Evjdvma7DpXHpludweJifTmE2JUT8KCAToNGDJW3x2k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XgvY4r24ag3Y72DPmVku1cg4JeRGEOFz2mc20JSx0vKdGGM+Vj4fkxX5yCiI+h3Sw oUTuBRrGH3RmgxtQ47WoSMPlhXiJSScODSsDpbHzRs7xF+YoyP4FLk0OsinHl+fl2R 1q1mZ8z0XX9bgjbSJ2M4Dssam+ge1FDvCn6I+3wQ= 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.16 0703/1039] drm/amdgpu: fixup bad vram size on gmc v8 Date: Mon, 24 Jan 2022 19:41:32 +0100 Message-Id: <20220124184148.962296625@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@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