Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp2785415ybg; Mon, 28 Oct 2019 02:19:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqzKKYZmtP4zrvFUxS+I/JVVLUeULwYDPHWSZUAYewh2Y+NDX2GIXb+R+44Z9IX9QWtgmDwu X-Received: by 2002:a17:906:b310:: with SMTP id n16mr13850136ejz.213.1572254362901; Mon, 28 Oct 2019 02:19:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572254362; cv=none; d=google.com; s=arc-20160816; b=Ik5XkFWBm4DSg8DqRuYuKInCwsD4wLGLuqe+C9mieOpCmwhEdxSHalNNSE3fUKMePG ApUSOT1kw35b09qeN/RXWI4qFy0n0uZxg94Fu32ucgnmP0P7Wk35CnOYJGUlUW4sD72D gyxvxypPdAsLyoliB4mxBu/Un0yuvizPBppwCXG6DUM4x08ji4MyNJ4QECVcDei1ZWb8 HekrOnZamMRwAzEGKEOWPqW52NAu9q8n2xzmxqatp72RiBNPzDtbiuBCilxgN+2fVyPF VQGjRbAh1ksMM3BZvEwnPgwOaQckz9uPGqEzEMxEcj/YIFoCcr9ySnG06UlYJ6K+Y2kC cORg== 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=2/GfsIQli862BZZIBnA5VDXJc9XhD+oeDpzFjRTLViM=; b=vyaCj37LwOo/sM9zoIp5WSrNEQ7FblaTlufWnALBnSqQ2eD6GewqOCzBMkHq4coWPp YAf2dD3cSqux1APdtWC2lehpwARhfjRw/tZeBdlUPab3FV99f+VBBLHtC7b054Tj75wl iioop/Iofcf+XURzqy9mO7tGv1izcyJVlTuF3W75Fhk+QYzNWKXoH6YrBWtJVljKyKXe oRTZwn8dcGz382rRFg6ESkoeeWasaDJEHV1dyG609PRLIQikP/PIedOHnELHGVDc/jlP sJMVpqh74+MyBHW7AZRoPh6xIAANLns6mGFqnpi95VH1ucq8dtfhytegZesI0IjOgQnX qJig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1o99OWxo; 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 um11si2876275ejb.263.2019.10.28.02.18.58; Mon, 28 Oct 2019 02:19:22 -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=1o99OWxo; 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 S1732357AbfJ0VX3 (ORCPT + 99 others); Sun, 27 Oct 2019 17:23:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:44624 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731704AbfJ0VX1 (ORCPT ); Sun, 27 Oct 2019 17:23:27 -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 7BE67208C0; Sun, 27 Oct 2019 21:23:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572211406; bh=uNhMYFcm2xnYvgOnMOPZE1j3UgoZUNQObkqsayaq5xY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1o99OWxoDepjSEjf8udQGXzgNXX1OEpgOinGcAtLCe5xTLbGsTRYBg2Nlndu5srCr Ir0L+OVmbaKRzIqUvxiiNV5SY3tpt+05BZH7K7eNwh3ViQTxdsS5yZ2sEVwFkJCGbu /LPIzsAV8gmU3EEHpcB20f6Hx5zaWWwLhaq79Krk= 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 133/197] drm/amdgpu/uvd6: fix allocation size in enc ring test (v2) Date: Sun, 27 Oct 2019 22:00:51 +0100 Message-Id: <20191027203358.900154264@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 ce584a8e2885c7b59dfacba42db39761243cacb2 upstream. We need to allocate a large enough buffer for the session info, otherwise the IB test can overwrite other memory. v2: - 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/uvd_v6_0.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) --- a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c +++ b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c @@ -206,13 +206,14 @@ static int uvd_v6_0_enc_ring_test_ring(s * Open up a stream for HW test */ static int uvd_v6_0_enc_get_create_msg(struct amdgpu_ring *ring, uint32_t handle, + 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); @@ -220,15 +221,15 @@ static int uvd_v6_0_enc_get_create_msg(s 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++] = 0x00010000; - 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++] = 0x00000014; ib->ptr[ib->length_dw++] = 0x00000002; /* task info */ @@ -268,13 +269,14 @@ err: */ static int uvd_v6_0_enc_get_destroy_msg(struct amdgpu_ring *ring, uint32_t handle, + 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); @@ -282,15 +284,15 @@ static int uvd_v6_0_enc_get_destroy_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++] = 0x00010000; - 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++] = 0x00000014; ib->ptr[ib->length_dw++] = 0x00000002; /* task info */ @@ -327,13 +329,20 @@ err: static int uvd_v6_0_enc_ring_test_ib(struct amdgpu_ring *ring, long timeout) { struct dma_fence *fence = NULL; + struct amdgpu_bo *bo = NULL; long r; - r = uvd_v6_0_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 = uvd_v6_0_enc_get_create_msg(ring, 1, bo, NULL); if (r) goto error; - r = uvd_v6_0_enc_get_destroy_msg(ring, 1, &fence); + r = uvd_v6_0_enc_get_destroy_msg(ring, 1, bo, &fence); if (r) goto error; @@ -345,6 +354,8 @@ static int uvd_v6_0_enc_ring_test_ib(str error: dma_fence_put(fence); + amdgpu_bo_unreserve(bo); + amdgpu_bo_unref(&bo); return r; }