From patchwork Mon May 3 15:57:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Ekstrand X-Patchwork-Id: 12236435 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=unavailable 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 1AEF3C433ED for ; Mon, 3 May 2021 15:58:46 +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 BB39C610C8 for ; Mon, 3 May 2021 15:58:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BB39C610C8 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 577376E903; Mon, 3 May 2021 15:58:26 +0000 (UTC) Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by gabe.freedesktop.org (Postfix) with ESMTPS id A4B0F6E8FA for ; Mon, 3 May 2021 15:58:24 +0000 (UTC) Received: by mail-pj1-x102d.google.com with SMTP id cl24-20020a17090af698b0290157efd14899so2203247pjb.2 for ; Mon, 03 May 2021 08:58:24 -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=zKSYg55UZ+wy9eQuy1FcVlRRqWf3FmEj2RvA7fBG2wk=; b=B/I++ksGOxZ+pVoUft3kSitCfrOqKh7t2jDsfBUVIUlS6HQHV5O3cn0KlBUdbU8Zh1 eQPTiqkyHNzZJ8ESrRHGeKwXM1clJDwQcXO2PJ2teLKC/xMkyz98NKQj0rufTJhMDLKU DhK+ifPEylN+lATerEnwpaYZXitcrPROf1GRO24oDs2xbRjTUHsIfiwmMjzodqCnPPWr PJPFF6AAXI92RI9yL6pPUJPSbwWbTBtQj2m83OEWl6FsHpwqkHZs2nDz6pPoOEuQB/Jt Nyb6/iEPjTFeJ3mdOy5pAUsQVDCfdMvwxLVh32uz/CsUMIAhx50TqqVymGn74J7zzIJ3 pvJw== 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=zKSYg55UZ+wy9eQuy1FcVlRRqWf3FmEj2RvA7fBG2wk=; b=XuJv+Y4e88O/6nkZU9GGi3WdN99ivH6Ks/ZpIgaqXECEoJUQPX9Rp1MoUdJKUzsDHA SvTmnUwGHUvoP/xEaYC0dHWKgrOoqazyoxh4hAnWhbCLa4qq/1qF2Dp00ZIWYArYsaCR Z0hGNpYKV5UKIBVlBBnbmAydoVSna86wde4p4kTz+ru9b6gbOa85AkbFTtapsAauqvIx fnYBvjX1VwazvhrsKifP3qwGAgqJsFwqQ5Bqm0NtUIMW/BW0T7JL58yWJ2TwTFuWHti7 VOI3gmKebb52ci5L8QAAK+ASF/x4mY5KVhOXhRvrrIzcCj8rBcPs9FEYHa+0MehMGDWc hwJg== X-Gm-Message-State: AOAM5332AoUx/glqIQgLqPaJEIbONBKgklVkJEgCpz5t88+temqyUNPJ Np95ziyGvgBCUlpvXHUTAghdwA== X-Google-Smtp-Source: ABdhPJygc86Pw0f6R4ccZB6z4qhmnD0oPAdfngL9DBe3qqmYWdFwWirSGOkwccmAko0w4PABCxhpKg== X-Received: by 2002:a17:90a:1150:: with SMTP id d16mr21865824pje.47.1620057504100; Mon, 03 May 2021 08:58:24 -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.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 May 2021 08:58:23 -0700 (PDT) From: Jason Ekstrand To: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH 17/27] drm/i915/gem: Rework error handling in default_engines Date: Mon, 3 May 2021 10:57:38 -0500 Message-Id: <20210503155748.1961781-18-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: Jason Ekstrand Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Since free_engines works for partially constructed engine sets, we can use the usual goto pattern. Signed-off-by: Jason Ekstrand Reviewed-by: Daniel Vetter --- drivers/gpu/drm/i915/gem/i915_gem_context.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c index 10bd1b6dd1774..ce729e640bbf7 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_context.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c @@ -420,7 +420,7 @@ static struct i915_gem_engines *default_engines(struct i915_gem_context *ctx) { const struct intel_gt *gt = &ctx->i915->gt; struct intel_engine_cs *engine; - struct i915_gem_engines *e; + struct i915_gem_engines *e, *err; enum intel_engine_id id; e = alloc_engines(I915_NUM_ENGINES); @@ -438,18 +438,21 @@ static struct i915_gem_engines *default_engines(struct i915_gem_context *ctx) ce = intel_context_create(engine); if (IS_ERR(ce)) { - __free_engines(e, e->num_engines + 1); - return ERR_CAST(ce); + err = ERR_CAST(ce); + goto free_engines; } intel_context_set_gem(ce, ctx); e->engines[engine->legacy_idx] = ce; - e->num_engines = max(e->num_engines, engine->legacy_idx); + e->num_engines = max(e->num_engines, engine->legacy_idx + 1); } - e->num_engines++; return e; + +free_engines: + free_engines(e); + return err; } void i915_gem_context_release(struct kref *ref)