Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1604019ybl; Sat, 25 Jan 2020 04:27:41 -0800 (PST) X-Google-Smtp-Source: APXvYqzKhxdYHxhUJ9acuGWw9TpAssHfw26yL91+LXknAFMUHBEDBuor2d1f0epyGcbKmugJJuG8 X-Received: by 2002:aca:d507:: with SMTP id m7mr2161016oig.48.1579955261804; Sat, 25 Jan 2020 04:27:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579955261; cv=none; d=google.com; s=arc-20160816; b=Bmfr5/HybF22QLY6madIlDocVB/PbjBLJmEBT5U4D3/UP/APcpcgTtLhQd1eDxf86N 6z6rxt1z+tiR0DiPG/oWzE03wdqWLYETTuERuLPiFeniE5Plaa2orXaa8Jm9NZWq77sV cNMwaFOuVq7aXPhX9Ie0ufizWqphIMH5jVtk+c5JOp1GDZFFG7L81YKkrnK1o70GWOiT TfAUFKXnU+Gy0b+rvUPbEps1fIHl+5gyMXKxviAGTmpwLEYtXE1SvutHSUq3jpkBPVEe OzpGi62VAHvh44rE+r06zDUfFbZYkBMS3GAKeF0ibwL6zeomrcnQ65Q6oOQi/UVlsJ4C TrrQ== 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 :message-id:date:subject:cc:to:from; bh=TBuV6jNY2LWPLwsGZkRY/3lYDHOxyN65ilcdyAmNrAM=; b=qUzddRvcqqbQhModLGmecVshsMhfaEcPGcV4l9KcWZb7JSsS3hWYmrKkd+UenHZ/ml gIRPchemVtJjpyW+wshElVT2D0u5lXJbyuzeaPjXgyYvKpjvDAUnnHlmbilK2MWzxfkN mrw1xSec24ABGUAU71HwOApXgLWh2vDS0canTpyadlWqmNRMz89qvEBHSPgxLleRCLwb uE1XwacgPbu/XKzyD309KbidmnNzXAVW0UWXlszGCMuGrmmkWYbRyNgFQieXu1qD8zmJ aLj/ZdG1sbOn15m6gVwWg7qiBBSPIHWMzCrFfZgaa0vPVAFlI/8OB2dfzf9oSJIvgGWN Epqw== ARC-Authentication-Results: i=1; mx.google.com; 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 w131si1240565oif.240.2020.01.25.04.27.27; Sat, 25 Jan 2020 04:27:41 -0800 (PST) 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; 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 S1729075AbgAYM0X (ORCPT + 99 others); Sat, 25 Jan 2020 07:26:23 -0500 Received: from 2.mo2.mail-out.ovh.net ([188.165.53.149]:37975 "EHLO 2.mo2.mail-out.ovh.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726191AbgAYM0X (ORCPT ); Sat, 25 Jan 2020 07:26:23 -0500 X-Greylist: delayed 1201 seconds by postgrey-1.27 at vger.kernel.org; Sat, 25 Jan 2020 07:26:22 EST Received: from player159.ha.ovh.net (unknown [10.108.35.110]) by mo2.mail-out.ovh.net (Postfix) with ESMTP id 148091C305D for ; Sat, 25 Jan 2020 12:47:12 +0100 (CET) Received: from sk2.org (nat-fit.net.vutbr.cz [147.229.117.36]) (Authenticated sender: steve@sk2.org) by player159.ha.ovh.net (Postfix) with ESMTPSA id F2C3EE9AA732; Sat, 25 Jan 2020 11:46:57 +0000 (UTC) From: Stephen Kitt To: Felix Kuehling , Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , David Zhou , David Airlie , Daniel Vetter , Sumit Semwal Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, Stephen Kitt Subject: [PATCH] amdgpu: use dma-resv API instead of manual kmalloc Date: Sat, 25 Jan 2020 12:46:24 +0100 Message-Id: <20200125114624.2093235-1-steve@sk2.org> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Ovh-Tracer-Id: 3080180672509660668 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedugedrvdejgdeffecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvffufffkofgggfestdekredtredttdenucfhrhhomhepufhtvghphhgvnhcumfhithhtuceoshhtvghvvgesshhkvddrohhrgheqnecukfhppedtrddtrddtrddtpddugeejrddvvdelrdduudejrdefieenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhhouggvpehsmhhtphdqohhuthdphhgvlhhopehplhgrhigvrhduheelrdhhrgdrohhvhhdrnhgvthdpihhnvghtpedtrddtrddtrddtpdhmrghilhhfrhhomhepshhtvghvvgesshhkvddrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrgh Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of hand-coding the dma_resv_list allocation, use dma_resv_list_alloc, which masks the shared_max handling. While we're at it, since we only need shared_count fences, allocate shared_count fences rather than shared_max. (This is the only place in the kernel, outside of dma-resv.c, which touches shared_max. This suggests we'd probably be better off without it!) Signed-off-by: Stephen Kitt --- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c index 888209eb8cec..aec595752200 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c @@ -234,12 +234,11 @@ static int amdgpu_amdkfd_remove_eviction_fence(struct amdgpu_bo *bo, if (!old) return 0; - new = kmalloc(offsetof(typeof(*new), shared[old->shared_max]), - GFP_KERNEL); + new = dma_resv_list_alloc(old->shared_count); if (!new) return -ENOMEM; - /* Go through all the shared fences in the resevation object and sort + /* Go through all the shared fences in the reservation object and sort * the interesting ones to the end of the list. */ for (i = 0, j = old->shared_count, k = 0; i < old->shared_count; ++i) { @@ -253,7 +252,6 @@ static int amdgpu_amdkfd_remove_eviction_fence(struct amdgpu_bo *bo, else RCU_INIT_POINTER(new->shared[k++], f); } - new->shared_max = old->shared_max; new->shared_count = k; /* Install the new fence list, seqcount provides the barriers */ -- 2.24.1