Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp693474ybg; Mon, 1 Jun 2020 11:51:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSS3WPKf57WZNcZy7zkFP1rwlfBMNCVOTrfjDNcQMeXP3TyrDLG07fuI21CfB4MMGbWEPF X-Received: by 2002:aa7:c908:: with SMTP id b8mr5699600edt.76.1591037500700; Mon, 01 Jun 2020 11:51:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591037500; cv=none; d=google.com; s=arc-20160816; b=FeN6ciNdpFZXfsDxNThYYnmaTHqc4lBz8BOYD7m/uCuLlaP5nTMvhj6PQfS3+o5C39 pTLgEab1M1qtqfl9dwRrd6ore2o2Jsu8RDiuJe0naWTXQmWPaOufW/tyoWv4tnce6/Yq VnHGiBvMkFth4nLYBAMKqPjFDCyHd0ru5bGugFxGKbPgpBQHWBBgFqZVfZcKnyknzEzH gimBZxCH4z5wwn+1QAF8N9Z9Er/XmCJuzOcjPCbBIvldKkcR4/SAIMufCn+EwE6vx3VV HgFatEprKt/O7lEp9sYITf+Za4M5e1noAKyXUsreHAILDvy18w0d6I14x4OH1NRyk+A8 6+8Q== 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=8WgbpyEKEQhF/G+woPKAk0HPhB1Rzz2GGCg94ZooSmU=; b=n8r1unIIlEe4d5nZQCr6KgFbLZKOTYc7DuMLt7Jme+2iLL6+Kku0AngtqUHk7qPKSt f6UO8dS4LSwC39wt/4VnuftnFfxJoDF+e6xpJsFupYcxdCxLMaWpyGPfU+RIvIGrF6yB qltBWElt73JnKB4pZ4Qhyfn+Wj3qnZrbMoaAYtDDKXCoEKw3bey/om4B5cx/S/FfYb/P vAlSouhpdoyMcMgMF2Wlb50RV1UbenoCXptb5rr/x5FQIDezSRdSNDCwuQxxoTZIJ9Xi kzU/g91/hmPS9eu+A0Ltrq6hjd33k6ruz58M9lsBwpbRFv63N2gd8XONmb+MZj4ZwfJo zSwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=p8Smh4R2; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p20si198624ejj.553.2020.06.01.11.51.17; Mon, 01 Jun 2020 11:51:40 -0700 (PDT) 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=@kernel.org header.s=default header.b=p8Smh4R2; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730690AbgFASIK (ORCPT + 99 others); Mon, 1 Jun 2020 14:08:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:53734 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730623AbgFASHq (ORCPT ); Mon, 1 Jun 2020 14:07:46 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 10EC6206E2; Mon, 1 Jun 2020 18:07:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591034865; bh=iGPnBlo8kyfDPRdtZjoXDIN1J6IGdWFa/3J4cMiOiuY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p8Smh4R2ykpg/yIFanTic299tQ5dtUG7WFJnxXkM1yUxQBtq4jzMUpu3iajYUv639 jvJk1DCjhMgQ+1VOVUnMIqU6RG1Hw/qaobTdNRSvvmtC2WiEluMhkJ6ST6Vv9Ra4rs LUMYLiJL7/yTrKQgZaLpKy6wyKL2BY7GGuAdjOUs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Felix Kuehling , Alex Sierra , =?UTF-8?q?Christian=20K=C3=B6nig?= , Alex Deucher , Sasha Levin Subject: [PATCH 5.4 046/142] drm/amdgpu: Use GEM obj reference for KFD BOs Date: Mon, 1 Jun 2020 19:53:24 +0200 Message-Id: <20200601174042.639429498@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200601174037.904070960@linuxfoundation.org> References: <20200601174037.904070960@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: Felix Kuehling [ Upstream commit 39b3128d7ffd44e400e581e6f49e88cb42bef9a1 ] Releasing the AMDGPU BO ref directly leads to problems when BOs were exported as DMA bufs. Releasing the GEM reference makes sure that the AMDGPU/TTM BO is not freed too early. Also take a GEM reference when importing BOs from DMABufs to keep references to imported BOs balances properly. Signed-off-by: Felix Kuehling Tested-by: Alex Sierra Acked-by: Christian König Reviewed-by: Alex Sierra Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c index 6d021ecc8d59..edb561baf8b9 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c @@ -1288,7 +1288,7 @@ int amdgpu_amdkfd_gpuvm_free_memory_of_gpu( } /* Free the BO*/ - amdgpu_bo_unref(&mem->bo); + drm_gem_object_put_unlocked(&mem->bo->tbo.base); mutex_destroy(&mem->lock); kfree(mem); @@ -1630,7 +1630,8 @@ int amdgpu_amdkfd_gpuvm_import_dmabuf(struct kgd_dev *kgd, AMDGPU_VM_PAGE_READABLE | AMDGPU_VM_PAGE_WRITEABLE | AMDGPU_VM_PAGE_EXECUTABLE | AMDGPU_VM_MTYPE_NC; - (*mem)->bo = amdgpu_bo_ref(bo); + drm_gem_object_get(&bo->tbo.base); + (*mem)->bo = bo; (*mem)->va = va; (*mem)->domain = (bo->preferred_domains & AMDGPU_GEM_DOMAIN_VRAM) ? AMDGPU_GEM_DOMAIN_VRAM : AMDGPU_GEM_DOMAIN_GTT; -- 2.25.1