From patchwork Fri Nov 2 21:46:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 10666241 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 D748717D5 for ; Fri, 2 Nov 2018 21:47:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C87A12C3C9 for ; Fri, 2 Nov 2018 21:47:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BD00F2C515; Fri, 2 Nov 2018 21:47:14 +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 446F02C3C9 for ; Fri, 2 Nov 2018 21:47:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A3F7A6E5FA; Fri, 2 Nov 2018 21:47:13 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) by gabe.freedesktop.org (Postfix) with ESMTPS id 207EF6E5FA for ; Fri, 2 Nov 2018 21:47:12 +0000 (UTC) Received: by mail-ed1-x543.google.com with SMTP id w19-v6so2945503eds.1 for ; Fri, 02 Nov 2018 14:47:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=F8EZXxrTXlSuX7Hckkrqwrm4gKGshUGDFqEPQTUw0nA=; b=WutjtO2nUhd9HvT1AIvFfp4cUBJS+GDO1SHaZsk8pgOIPLSX1iAHKGM3IzPo8zFcay wOO1G7ndKEM+NAa6X1uaa1UAY5z8idYOWh/RR2FGaZ4H/a2GbQGEADoCEPrSswTKXpdp WBhBR0LbyzGe6hpSMsYBV1hE6lZURrXGEdXoPsca/ggLR3RrQSU1E54SW6JdjKdzJEfJ L0si8Lg1VNkQXffzjG68iYIP3yXgiYJrvq5vk9CNPDFN7vA3TVfkeGRcxNxQtXptBp1g K9WKolXApxvkLNUTqfOP1JP4NeEHcZJVlQSxa3KK5unBqegMAkn+hh2hxaDKx2OdVUht DOXQ== X-Gm-Message-State: AGRZ1gLOy0TER1No9snZboABXROb6JZWZHqDy+7oYlNYvAo6ww+8Bbh1 vgDLg94YFpfpqhopDpfwHkG51A== X-Google-Smtp-Source: AJdET5eeu46vZymKPpSPYoqjNXbcGyT93zG1A1SdNf6KDVNjAY6UFV1bZPmfQQpB5ZSGmPl9pC0C3w== X-Received: by 2002:a50:f619:: with SMTP id c25-v6mr9483660edn.197.1541195230725; Fri, 02 Nov 2018 14:47:10 -0700 (PDT) Received: from wespe.ffwll.local ([2a02:168:569e:0:7e01:304d:1991:69d]) by smtp.gmail.com with ESMTPSA id i33-v6sm5036644edc.81.2018.11.02.14.47.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 02 Nov 2018 14:47:09 -0700 (PDT) From: Daniel Vetter To: DRI Development Date: Fri, 2 Nov 2018 22:46:59 +0100 Message-Id: <20181102214659.25381-1-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20181102132543.16486-3-daniel.vetter@ffwll.ch> References: <20181102132543.16486-3-daniel.vetter@ffwll.ch> Subject: [Intel-gfx] [PATCH] drm/lease: look at ->universal_planes only once X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Vetter , Intel Graphics Development , Daniel Vetter MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP It's lockless, and userspace might chance it underneath us. That's not really a problem, all userspace gets is a slightly dysfunctional lease with the current code. But this might change, and gcc might decide to reload a few too many times, and then boom. So better safe than sorry. v2: Remove the now unused lessor_priv argument from validate_lease() (Keith). Cc: Keith Packard Cc: Dave Airlie Signed-off-by: Daniel Vetter --- drivers/gpu/drm/drm_lease.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/drm_lease.c b/drivers/gpu/drm/drm_lease.c index 3b0342a45ae9..739d3830173f 100644 --- a/drivers/gpu/drm/drm_lease.c +++ b/drivers/gpu/drm/drm_lease.c @@ -353,9 +353,9 @@ void drm_lease_revoke(struct drm_master *top) } static int validate_lease(struct drm_device *dev, - struct drm_file *lessor_priv, int object_count, - struct drm_mode_object **objects) + struct drm_mode_object **objects, + bool universal_planes) { int o; int has_crtc = -1; @@ -372,14 +372,14 @@ static int validate_lease(struct drm_device *dev, if (objects[o]->type == DRM_MODE_OBJECT_CONNECTOR && has_connector == -1) has_connector = o; - if (lessor_priv->universal_planes) { + if (universal_planes) { if (objects[o]->type == DRM_MODE_OBJECT_PLANE && has_plane == -1) has_plane = o; } } if (has_crtc == -1 || has_connector == -1) return -EINVAL; - if (lessor_priv->universal_planes && has_plane == -1) + if (universal_planes && has_plane == -1) return -EINVAL; return 0; } @@ -393,6 +393,8 @@ static int fill_object_idr(struct drm_device *dev, struct drm_mode_object **objects; u32 o; int ret; + bool universal_planes = READ_ONCE(lessor_priv->universal_planes); + objects = kcalloc(object_count, sizeof(struct drm_mode_object *), GFP_KERNEL); if (!objects) @@ -421,7 +423,8 @@ static int fill_object_idr(struct drm_device *dev, } } - ret = validate_lease(dev, lessor_priv, object_count, objects); + ret = validate_lease(dev, lessor_priv, object_count, objects, + universal_planes); if (ret) { DRM_DEBUG_LEASE("lease validation failed\n"); goto out_free_objects; @@ -448,7 +451,7 @@ static int fill_object_idr(struct drm_device *dev, object_id, ret); goto out_free_objects; } - if (obj->type == DRM_MODE_OBJECT_CRTC && !lessor_priv->universal_planes) { + if (obj->type == DRM_MODE_OBJECT_CRTC && !universal_planes) { struct drm_crtc *crtc = obj_to_crtc(obj); ret = idr_alloc(leases, &drm_lease_idr_object, crtc->primary->base.id, crtc->primary->base.id + 1, GFP_KERNEL); if (ret < 0) {