Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp2778993ybg; Mon, 28 Oct 2019 02:11:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqzrrhepigmPAoeBu8oDmtNvLJNqz57xv+2bLXZTuPKjMWGQXc6l+tRLSutvUid+hVFtQDk0 X-Received: by 2002:a17:906:2d68:: with SMTP id f8mr15466188eji.71.1572253908861; Mon, 28 Oct 2019 02:11:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572253908; cv=none; d=google.com; s=arc-20160816; b=EvmQpG5bv2xpzMLZgfPWAIkK9opzFberPKKk0ydJiL6A7sxymPFRL/7GApPCF6dayR p59lsvomjXgRoGUQMf36SPRdBY64ZulF8tJmiPfY3wdANZs3yTy8ZTioJYR75ZHdg71H 2VxD9i70m4FGW+nEDMj9kC4x/r1qbe2KiAgdP5TXpyFNLFQ5DrP86Rsvg803Y2QgXoq9 i0tZYC2t7k+FglXPkWUHiimuA8PaO4P61npp1QcySGyEZVfOdeXiUoHuFnkpfJkmXJTZ y68YinLO/4g6RZyX3dUNClPFBMI+BEhg2rANei1KGxp0+ZbPCx+pvc10sjfAj34G3J06 44gg== 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=jqqPsS/I/xfpf2xQLgGLUD0CqjZizBnnDIWRaYG2XZU=; b=iAmj/p2qCOINxLiubkZcOGL7jSIiKzqf5VwwPrxedlDsVIqhd31N7sj8oW8Pn1i6Ve C2qJcvK5j75R/Uj84xDxj62nkjipqdvHvSBCxlfXmrrAgOLi4M/YFhJqeg1gfXuAhlI1 KsmZGPsrXhss91psaSAG6fdJ+quzz6M15dU98bc9scse6Zw7WrGmgHorKzPQanTuigK4 6cnQtP6gbDJ4H0ymX6/7NhLvbgHC3mMd1UV1lQqVCfZduw7MT/lHAMLLEY6/l3WR5kF0 YJwahLk1Q4T0queakmSII8LRZnydREdvG1ZnOcSn5KvVak6NyUcMvRajssMte4nCmbtF 61xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=eXGd61xJ; 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 s35si2771879edd.261.2019.10.28.02.11.25; Mon, 28 Oct 2019 02:11:48 -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=eXGd61xJ; 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 S1732293AbfJ0VXJ (ORCPT + 99 others); Sun, 27 Oct 2019 17:23:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:44252 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731618AbfJ0VXH (ORCPT ); Sun, 27 Oct 2019 17:23:07 -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 995C1205C9; Sun, 27 Oct 2019 21:23:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572211386; bh=2K+kbrC0pT7NeYLIPxFN+7ukgau/pSNVnR6/Ps6OhsQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eXGd61xJjXv9goeFIqUj9LMfPQA1fb+cSkkndbKlMyih5myB+plF26TjCXwHYQoM4 pLa1+v1CsUp7+iHdT3Jj8JG6w2Yvn47cLDS2XJYCr9tro3MCvtgcY6MexNEYOaS6qX LF37qwNSpQgcYqRc0F5lHWg9G7QmFtwdjjm3ieFo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, James Zhu , =?UTF-8?q?Christian=20K=C3=B6nig?= , Alex Deucher Subject: [PATCH 5.3 131/197] drm/amdgpu/vce: fix allocation size in enc ring test Date: Sun, 27 Oct 2019 22:00:49 +0100 Message-Id: <20191027203358.794097652@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 ee027828c40faa92a7ef4c2b0641bbb3f4be95d3 upstream. We need to allocate a large enough buffer for the feedback buffer, otherwise the IB test can overwrite other memory. Reviewed-by: James Zhu Acked-by: Christian König Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 20 +++++++++++++++----- drivers/gpu/drm/amd/amdgpu/amdgpu_vce.h | 1 + 2 files changed, 16 insertions(+), 5 deletions(-) --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c @@ -429,13 +429,14 @@ void amdgpu_vce_free_handles(struct amdg * Open up a stream for HW test */ int amdgpu_vce_get_create_msg(struct amdgpu_ring *ring, uint32_t handle, + struct amdgpu_bo *bo, struct dma_fence **fence) { const unsigned ib_size_dw = 1024; 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); @@ -444,7 +445,7 @@ int amdgpu_vce_get_create_msg(struct amd ib = &job->ibs[0]; - dummy = ib->gpu_addr + 1024; + addr = amdgpu_bo_gpu_offset(bo); /* stitch together an VCE create msg */ ib->length_dw = 0; @@ -476,8 +477,8 @@ int amdgpu_vce_get_create_msg(struct amd ib->ptr[ib->length_dw++] = 0x00000014; /* len */ ib->ptr[ib->length_dw++] = 0x05000005; /* feedback buffer */ - 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++] = 0x00000001; for (i = ib->length_dw; i < ib_size_dw; ++i) @@ -1110,13 +1111,20 @@ int amdgpu_vce_ring_test_ring(struct amd int amdgpu_vce_ring_test_ib(struct amdgpu_ring *ring, long timeout) { struct dma_fence *fence = NULL; + struct amdgpu_bo *bo = NULL; long r; /* skip vce ring1/2 ib test for now, since it's not reliable */ if (ring != &ring->adev->vce.ring[0]) return 0; - r = amdgpu_vce_get_create_msg(ring, 1, NULL); + r = amdgpu_bo_create_reserved(ring->adev, 512, PAGE_SIZE, + AMDGPU_GEM_DOMAIN_VRAM, + &bo, NULL, NULL); + if (r) + return r; + + r = amdgpu_vce_get_create_msg(ring, 1, bo, NULL); if (r) goto error; @@ -1132,5 +1140,7 @@ int amdgpu_vce_ring_test_ib(struct amdgp error: dma_fence_put(fence); + amdgpu_bo_unreserve(bo); + amdgpu_bo_unref(&bo); return r; } --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.h @@ -59,6 +59,7 @@ int amdgpu_vce_entity_init(struct amdgpu int amdgpu_vce_suspend(struct amdgpu_device *adev); int amdgpu_vce_resume(struct amdgpu_device *adev); int amdgpu_vce_get_create_msg(struct amdgpu_ring *ring, uint32_t handle, + struct amdgpu_bo *bo, struct dma_fence **fence); int amdgpu_vce_get_destroy_msg(struct amdgpu_ring *ring, uint32_t handle, bool direct, struct dma_fence **fence);