Received: by 10.223.164.202 with SMTP id h10csp658203wrb; Wed, 22 Nov 2017 13:11:27 -0800 (PST) X-Google-Smtp-Source: AGs4zMYlpkH7E1WZFcXHfKlHX09OsVLOJHWePZxx2sLD8F5kUvJA+EzyTso0coWzTME9ygbEa/C8 X-Received: by 10.84.165.171 with SMTP id y40mr23396873pla.362.1511385087604; Wed, 22 Nov 2017 13:11:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511385087; cv=none; d=google.com; s=arc-20160816; b=VgcDEbd23hE7pE8ve/4dPAJOtZ4lNHE8+ke05lt8pRkk0qmdxDvjbqilHc/4tvVLpG VbIDCMT3Eqj4tKWbuRdxLXUGW9cDxlrzVYl4ZXzc1JYDP4+eQf4pZF9b3AN226Csxkmj 47gFSM5eYfQiEWeOLWxLDd91wePUhHUprggwa4Ja09RXNnzzWZNLKl+SJljICcKA1PXy PQvDCKg5G21BYSYVdOoXCOpNay/DHYFAe8yekW6KyK4VKmyKHaaiRZCtmd6GFAD/C/Zc EtMJKy7vWjAB6BojzXVKSYMS/LaUuLwM3sDo4dpbLhdb0uk3GRMU9yl4bzAiSBLj9iGv 7AyA== 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=bKcexCjSOVsepkAE8mtqF4L1OHEpAkOu/LOPd0WaYTE=; b=bJopkgpYqp6AzQ4MlwTttburYsz6YkmkUbCyzhLdeXIFLxBEK+TSSiadH2ZB/LaGMI FTogUYrCKu/wdSor3PXvxZK0s+oWYlRVW0A3TSX6lg3kcZTicVVs8omv2wMEMiQlRKF1 lzA63g0drjuoRZYQnVPcRiAcM/ezwI9loLw1JrjcokL5yDvZVnb2aFm+U9aHsVV4JodX sjlZuW8Jb2Wdwd+DR8Qybt34r2YZ/Bwj2Y5/zizHScEYiYHJralE4bFx8GyKzlICsm1W l+lGvW35VLN8JJE4MKpd0+4uFHCnXHwlfIIxI/mTIetG/LsSO6YlIqYNOF1XNoXh5NCF LgUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=FL7CB0Uo; 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 bb8si3324584plb.287.2017.11.22.13.11.16; Wed, 22 Nov 2017 13:11:27 -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=FL7CB0Uo; 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 S1751987AbdKVVKE (ORCPT + 77 others); Wed, 22 Nov 2017 16:10:04 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:36350 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751883AbdKVVIU (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=bKcexCjSOVsepkAE8mtqF4L1OHEpAkOu/LOPd0WaYTE=; b=FL7CB0UoSo5NG9CzWcYDFb4MN lPyvhGvRuosGKwMn58No3sMNgyVN3LL+RmvdxAAb1v8zWRjBM+YecCsVRQ68XFy9Tkwj+rclslkOz imdpHO+a/61tu6CxE4e7GkQzbckwxi1dTRP/G55IP7KJZDU5rkAjiREuF5u9t6Rx6/F1JnrW1bTVa hYhIp3hQGNII8xsqbvnOuCojBkMYULf+zQPNOvL7ibmr58yByflkE+J9+SC8bXfNwcTjfVb4QYu/r DbhdK411oRoUnCkIj7yW2r/MgoxZjxpMMdFuR/ymzAhdWOuecJu9ohguTqwjH73Ecb6DHX8Y7U85U 4TMrJvKJQ==; Received: from willy by bombadil.infradead.org with local (Exim 4.87 #1 (Red Hat Linux)) id 1eHcFo-0007yi-CC; 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 58/62] drm: Remove qxl driver IDR locks Date: Wed, 22 Nov 2017 13:07:35 -0800 Message-Id: <20171122210739.29916-59-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 By switching to the internal IDR lock, we can get rid of the idr_preload calls. Signed-off-by: Matthew Wilcox --- drivers/gpu/drm/qxl/qxl_cmd.c | 26 +++++++------------------- drivers/gpu/drm/qxl/qxl_drv.h | 2 -- drivers/gpu/drm/qxl/qxl_kms.c | 2 -- drivers/gpu/drm/qxl/qxl_release.c | 12 +++--------- 4 files changed, 10 insertions(+), 32 deletions(-) diff --git a/drivers/gpu/drm/qxl/qxl_cmd.c b/drivers/gpu/drm/qxl/qxl_cmd.c index c0fb52c6d4ca..b1cecc38ef5f 100644 --- a/drivers/gpu/drm/qxl/qxl_cmd.c +++ b/drivers/gpu/drm/qxl/qxl_cmd.c @@ -451,37 +451,29 @@ int qxl_surface_id_alloc(struct qxl_device *qdev, int idr_ret; int count = 0; again: - idr_preload(GFP_ATOMIC); - spin_lock(&qdev->surf_id_idr_lock); - idr_ret = idr_alloc(&qdev->surf_id_idr, NULL, 1, 0, GFP_NOWAIT); - spin_unlock(&qdev->surf_id_idr_lock); - idr_preload_end(); + idr_ret = idr_alloc(&qdev->surf_id_idr, NULL, 1, 0, GFP_ATOMIC); if (idr_ret < 0) return idr_ret; handle = idr_ret; if (handle >= qdev->rom->n_surfaces) { count++; - spin_lock(&qdev->surf_id_idr_lock); idr_remove(&qdev->surf_id_idr, handle); - spin_unlock(&qdev->surf_id_idr_lock); qxl_reap_surface_id(qdev, 2); goto again; } surf->surface_id = handle; - spin_lock(&qdev->surf_id_idr_lock); + idr_lock(&qdev->surf_id_idr); qdev->last_alloced_surf_id = handle; - spin_unlock(&qdev->surf_id_idr_lock); + idr_unlock(&qdev->surf_id_idr); return 0; } void qxl_surface_id_dealloc(struct qxl_device *qdev, uint32_t surface_id) { - spin_lock(&qdev->surf_id_idr_lock); idr_remove(&qdev->surf_id_idr, surface_id); - spin_unlock(&qdev->surf_id_idr_lock); } int qxl_hw_surface_alloc(struct qxl_device *qdev, @@ -534,9 +526,7 @@ int qxl_hw_surface_alloc(struct qxl_device *qdev, qxl_release_fence_buffer_objects(release); surf->hw_surf_alloc = true; - spin_lock(&qdev->surf_id_idr_lock); idr_replace(&qdev->surf_id_idr, surf, surf->surface_id); - spin_unlock(&qdev->surf_id_idr_lock); return 0; } @@ -559,9 +549,7 @@ int qxl_hw_surface_dealloc(struct qxl_device *qdev, surf->surf_create = NULL; /* remove the surface from the idr, but not the surface id yet */ - spin_lock(&qdev->surf_id_idr_lock); idr_replace(&qdev->surf_id_idr, NULL, surf->surface_id); - spin_unlock(&qdev->surf_id_idr_lock); surf->hw_surf_alloc = false; id = surf->surface_id; @@ -650,9 +638,9 @@ static int qxl_reap_surface_id(struct qxl_device *qdev, int max_to_reap) mutex_lock(&qdev->surf_evict_mutex); again: - spin_lock(&qdev->surf_id_idr_lock); + idr_lock(&qdev->surf_id_idr); start = qdev->last_alloced_surf_id + 1; - spin_unlock(&qdev->surf_id_idr_lock); + idr_unlock(&qdev->surf_id_idr); for (i = start; i < start + qdev->rom->n_surfaces; i++) { void *objptr; @@ -661,9 +649,9 @@ static int qxl_reap_surface_id(struct qxl_device *qdev, int max_to_reap) /* this avoids the case where the objects is in the idr but has been evicted half way - its makes the idr lookup atomic with the eviction */ - spin_lock(&qdev->surf_id_idr_lock); + idr_lock(&qdev->surf_id_idr); objptr = idr_find(&qdev->surf_id_idr, surfid); - spin_unlock(&qdev->surf_id_idr_lock); + idr_unlock(&qdev->surf_id_idr); if (!objptr) continue; diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h index 08752c0ffb35..07378adbf4e8 100644 --- a/drivers/gpu/drm/qxl/qxl_drv.h +++ b/drivers/gpu/drm/qxl/qxl_drv.h @@ -255,7 +255,6 @@ struct qxl_device { spinlock_t release_lock; struct idr release_idr; uint32_t release_seqno; - spinlock_t release_idr_lock; struct mutex async_io_mutex; unsigned int last_sent_io_cmd; @@ -277,7 +276,6 @@ struct qxl_device { struct mutex update_area_mutex; struct idr surf_id_idr; - spinlock_t surf_id_idr_lock; int last_alloced_surf_id; struct mutex surf_evict_mutex; diff --git a/drivers/gpu/drm/qxl/qxl_kms.c b/drivers/gpu/drm/qxl/qxl_kms.c index c5716a0ca3b8..276a5b25ae8e 100644 --- a/drivers/gpu/drm/qxl/qxl_kms.c +++ b/drivers/gpu/drm/qxl/qxl_kms.c @@ -204,11 +204,9 @@ int qxl_device_init(struct qxl_device *qdev, GFP_KERNEL); idr_init(&qdev->release_idr); - spin_lock_init(&qdev->release_idr_lock); spin_lock_init(&qdev->release_lock); idr_init(&qdev->surf_id_idr); - spin_lock_init(&qdev->surf_id_idr_lock); mutex_init(&qdev->async_io_mutex); diff --git a/drivers/gpu/drm/qxl/qxl_release.c b/drivers/gpu/drm/qxl/qxl_release.c index a6da6fa6ad58..c327b3441b63 100644 --- a/drivers/gpu/drm/qxl/qxl_release.c +++ b/drivers/gpu/drm/qxl/qxl_release.c @@ -142,12 +142,10 @@ qxl_release_alloc(struct qxl_device *qdev, int type, release->surface_release_id = 0; INIT_LIST_HEAD(&release->bos); - idr_preload(GFP_KERNEL); - spin_lock(&qdev->release_idr_lock); - handle = idr_alloc(&qdev->release_idr, release, 1, 0, GFP_NOWAIT); + handle = idr_alloc(&qdev->release_idr, release, 1, 0, GFP_KERNEL); + idr_lock(&qdev->release_idr); release->base.seqno = ++qdev->release_seqno; - spin_unlock(&qdev->release_idr_lock); - idr_preload_end(); + idr_unlock(&qdev->release_idr); if (handle < 0) { kfree(release); *ret = NULL; @@ -184,9 +182,7 @@ qxl_release_free(struct qxl_device *qdev, if (release->surface_release_id) qxl_surface_id_dealloc(qdev, release->surface_release_id); - spin_lock(&qdev->release_idr_lock); idr_remove(&qdev->release_idr, release->id); - spin_unlock(&qdev->release_idr_lock); if (release->base.ops) { WARN_ON(list_empty(&release->bos)); @@ -392,9 +388,7 @@ struct qxl_release *qxl_release_from_id_locked(struct qxl_device *qdev, { struct qxl_release *release; - spin_lock(&qdev->release_idr_lock); release = idr_find(&qdev->release_idr, id); - spin_unlock(&qdev->release_idr_lock); if (!release) { DRM_ERROR("failed to find id in release_idr\n"); return NULL; -- 2.15.0 From 1584799691714587892@xxx Wed Nov 22 20:32:42 +0000 2017 X-GM-THRID: 1584799691714587892 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread