Received: by 10.223.164.202 with SMTP id h10csp658656wrb; Wed, 22 Nov 2017 13:11:56 -0800 (PST) X-Google-Smtp-Source: AGs4zMZIlc0OopOROPkavQvVbiLm0db8uFRD/zjZtyqRPiO5LjqmwGWiPVqzEjI1EPnwm7TjTayY X-Received: by 10.98.46.7 with SMTP id u7mr20633501pfu.37.1511385116744; Wed, 22 Nov 2017 13:11:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511385116; cv=none; d=google.com; s=arc-20160816; b=ikHtH3J6N1O97uTutGssYNMOPVZn976ADrAO9BR40gj3CLZDjbiOhrkgo4w1xatj1W dMs2Kx5nJN63Cf8j8ec4yLzUd9G+EAogmla64aJzCif/IU3mnWYg4dS5nFlT4QLB6ycs ezBREh8vF9CfClRcAcA8IwW/lXReCxtJmSSmcCaUKXnw5ifvR/YWJwRD3P730y2cfHxW 28a+XHWhe6QI8+NZxHcti9hU/tspS0IJ9nGkZ5QacfuMhAWcHDD5XnSJTKX8m2UmG5uC 5rdqdJtIkZWTUVjlC20n8dUqDTC4sOMDE1/ito0hebEwqXudzHvour3xFpDncf41t/KU hbRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=5Nf9WnRCsYb6dYmVw5P12dw5UAX9mXUp9FH2ROTxTjg=; b=x0TQcE6HpHuLNoE9P+Nrr4gk8uMKE8MO8SScSwn5GlDcOLi3cWe+WDZRl6PFr+8Ztq NH95YQZ3SI/KYE/u17DNwqRwRxe5P2vond+fHZoTd31DRBnzt+bLibpaE86JJfXLdxl5 aRNyyxO/sYtKrwYuhpsASKmjnpBqfDx2VlqkBZGbKHLMkOiQ/Ojje8skG7gQ0GqDkbj+ uocq2Ig28BeXubpchej/izZHT1k9B7MzeGQVTuT8IZDuMas7Pj70XJF32yWK95UuCyFe U4CZOLg3RtHlrsKUFJKAm/U4YH66KurK6JpoAF8lXTtoJVP2meKYNEa8C4vhQIhLGBpj 6qrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=Lxu4Zexc; 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 4si14258646plc.324.2017.11.22.13.11.45; Wed, 22 Nov 2017 13:11:56 -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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=Lxu4Zexc; 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 S1751688AbdKVVKC (ORCPT + 77 others); Wed, 22 Nov 2017 16:10:02 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:43679 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751884AbdKVVIU (ORCPT ); Wed, 22 Nov 2017 16:08:20 -0500 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=5Nf9WnRCsYb6dYmVw5P12dw5UAX9mXUp9FH2ROTxTjg=; b=Lxu4ZexcjfNSXHP7E+hRg4I7j Ao2z1F54eu2Zg6QrqoiwoEn4uHwgu6wlwBHi0YWBor02sb0zfnITVp/w+/TBPjijomZSmZn/VYaOw a9wk3bYGLxA5P/Fv9BL5HvOidgyvDAx6vXqXN3wnBcdvIAY32WLzwrqHH3p8ENzHtAqREh08LG4Wg ySg/zKET40Qp2DtuIbC0JWvPrcT0m9YYCMf9nBKhlFSzzn3MBvbzEVGkTos4qojS3G2jCWoo53WHo GRb6ZNpqsNQolsz00v4cMai7jQq5J+v4vRrDQDGipRcTtGb61rZATXNlIB2Db59sdrqZyE6wgVDgI tKKF9ZGWg==; Received: from willy by bombadil.infradead.org with local (Exim 4.87 #1 (Red Hat Linux)) id 1eHcFo-0007yr-EM; Wed, 22 Nov 2017 21:08:20 +0000 From: Matthew Wilcox To: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Matthew Wilcox Subject: [PATCH 59/62] drm: Replace virtio IDRs with IDAs Date: Wed, 22 Nov 2017 13:07:36 -0800 Message-Id: <20171122210739.29916-60-willy@infradead.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171122210739.29916-1-willy@infradead.org> References: <20171122210739.29916-1-willy@infradead.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Matthew Wilcox These IDRs were only being used to allocate unique numbers, not to look up pointers, so they can use the more space-efficient IDA instead. Signed-off-by: Matthew Wilcox --- drivers/gpu/drm/virtio/virtgpu_drv.h | 6 ++---- drivers/gpu/drm/virtio/virtgpu_kms.c | 18 ++++-------------- drivers/gpu/drm/virtio/virtgpu_vq.c | 12 ++---------- 3 files changed, 8 insertions(+), 28 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h index da2fb585fea4..6852e8bbc1b0 100644 --- a/drivers/gpu/drm/virtio/virtgpu_drv.h +++ b/drivers/gpu/drm/virtio/virtgpu_drv.h @@ -181,8 +181,7 @@ struct virtio_gpu_device { struct kmem_cache *vbufs; bool vqs_ready; - struct idr resource_idr; - spinlock_t resource_idr_lock; + struct ida resource_ida; wait_queue_head_t resp_wq; /* current display info */ @@ -191,8 +190,7 @@ struct virtio_gpu_device { struct virtio_gpu_fence_driver fence_drv; - struct idr ctx_id_idr; - spinlock_t ctx_id_idr_lock; + struct ida ctx_id_ida; bool has_virgl_3d; diff --git a/drivers/gpu/drm/virtio/virtgpu_kms.c b/drivers/gpu/drm/virtio/virtgpu_kms.c index 6400506a06b0..29c08b63d8d3 100644 --- a/drivers/gpu/drm/virtio/virtgpu_kms.c +++ b/drivers/gpu/drm/virtio/virtgpu_kms.c @@ -55,21 +55,13 @@ static void virtio_gpu_config_changed_work_func(struct work_struct *work) static void virtio_gpu_ctx_id_get(struct virtio_gpu_device *vgdev, uint32_t *resid) { - int handle; - - idr_preload(GFP_KERNEL); - spin_lock(&vgdev->ctx_id_idr_lock); - handle = idr_alloc(&vgdev->ctx_id_idr, NULL, 1, 0, 0); - spin_unlock(&vgdev->ctx_id_idr_lock); - idr_preload_end(); + int handle = ida_simple_get(&vgdev->ctx_id_ida, 1, 0, GFP_KERNEL); *resid = handle; } static void virtio_gpu_ctx_id_put(struct virtio_gpu_device *vgdev, uint32_t id) { - spin_lock(&vgdev->ctx_id_idr_lock); - idr_remove(&vgdev->ctx_id_idr, id); - spin_unlock(&vgdev->ctx_id_idr_lock); + ida_simple_remove(&vgdev->ctx_id_ida, id); } static void virtio_gpu_context_create(struct virtio_gpu_device *vgdev, @@ -151,10 +143,8 @@ int virtio_gpu_driver_load(struct drm_device *dev, unsigned long flags) vgdev->dev = dev->dev; spin_lock_init(&vgdev->display_info_lock); - spin_lock_init(&vgdev->ctx_id_idr_lock); - idr_init(&vgdev->ctx_id_idr); - spin_lock_init(&vgdev->resource_idr_lock); - idr_init(&vgdev->resource_idr); + ida_init(&vgdev->ctx_id_ida); + ida_init(&vgdev->resource_ida); init_waitqueue_head(&vgdev->resp_wq); virtio_gpu_init_vq(&vgdev->ctrlq, virtio_gpu_dequeue_ctrl_func); virtio_gpu_init_vq(&vgdev->cursorq, virtio_gpu_dequeue_cursor_func); diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c index 9eb96fb2c147..b35b5f2c056c 100644 --- a/drivers/gpu/drm/virtio/virtgpu_vq.c +++ b/drivers/gpu/drm/virtio/virtgpu_vq.c @@ -41,21 +41,13 @@ void virtio_gpu_resource_id_get(struct virtio_gpu_device *vgdev, uint32_t *resid) { - int handle; - - idr_preload(GFP_KERNEL); - spin_lock(&vgdev->resource_idr_lock); - handle = idr_alloc(&vgdev->resource_idr, NULL, 1, 0, GFP_NOWAIT); - spin_unlock(&vgdev->resource_idr_lock); - idr_preload_end(); + int handle = ida_simple_get(&vgdev->resource_ida, 1, 0, GFP_KERNEL); *resid = handle; } void virtio_gpu_resource_id_put(struct virtio_gpu_device *vgdev, uint32_t id) { - spin_lock(&vgdev->resource_idr_lock); - idr_remove(&vgdev->resource_idr, id); - spin_unlock(&vgdev->resource_idr_lock); + ida_simple_remove(&vgdev->resource_ida, id); } void virtio_gpu_ctrl_ack(struct virtqueue *vq) -- 2.15.0 From 1584784830487613735@xxx Wed Nov 22 16:36:29 +0000 2017 X-GM-THRID: 1584751082013876981 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread