Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752412AbdCOQJd (ORCPT ); Wed, 15 Mar 2017 12:09:33 -0400 Received: from mail-by2nam01on0073.outbound.protection.outlook.com ([104.47.34.73]:39384 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751286AbdCOQI3 (ORCPT ); Wed, 15 Mar 2017 12:08:29 -0400 From: "Deucher, Alexander" To: =?utf-8?B?J0NocmlzdGlhbiBLw7ZuaWcn?= , Ayyappa Ch CC: "linux-pci@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "amd-gfx@lists.freedesktop.org" , "platform-driver-x86@vger.kernel.org" , "helgaas@kernel.org" , "dri-devel@lists.freedesktop.org" Subject: RE: [PATCH 4/4] drm/amdgpu: resize VRAM BAR for CPU access Thread-Topic: [PATCH 4/4] drm/amdgpu: resize VRAM BAR for CPU access Thread-Index: AQHSm/cxITUB9HGOIUOPEe0tOTAJXKGVgjsAgAAD2ICAAI6VoA== Date: Wed, 15 Mar 2017 16:08:27 +0000 Message-ID: References: <1489408896-25039-1-git-send-email-deathsimple@vodafone.de> <1489408896-25039-5-git-send-email-deathsimple@vodafone.de> <6fac05e4-26ae-e959-9af6-cb68a04a1110@vodafone.de> In-Reply-To: <6fac05e4-26ae-e959-9af6-cb68a04a1110@vodafone.de> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: vodafone.de; dkim=none (message not signed) header.d=none;vodafone.de; dmarc=none action=none header.from=amd.com; x-originating-ip: [165.204.55.251] x-ms-office365-filtering-correlation-id: 97cdb5c0-cf15-40f0-9837-08d46bbd841b x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(48565401081);SRVR:CY4PR12MB1654; x-microsoft-exchange-diagnostics: 1;CY4PR12MB1654;7:e88xc7YRipTppOJiCRBdkHxA0zrwB81ODKENl4vh8xcv+dMYmZAHJ+dAo7qtGWjAQ2sTW7jQauOoY7UY+d2QfAqMh6uphDwYGOiGJTvO6jGXES/1V2KL0y9h6aeWDd8K1qPizWZPcwPAC/HhXx5Uuu0KyUyGY9gVvhvlvw3sDJDUe6X3HsN1oK8G2j2EDaFi1LAa7Zf8yBh/LGAvFT77utn0f92dx8fQuDTv3K2Wg9mPnqUCZGDOGek3q6SS6ARvFgAEk6/UA1sAiMcRIwbhdCtFc6DxgOcQQ5FekJC7AB24V94wT1nAKJIPqGZvqpboCi1CFnHkO4oDjMxGzergig==;20:wZQOIttJjbcmE65OWkHHCJVjVp/5Rto7+yATVbICqJ8T/uQb4SidVcygpSYr2BVSoK4IP4rp4Mh+u6iEyJzrQ8+/2TID7k1ZLPQcuUKDfVyqy5HDhZkeKnTjtwXUoJGlxyGlv+tEuxZBMGp+jQmgH9is00cV89M6PkaalL/xoy8FHxHpPqvMMGcTrx6jvze81AD6U6g8ydZ3j0vjYnk0vQaq4ZIpI+/uKbBXZ2WT5wd7bwfsHBeWqGE4BigdPW+X x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(9452136761055)(767451399110)(217544274631240); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026)(6041248)(20161123560025)(20161123562025)(20161123564025)(20161123558025)(20161123555025)(6072148);SRVR:CY4PR12MB1654;BCL:0;PCL:0;RULEID:;SRVR:CY4PR12MB1654; x-forefront-prvs: 02475B2A01 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(6009001)(39450400003)(39840400002)(39410400002)(39860400002)(39850400002)(24454002)(13464003)(377454003)(122556002)(6116002)(86362001)(305945005)(54356999)(93886004)(50986999)(77096006)(229853002)(189998001)(5660300001)(53546007)(3280700002)(7736002)(6246003)(38730400002)(8936002)(76176999)(4326008)(102836003)(3846002)(53936002)(33656002)(25786008)(66066001)(2950100002)(39060400002)(2900100001)(6436002)(55016002)(2906002)(8676002)(7696004)(99286003)(54906002)(74316002)(81166006)(6306002)(9686003)(6506006)(3660700001)(217873001);DIR:OUT;SFP:1101;SCL:1;SRVR:CY4PR12MB1654;H:CY4PR12MB1653.namprd12.prod.outlook.com;FPR:;SPF:None;MLV:ovrnspm;PTR:InfoNoRecords;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Mar 2017 16:08:27.3599 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1654 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id v2FGCShG003149 Content-Length: 6625 Lines: 169 > -----Original Message----- > From: amd-gfx [mailto:amd-gfx-bounces@lists.freedesktop.org] On Behalf > Of Christian König > Sent: Wednesday, March 15, 2017 3:38 AM > To: Ayyappa Ch > Cc: linux-pci@vger.kernel.org; linux-kernel@vger.kernel.org; amd- > gfx@lists.freedesktop.org; platform-driver-x86@vger.kernel.org; > helgaas@kernel.org; dri-devel@lists.freedesktop.org > Subject: Re: [PATCH 4/4] drm/amdgpu: resize VRAM BAR for CPU access > > Carizzo is an APU and resizing BARs isn't needed nor supported there. > The CPU can access the full stolen VRAM directly on that hardware. > > As far as I know ASICs with support for this are Tonga, Fiji and all > Polaris variants. I think resizable BARs are supported as far back as evergreen or NI. Alex > > Christian. > > Am 15.03.2017 um 08:23 schrieb Ayyappa Ch: > > Is it possible on Carrizo asics? Or only supports on newer asics? > > > > On Mon, Mar 13, 2017 at 6:11 PM, Christian König > > wrote: > >> From: Christian König > >> > >> Try to resize BAR0 to let CPU access all of VRAM. > >> > >> Signed-off-by: Christian König > >> --- > >> drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + > >> drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 29 > +++++++++++++++++++++++++++++ > >> drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c | 8 +++++--- > >> drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 8 +++++--- > >> 4 files changed, 40 insertions(+), 6 deletions(-) > >> > >> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h > b/drivers/gpu/drm/amd/amdgpu/amdgpu.h > >> index 3b81ded..905ded9 100644 > >> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h > >> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h > >> @@ -1719,6 +1719,7 @@ uint64_t amdgpu_ttm_tt_pte_flags(struct > amdgpu_device *adev, struct ttm_tt *ttm, > >> struct ttm_mem_reg *mem); > >> void amdgpu_vram_location(struct amdgpu_device *adev, struct > amdgpu_mc *mc, u64 base); > >> void amdgpu_gtt_location(struct amdgpu_device *adev, struct > amdgpu_mc *mc); > >> +void amdgpu_resize_bar0(struct amdgpu_device *adev); > >> void amdgpu_ttm_set_active_vram_size(struct amdgpu_device *adev, > u64 size); > >> int amdgpu_ttm_init(struct amdgpu_device *adev); > >> void amdgpu_ttm_fini(struct amdgpu_device *adev); > >> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > >> index 118f4e6..92955fe 100644 > >> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > >> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > >> @@ -692,6 +692,35 @@ void amdgpu_gtt_location(struct amdgpu_device > *adev, struct amdgpu_mc *mc) > >> mc->gtt_size >> 20, mc->gtt_start, mc->gtt_end); > >> } > >> > >> +/** > >> + * amdgpu_resize_bar0 - try to resize BAR0 > >> + * > >> + * @adev: amdgpu_device pointer > >> + * > >> + * Try to resize BAR0 to make all VRAM CPU accessible. > >> + */ > >> +void amdgpu_resize_bar0(struct amdgpu_device *adev) > >> +{ > >> + u32 size = max(ilog2(adev->mc.real_vram_size - 1) + 1, 20) - 20; > >> + int r; > >> + > >> + r = pci_resize_resource(adev->pdev, 0, size); > >> + > >> + if (r == -ENOTSUPP) { > >> + /* The hardware don't support the extension. */ > >> + return; > >> + > >> + } else if (r == -ENOSPC) { > >> + DRM_INFO("Not enoigh PCI address space for a large BAR."); > >> + } else if (r) { > >> + DRM_ERROR("Problem resizing BAR0 (%d).", r); > >> + } > >> + > >> + /* Reinit the doorbell mapping, it is most likely moved as well */ > >> + amdgpu_doorbell_fini(adev); > >> + BUG_ON(amdgpu_doorbell_init(adev)); > >> +} > >> + > >> /* > >> * GPU helpers function. > >> */ > >> diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c > b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c > >> index dc9b6d6..36a7aa5 100644 > >> --- a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c > >> +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c > >> @@ -367,13 +367,15 @@ static int gmc_v7_0_mc_init(struct > amdgpu_device *adev) > >> break; > >> } > >> adev->mc.vram_width = numchan * chansize; > >> - /* Could aper size report 0 ? */ > >> - adev->mc.aper_base = pci_resource_start(adev->pdev, 0); > >> - adev->mc.aper_size = pci_resource_len(adev->pdev, 0); > >> /* size in MB on si */ > >> adev->mc.mc_vram_size = RREG32(mmCONFIG_MEMSIZE) * > 1024ULL * 1024ULL; > >> adev->mc.real_vram_size = RREG32(mmCONFIG_MEMSIZE) * > 1024ULL * 1024ULL; > >> > >> + if (!(adev->flags & AMD_IS_APU)) > >> + amdgpu_resize_bar0(adev); > >> + adev->mc.aper_base = pci_resource_start(adev->pdev, 0); > >> + adev->mc.aper_size = pci_resource_len(adev->pdev, 0); > >> + > >> #ifdef CONFIG_X86_64 > >> if (adev->flags & AMD_IS_APU) { > >> adev->mc.aper_base = ((u64)RREG32(mmMC_VM_FB_OFFSET)) > << 22; > >> diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c > b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c > >> index c087b00..7761ad3 100644 > >> --- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c > >> +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c > >> @@ -459,13 +459,15 @@ static int gmc_v8_0_mc_init(struct > amdgpu_device *adev) > >> break; > >> } > >> adev->mc.vram_width = numchan * chansize; > >> - /* Could aper size report 0 ? */ > >> - adev->mc.aper_base = pci_resource_start(adev->pdev, 0); > >> - adev->mc.aper_size = pci_resource_len(adev->pdev, 0); > >> /* size in MB on si */ > >> adev->mc.mc_vram_size = RREG32(mmCONFIG_MEMSIZE) * > 1024ULL * 1024ULL; > >> adev->mc.real_vram_size = RREG32(mmCONFIG_MEMSIZE) * > 1024ULL * 1024ULL; > >> > >> + if (!(adev->flags & AMD_IS_APU)) > >> + amdgpu_resize_bar0(adev); > >> + adev->mc.aper_base = pci_resource_start(adev->pdev, 0); > >> + adev->mc.aper_size = pci_resource_len(adev->pdev, 0); > >> + > >> #ifdef CONFIG_X86_64 > >> if (adev->flags & AMD_IS_APU) { > >> adev->mc.aper_base = ((u64)RREG32(mmMC_VM_FB_OFFSET)) > << 22; > >> -- > >> 2.7.4 > >> > >> _______________________________________________ > >> dri-devel mailing list > >> dri-devel@lists.freedesktop.org > >> https://lists.freedesktop.org/mailman/listinfo/dri-devel > > > _______________________________________________ > amd-gfx mailing list > amd-gfx@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/amd-gfx