From patchwork Mon May 3 15:57:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Ekstrand X-Patchwork-Id: 12236441 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=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 4065FC43462 for ; Mon, 3 May 2021 15:58:51 +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 E200761164 for ; Mon, 3 May 2021 15:58:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E200761164 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=jlekstrand.net Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2E8E46E909; Mon, 3 May 2021 15:58:31 +0000 (UTC) Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7F4D66E902 for ; Mon, 3 May 2021 15:58:29 +0000 (UTC) Received: by mail-pf1-x42a.google.com with SMTP id m11so4452295pfc.11 for ; Mon, 03 May 2021 08:58:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jlekstrand-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pGbRfkYO2tB9Xa9gRZykJRU1Fx3KbrdM+GhGgkHKxkI=; b=FRyN2trmreTDe9adJ+VImkN4XiFGBjt97ynebNty4iaxnOqLK1q2Dc5MSsNSl7LgkE 5iZGUdMzRVteeJ1FP14+z6+x/kqF/b9Kcg/rggFdBn3pBRnycnsbX+Kby/IvDzi8em5v k48yqf1sfZHy0/X8P6TP9vCaRkEqwGRSDO0xODjo+sA5bZ7eVJ97hiuh3yiJjHM5ZiFm XB+en/D6aQ8VpQum1gDOABRqT3/dXUQ559ZqyEX8jZPJDmFIsnzi9zsfn5XhbOino6c2 Mp055Fvged267kK+HBeB+yltW3YMptonOQaKaG2MzYBiSXYJNtqgul6x13VRhilUivI8 7hLA== 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:mime-version:content-transfer-encoding; bh=pGbRfkYO2tB9Xa9gRZykJRU1Fx3KbrdM+GhGgkHKxkI=; b=TBy6z/1w0xhWQe96GfkIZIseQfAoxovYS6oe8OKAjrMzdBcsMvXP556KfozNwnAJlt gWFLJxaW5lXyn8vkWIk+au35V8s9ei1GjwKq5k7VDajYrXYcNgiAxcy9GWomy9QiRZ6A WlujodbGWZgLCDL8JappEvdFRKWmJRpzbC785ezbDZrWY4/649zjTTjmDzw7bBBiWVq4 qVI/6NRkbtmr+6vhXsRQgbh7Mt1VQ7ETblPQTKnffX5wmQrxyLSTYKGEOKEu9z5MpMSh DOWBF4UP8CwDV5NWXsjhmG0ASmLcRkmp6AkDALzmT52eS5Kswr+7nxZ5Hk6A0YnZUh5Q 7EXA== X-Gm-Message-State: AOAM532Z8E56ZaKW4pvHU8qyJd62i+vJ6eUxoMnQJ8smIUui4O0DPQCT 4zec0IHAAg/h4s64KhWKbJ9Jzw== X-Google-Smtp-Source: ABdhPJxGqXOW9Y8n1eLyuF5BewQvk+9IImzJVuvB67uZ6gPkLB+RcoFXnipE4PaP8PxI23MutqKpPQ== X-Received: by 2002:a63:1d5d:: with SMTP id d29mr19493025pgm.398.1620057509054; Mon, 03 May 2021 08:58:29 -0700 (PDT) Received: from omlet.com (jfdmzpr05-ext.jf.intel.com. [134.134.139.74]) by smtp.gmail.com with ESMTPSA id gf21sm9783296pjb.20.2021.05.03.08.58.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 May 2021 08:58:28 -0700 (PDT) From: Jason Ekstrand To: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH 20/27] drm/i915/gem: Return an error ptr from context_lookup Date: Mon, 3 May 2021 10:57:41 -0500 Message-Id: <20210503155748.1961781-21-jason@jlekstrand.net> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210503155748.1961781-1-jason@jlekstrand.net> References: <20210503155748.1961781-1-jason@jlekstrand.net> MIME-Version: 1.0 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: , Cc: Daniel Vetter , Jason Ekstrand Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" We're about to start doing lazy context creation which means contexts get created in i915_gem_context_lookup and we may start having more errors than -ENOENT. Signed-off-by: Jason Ekstrand Reviewed-by: Daniel Vetter --- drivers/gpu/drm/i915/gem/i915_gem_context.c | 12 ++++++------ drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c | 4 ++-- drivers/gpu/drm/i915/i915_drv.h | 2 +- drivers/gpu/drm/i915/i915_perf.c | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c index aa4edfbf7ed48..d84d704534128 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_context.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c @@ -2646,8 +2646,8 @@ int i915_gem_context_getparam_ioctl(struct drm_device *dev, void *data, int ret = 0; ctx = i915_gem_context_lookup(file_priv, args->ctx_id); - if (!ctx) - return -ENOENT; + if (IS_ERR(ctx)) + return PTR_ERR(ctx); switch (args->param) { case I915_CONTEXT_PARAM_GTT_SIZE: @@ -2715,8 +2715,8 @@ int i915_gem_context_setparam_ioctl(struct drm_device *dev, void *data, int ret; ctx = i915_gem_context_lookup(file_priv, args->ctx_id); - if (!ctx) - return -ENOENT; + if (IS_ERR(ctx)) + return PTR_ERR(ctx); ret = ctx_setparam(file_priv, ctx, args); @@ -2735,8 +2735,8 @@ int i915_gem_context_reset_stats_ioctl(struct drm_device *dev, return -EINVAL; ctx = i915_gem_context_lookup(file->driver_priv, args->ctx_id); - if (!ctx) - return -ENOENT; + if (IS_ERR(ctx)) + return PTR_ERR(ctx); /* * We opt for unserialised reads here. This may result in tearing diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c index 7024adcd5cf15..de14b26f3b2d5 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c @@ -739,8 +739,8 @@ static int eb_select_context(struct i915_execbuffer *eb) struct i915_gem_context *ctx; ctx = i915_gem_context_lookup(eb->file->driver_priv, eb->args->rsvd1); - if (unlikely(!ctx)) - return -ENOENT; + if (unlikely(IS_ERR(ctx))) + return PTR_ERR(ctx); eb->gem_context = ctx; if (rcu_access_pointer(ctx->vm)) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 8571c5c1509a7..004ed0e59c999 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -1851,7 +1851,7 @@ i915_gem_context_lookup(struct drm_i915_file_private *file_priv, u32 id) ctx = NULL; rcu_read_unlock(); - return ctx; + return ctx ? ctx : ERR_PTR(-ENOENT); } /* i915_gem_evict.c */ diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c index 85ad62dbabfab..b86ed03f6a705 100644 --- a/drivers/gpu/drm/i915/i915_perf.c +++ b/drivers/gpu/drm/i915/i915_perf.c @@ -3414,10 +3414,10 @@ i915_perf_open_ioctl_locked(struct i915_perf *perf, struct drm_i915_file_private *file_priv = file->driver_priv; specific_ctx = i915_gem_context_lookup(file_priv, ctx_handle); - if (!specific_ctx) { + if (IS_ERR(specific_ctx)) { DRM_DEBUG("Failed to look up context with ID %u for opening perf stream\n", ctx_handle); - ret = -ENOENT; + ret = PTR_ERR(specific_ctx); goto err; } }