Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CAD6CC432BE for ; Thu, 2 Sep 2021 09:11:56 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5F9E960F90 for ; Thu, 2 Sep 2021 09:11:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5F9E960F90 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=emersion.fr Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AE3F26E497; Thu, 2 Sep 2021 09:11:55 +0000 (UTC) Received: from mail-40136.protonmail.ch (mail-40136.protonmail.ch [185.70.40.136]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2EB036E497 for ; Thu, 2 Sep 2021 09:11:54 +0000 (UTC) Date: Thu, 02 Sep 2021 09:11:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=emersion.fr; s=protonmail; t=1630573911; bh=IeKFquLOkYg8xBkDVgO6TgOkTaCu1dEVC4MZVq4Iehg=; h=Date:To:From:Cc:Reply-To:Subject:From; b=EnLOlea6mrfkReBiuHGYkthOpSorShO45AaS5qeDjyb6RI/K90yLSX8FSrDL1QMoL ralyKD+W/hTrxlma0EFmcK0hXjFSnHYEUfiLpDf3Ru0w8sLCgxMpAoDCkfTL16Yn/M LgQpEKHkReXKV4kkXHECkbfPO+GJrxJStiMB2+tI+Az1rhHWz1XutC3MOLvlbgSyKv Zd0b+kYN2lYdAbRTJaGI9BobUDFsppEr+XdV/uTcIAVFux+bspPpeF7tMlF1wwxLC1 Hv2d8QxGvtjVcz8uomZC4S3vBo4hLMR4sGSa+FzqkDd5b+8VHu36O9JjGwqHXbPDxD 5MXXkspY5vGdQ== To: dri-devel@lists.freedesktop.org From: Simon Ser Cc: Daniel Vetter , Daniel Stone , Pekka Paalanen , =?utf-8?Q?Michel_D=C3=A4nzer?= , Emil Velikov , Keith Packard , Boris Brezillon , Dave Airlie Subject: [PATCH] drm/lease: allow empty leases Message-ID: <20210902091126.2312-1-contact@emersion.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Simon Ser Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This can be used to create a separate DRM file description, thus creating a new GEM handle namespace. See [1]. Example usage in wlroots is available at [2]. [1]: https://gitlab.freedesktop.org/mesa/drm/-/merge_requests/110 [2]: https://github.com/swaywm/wlroots/pull/3158 Signed-off-by: Simon Ser Cc: Daniel Vetter Cc: Daniel Stone Cc: Pekka Paalanen Cc: Michel D=C3=A4nzer Cc: Emil Velikov Cc: Keith Packard Cc: Boris Brezillon Cc: Dave Airlie --- drivers/gpu/drm/drm_lease.c | 39 +++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/drivers/gpu/drm/drm_lease.c b/drivers/gpu/drm/drm_lease.c index dee4f24a1808..d72c2fac0ff1 100644 --- a/drivers/gpu/drm/drm_lease.c +++ b/drivers/gpu/drm/drm_lease.c @@ -489,12 +489,6 @@ int drm_mode_create_lease_ioctl(struct drm_device *dev= , =09if (!drm_core_check_feature(dev, DRIVER_MODESET)) =09=09return -EOPNOTSUPP; =20 -=09/* need some objects */ -=09if (cl->object_count =3D=3D 0) { -=09=09DRM_DEBUG_LEASE("no objects in lease\n"); -=09=09return -EINVAL; -=09} - =09if (cl->flags && (cl->flags & ~(O_CLOEXEC | O_NONBLOCK))) { =09=09DRM_DEBUG_LEASE("invalid flags\n"); =09=09return -EINVAL; @@ -510,23 +504,26 @@ int drm_mode_create_lease_ioctl(struct drm_device *de= v, =20 =09object_count =3D cl->object_count; =20 -=09object_ids =3D memdup_user(u64_to_user_ptr(cl->object_ids), -=09=09=09array_size(object_count, sizeof(__u32))); -=09if (IS_ERR(object_ids)) { -=09=09ret =3D PTR_ERR(object_ids); -=09=09goto out_lessor; -=09} - +=09/* Handle leased objects, if any */ =09idr_init(&leases); +=09if (object_count !=3D 0) { +=09=09object_ids =3D memdup_user(u64_to_user_ptr(cl->object_ids), +=09=09=09=09=09 array_size(object_count, sizeof(__u32))); +=09=09if (IS_ERR(object_ids)) { +=09=09=09ret =3D PTR_ERR(object_ids); +=09=09=09idr_destroy(&leases); +=09=09=09goto out_lessor; +=09=09} =20 -=09/* fill and validate the object idr */ -=09ret =3D fill_object_idr(dev, lessor_priv, &leases, -=09=09=09 object_count, object_ids); -=09kfree(object_ids); -=09if (ret) { -=09=09DRM_DEBUG_LEASE("lease object lookup failed: %i\n", ret); -=09=09idr_destroy(&leases); -=09=09goto out_lessor; +=09=09/* fill and validate the object idr */ +=09=09ret =3D fill_object_idr(dev, lessor_priv, &leases, +=09=09=09=09 object_count, object_ids); +=09=09kfree(object_ids); +=09=09if (ret) { +=09=09=09DRM_DEBUG_LEASE("lease object lookup failed: %i\n", ret); +=09=09=09idr_destroy(&leases); +=09=09=09goto out_lessor; +=09=09} =09} =20 =09/* Allocate a file descriptor for the lease */ --=20 2.33.0