From patchwork Thu Feb 21 18:42:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 10825449 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3D0001390 for ; Fri, 22 Feb 2019 08:21:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F45A31B2B for ; Fri, 22 Feb 2019 08:21:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 23BD831AFD; Fri, 22 Feb 2019 08:21:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BD07B31B13 for ; Fri, 22 Feb 2019 08:21:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B451489336; Fri, 22 Feb 2019 08:20:55 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by gabe.freedesktop.org (Postfix) with ESMTPS id B2F8C89127 for ; Thu, 21 Feb 2019 18:42:35 +0000 (UTC) Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1gwtIp-0000gh-7S; Thu, 21 Feb 2019 18:42:35 +0000 From: Matthew Wilcox To: dri-devel@lists.freedesktop.org Subject: [PATCH 22/34] drm/i915: Convert object_idr to IDA Date: Thu, 21 Feb 2019 10:42:03 -0800 Message-Id: <20190221184226.2149-44-willy@infradead.org> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20190221184226.2149-1-willy@infradead.org> References: <20190221184226.2149-1-willy@infradead.org> X-Mailman-Approved-At: Fri, 22 Feb 2019 08:20:52 +0000 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Gw9d4kAxPh0AgxqFVtAWtJ2mEnUoEhj2AYFcWkZw7BI=; b=uliE2S1+ONZ+AJfDQ9Dl4iOhI iCFm36DzHYOVN8JnRd3spBydD3d3G7OSCkcAvWYQ8FIQV7hNjG07FQ9jskHguOBdee+dNs44zAXVO TKdk2GQEvbJDt73uRmajwy4CkG3qUTmU987XGCLuiZY4SSlYNC/B380087sKwmrdS27QHYVjFnX/Q uuHzkOI+Q8vUbQGTC4wlpJFf6J/24QLlssNPV6Etku65ST+aRgFn5HuU+y40tdgzgOmDBEcTHz70p Lps2r9cCY5CIYCL1SJcGJFbcKTQTe3PnAgqXYD1ZVrHSV3THIyaVf5bz6JClFBvdv6jBKuaN3b+If S1T4HyVkw==; X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Matthew Wilcox MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP I suspect dmabuf_obj_list_head and object_ids should be combined into a single xarray, but that's a job for later. Signed-off-by: Matthew Wilcox --- drivers/gpu/drm/i915/gvt/dmabuf.c | 7 +++---- drivers/gpu/drm/i915/gvt/gvt.h | 2 +- drivers/gpu/drm/i915/gvt/vgpu.c | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/i915/gvt/dmabuf.c b/drivers/gpu/drm/i915/gvt/dmabuf.c index 51ed99a37803..9fb60461affc 100644 --- a/drivers/gpu/drm/i915/gvt/dmabuf.c +++ b/drivers/gpu/drm/i915/gvt/dmabuf.c @@ -96,8 +96,7 @@ static void dmabuf_gem_object_free(struct kref *kref) struct intel_vgpu_dmabuf_obj, list); if (dmabuf_obj == obj) { intel_gvt_hypervisor_put_vfio_device(vgpu); - idr_remove(&vgpu->object_idr, - dmabuf_obj->dmabuf_id); + ida_free(&vgpu->object_ids, dmabuf_obj->dmabuf_id); kfree(dmabuf_obj->info); kfree(dmabuf_obj); list_del(pos); @@ -431,7 +430,7 @@ int intel_vgpu_query_plane(struct intel_vgpu *vgpu, void *args) dmabuf_obj->vgpu = vgpu; - ret = idr_alloc(&vgpu->object_idr, dmabuf_obj, 1, 0, GFP_NOWAIT); + ret = ida_alloc_min(&vgpu->object_ids, 1, GFP_NOWAIT); if (ret < 0) goto out_free_info; gfx_plane_info->dmabuf_id = ret; @@ -553,7 +552,7 @@ void intel_vgpu_dmabuf_cleanup(struct intel_vgpu *vgpu) list); dmabuf_obj->vgpu = NULL; - idr_remove(&vgpu->object_idr, dmabuf_obj->dmabuf_id); + ida_free(&vgpu->object_ids, dmabuf_obj->dmabuf_id); intel_gvt_hypervisor_put_vfio_device(vgpu); list_del(pos); diff --git a/drivers/gpu/drm/i915/gvt/gvt.h b/drivers/gpu/drm/i915/gvt/gvt.h index e5bf20dcdd7d..ffb181a086be 100644 --- a/drivers/gpu/drm/i915/gvt/gvt.h +++ b/drivers/gpu/drm/i915/gvt/gvt.h @@ -231,7 +231,7 @@ struct intel_vgpu { struct list_head dmabuf_obj_list_head; struct mutex dmabuf_lock; - struct idr object_idr; + struct ida object_ids; struct completion vblank_done; diff --git a/drivers/gpu/drm/i915/gvt/vgpu.c b/drivers/gpu/drm/i915/gvt/vgpu.c index 6ec5d16f4e06..c1db9a6a1281 100644 --- a/drivers/gpu/drm/i915/gvt/vgpu.c +++ b/drivers/gpu/drm/i915/gvt/vgpu.c @@ -383,7 +383,7 @@ static struct intel_vgpu *__intel_gvt_create_vgpu(struct intel_gvt *gvt, mutex_init(&vgpu->dmabuf_lock); INIT_LIST_HEAD(&vgpu->dmabuf_obj_list_head); xa_init(&vgpu->page_track); - idr_init(&vgpu->object_idr); + ida_init(&vgpu->object_ids); intel_vgpu_init_cfg_space(vgpu, param->primary); ret = intel_vgpu_init_mmio(vgpu);