Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp2253229ybg; Sun, 27 Oct 2019 14:27:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqyZd3q3RZBwNG0/xdlEltRcpLSTxZ2EPOsx7/GzELJpmdzOyhTrZJFbl7f9DRUbxhJzj+FC X-Received: by 2002:a17:906:e57:: with SMTP id q23mr13720698eji.303.1572211652923; Sun, 27 Oct 2019 14:27:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572211652; cv=none; d=google.com; s=arc-20160816; b=zV1Wd4Mq/q9umCZ+zp37Mc1K0i/7JF2iR2QL+3oNF+va3lvNghI2uMqwY58kbooqoT JO5cb1eHQJIclstJoUS+2XiQXp4nEzF/9yWNGBE87+mFsQ//ofG+HvRys+we6s8W9Wfz Q9g9fszZNdRFXGAmIGAA4PEAxidi2xrOu2stUs+DhSjiH2AIAqXsn08aX0rHFNU30A7D eEVEx3abMmAgXFNKsRRn75cr9BSAkPLgH9VFTAKRKxG1N9fCZsrX2GcxPatHsB631QHj QXuAWPrdL4/az9qrgW9v+M0aQ9BWGG5DVtr766wFeNukBlIuw4YdE41Xis6He2oRx5U9 25Dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=elG2CTRDMydbOHomADEdKobA+ly//MATYzVlrHrMWp8=; b=VKp6joqBoJZgmcLSjxOYAcQnpsJ3nMbSIR68s0GqGscwvk/+8OFXQrOaHTqfqZCjIJ 7RM88nIUqXya2cN3ZgAJiACoYH2Yz7ESblrtIPkKVjNH1972BGTvNFA5mdN0Xeap/BRL Cj2t0KbOUxpKGr91DnL5KrHExKF4kVQ0LHhrIeDf7BRv+DtvMId+nquNKolZbYOXg+Dp Q1Fh1JX6wh8KmoIZuskazxFYas5KXPmZDai2AMclqgIFYzmRwtZPSp/tEEaySvMt+7bP MBGNhil1wU4rBlkWtJi01lnNn51Jk7MjBklP4K+xxq3jXFA+Yrzl5DWUHzEWX7UsHaw3 DYYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0T7+Cz2D; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c36si6390673ede.323.2019.10.27.14.27.09; Sun, 27 Oct 2019 14:27:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0T7+Cz2D; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731911AbfJ0VZl (ORCPT + 99 others); Sun, 27 Oct 2019 17:25:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:47504 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732779AbfJ0VZi (ORCPT ); Sun, 27 Oct 2019 17:25:38 -0400 Received: from localhost (100.50.158.77.rev.sfr.net [77.158.50.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B347421850; Sun, 27 Oct 2019 21:25:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572211537; bh=eRXpJNeQCyyCD23nmN3XQx5ovGSGyho2lmGLOeVxShs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0T7+Cz2DlLAg90wg2cdVIprHqVdSRtTOjubwZlP5ObUqcjMmJftgEzCSlVeZJBCFI 6y5c1PIdLOkKu/QxGOnq+oo/Z3/TWJ+2TR4vy2//47C0ovnQzSkg3PGMg+3u9QW2Sc ju9sUNpwFIarZZkU+t3o5X5QQgoEHM+dgqg8s3H0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Christian=20K=C3=B6nig?= , James Zhu , Alex Deucher Subject: [PATCH 5.3 132/197] drm/amdgpu/vcn: fix allocation size in enc ring test Date: Sun, 27 Oct 2019 22:00:50 +0100 Message-Id: <20191027203358.845695967@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191027203351.684916567@linuxfoundation.org> References: <20191027203351.684916567@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alex Deucher commit c81fffc2c9450750dd7a54a36a788a860ab0425d upstream. We need to allocate a large enough buffer for the session info, otherwise the IB test can overwrite other memory. - Session info is 128K according to mesa - Use the same session info for create and destroy Bug: https://bugzilla.kernel.org/show_bug.cgi?id=204241 Acked-by: Christian König Reviewed-by: James Zhu Tested-by: James Zhu Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 35 +++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 12 deletions(-) --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c @@ -517,13 +517,14 @@ int amdgpu_vcn_enc_ring_test_ring(struct } static int amdgpu_vcn_enc_get_create_msg(struct amdgpu_ring *ring, uint32_t handle, - struct dma_fence **fence) + struct amdgpu_bo *bo, + struct dma_fence **fence) { const unsigned ib_size_dw = 16; struct amdgpu_job *job; struct amdgpu_ib *ib; struct dma_fence *f = NULL; - uint64_t dummy; + uint64_t addr; int i, r; r = amdgpu_job_alloc_with_ib(ring->adev, ib_size_dw * 4, &job); @@ -531,14 +532,14 @@ static int amdgpu_vcn_enc_get_create_msg return r; ib = &job->ibs[0]; - dummy = ib->gpu_addr + 1024; + addr = amdgpu_bo_gpu_offset(bo); ib->length_dw = 0; ib->ptr[ib->length_dw++] = 0x00000018; ib->ptr[ib->length_dw++] = 0x00000001; /* session info */ ib->ptr[ib->length_dw++] = handle; - ib->ptr[ib->length_dw++] = upper_32_bits(dummy); - ib->ptr[ib->length_dw++] = dummy; + ib->ptr[ib->length_dw++] = upper_32_bits(addr); + ib->ptr[ib->length_dw++] = addr; ib->ptr[ib->length_dw++] = 0x0000000b; ib->ptr[ib->length_dw++] = 0x00000014; @@ -569,13 +570,14 @@ err: } static int amdgpu_vcn_enc_get_destroy_msg(struct amdgpu_ring *ring, uint32_t handle, - struct dma_fence **fence) + struct amdgpu_bo *bo, + struct dma_fence **fence) { const unsigned ib_size_dw = 16; struct amdgpu_job *job; struct amdgpu_ib *ib; struct dma_fence *f = NULL; - uint64_t dummy; + uint64_t addr; int i, r; r = amdgpu_job_alloc_with_ib(ring->adev, ib_size_dw * 4, &job); @@ -583,14 +585,14 @@ static int amdgpu_vcn_enc_get_destroy_ms return r; ib = &job->ibs[0]; - dummy = ib->gpu_addr + 1024; + addr = amdgpu_bo_gpu_offset(bo); ib->length_dw = 0; ib->ptr[ib->length_dw++] = 0x00000018; ib->ptr[ib->length_dw++] = 0x00000001; ib->ptr[ib->length_dw++] = handle; - ib->ptr[ib->length_dw++] = upper_32_bits(dummy); - ib->ptr[ib->length_dw++] = dummy; + ib->ptr[ib->length_dw++] = upper_32_bits(addr); + ib->ptr[ib->length_dw++] = addr; ib->ptr[ib->length_dw++] = 0x0000000b; ib->ptr[ib->length_dw++] = 0x00000014; @@ -623,13 +625,20 @@ err: int amdgpu_vcn_enc_ring_test_ib(struct amdgpu_ring *ring, long timeout) { struct dma_fence *fence = NULL; + struct amdgpu_bo *bo = NULL; long r; - r = amdgpu_vcn_enc_get_create_msg(ring, 1, NULL); + r = amdgpu_bo_create_reserved(ring->adev, 128 * 1024, PAGE_SIZE, + AMDGPU_GEM_DOMAIN_VRAM, + &bo, NULL, NULL); + if (r) + return r; + + r = amdgpu_vcn_enc_get_create_msg(ring, 1, bo, NULL); if (r) goto error; - r = amdgpu_vcn_enc_get_destroy_msg(ring, 1, &fence); + r = amdgpu_vcn_enc_get_destroy_msg(ring, 1, bo, &fence); if (r) goto error; @@ -641,6 +650,8 @@ int amdgpu_vcn_enc_ring_test_ib(struct a error: dma_fence_put(fence); + amdgpu_bo_unreserve(bo); + amdgpu_bo_unref(&bo); return r; }